]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
pktcdvd: Fix possible Spectre-v1 for pkt_devs
authorJinbum Park <jinb.park7@gmail.com>
Sat, 28 Jul 2018 04:20:44 +0000 (13:20 +0900)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 24 Apr 2019 08:09:07 +0000 (10:09 +0200)
User controls @dev_minor which to be used as index of pkt_devs.
So, It can be exploited via Spectre-like attack. (speculative execution)

This kind of attack leaks address of pkt_devs, [1]
It leads an attacker to bypass security mechanism such as KASLR.

So sanitize @dev_minor before using it to prevent attack.

[1] https://github.com/jinb-park/linux-exploit/
tree/master/exploit-remaining-spectre-gadget/leak_pkt_devs.c

Signed-off-by: Jinbum Park <jinb.park7@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
CVE-2017-5753

(cherry picked from commit 55690c07b44a82cc3359ce0c233f4ba7d80ba145)
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/block/pktcdvd.c

index 531a0915066b313462d6208359ecea4102397215..11ec92e47455a3fafc4a853da977adb31ae2bde6 100644 (file)
@@ -67,7 +67,7 @@
 #include <scsi/scsi.h>
 #include <linux/debugfs.h>
 #include <linux/device.h>
-
+#include <linux/nospec.h>
 #include <linux/uaccess.h>
 
 #define DRIVER_NAME    "pktcdvd"
@@ -2231,6 +2231,8 @@ static struct pktcdvd_device *pkt_find_dev_from_minor(unsigned int dev_minor)
 {
        if (dev_minor >= MAX_WRITERS)
                return NULL;
+
+       dev_minor = array_index_nospec(dev_minor, MAX_WRITERS);
        return pkt_devs[dev_minor];
 }