From: Damien Le Moal <dlemoal@kernel.org>
To: Zizhi Wo <wozizhi@huaweicloud.com>,
axboe@kernel.dk, nilay@linux.ibm.com,
linux-block@vger.kernel.org, kch@nvidia.com,
johannes.thumshirn@wdc.com, kbusch@kernel.org,
bvanassche@acm.org
Cc: linux-kernel@vger.kernel.org, yangerkun@huawei.com,
chengzhihao1@huawei.com, wozizhi@huawei.com
Subject: Re: [PATCH V2 1/6] null_blk: use DEFINE_MUTEX for the file-scope mutex
Date: Tue, 7 Jul 2026 13:07:11 +0900 [thread overview]
Message-ID: <f448bfcf-207d-4550-b268-efa5a51a6603@kernel.org> (raw)
In-Reply-To: <20260707025542.1299859-2-wozizhi@huaweicloud.com>
On 7/7/26 11:55, Zizhi Wo wrote:
> From: Zizhi Wo <wozizhi@huawei.com>
>
> In null_init(), mutex_init(&lock) currently happens after
> configfs_register_subsystem(), which exposes the nullb subsystem to
> userspace. A racing mkdir() into /sys/kernel/config/nullb/ can reach
> null_find_dev_by_name() -> mutex_lock(&lock) before the mutex is
> initialized, trigger warning:
>
> [ 123.137788] DEBUG_LOCKS_WARN_ON(lock->magic != lock)
> [ 123.137796] WARNING: kernel/locking/mutex.c:159 at mutex_lock+0x171/0x1c0, CPU#13: mkdir/1301
> [ 123.140090] Modules linked in: null_blk(+) nft_fib_inet nft_fib_ipv4
> ......
> [ 123.154926] Call Trace:
> [ 123.155172] <TASK>
> [ 123.155419] ? __pfx_mutex_lock+0x10/0x10
> [ 123.156181] ? __pfx__raw_spin_lock+0x10/0x10
> [ 123.156571] nullb_group_make_group+0x20/0x100 [null_blk]
> [ 123.157011] configfs_mkdir+0x47b/0xc70
> [ 123.157337] ? __pfx_configfs_mkdir+0x10/0x10
> [ 123.157719] ? may_create_dentry+0x242/0x2e0
> [ 123.158061] vfs_mkdir+0x2a9/0x6c0
> [ 123.158352] filename_mkdirat+0x3dc/0x500
> [ 123.158710] ? __pfx_filename_mkdirat+0x10/0x10
> [ 123.159070] ? strncpy_from_user+0x3a/0x1d0
> [ 123.159413] __x64_sys_mkdir+0x6b/0x90
> [ 123.159760] do_syscall_64+0xea/0x600
>
> Replace the runtime mutex_init(&lock) with a static DEFINE_MUTEX(lock)
> declaration to fix this issue.
>
> Fixes: 49c3b9266a71 ("block: null_blk: Improve device creation with configfs")
> Suggested-by: Bart Van Assche <bvanassche@acm.org>
> Signed-off-by: Zizhi Wo <wozizhi@huawei.com>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-07-07 4:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 2:55 [PATCH V2 0/6] null_blk: fix init/exit races, leaks and cleanup Zizhi Wo
2026-07-07 2:55 ` [PATCH V2 1/6] null_blk: use DEFINE_MUTEX for the file-scope mutex Zizhi Wo
2026-07-07 4:07 ` Damien Le Moal [this message]
2026-07-07 2:55 ` [PATCH V2 2/6] null_blk: give the file-scope mutex a descriptive name Zizhi Wo
2026-07-07 4:16 ` Damien Le Moal
2026-07-07 6:24 ` Zizhi Wo
2026-07-07 6:28 ` Damien Le Moal
2026-07-07 6:45 ` Zizhi Wo
2026-07-07 2:55 ` [PATCH V2 3/6] null_blk: register configfs subsystem after creating default devices Zizhi Wo
2026-07-07 4:18 ` Damien Le Moal
2026-07-07 2:55 ` [PATCH V2 4/6] null_blk: move unregister_blkdev() after destroying dev in null_exit() Zizhi Wo
2026-07-07 4:19 ` Damien Le Moal
2026-07-07 2:55 ` [PATCH V2 5/6] null_blk: don't locklessly overwrite dev state after apply_fn Zizhi Wo
2026-07-07 3:38 ` Zizhi Wo
2026-07-07 4:21 ` Damien Le Moal
2026-07-07 7:33 ` Nilay Shroff
2026-07-07 8:24 ` Zizhi Wo
2026-07-07 2:55 ` [PATCH V2 6/6] null_blk: free global tag_set on init error path Zizhi Wo
2026-07-07 4:24 ` Damien Le Moal
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=f448bfcf-207d-4550-b268-efa5a51a6603@kernel.org \
--to=dlemoal@kernel.org \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=chengzhihao1@huawei.com \
--cc=johannes.thumshirn@wdc.com \
--cc=kbusch@kernel.org \
--cc=kch@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nilay@linux.ibm.com \
--cc=wozizhi@huawei.com \
--cc=wozizhi@huaweicloud.com \
--cc=yangerkun@huawei.com \
/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