]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
taskstats: don't allow duplicate entries in listener mode
authorVasiliy Kulikov <segoon@openwall.com>
Mon, 27 Jun 2011 23:18:11 +0000 (16:18 -0700)
committerAndi Kleen <ak@linux.intel.com>
Mon, 1 Aug 2011 20:54:58 +0000 (13:54 -0700)
commited5ba3843ac94bee8cd5681ab13645dfc65d3b40
tree1b86846386e2b6a9b35b1bd31ca176863ec6957d
parent95cb3f2eefee6dd22468318a0d986598f6e9827d
taskstats: don't allow duplicate entries in listener mode

commit 26c4caea9d697043cc5a458b96411b86d7f6babd upstream.

Currently a single process may register exit handlers unlimited times.
It may lead to a bloated listeners chain and very slow process
terminations.

Eg after 10KK sent TASKSTATS_CMD_ATTR_REGISTER_CPUMASKs ~300 Mb of
kernel memory is stolen for the handlers chain and "time id" shows 2-7
seconds instead of normal 0.003.  It makes it possible to exhaust all
kernel memory and to eat much of CPU time by triggerring numerous exits
on a single CPU.

The patch limits the number of times a single process may register
itself on a single CPU to one.

One little issue is kept unfixed - as taskstats_exit() is called before
exit_files() in do_exit(), the orphaned listener entry (if it was not
explicitly deregistered) is kept until the next someone's exit() and
implicit deregistration in send_cpu_listeners().  So, if a process
registered itself as a listener exits and the next spawned process gets
the same pid, it would inherit taskstats attributes.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
kernel/taskstats.c