Skip to content

Commit 77bc1bb

Browse files
committed
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
2 parents 291a73a + ccfd889 commit 77bc1bb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

security/smack/smackfs.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ static int smk_open_cipso(struct inode *inode, struct file *file)
830830
static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
831831
size_t count, loff_t *ppos, int format)
832832
{
833-
struct netlbl_lsm_catmap *old_cat;
833+
struct netlbl_lsm_catmap *old_cat, *new_cat = NULL;
834834
struct smack_known *skp;
835835
struct netlbl_lsm_secattr ncats;
836836
char mapcatset[SMK_CIPSOLEN];
@@ -917,8 +917,19 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
917917

918918
smack_catset_bit(cat, mapcatset);
919919
}
920-
921-
rc = smk_netlbl_mls(maplevel, mapcatset, &ncats, SMK_CIPSOLEN);
920+
ncats.flags = 0;
921+
if (catlen == 0) {
922+
ncats.attr.mls.cat = NULL;
923+
ncats.attr.mls.lvl = maplevel;
924+
new_cat = netlbl_catmap_alloc(GFP_ATOMIC);
925+
if (new_cat)
926+
new_cat->next = ncats.attr.mls.cat;
927+
ncats.attr.mls.cat = new_cat;
928+
skp->smk_netlabel.flags &= ~(1U << 3);
929+
rc = 0;
930+
} else {
931+
rc = smk_netlbl_mls(maplevel, mapcatset, &ncats, SMK_CIPSOLEN);
932+
}
922933
if (rc >= 0) {
923934
old_cat = skp->smk_netlabel.attr.mls.cat;
924935
skp->smk_netlabel.attr.mls.cat = ncats.attr.mls.cat;

0 commit comments

Comments
 (0)