linux-sg2042/include/linux/sched
David Howells 29e44f4535 watch_queue: Limit the number of watches a user can hold
Impose a limit on the number of watches that a user can hold so that
they can't use this mechanism to fill up all the available memory.

This is done by putting a counter in user_struct that's incremented when
a watch is allocated and decreased when it is released.  If the number
exceeds the RLIMIT_NOFILE limit, the watch is rejected with EAGAIN.

This can be tested by the following means:

 (1) Create a watch queue and attach it to fd 5 in the program given - in
     this case, bash:

	keyctl watch_session /tmp/nlog /tmp/gclog 5 bash

 (2) In the shell, set the maximum number of files to, say, 99:

	ulimit -n 99

 (3) Add 200 keyrings:

	for ((i=0; i<200; i++)); do keyctl newring a$i @s || break; done

 (4) Try to watch all of the keyrings:

	for ((i=0; i<200; i++)); do echo $i; keyctl watch_add 5 %:a$i || break; done

     This should fail when the number of watches belonging to the user hits
     99.

 (5) Remove all the keyrings and all of those watches should go away:

	for ((i=0; i<200; i++)); do keyctl unlink %:a$i; done

 (6) Kill off the watch queue by exiting the shell spawned by
     watch_session.

Fixes: c73be61ced ("pipe: Add general notification queue support")
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-08-17 09:39:18 -07:00
..
autogroup.h
clock.h
coredump.h
cpufreq.h sched/fair: Remove redundant call to cpufreq_update_util() 2020-01-17 10:19:22 +01:00
cputime.h posix-cpu-timers: Move state tracking to struct posix_cputimers 2019-08-28 11:50:42 +02:00
deadline.h cpusets: Rebuild root domain deadline accounting information 2019-07-25 15:55:01 +02:00
debug.h kernel: rename show_stack_loglvl() => show_stack() 2020-06-09 09:39:13 -07:00
hotplug.h
idle.h
init.h
isolation.h isolcpus: Affine unbound kernel threads to housekeeping cpus 2020-06-15 14:10:03 +02:00
jobctl.h task_work: teach task_work_add() to do signal_wake_up() 2020-06-30 12:18:08 -06:00
loadavg.h sched: nohz: stop passing around unused "ticks" parameter. 2020-07-22 10:22:04 +02:00
mm.h include/linux/sched/mm.h: optimize current_gfp_context() 2020-08-12 10:57:57 -07:00
nohz.h timers/nohz: Update NOHZ load in remote tick 2020-01-28 21:36:44 +01:00
numa_balancing.h sched/fair: Don't free p->numa_faults with concurrent readers 2019-07-25 15:37:04 +02:00
prio.h
rt.h
signal.h exit: Factor thread_group_exited out of pidfd_poll 2020-07-07 11:58:17 -05:00
smt.h
stat.h
sysctl.h sched/uclamp: Add a new sysctl to control RT default boost value 2020-07-29 13:51:47 +02:00
task.h kernel: add a kernel_wait helper 2020-08-12 10:57:59 -07:00
task_stack.h
topology.h sched: Document arch_scale_*_capacity() 2020-08-01 09:19:43 +02:00
types.h posix-cpu-timers: Provide array based access to expiry cache 2019-08-28 11:50:35 +02:00
user.h watch_queue: Limit the number of watches a user can hold 2020-08-17 09:39:18 -07:00
wake_q.h locking/rwsem: Always release wait_lock before waking up tasks 2019-06-17 12:28:00 +02:00
xacct.h