From: sashiko-bot@kernel.org
To: "Lin Tzu Yang" <rongh7426@gmail.com>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet: fix one-byte overflow in configfs string show callbacks
Date: Mon, 30 Nov 2026 11:59:49 +0000 [thread overview]
Message-ID: <sashiko-outbox-241002@kernel.org> (raw)
In-Reply-To: <20261130114711.842577-1-rongh7426@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] nvmet: snprintf() in nvmet_passthru_device_path_show()
mismatches changelog
--
commit 439334c02309f8c7dc424a02bda5bf34576398b8
Author: Lin Tzu Yang <rongh7426@gmail.com>
nvmet: fix one-byte overflow in configfs string show callbacks
This commit replaces sprintf() with scnprintf(..., PAGE_SIZE, ...) in
nvmet_ns_device_path_show(), nvmet_host_dhchap_key_show(), and
nvmet_host_dhchap_ctrl_key_show() to prevent a one-byte buffer overflow on
4095-byte attribute values.
> Use scnprintf() with PAGE_SIZE, as the passthru device_path show
> already does. A value that does not fit loses its trailing newline
> instead of overflowing the buffer.
[Severity: Low]
Does nvmet_passthru_device_path_show() need to be converted to scnprintf()
as well, or should the commit message be adjusted?
drivers/nvme/target/configfs.c:nvmet_passthru_device_path_show() {
...
ret = snprintf(page, PAGE_SIZE, "%s\n",
subsys->passthru && subsys->passthru->ctrl_path ?
subsys->passthru->ctrl_path : "");
...
}
nvmet_passthru_device_path_show() currently uses snprintf() rather than
scnprintf(). When ctrl_path is 4095 bytes long, snprintf() drops the
newline, writes a NUL terminator at page[4095], and returns 4096, which
fill_read_buffer() accepts (count <= SIMPLE_ATTR_SIZE) so configfs copies
the trailing NUL byte to userspace instead of returning 4095 bytes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130114711.842577-1-rongh7426@gmail.com?part=1
prev parent reply other threads:[~2026-11-30 12:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 11:47 [PATCH] nvmet: fix one-byte overflow in configfs string show callbacks Lin Tzu Yang
2026-11-30 11:59 ` sashiko-bot [this message]
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-241002@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=rongh7426@gmail.com \
--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