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] [day] [month] [year] [list]
Message-ID: <76ab6eb2c848f6b33fe3cc910d754599e6b2d213.camel@surriel.com>
Date:   Fri, 18 Feb 2022 11:54:21 -0500
From:   Rik van Riel <riel@...riel.com>
To:     "Eric W. Biederman" <ebiederm@...ssion.com>
Cc:     linux-kernel@...r.kernel.org, kernel-team@...com,
        Chris Mason <clm@...com>,
        "Paul E. McKenney" <paulmck@...nel.org>,
        linux-fsdevel@...r.kernel.org,
        Giuseppe Scrivano <gscrivan@...hat.com>,
        Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [PATCH][RFC] ipc,fs: use rcu_work to free struct ipc_namespace

On Fri, 2022-02-18 at 10:08 -0600, Eric W. Biederman wrote:
> 
> Maybe I am reading the lifetimes wrong but is there
> any chance the code can just do something like the diff below?
> 
> AKA have a special version of kern_umount that does the call_rcu?
> 
> Looking at rcu_reclaim_tiny I think this use of mnt_rcu is valid.
> AKA reusing the rcu_head in the rcu callback.
> 
> 
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 40b994a29e90..7d7aaef1592e 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -4395,6 +4395,22 @@ void kern_unmount(struct vfsmount *mnt)
>  }
>  EXPORT_SYMBOL(kern_unmount);
>  
> +static void rcu_mntput(struct rcu_head *head)
> +{
> +       struct mount *mnt = container_of(head, struct mount,
> mnt_rcu);
> +       mntput(&mnt->mnt);
> +}
> +
> +void kern_rcu_unmount(struct vfsmount *mnt)
> +{
> +       /* release long term mount so mount point can be released */
> +       if (!IS_ERR_OR_NULL(mnt)) {
> +               struct mount *m = real_mount(mnt);
> +               m->mnt_ns = NULL;
> +               call_rcu(&m->mnt_rcu, rcu_mntput);
> +       }
> +}

OK, two comments here:

1) As Paul pointed out, we need to use call_rcu_work here,
   because rcu_mntput needs to run from a work item (or well,
   any process context) because of the rwlock.
2) No user of kern_unmount can use the vfsmount structure
   after kern_unmount returns. That means they could all use
   the RCU version, and no special version is needed.

Let me go test a patch that does that...

-- 
All Rights Reversed.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ