UBUNTU: SAUCE: apparmor4.0.0 [29/90]: LSM stacking v39: LSM: secctx provider check on release

BugLink: http://bugs.launchpad.net/bugs/2028253

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>
(cherry picked from commit 2e26924a9155d6e5d5de80f66e77192b951e0a99
https://git.launchpad.net/~apparmor-dev/ubuntu-kernel-next)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
This commit is contained in:
Casey Schaufler
2023-08-20 14:45:09 -07:00
committed by Paolo Pisati
parent 3378b3ca12
commit 3f8660dcc1
2 changed files with 4 additions and 16 deletions
+2 -8
View File
@@ -142,14 +142,8 @@ int apparmor_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid)
void apparmor_release_secctx(struct lsmcontext *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);
}
/**
+2 -8
View File
@@ -6672,14 +6672,8 @@ static int selinux_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid)
static void selinux_release_secctx(struct lsmcontext *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)