]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
stm class: Fix a use-after-free
authorAlexander Shishkin <alexander.shishkin@linux.intel.com>
Tue, 19 Sep 2017 15:47:40 +0000 (18:47 +0300)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 19 Oct 2017 14:49:04 +0000 (09:49 -0500)
BugLink: http://bugs.launchpad.net/bugs/1723145
commit fd085bb1766d6a598f53af2308374a546a49775a upstream.

For reasons unknown, the stm_source removal path uses device_destroy()
to kill the underlying device object. Because device_destroy() uses
devt to look for the device to destroy and the fact that stm_source
devices don't have one (or all have the same one), it just picks the
first device in the class, which may well be the wrong one.

That is, loading stm_console and stm_heartbeat and then removing both
will die in dereferencing a freed object.

Since this should have been device_unregister() in the first place,
use it instead of device_destroy().

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: 7bd1d4093c2 ("stm class: Introduce an abstraction for System Trace Module devices")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
drivers/hwtracing/stm/core.c

index 0e731143f6a489a6c1d3decb227e462265c4329e..08b8305fee44f0356aba535524f62f19f4209379 100644 (file)
@@ -1119,7 +1119,7 @@ void stm_source_unregister_device(struct stm_source_data *data)
 
        stm_source_link_drop(src);
 
-       device_destroy(&stm_source_class, src->dev.devt);
+       device_unregister(&src->dev);
 }
 EXPORT_SYMBOL_GPL(stm_source_unregister_device);