inotify: stop kernel memory leak on file creation failure
Subsystems (3)
PATCH 1/2 inotify: stop kernel memory leak on file creation failure
If inotify_init is unable to allocate a new file for the new inotify group we leak the new group. This patch drops the reference on the group on file allocation failure.
Reported-by Vegard Nossum <[email protected]>
Signed-off-by Eric Paris <[email protected]>
--- fs/notify/inotify/inotify_user.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
fs/notify/inotify/inotify_user.c +1 -0
@@ -752,6 +752,7 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)if (ret >=0 )return ret; +fsnotify_put_group (group);atomic_dec (&user->inotify_devs); out_free_uid:free_uid (user);
Signature · 1 line
1.7.1
PATCH 2/2 fanotify: do not leak user reference on allocation failure
If fanotify_init is unable to allocate a new fsnotify group it will return but will not drop its reference on the associated user struct. Drop that reference on error.
Reported-by Vegard Nossum <[email protected]>
Signed-off-by Eric Paris <[email protected]>
--- fs/notify/fanotify/fanotify_user.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
fs/notify/fanotify/fanotify_user.c +3 -1
@@ -695,8 +695,10 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)/* fsnotify_alloc_group takes a ref. Dropped in fanotify_release */ group =fsnotify_alloc_group (&fanotify_fsnotify_ops); -if (IS_ERR (group)) +if (IS_ERR (group)) { +free_uid (user);return PTR_ERR (group); + } group->fanotify_data.user = user;atomic_inc (&user->fanotify_listeners);
Signature · 1 line
1.7.1