public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Console/stdio use after free
@ 2021-01-28 13:12 Nicolas Saenz Julienne
  2021-01-28 13:12 ` [PATCH v2 1/2] stdio: Introduce stdio_valid() Nicolas Saenz Julienne
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Nicolas Saenz Julienne @ 2021-01-28 13:12 UTC (permalink / raw)
  To: u-boot

With today's master, 70c2525c0d3c ('IOMUX: Stop dropped consoles')
introduces a use after free in usb_kbd_remove():

- usbkbd's stdio device is de-registered with stdio_deregister_dev(),
  the struct stdio_dev is freed.

- iomux_doenv() is called, usbkbd removed from the console list, and
  console_stop() is called on the struct stdio_dev pointer that no
  longer exists.

This series mitigates this by making sure the pointer is really a stdio
device prior performing the stop operation. It's not ideal, but I
couldn't figure out a nicer way to fix this.

Regards,
Nicolas

---

Changes since v1:
 - Comment new function
 - Add comment stating this needs a proper fix

Nicolas Saenz Julienne (2):
  stdio: Introduce stdio_valid()
  console: Don't start/stop console if stdio device invalid

 common/console.c    |  9 +++++++++
 common/stdio.c      | 11 +++++++++++
 include/stdio_dev.h | 11 +++++++++++
 3 files changed, 31 insertions(+)

-- 
2.30.0

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-02-05 20:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-28 13:12 [PATCH v2 0/2] Console/stdio use after free Nicolas Saenz Julienne
2021-01-28 13:12 ` [PATCH v2 1/2] stdio: Introduce stdio_valid() Nicolas Saenz Julienne
2021-02-01 20:43   ` Simon Glass
2021-01-28 13:12 ` [PATCH v2 2/2] console: Don't start/stop console if stdio device invalid Nicolas Saenz Julienne
2021-01-28 15:52   ` Andy Shevchenko
2021-01-29  8:50     ` Matthias Brugger
2021-02-01 19:29       ` Tom Rini
2021-02-03  9:50         ` Andy Shevchenko
2021-02-05 17:06           ` Andy Shevchenko
2021-02-05 17:50             ` Tom Rini
2021-02-05 18:07               ` Tom Rini
2021-02-05 19:31                 ` Andy Shevchenko
2021-02-05 20:47                   ` Tom Rini
2021-02-01 20:18   ` Simon Glass
2021-01-28 16:55 ` [PATCH v2 0/2] Console/stdio use after free Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox