From af669c4b17feaa7e1ca62691edd694e49bc58d7b Mon Sep 17 00:00:00 2001 From: Alexandre Figueiredo <17xande@gmail.com> Date: Fri, 4 Dec 2026 16:28:54 +0200 Subject: [PATCH] usb: a broken transfer can be a lost reply on a pwned boot ROM On Linux, a device that leaves USB in the middle of a control request can show as a broken transfer (nusb's TransferError::Fault, EPROTO) rather than as a disconnect. usbliter8's boot request on an iPhone XS Max ended that way while the iBSS started, and the ibss route stopped with "DFU start on a pwned boot ROM: hardware fault or protocol violation" although the patched iBoot came up in recovery mode a few seconds later. Give that failure its own kind, Fault, and let reply_may_be_lost take it as an unconfirmed reply, as it takes a timeout, stall or disconnect. The download before it still fails on any error. Assisted-by: LLM --- CHANGELOG.md | 4 ++++ crates/usb/src/dfu.rs | 12 ++++++++++-- crates/usb/src/error.rs | 7 +++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 060985a9..cb347e5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ is on main, the release is published with that section as its notes (AGENTS.md, ### Command line +- On Linux, an A12 device entered by a usbliter8 board starts by the ibss + route: the boot request can end in a USB protocol error while the iBSS + takes over, and the run no longer stops there. + - The A13 iPhones (iPhone 11, 11 Pro, 11 Pro Max, SE 2nd generation) get their boot firmware built as the A12's: their patched iBSS takes the same borrowed manifest, so no manifest of your own is needed. diff --git a/crates/usb/src/dfu.rs b/crates/usb/src/dfu.rs index 3b39e1db..8c80e060 100644 --- a/crates/usb/src/dfu.rs +++ b/crates/usb/src/dfu.rs @@ -57,10 +57,18 @@ const SUFFIX: [u8; 12] = [ /// The reply to a request that starts code, or that an exploit payload /// answers, can be lost: the device leaves or the payload does not answer. +/// On Linux a device that leaves in the middle of the request can show as a +/// broken transfer (EPROTO) rather than a disconnect, as usbliter8's boot +/// request does on an iPhone XS Max while the iBSS starts. fn reply_may_be_lost(reply: Result) -> Result { match reply { Ok(_) => Ok(Sent::Acknowledged), - Err(e) if matches!(e.kind, Kind::Timeout | Kind::Stall | Kind::Disconnected) => { + Err(e) + if matches!( + e.kind, + Kind::Timeout | Kind::Stall | Kind::Disconnected | Kind::Fault + ) => + { Ok(Sent::Unconfirmed) } Err(e) => Err(e), @@ -546,7 +554,7 @@ mod tests { #[test] fn only_transfer_failures_can_be_unconfirmed() { - for kind in [Kind::Timeout, Kind::Stall, Kind::Disconnected] { + for kind in [Kind::Timeout, Kind::Stall, Kind::Disconnected, Kind::Fault] { assert_eq!( reply_may_be_lost::<()>(Err(Fault::new(kind, "test"))).unwrap(), Sent::Unconfirmed diff --git a/crates/usb/src/error.rs b/crates/usb/src/error.rs index 55512267..ae4a9282 100644 --- a/crates/usb/src/error.rs +++ b/crates/usb/src/error.rs @@ -9,6 +9,9 @@ pub enum Kind { Stall, /// The device is gone. Disconnected, + /// The transfer broke off on the bus (Linux: EPROTO), as when the + /// device leaves in the middle of a request. + Fault, /// The device answered, but not with what the protocol expects. Unexpected, /// The device is not in the mode this protocol talks to. @@ -103,6 +106,10 @@ impl From for Fault { T::Cancelled => Fault::new(Kind::Timeout, "timed out"), T::Stall => Fault::new(Kind::Stall, "the device rejected the request"), T::Disconnected => Fault::new(Kind::Disconnected, "the device disconnected"), + T::Fault => Fault::new( + Kind::Fault, + "the transfer broke off (hardware fault or protocol violation)", + ), other => Fault::new(Kind::Other, other.to_string()), } }