Skip to content

Commit 41662f5

Browse files
keestorvalds
authored andcommitted
sysctl: enable strict writes
SYSCTL_WRITES_WARN was added in commit f4aacea ("sysctl: allow for strict write position handling"), and released in v3.16 in August of 2014. Since then I can find only 1 instance of non-zero offset writing[1], and it was fixed immediately in CRIU[2]. As such, it appears safe to flip this to the strict state now. [1] https://www.google.com/search?q="when%20file%20position%20was%20not%200" [2] http://lists.openvz.org/pipermail/criu/2015-April/019819.html Signed-off-by: Kees Cook <keescook@chromium.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent a460bec commit 41662f5

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

‎Documentation/sysctl/kernel.txt‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -825,14 +825,13 @@ via the /proc/sys interface:
825825
Each write syscall must fully contain the sysctl value to be
826826
written, and multiple writes on the same sysctl file descriptor
827827
will rewrite the sysctl value, regardless of file position.
828-
0 - (default) Same behavior as above, but warn about processes that
829-
perform writes to a sysctl file descriptor when the file position
830-
is not 0.
831-
1 - Respect file position when writing sysctl strings. Multiple writes
832-
will append to the sysctl value buffer. Anything past the max length
833-
of the sysctl value buffer will be ignored. Writes to numeric sysctl
834-
entries must always be at file position 0 and the value must be
835-
fully contained in the buffer sent in the write syscall.
828+
0 - Same behavior as above, but warn about processes that perform writes
829+
to a sysctl file descriptor when the file position is not 0.
830+
1 - (default) Respect file position when writing sysctl strings. Multiple
831+
writes will append to the sysctl value buffer. Anything past the max
832+
length of the sysctl value buffer will be ignored. Writes to numeric
833+
sysctl entries must always be at file position 0 and the value must
834+
be fully contained in the buffer sent in the write syscall.
836835

837836
==============================================================
838837

‎kernel/sysctl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ extern int no_unaligned_warning;
173173
#define SYSCTL_WRITES_WARN 0
174174
#define SYSCTL_WRITES_STRICT 1
175175

176-
static int sysctl_writes_strict = SYSCTL_WRITES_WARN;
176+
static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
177177

178178
static int proc_do_cad_pid(struct ctl_table *table, int write,
179179
void __user *buffer, size_t *lenp, loff_t *ppos);

0 commit comments

Comments
 (0)