From patchwork Tue Apr 23 07:54:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13639468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 411DDC4345F for ; Tue, 23 Apr 2024 07:56:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D9076B00D4; Tue, 23 Apr 2024 03:56:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 33B126B00D6; Tue, 23 Apr 2024 03:56:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A9366B00D7; Tue, 23 Apr 2024 03:56:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AA0946B00CF for ; Tue, 23 Apr 2024 03:56:10 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3D3B0120DEB for ; Tue, 23 Apr 2024 07:56:10 +0000 (UTC) X-FDA: 82040038500.15.971A95F Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by imf05.hostedemail.com (Postfix) with ESMTP id 83598100009 for ; Tue, 23 Apr 2024 07:56:08 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=weissschuh.net header.s=mail header.b=BuKkQ4wn; spf=pass (imf05.hostedemail.com: domain of linux@weissschuh.net designates 159.69.126.157 as permitted sender) smtp.mailfrom=linux@weissschuh.net; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713858968; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=a9R2TDpG8djghZqIV1uRWoI2kPm13d6nldGovHHPoxs=; b=lydx2Wv9azHfJl3SY1Ykujd1Jy4msnfTHdeDWOFnhc21zdLiiECaNurVD4i590yFOeL1yX 86E+4/Kd+9AGj33xSN9zsBtgdFzkAFp1dPCeEQ/kb2lHrWX8h2un6d1evbOWFnm3+C+7ee zu8anPwty8570Ipex9nFVfX2xoDv7/U= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=weissschuh.net header.s=mail header.b=BuKkQ4wn; spf=pass (imf05.hostedemail.com: domain of linux@weissschuh.net designates 159.69.126.157 as permitted sender) smtp.mailfrom=linux@weissschuh.net; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713858968; a=rsa-sha256; cv=none; b=iUVwdTzb5GtJtqcXTn4J7YZ6JVOFu5Pu2AIgw3jYjGo+LXV4/gg1GUHA84YBM/OT8syO3z wV9Z++ZkFo5gNQOw9hPUwhmsfuIdttACbj3hpA4cS9F585XtlOVUuP9dZc5w6wNFiQWLZW cjkJFZXEJIen7VOSqcqNAPz4Q0TF7Ek= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1713858962; bh=ydR7obNBKRDnMbLpYk0O5xU1+ChzUePuE2B1VMOxcXg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=BuKkQ4wnru53tO4VImE+RBd94hQrxsXOmY7rg+ASOS2vW15touD/aAGtiLNa1kC+7 kC2YollDK7PTHGVEIYC9k1hBEXljd/ZFrzfP4ao96J9I20cbjm5KtPCpR+HwBCFr96 ZKhP+40sphF/eXyhl8i7U8pbsuJQSpZMyZvpLjxI= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 23 Apr 2024 09:54:45 +0200 Subject: [PATCH v3 10/11] sysctl: constify ctl_table arguments of utility function MIME-Version: 1.0 Message-Id: <20240423-sysctl-const-handler-v3-10-e0beccb836e2@weissschuh.net> References: <20240423-sysctl-const-handler-v3-0-e0beccb836e2@weissschuh.net> In-Reply-To: <20240423-sysctl-const-handler-v3-0-e0beccb836e2@weissschuh.net> To: Luis Chamberlain , Joel Granados , Kees Cook Cc: Eric Dumazet , Dave Chinner , linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, bpf@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-xfs@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, kexec@lists.infradead.org, linux-hardening@vger.kernel.org, bridge@lists.linux.dev, lvs-devel@vger.kernel.org, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com, linux-sctp@vger.kernel.org, linux-nfs@vger.kernel.org, apparmor@lists.ubuntu.com, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713858961; l=4555; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=ydR7obNBKRDnMbLpYk0O5xU1+ChzUePuE2B1VMOxcXg=; b=ILR4Nd0n0ptnfip2BSMBBu8wiCN5WTML70FZKdOlvCmeFL1Tz1zsPatlYuvHdEeskE5uykhWp ovqoAP1o0dGDhLLLePYQ0dpqqOG2g0I2Y7dJoidleRvVpkT/QbYbHhD X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Rspamd-Queue-Id: 83598100009 X-Stat-Signature: psuyu3754z41mrxjfc5n836oey99nms5 X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1713858968-862769 X-HE-Meta: U2FsdGVkX19VnVHgyqME4FTfS4vbEDwdffqhBVJZQWCYPT5k7sXVupqsgsQvBP1tjxrAa27iXAYtTWvvGcylY0Cu5rNSGoYrUoNN4wlr+96+sqZmSgP2y94DPFNRSp4kVJO1dkvguIE+vcq5/GpvxT6litpQziFsAoMHFIkPXboC6rUq0pa6f34jjmx68EbtfVWV96U0qvDoW/+/5gJtuoTutzlVH1tgqrPUWaNBsEiyT1ecxLHkvKfRn6EYIzjoIPiGIS5SZ0HqHh1K5vd7/tpEMOXT1odhlraiCCk+/zQ1+G6JTI9Ar9LoeUJrmT6ud9Zrqoj254PCHqEwvOgVEl3P2Jfax4gLxZ87g8m7LNt/n27H93mEugAUUndsi3dCBWhHDqz43NbnjWHyqF/kTcmxKEQF5z4BjCWiomaiJbMUZ0IwiucLrRZV7btq/tnFwt0f57XtuhV9YDOH1GcOkdpf1f0YaM+DKzaehI8J0jTVqazcbEnr7eMbWu7zzt/SxPkmrICfTpUfJVMdsb5fS6wRd0/+a4geePewdfUs3ji2/jKW3mNEg2pI4pw2aUuUda9j3TMOPW22FaCem0+iXML7Wbr91H3CsmkrrahQW/JVgqwwXwDzhhm3VZselfa74nX3r4Mr+ECbA1sw+fnFPIj44zR7MEPZtxho69Qnqn5hjNiMo/85Q9pHHmjyX87vxb4JPKn25NYRRisWPxKd50sF2BBVRoc9duXsOlUJcg1+wlu0dky56cfpoM4191qNDUvpf//v6jBtVkZ+Ll2FMioqUPMz8Uqmym7fkZ5FLLsSn272nDEfpHp07PXwq9R9J8hiopjY7rs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: In a future commit the proc_handlers themselves will change to "const struct ctl_table". As a preparation for that adapt the internal helper. Signed-off-by: Thomas Weißschuh --- include/linux/sysctl.h | 2 +- kernel/sysctl.c | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 09db2f2e6488..54fbec062772 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -237,7 +237,7 @@ extern struct ctl_table_header *register_sysctl_mount_point(const char *path); void do_sysctl_args(void); bool sysctl_is_alias(char *param); -int do_proc_douintvec(struct ctl_table *table, int write, +int do_proc_douintvec(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos, int (*conv)(unsigned long *lvalp, unsigned int *valp, diff --git a/kernel/sysctl.c b/kernel/sysctl.c index e0b917328cf9..62dd27752960 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -205,7 +205,7 @@ static int _proc_do_string(char *data, int maxlen, int write, return 0; } -static void warn_sysctl_write(struct ctl_table *table) +static void warn_sysctl_write(const struct ctl_table *table) { pr_warn_once("%s wrote to %s when file position was not 0!\n" "This will not be supported in the future. To silence this\n" @@ -223,7 +223,7 @@ static void warn_sysctl_write(struct ctl_table *table) * handlers can ignore the return value. */ static bool proc_first_pos_non_zero_ignore(loff_t *ppos, - struct ctl_table *table) + const struct ctl_table *table) { if (!*ppos) return false; @@ -468,7 +468,7 @@ static int do_proc_douintvec_conv(unsigned long *lvalp, static const char proc_wspace_sep[] = { ' ', '\t', '\n' }; -static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, +static int __do_proc_dointvec(void *tbl_data, const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos, int (*conv)(bool *negp, unsigned long *lvalp, int *valp, @@ -541,7 +541,7 @@ static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table, return err; } -static int do_proc_dointvec(struct ctl_table *table, int write, +static int do_proc_dointvec(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos, int (*conv)(bool *negp, unsigned long *lvalp, int *valp, int write, void *data), @@ -552,7 +552,7 @@ static int do_proc_dointvec(struct ctl_table *table, int write, } static int do_proc_douintvec_w(unsigned int *tbl_data, - struct ctl_table *table, + const struct ctl_table *table, void *buffer, size_t *lenp, loff_t *ppos, int (*conv)(unsigned long *lvalp, @@ -639,7 +639,7 @@ static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer, return err; } -static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table, +static int __do_proc_douintvec(void *tbl_data, const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos, int (*conv)(unsigned long *lvalp, @@ -675,7 +675,7 @@ static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table, return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data); } -int do_proc_douintvec(struct ctl_table *table, int write, +int do_proc_douintvec(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos, int (*conv)(unsigned long *lvalp, unsigned int *valp, @@ -1023,8 +1023,9 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write, } #endif -static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, - int write, void *buffer, size_t *lenp, loff_t *ppos, +static int __do_proc_doulongvec_minmax(void *data, + const struct ctl_table *table, int write, + void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul, unsigned long convdiv) { unsigned long *i, *min, *max; @@ -1096,7 +1097,7 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, return err; } -static int do_proc_doulongvec_minmax(struct ctl_table *table, int write, +static int do_proc_doulongvec_minmax(const struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul, unsigned long convdiv) {