ALSA: seq: Fix race of get-subscription call vs port-delete ioctls
authorTakashi Iwai <tiwai@suse.de>
Tue, 9 Apr 2019 16:04:17 +0000 (18:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Jun 2019 06:18:01 +0000 (08:18 +0200)
commit731ebeeda51fea2327e26ddf02025bd959d96b3e
tree86b302a2ca5f95d0cfc5643662449919e4560549
parentb52fd8af8db3a099af4f93126a4c9c5459fb64b4
ALSA: seq: Fix race of get-subscription call vs port-delete ioctls

[ Upstream commit 2eabc5ec8ab4d4748a82050dfcb994119b983750 ]

The snd_seq_ioctl_get_subscription() retrieves the port subscriber
information as a pointer, while the object isn't protected, hence it
may be deleted before the actual reference.  This race was spotted by
syzkaller and may lead to a UAF.

The fix is simply copying the data in the lookup function that
performs in the rwsem to protect against the deletion.

Reported-by: syzbot+9437020c82413d00222d@syzkaller.appspotmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_ports.c
sound/core/seq/seq_ports.h