lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 30 Aug 2018 16:19:31 -0700
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Eric Biggers <ebiggers@...nel.org>
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lib/parser.c: switch match_strdup() over to use
 kmemdup_nul()

On Thu, 30 Aug 2018 12:44:36 -0700 Eric Biggers <ebiggers@...nel.org> wrote:

> From: Eric Biggers <ebiggers@...gle.com>
> 
> This simplifies the code.  No change in behavior.
> 
> ...
>
> --- a/lib/parser.c
> +++ b/lib/parser.c
> @@ -327,10 +327,6 @@ EXPORT_SYMBOL(match_strlcpy);
>   */
>  char *match_strdup(const substring_t *s)
>  {
> -	size_t sz = s->to - s->from + 1;
> -	char *p = kmalloc(sz, GFP_KERNEL);
> -	if (p)
> -		match_strlcpy(p, s, sz);
> -	return p;
> +	return kmemdup_nul(s->from, s->to - s->from, GFP_KERNEL);
>  }
>  EXPORT_SYMBOL(match_strdup);

Huh.  I never noticed kmemdup_nul() fly past - it rather happened on
the sly.  We do have some fun goodies in there.

We could make match_strdup() an inline now.  But that will probably
produce a fatter kernel, as each callsite would then need to prepare
three args rather than one.

Powered by blists - more mailing lists