linux/kernel
Christian Brauner b227f15712 sysctl: handle overflow for file-max
[ Upstream commit 32a5ad9c22 ]

Currently, when writing

  echo 18446744073709551616 > /proc/sys/fs/file-max

/proc/sys/fs/file-max will overflow and be set to 0.  That quickly
crashes the system.

This commit sets the max and min value for file-max.  The max value is
set to long int.  Any higher value cannot currently be used as the
percpu counters are long ints and not unsigned integers.

Note that the file-max value is ultimately parsed via
__do_proc_doulongvec_minmax().  This function does not report error when
min or max are exceeded.  Which means if a value largen that long int is
written userspace will not receive an error instead the old value will be
kept.  There is an argument to be made that this should be changed and
__do_proc_doulongvec_minmax() should return an error when a dedicated min
or max value are exceeded.  However this has the potential to break
userspace so let's defer this to an RFC patch.

Link: http://lkml.kernel.org/r/20190107222700.15954-3-christian@brauner.io
Signed-off-by: Christian Brauner <christian@brauner.io>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Joe Lawrence <joe.lawrence@redhat.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Waiman Long <longman@redhat.com>
[christian@brauner.io: v4]
  Link: http://lkml.kernel.org/r/20190210203943.8227-3-christian@brauner.io
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2019-04-05 22:32:57 +02:00
..
bpf bpf: do not restore dst_reg when cur_state is freed 2019-04-03 06:26:30 +02:00
cgroup fix cgroup_do_mount() handling of failure exits 2019-03-23 20:09:53 +01:00
configs
debug kdb: Don't back trace on a cpu that didn't round up 2019-02-12 19:47:19 +01:00
dma dma-direct: do not include SME mask in the DMA supported check 2019-01-13 09:51:05 +01:00
events perf core: Fix perf_proc_update_handler() bug 2019-03-13 14:02:26 -07:00
gcov
irq genirq: Make sure the initial affinity is not empty 2019-03-05 17:58:47 +01:00
livepatch
locking locking/lockdep: Add debug_locks check in __lock_downgrade() 2019-03-27 14:14:43 +09:00
power
printk
rcu rcu: Do RCU GP kthread self-wakeup from softirq and interrupt 2019-03-23 20:10:12 +01:00
sched sched/wake_q: Fix wakeup ordering for wake_q 2019-03-05 17:58:49 +01:00
time timekeeping: Use proper seqcount initializer 2019-02-12 19:47:05 +01:00
trace tracing: kdb: Fix ftdump to not sleep 2019-04-05 22:32:56 +02:00
.gitignore
acct.c
async.c
audit_fsnotify.c
audit_tree.c
audit_watch.c
audit.c
audit.h
auditfilter.c
auditsc.c
backtracetest.c
bounds.c
capability.c
compat.c
configs.c
context_tracking.c
cpu_pm.c
cpu.c cpu/hotplug: Prevent crash when CPU bringup fails on CONFIG_HOTPLUG_CPU=n 2019-04-03 06:26:29 +02:00
crash_core.c
crash_dump.c
cred.c
delayacct.c
dma.c
elfcore.c
exec_domain.c
exit.c sched/wait: Fix rcuwait_wake_up() ordering 2019-03-05 17:58:49 +01:00
extable.c
fail_function.c
fork.c fork: record start_time late 2019-01-13 09:51:04 +01:00
freezer.c
futex_compat.c
futex.c futex: Ensure that futex address is aligned in handle_futex_death() 2019-03-27 14:14:40 +09:00
groups.c
hung_task.c kernel/hung_task.c: force console verbose before panic 2019-02-12 19:47:19 +01:00
iomem.c
irq_work.c
jump_label.c
kallsyms.c
kcmp.c
Kconfig.freezer
Kconfig.hz
Kconfig.locks
Kconfig.preempt
kcov.c kernel/kcov.c: mark write_comp_data() as notrace 2019-02-12 19:47:20 +01:00
kexec_core.c
kexec_file.c
kexec_internal.h
kexec.c
kmod.c
kprobes.c
ksysfs.c
kthread.c
latencytop.c
Makefile
memremap.c mm, devm_memremap_pages: add MEMORY_DEVICE_PRIVATE support 2019-01-13 09:51:04 +01:00
module_signing.c
module-internal.h
module.c kobject: return error code if writing /sys/.../uevent fails 2019-02-12 19:47:06 +01:00
notifier.c
nsproxy.c
padata.c
panic.c panic: avoid deadlocks in re-entrant console drivers 2018-12-29 13:37:57 +01:00
params.c
pid_namespace.c
pid.c Fix failure path in alloc_pid() 2019-01-13 09:51:06 +01:00
profile.c
ptrace.c ptrace: Remove unused ptrace_may_access_sched() and MODE_IBRS 2018-12-05 19:32:03 +01:00
range.c
reboot.c
relay.c relay: check return of create_buf_file() properly 2019-03-13 14:02:35 -07:00
resource.c
rseq.c
seccomp.c
signal.c signal: Restore the stop PTRACE_EVENT_EXIT 2019-02-20 10:25:48 +01:00
smp.c cpu/hotplug: Fix "SMT disabled by BIOS" detection for KVM 2019-02-12 19:47:25 +01:00
smpboot.c
smpboot.h
softirq.c
stacktrace.c
stop_machine.c
sys_ni.c
sys.c
sysctl_binary.c
sysctl.c sysctl: handle overflow for file-max 2019-04-05 22:32:57 +02:00
task_work.c
taskstats.c
test_kprobes.c
torture.c
tracepoint.c
tsacct.c
ucount.c
uid16.c
uid16.h
umh.c
up.c
user_namespace.c
user-return-notifier.c
user.c
utsname_sysctl.c
utsname.c
watchdog_hld.c
watchdog.c watchdog: Respect watchdog cpumask on CPU hotplug 2019-04-03 06:26:29 +02:00
workqueue_internal.h
workqueue.c