audit: fix potential double free on error path from fsnotify_add_inode_mark
ANBZ: #9547 commitad982c3be4
upstream. 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:7b12932340
("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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: YiLin.Li <YiLin.Li@linux.alibaba.com> Reviewed-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> Link: https://gitee.com/anolis/cloud-kernel/pulls/3511
This commit is contained in:
parent
f63fad409f
commit
3bc6a54f69
|
@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
|
|||
|
||||
ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, true);
|
||||
if (ret < 0) {
|
||||
audit_mark->path = NULL;
|
||||
fsnotify_put_mark(&audit_mark->mark);
|
||||
audit_mark = ERR_PTR(ret);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue