[PATCH 4/9] scsi: ipr: Skip dump entries whose length is not a 4 byte multiple

From: Praneeth Balasubramanian

Date: Sat Dec 05 2026 - 01:34:15 EST


ipr_get_ioa_dump() takes each dump entry length from the adapter dump
table and passes it to ipr_sdt_copy() without checking that it is a
multiple of 4. ipr_sdt_copy() copies whole 32 bit words but advances
page_offset, bytes_copied and the dump header length by the full byte
count. When firmware supplies an unaligned length the trailing 1 to 3
bytes of the copy stay uninitialized and the next entry is written at a
shifted offset. A later read of the dump sysfs attribute then copies
those uninitialized kmalloc bytes to userspace. The dump is only
readable by root and the values come from firmware, so the impact is
limited.

Skip such entries by clearing their valid flag, matching the existing
handling of entries whose length exceeds the maximum dump size.

This was found by an LLM-based audit that checks code against the rules
stated in kernel comments.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Praneeth Balasubramanian <praneethb2002@xxxxxxxxx>
---

Notes:
This was found by an LLM-based audit, part of research at UCSB SecLab.
An LLM turned a kernel comment into a rule, and three LLM votes checked
the code against it. The fix and changelog were drafted with GLM-5.3 and
checked against the source with Claude Opus 5.5. I reviewed the patch
and take responsibility for it.

Testing: builds without new warnings with W=1 (x86_64 allmodconfig),
clang 23. checkpatch.pl is clean. Not runtime-tested, and there is no
reproducer. I do not have this hardware.

drivers/scsi/ipr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 1a5e362cccbd..71a70ce59bb2 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -3173,7 +3173,8 @@ static void ipr_get_ioa_dump(struct ipr_ioa_cfg *ioa_cfg, struct ipr_dump *dump)
valid = 0;
}
if (valid) {
- if (bytes_to_copy > max_dump_size) {
+ if (bytes_to_copy > max_dump_size ||
+ bytes_to_copy & (sizeof(u32) - 1)) {
sdt->entry[i].flags &= ~IPR_SDT_VALID_ENTRY;
continue;
}
--
2.25.1