Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a19ac337 authored by Luis R. Rodriguez's avatar Luis R. Rodriguez Committed by Linus Torvalds
Browse files

sysctl: kdoc'ify sysctl_writes_strict

Document the different sysctl_writes_strict modes in code.

Link: http://lkml.kernel.org/r/20170519033554.18592-3-mcgrof@kernel.org


Signed-off-by: default avatarLuis R. Rodriguez <mcgrof@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 89c5b53b
Loading
Loading
Loading
Loading
+25 −4
Original line number Original line Diff line number Diff line
@@ -174,11 +174,32 @@ extern int no_unaligned_warning;


#ifdef CONFIG_PROC_SYSCTL
#ifdef CONFIG_PROC_SYSCTL


#define SYSCTL_WRITES_LEGACY	-1
/**
#define SYSCTL_WRITES_WARN	 0
 * enum sysctl_writes_mode - supported sysctl write modes
#define SYSCTL_WRITES_STRICT	 1
 *
 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
 * 	to be written, and multiple writes on the same sysctl file descriptor
 * 	will rewrite the sysctl value, regardless of file position. No warning
 * 	is issued when the initial position is not 0.
 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
 * 	not 0.
 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
 * 	file position 0 and the value must be fully contained in the buffer
 * 	sent to the write syscall. If dealing with strings respect the file
 * 	position, but restrict this to the max length of the buffer, anything
 * 	passed the max lenght will be ignored. Multiple writes will append
 * 	to the buffer.
 *
 * These write modes control how current file position affects the behavior of
 * updating sysctl values through the proc interface on each write.
 */
enum sysctl_writes_mode {
	SYSCTL_WRITES_LEGACY		= -1,
	SYSCTL_WRITES_WARN		= 0,
	SYSCTL_WRITES_STRICT		= 1,
};


static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;


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