mainlining shenanigans
Go to file
Christian Brauner 7f2923c4f7 sysctl: handle overflow in proc_get_long
proc_get_long() is a funny function.  It uses simple_strtoul() and for a
good reason.  proc_get_long() wants to always succeed the parse and
return the maybe incorrect value and the trailing characters to check
against a pre-defined list of acceptable trailing values.  However,
simple_strtoul() explicitly ignores overflows which can cause funny
things like the following to happen:

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

(Which will cause your system to silently die behind your back.)

On the other hand kstrtoul() does do overflow detection but does not
return the trailing characters, and also fails the parse when anything
other than '\n' is a trailing character whereas proc_get_long() wants to
be more lenient.

Now, before adding another kstrtoul() function let's simply add a static
parse strtoul_lenient() which:
 - fails on overflow with -ERANGE
 - returns the trailing characters to the caller

The reason why we should fail on ERANGE is that we already do a partial
fail on overflow right now.  Namely, when the TMPBUFLEN is exceeded.  So
we already reject values such as 184467440737095516160 (21 chars) but
accept values such as 18446744073709551616 (20 chars) but both are
overflows.  So we should just always reject 64bit overflows and not
special-case this based on the number of chars.

Link: http://lkml.kernel.org/r/20190107222700.15954-2-christian@brauner.io
Signed-off-by: Christian Brauner <christian@brauner.io>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Joe Lawrence <joe.lawrence@redhat.com>
Cc: Waiman Long <longman@redhat.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-03-07 18:32:02 -08:00
arch Driver core patches for 5.1-rc1 2019-03-06 14:52:48 -08:00
block for-linus-20190215 2019-02-15 09:12:28 -08:00
certs kbuild: remove redundant target cleaning on failure 2019-01-06 09:46:51 +09:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2019-03-05 09:09:55 -08:00
Documentation USB/PHY patches for 5.1-rc1 2019-03-06 16:48:27 -08:00
drivers rapidio/mport_cdev: mark expected switch fall-through 2019-03-07 18:32:02 -08:00
fs exec: increase BINPRM_BUF_SIZE to 256 2019-03-07 18:32:01 -08:00
include exec: increase BINPRM_BUF_SIZE to 256 2019-03-07 18:32:01 -08:00
init Merge branch 'akpm' (patches from Andrew) 2019-03-06 10:31:36 -08:00
ipc y2038: syscalls: rename y2038 compat syscalls 2019-02-07 00:13:27 +01:00
kernel sysctl: handle overflow in proc_get_long 2019-03-07 18:32:02 -08:00
lib lib/test_firmware.c: remove some dead code 2019-03-07 18:32:00 -08:00
LICENSES This is a fairly typical cycle for documentation. There's some welcome 2018-10-24 18:01:11 +01:00
mm mm,mremap: bail out earlier in mremap_to under map pressure 2019-03-05 21:07:21 -08:00
net Merge branch 'akpm' (patches from Andrew) 2019-03-06 10:31:36 -08:00
samples Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-03-05 08:26:13 -08:00
scripts checkpatch: add test for SPDX-License-Identifier on wrong line # 2019-03-07 18:32:01 -08:00
security get rid of legacy 'get_ds()' function 2019-03-04 10:50:14 -08:00
sound Char/Misc driver patches for 5.1-rc1 2019-03-06 14:18:59 -08:00
tools Staging/IIO patches for 5.1-rc1 2019-03-06 16:29:27 -08:00
usr user/Makefile: Fix typo and capitalization in comment section 2018-12-11 00:18:03 +09:00
virt ACPI updates for 5.1-rc1 2019-03-06 13:33:11 -08:00
.clang-format clang-format: Update .clang-format with the latest for_each macro list 2019-01-19 19:26:06 +01:00
.cocciconfig
.get_maintainer.ignore
.gitattributes .gitattributes: set git diff driver for C source code files 2016-10-07 18:46:30 -07:00
.gitignore kbuild: Add support for DT binding schema checks 2018-12-13 09:41:32 -06:00
.mailmap .mailmap: Add Mathieu Othacehe 2019-02-21 11:41:19 +00:00
COPYING COPYING: use the new text with points to the license files 2018-03-23 12:41:45 -06:00
CREDITS Char/Misc driver patches for 5.1-rc1 2019-03-06 14:18:59 -08:00
Kbuild Merge branch 'locking/atomics' into locking/core, to pick up WIP commits 2019-02-11 14:27:05 +01:00
Kconfig kconfig: move the "Executable file formats" menu to fs/Kconfig.binfmt 2018-08-02 08:06:55 +09:00
MAINTAINERS USB/PHY patches for 5.1-rc1 2019-03-06 16:48:27 -08:00
Makefile Driver core patches for 5.1-rc1 2019-03-06 14:52:48 -08:00
README Drop all 00-INDEX files from Documentation/ 2018-09-09 15:08:58 -06:00

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.