lkml.org 
[lkml]   [2022]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] proc: "mount -o lookup=" support
On Wed, Jan 19, 2022 at 06:48:03PM +0300, Alexey Dobriyan wrote:
> # mount -t proc -o lookup=/ proc /proc

> +static int proc_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc)
> +{
> + struct proc_fs_context *src = fc->fs_private;
> + struct proc_fs_context *dst;
> +
> + dst = kmemdup(src, sizeof(struct proc_fs_context), GFP_KERNEL);
> + if (!dst) {
> + return -ENOMEM;
> + }
> +
> + dst->lookup_list = kmemdup(dst->lookup_list, dst->lookup_list_len, GFP_KERNEL);
> + if (!dst->lookup_list) {
> + kfree(dst);
> + return -ENOMEM;
> + }
> + get_pid_ns(dst->pid_ns);
> +
> + fc->fs_private = dst;
> + return 0;
> +}

Stephen, sorry for not replying earlier.

I don't pretend to understand fully what ->dup() is supposed to do.
And the above code was not tested.

In particular

p->a = kmemdup(p->a, ...)

reads like "MEMORY LEAK" on the first glance but it is not.

Understanding ->dup is the next thing.

\
 
 \ /
  Last update: 2022-01-19 16:57    [W:0.077 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site