Skip to contentSkip to conversation

usb: serial: garmin_gps: A possible concurrency use-after-free bug

BUG Jia-Ju Bai 2 participants 3 messages Dec 20, 2018

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

In drivers/usb/serial/garmin_gps.c,
the functions garmin_read_bulk_callback() and garmin_write_bulk_callback() may be concurrently executed.

In garmin_write_bulk_callback() on line 969:

    kfree(urb->transfer_buffer);
In garmin_read_bulk_callback() on line 1165:
    unsigned char *data = urb->transfer_buffer;

Thus, a concurrency use-after-free bug may occur.

This possible bug is found by a static analysis tool written by myself.

Best wishes,
Jia-Ju Bai

#1 lore raw
Quoted 9 lines · Jia-Ju Bai

In drivers/usb/serial/garmin_gps.c,
the functions garmin_read_bulk_callback() and garmin_write_bulk_callback() may be concurrently executed.

In garmin_write_bulk_callback() on line 969:

     kfree(urb->transfer_buffer);
In garmin_read_bulk_callback() on line 1165:
     unsigned char *data = urb->transfer_buffer;

Thus, a concurrency use-after-free bug may occur.

No, they operate on different struct urb.

Quoted 1 line

This possible bug is found by a static analysis tool written by myself.

Seems you need to update your tool. Please also make sure to review its output before reporting anything.

Thanks,
Johan

author
#2 lore raw
Quoted 10 lines · Johan Hovold
Quoted 9 lines · Jia-Ju Bai

In drivers/usb/serial/garmin_gps.c,
the functions garmin_read_bulk_callback() and garmin_write_bulk_callback() may be concurrently executed.

In garmin_write_bulk_callback() on line 969:

      kfree(urb->transfer_buffer);
In garmin_read_bulk_callback() on line 1165:
      unsigned char *data = urb->transfer_buffer;

Thus, a concurrency use-after-free bug may occur.

Quoted 5 lines

No, they operate on different struct urb.

Quoted 1 line

This possible bug is found by a static analysis tool written by myself.

Seems you need to update your tool. Please also make sure to review its output before reporting anything.

Okay, thanks for your reply.
Sorry for my false positive...

Best wishes,
Jia-Ju Bai