summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavo@embeddedor.com>2018-12-12 12:20:49 -0500
committerTakashi Iwai <tiwai@suse.de>2018-12-13 03:13:04 -0500
commit4aea96f4237cea0c51a8bc87c0db31f0f932f1f0 (patch)
treec10f89ad1d9ca4155a16fe6cb11296a9f0f23f34
parentc7072f5f2aa1124d57042d1d7f17521532657dc6 (diff)
ALSA: emux: Fix potential Spectre v1 vulnerabilities
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>
-rw-r--r--sound/synth/emux/emux_hwdep.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sound/synth/emux/emux_hwdep.c b/sound/synth/emux/emux_hwdep.c
index e557946718a9..d9fcae071b47 100644
--- a/sound/synth/emux/emux_hwdep.c
+++ b/sound/synth/emux/emux_hwdep.c
@@ -22,9 +22,9 @@
22#include <sound/core.h> 22#include <sound/core.h>
23#include <sound/hwdep.h> 23#include <sound/hwdep.h>
24#include <linux/uaccess.h> 24#include <linux/uaccess.h>
25#include <linux/nospec.h>
25#include "emux_voice.h" 26#include "emux_voice.h"
26 27
27
28#define TMP_CLIENT_ID 0x1001 28#define TMP_CLIENT_ID 0x1001
29 29
30/* 30/*
@@ -66,13 +66,16 @@ snd_emux_hwdep_misc_mode(struct snd_emux *emu, void __user *arg)
66 return -EFAULT; 66 return -EFAULT;
67 if (info.mode < 0 || info.mode >= EMUX_MD_END) 67 if (info.mode < 0 || info.mode >= EMUX_MD_END)
68 return -EINVAL; 68 return -EINVAL;
69 info.mode = array_index_nospec(info.mode, EMUX_MD_END);
69 70
70 if (info.port < 0) { 71 if (info.port < 0) {
71 for (i = 0; i < emu->num_ports; i++) 72 for (i = 0; i < emu->num_ports; i++)
72 emu->portptrs[i]->ctrls[info.mode] = info.value; 73 emu->portptrs[i]->ctrls[info.mode] = info.value;
73 } else { 74 } else {
74 if (info.port < emu->num_ports) 75 if (info.port < emu->num_ports) {
76 info.port = array_index_nospec(info.port, emu->num_ports);
75 emu->portptrs[info.port]->ctrls[info.mode] = info.value; 77 emu->portptrs[info.port]->ctrls[info.mode] = info.value;
78 }
76 } 79 }
77 return 0; 80 return 0;
78} 81}