From: Junyoung Jang <graypanda.inzag@gmail.com>
To: Bradley Grove <linuxdrivers@attotech.com>
Cc: Junyoung Jang <graypanda.inzag@gmail.com>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <mkp@kernel.org>,
Gwanhyun Lee <gwanhyunlee@gmail.com>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] scsi: esas2r: bound owner-only binary sysfs reads
Date: Thu, 3 Dec 2026 22:55:24 +0900 [thread overview]
Message-ID: <20261203135526.1026638-3-graypanda.inzag@gmail.com> (raw)
In-Reply-To: <20261203135526.1026638-1-graypanda.inzag@gmail.com>
The live_nvram and hw binary sysfs attributes have mode 0600. Their
read callbacks ignore count and copy a fixed amount into the kernfs
buffer. A short read allocates a smaller buffer, so either copy can
write past it when the callback succeeds.
Bound both copies by count. Because both attributes declare size 0 and
have always ignored off, keep ignoring off so write-then-read exchanges
on the same fd, such as hw commands, continue to work without a seek,
and leave read_hw()'s per-read HBA command execution unchanged.
An in-house LLM-based agent assisted with discovery and patch
preparation.
Fixes: 26780d9e12ed ("[SCSI] esas2r: ATTO Technology ExpressSAS 6G SAS/SATA RAID Adapter Driver")
Cc: stable@vger.kernel.org
Co-developed-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
Signed-off-by: Gwanhyun Lee <gwanhyunlee@gmail.com>
Signed-off-by: Junyoung Jang <graypanda.inzag@gmail.com>
---
drivers/scsi/esas2r/esas2r_main.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
index ad5de07d1e14..d462b2fde10e 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -133,7 +133,7 @@ static ssize_t read_live_nvram(struct file *file, struct kobject *kobj,
char *buf, loff_t off, size_t count)
{
struct esas2r_adapter *a = esas2r_adapter_from_kobj(kobj);
- int length = min_t(size_t, sizeof(struct esas2r_sas_nvram), PAGE_SIZE);
+ size_t length = min(sizeof(*a->nvram), count);
memcpy(buf, a->nvram, length);
return length;
@@ -176,7 +176,7 @@ static ssize_t read_hw(struct file *file, struct kobject *kobj,
char *buf, loff_t off, size_t count)
{
struct esas2r_adapter *a = esas2r_adapter_from_kobj(kobj);
- int length = min_t(size_t, sizeof(struct atto_ioctl), PAGE_SIZE);
+ size_t length = min_t(size_t, sizeof(struct atto_ioctl), PAGE_SIZE);
if (!a->local_atto_ioctl)
return -ENOMEM;
@@ -184,8 +184,8 @@ static ssize_t read_hw(struct file *file, struct kobject *kobj,
if (handle_hba_ioctl(a, a->local_atto_ioctl) != IOCTL_SUCCESS)
return -ENOMEM;
+ length = min(length, count);
memcpy(buf, a->local_atto_ioctl, length);
-
return length;
}
--
2.43.0
prev parent reply other threads:[~2026-12-03 13:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 13:55 [PATCH 0/2] scsi: esas2r: bound " Junyoung Jang
2026-12-03 13:55 ` [PATCH 1/2] scsi: esas2r: bound default_nvram reads to the requested count Junyoung Jang
2026-12-03 13:55 ` Junyoung Jang [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=20261203135526.1026638-3-graypanda.inzag@gmail.com \
--to=graypanda.inzag@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=gwanhyunlee@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxdrivers@attotech.com \
--cc=mkp@kernel.org \
/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
all inboxes | Powered by JetHome®