FAILED: patch "[PATCH] ata: libata-core: Reject an invalid concurrent positioning" failed to apply to 6.1-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 533a0b940f901c15e5cbbd4b5d66e871c209e8ce
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072113-nanometer-showdown-d9de@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 533a0b940f901c15e5cbbd4b5d66e871c209e8ce Mon Sep 17 00:00:00 2001
From: Bryam Vargas <[email protected]>
Date: Mon, 22 Jun 2026 22:23:45 -0500
Subject: [PATCH] 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.
drivers/ata/libata-core.c +18 -0
@@ -2847,6 +2847,24 @@ static void ata_dev_config_cpr(struct ata_device *dev)if (!nr_cpr) goto out; +/* +* The device reports the number of CPR descriptors independently of the +* log size, and that count is also used to emit VPD page B9h into the +* fixed-size rbuf. Reject a count larger than what that buffer can hold +* (ATA_DEV_MAX_CPR) or larger than the log the device actually returned. +*/ +if (nr_cpr >ATA_DEV_MAX_CPR ) { +ata_dev_warn (dev, +"Too many concurrent positioning ranges\n" ); + goto out; + } + +if (buf_len <64 + (size_t )nr_cpr *32 ) { +ata_dev_warn (dev, +"Invalid number of concurrent positioning ranges\n" ); + goto out; + } + cpr_log =kzalloc_flex (*cpr_log, cpr, nr_cpr);if (!cpr_log) goto out;
drivers/ata/libata-scsi.c +0 -2
@@ -37,8 +37,6 @@#include "libata.h" #include "libata-transport.h" -#define ATA_SCSI_RBUF_SIZE 2048 -static DEFINE_SPINLOCK (ata_scsi_rbuf_lock);static u8 ata_scsi_rbuf[ATA_SCSI_RBUF_SIZE ];
drivers/ata/libata.h +9 -0
@@ -149,6 +149,15 @@ static inline bool ata_acpi_dev_manage_restart(struct ata_device *dev) { return#endif /* libata-scsi.c */ +#define ATA_SCSI_RBUF_SIZE 2048 + +/* +* Maximum number of concurrent positioning ranges (CPR) supported. The ACS +* specifications allow up to 255, but we limit this to the number of CPR +* descriptors that fit in the rbuf buffer used to emit VPD page B9h. +*/ +#define ATA_DEV_MAX_CPR min(255, ((ATA_SCSI_RBUF_SIZE - 64) / 32)) +extern struct ata_device *ata_scsi_find_dev (struct ata_port *ap,const struct scsi_device *scsidev); extern int ata_scsi_add_hosts(struct ata_host *host,
Sasha Levin
maintainerPATCH 1/1 ata: libata-core: Reject an invalid concurrent positioning ranges count
From: Bryam Vargas <[email protected]>
[ Upstream commit 533a0b940f901c15e5cbbd4b5d66e871c209e8ce ]
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.
--- drivers/ata/libata-core.c | 18 ++++++++++++++++++ drivers/ata/libata-scsi.c | 2 -- drivers/ata/libata.h | 9 +++++++++ 3 files changed, 27 insertions(+), 2 deletions(-)
drivers/ata/libata-core.c +18 -0
@@ -2598,6 +2598,24 @@ static void ata_dev_config_cpr(struct ata_device *dev)if (!nr_cpr) goto out; +/* +* The device reports the number of CPR descriptors independently of the +* log size, and that count is also used to emit VPD page B9h into the +* fixed-size rbuf. Reject a count larger than what that buffer can hold +* (ATA_DEV_MAX_CPR) or larger than the log the device actually returned. +*/ +if (nr_cpr >ATA_DEV_MAX_CPR ) { +ata_dev_warn (dev, +"Too many concurrent positioning ranges\n" ); + goto out; + } + +if (buf_len <64 + (size_t )nr_cpr *32 ) { +ata_dev_warn (dev, +"Invalid number of concurrent positioning ranges\n" ); + goto out; + } + cpr_log =kzalloc (struct_size (cpr_log, cpr, nr_cpr),GFP_KERNEL );if (!cpr_log) goto out;
drivers/ata/libata-scsi.c +0 -2
@@ -37,8 +37,6 @@#include "libata.h" #include "libata-transport.h" -#define ATA_SCSI_RBUF_SIZE 576 -static DEFINE_SPINLOCK (ata_scsi_rbuf_lock);static u8 ata_scsi_rbuf[ATA_SCSI_RBUF_SIZE ];
drivers/ata/libata.h +9 -0
@@ -112,6 +112,15 @@ static inline void ata_acpi_bind_dev(struct ata_device *dev) {}#endif /* libata-scsi.c */ +#define ATA_SCSI_RBUF_SIZE 576 + +/* +* Maximum number of concurrent positioning ranges (CPR) supported. The ACS +* specifications allow up to 255, but we limit this to the number of CPR +* descriptors that fit in the rbuf buffer used to emit VPD page B9h. +*/ +#define ATA_DEV_MAX_CPR min(255, ((ATA_SCSI_RBUF_SIZE - 64) / 32)) +extern struct ata_device *ata_scsi_find_dev (struct ata_port *ap,const struct scsi_device *scsidev); extern int ata_scsi_add_hosts(struct ata_host *host,
Signature · 1 line
2.53.0