From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B5E2C001DE for ; Fri, 28 Jul 2023 10:51:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236003AbjG1Kva (ORCPT ); Fri, 28 Jul 2023 06:51:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235144AbjG1Kv3 (ORCPT ); Fri, 28 Jul 2023 06:51:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE45019B6; Fri, 28 Jul 2023 03:51:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4B33E620DA; Fri, 28 Jul 2023 10:51:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A64EC433C8; Fri, 28 Jul 2023 10:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690541487; bh=E4KGSR6GkAndxuU2Aa+9XEtnvO90z/FTuRBymxeho50=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cGFJDR9w0JqyMrOp6qnBtT6KTjeMFRZddjBvEfLiLldS6j7ki7uYRkV/IOkCGGFVR xAIP/3Qqt0ISv6gzNv6A5uWIoYIXQ8569T630PVHlsNKCTOorhnq8GWo/XYEaq6MmR 7/Ov8F4m/P/0eMqDGJWGKEIv/3V658aAtUgSQjEiQUliqxcWiG1UBGMGXhgpuctEtF HxwybgjvNM2H16FCY/4/iDfibyIs9vISEdRNyqchK2gYFCyiJN7SXGstDKM8mQrBg6 pTOVjehsNIoyCJTtWAHHIl4SBksfYSmWXSZxWdnttw1o7tYAX/ajuc/BsS2mfuH0A7 4jlcTIGZXyCIA== Date: Fri, 28 Jul 2023 12:51:22 +0200 From: Simon Horman To: Joel Granados Cc: mcgrof@kernel.org, Kees Cook , Iurii Zaikin , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , willy@infradead.org, josh@joshtriplett.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 05/14] sysctl: Add a size arg to __register_sysctl_table Message-ID: References: <20230726140635.2059334-1-j.granados@samsung.com> <20230726140635.2059334-6-j.granados@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230726140635.2059334-6-j.granados@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Wed, Jul 26, 2023 at 04:06:25PM +0200, Joel Granados wrote: > This is part of the effort to remove the sentinel element in the > ctl_table arrays. We add a table_size argument to > __register_sysctl_table and adjust callers, all of which pass ctl_table > pointers and need an explicit call to ARRAY_SIZE. > > The new table_size argument does not yet have any effect in the > init_header call which is still dependent on the sentinel's presence. > table_size *does* however drive the `kzalloc` allocation in > __register_sysctl_table with no adverse effects as the allocated memory > is either one element greater than the calculated ctl_table array (for > the calls in ipc_sysctl.c, mq_sysctl.c and ucount.c) or the exact size > of the calculated ctl_table array (for the call from sysctl_net.c and > register_sysctl). This approach will allows us to "just" remove the > sentinel without further changes to __register_sysctl_table as > table_size will represent the exact size for all the callers at that > point. > > Temporarily implement a size calculation in register_net_sysctl, which > is an indirection call for all the network register calls. > > Signed-off-by: Joel Granados > --- > fs/proc/proc_sysctl.c | 22 +++++++++++----------- > include/linux/sysctl.h | 2 +- > ipc/ipc_sysctl.c | 4 +++- > ipc/mq_sysctl.c | 4 +++- > kernel/ucount.c | 3 ++- > net/sysctl_net.c | 8 +++++++- > 6 files changed, 27 insertions(+), 16 deletions(-) > > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c > index fa1438f1a355..8d04f01a89c1 100644 > --- a/fs/proc/proc_sysctl.c > +++ b/fs/proc/proc_sysctl.c > @@ -1354,27 +1354,20 @@ static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path) > */ > struct ctl_table_header *__register_sysctl_table( > struct ctl_table_set *set, > - const char *path, struct ctl_table *table) > + const char *path, struct ctl_table *table, size_t table_size) Hi Joel, Please consider adding table_size to the kernel doc for this function. ...