Skip to content

Commit

Permalink
smack: Revert "smackfs: Added check catlen"
Browse files Browse the repository at this point in the history
This reverts commit ccfd889

The indicated commit
* does not describe the problem that change tries to solve
* has programming issues
* introduces a bug: forever clears NETLBL_SECATTR_MLS_CAT
         in (struct smack_known *)skp->smk_netlabel.flags

Reverting the commit to reapproach original problem

Signed-off-by: Konstantin Andreev <[email protected]>
Signed-off-by: Casey Schaufler <[email protected]>
  • Loading branch information
goongas authored and cschaufler committed Feb 16, 2025
1 parent bf9f14c commit c7fb50c
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions security/smack/smackfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,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, *new_cat = NULL;
struct netlbl_lsm_catmap *old_cat;
struct smack_known *skp;
struct netlbl_lsm_secattr ncats;
char mapcatset[SMK_CIPSOLEN];
Expand Down Expand Up @@ -901,19 +901,8 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,

smack_catset_bit(cat, mapcatset);
}
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);
}

rc = smk_netlbl_mls(maplevel, mapcatset, &ncats, SMK_CIPSOLEN);
if (rc >= 0) {
old_cat = skp->smk_netlabel.attr.mls.cat;
rcu_assign_pointer(skp->smk_netlabel.attr.mls.cat, ncats.attr.mls.cat);
Expand Down

0 comments on commit c7fb50c

Please sign in to comment.