Commit 624cb7b2 authored by Lorenzo Stoakes's avatar Lorenzo Stoakes Committed by yipeng xiang
Browse files

UPSTREAM: mm/madvise: process_madvise() drop capability check if same mm

In commit 96cfe2c0 ("mm/madvise: replace ptrace attach requirement for
process_madvise") process_madvise() was updated to require the caller to
possess the CAP_SYS_NICE capability to perform the operation, in addition
to a check against PTRACE_MODE_READ performed by mm_access().

The mm_access() function explicitly checks to see if the address space of
the process being referenced is the current one, in which case no check is
performed.

We, however, do not do this when checking the CAP_SYS_NICE capability. This
means that we insist on the caller possessing this capability in order to
perform madvise() operations on its own address space, which seems
nonsensical.

Simply add a check to allow for an invocation of this function with pidfd
set to the current process without elevation.

Link: https://lkml.kernel.org/r/20240913140628.77047-1-lorenzo.stoakes@oracle.com


Fixes: 96cfe2c0 ("mm/madvise: replace ptrace attach requirement for process_madvise")
Signed-off-by: default avatarLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: default avatarLiam R. Howlett <Liam.Howlett@Oracle.com>
Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
Acked-by: default avatarShakeel Butt <shakeel.butt@linux.dev>
Acked-by: default avatarDavid Rientjes <rientjes@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>

Bug: 442327187
Bug: 442693928
(cherry picked from commit 22af8caf)
Change-Id: I212b57c1129505ac0e5f921980d0960b93eba766
Signed-off-by: default avataryipeng xiang <yipengxiang@honor.corp-partner.google.com>
(cherry picked from commit bdb23d0a)
parent a2a7e6d8
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment