aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/sysctl
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2014-06-06 14:37:19 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-06 16:08:13 -0700
commitf4aacea2f5d1a5f7e3154e967d70cf3f711bcd61 (patch)
tree6706ce16774c72bcbb33e4872b4913731349cb13 /tools/testing/selftests/sysctl
parentsysctl: refactor sysctl string writing logic (diff)
downloadlinux-dev-f4aacea2f5d1a5f7e3154e967d70cf3f711bcd61.tar.xz
linux-dev-f4aacea2f5d1a5f7e3154e967d70cf3f711bcd61.zip
sysctl: allow for strict write position handling
When writing to a sysctl string, each write, regardless of VFS position, begins writing the string from the start. This means the contents of the last write to the sysctl controls the string contents instead of the first: open("/proc/sys/kernel/modprobe", O_WRONLY) = 1 write(1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"..., 4096) = 4096 write(1, "/bin/true", 9) = 9 close(1) = 0 $ cat /proc/sys/kernel/modprobe /bin/true Expected behaviour would be to have the sysctl be "AAAA..." capped at maxlen (in this case KMOD_PATH_LEN: 256), instead of truncating to the contents of the second write. Similarly, multiple short writes would not append to the sysctl. The old behavior is unlike regular POSIX files enough that doing audits of software that interact with sysctls can end up in unexpected or dangerous situations. For example, "as long as the input starts with a trusted path" turns out to be an insufficient filter, as what must also happen is for the input to be entirely contained in a single write syscall -- not a common consideration, especially for high level tools. This provides kernel.sysctl_writes_strict as a way to make this behavior act in a less surprising manner for strings, and disallows non-zero file position when writing numeric sysctls (similar to what is already done when reading from non-zero file positions). For now, the default (0) is to warn about non-zero file position use, but retain the legacy behavior. Setting this to -1 disables the warning, and setting this to 1 enables the file position respecting behavior. [akpm@linux-foundation.org: fix build] [akpm@linux-foundation.org: move misplaced hunk, per Randy] Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'tools/testing/selftests/sysctl')
0 files changed, 0 insertions, 0 deletions