[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250312212148.274205-3-ryan.lee@canonical.com>
Date: Wed, 12 Mar 2025 14:21:42 -0700
From: Ryan Lee <ryan.lee@...onical.com>
To: linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
apparmor@...ts.ubuntu.com,
linux-security-module@...r.kernel.org,
selinux@...r.kernel.org
Cc: Ryan Lee <ryan.lee@...onical.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>,
Jan Kara <jack@...e.cz>,
John Johansen <john.johansen@...onical.com>,
Paul Moore <paul@...l-moore.com>,
James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
Mickaël Salaün <mic@...ikod.net>,
Günther Noack <gnoack@...gle.com>,
Stephen Smalley <stephen.smalley.work@...il.com>,
Ondrej Mosnacek <omosnace@...hat.com>,
Casey Schaufler <casey@...aufler-ca.com>,
Kentaro Takeda <takedakn@...data.co.jp>,
Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
Subject: [RFC PATCH 2/6] apparmor: explicitly skip mediation of O_PATH file descriptors
Previously, we saw O_PATH fds only when mediating fd inheritance on exec,
but because they would have no request associated with them, we would
unconditionally let them be inherited. Until we have better handling of
O_PATH fds, preserve the existing behavior of unconditionally allowing
them.
Signed-off-by: Ryan Lee <ryan.lee@...onical.com>
---
security/apparmor/lsm.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index 11ace667cbbf..2349a1dd41f4 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -647,6 +647,16 @@ static int apparmor_file_open(struct file *file)
return 0;
}
+ /*
+ * Preserve the behavior of O_PATH fd creation not being mediated.
+ *
+ * TODO: we weren't handling O_PATH fds in aa_inherit_files anyways
+ * (all-zero request -> fds unconditionally inherited), so proper
+ * mediation of those will require changes in multiple places.
+ */
+ if (file->f_flags & O_PATH)
+ return 0;
+
label = aa_get_newest_cred_label_condref(file->f_cred, &needput);
if (!unconfined(label)) {
struct mnt_idmap *idmap = file_mnt_idmap(file);
--
2.43.0
base-kernel: v6.14-rc6
Powered by blists - more mailing lists