[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211227223436.317091-1-wander@redhat.com>
Date: Mon, 27 Dec 2021 19:34:31 -0300
From: Wander Lairson Costa <wander@...hat.com>
To: Alexander Viro <viro@...iv.linux.org.uk>,
Ingo Molnar <mingo@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Juri Lelli <juri.lelli@...hat.com>,
Vincent Guittot <vincent.guittot@...aro.org>,
Dietmar Eggemann <dietmar.eggemann@....com>,
Steven Rostedt <rostedt@...dmis.org>,
Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Wander Lairson Costa <wander@...hat.com>,
Laurent Vivier <laurent@...ier.eu>,
YunQiang Su <ysu@...ecomp.com>, Helge Deller <deller@....de>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
Alexey Gladkov <legion@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Jens Axboe <axboe@...nel.dk>,
Rafael Aquini <aquini@...hat.com>,
Phil Auld <pauld@...hat.com>, Rolf Eike Beer <eb@...ix.com>,
Muchun Song <songmuchun@...edance.com>,
linux-fsdevel@...r.kernel.org (open list:FILESYSTEMS (VFS and
infrastructure)), linux-kernel@...r.kernel.org (open list)
Subject: [PATCH RFC 0/4] coredump: mitigate privilege escalation of process coredump
A set-uid executable might be a vector to privilege escalation if the
system configures the coredump file name pattern as a relative
directory destiny. The full description of the vulnerability and
a demonstration of how we can exploit it can be found at [1].
This patch series adds a PF_SUID flag to the process in execve if it is
set-[ug]id binary and elevates the new image's privileges.
In the do_coredump function, we check if:
1) We have the SUID_FLAG set
2) We have CAP_SYS_ADMIN (the process might have decreased its
privileges)
3) The current directory is owned by root (the current code already
checks for core_pattern being a relative path).
4) non-privileged users don't have permission to write to the current
directory.
If all four conditions match, we set the need_suid_safe flag.
An alternative implementation (and more elegant IMO) would be saving
the fsuid and fsgid of the process in the task_struct before loading the
new image to the memory. But this approach would add eight bytes to all
task_struct instances where only a tiny fraction of the processes need
it and under a configuration that not all (most?) distributions don't
adopt by default.
Wander Lairson Costa (4):
exec: add a flag indicating if an exec file is a suid/sgid
process: add the PF_SUID flag
coredump: mitigate privilege escalation of process coredump
exec: only set the suid flag if the current proc isn't root
fs/coredump.c | 15 +++++++++++++++
fs/exec.c | 10 ++++++++++
include/linux/binfmts.h | 6 +++++-
include/linux/sched.h | 1 +
kernel/fork.c | 2 ++
5 files changed, 33 insertions(+), 1 deletion(-)
--
2.27.0
Powered by blists - more mailing lists