Linux Kernel Mentees list
 help / color / mirror / Atom feed
* [PATCH] sound: usb: increase snd_card alloc size
@ 2023-09-22  0:51 Ricardo B. Marliere
  2023-09-22  8:46 ` Takashi Iwai
  0 siblings, 1 reply; 6+ messages in thread
From: Ricardo B. Marliere @ 2023-09-22  0:51 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, Ruslan Bilovol
  Cc: alsa-devel, linux-kernel-mentees, linux-kernel,
	syzbot+59875ffef5cb9c9b29e9

Syzbot reports a slab-out-of-bounds read of a snd_card object. When
snd_usb_audio_create calls snd_card_new, it passes sizeof(*chip) as the
extra_size argument, which is not enough in this case.

Relevant logs below:

BUG: KASAN: slab-out-of-bounds in imon_probe+0x2983/0x3910
Read of size 1 at addr ffff8880436a2c71 by task kworker/1:2/777
(...)
The buggy address belongs to the object at ffff8880436a2000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 1 bytes to the right of
 allocated 3184-byte region [ffff8880436a2000, ffff8880436a2c70)

Reported-by: syzbot+59875ffef5cb9c9b29e9@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/000000000000a838aa0603cc74d6@google.com/
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
 sound/usb/card.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/usb/card.c b/sound/usb/card.c
index 1b2edc0fd2e9..6578326d33e8 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -619,7 +619,7 @@ static int snd_usb_audio_create(struct usb_interface *intf,
 	}
 
 	err = snd_card_new(&intf->dev, index[idx], id[idx], THIS_MODULE,
-			   sizeof(*chip), &card);
+			   sizeof(*chip) + 2, &card);
 	if (err < 0) {
 		dev_err(&dev->dev, "cannot create card instance %d\n", idx);
 		return err;
-- 
2.40.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-09-22 11:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-22  0:51 [PATCH] sound: usb: increase snd_card alloc size Ricardo B. Marliere
2023-09-22  8:46 ` Takashi Iwai
2023-09-22  9:49   ` Takashi Iwai
2023-09-22 10:37     ` Ricardo B. Marliere
2023-09-22 11:10       ` Takashi Iwai
2023-09-22  9:56   ` Ricardo B. Marliere

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox