ALSA: usb-audio: Fix OOB access of mixer element list
authorTakashi Iwai <tiwai@suse.de>
Wed, 24 Jun 2020 12:23:40 +0000 (14:23 +0200)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:38:41 +0000 (15:38 -0400)
commitf05360bfb9befa74e661bed1d882b969f67c0a4f
tree1dc1a1211cca004d5717f9f09f86aa6a2f387156
parent380006c7c1e366b3d0aef666ade254e193aa1947
ALSA: usb-audio: Fix OOB access of mixer element list

[ Upstream commit 220345e98f1cdc768eeb6e3364a0fa7ab9647fe7 ]

The USB-audio mixer code holds a linked list of usb_mixer_elem_list,
and several operations are performed for each mixer element.  A few of
them (snd_usb_mixer_notify_id() and snd_usb_mixer_interrupt_v2())
assume each mixer element being a usb_mixer_elem_info object that is a
subclass of usb_mixer_elem_list, cast via container_of() and access it
members.  This may result in an out-of-bound access when a
non-standard list element has been added, as spotted by syzkaller
recently.

This patch adds a new field, is_std_info, in usb_mixer_elem_list to
indicate that the element is the usb_mixer_elem_info type or not, and
skip the access to such an element if needed.

Reported-by: syzbot+fb14314433463ad51625@syzkaller.appspotmail.com
Reported-by: syzbot+2405ca3401e943c538b5@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200624122340.9615-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/usb/mixer.c
sound/usb/mixer.h
sound/usb/mixer_quirks.c