exp(checkm8): carry the serial index across re-acquisition and log the address

The descriptor index of the serial string is not stable across enumerations, which is why both retry paths in checkm8_exploit write it back; the PWND check reads it through dev->iserial_index. Logging the device address before and after the re-open makes the re-enumeration visible in the run instead of inferred from dmesg, and the window grows to ten seconds to match the waits used elsewhere for re-enumeration.
This commit is contained in:
debian 2026-11-29 16:52:46 -03:00
parent 0d97c3767e
commit c0dac9c172

View file

@ -74,20 +74,41 @@ static int exploit_reacquire(exploit_ctx_t *ctx)
{ {
device_info_t *dev = ctx->dev; device_info_t *dev = ctx->dev;
uint8_t iserial = 0; uint8_t iserial = 0;
unsigned old_addr = 0;
int i; int i;
if (dev->usb) { if (dev->usb) {
libusb_device *old = libusb_get_device(dev->usb);
if (old)
old_addr = (unsigned)libusb_get_device_address(old);
usb_dfu_close(dev->usb); usb_dfu_close(dev->usb);
dev->usb = NULL; dev->usb = NULL;
} }
for (i = 0; i < 60; i++) { /* up to ~3 s at 50 ms */ for (i = 0; i < 100; i++) { /* up to ~10 s at 100 ms */
if (usb_dfu_find(&dev->usb, &iserial) == 0) { if (usb_dfu_find(&dev->usb, &iserial) == 0) {
log_info("exploit_deliver: device re-acquired (iserial %u)", libusb_device *now = libusb_get_device(dev->usb);
(unsigned)iserial); unsigned new_addr = 0;
if (now)
new_addr = (unsigned)libusb_get_device_address(now);
/*
* The descriptor index of the serial string is not stable
* across enumerations; the retry paths in checkm8_exploit
* carry it forward for that reason, and the PWND check
* reads it back through dev->iserial_index.
*/
dev->iserial_index = iserial;
log_info("exploit_deliver: device re-acquired "
"(iserial %u, address %u -> %u)",
(unsigned)iserial, old_addr, new_addr);
return 0; return 0;
} }
usleep(50000); usleep(100000);
} }
log_error("exploit_deliver: device did not come back after re-acquiring"); log_error("exploit_deliver: device did not come back after re-acquiring");