[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211228170910.623156-5-wander@redhat.com>
Date: Tue, 28 Dec 2021 14:09:08 -0300
From: Wander Lairson Costa <wander@...hat.com>
To: Alexander Viro <viro@...iv.linux.org.uk>,
Eric Biederman <ebiederm@...ssion.com>,
Kees Cook <keescook@...omium.org>,
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>,
Helge Deller <deller@....de>,
Laurent Vivier <laurent@...ier.eu>,
YunQiang Su <ysu@...ecomp.com>,
Wander Lairson Costa <wander@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Alexey Gladkov <legion@...nel.org>,
Jens Axboe <axboe@...nel.dk>,
David Hildenbrand <david@...hat.com>,
Rolf Eike Beer <eb@...ix.com>,
linux-fsdevel@...r.kernel.org (open list:FILESYSTEMS (VFS and
infrastructure)), linux-kernel@...r.kernel.org (open list)
Subject: [PATCH RFC v2 4/4] exec: only set the suid flag if the current proc isn't root
The goal of PF_SUID flag is to check if it is safe to coredump the
process. If the current process is already privileged, there is no
point in performing security checks because the name image is a
set-uid process.
Because of that, we don't set the suid flag if the forked process
already runs as root.
Signed-off-by: Wander Lairson Costa <wander@...hat.com>
---
fs/exec.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/exec.c b/fs/exec.c
index 81d6ab9a4f64..1a3458c6c9b7 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1310,7 +1310,11 @@ int begin_new_exec(struct linux_binprm * bprm)
me->flags &= ~(PF_RANDOMIZE | PF_FORKNOEXEC | PF_KTHREAD |
PF_NOFREEZE | PF_NO_SETAFFINITY);
- if (bprm->suid_bin)
+ /*
+ * We set the PF_SUID flags for security reasons. There is no
+ * point in setting it if the parent is root.
+ */
+ if (bprm->suid_bin && !capable(CAP_SYS_ADMIN))
me->flags |= PF_SUID;
flush_thread();
--
2.27.0
Powered by blists - more mailing lists