Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1832998rdh; Sat, 25 Nov 2023 04:53:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiAq1nLw5/6S34u5IIYf8AoKrab/rcVBddA/YdOHRDvT7wq4UBZFWqVhWYgLtdQCKlFyRR X-Received: by 2002:a05:6a20:1446:b0:18c:770:4578 with SMTP id a6-20020a056a20144600b0018c07704578mr5014666pzi.30.1700916798582; Sat, 25 Nov 2023 04:53:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700916798; cv=none; d=google.com; s=arc-20160816; b=sqbUWneOwXs9UrhkDhJV+IdGRm0PgwQ5CGU5H49xF32aq4Rbk2PpM9jw7NwhMgnEvL F/siFoKiEkTeSDmHrTb+2FT+jJ7TrP2qhDqYP3RaXH55iUT+K/i+xCxm/DzWkC5kp50Z Zb+vxVkL1Yk+N30qlizhTQSNCIMVPwhtcD7tRWCfzsOAt+QrLrH3MKveYYufhIXnMTbP Ffx2rY4/E5QSr7VeKtoJM+YTRD+u/fsNUJYlrmpg7Q/NzG2LlVc9cVrN/GnKwkz6vA7L ZY57LRXCvdFHttmRRBA48HHLtvwEaoGYd3uF0cbp9Omim7tX25ebTjMRySQartq1bwJ1 hJ9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=RlCgs7kFey7nAFUoHTaBV/gfxfj7vNk9AdUPQ621+Tg=; fh=1v5zqbO9sIGUc9bsdyhYE0zxdK1knZz2xnJYWUWMFKo=; b=0sWp+MGThMAdErqTaJcLvS4uvG2LWvnPSfX3uTWjxO1JaeNN68ZdQFZhsamwo/V024 eTZWnMY13F2nYJN9gHlA9RiDPgm+TVjCRynTaZk67fU30OhxG0CSr4ZxJmn+VnBWym5+ 07woP0oYcMvzNwbhjgZeyy4+MlyrPfH5DXoCnxote+NNzRrAwOOzDRLtsDz4a6Z0vWxT 6KOzez0/56mIdFx/4ssSCbEfkf2qxj4f+xFrtdKS07YFRIjs0PEqC+KqZAmNjbrfahEA kAZJiGL2NUacp4vah/Etyz9erm3SfyV/Eeo/Y52dOU/3yNXixZ72ASqmCZxW+5BDtaRO D3hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=fztyoxz+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id ka41-20020a056a0093a900b006cbf67390d8si3521501pfb.25.2023.11.25.04.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 04:53:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=fztyoxz+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 5A5E1804432B; Sat, 25 Nov 2023 04:53:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232089AbjKYMw4 (ORCPT + 99 others); Sat, 25 Nov 2023 07:52:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232000AbjKYMwy (ORCPT ); Sat, 25 Nov 2023 07:52:54 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC742D3; Sat, 25 Nov 2023 04:52:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1700916776; bh=iUFGOwiGkTIEhre+odhGn4/1WdiJ+qVq49adTV3gQHM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fztyoxz+RxX7MwxRfaVFrpt8zAzdiGOJNQQaZ2liuOTEhZJSPtgzPDAwdy8d+nduu 6HIpQDcLALScEvSo3TB44K9Cg07c0e+d5EKM4CrbFZS+z4cX07Vb3ZYhQbCW8bF+IK CuVl6bAJigVYO1bVG73ZQ0PsCKDHyk2/sxUnLMcc= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 25 Nov 2023 13:52:50 +0100 Subject: [PATCH RFC 1/7] sysctl: add helper sysctl_run_handler MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20231125-const-sysctl-v1-1-5e881b0e0290@weissschuh.net> References: <20231125-const-sysctl-v1-0-5e881b0e0290@weissschuh.net> In-Reply-To: <20231125-const-sysctl-v1-0-5e881b0e0290@weissschuh.net> To: Kees Cook , "Gustavo A. R. Silva" , Luis Chamberlain , Iurii Zaikin , Greg Kroah-Hartman , Joel Granados Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1700916776; l=1484; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=iUFGOwiGkTIEhre+odhGn4/1WdiJ+qVq49adTV3gQHM=; b=Cv+9BCerGMTP/2lwcmiBVc/6/kwT01UgiJ38sgxdeBN+8Ofpm5XgsYBpLeAWweL5YsfOi/XO9 t1IRt8PjV7dBp1eb61hCnnM6/2qS3I9vKlVDUuz7KXnyXahSMJE7Xs2 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sat, 25 Nov 2023 04:53:13 -0800 (PST) A future patch will introduce a second handler function. To make the code future-proof add the sysctl_run_handler function that automatically can call the correct handler function. Signed-off-by: Thomas Weißschuh --- fs/proc/proc_sysctl.c | 2 +- include/linux/sysctl.h | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 8064ea76f80b..1bb0aa2ff501 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -597,7 +597,7 @@ static ssize_t proc_sys_call_handler(struct kiocb *iocb, struct iov_iter *iter, goto out_free_buf; /* careful: calling conventions are nasty here */ - error = table->proc_handler(table, write, kbuf, &count, &iocb->ki_pos); + error = sysctl_run_handler(table, write, kbuf, &count, &iocb->ki_pos); if (error) goto out_free_buf; diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 61b40ea81f4d..604aaaa1fce2 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -298,4 +298,10 @@ static inline bool sysctl_is_alias(char *param) int sysctl_max_threads(struct ctl_table *table, int write, void *buffer, size_t *lenp, loff_t *ppos); +static inline int sysctl_run_handler(struct ctl_table *ctl, int write, + void *buffer, size_t *lenp, loff_t *ppos) +{ + return ctl->proc_handler(ctl, write, buffer, lenp, ppos); +} + #endif /* _LINUX_SYSCTL_H */ -- 2.43.0