diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2021-06-22 02:08:30 +0300 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2021-06-22 16:55:41 +0300 |
commit | 399f8dd9a866e107639eabd3c1979cd526ca3a98 (patch) | |
tree | 5e9cfbb7c122d0216fbbcadf9dcd5f4ee32864f3 /scripts/selinux | |
parent | 13311e74253fe64329390df80bed3f07314ddd61 (diff) | |
download | linux-399f8dd9a866e107639eabd3c1979cd526ca3a98.tar.xz |
signal: Prevent sigqueue caching after task got released
syzbot reported a memory leak related to sigqueue caching.
The assumption that a task cannot cache a sigqueue after the signal handler
has been dropped and exit_task_sigqueue_cache() has been invoked turns out
to be wrong.
Such a task can still invoke release_task(other_task), which cleans up the
signals of 'other_task' and ends up in sigqueue_cache_or_free(), which in
turn will cache the signal because task->sigqueue_cache is NULL. That's
obviously bogus because nothing will free the cached signal of that task
anymore, so the cached item is leaked.
This happens when e.g. the last non-leader thread exits and reaps the
zombie leader.
Prevent this by setting tsk::sigqueue_cache to an error pointer value in
exit_task_sigqueue_cache() which forces any subsequent invocation of
sigqueue_cache_or_free() from that task to hand the sigqueue back to the
kmemcache.
Add comments to all relevant places.
Fixes: 4bad58ebc8bc ("signal: Allow tasks to cache one sigqueue struct")
Reported-by: syzbot+0bac5fec63d4f399ba98@syzkaller.appspotmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Link: https://lore.kernel.org/r/878s32g6j5.ffs@nanos.tec.linutronix.de
Diffstat (limited to 'scripts/selinux')
0 files changed, 0 insertions, 0 deletions