linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>,
	Iurii Zaikin <yzaikin@google.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Linux FS-devel Mailing List <linux-fsdevel@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] sysctl: use min() helper for namecmp()
Date: Mon, 1 Mar 2021 15:47:09 -0800	[thread overview]
Message-ID: <202103011546.9AA6D832@keescook> (raw)
In-Reply-To: <CAK7LNARXy_puE7KZp2vjzn_KcW5uZ_ba3O5zFX46yGULjNhpZg@mail.gmail.com>

On Sun, Feb 28, 2021 at 04:44:22PM +0900, Masahiro Yamada wrote:
> (CC: Andrew Morton)
> 
> A friendly reminder.
> 
> 
> This is just a minor clean-up.
> 
> If nobody picks it up,
> I hope perhaps Andrew Morton will do.
> 
> This patch:
> https://lore.kernel.org/patchwork/patch/1360092/
> 
> 
> 
> 
> 
> On Mon, Jan 4, 2021 at 5:33 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Make it slightly readable by using min().
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Acked-by: Kees Cook <keescook@chromium.org>

Feel free to take this via your tree Masahiro. Thanks!

-Kees

> > ---
> >
> >  fs/proc/proc_sysctl.c | 7 +------
> >  1 file changed, 1 insertion(+), 6 deletions(-)
> >
> > diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> > index 317899222d7f..86341c0f0c40 100644
> > --- a/fs/proc/proc_sysctl.c
> > +++ b/fs/proc/proc_sysctl.c
> > @@ -94,14 +94,9 @@ static void sysctl_print_dir(struct ctl_dir *dir)
> >
> >  static int namecmp(const char *name1, int len1, const char *name2, int len2)
> >  {
> > -       int minlen;
> >         int cmp;
> >
> > -       minlen = len1;
> > -       if (minlen > len2)
> > -               minlen = len2;
> > -
> > -       cmp = memcmp(name1, name2, minlen);
> > +       cmp = memcmp(name1, name2, min(len1, len2));
> >         if (cmp == 0)
> >                 cmp = len1 - len2;
> >         return cmp;
> > --
> > 2.27.0
> >
> 
> 
> -- 
> Best Regards
> Masahiro Yamada

-- 
Kees Cook

Reviewed-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

  reply	other threads:[~2021-03-02 12:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-04  8:32 [PATCH] sysctl: use min() helper for namecmp() Masahiro Yamada
2021-01-06 23:38 ` Kees Cook
2021-02-28  7:44 ` Masahiro Yamada
2021-03-01 23:47   ` Kees Cook [this message]
2021-04-11 13:30     ` Masahiro Yamada

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=202103011546.9AA6D832@keescook \
    --to=keescook@chromium.org \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).