ALSA: hdspm: Hardening for potential Spectre v1
authorTakashi Iwai <tiwai@suse.de>
Tue, 24 Apr 2018 06:03:14 +0000 (08:03 +0200)
committerSasha Levin <alexander.levin@microsoft.com>
Wed, 23 May 2018 01:36:38 +0000 (21:36 -0400)
commit9024c599ac2afeb7b1c3032bcb745cac92107859
treecdfc3d5fc25fd154cebe93ff06b2757d0e793cc4
parent780b273920078cfbc63143fc695fca1e37b6a176
ALSA: hdspm: Hardening for potential Spectre v1

[ Upstream commit 10513142a7114d251670361ad40cba2c61403406 ]

As recently Smatch suggested, a couple of places in HDSP MADI driver
may expand the array directly from the user-space value with
speculation:
  sound/pci/rme9652/hdspm.c:5717 snd_hdspm_channel_info() warn: potential spectre issue 'hdspm->channel_map_out' (local cap)
  sound/pci/rme9652/hdspm.c:5734 snd_hdspm_channel_info() warn: potential spectre issue 'hdspm->channel_map_in' (local cap)

This patch puts array_index_nospec() for hardening against them.

BugLink: https://marc.info/?l=linux-kernel&m=152411496503418&w=2
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
sound/pci/rme9652/hdspm.c