ksmbd: fix reference count leak in smb_check_perm_dacl()
authorXin Xiong <xiongx18@fudan.edu.cn>
Fri, 29 Apr 2022 08:11:22 +0000 (16:11 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 16:36:06 +0000 (18:36 +0200)
commitcf824b95c12a1abacadbc2d069931963221a3414
treebc9977f9661ddeb25360ca33563bd23eff55a0a6
parentfffde6d1c67920b5675402f1ce3eed3765c79e8e
ksmbd: fix reference count leak in smb_check_perm_dacl()

[ Upstream commit d21a580dafc69aa04f46e6099616146a536b0724 ]

The issue happens in a specific path in smb_check_perm_dacl(). When
"id" and "uid" have the same value, the function simply jumps out of
the loop without decrementing the reference count of the object
"posix_acls", which is increased by get_acl() earlier. This may
result in memory leaks.

Fix it by decreasing the reference count of "posix_acls" before
jumping to label "check_access_bits".

Fixes: 777cad1604d6 ("ksmbd: remove select FS_POSIX_ACL in Kconfig")
Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/ksmbd/smbacl.c