]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ata: libata-core: Reject an invalid concurrent positioning ranges count
authorBryam Vargas <hexlabsecurity@proton.me>
Tue, 23 Jun 2026 03:23:45 +0000 (22:23 -0500)
committerDamien Le Moal <dlemoal@kernel.org>
Fri, 3 Jul 2026 04:44:18 +0000 (13:44 +0900)
commit533a0b940f901c15e5cbbd4b5d66e871c209e8ce
treeed19ca4c626d9496522c7ac3a6aac68e0fa08a31
parent462775c620197adaabc983ce847e5b9878ff4cb0
ata: libata-core: Reject an invalid concurrent positioning ranges count

ata_dev_config_cpr() takes the number of range descriptors from buf[0]
of the concurrent positioning ranges log (up to 255), which the device
reports independently of the log size in the GPL directory. The count is
then walked at a fixed 32-byte stride in two places with no bound: the
log read here, and the INQUIRY VPD page B9h emitter, which writes one
descriptor per range into the fixed 2048-byte ata_scsi_rbuf. A device
reporting a count larger than its own log overflows the read buffer (up
to 7704 bytes past a 512-byte slab), and a count above 62 overflows the
response buffer on the emit side.

Bound the count once, on probe, against both the log the device returned
and the number of descriptors the VPD B9h response buffer can hold
(ATA_DEV_MAX_CPR, derived from the rbuf size). Reject an out-of-range
count with a warning; this keeps the emitter in bounds with no separate
change there.

Suggested-by: Damien Le Moal <dlemoal@kernel.org>
Fixes: fe22e1c2f705 ("libata: support concurrent positioning ranges log")
Fixes: c745dfc541e7 ("libata: fix reading concurrent positioning ranges log")
Cc: stable@vger.kernel.org
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
Reviewed-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
drivers/ata/libata-core.c
drivers/ata/libata-scsi.c
drivers/ata/libata.h