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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdXT63aJ2hXJg9mtMv-PZYT7CEw+ab-j42_VoFB-ib+ghg@mail.gmail.com>
Date:	Fri, 15 Jan 2016 13:29:06 +0100
From:	Geert Uytterhoeven <geert@...ux-m68k.org>
To:	Tejun Heo <tj@...nel.org>
Cc:	"David S. Miller" <davem@...emloft.net>, pablo@...filter.org,
	Patrick McHardy <kaber@...sh.net>, kadlec@...ckhole.kfki.hu,
	Daniel Borkmann <daniel@...earbox.net>,
	daniel.wagner@...-carit.de, nhorman@...driver.com,
	Zefan Li <lizefan@...wei.com>,
	Johannes Weiner <hannes@...xchg.org>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	netfilter-devel@...r.kernel.org, coreteam@...filter.org,
	cgroups@...r.kernel.org,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	kernel-team@...com, ninasc@...com,
	Josh Triplett <josh@...htriplett.org>
Subject: Re: [PATCH 2/8] kernfs: implement kernfs_walk_and_get()

On Mon, Dec 7, 2015 at 11:38 PM, Tejun Heo <tj@...nel.org> wrote:
> Implement kernfs_walk_and_get() which is similar to
> kernfs_find_and_get() but can walk a path instead of just a name.
>
> v2: Use strlcpy() instead of strlen() + memcpy() as suggested by
>     David.
>
> Signed-off-by: Tejun Heo <tj@...nel.org>
> Acked-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: David Miller <davem@...emloft.net>
> ---
>  fs/kernfs/dir.c        | 46 ++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/kernfs.h | 12 ++++++++++++
>  2 files changed, 58 insertions(+)
>
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index 91e0045..742bf4a 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -694,6 +694,29 @@ static struct kernfs_node *kernfs_find_ns(struct kernfs_node *parent,
>         return NULL;
>  }
>
> +static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent,
> +                                         const unsigned char *path,
> +                                         const void *ns)
> +{
> +       static char path_buf[PATH_MAX]; /* protected by kernfs_mutex */

This is showing up in bloat-o-meter as increasing kernel size by 4 KiB.

> +       size_t len = strlcpy(path_buf, path, PATH_MAX);

The full input string is copied because strsep() replaces the delimiters by
zeroes?
Can this be handled in some other way?

> +       char *p = path_buf;
> +       char *name;
> +
> +       lockdep_assert_held(&kernfs_mutex);
> +
> +       if (len >= PATH_MAX)
> +               return NULL;
> +
> +       while ((name = strsep(&p, "/")) && parent) {
> +               if (*name == '\0')
> +                       continue;
> +               parent = kernfs_find_ns(parent, name, ns);
> +       }
> +
> +       return parent;
> +}

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ