]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ALSA: emux: Fix potential Spectre v1 vulnerabilities
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Wed, 12 Dec 2018 17:20:49 +0000 (11:20 -0600)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 24 Apr 2019 08:09:11 +0000 (10:09 +0200)
info.mode and info.port are indirectly controlled by user-space,
hence leading to a potential exploitation of the Spectre variant 1
vulnerability.

These issues were detected with the help of Smatch:

sound/synth/emux/emux_hwdep.c:72 snd_emux_hwdep_misc_mode() warn: potential spectre issue 'emu->portptrs[i]->ctrls' [w] (local cap)
sound/synth/emux/emux_hwdep.c:75 snd_emux_hwdep_misc_mode() warn: potential spectre issue 'emu->portptrs' [w] (local cap)
sound/synth/emux/emux_hwdep.c:75 snd_emux_hwdep_misc_mode() warn: potential spectre issue 'emu->portptrs[info.port]->ctrls' [w] (local cap)

Fix this by sanitizing both info.mode and info.port before using them
to index emu->portptrs[i]->ctrls, emu->portptrs[info.port]->ctrls and
emu->portptrs.

Notice that given that speculation windows are large, the policy is
to kill the speculation on the first load and not worry if it can be
completed with a dependent load/store [1].

[1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Cc: stable@vger.kernel.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>
CVE-2017-5753

(cherry picked from commit 4aea96f4237cea0c51a8bc87c0db31f0f932f1f0)
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>
sound/synth/emux/emux_hwdep.c

index e557946718a9ed7006c17901060b927b43e0f31c..d9fcae071b477dc1afc110d1f8fb42055d736344 100644 (file)
@@ -22,9 +22,9 @@
 #include <sound/core.h>
 #include <sound/hwdep.h>
 #include <linux/uaccess.h>
+#include <linux/nospec.h>
 #include "emux_voice.h"
 
-
 #define TMP_CLIENT_ID  0x1001
 
 /*
@@ -66,13 +66,16 @@ snd_emux_hwdep_misc_mode(struct snd_emux *emu, void __user *arg)
                return -EFAULT;
        if (info.mode < 0 || info.mode >= EMUX_MD_END)
                return -EINVAL;
+       info.mode = array_index_nospec(info.mode, EMUX_MD_END);
 
        if (info.port < 0) {
                for (i = 0; i < emu->num_ports; i++)
                        emu->portptrs[i]->ctrls[info.mode] = info.value;
        } else {
-               if (info.port < emu->num_ports)
+               if (info.port < emu->num_ports) {
+                       info.port = array_index_nospec(info.port, emu->num_ports);
                        emu->portptrs[info.port]->ctrls[info.mode] = info.value;
+               }
        }
        return 0;
 }