Project

General

Profile

Actions

Bug #4251

closed

simtrace2 firmware can get OOM / talloc unable to allocate buffer for APDU

Added by laforge over 4 years ago. Updated over 4 years ago.

Status:
Resolved
Priority:
Urgent
Assignee:
Category:
-
Target version:
-
Start date:
11/07/2019
Due date:
% Done:

100%

Spec Reference:

Description

In a scenario where the modem/phone is already sending APDUs to the simtrace2 firmware before any libusb-client software on the USB host is running, the firmware is allocating buffers for those APDUs and putting them in the usb endpoint buffer queue of the IN endpoint.

At some point, the firmware is out of memory as all memory is allocated in buffers on the queue.

As there's no explicit notification if somebody is currently submitting IN URBs on the endpoint on the host (i.e. an application handling the device) or not, we have to resort to indirect means of determining this situation.

My idea is to store the systick timer at the time of enqueue inside the buffer descriptor, and then have some periodic timer that verifies every e.g. 10ms if any entries in the queue have been sitting there for more than 10ms. If so, release them.

This checking for expired / too old buffers could also happen at other points in time, such as
  • when we enqueue a new entry into the queue (and hold the lock anyway)
  • when we want to allocate a buffer but are OOM
  • ...

I wonder how other USB device firmware projects are handling this general problem.


Related issues

Related to SIMtrace 2 - Bug #4329: IN endpoint gets stuck during USB suspendResolvedlaforge12/15/2019

Actions
Actions

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 48.8 MB)