From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756112AbdESDhA (ORCPT ); Thu, 18 May 2017 23:37:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:48312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754107AbdESDgA (ORCPT ); Thu, 18 May 2017 23:36:00 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 85B83239E6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mcgrof@kernel.org From: "Luis R. Rodriguez" To: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, ebiederm@xmission.com, keescook@chromium.org, acme@redhat.com, mingo@kernel.org, mgorman@suse.de, subashab@codeaurora.org Cc: jeyu@redhat.com, rusty@rustcorp.com.au, swhiteho@redhat.com, deepa.kernel@gmail.com, matt@codeblueprint.co.uk, adobriyan@gmail.com, bp@suse.de, zlpnobody@gmail.com, dmitry.torokhov@gmail.com, shuah@kernel.org, torvalds@linux-foundation.org, linux@roeck-us.net, linux-kernel@vger.kernel.org, "Luis R. Rodriguez" Subject: [PATCH v3 2/5] sysctl: kdoc'ify sysctl_writes_strict Date: Thu, 18 May 2017 20:35:51 -0700 Message-Id: <20170519033554.18592-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170519033554.18592-1-mcgrof@kernel.org> References: <20170211003614.6579-1-mcgrof@kernel.org> <20170519033554.18592-1-mcgrof@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Document the different sysctl_writes_strict modes in code. Signed-off-by: Luis R. Rodriguez --- kernel/sysctl.c | 29 +++++++++++++++++++++++++---- 1 file 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; #ifdef CONFIG_PROC_SYSCTL -#define SYSCTL_WRITES_LEGACY -1 -#define SYSCTL_WRITES_WARN 0 -#define SYSCTL_WRITES_STRICT 1 +/** + * enum sysctl_writes_mode - supported sysctl write modes + * + * @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, void __user *buffer, size_t *lenp, loff_t *ppos); -- 2.11.0