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 1/2] scsi: esas2r: bound default_nvram reads to the requested count
Date: Thu, 3 Dec 2026 22:55:23 +0900 [thread overview]
Message-ID: <20261203135526.1026638-2-graypanda.inzag@gmail.com> (raw)
In-Reply-To: <20261203135526.1026638-1-graypanda.inzag@gmail.com>
The default_nvram sysfs binary attribute is readable by all users.
For a one-byte read, kernfs requests a one-byte heap allocation and
passes count=1 to read_default_nvram(). The callback ignores count
and off. esas2r_nvram_get_defaults() writes the entire 256-byte NVRAM
structure into that buffer, corrupting memory beyond the allocation.
Reproduced in QEMU without physical ATTO hardware by registering
bin_attr_default_nvram on a dummy SCSI host. A 1-byte read as UID 1000
triggered a 256-byte KASAN slab-out-of-bounds write in
esas2r_nvram_get_defaults().
Build the defaults in a zero-initialized local structure and use
memory_read_from_buffer() to return only the requested bytes at the
requested offset.
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 | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
index ada278c24c51..ad5de07d1e14 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -41,6 +41,8 @@
* USA.
*/
+#include <linux/string.h>
+
#include "esas2r.h"
MODULE_DESCRIPTION(ESAS2R_DRVR_NAME ": " ESAS2R_LONGNAME " driver");
@@ -162,10 +164,11 @@ static ssize_t read_default_nvram(struct file *file, struct kobject *kobj,
char *buf, loff_t off, size_t count)
{
struct esas2r_adapter *a = esas2r_adapter_from_kobj(kobj);
+ struct esas2r_sas_nvram nvram = {};
- esas2r_nvram_get_defaults(a, (struct esas2r_sas_nvram *)buf);
+ esas2r_nvram_get_defaults(a, &nvram);
- return sizeof(struct esas2r_sas_nvram);
+ return memory_read_from_buffer(buf, count, &off, &nvram, sizeof(nvram));
}
static ssize_t read_hw(struct file *file, struct kobject *kobj,
--
2.43.0
next 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 binary sysfs reads Junyoung Jang
2026-12-03 13:55 ` Junyoung Jang [this message]
2026-12-03 13:55 ` [PATCH 2/2] scsi: esas2r: bound owner-only " Junyoung Jang
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-2-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®