proc: add config & param to block forcing mem writes
BugLink: https://bugs.launchpad.net/bugs/2089884 [ Upstream commit 41e8149c8892ed1962bd15350b3c3e6e90cba7f4 ] This adds a Kconfig option and boot param to allow removing the FOLL_FORCE flag from /proc/pid/mem write calls because it can be abused. The traditional forcing behavior is kept as default because it can break GDB and some other use cases. Previously we tried a more sophisticated approach allowing distributions to fine-tune /proc/pid/mem behavior, however that got NAK-ed by Linus [1], who prefers this simpler approach with semantics also easier to understand for users. Link: https://lore.kernel.org/lkml/CAHk-=wiGWLChxYmUA5HrT5aopZrB7_2VTa0NLZcxORgkUe5tEQ@mail.gmail.com/ [1] Cc: Doug Anderson <dianders@chromium.org> Cc: Jeff Xu <jeffxu@google.com> Cc: Jann Horn <jannh@google.com> Cc: Kees Cook <kees@kernel.org> Cc: Ard Biesheuvel <ardb@kernel.org> Cc: Christian Brauner <brauner@kernel.org> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> Link: https://lore.kernel.org/r/20240802080225.89408-1-adrian.ratiu@collabora.com Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
This commit is contained in:
committed by
Mehmet Basaran
parent
1295751c07
commit
120c82bc09
@@ -28,6 +28,38 @@ config SECURITY_PERF_EVENTS_RESTRICT
|
||||
perf_event_open syscall will be permitted unless it is
|
||||
changed.
|
||||
|
||||
choice
|
||||
prompt "Allow /proc/pid/mem access override"
|
||||
default PROC_MEM_ALWAYS_FORCE
|
||||
help
|
||||
Traditionally /proc/pid/mem allows users to override memory
|
||||
permissions for users like ptrace, assuming they have ptrace
|
||||
capability.
|
||||
|
||||
This allows people to limit that - either never override, or
|
||||
require actual active ptrace attachment.
|
||||
|
||||
Defaults to the traditional behavior (for now)
|
||||
|
||||
config PROC_MEM_ALWAYS_FORCE
|
||||
bool "Traditional /proc/pid/mem behavior"
|
||||
help
|
||||
This allows /proc/pid/mem accesses to override memory mapping
|
||||
permissions if you have ptrace access rights.
|
||||
|
||||
config PROC_MEM_FORCE_PTRACE
|
||||
bool "Require active ptrace() use for access override"
|
||||
help
|
||||
This allows /proc/pid/mem accesses to override memory mapping
|
||||
permissions for active ptracers like gdb.
|
||||
|
||||
config PROC_MEM_NO_FORCE
|
||||
bool "Never"
|
||||
help
|
||||
Never override memory mapping permissions
|
||||
|
||||
endchoice
|
||||
|
||||
config SECURITY
|
||||
bool "Enable different security models"
|
||||
depends on SYSFS
|
||||
|
||||
Reference in New Issue
Block a user