From: sashiko-bot@kernel.org
To: "Tao Cui" <cui.tao@linux.dev>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH] blktrace: require CAP_SYS_ADMIN for the BLKTRACE ioctls
Date: Fri, 06 Nov 2026 14:39:03 +0000 [thread overview]
Message-ID: <sashiko-outbox-201597@kernel.org> (raw)
In-Reply-To: <20261106142852.3233950-1-cui.tao@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] blktrace: missing CAP_SYS_ADMIN check in sg_ioctl_common()
--
commit 8392196724a6f06dfb860d63cf54fba3357cc04e
Author: Tao Cui <cuitao@kylinos.cn>
blktrace: require CAP_SYS_ADMIN for the BLKTRACE ioctls
This commit adds a CAP_SYS_ADMIN capability check to blk_trace_ioctl() to
restrict block tracing ioctls to privileged users.
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index 8cd2520b4c99e..c1bf8ca350fee 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -927,6 +927,9 @@ int blk_trace_ioctl(struct block_device *bdev, unsigned cmd, char __user *arg)
> int ret, start = 0;
> char b[BDEVNAME_SIZE];
>
> + if (!capable(CAP_SYS_ADMIN))
> + return -EPERM;
> +
> switch (cmd) {
> case BLKTRACESETUP2:
> snprintf(b, sizeof(b), "%pg", bdev);
[Severity: Medium]
Does checking CAP_SYS_ADMIN only in blk_trace_ioctl() leave the sg
passthrough path in sg_ioctl_common() ungated?
drivers/scsi/sg.c:sg_ioctl_common() {
...
case BLKTRACESETUP:
return blk_trace_setup(sdp->device->request_queue, sdp->name,
MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
NULL, p);
case BLKTRACESTART:
return blk_trace_startstop(sdp->device->request_queue, 1);
case BLKTRACESTOP:
return blk_trace_startstop(sdp->device->request_queue, 0);
case BLKTRACETEARDOWN:
return blk_trace_remove(sdp->device->request_queue);
...
}
Because sg_ioctl_common() calls blk_trace_setup(), blk_trace_startstop()
and blk_trace_remove() directly rather than going through
blk_trace_ioctl(), an unprivileged process with access to an /dev/sg* node
can still allocate persistent relay buffers and control tracing state on
the underlying request_queue.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261106142852.3233950-1-cui.tao@linux.dev?part=1
next prev parent reply other threads:[~2026-11-06 14:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 14:28 [PATCH] blktrace: require CAP_SYS_ADMIN for the BLKTRACE ioctls Tao Cui
2026-11-06 14:39 ` sashiko-bot [this message]
2026-11-09 2:22 ` Tao Cui
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=sashiko-outbox-201597@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cui.tao@linux.dev \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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