The patch titled futex: fix reference leak has been added to the -mm tree. Its filename is futex-fix-reference-leak.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find out what to do about this The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/ ------------------------------------------------------ Subject: futex: fix reference leak From: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Catalin noticed that (38d47c1b7075: futex: rely on get_user_pages() for shared futexes) caused an mm_struct leak. Some tracing with the function graph tracer quickly pointed out that futex_wait() has exit paths with unbalanced reference counts. This regression was discovered by kmemleak. Signed-off-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx> Tested-by: "Pallipadi, Venkatesh" <venkatesh.pallipadi@xxxxxxxxx> Tested-by: Catalin Marinas <catalin.marinas@xxxxxxx> Reported-by: Catalin Marinas <catalin.marinas@xxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- kernel/futex.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff -puN kernel/futex.c~futex-fix-reference-leak kernel/futex.c --- a/kernel/futex.c~futex-fix-reference-leak +++ a/kernel/futex.c @@ -1289,18 +1289,23 @@ retry: */ /* If we were woken (and unqueued), we succeeded, whatever. */ - if (!unqueue_me(&q)) - return 0; - if (rem) - return -ETIMEDOUT; + if (!unqueue_me(&q)) { + ret = 0; + goto out_put_key; + } + if (rem) { + ret = -ETIMEDOUT; + goto out_put_key; + } /* * We expect signal_pending(current), but another thread may * have handled it for us already. */ - if (!abs_time) - return -ERESTARTSYS; - else { + if (!abs_time) { + ret = -ERESTARTSYS; + goto out_put_key; + } else { struct restart_block *restart; restart = ¤t_thread_info()->restart_block; restart->fn = futex_wait_restart; @@ -1314,11 +1319,13 @@ retry: restart->futex.flags |= FLAGS_SHARED; if (clockrt) restart->futex.flags |= FLAGS_CLOCKRT; - return -ERESTART_RESTARTBLOCK; + ret = -ERESTART_RESTARTBLOCK; + goto out_put_key; } out_unlock_put_key: queue_unlock(&q, hb); +out_put_key: put_futex_key(fshared, &q.key); out: _ Patches currently in -mm which might be from peterz@xxxxxxxxxxxxx are mm-fix-dirty_bytes-dirty_background_bytes-sysctls-on-64bit-arches.patch mm-fix-dirty_bytes-dirty_background_bytes-sysctls-on-64bit-arches-fix.patch futex-fix-reference-leak.patch linux-next.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html