From: Ming Lei <ming.lei@redhat.com>
To: Seamus Connor <sconnor@purestorage.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org,
Caleb Sander Mateos <csander@purestorage.com>
Subject: Re: [PATCH v2] ublk: fix ublksrv pid handling for pid namespaces
Date: Tue, 13 Jan 2026 10:01:41 +0800 [thread overview]
Message-ID: <aWWnhX7h3m9w2wc6@fedora> (raw)
In-Reply-To: <20260112225614.1817055-1-sconnor@purestorage.com>
On Mon, Jan 12, 2026 at 02:56:14PM -0800, Seamus Connor wrote:
> When ublksrv runs inside a pid namespace, START/END_RECOVERY compared
> the stored init-ns tgid against the userspace pid (getpid vnr), so the
> check failed and control ops could not proceed. Compare against the
> caller’s init-ns tgid and store that value, then translate it back to
> the caller’s pid namespace when reporting GET_DEV_INFO so ublk list
> shows a sensible pid.
>
> Testing: start/recover in a pid namespace; `ublk list` shows
> reasonable pid values in init, child, and sibling namespaces.
>
> Fixes: d37a224fc119 ("ublk: validate ublk server pid")
> Signed-off-by: Seamus Connor <sconnor@purestorage.com>
> Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
> ---
> Changes since v1:
> - Updated start_dev and end_recovery to respect the user-supplied pid
>
> drivers/block/ublk_drv.c | 30 +++++++++++++++++++++++++++++-
> 1 file changed, 29 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 79847e0b9e88..4a4673e64668 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -2922,6 +2922,10 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub,
> if (wait_for_completion_interruptible(&ub->completion) != 0)
> return -EINTR;
>
> + rcu_read_lock();
> + ublksrv_pid = pid_nr(find_vpid(ublksrv_pid));
> + rcu_read_unlock();
> +
`ublksrv_pid` is from userspace, so it may be invalid, then you may have to
check result of find_vpid().
> if (ub->ublksrv_tgid != ublksrv_pid)
> return -EINVAL;
Please add one helper of ublk_validate_ublksrv_pid() by moving all above
change into the helper, then two code paths can use the single helper.
Otherwise, this patch looks fine.
Thanks,
Ming
next prev parent reply other threads:[~2026-01-13 2:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-11 0:00 [PATCH] ublk: fix ublksrv pid handling for pid namespaces Seamus Connor
2026-01-12 5:40 ` Ming Lei
2026-01-12 18:09 ` Seamus Connor
2026-01-12 22:56 ` [PATCH v2] " Seamus Connor
2026-01-13 2:01 ` Ming Lei [this message]
2026-01-13 2:46 ` Seamus Connor
2026-01-13 3:47 ` Ming Lei
2026-01-13 23:03 ` Seamus Connor
2026-01-14 3:55 ` Ming Lei
2026-01-14 20:47 ` [PATCH v3] " Seamus Connor
2026-01-15 1:48 ` Ming Lei
2026-01-15 2:59 ` [PATCH v4] " Seamus Connor
2026-01-20 23:48 ` Seamus Connor
2026-01-21 14:45 ` Jens Axboe
2026-01-21 14:48 ` Jens Axboe
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=aWWnhX7h3m9w2wc6@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=csander@purestorage.com \
--cc=linux-block@vger.kernel.org \
--cc=sconnor@purestorage.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