From: Julia Lawall <julia.lawall@inria.fr>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
Joel Granados <j.granados@samsung.com>,
Dan Carpenter <dan.carpenter@linaro.org>,
Kees Cook <keescook@chromium.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Iurii Zaikin <yzaikin@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v2 00/18] sysctl: constify sysctl ctl_tables
Date: Tue, 19 Dec 2023 21:39:56 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.22.394.2312192139150.3196@hadrien> (raw)
In-Reply-To: <a0d96e7b-544f-42d5-b8da-85bc4ca087a9@t-8ch.de>
[-- Attachment #1: Type: text/plain, Size: 4198 bytes --]
On Tue, 19 Dec 2023, Thomas Weißschuh wrote:
> Hi Luis and Julia,
>
> (Julia, there is a question and context for you inline, marked with your name)
>
> On 2023-12-18 13:21:49-0800, Luis Chamberlain wrote:
> > So we can split this up concentually in two:
> >
> > * constificaiton of the table handlers
> > * constification of the table struct itself
> >
> > On Sun, Dec 17, 2023 at 11:10:15PM +0100, Thomas Weißschuh wrote:
> > > The handlers can already be made const as shown in this series,
> >
> > The series did already produce issues with some builds, and so
> > Julia's point is confirmed that the series only proves hanlders
> > which you did build and for which 0-day has coverage for.
> >
> > The challenge here was to see if we could draw up a test case
> > that would prove this without build tests, and what occurred to
> > me was coccinelle or smatch.
>
> I used the following coccinelle script to find more handlers that I
> missed before:
>
> virtual patch
> virtual context
> virtual report
>
> @@
> identifier func;
> identifier ctl;
> identifier write;
> identifier buffer;
> identifier lenp;
> identifier ppos;
> type loff_t;
> @@
>
> int func(
> - struct ctl_table *ctl,
> + const struct ctl_table *ctl,
> int write, void *buffer, size_t *lenp, loff_t *ppos) { ... }
>
> It did not find any additional occurrences while it was able to match
> the existing changes.
>
> After that I manually reviewed all handlers that they are not modifying
> their table argument, which they don't.
>
> Should we do more?
>
>
> For Julia:
>
> Maybe you could advise on how to use coccinelle to find where a const
> function argument or one of its members are modified directly or passed
> to some other function as non-const arguments.
> See the coccinelle patch above.
>
> Is this possible?
I will propose something.
>
> > > > If that is indeed what you are proposing, you might not even need the
> > > > un-register step as all the mutability that I have seen occurs before
> > > > the register. So maybe instead of re-registering it, you can so a copy
> > > > (of the changed ctl_table) to a const pointer and then pass that along
> > > > to the register function.
> > >
> > > Tables that are modified, but *not* through the handler, would crop
> > > during the constification of the table structs.
> > > Which should be a second step.
> >
> > Instead of "croping up" at build time again, I wonder if we can do
> > better with coccinelle / smatch.
>
> As for smatch:
>
> Doesn't smatch itself run as part of a normal build [0]?
> So it would have the same visibility issues as the compiler itself.
I also believe that this is the case.
julia
> > Joel, and yes, what you described is what I was suggesting, that is to
> > avoid having to add a non-const handler a first step, instead we modify
> > those callers which do require to modify the table by first a
> > deregistration and later a registration. In fact to make this even
> > easier a new call would be nice so to aslo be able to git grep when
> > this is done in the kernel.
> >
> > But if what you suggest is true that there are no registrations which
> > later modify the table, we don't need that. It is the uncertainty that
> > we might have that this is a true statment that I wanted to challenge
> > to see if we could do better. Can we avoid this being a stupid
> > regression later by doing code analysis with coccinelle / smatch?
> >
> > The template of the above endeavor seems useful not only to this use
> > case but to any place in the kernel where this previously has been done
> > before, and hence my suggestion that this seems like a sensible thing
> > to think over to see if we could generalize.
>
> I'd like to split the series and submit the part up until and including
> the constification of arguments first and on its own.
> It keeps the subsystem maintainers out of the discussion of the core
> sysctl changes.
>
> I'll submit the core sysctl changes after I figure out proper responses
> to all review comments and we can do this in parallel to the tree-wide
> preparation.
>
> What do you think Luis and Joel?
>
> [0] https://repo.or.cz/smatch.git/blob/HEAD:/smatch_scripts/test_kernel.sh
>
next prev parent reply other threads:[~2023-12-19 20:40 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20231204075237eucas1p27966f7e7da014b5992d3eef89a8fde25@eucas1p2.samsung.com>
2023-12-04 7:52 ` Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 01/18] watchdog/core: remove sysctl handlers from public header Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 02/18] sysctl: delete unused define SYSCTL_PERM_EMPTY_DIR Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 03/18] sysctl: drop sysctl_is_perm_empty_ctl_table Thomas Weißschuh
2023-12-07 14:09 ` Joel Granados
2023-12-04 7:52 ` [PATCH v2 04/18] cgroup: bpf: constify ctl_table arguments and fields Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 05/18] seccomp: constify ctl_table arguments of utility functions Thomas Weißschuh
2023-12-04 22:12 ` Kees Cook
2023-12-04 7:52 ` [PATCH v2 06/18] hugetlb: " Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 07/18] utsname: constify ctl_table arguments of utility function Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 08/18] stackleak: don't modify ctl_table argument Thomas Weißschuh
2023-12-04 22:14 ` Kees Cook
2023-12-04 7:52 ` [PATCH v2 09/18] sysctl: treewide: constify ctl_table_root::set_ownership Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 10/18] sysctl: treewide: constify ctl_table_root::permissions Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 11/18] sysctl: treewide: constify ctl_table_header::ctl_table_arg Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 12/18] sysctl: treewide: constify the ctl_table argument of handlers Thomas Weißschuh
2023-12-04 22:17 ` Kees Cook
2023-12-05 9:50 ` kernel test robot
2023-12-05 16:05 ` kernel test robot
2023-12-04 7:52 ` [PATCH v2 13/18] sysctl: move sysctl type to ctl_table_header Thomas Weißschuh
2023-12-05 22:33 ` Luis Chamberlain
2023-12-05 22:41 ` Thomas Weißschuh
2023-12-05 22:50 ` Luis Chamberlain
2023-12-06 5:53 ` Thomas Weißschuh
2023-12-07 12:14 ` Joel Granados
2023-12-07 19:29 ` Thomas Weißschuh
2023-12-21 12:09 ` Joel Granados
2023-12-23 13:04 ` Thomas Weißschuh
2023-12-24 18:51 ` Joel Granados
2023-12-07 12:05 ` Joel Granados
2023-12-07 11:31 ` Joel Granados
2023-12-04 7:52 ` [PATCH v2 14/18] sysctl: move internal interfaces to const struct ctl_table Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 15/18] sysctl: allow registration of " Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 16/18] const_structs.checkpatch: add ctl_table Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 17/18] sysctl: make ctl_table sysctl_mount_point const Thomas Weißschuh
2023-12-04 7:52 ` [PATCH v2 18/18] sysctl: constify standard sysctl tables Thomas Weißschuh
2023-12-05 5:50 ` [PATCH v2 00/18] sysctl: constify sysctl ctl_tables Luis Chamberlain
2023-12-05 8:04 ` Thomas Weißschuh
2023-12-05 17:16 ` Thomas Weißschuh
2023-12-05 22:27 ` Luis Chamberlain
2023-12-07 11:23 ` Joel Granados
2023-12-07 11:19 ` Joel Granados
2023-12-07 19:23 ` Thomas Weißschuh
2023-12-07 11:05 ` Joel Granados
2023-12-07 10:43 ` Joel Granados
2023-12-07 19:19 ` Thomas Weißschuh
2023-12-08 9:59 ` Joel Granados
2023-12-11 11:25 ` Thomas Weißschuh
2023-12-12 9:09 ` Joel Granados
2023-12-13 7:51 ` Luis Chamberlain
2023-12-15 16:40 ` Thomas Weißschuh
2023-12-15 17:05 ` Julia Lawall
2023-12-17 12:02 ` Joel Granados
2023-12-17 22:10 ` Thomas Weißschuh
2023-12-18 21:21 ` Luis Chamberlain
2023-12-19 19:29 ` Thomas Weißschuh
2023-12-19 20:39 ` Julia Lawall [this message]
2023-12-19 21:09 ` Luis Chamberlain
2023-12-19 21:21 ` Julia Lawall
2023-12-20 0:09 ` Luis Chamberlain
2023-12-20 7:39 ` Julia Lawall
2023-12-20 14:34 ` Luis Chamberlain
2023-12-19 23:04 ` Julia Lawall
2023-12-21 12:44 ` Joel Granados
[not found] ` <CGME20231223120907eucas1p20afac63076e1e9d5aee6adaa101c0630@eucas1p2.samsung.com>
2023-12-21 12:36 ` Joel Granados
2023-12-21 12:12 ` Joel Granados
2023-12-13 7:47 ` Luis Chamberlain
2023-12-13 18:18 ` Eric W. Biederman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.22.394.2312192139150.3196@hadrien \
--to=julia.lawall@inria.fr \
--cc=dan.carpenter@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=j.granados@samsung.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=mcgrof@kernel.org \
--cc=yzaikin@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®