Linux block layer
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: Zizhi Wo <wozizhi@huaweicloud.com>,
	axboe@kernel.dk, dlemoal@kernel.org, kch@nvidia.com,
	johannes.thumshirn@wdc.com, kbusch@kernel.org,
	bvanassche@acm.org, linux-block@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, yangerkun@huawei.com,
	chengzhihao1@huawei.com, wozizhi@huawei.com
Subject: Re: [PATCH V4 8/9] null_blk: serialize configfs attribute stores with device setup
Date: Fri, 10 Jul 2026 18:00:55 +0530	[thread overview]
Message-ID: <46c33982-0f5a-4acf-8695-858fdb4bf75b@linux.ibm.com> (raw)
In-Reply-To: <20260709100452.3520482-9-wozizhi@huaweicloud.com>

On 7/9/26 3:34 PM, Zizhi Wo wrote:
> From: Zizhi Wo <wozizhi@huawei.com>
> 
> The NULLB_DEVICE_ATTR _store takes no lock: apply_fn attributes
> (submit_queues, poll_queues) get dev->NAME written again after apply_fn
> returns, outside its lock; APPLY=NULL attributes are entirely lockless.
> configfs only serializes stores per-open-file, so concurrent stores on
> separate fds race.
> 
> For apply_fn attributes, once one store's apply_fn has reconfigured the
> hardware, a second (losing) store can still overwrite dev->NAME
> afterwards. This leaves dev->submit_queues out of sync with the live
> queue count, which is later caught by the WARN_ON_ONCE() in
> null_map_queues().
> 
> For !apply_fn attributes, power_store()'s null_add_dev() validates and
> builds the device under "lock" but only sets CONFIGURED afterwards. A store
> slipping in during this window can change a field mid-setup -- for example,
> zone_nr_conv can be pushed above nr_zones after it has already been
> clamped, leading to an out-of-bounds dev->zones[] access.
> 
> Take "lock" in the macro around the apply_fn call, the CONFIGURED test and
> the field write, and move it out of nullb_apply_submit_queues()/
> nullb_apply_poll_queues() so both paths are covered once. This serializes
> stores with power_store's setup and with each other.
> 
> Also reset ret to 0 after the input parsing so that within the locked
> section ret is purely a status code, rather than carrying the byte count
> returned by nullb_device_##TYPE##_attr_store(). The field is then written
> only on success via if (!ret), giving a single consistent rule for both the
> apply_fn and the APPLY=NULL paths.
> 
> Fixes: 45919fbfe1c4 ("null_blk: Enable modifying 'submit_queues' after an instance has been configured")
> Signed-off-by: Zizhi Wo <wozizhi@huawei.com>

Looks good to me.

Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>

  reply	other threads:[~2026-07-10 12:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 10:04 [PATCH V4 0/9] null_blk: fix init/exit races and memleaks Zizhi Wo
2026-07-09 10:04 ` [PATCH V4 1/9] null_blk: use DEFINE_MUTEX for the file-scope mutex Zizhi Wo
2026-07-10 12:35   ` Nilay Shroff
2026-07-09 10:04 ` [PATCH V4 2/9] null_blk: register configfs subsystem after creating default devices Zizhi Wo
2026-07-10 12:36   ` Nilay Shroff
2026-07-09 10:04 ` [PATCH V4 3/9] null_blk: move unregister_blkdev() after destroying dev in null_exit() Zizhi Wo
2026-07-10 12:36   ` Nilay Shroff
2026-07-09 10:04 ` [PATCH V4 4/9] null_blk: free global tag_set on init error path Zizhi Wo
2026-07-10 12:37   ` Nilay Shroff
2026-07-09 10:04 ` [PATCH V4 5/9] null_blk: free zones array on device power-off Zizhi Wo
2026-07-10 14:24   ` Nilay Shroff
2026-07-09 10:04 ` [PATCH V4 6/9] null_blk: clean up null_del_dev() to use cached dev pointer Zizhi Wo
2026-07-10 13:03   ` Nilay Shroff
2026-07-09 10:04 ` [PATCH V4 7/9] null_blk: reject per-device queue resize for shared tag set Zizhi Wo
2026-07-10 12:34   ` Nilay Shroff
2026-07-09 10:04 ` [PATCH V4 8/9] null_blk: serialize configfs attribute stores with device setup Zizhi Wo
2026-07-10 12:30   ` Nilay Shroff [this message]
2026-07-09 10:04 ` [PATCH V4 9/9] null_blk: serialize configfs attribute shows with the file-scope lock Zizhi Wo
2026-07-10 12:31   ` Nilay Shroff

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=46c33982-0f5a-4acf-8695-858fdb4bf75b@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=chengzhihao1@huawei.com \
    --cc=dlemoal@kernel.org \
    --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=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