[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] Update kernel base to 6.6.146 - #2027
Conversation
[ Upstream commit cd3f846 ] mm_access() can return NULL if the mm is not found, but this is handled the same as an error in all callers, with some translating this into an -ESRCH error. Only proc_mem_open() returns NULL if no mm is found, however in this case it is clearer and makes more sense to explicitly handle the error. Additionally we take the opportunity to refactor the function to eliminate unnecessary nesting. Simplify things by simply returning -ESRCH if no mm is found - this both eliminates confusing use of the IS_ERR_OR_NULL() macro, and simplifies callers which would return -ESRCH by returning this error directly. [lorenzo.stoakes@oracle.com: prefer neater pointer error comparison] Link: https://lkml.kernel.org/r/2fae1834-749a-45e1-8594-5e5979cf7103@lucifer.local Link: https://lkml.kernel.org/r/20240924201023.193135-1-lorenzo.stoakes@oracle.com Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Suggested-by: Arnd Bergmann <arnd@arndb.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit d8a1f7420d2d58fcbde479bd72d0900fb512cb2d) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit ae068b67619673618814059f96802314e08050d1) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Reviewer's GuideUpdate kernel base to 6.6.146 and adjust mm_access error handling semantics, propagating the new behavior across proc, madvise, and process_vm syscalls. Sequence diagram for updated mm_access handling in proc_mem_opensequenceDiagram
participant proc_mem_open
participant get_proc_task
participant mm_access
participant task_struct
proc_mem_open->>get_proc_task: get_proc_task(inode)
get_proc_task-->>proc_mem_open: task
alt no_task
proc_mem_open-->>proc_mem_open: return ERR_PTR_ESRCH
else task_exists
proc_mem_open->>mm_access: mm_access(task, mode|PTRACE_MODE_FSCREDS)
mm_access-->>proc_mem_open: mm
proc_mem_open->>task_struct: put_task_struct(task)
alt mm_is_ERR_ESRCH
proc_mem_open-->>proc_mem_open: return NULL
else mm_is_other_error
proc_mem_open-->>proc_mem_open: return mm_error
else mm_is_valid
proc_mem_open->>mm_access: mmgrab(mm)
proc_mem_open->>mm_access: mmput(mm)
proc_mem_open-->>proc_mem_open: return mm
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Avenger-285714 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
proc_mem_open, convertingERR_PTR(-ESRCH)back toNULLwhile returning other errors asERR_PTRmakes the mm_access semantics less uniform; consider consistently using error pointers and adjusting callers instead of special-casing ESRCH. - The comparison
mm == ERR_PTR(-ESRCH)inproc_mem_openrelies on pointer equality with an ERR_PTR value; usingIS_ERR(mm)together withPTR_ERR(mm) == -ESRCHwould be clearer and less brittle.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `proc_mem_open`, converting `ERR_PTR(-ESRCH)` back to `NULL` while returning other errors as `ERR_PTR` makes the mm_access semantics less uniform; consider consistently using error pointers and adjusting callers instead of special-casing ESRCH.
- The comparison `mm == ERR_PTR(-ESRCH)` in `proc_mem_open` relies on pointer equality with an ERR_PTR value; using `IS_ERR(mm)` together with `PTR_ERR(mm) == -ESRCH` would be clearer and less brittle.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
Updates the Deepin kernel tree to Linux 6.6.146 and aligns mm_access() semantics with upstream expectations by returning ERR_PTR(-ESRCH) when a task has no mm_struct, with corresponding caller adjustments across /proc and process memory syscalls.
Changes:
- Bump kernel
SUBLEVELfrom 6.6.145 to 6.6.146. - Change
mm_access()to returnERR_PTR(-ESRCH)(instead ofNULL) when nomm_structis present. - Update
process_vm_*,process_madvise, and/procpaths to treatmm_access()results as error-pointers (and preserve/proc“empty for no-mm task” behavior where applicable).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| mm/process_vm_access.c | Updates mm_access() return handling to rely on IS_ERR()/PTR_ERR() only. |
| mm/madvise.c | Updates process_madvise to treat mm_access() failures as error-pointers only. |
| kernel/fork.c | Changes mm_access() to return ERR_PTR(-ESRCH) when get_task_mm() returns NULL. |
| fs/proc/base.c | Adjusts /proc helpers and map_files logic to the new mm_access() error-pointer semantics, preserving “empty” behavior for no-mm tasks. |
| Makefile | Bumps kernel sublevel to 6.6.146. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (IS_ERR(mm)) | ||
| return mm == ERR_PTR(-ESRCH) ? NULL : mm; |
Update kernel base to 6.6.146.
Summary by Sourcery
Adjust mm_access error semantics and update callers while bumping kernel sublevel to 6.6.146.
Bug Fixes:
Build: