Skip to content

Commit 4d0892a

Browse files
tiwaigregkh
authored andcommitted
ALSA: dummy: Check card index validity at probe
commit 02442d5 upstream. snd_dummy_probe() blindly trusts that the given devptr->id value is within the proper card index range. It's OK for the devices the driver itself creates at the module probe time, but if the device is bound manually via sysfs interface, this could be -1 as "none", and this leads to OOB access for index[] and other parameters. Add a sanity check for the card index and warn/correct it if it's a value out of the range. Reported-by: syzbot+2fb5d1f7cc4c1f132bcc@syzkaller.appspotmail.com Closes: https://lore.kernel.org/6a73bd4d.01d0871a.3a0d52.0005.GAE@google.com Cc: <stable@vger.kernel.org> Link: https://patch.msgid.link/20260806100433.1287393-1-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f8e6fde commit 4d0892a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

sound/drivers/dummy.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,12 @@ static int snd_dummy_probe(struct platform_device *devptr)
10331033
int idx, err;
10341034
int dev = devptr->id;
10351035

1036+
if (dev < 0 || dev >= SNDRV_CARDS) {
1037+
dev_warn(&devptr->dev,
1038+
"Invalid card index %d, using default 0\n", dev);
1039+
dev = 0;
1040+
}
1041+
10361042
err = snd_devm_card_new(&devptr->dev, index[dev], id[dev], THIS_MODULE,
10371043
sizeof(struct snd_dummy), &card);
10381044
if (err < 0)

0 commit comments

Comments
 (0)