smackfs: Fix use-after-free in netlbl_catmap_walk()
authorPawan Gupta <pawan.kumar.gupta@linux.intel.com>
Sun, 29 Aug 2021 06:41:40 +0000 (23:41 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 13:03:53 +0000 (14:03 +0100)
commit3fac6feca95fd7e8029c72be874bd62796f2f9cb
tree87a35c3cb3545907c2c4533aa77c92c31800453c
parent02ddf26d849dd241e22a8713e15e243d851199cc
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@google.com/

Reported-by: syzbot+3f91de0b813cc3d19a80@syzkaller.appspotmail.com
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/smack/smackfs.c