Re: [PATCH 2/4] proc/sysctl: add shared variables -1

From: Kees Cook
Date: Sat May 16 2020 - 22:38:13 EST


On Sat, May 16, 2020 at 11:05:53AM +0800, Xiaoming Ni wrote:
> On 2020/5/16 10:47, Kees Cook wrote:
> > On Sat, May 16, 2020 at 10:32:19AM +0800, Xiaoming Ni wrote:
> > > On 2020/5/16 0:05, Kees Cook wrote:
> > > > On Fri, May 15, 2020 at 05:06:28PM +0800, Xiaoming Ni wrote:
> > > > > On 2020/5/15 16:06, Kees Cook wrote:
> > > > > > On Fri, May 15, 2020 at 12:33:42PM +0800, Xiaoming Ni wrote:
> > > > > > > Add the shared variable SYSCTL_NEG_ONE to replace the variable neg_one
> > > > > > > used in both sysctl_writes_strict and hung_task_warnings.
> > > > > > >
> > > > > > > Signed-off-by: Xiaoming Ni <nixiaoming@xxxxxxxxxx>
> > > > > > > ---
> > > > > > > fs/proc/proc_sysctl.c | 2 +-
> > > > > > > include/linux/sysctl.h | 1 +
> > > > > > > kernel/hung_task_sysctl.c | 3 +--
> > > > > > > kernel/sysctl.c | 3 +--
> > > > > >
> > > > > > How about doing this refactoring in advance of the extraction patch?
> > > > > Before advance of the extraction patch, neg_one is only used in one file,
> > > > > does it seem to have no value for refactoring?
> > > >
> > > > I guess it doesn't matter much, but I think it's easier to review in the
> > > > sense that neg_one is first extracted and then later everything else is
> > > > moved.
> > > >
> > > Later, when more features sysctl interface is moved to the code file, there
> > > will be more variables that need to be extracted.
> > > So should I only extract the neg_one variable here, or should I extract all
> > > the variables used by multiple features?
> >
> > Hmm -- if you're going to do a consolidation pass, then nevermind, I
> > don't think order will matter then.
> >
> > Thank you for the cleanup! Sorry we're giving you back-and-forth advice!
> >
> > -Kees
> >
>
> Sorry, I don't fully understand.
> Does this mean that there is no need to adjust the patch order or the order
> of variables in sysctl_vals?
> Should I extract only SYSCTL_NEG_ONE or should I extract all variables?

I think either order is fine -- I though you were only doing 1 variable.
If you're don't a bunch, then I don't think order is important.

--
Kees Cook