Message ID | 20230726140635.2059334-8-j.granados@samsung.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp442522vqo; Wed, 26 Jul 2023 07:28:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlHYwqzoo4jcZG2xKzha9wYooCAmUqarPlBcuA1rfJSw7q4zOgBihnrxQYQtd55dvgcvur9H X-Received: by 2002:a17:902:e885:b0:1b5:5052:5af7 with SMTP id w5-20020a170902e88500b001b550525af7mr2797418plg.8.1690381730366; Wed, 26 Jul 2023 07:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690381730; cv=none; d=google.com; s=arc-20160816; b=jq8SZMPKtI3BosfSgCIbZRx9DqXjYq0SGpazj0BwbbTLjoVE6jDO+kHZ2/GCdJfBWe F1EJK6VsyF39TXgiea2CLJl3hxXW3ioX5nEKAG1yRVbgynH6wRo8YEJXKohtF6pYS0iU VJqIFLuFmUy2j+QdafAfcj+JWZeGsAw6MaqWV7kX1qdT3y8I8YHacpjGKK82DfeNhfvi 3D98wTJdK4ScivyApcy8g/Kw9CPF0C/Vk0lr/7fAqCaxDPhjIYtPPMzY18xL7JTACYJn CbXjmG1mFZTCleYFzo+a3RdesEcEDqrq2Sz0JTzCJ7Usdqxv3PRhJ54vBPniDwiCCZ1V Pn8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:content-transfer-encoding :mime-version:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=O9C8cu+eriqJgnbO4v2Z8b/dkIKixZDljclAYTZ36o0=; fh=jc9Oc4z2chBkB++ulkkGj5ASBtrAOk+67EQBS5BnDw0=; b=wUOnuVro0ssYxLgZRYGU0uAzvNMhkaXCQVN0SWm1WbA+uTyqiWG6Lsy1OOfnjDfxFg GyZR0IjTgQoumH7JWFRkn1BplyOXthHg5MzTo7HEvk8R6Lr8W/mCLFef0r3WhWsaYNPE px0XtQ5T1uWe5DENSEYc5DtExgEXZJf2i8WEsk2OfYEOQTQ9rM3S41h4J5xEXcRt2Kb3 Vki27ZkTz4C1snsJ0vxiYW6akFh/D8Mx6CrrbJdVjYcZqoRHPx0bo2MrysX956yHiT+6 ipn9SQuFc4606bSEJFFRLMDQ0afk/5gd/gYKGwH+2eVtNvBEFgQyn2FWYhxvLQsG8v4s nhsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=rCh9soBB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l10-20020a170902f68a00b001b9eb5d1ea2si14279374plg.198.2023.07.26.07.28.35; Wed, 26 Jul 2023 07:28:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=rCh9soBB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234313AbjGZOIO (ORCPT <rfc822;kloczko.tomasz@gmail.com> + 99 others); Wed, 26 Jul 2023 10:08:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234403AbjGZOHP (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 26 Jul 2023 10:07:15 -0400 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F4082D5A for <linux-kernel@vger.kernel.org>; Wed, 26 Jul 2023 07:07:02 -0700 (PDT) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20230726140701euoutp0238502fca2a7fd27d907802b134910b5d~1cAlzXb4B1520515205euoutp02w for <linux-kernel@vger.kernel.org>; Wed, 26 Jul 2023 14:07:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20230726140701euoutp0238502fca2a7fd27d907802b134910b5d~1cAlzXb4B1520515205euoutp02w DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1690380421; bh=O9C8cu+eriqJgnbO4v2Z8b/dkIKixZDljclAYTZ36o0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rCh9soBByg/s7ArBTkcS868IDLNvIsbCkXDuk4jbQ32Qroi9/iiQnUSaa7CJC0s8N qL7Kef6Ta0cNOF8iVu/k8RJlwbS+WT8kEZS1/W2ugTD5AgTveISpr/yuNd2dPcF9+w ALeZ0NJ+FVtJ2ydU9piHLOcPsWTE4ucc5xhZmm1I= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20230726140700eucas1p23c3d90dc8d83fc17d20e7181ad9cdf58~1cAlgA4qF3020930209eucas1p2T; Wed, 26 Jul 2023 14:07:00 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id BC.66.42423.48821C46; Wed, 26 Jul 2023 15:07:00 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20230726140700eucas1p1e6b16e884362ebec50f6712b3f11a533~1cAlMkQVf2040620406eucas1p1h; Wed, 26 Jul 2023 14:07:00 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20230726140700eusmtrp23cb07803949101e69d6e6784132527b8~1cAlL-95p2014720147eusmtrp2g; Wed, 26 Jul 2023 14:07:00 +0000 (GMT) X-AuditID: cbfec7f2-a3bff7000002a5b7-79-64c1288491dd Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 05.57.14344.48821C46; Wed, 26 Jul 2023 15:07:00 +0100 (BST) Received: from localhost (unknown [106.210.248.223]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20230726140700eusmtip26639b8677aab72762d4dfdf7367693e1~1cAk7WVCu2007220072eusmtip2G; Wed, 26 Jul 2023 14:07:00 +0000 (GMT) From: Joel Granados <j.granados@samsung.com> To: mcgrof@kernel.org, Kees Cook <keescook@chromium.org>, Iurii Zaikin <yzaikin@google.com> Cc: willy@infradead.org, josh@joshtriplett.org, Joel Granados <j.granados@samsung.com>, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 07/14] sysctl: Add size arg to __register_sysctl_init Date: Wed, 26 Jul 2023 16:06:27 +0200 Message-Id: <20230726140635.2059334-8-j.granados@samsung.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230726140635.2059334-1-j.granados@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprBKsWRmVeSWpSXmKPExsWy7djPc7otGgdTDHYsULFYuv8ho8X/BfkW Z7pzLfbsPclicXnXHDaLGxOeMlr8/gFkLdvp58DhMbvhIovHgk2lHptXaHncem3rsWlVJ5tH 35ZVjB6fN8kFsEdx2aSk5mSWpRbp2yVwZXTvfsNS0ChYcepUG0sD4xq+LkZODgkBE4n/7T2s XYxcHE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Sqk82j b8sqRo/Pm+QC2KP0bIryS0tSFTLyi0tslaINLYz0DC0t9IxMLPUMjc1jrYxMlfTtbFJSczLL Uov07RL0Mrp3v2EpaBSsOHWqjaWBcQ1fFyMnh4SAicTn359Zuxi5OIQEljJK/Lz7j72LkQMo ISXxfRknRI2wxJ9rXWwQNc8ZJVau38AOkmAT0JE4/+YOM4gtIhAvMfPxfSaQImaB2YwSq08e AksIC7hK/Go9D2azCKhKLD65jAVkAa+ArcSa6aoQC+Ql2q5PZwSxOQXsJFau/c4KYgsBlfRM fQq2i1dAUOLkzCcsIDYzUH3z1tnMExgFZiFJzUKSWsDItIpRJLW0ODc9t9hIrzgxt7g0L10v OT93EyMwSrYd+7llB+PKVx/1DjEycTAeYpTgYFYS4TWM2ZcixJuSWFmVWpQfX1Sak1p8iNEU 6OyJzFKiyfnAOM0riTc0MzA1NDGzNDC1NDNWEuf1LOhIFBJITyxJzU5NLUgtgulj4uCUamBa wv5vmVce543wyHq5rhvfO278lvnwKOfW9FK9LY8bTvQ97j9TWK5QVcvR277nJcvTOQcuVl7b v2nGLmOZvMJNHQrVmRIuG/QeTY/edfzY4wtpn18I2asvXMmueHeFgv+aQyveLro38Q+TcsK/ LN4VT79KdkgZTojbsNF9qrDdN6UFUVXLsxvfckU/8uaeEtuRIOEk8YXBoTIgufzllzSXKveC P6bbrebc/NR5UWODnpmXV0iKYsbpWxabm0/Gf/aeOm3T6mUXw67n2075N/mFcrUKc/k390OZ Z9acv2p4L4BZ42Je6m7H1bOmyGzuY/8UeeFk8/XVd09cUll5Sni19y87yb2uzzmbjQ6rrD7U ocRSnJFoqMVcVJwIAN5IOfYbAwAA X-CMS-MailID: 20230726140700eucas1p1e6b16e884362ebec50f6712b3f11a533 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20230726140700eucas1p1e6b16e884362ebec50f6712b3f11a533 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20230726140700eucas1p1e6b16e884362ebec50f6712b3f11a533 References: <20230726140635.2059334-1-j.granados@samsung.com> <CGME20230726140700eucas1p1e6b16e884362ebec50f6712b3f11a533@eucas1p1.samsung.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772493713512251004 X-GMAIL-MSGID: 1772493713512251004 |
Series |
[01/14] sysctl: Prefer ctl_table_header in proc_sysctl
|
|
Commit Message
Joel Granados
July 26, 2023, 2:06 p.m. UTC
This is part of the effort to remove the sentinel element from the
ctl_table array at register time. We add a size argument to
__register_sysctl_init and modify the register_sysctl_init macro to
calculate the array size with ARRAY_SIZE. The original callers do not
need to be updated as they will go through the new macro.
Signed-off-by: Joel Granados <j.granados@samsung.com>
---
fs/proc/proc_sysctl.c | 11 ++---------
include/linux/sysctl.h | 5 +++--
2 files changed, 5 insertions(+), 11 deletions(-)
Comments
On Wed, Jul 26, 2023 at 04:06:27PM +0200, Joel Granados wrote: > This is part of the effort to remove the sentinel element from the > ctl_table array at register time. We add a size argument to > __register_sysctl_init and modify the register_sysctl_init macro to > calculate the array size with ARRAY_SIZE. The original callers do not > need to be updated as they will go through the new macro. > > Signed-off-by: Joel Granados <j.granados@samsung.com> > --- > fs/proc/proc_sysctl.c | 11 ++--------- > include/linux/sysctl.h | 5 +++-- > 2 files changed, 5 insertions(+), 11 deletions(-) > > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c > index c04293911e7e..6c0721cd35f3 100644 > --- a/fs/proc/proc_sysctl.c > +++ b/fs/proc/proc_sysctl.c > @@ -1444,16 +1444,9 @@ EXPORT_SYMBOL(register_sysctl_sz); > * Context: if your base directory does not exist it will be created for you. > */ > void __init __register_sysctl_init(const char *path, struct ctl_table *table, > - const char *table_name) > + const char *table_name, size_t table_size) Hi Joel, in the same vein as my comment on another patch. Please add table_size to the kernel doc for this function.
On Fri, Jul 28, 2023 at 12:56:36PM +0200, Simon Horman wrote: > On Wed, Jul 26, 2023 at 04:06:27PM +0200, Joel Granados wrote: > > This is part of the effort to remove the sentinel element from the > > ctl_table array at register time. We add a size argument to > > __register_sysctl_init and modify the register_sysctl_init macro to > > calculate the array size with ARRAY_SIZE. The original callers do not > > need to be updated as they will go through the new macro. > > > > Signed-off-by: Joel Granados <j.granados@samsung.com> > > --- > > fs/proc/proc_sysctl.c | 11 ++--------- > > include/linux/sysctl.h | 5 +++-- > > 2 files changed, 5 insertions(+), 11 deletions(-) > > > > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c > > index c04293911e7e..6c0721cd35f3 100644 > > --- a/fs/proc/proc_sysctl.c > > +++ b/fs/proc/proc_sysctl.c > > @@ -1444,16 +1444,9 @@ EXPORT_SYMBOL(register_sysctl_sz); > > * Context: if your base directory does not exist it will be created for you. > > */ > > void __init __register_sysctl_init(const char *path, struct ctl_table *table, > > - const char *table_name) > > + const char *table_name, size_t table_size) > > Hi Joel, > > in the same vein as my comment on another patch. > Please add table_size to the kernel doc for this function. Will do.
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index c04293911e7e..6c0721cd35f3 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c @@ -1444,16 +1444,9 @@ EXPORT_SYMBOL(register_sysctl_sz); * Context: if your base directory does not exist it will be created for you. */ void __init __register_sysctl_init(const char *path, struct ctl_table *table, - const char *table_name) + const char *table_name, size_t table_size) { - int count = 0; - struct ctl_table *entry; - struct ctl_table_header t_hdr, *hdr; - - t_hdr.ctl_table = table; - list_for_each_table_entry(entry, (&t_hdr)) - count++; - hdr = register_sysctl_sz(path, table, count); + struct ctl_table_header *hdr = register_sysctl_sz(path, table, table_size); if (unlikely(!hdr)) { pr_err("failed when register_sysctl_sz %s to %s\n", table_name, path); diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index b1168ae281c9..09d7429d67c0 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -236,8 +236,9 @@ void unregister_sysctl_table(struct ctl_table_header * table); extern int sysctl_init_bases(void); extern void __register_sysctl_init(const char *path, struct ctl_table *table, - const char *table_name); -#define register_sysctl_init(path, table) __register_sysctl_init(path, table, #table) + const char *table_name, size_t table_size); +#define register_sysctl_init(path, table) \ + __register_sysctl_init(path, table, #table, ARRAY_SIZE(table)) extern struct ctl_table_header *register_sysctl_mount_point(const char *path); void do_sysctl_args(void);