linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sysctl: use min() helper for namecmp()
@ 2021-01-04  8:32 Masahiro Yamada
  2021-01-06 23:38 ` Kees Cook
  2021-02-28  7:44 ` Masahiro Yamada
  0 siblings, 2 replies; 5+ messages in thread
From: Masahiro Yamada @ 2021-01-04  8:32 UTC (permalink / raw)
  To: Luis Chamberlain, Kees Cook, Iurii Zaikin, Alexey Dobriyan,
	linux-fsdevel
  Cc: Masahiro Yamada, linux-kernel

Make it slightly readable by using min().

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] sysctl: use min() helper for namecmp()
  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
  1 sibling, 0 replies; 5+ messages in thread
From: Kees Cook @ 2021-01-06 23:38 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Luis Chamberlain, Iurii Zaikin, Alexey Dobriyan, linux-fsdevel,
	linux-kernel

On Mon, Jan 04, 2021 at 05:32:21PM +0900, Masahiro Yamada wrote:
> Make it slightly readable by using min().
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

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

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] sysctl: use min() helper for namecmp()
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Masahiro Yamada @ 2021-02-28  7:44 UTC (permalink / raw)
  To: Luis Chamberlain, Kees Cook, Iurii Zaikin, Alexey Dobriyan,
	Linux FS-devel Mailing List
  Cc: Linux Kernel Mailing List, Andrew Morton

(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>
> ---
>
>  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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] sysctl: use min() helper for namecmp()
  2021-02-28  7:44 ` Masahiro Yamada
@ 2021-03-01 23:47   ` Kees Cook
  2021-04-11 13:30     ` Masahiro Yamada
  0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2021-03-01 23:47 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Luis Chamberlain, Iurii Zaikin, Alexey Dobriyan,
	Linux FS-devel Mailing List, Linux Kernel Mailing List,
	Andrew Morton

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] sysctl: use min() helper for namecmp()
  2021-03-01 23:47   ` Kees Cook
@ 2021-04-11 13:30     ` Masahiro Yamada
  0 siblings, 0 replies; 5+ messages in thread
From: Masahiro Yamada @ 2021-04-11 13:30 UTC (permalink / raw)
  To: Kees Cook
  Cc: Luis Chamberlain, Iurii Zaikin, Alexey Dobriyan,
	Linux FS-devel Mailing List, Linux Kernel Mailing List,
	Andrew Morton

On Tue, Mar 2, 2021 at 8:47 AM Kees Cook <keescook@chromium.org> wrote:
>
> 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

Applied to linux-kbuild.




-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-04-11 13:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-04-11 13:30     ` Masahiro Yamada

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).