Re: [PATCH 2/5] fs: make ustat() and quotactl() killable in lookup
From: Jan Kara
Date: Thu Oct 22 2026 - 07:41:32 EST
On Wed 21-10-26 16:46:58, Josef Bacik wrote:
> user_get_super() looks up the superblock for a device number on behalf of
> ustat(2) and quotactl(2). If that superblock is still being mounted it
> waits for SB_BORN, and then for s_umount, in super_lock(). With a mount
> which is stuck on its device neither system call ever returns, and neither
> can be killed.
>
> Both fail if there is no superblock for the device, which is what
> user_get_super() returning NULL means to them. Use super_lock_killable()
> and return NULL when the task is killed.
>
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@xxxxxxx>
Honza
> ---
> fs/super.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/fs/super.c b/fs/super.c
> index 7164c92fe70e..40f92ffa39c1 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -1172,9 +1172,15 @@ struct super_block *user_get_super(dev_t dev, bool excl)
>
> for (sb_dev = super_dev_first(dev); sb_dev; sb_dev = super_dev_next(sb_dev)) {
> struct super_block *sb = sb_dev->sd_sb;
> + int ret;
>
> - if (!super_lock(sb, excl))
> + ret = super_lock_killable(sb, excl);
> + if (ret == -ENOENT)
> continue;
> + if (ret) {
> + super_dev_put(sb_dev);
> + return NULL;
> + }
>
> /* The pinned entry holds a passive reference, take our own. */
> refcount_inc(&sb->s_passive);
>
> --
> 2.55.0
>
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR