Patch "smackfs: Fix use-after-free in netlbl_catmap_walk()" has been added to the 4.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    smackfs: Fix use-after-free in netlbl_catmap_walk()

to the 4.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     smackfs-fix-use-after-free-in-netlbl_catmap_walk.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 216edc62ab75b4d56805476a075a8090d80b58f1
Author: Pawan Gupta <pawan.kumar.gupta@xxxxxxxxxxxxxxx>
Date:   Sat Aug 28 23:41:40 2021 -0700

    smackfs: Fix use-after-free in netlbl_catmap_walk()
    
    [ Upstream commit 0817534ff9ea809fac1322c5c8c574be8483ea57 ]
    
    Syzkaller reported use-after-free bug as described in [1]. The bug is
    triggered when smk_set_cipso() tries to free stale category bitmaps
    while there are concurrent reader(s) using the same bitmaps.
    
    Wait for RCU grace period to finish before freeing the category bitmaps
    in smk_set_cipso(). This makes sure that there are no more readers using
    the stale bitmaps and freeing them should be safe.
    
    [1] https://lore.kernel.org/netdev/000000000000a814c505ca657a4e@xxxxxxxxxx/
    
    Reported-by: syzbot+3f91de0b813cc3d19a80@xxxxxxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Pawan Gupta <pawan.kumar.gupta@xxxxxxxxxxxxxxx>
    Signed-off-by: Casey Schaufler <casey@xxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 009e83ee2d002..25705a72d31bc 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -859,6 +859,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 smack_known *skp;
 	struct netlbl_lsm_secattr ncats;
 	char mapcatset[SMK_CIPSOLEN];
@@ -948,9 +949,11 @@ static ssize_t smk_set_cipso(struct file *file, const char __user *buf,
 
 	rc = smk_netlbl_mls(maplevel, mapcatset, &ncats, SMK_CIPSOLEN);
 	if (rc >= 0) {
-		netlbl_catmap_free(skp->smk_netlabel.attr.mls.cat);
+		old_cat = skp->smk_netlabel.attr.mls.cat;
 		skp->smk_netlabel.attr.mls.cat = ncats.attr.mls.cat;
 		skp->smk_netlabel.attr.mls.lvl = ncats.attr.mls.lvl;
+		synchronize_rcu();
+		netlbl_catmap_free(old_cat);
 		rc = count;
 	}
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux