Skip to content

Commit ad982c3

Browse files
gscuipcmoore
authored andcommitted
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: [email protected] Fixes: 7b12932 ("fsnotify: Add group pointer in fsnotify_init_mark()") Signed-off-by: Gaosheng Cui <[email protected]> Reviewed-by: Jan Kara <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent 1c23f9e commit ad982c3

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

kernel/audit_fsnotify.c

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
102102

103103
ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, 0);
104104
if (ret < 0) {
105+
audit_mark->path = NULL;
105106
fsnotify_put_mark(&audit_mark->mark);
106107
audit_mark = ERR_PTR(ret);
107108
}

0 commit comments

Comments
 (0)