Skip to contentSkip to conversation

USB: serial: io_edgeport: cap received transmit credits

PATCH Applied Sunho Park 3 participants 4 messages Jul 14 – Jul 22

Subsystems (2)
lore
Share & tools
lore

Sunho Park

author
#0 lore raw

PATCH v3 1/1 USB: serial: io_edgeport: cap received transmit credits

The interrupt-status packet reports transmit credits returned by the device. edge_interrupt_callback() adds the 16-bit value to txCredits without checking maxTxCredits.

edge_write() uses txCredits minus the software FIFO count as the amount of data that fits. Since the FIFO is allocated with maxTxCredits bytes, txCredits exceeding maxTxCredits can cause OOB write in ring buffer.

Cap accumulated credits at maxTxCredits. Conforming devices should never hit the cap.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by Codex:GPT-5

---
V2 -> V3: Added missing revision history (no code changes) V1 -> V2: Replaced min_t() with min()

v2: https://lore.kernel.org/linux-usb/[email protected]/
v1: https://lore.kernel.org/linux-usb/[email protected]/

---
 drivers/usb/serial/io_edgeport.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/serial/io_edgeport.c +3 -1
index 34ccf7820537..2ab3f8262259 100644
@@ -646,7 +646,9 @@ static void edge_interrupt_callback(struct urb *urb)
 				if (edge_port && edge_port->open) {
 					spin_lock_irqsave(&edge_port->ep_lock,
 							  flags);
-					edge_port->txCredits += txCredits;
+					edge_port->txCredits =
+						min(edge_port->txCredits + txCredits,
+						    edge_port->maxTxCredits);
 					spin_unlock_irqrestore(&edge_port->ep_lock,
 							       flags);
 					dev_dbg(dev, "%s - txcredits for port%d = %d\n",

base-commit: fad0fd120e29041b3e6cdf41bb12e3184fb524a2

Signature · 1 line
2.43.0
#1 lore raw
Quoted 11 lines · Sunho Park

The interrupt-status packet reports transmit credits returned by the device. edge_interrupt_callback() adds the 16-bit value to txCredits without checking maxTxCredits.

edge_write() uses txCredits minus the software FIFO count as the amount of data that fits. Since the FIFO is allocated with maxTxCredits bytes, txCredits exceeding maxTxCredits can cause OOB write in ring buffer.

Cap accumulated credits at maxTxCredits. Conforming devices should never hit the cap.

Quoted 7 lines
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by Codex:GPT-5

---
V2 -> V3: Added missing revision history (no code changes) V1 -> V2: Replaced min_t() with min()

Please slow down and don't send patches right after each other. There might have been other review comments...

author
#2 lore raw
Quoted 2 lines · Greg Kroah-Hartman

Please slow down and don't send patches right after each other. There might have been other review comments...

I apologize for sending patches too quickly. I'm fairly new to the process, and I'll allow enough time for review in future contributions.

Thanks,
Sunho

maintainer Applied
#3 lore raw
In reply to Sunho Park
Quoted 15 lines · Sunho Park

The interrupt-status packet reports transmit credits returned by the device. edge_interrupt_callback() adds the 16-bit value to txCredits without checking maxTxCredits.

edge_write() uses txCredits minus the software FIFO count as the amount of data that fits. Since the FIFO is allocated with maxTxCredits bytes, txCredits exceeding maxTxCredits can cause OOB write in ring buffer.

Cap accumulated credits at maxTxCredits. Conforming devices should never hit the cap.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by Codex:GPT-5
Quoted 6 lines

---
V2 -> V3: Added missing revision history (no code changes) V1 -> V2: Replaced min_t() with min()

v2: https://lore.kernel.org/linux-usb/[email protected]/
v1: https://lore.kernel.org/linux-usb/[email protected]/

Applied, thanks.

Johan