]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
media: dvb_ca_en50221: prevent using slot_info for Spectre attacs
authorMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 15 May 2018 12:31:38 +0000 (08:31 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 24 Apr 2019 08:06:41 +0000 (10:06 +0200)
slot can be controlled by user-space, hence leading to
a potential exploitation of the Spectre variant 1 vulnerability,
as warned by smatch:
drivers/media/dvb-core/dvb_ca_en50221.c:1479 dvb_ca_en50221_io_write() warn: potential spectre issue 'ca->slot_info' (local cap)

Acked-by: "Jasmin J." <jasmin@anw.at>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
CVE-2017-5753

(backported from commit 4f5ab5d7a5e765ad231a132f82cec71de88b9aad)
[juergh:
 - Adjusted context.
 - Folded in a24e6348e5a0 ("media: dvb_ca_en50221: sanity check slot number from userspace").]
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/media/dvb-core/dvb_ca_en50221.c

index d48b61eb01f4cdc7f11913208a6beef0136a7bff..aadda661ad9c3e14aa8c0275f8f8219f4bd46ee8 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/slab.h>
 #include <linux/list.h>
 #include <linux/module.h>
+#include <linux/nospec.h>
 #include <linux/vmalloc.h>
 #include <linux/delay.h>
 #include <linux/spinlock.h>
@@ -1473,6 +1474,10 @@ static ssize_t dvb_ca_en50221_io_write(struct file *file,
                return -EFAULT;
        buf += 2;
        count -= 2;
+
+       if (slot >= ca->slot_count)
+               return -EINVAL;
+       slot = array_index_nospec(slot, ca->slot_count);
        sl = &ca->slot_info[slot];
 
        /* check if the slot is actually running */