summaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2023-02-22 12:52:59 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2023-02-22 12:52:59 -0800
commit77bc1bb18463a7fa3742accaddf31845655edf66 (patch)
tree979970e996c7a9b46caab13ce2ccb375c7f56e7d /security
parent291a73a8e63a6a00f2f6863989cd1652a1f5b9a1 (diff)
parentccfd889acb06eab10b98deb4b5eef0ec74157ea0 (diff)
downloadlinux-stable-77bc1bb18463a7fa3742accaddf31845655edf66.tar.gz
linux-stable-77bc1bb18463a7fa3742accaddf31845655edf66.tar.bz2
linux-stable-77bc1bb18463a7fa3742accaddf31845655edf66.zip
Merge tag 'Smack-for-6.3' of https://github.com/cschaufler/smack-next
Pull smack update from Casey Schaufler: "One fix for resetting CIPSO labeling" * tag 'Smack-for-6.3' of https://github.com/cschaufler/smack-next: smackfs: Added check catlen
Diffstat (limited to 'security')
-rw-r--r--security/smack/smackfs.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 4b58526450d4..5590eaad241b 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -830,7 +830,7 @@ static int smk_open_cipso(struct inode *inode, struct file *file)
static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
size_t count, loff_t *ppos, int format)
{
- struct netlbl_lsm_catmap *old_cat;
+ struct netlbl_lsm_catmap *old_cat, *new_cat = NULL;
struct smack_known *skp;
struct netlbl_lsm_secattr ncats;
char mapcatset[SMK_CIPSOLEN];
@@ -917,8 +917,19 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
smack_catset_bit(cat, mapcatset);
}
-
- rc = smk_netlbl_mls(maplevel, mapcatset, &ncats, SMK_CIPSOLEN);
+ ncats.flags = 0;
+ if (catlen == 0) {
+ ncats.attr.mls.cat = NULL;
+ ncats.attr.mls.lvl = maplevel;
+ new_cat = netlbl_catmap_alloc(GFP_ATOMIC);
+ if (new_cat)
+ new_cat->next = ncats.attr.mls.cat;
+ ncats.attr.mls.cat = new_cat;
+ skp->smk_netlabel.flags &= ~(1U << 3);
+ rc = 0;
+ } else {
+ rc = smk_netlbl_mls(maplevel, mapcatset, &ncats, SMK_CIPSOLEN);
+ }
if (rc >= 0) {
old_cat = skp->smk_netlabel.attr.mls.cat;
skp->smk_netlabel.attr.mls.cat = ncats.attr.mls.cat;