Re: [PATCH v2 1/2] ublk: validate auto buf reg before taking uring_cmd

Ming Lei <[email protected]> Fri, 31 Jul 2026 11:10:53 -0500
Newsgroups org.kernel.vger.linux-block
Message-ID <amzJDfYFOL44eMe3@fedora-laptop>
On Thu, Jul 30, 2026 at 09:09:09AM +0800, Yang Xiuwei wrote:
> With UBLK_F_AUTO_BUF_REG, invalid sqe->addr can fail after
> ublk_fill_io_cmd() has set UBLK_IO_FLAG_ACTIVE. The uring_cmd is
> completed while the tag stays active, which can hang teardown.
> 
> Split validation from buffer apply so the check has no side effects,
> then take the uring_cmd and store the already-validated buffer. Apply
> the same order in FETCH so io->buf is not written before __ublk_fetch()
> state checks.
> 
> Fixes: 52460dda3a77 ("ublk: move auto buffer register handling into one dedicated helper")
> Suggested-by: Caleb Sander Mateos <[email protected]>
> Signed-off-by: Yang Xiuwei <[email protected]>

Nice catch!

Reviewed-by: Ming Lei <[email protected]>


Thanks,
Ming