diff options
author | Takashi Iwai <tiwai@suse.de> | 2019-04-09 18:04:17 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2019-04-09 18:54:13 +0200 |
commit | 2eabc5ec8ab4d4748a82050dfcb994119b983750 (patch) | |
tree | 13103ccf8a6c0f07e9200403fcd26a30b30200c6 /sound/core/seq/seq_ports.c | |
parent | feb689025fbb6f0aa6297d3ddf97de945ea4ad32 (diff) | |
download | talos-op-linux-2eabc5ec8ab4d4748a82050dfcb994119b983750.tar.gz talos-op-linux-2eabc5ec8ab4d4748a82050dfcb994119b983750.zip |
ALSA: seq: Fix race of get-subscription call vs port-delete ioctls
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>
Diffstat (limited to 'sound/core/seq/seq_ports.c')
-rw-r--r-- | sound/core/seq/seq_ports.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sound/core/seq/seq_ports.c b/sound/core/seq/seq_ports.c index 1e2239240f21..d964d728681e 100644 --- a/sound/core/seq/seq_ports.c +++ b/sound/core/seq/seq_ports.c @@ -632,20 +632,23 @@ int snd_seq_port_disconnect(struct snd_seq_client *connector, /* get matched subscriber */ -struct snd_seq_subscribers *snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp, - struct snd_seq_addr *dest_addr) +int snd_seq_port_get_subscription(struct snd_seq_port_subs_info *src_grp, + struct snd_seq_addr *dest_addr, + struct snd_seq_port_subscribe *subs) { - struct snd_seq_subscribers *s, *found = NULL; + struct snd_seq_subscribers *s; + int err = -ENOENT; down_read(&src_grp->list_mutex); list_for_each_entry(s, &src_grp->list_head, src_list) { if (addr_match(dest_addr, &s->info.dest)) { - found = s; + *subs = s->info; + err = 0; break; } } up_read(&src_grp->list_mutex); - return found; + return err; } /* |