From dee56aeafa67dd6c3ca0301544bba443bfccebe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Sun, 16 Oct 2016 13:55:22 +0200 Subject: [PATCH] usb_drv: add missing device pointer checks The usb_drv must always check the device pointer in all session facing. methods. A errorneous client can otherwise trigger a page-fault in the driver. Fixes #2133. --- repos/dde_linux/src/lib/usb/raw/raw.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/repos/dde_linux/src/lib/usb/raw/raw.cc b/repos/dde_linux/src/lib/usb/raw/raw.cc index ca1b5bc189..91f8845812 100644 --- a/repos/dde_linux/src/lib/usb/raw/raw.cc +++ b/repos/dde_linux/src/lib/usb/raw/raw.cc @@ -643,6 +643,9 @@ class Usb::Session_component : public Session_rpc_object, void claim_interface(unsigned interface_num) override { + if (!_device) + throw Device_not_found(); + usb_interface *iface = _device->interface(interface_num); if (!iface) throw Interface_not_found(); @@ -653,6 +656,9 @@ class Usb::Session_component : public Session_rpc_object, void release_interface(unsigned interface_num) override { + if (!_device) + throw Device_not_found(); + usb_interface *iface = _device->interface(interface_num); if (!iface) throw Interface_not_found(); @@ -663,6 +669,9 @@ class Usb::Session_component : public Session_rpc_object, void config_descriptor(Device_descriptor *device_descr, Config_descriptor *config_descr) override { + if (!_device) + throw Device_not_found(); + Genode::memcpy(device_descr, &_device->udev->descriptor, sizeof(usb_device_descriptor)); if (_device->udev->actconfig) @@ -677,6 +686,9 @@ class Usb::Session_component : public Session_rpc_object, unsigned alt_settings(unsigned index) override { + if (!_device) + throw Device_not_found(); + return _device->interface(index)->num_altsetting; }