diff options
| author | Luis R. Rodriguez <mcgrof@kernel.org> | 2017-07-12 17:33:30 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-07-12 19:26:00 -0400 |
| commit | a19ac3374995382a994653ff372b98ea7cbad548 (patch) | |
| tree | ea6ed73455c4d801a2cf35d061afe517df5ddf61 /kernel | |
| parent | 89c5b53b16bf577079d4f0311406dbea3c71202c (diff) | |
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: Luis 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/sysctl.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 4dfba1a76cc3..02725178694a 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
| @@ -174,11 +174,32 @@ extern int no_unaligned_warning; | |||
| 174 | 174 | ||
| 175 | #ifdef CONFIG_PROC_SYSCTL | 175 | #ifdef CONFIG_PROC_SYSCTL |
| 176 | 176 | ||
| 177 | #define SYSCTL_WRITES_LEGACY -1 | 177 | /** |
| 178 | #define SYSCTL_WRITES_WARN 0 | 178 | * enum sysctl_writes_mode - supported sysctl write modes |
| 179 | #define SYSCTL_WRITES_STRICT 1 | 179 | * |
| 180 | * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value | ||
| 181 | * to be written, and multiple writes on the same sysctl file descriptor | ||
| 182 | * will rewrite the sysctl value, regardless of file position. No warning | ||
| 183 | * is issued when the initial position is not 0. | ||
| 184 | * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is | ||
| 185 | * not 0. | ||
| 186 | * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at | ||
| 187 | * file position 0 and the value must be fully contained in the buffer | ||
| 188 | * sent to the write syscall. If dealing with strings respect the file | ||
| 189 | * position, but restrict this to the max length of the buffer, anything | ||
| 190 | * passed the max lenght will be ignored. Multiple writes will append | ||
| 191 | * to the buffer. | ||
| 192 | * | ||
| 193 | * These write modes control how current file position affects the behavior of | ||
| 194 | * updating sysctl values through the proc interface on each write. | ||
| 195 | */ | ||
| 196 | enum sysctl_writes_mode { | ||
| 197 | SYSCTL_WRITES_LEGACY = -1, | ||
| 198 | SYSCTL_WRITES_WARN = 0, | ||
| 199 | SYSCTL_WRITES_STRICT = 1, | ||
| 200 | }; | ||
| 180 | 201 | ||
| 181 | static int sysctl_writes_strict = SYSCTL_WRITES_STRICT; | 202 | static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT; |
| 182 | 203 | ||
| 183 | static int proc_do_cad_pid(struct ctl_table *table, int write, | 204 | static int proc_do_cad_pid(struct ctl_table *table, int write, |
| 184 | void __user *buffer, size_t *lenp, loff_t *ppos); | 205 | void __user *buffer, size_t *lenp, loff_t *ppos); |
