From: Casey Schaufler <casey@schaufler-ca.com>
To: casey@schaufler-ca.com, paul@paul-moore.com,
linux-security-module@vger.kernel.org
Cc: jmorris@namei.org, serge@hallyn.com, keescook@chromium.org,
john.johansen@canonical.com, penguin-kernel@i-love.sakura.ne.jp,
stephen.smalley.work@gmail.com, linux-kernel@vger.kernel.org,
selinux@vger.kernel.org, mic@digikod.net
Subject: [PATCH v2 5/6] LSM: secctx provider check on release
Date: Mon, 14 Oct 2024 08:14:49 -0700 [thread overview]
Message-ID: <20241014151450.73674-6-casey@schaufler-ca.com> (raw)
In-Reply-To: <20241014151450.73674-1-casey@schaufler-ca.com>
Verify that the LSM releasing the secctx is the LSM that
allocated it. This was not necessary when only one LSM could
create a secctx, but once there can be more than one it is.
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
---
security/apparmor/secid.c | 10 ++--------
security/selinux/hooks.c | 10 ++--------
2 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/security/apparmor/secid.c b/security/apparmor/secid.c
index 5d92fc3ab8b4..974f802cbe5a 100644
--- a/security/apparmor/secid.c
+++ b/security/apparmor/secid.c
@@ -122,14 +122,8 @@ int apparmor_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid)
void apparmor_release_secctx(struct lsm_context *cp)
{
- /*
- * stacking scaffolding:
- * When it is possible for more than one LSM to provide a
- * release hook, do this check:
- * if (cp->id == LSM_ID_APPARMOR || cp->id == LSM_ID_UNDEF)
- */
-
- kfree(cp->context);
+ if (cp->id == LSM_ID_APPARMOR)
+ kfree(cp->context);
}
/**
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 79776a5e651d..b9286c2c5efe 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -6640,14 +6640,8 @@ static int selinux_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid)
static void selinux_release_secctx(struct lsm_context *cp)
{
- /*
- * stacking scaffolding:
- * When it is possible for more than one LSM to provide a
- * release hook, do this check:
- * if (cp->id == LSM_ID_SELINUX || cp->id == LSM_ID_UNDEF)
- */
-
- kfree(cp->context);
+ if (cp->id == LSM_ID_SELINUX)
+ kfree(cp->context);
}
static void selinux_inode_invalidate_secctx(struct inode *inode)
--
2.46.0
next prev parent reply other threads:[~2024-10-14 15:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20241014151450.73674-1-casey.ref@schaufler-ca.com>
2024-10-14 15:14 ` [PATCH v2 0/6] LSM: Replace secctx/len pairs with lsm_context Casey Schaufler
2024-10-14 15:14 ` [PATCH v2 1/6] LSM: Ensure the correct LSM context releaser Casey Schaufler
2024-10-15 3:40 ` sergeh
2024-10-21 23:39 ` Paul Moore
2024-10-21 23:58 ` Casey Schaufler
2024-10-22 16:25 ` Paul Moore
2024-10-14 15:14 ` [PATCH v2 2/6] LSM: Replace context+len with lsm_context Casey Schaufler
2024-10-14 15:14 ` [PATCH v2 3/6] LSM: Use lsm_context in security_inode_getsecctx Casey Schaufler
2024-10-14 15:14 ` [PATCH v2 4/6] LSM: lsm_context in security_dentry_init_security Casey Schaufler
2024-10-21 23:39 ` Paul Moore
2024-10-22 0:00 ` Casey Schaufler
2024-10-22 16:35 ` Paul Moore
2024-10-22 16:46 ` Casey Schaufler
2024-10-14 15:14 ` Casey Schaufler [this message]
2024-10-21 23:39 ` [PATCH v2 5/6] LSM: secctx provider check on release Paul Moore
2024-10-22 0:05 ` Casey Schaufler
2024-10-22 16:28 ` Paul Moore
2024-10-14 15:14 ` [PATCH v2 6/6] LSM: Use lsm_context in security_inode_notifysecctx Casey Schaufler
2024-10-14 21:29 ` [PATCH v2 0/6] LSM: Replace secctx/len pairs with lsm_context Serge E. Hallyn
2024-10-14 21:35 ` Serge E. Hallyn
2024-10-14 21:54 ` Casey Schaufler
2024-10-14 21:47 ` Casey Schaufler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241014151450.73674-6-casey@schaufler-ca.com \
--to=casey@schaufler-ca.com \
--cc=jmorris@namei.org \
--cc=john.johansen@canonical.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@digikod.net \
--cc=paul@paul-moore.com \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=selinux@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=stephen.smalley.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®