Received: by 2002:ab2:6486:0:b0:1ef:eae8:a797 with SMTP id de6csp28682lqb; Fri, 15 Mar 2024 14:01:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVnSejGdKVdtSuiLCmb17kL1aZ5YOQiunAdlFZinb3hREESxNCcM5xc7RtOEPPPhfqskrkbHGl2bK8xH0cbXKqr3s9C99pUwrIyxm9jbA== X-Google-Smtp-Source: AGHT+IEm9AEMjF6g/Xcwiz4mA9YaAXp/teHSSsGLOKKlv6Ie10MMxPABynO6EnLp9uIigeZU/TfF X-Received: by 2002:a17:90a:fd85:b0:29d:f52c:5d40 with SMTP id cx5-20020a17090afd8500b0029df52c5d40mr4342500pjb.15.1710536481516; Fri, 15 Mar 2024 14:01:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710536481; cv=pass; d=google.com; s=arc-20160816; b=PsllsM6hJ6a0SoIGvAHrsjDa7GQngYJ6P7vGE2Xc1qcat/7B7jj/gxqxA2wILuYFap iGIkmVVvhf+pz8VIYGCPkoOIxWagxYMlgf9PdOAUBec16bjyyv8WjndzuqwTp3xr43Cu /ncILCH64H9bSGReLMRndEq5eXw/mH2CnG1zhBxARRiCUNjFLsxW0zSFfpAT5KxtU67w xv390bjSgRFhQX+yJG2pHG5R6LnPRwJSm6n/XVzrUCBGLalAQzFgdx7UrmnLAjEWnybY SV9UOdI2zflfofm9r7lJ5VLO9DXyo79NYsEuJXdhtQhM3zUZvGrUgtVXAtI/XFy8ZTvX fK5Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=1VV4zrztCYLsSEmrDg++4n0CCKLp1aEWVav2GCV5kZg=; fh=P5LopblOuM+wTyGvxUQN+d1jxiejuSAgMh+CJu1BpsA=; b=uUTjfhxT7l8p0aU5z2ufsq3ZZ2KDsW6uGQUx6i4QDFHaO7h1wG+q4ehJU1OqpEUo9N cKr7LE6aP1sNkstGZ8QczmW4iB5+t+AUq/3ubvdCJPgrQoikaovuDzdEJcFKWLqYXImv 6m+HK5i2SC0RpKcBe5njOCqvRQ/V7u+EZW0jLdUQ2mvQwH9GIb0d+L0jeLr6DF4vidXr zFq7LEBWCzUgGJXwnK0cmZifdkaaesS5iX6BNbFYLfhx87DjhAIc6C/s6d06LbL9ZoDc V8Whdktzypok3kCv9nRwWAwR2uMWuXa6VdtnYd9Coobp/U4YL/DQujGnwV8/EiBQsZVh cZOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=U4bUcES3; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-104917-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104917-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id v10-20020a17090ac90a00b0029b9d828c4fsi3436315pjt.86.2024.03.15.14.01.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Mar 2024 14:01:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-104917-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=U4bUcES3; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-104917-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-104917-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2280DB23E55 for ; Fri, 15 Mar 2024 20:56:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B4BEE5FF0E; Fri, 15 Mar 2024 20:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="U4bUcES3" Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9277354FB5; Fri, 15 Mar 2024 20:49:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710535772; cv=none; b=upaCErzMZ+FIKtLCbIKCwE3e+jXBieXgalaE0eW+ySjlTvZDIjamNLBBbDYwynFHVWvZNyFnPJ/iKJsaJuvuS/BgUrBuMGVQBgZUfsXM76PZSXy1b3+1KBmmTPm+pYRS8Bto3w6jZziRiYxRJ9bYrXp/ZmJn9Ubs1RnK4qejLYA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710535772; c=relaxed/simple; bh=ioYxjFgUhmgN64D7EqS9neBKa6VPb6OHx0+I2+vtq58=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M+Z4awS540WiHsJziYQ4+I+tNZOqCTgrT4y5PSIWNwEMuMYtdzzcUMomZ7ppSeb+Oe9BNhUHMCR0NSfFyVbNSZSjH8IjRwDbW3d8mAsa6b8m6KQ8L0mdgN+CozzprIk/hfKXSwiksUsyx9emMe4N0lNnF5Pzws1AdAME4aqNYek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=U4bUcES3; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1710535767; bh=ioYxjFgUhmgN64D7EqS9neBKa6VPb6OHx0+I2+vtq58=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=U4bUcES3s2tjQfaJWa5kyV07tIaEq54seuKRZncSMfN3xTCOuGrLDMLybcDmwJiHY ATXaHOHgLnm1H38G00+7D2Qr6StGQ2gP0zruWtCyTLYxFxe885rD9AfLaJyLIS6zx1 NmZbFZqMIU/KmrUeGsPfH36Qh5k2WHCdEy49ynD0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 15 Mar 2024 21:48:08 +0100 Subject: [PATCH 10/11] sysctl: constify ctl_table arguments of utility function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240315-sysctl-const-handler-v1-10-1322ac7cb03d@weissschuh.net> References: <20240315-sysctl-const-handler-v1-0-1322ac7cb03d@weissschuh.net> In-Reply-To: <20240315-sysctl-const-handler-v1-0-1322ac7cb03d@weissschuh.net> To: Greg Kroah-Hartman , Kees Cook , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Muchun Song , Andrew Morton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern , Simon Horman , Julian Anastasov , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , Luis Chamberlain , Joel Granados , Catalin Marinas , Will Deacon , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Gerald Schaefer , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Phillip Potter , Theodore Ts'o , "Jason A. Donenfeld" , Sudip Mukherjee , Mark Rutland , Atish Patra , Anup Patel , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexander Viro , Christian Brauner , Jan Kara , Eric Biederman , Chandan Babu R , "Darrick J. Wong" , Steven Rostedt , Masami Hiramatsu , Peter Zijlstra , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Ian Rogers , Adrian Hunter , Balbir Singh , "Naveen N. Rao" , Anil S Keshavamurthy , Petr Mladek , John Ogness , Sergey Senozhatsky , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Andy Lutomirski , Will Drewry , John Stultz , Stephen Boyd , Mathieu Desnoyers , "Matthew Wilcox (Oracle)" , Roopa Prabhu , Nikolay Aleksandrov , Remi Denis-Courmont , Allison Henderson , Marcelo Ricardo Leitner , Xin Long , Chuck Lever , Jeff Layton , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , John Johansen , Paul Moore , James Morris , "Serge E. Hallyn" , Alexander Popov Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, linux-fsdevel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-s390@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-xfs@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, kexec@lists.infradead.org, bridge@lists.linux.dev, linux-rdma@vger.kernel.org, rds-devel@oss.oracle.com, linux-sctp@vger.kernel.org, linux-nfs@vger.kernel.org, apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1710535695; l=4555; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=ioYxjFgUhmgN64D7EqS9neBKa6VPb6OHx0+I2+vtq58=; b=3ezsimD4t+3/T0cNPSQ4+FYpRTQhNYyohAK+Rbgx8HlPQ+xGzze+WEFqLcmmpL3mfNQxqYUX7 1t4oHVoJb7wAVyGZrGoUFlfOOhXQ+0lakf0I5Pzjxrct2orfuAx6LgW X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= 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 ee7d33b89e9e..99ea26b16c0d 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -238,7 +238,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 157f7ce2942d..93824d8a3636 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) { -- 2.44.0