From: Jeff Layton <jlayton@kernel.org>
To: Al Viro <viro@zeniv.linux.org.uk>, linux-fsdevel@vger.kernel.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Christian Brauner <brauner@kernel.org>,
linux-ext4@vger.kernel.org, linux-nfs@vger.kernel.org,
Miklos Szeredi <miklos@szeredi.hu>,
linux-cifs@vger.kernel.org
Subject: Re: [PATCH 01/13] fs/super.c: don't drop ->s_user_ns until we free struct super_block itself
Date: Mon, 05 Feb 2024 07:36:42 -0500 [thread overview]
Message-ID: <bc36104e67120e6e86423fe2e83f9745380c8575.camel@kernel.org> (raw)
In-Reply-To: <20240204021739.1157830-1-viro@zeniv.linux.org.uk>
On Sun, 2024-02-04 at 02:17 +0000, Al Viro wrote:
> Avoids fun races in RCU pathwalk... Same goes for freeing LSM shite
> hanging off super_block's arse.
>
> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> ---
> fs/super.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/fs/super.c b/fs/super.c
> index d35e85295489..d6efeba0d0ce 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -274,9 +274,10 @@ static void destroy_super_work(struct work_struct *work)
> {
> struct super_block *s = container_of(work, struct super_block,
> destroy_work);
> - int i;
> -
> - for (i = 0; i < SB_FREEZE_LEVELS; i++)
> + security_sb_free(s);
> + put_user_ns(s->s_user_ns);
> + kfree(s->s_subtype);
> + for (int i = 0; i < SB_FREEZE_LEVELS; i++)
> percpu_free_rwsem(&s->s_writers.rw_sem[i]);
nit: put_user_ns can call __put_user_ns which ends up queueing yet
another workqueue job. It might be nice in the future to come up with a
way to do the work that __put_user_ns does directly here instead of
queueing it.
OTOH, maybe it's not worth the effort...
> kfree(s);
> }
> @@ -296,9 +297,6 @@ static void destroy_unused_super(struct super_block *s)
> super_unlock_excl(s);
> list_lru_destroy(&s->s_dentry_lru);
> list_lru_destroy(&s->s_inode_lru);
> - security_sb_free(s);
> - put_user_ns(s->s_user_ns);
> - kfree(s->s_subtype);
> shrinker_free(s->s_shrink);
> /* no delays needed */
> destroy_super_work(&s->destroy_work);
> @@ -409,9 +407,6 @@ static void __put_super(struct super_block *s)
> WARN_ON(s->s_dentry_lru.node);
> WARN_ON(s->s_inode_lru.node);
> WARN_ON(!list_empty(&s->s_mounts));
> - security_sb_free(s);
> - put_user_ns(s->s_user_ns);
> - kfree(s->s_subtype);
> call_rcu(&s->rcu, destroy_super_rcu);
> }
> }
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2024-02-05 12:36 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-04 2:14 [PATCHES] RCU pathwalk race fixes Al Viro
2024-02-04 2:17 ` [PATCH 01/13] fs/super.c: don't drop ->s_user_ns until we free struct super_block itself Al Viro
2024-02-04 2:17 ` [PATCH 02/13] rcu pathwalk: prevent bogus hard errors from may_lookup() Al Viro
2024-02-05 12:26 ` Christian Brauner
2024-02-04 2:17 ` [PATCH 03/13] affs: free affs_sb_info with kfree_rcu() Al Viro
2024-02-05 12:26 ` Christian Brauner
2024-02-04 2:17 ` [PATCH 04/13] exfat: move freeing sbi, upcase table and dropping nls into rcu-delayed helper Al Viro
2024-02-05 12:27 ` Christian Brauner
2024-02-04 2:17 ` [PATCH 05/13] hfsplus: switch to rcu-delayed unloading of nls and freeing ->s_fs_info Al Viro
2024-02-05 12:27 ` Christian Brauner
2024-02-04 2:17 ` [PATCH 06/13] afs: fix __afs_break_callback() / afs_drop_open_mmap() race Al Viro
2024-02-05 12:28 ` Christian Brauner
2024-02-04 2:17 ` [PATCH 07/13] nfs: make nfs_set_verifier() safe for use in RCU pathwalk Al Viro
2024-02-05 12:29 ` Christian Brauner
2024-02-04 2:17 ` [PATCH 08/13] nfs: fix UAF on pathwalk running into umount Al Viro
2024-02-05 12:29 ` Christian Brauner
2024-02-04 2:17 ` [PATCH 09/13] procfs: move dropping pde and pid from ->evict_inode() to ->free_inode() Al Viro
2024-02-05 12:30 ` Christian Brauner
2024-02-04 2:17 ` [PATCH 10/13] procfs: make freeing proc_fs_info rcu-delayed Al Viro
2024-02-05 12:31 ` Christian Brauner
2024-02-04 2:17 ` [PATCH 11/13] fuse: fix UAF in rcu pathwalks Al Viro
2024-02-05 12:31 ` Christian Brauner
2024-02-05 13:51 ` Miklos Szeredi
2024-03-04 14:36 ` Amir Goldstein
2024-03-05 12:43 ` Miklos Szeredi
2024-03-06 10:18 ` Amir Goldstein
2024-03-06 10:21 ` Miklos Szeredi
2024-02-04 2:17 ` [PATCH 12/13] cifs_get_link(): bail out in unsafe case Al Viro
2024-02-04 15:45 ` Steve French
2024-02-04 16:25 ` Al Viro
2024-02-04 16:41 ` Al Viro
2024-02-04 2:17 ` [PATCH 13/13] ext4_get_link(): fix breakage in RCU mode Al Viro
2024-02-05 12:24 ` [PATCH 01/13] fs/super.c: don't drop ->s_user_ns until we free struct super_block itself Christian Brauner
2024-02-05 12:36 ` Jeff Layton [this message]
2024-02-04 2:27 ` RCU pathwalk audit notes Al Viro
2024-02-05 12:48 ` [PATCHES] RCU pathwalk race fixes Jeff Layton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bc36104e67120e6e86423fe2e83f9745380c8575.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=brauner@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).