]> git.baikalelectronics.ru Git - kernel.git/commit
audit: fix potential double free on error path from fsnotify_add_inode_mark
authorGaosheng Cui <cuigaosheng1@huawei.com>
Mon, 22 Aug 2022 02:29:05 +0000 (10:29 +0800)
committerPaul Moore <paul@paul-moore.com>
Mon, 22 Aug 2022 22:50:06 +0000 (18:50 -0400)
commitd542d726cd19c86257546f887005cab15c975f56
tree8aef373f519457b05afa7f6cf105ac2646a84324
parentab10ff5e8831a0b67cd316b656c1de8c860c2d7c
audit: fix potential double free on error path from fsnotify_add_inode_mark

Audit_alloc_mark() assign pathname to audit_mark->path, on error path
from fsnotify_add_inode_mark(), fsnotify_put_mark will free memory
of audit_mark->path, but the caller of audit_alloc_mark will free
the pathname again, so there will be double free problem.

Fix this by resetting audit_mark->path to NULL pointer on error path
from fsnotify_add_inode_mark().

Cc: stable@vger.kernel.org
Fixes: f0ae08f14fd51 ("fsnotify: Add group pointer in fsnotify_init_mark()")
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Paul Moore <paul@paul-moore.com>
kernel/audit_fsnotify.c