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]
Date:   Thu, 10 Nov 2022 19:00:52 +0100
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Chengming Zhou <zhouchengming@...edance.com>
Cc:     tj@...nel.org, linux-kernel@...r.kernel.org,
        syzbot+2fdf66e68f5f882c1074@...kaller.appspotmail.com
Subject: Re: [PATCH] fs/kernfs: Fix lockdep warning in kernfs_active()

On Wed, Nov 09, 2022 at 08:04:15PM +0800, Chengming Zhou wrote:
> syzbot found a lockdep warning in kernfs_find_and_get_node_by_id(),
> bisected to the commit c25491747b21 ("kernfs: Add KERNFS_REMOVING flags"),
> which didn't hold kernfs_rwsem before call kernfs_active(kn).
> 
> Since kernfs_find_and_get_node_by_id() doesn't have to get active count
> of kn, only need to get a stable refcount of kn, so it should be enough
> to just check kn has been KERNFS_ACTIVATED.
> 
> Reported-by: syzbot+2fdf66e68f5f882c1074@...kaller.appspotmail.com
> Fixes: c25491747b21 ("kernfs: Add KERNFS_REMOVING flags")
> Signed-off-by: Chengming Zhou <zhouchengming@...edance.com>
> ---
>  fs/kernfs/dir.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index 6acd9c3d4cff..08f0f1570cd7 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -705,7 +705,13 @@ struct kernfs_node *kernfs_find_and_get_node_by_id(struct kernfs_root *root,
>  			goto err_unlock;
>  	}
>  
> -	if (unlikely(!kernfs_active(kn) || !atomic_inc_not_zero(&kn->count)))
> +	/*
> +	 * ACTIVATED is protected with kernfs_mutex but it was clear when
> +	 * @kn was added to idr and we just wanna see it set.  No need to
> +	 * grab kernfs_mutex.
> +	 */
> +	if (unlikely(!(kn->flags & KERNFS_ACTIVATED) ||
> +		     !atomic_inc_not_zero(&kn->count)))
>  		goto err_unlock;
>  
>  	spin_unlock(&kernfs_idr_lock);
> -- 
> 2.37.2
> 

Shouldn't:
	https://lore.kernel.org/r/Y0SwqBsZ9BMmZv6x@slm.duckdns.org fix this
instead?

Powered by blists - more mailing lists