Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1584360rdb; Thu, 7 Dec 2023 03:31:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGkJBuuRuBGtXSpawU/WatcxSURIjnAC0XmzuLz4QlGeHbU3/zE5XWutLv5tsFfNh8ohoLT X-Received: by 2002:a05:6a20:5603:b0:18c:4f:ce9e with SMTP id ir3-20020a056a20560300b0018c004fce9emr2599205pzc.43.1701948699391; Thu, 07 Dec 2023 03:31:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701948699; cv=none; d=google.com; s=arc-20160816; b=ZxSOVkYypstWwJ3Wiw6kZ4xIFiajoD3m3ctxqxRex/pSjn8pdVbDyvDjLx7Ft+iP0V HaKyap0caYMOtIWrpCWy2wFv8k27YE9dKHwSYYD/pR6cwFceh6ZvQWm9L3iCnbl+wXe6 pMog/jhUYKVlPmoFqkBOgk6GVmxNB4rzdqwgU/c9eZGYy+k5yudgkFAC5RSVi8bOnfUM 5ijfpoyj05I03n6yy3Ty9Tp0JCZJiRGOza+BCYiOMFrBN/h5IlFdffAViDXQzh5uUVKM UtfvLQhjF9o5wwRwRDB46tOexLwKv9mwGPqGwuwh/+rlMgbH4qCqM1VRwgkMp1F4LIn4 YxFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:in-reply-to :content-disposition:mime-version:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=LQbsCB2xkDlZrVSHuSbYgEXZy2Mk/5QJLXPD/YcUQ/I=; fh=F+seLicu2+0lodrWqq1yOikAPCIvf0PgOELkKn9NRr4=; b=Vkcc2BPKzNu7AN2jVrxCeo1YDq5/+Kku48N8ob/k4dPb/VoSeesoa/VRuVLaSOBUFo BrJg6eIDWoH35K8mCB7cXHsbClB6DLXOyGfKuAXPVwoD0UbnT5kzn54uwZ3TaQW3xt8n vPZlA8VUXtcCUPtlIdgF5h3RpxcfqYz4PtITwgHTsbRIJN6z7P/KsNynantwNwu4wLU8 aBRJ8smaob2u3Dm5k7BvVsJMIPMPA6+G93k4JXyOYobzv0M1pWVMcY+6Wq+nA39Y294y 1Y1TFAo+d1ShKCabItGdB/nwb8h/4U3IJ49dXi0w/SHd+QjrejmxE6kCWaWg69aumWMB ukVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=BbOHq0vN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bs67-20020a632846000000b005b9483bf765si1016489pgb.25.2023.12.07.03.31.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 03:31:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=BbOHq0vN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id AE2168050D28; Thu, 7 Dec 2023 03:31:36 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231439AbjLGLbO (ORCPT + 99 others); Thu, 7 Dec 2023 06:31:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbjLGLbJ (ORCPT ); Thu, 7 Dec 2023 06:31:09 -0500 Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9DE110C4; Thu, 7 Dec 2023 03:31:13 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20231207113112euoutp029900412f10484f3ca5a51062bbc5f7a6~eiUzPPxN11146011460euoutp02i; Thu, 7 Dec 2023 11:31:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20231207113112euoutp029900412f10484f3ca5a51062bbc5f7a6~eiUzPPxN11146011460euoutp02i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1701948672; bh=LQbsCB2xkDlZrVSHuSbYgEXZy2Mk/5QJLXPD/YcUQ/I=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=BbOHq0vNAsLVh1rT9jh5jrbUFfNdw6mLl7M7nmCKpui8r92Nu/u2zviKPJ9g73OTf 8QGLvDuLLwVnlocFDE/Aq99jMXv3SDy3reT7pK+kAi0t/yhv7DOXVQmd4e4I5Cq4vG DLk6/rWE7YMg8oj7A5qtGbmceDUCYNPpNR2EKhRo= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20231207113112eucas1p2262dec4c91d359055358e432181bc448~eiUzErjVq0649006490eucas1p29; Thu, 7 Dec 2023 11:31:12 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id C9.4E.09539.FFCA1756; Thu, 7 Dec 2023 11:31:11 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20231207113111eucas1p2d8a3b27e91bf4cf00c33d717cdd2bf9e~eiUypFNtt0649006490eucas1p28; Thu, 7 Dec 2023 11:31:11 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20231207113111eusmtrp170fae65246d78fbbaafb0bfdf99ee506~eiUyoex6E2693926939eusmtrp1A; Thu, 7 Dec 2023 11:31:11 +0000 (GMT) X-AuditID: cbfec7f2-52bff70000002543-63-6571acffbd08 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id D1.77.09274.FFCA1756; Thu, 7 Dec 2023 11:31:11 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231207113111eusmtip2d4e87ab44d7318d3da608777a9f1fcc5~eiUycspVC1212812128eusmtip2X; Thu, 7 Dec 2023 11:31:11 +0000 (GMT) Received: from localhost (106.210.248.38) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 7 Dec 2023 11:31:10 +0000 Date: Thu, 7 Dec 2023 12:31:09 +0100 From: Joel Granados To: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= CC: Kees Cook , "Gustavo A. R. Silva" , Luis Chamberlain , Iurii Zaikin , Greg Kroah-Hartman , , , Subject: Re: [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header Message-ID: <20231207113109.dc4fpaaenk7z7hmu@localhost> MIME-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="ce6zcdvlndypsxv7" Content-Disposition: inline In-Reply-To: <20231204-const-sysctl-v2-13-7a5060b11447@weissschuh.net> X-Originating-IP: [106.210.248.38] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002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kn7FO5tyPsyDz7rSmHuVMzK3be/BjMbXadN3rV3ovMJz9EiGaf3OPplG1wSbFV 9Jod35a/O38uObkwqn3BfI2TF6Wk2YJMivfrr+CUvX8tKqi+eOsGWWnZrfOUJ3VE1nwvLDtj 0uWv+r7H6XSW+7HkL/ueV6YosRRnJBpqMRcVJwIAFw0JiIkDAAA= X-CMS-MailID: 20231207113111eucas1p2d8a3b27e91bf4cf00c33d717cdd2bf9e X-Msg-Generator: CA X-RootMTR: 20231204075921eucas1p1ba1617c3d261249f38c78c8e3d96239c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231204075921eucas1p1ba1617c3d261249f38c78c8e3d96239c References: <20231204-const-sysctl-v2-0-7a5060b11447@weissschuh.net> <20231204-const-sysctl-v2-13-7a5060b11447@weissschuh.net> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 07 Dec 2023 03:31:36 -0800 (PST) --ce6zcdvlndypsxv7 Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable This is the patch that I said could be on its own to facilitate review On Mon, Dec 04, 2023 at 08:52:26AM +0100, Thomas Wei=DFschuh wrote: > In a future commit the sysctl core will only use > "const struct ctl_table". As a preparation for that move this mutable > field from "struct ctl_table" to "struct ctl_table_header". >=20 > This is also more correct in general as this is in fact a property of > the header and not the table itself. >=20 > Signed-off-by: Thomas Wei=DFschuh > --- > fs/proc/proc_sysctl.c | 11 ++++++----- > include/linux/sysctl.h | 22 +++++++++++----------- > 2 files changed, 17 insertions(+), 16 deletions(-) >=20 > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c > index 689a30196d0c..a398cc77637f 100644 > --- a/fs/proc/proc_sysctl.c > +++ b/fs/proc/proc_sysctl.c > @@ -31,7 +31,7 @@ static const struct inode_operations proc_sys_dir_opera= tions; > =20 > /* Support for permanently empty directories */ > static struct ctl_table sysctl_mount_point[] =3D { > - {.type =3D SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY } > + { } > }; > =20 > /** > @@ -49,11 +49,11 @@ struct ctl_table_header *register_sysctl_mount_point(= const char *path) > EXPORT_SYMBOL(register_sysctl_mount_point); > =20 > #define sysctl_is_perm_empty_ctl_header(hptr) \ > - (hptr->ctl_table[0].type =3D=3D SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) > + (hptr->type =3D=3D SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) > #define sysctl_set_perm_empty_ctl_header(hptr) \ > - (hptr->ctl_table[0].type =3D SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) > + (hptr->type =3D SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY) > #define sysctl_clear_perm_empty_ctl_header(hptr) \ > - (hptr->ctl_table[0].type =3D SYSCTL_TABLE_TYPE_DEFAULT) > + (hptr->type =3D SYSCTL_TABLE_TYPE_DEFAULT) > =20 > void proc_sys_poll_notify(struct ctl_table_poll *poll) > { > @@ -231,7 +231,8 @@ static int insert_header(struct ctl_dir *dir, struct = ctl_table_header *header) > return -EROFS; > =20 > /* Am I creating a permanently empty directory? */ > - if (sysctl_is_perm_empty_ctl_header(header)) { > + if (header->ctl_table =3D=3D sysctl_mount_point || > + sysctl_is_perm_empty_ctl_header(header)) { Why do you have to check that it is equal to sysctl_mount_point? It should be enough to make sure that the type of PERMANENTLY_EMPTY. no? > if (!RB_EMPTY_ROOT(&dir->root)) > return -EINVAL; > sysctl_set_perm_empty_ctl_header(dir_h); > diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h > index ada36ef8cecb..061ea65104be 100644 > --- a/include/linux/sysctl.h > +++ b/include/linux/sysctl.h > @@ -137,17 +137,6 @@ struct ctl_table { > void *data; > int maxlen; > umode_t mode; > - /** > - * enum type - Enumeration to differentiate between ctl target types > - * @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations > - * @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently > - * empty directory target to serve > - * as mount point. > - */ > - enum { > - SYSCTL_TABLE_TYPE_DEFAULT, > - SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY > - } type; > proc_handler *proc_handler; /* Callback for text formatting */ > struct ctl_table_poll *poll; > void *extra1; > @@ -188,6 +177,17 @@ struct ctl_table_header { > struct ctl_dir *parent; > struct ctl_node *node; > struct hlist_head inodes; /* head for proc_inode->sysctl_inodes */ > + /** > + * enum type - Enumeration to differentiate between ctl target types > + * @SYSCTL_TABLE_TYPE_DEFAULT: ctl target with no special considerations > + * @SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY: Used to identify a permanently > + * empty directory target to serve > + * as mount point. > + */ > + enum { > + SYSCTL_TABLE_TYPE_DEFAULT, > + SYSCTL_TABLE_TYPE_PERMANENTLY_EMPTY > + } type; > }; > =20 > struct ctl_dir { >=20 > --=20 > 2.43.0 >=20 --=20 Joel Granados --ce6zcdvlndypsxv7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmVxrP0ACgkQupfNUreW QU/4CAv9G2jBKR2NiolqAwAvYHcTmNPtwVxq2ZOsMh0bFWdGtUxskZkfYiMnjdc/ 2SwCtBUjyweEacRbhiJdqYjWzjH8APKp0lpEze1CrHEZQ7Ug3Cq9UiK8+PFkD1Va bdFZJaVx2jXbeYf47ZE4rWClgrSW9E/8KqgnimtkVIw4aidcI4Ixjw8Ral0DC38I 22ZeqJALOtg/ayF9Uy1waCayVj6rupZoVR3sePIVZm4CtYCzO9eL/STgK8ONRzol A2beO02uZ6akJG9I0tzR2tZ6gvjTy1sTkTWBXKSGbKIVq2j2irRr16ek3i8Mr2PU QLgkumQZQiC3/HzRxO9rf9bfSvRcr42LexCNfcZOi1rLhme/YKgF702c1aWn6kv1 QI5GSBn1Q0HU884O/+X9glIAG9vf7bb2DAd4Jo7rsJNsoSei4pLFYD65qj/lM9Jr 5xTZGcx6/JtW3eo8ToGvRDnbyZjvppoeXTmHNRH3PYIu37RnLKjQgUz3fvSd67C5 Kk+zmfLi =rMjb -----END PGP SIGNATURE----- --ce6zcdvlndypsxv7--