Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2567281rdb; Mon, 4 Dec 2023 00:44:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHHchIFNLaNEnhW5iuQLtlLxYPXr12bExXJSeu9XWi+5bgj3kpsX8pUFKEwAW70gsVSdbxm X-Received: by 2002:a17:902:f54c:b0:1d0:6ffd:e2b0 with SMTP id h12-20020a170902f54c00b001d06ffde2b0mr4718993plf.74.1701679465434; Mon, 04 Dec 2023 00:44:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701679465; cv=none; d=google.com; s=arc-20160816; b=VeHWfUsxdHFmhStiNcRQObdamE5d19RLSbkZHvNqvTHM8ouxN5XECVm5pmMdpEVi6g D2SI/6cIdBern4sWolLrCgQnmZxFZBoRDf0VSprKu7aWIi4JnyOmcEJujUzyLrfAtO9j dRAwHtXez/Otgj3poWVc9VhcbMHgmHvKpK6vIN+x3K8E/WM/5SoMnGC1yIHdku9Bff5U h0k8t6j8ge3sQ4tM4rUsV9eMGUEzt/SXbnZJNNP9OOc7xHl8ypGyO60fayzzI0dNaZIg B535heH8IKxBwyI2LQgqxB6tnv8Awbdz92PqUVGt3/uyzQxt7NDICdCG66Rz2pCmXlYt f8XQ== 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=hUZsAmSk95WEIzJ9RUcGUSd+zr2Kqs9vErQ81TuxOmw=; fh=F+seLicu2+0lodrWqq1yOikAPCIvf0PgOELkKn9NRr4=; b=ex8Q6NauaI5kyuOa6A33HKbAaENERtdb3vkaNCHVc2Akb1QPgd/ic9FyF6OGkjerE7 Ywi/8HoxZsDv8MBjj0eDeGUHvXTexT5JDhyW2ufpvuLjzgxBiB55I8etiTKplEsLnFRM hQbSQUEeiTpC/OWDLaNIOkF8SgnNl+ncuVwEYQpyt1olIqesK4B+4zl5P0wafYYS+lTM MJgB98FD7wZIPQ0uvxIdQthZQNnwm6/gNIsLkmzd5ba7dAnLYBoYIBn3uLA1xfj9la7q nS/eoMl7hQ8e8mdBqPHeHwpM8bmF8gJ92Dq8GblxGdSNsZwYvoholXbgdiMH9PKyugdG HRKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Umyn7Y5N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id jh19-20020a170903329300b001d0750f2942si3140120plb.253.2023.12.04.00.44.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 00:44:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Umyn7Y5N; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 65845805C3E5; Mon, 4 Dec 2023 00:44:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235364AbjLDIoK (ORCPT + 99 others); Mon, 4 Dec 2023 03:44:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235375AbjLDInv (ORCPT ); Mon, 4 Dec 2023 03:43:51 -0500 Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03B1110FA; Mon, 4 Dec 2023 00:43:20 -0800 (PST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20231204084318euoutp01ee7dabbcf18ad0df6fe293845daa7740~dlGWKlQFn0169201692euoutp01x; Mon, 4 Dec 2023 08:43:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20231204084318euoutp01ee7dabbcf18ad0df6fe293845daa7740~dlGWKlQFn0169201692euoutp01x DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1701679398; bh=hUZsAmSk95WEIzJ9RUcGUSd+zr2Kqs9vErQ81TuxOmw=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=Umyn7Y5Ni5ryV1PKXkC1aOz2hQOIvlq3C6kXoRHoHyIGXlbojaUGfsk9vahlsHr/Z OkS6cLxVX5xBjsiqpt6L/C7Lxl8YRqAmsKZfLNbjbHhnvymriH3vTRVkJKHm6dwokl slLvduy8tgZTFgBStqCwOH857XEz+XDEqwMP0pF8= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20231204084317eucas1p11dd9ab492fb8a71efd4c1e736771233f~dlGVxcoLy0755207552eucas1p1C; Mon, 4 Dec 2023 08:43:17 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 77.A9.09814.5219D656; Mon, 4 Dec 2023 08:43:17 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20231204084317eucas1p14c79a170988056cc2ad7499dadc1d3b0~dlGVQgJkM1146411464eucas1p1-; Mon, 4 Dec 2023 08:43:17 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20231204084317eusmtrp1fde1045f9829d11dc3aaf0854c8c6c70~dlGVPf6sY1513115131eusmtrp1U; Mon, 4 Dec 2023 08:43:17 +0000 (GMT) X-AuditID: cbfec7f4-727ff70000002656-29-656d91257e0a Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 11.5A.09146.4219D656; Mon, 4 Dec 2023 08:43:16 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20231204084316eusmtip2f87fc24f956edd53b912687a007e35e7~dlGVDwNiu2035720357eusmtip2U; Mon, 4 Dec 2023 08:43:16 +0000 (GMT) Received: from localhost (106.110.32.133) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 4 Dec 2023 08:43:16 +0000 Date: Mon, 4 Dec 2023 09:43:14 +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 RFC 0/7] sysctl: constify sysctl ctl_tables Message-ID: <20231204084314.i7tvvejhlppdz5zd@localhost> MIME-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="qjmppfb42xwa7qzq" Content-Disposition: inline In-Reply-To: X-Originating-IP: [106.110.32.133] X-ClientProxiedBy: CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) To CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJKsWRmVeSWpSXmKPExsW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PVSQxXpcwe2yW9+HNIsuCjHkW2Vln/truF3n56O7MDI81CdPrHP4b5u1Vqn14X36HUu+b L3cCGmN67LMEF1U9UWIpzkg01GIuKk4EAJtbPECLAwAA X-CMS-MailID: 20231204084317eucas1p14c79a170988056cc2ad7499dadc1d3b0 X-Msg-Generator: CA X-RootMTR: 20231125125305eucas1p2ebdf870dd8ef46ea9d346f727b832439 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20231125125305eucas1p2ebdf870dd8ef46ea9d346f727b832439 References: <20231125-const-sysctl-v1-0-5e881b0e0290@weissschuh.net> <20231127101323.sdnibmf7c3d5ovye@localhost> <475cd5fa-f0cc-4b8b-9e04-458f6d143178@t-8ch.de> <20231201163120.depfyngsxdiuchvc@localhost> 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 autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 00:44:24 -0800 (PST) --qjmppfb42xwa7qzq Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hey I see that you sent a V2. I'll try to get to it at the end of the week. On Sun, Dec 03, 2023 at 04:37:01PM +0100, Thomas Wei=DFschuh wrote: > Hi Joel, >=20 > On 2023-12-01 17:31:20+0100, Joel Granados wrote: > > Hey Thomas. > >=20 > > Thx for the clarifications. I did more of a deep dive into your set and > > have additional comments (in line). I think const-ing all this is a good > > approach. The way forward is to be able to see the entire patch set of > > changes in a V1 or a shared repo somewhere to have a better picture of > > what is going on. By the "entire patchset" I mean all the changes that > > you described in the "full process". >=20 > All the changes will be a lot. I don't think the incremental value to > migrate all proc_handlers versus the work is useful for the discussion. > I can however write up my proposed changes for the sysctl core properly > and submit them as part of the next revision. Looking forward to seeing them in V2 >=20 > > On Tue, Nov 28, 2023 at 09:18:30AM +0100, Thomas Wei=DFschuh wrote: > > > Hi Joel, > > >=20 > > > On 2023-11-27 11:13:23+0100, Joel Granados wrote: > > > > In general I would like to see more clarity with the motivation and= I > > > > would also expect some system testing. My comments inline: <--- snip ---> > > is all sysctl code and cannot be chunked up because of dependencies, > > then it should be ok to do it in one go. > >=20 > > > > > * Migrate all other sysctl handlers to proc_handler_new. > > > > > * Drop the old proc_handler_field. > > > > > * Fix the sysctl core to not modify the tables anymore. > > > > > * Adapt public sysctl APIs to take "const struct ctl_table *". > > > > > * Teach checkpatch.pl to warn on non-const "struct ctl_table" > > > > > definitions. >=20 > > Have you considered how to ignore the cases where the ctl_tables are > > supposed to be non-const when they are defined (like in the network > > code that we were discussing earlier) >=20 > As it would be a checkpatch warning it can be ignore while writing the > patch and it won't trigger afterwards. I mention coccinelle it is able to identify const vs non-const uses of the ctl_table and only warn on the cases where it makes sense. This would remove false negatives from pushing patches through. >=20 > > > > > * Migrate definitions of "struct ctl_table" to "const" where appl= icable. > > These migrations are treewide and are usually reviewed by a wider > > audience. You might need to chunk it up to make the review more palpable > > for the other maintainers. >=20 > Ack. >=20 > > > > > =20 > > > > >=20 > > > > > Notes: > > > > >=20 > > > > > Just casting the function pointers around would trigger > > > > > CFI (control flow integrity) warnings. > > > > >=20 > > > > > The name of the new handler "proc_handler_new" is a bit too long = messing > > > > > up the alignment of the table definitions. > > > > > Maybe "proc_handler2" or "proc_handler_c" for (const) would be be= tter. > > >=20 > > > > indeed the name does not say much. "_new" looses its meaning quite = fast > > > > :) > > >=20 > > > Hopefully somebody comes up with a better name! >=20 > > I would like to avoid this all together and just do add the const to the > > existing "proc_handler" >=20 > Ack. >=20 > > >=20 > > > > In my experience these tree wide modifications are quite tricky. Ha= ve you > > > > run any tests to see that everything is as it was? sysctl selftests= and > > > > 0-day come to mind. > > >=20 > > > I managed to miss one change in my initial submission: > > > With the hunk below selftests and typing emails work. > > >=20 > > > --- a/fs/proc/proc_sysctl.c > > > +++ b/fs/proc/proc_sysctl.c > > > @@ -1151,7 +1151,7 @@ static int sysctl_check_table(const char *path,= struct ctl_table_header *header) > > > else > > > err |=3D sysctl_check_table_array(pat= h, entry); > > > } > > > - if (!entry->proc_handler) > > > + if (!entry->proc_handler && !entry->proc_handler_new) > > > err |=3D sysctl_err(path, entry, "No proc_han= dler"); > > > =20 > > > if ((entry->mode & (S_IRUGO|S_IWUGO)) !=3D entry->mod= e) > > >=20 > > > > [..] > > >=20 > > > [0] 43a7206b0963 ("driver core: class: make class_register() take a c= onst *") > > > [1] https://lore.kernel.org/lkml/20230930050033.41174-1-wedsonaf@gmai= l.com/ >=20 > Thanks for the feedback! >=20 > Thomas --=20 Joel Granados --qjmppfb42xwa7qzq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmVtkRwACgkQupfNUreW QU+y6gwAjmwiTajL3mLXXNgL5w17CaV42APC0OLNo5wj9QChvb9jjfHkSUyhM5Yu jkfQdXAvoGv/T1iKWIiO+lD35CNuLrZ+4Jdahw8jk0lPNp7B8qbRTfd4GcVtFwQX kcOTEZ1hRi7/cXf9yqllN8L5QZx0aALg8N3CM1/d/19nnZFZK+RfhS3ELSps6iIv xv4VLF+1WbtnKgMQBm9DR6mPt8igvuTY/0sT2haTM8JQ/SomWeID2ouHqViYD+CU hENTI608WD3x5oB/oozWwGfJhKEncYBbUKGpQH6hxnsFU5s9CjWF28j2bHCCSXW6 F3XKm4c+2bkch6oPvgP0h27ZJVNHZAKUXIUc3zCGwFg6D6w/PitbPkcaGa6wco7s P+rx6EWENX/6zD0iUReFSE+1WRYpqkh3j/qDLaO2Zc8M84tTAgRxv+ZsIlTEWSFz sRYZvi/y9k5cjrmmqhNCDPeNV/sCiPw85ftak5aNh8/5gJDdb2Ei8HCXj3ryu6Hp 2WUuz9HZ =KDf2 -----END PGP SIGNATURE----- --qjmppfb42xwa7qzq--