* [PATCH next 0/2] fixes for sound: usb:
@ 2021-03-08 22:29 ` Pavel Skripkin
0 siblings, 0 replies; 10+ messages in thread
From: Pavel Skripkin @ 2021-03-08 22:29 UTC (permalink / raw)
To: perex, tiwai, kai.heng.feng; +Cc: alsa-devel, linux-kernel, Pavel Skripkin
This small patch series fixes 2 errors from commit 9799110825db
("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()").
One of them was reported by syzbot, but second one appeared while testing fixes for the first one.
Pavel Skripkin (2):
sound: usb: fix NULL ptr dereference in usb_audio_probe
sound: usb: fix use after free in usb_audio_disconnect
sound/usb/card.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH next 0/2] fixes for sound: usb:
@ 2021-03-08 22:29 ` Pavel Skripkin
0 siblings, 0 replies; 10+ messages in thread
From: Pavel Skripkin @ 2021-03-08 22:29 UTC (permalink / raw)
To: perex, tiwai, kai.heng.feng; +Cc: Pavel Skripkin, alsa-devel, linux-kernel
This small patch series fixes 2 errors from commit 9799110825db
("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()").
One of them was reported by syzbot, but second one appeared while testing fixes for the first one.
Pavel Skripkin (2):
sound: usb: fix NULL ptr dereference in usb_audio_probe
sound: usb: fix use after free in usb_audio_disconnect
sound/usb/card.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH next 1/2] sound: usb: fix NULL ptr dereference in usb_audio_probe
2021-03-08 22:29 ` Pavel Skripkin
@ 2021-03-08 22:30 ` Pavel Skripkin
-1 siblings, 0 replies; 10+ messages in thread
From: Pavel Skripkin @ 2021-03-08 22:30 UTC (permalink / raw)
To: perex, tiwai, kai.heng.feng
Cc: alsa-devel, linux-kernel, Pavel Skripkin, syzbot+719da9b149a931f5143f
syzbot reported null pointer dereference in usb_audio_probe.
The problem was in case, when quirk == NULL. It's not an
error condition, so quirk must be checked before dereferencing.
Call Trace:
usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
really_probe+0x291/0xe60 drivers/base/dd.c:554
driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:740
__device_attach_driver+0x1d1/0x290 drivers/base/dd.c:846
bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
__device_attach+0x228/0x4a0 drivers/base/dd.c:914
bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
device_add+0xbdb/0x1db0 drivers/base/core.c:3242
usb_set_configuration+0x113f/0x1910 drivers/usb/core/message.c:2164
usb_generic_driver_probe+0xba/0x100 drivers/usb/core/generic.c:238
usb_probe_device+0xd9/0x2c0 drivers/usb/core/driver.c:293
really_probe+0x291/0xe60 drivers/base/dd.c:554
driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:740
__device_attach_driver+0x1d1/0x290 drivers/base/dd.c:846
bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
__device_attach+0x228/0x4a0 drivers/base/dd.c:914
bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
device_add+0xbdb/0x1db0 drivers/base/core.c:3242
usb_new_device.cold+0x721/0x1058 drivers/usb/core/hub.c:2555
hub_port_connect drivers/usb/core/hub.c:5223 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
port_event drivers/usb/core/hub.c:5509 [inline]
hub_event+0x2357/0x4320 drivers/usb/core/hub.c:5591
process_one_work+0x98d/0x1600 kernel/workqueue.c:2275
worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
kthread+0x3b1/0x4a0 kernel/kthread.c:292
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
Reported-by: syzbot+719da9b149a931f5143f@syzkaller.appspotmail.com
Fixes: 9799110825db ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
sound/usb/card.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 08c794883299..3fd1743513b5 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -830,7 +830,8 @@ static int usb_audio_probe(struct usb_interface *intf,
snd_media_device_create(chip, intf);
}
- chip->quirk_type = quirk->type;
+ if (quirk)
+ chip->quirk_type = quirk->type;
usb_chip[chip->index] = chip;
chip->intf[chip->num_interfaces] = intf;
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH next 1/2] sound: usb: fix NULL ptr dereference in usb_audio_probe
@ 2021-03-08 22:30 ` Pavel Skripkin
0 siblings, 0 replies; 10+ messages in thread
From: Pavel Skripkin @ 2021-03-08 22:30 UTC (permalink / raw)
To: perex, tiwai, kai.heng.feng
Cc: Pavel Skripkin, alsa-devel, syzbot+719da9b149a931f5143f, linux-kernel
syzbot reported null pointer dereference in usb_audio_probe.
The problem was in case, when quirk == NULL. It's not an
error condition, so quirk must be checked before dereferencing.
Call Trace:
usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
really_probe+0x291/0xe60 drivers/base/dd.c:554
driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:740
__device_attach_driver+0x1d1/0x290 drivers/base/dd.c:846
bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
__device_attach+0x228/0x4a0 drivers/base/dd.c:914
bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
device_add+0xbdb/0x1db0 drivers/base/core.c:3242
usb_set_configuration+0x113f/0x1910 drivers/usb/core/message.c:2164
usb_generic_driver_probe+0xba/0x100 drivers/usb/core/generic.c:238
usb_probe_device+0xd9/0x2c0 drivers/usb/core/driver.c:293
really_probe+0x291/0xe60 drivers/base/dd.c:554
driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:740
__device_attach_driver+0x1d1/0x290 drivers/base/dd.c:846
bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
__device_attach+0x228/0x4a0 drivers/base/dd.c:914
bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
device_add+0xbdb/0x1db0 drivers/base/core.c:3242
usb_new_device.cold+0x721/0x1058 drivers/usb/core/hub.c:2555
hub_port_connect drivers/usb/core/hub.c:5223 [inline]
hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
port_event drivers/usb/core/hub.c:5509 [inline]
hub_event+0x2357/0x4320 drivers/usb/core/hub.c:5591
process_one_work+0x98d/0x1600 kernel/workqueue.c:2275
worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
kthread+0x3b1/0x4a0 kernel/kthread.c:292
ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
Reported-by: syzbot+719da9b149a931f5143f@syzkaller.appspotmail.com
Fixes: 9799110825db ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()")
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
sound/usb/card.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 08c794883299..3fd1743513b5 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -830,7 +830,8 @@ static int usb_audio_probe(struct usb_interface *intf,
snd_media_device_create(chip, intf);
}
- chip->quirk_type = quirk->type;
+ if (quirk)
+ chip->quirk_type = quirk->type;
usb_chip[chip->index] = chip;
chip->intf[chip->num_interfaces] = intf;
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH next 2/2] sound: usb: fix use after free in usb_audio_disconnect
2021-03-08 22:29 ` Pavel Skripkin
@ 2021-03-08 22:30 ` Pavel Skripkin
-1 siblings, 0 replies; 10+ messages in thread
From: Pavel Skripkin @ 2021-03-08 22:30 UTC (permalink / raw)
To: perex, tiwai, kai.heng.feng; +Cc: alsa-devel, linux-kernel, Pavel Skripkin
The problem was in wrong "if" placement. chip->quirk_type is freed
in snd_card_free_when_closed(), but inside if statement it's accesed.
Fixes: 9799110825db ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()"
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
sound/usb/card.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 3fd1743513b5..b6f4c0848e66 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -907,6 +907,9 @@ static void usb_audio_disconnect(struct usb_interface *intf)
}
}
+ if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND)
+ usb_enable_autosuspend(interface_to_usbdev(intf));
+
chip->num_interfaces--;
if (chip->num_interfaces <= 0) {
usb_chip[chip->index] = NULL;
@@ -915,9 +918,6 @@ static void usb_audio_disconnect(struct usb_interface *intf)
} else {
mutex_unlock(®ister_mutex);
}
-
- if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND)
- usb_enable_autosuspend(interface_to_usbdev(intf));
}
/* lock the shutdown (disconnect) task and autoresume */
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH next 2/2] sound: usb: fix use after free in usb_audio_disconnect
@ 2021-03-08 22:30 ` Pavel Skripkin
0 siblings, 0 replies; 10+ messages in thread
From: Pavel Skripkin @ 2021-03-08 22:30 UTC (permalink / raw)
To: perex, tiwai, kai.heng.feng; +Cc: Pavel Skripkin, alsa-devel, linux-kernel
The problem was in wrong "if" placement. chip->quirk_type is freed
in snd_card_free_when_closed(), but inside if statement it's accesed.
Fixes: 9799110825db ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()"
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
sound/usb/card.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/usb/card.c b/sound/usb/card.c
index 3fd1743513b5..b6f4c0848e66 100644
--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -907,6 +907,9 @@ static void usb_audio_disconnect(struct usb_interface *intf)
}
}
+ if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND)
+ usb_enable_autosuspend(interface_to_usbdev(intf));
+
chip->num_interfaces--;
if (chip->num_interfaces <= 0) {
usb_chip[chip->index] = NULL;
@@ -915,9 +918,6 @@ static void usb_audio_disconnect(struct usb_interface *intf)
} else {
mutex_unlock(®ister_mutex);
}
-
- if (chip->quirk_type & QUIRK_SETUP_DISABLE_AUTOSUSPEND)
- usb_enable_autosuspend(interface_to_usbdev(intf));
}
/* lock the shutdown (disconnect) task and autoresume */
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH next 1/2] sound: usb: fix NULL ptr dereference in usb_audio_probe
2021-03-08 22:30 ` Pavel Skripkin
@ 2021-03-09 6:37 ` Takashi Iwai
-1 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2021-03-09 6:37 UTC (permalink / raw)
To: Pavel Skripkin
Cc: perex, tiwai, kai.heng.feng, alsa-devel, linux-kernel,
syzbot+719da9b149a931f5143f
On Mon, 08 Mar 2021 23:30:36 +0100,
Pavel Skripkin wrote:
>
> syzbot reported null pointer dereference in usb_audio_probe.
> The problem was in case, when quirk == NULL. It's not an
> error condition, so quirk must be checked before dereferencing.
>
> Call Trace:
> usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
> really_probe+0x291/0xe60 drivers/base/dd.c:554
> driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:740
> __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:846
> bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
> __device_attach+0x228/0x4a0 drivers/base/dd.c:914
> bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
> device_add+0xbdb/0x1db0 drivers/base/core.c:3242
> usb_set_configuration+0x113f/0x1910 drivers/usb/core/message.c:2164
> usb_generic_driver_probe+0xba/0x100 drivers/usb/core/generic.c:238
> usb_probe_device+0xd9/0x2c0 drivers/usb/core/driver.c:293
> really_probe+0x291/0xe60 drivers/base/dd.c:554
> driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:740
> __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:846
> bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
> __device_attach+0x228/0x4a0 drivers/base/dd.c:914
> bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
> device_add+0xbdb/0x1db0 drivers/base/core.c:3242
> usb_new_device.cold+0x721/0x1058 drivers/usb/core/hub.c:2555
> hub_port_connect drivers/usb/core/hub.c:5223 [inline]
> hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
> port_event drivers/usb/core/hub.c:5509 [inline]
> hub_event+0x2357/0x4320 drivers/usb/core/hub.c:5591
> process_one_work+0x98d/0x1600 kernel/workqueue.c:2275
> worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
> kthread+0x3b1/0x4a0 kernel/kthread.c:292
> ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
>
> Reported-by: syzbot+719da9b149a931f5143f@syzkaller.appspotmail.com
> Fixes: 9799110825db ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()")
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH next 1/2] sound: usb: fix NULL ptr dereference in usb_audio_probe
@ 2021-03-09 6:37 ` Takashi Iwai
0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2021-03-09 6:37 UTC (permalink / raw)
To: Pavel Skripkin
Cc: alsa-devel, syzbot+719da9b149a931f5143f, linux-kernel, tiwai,
kai.heng.feng
On Mon, 08 Mar 2021 23:30:36 +0100,
Pavel Skripkin wrote:
>
> syzbot reported null pointer dereference in usb_audio_probe.
> The problem was in case, when quirk == NULL. It's not an
> error condition, so quirk must be checked before dereferencing.
>
> Call Trace:
> usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396
> really_probe+0x291/0xe60 drivers/base/dd.c:554
> driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:740
> __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:846
> bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
> __device_attach+0x228/0x4a0 drivers/base/dd.c:914
> bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
> device_add+0xbdb/0x1db0 drivers/base/core.c:3242
> usb_set_configuration+0x113f/0x1910 drivers/usb/core/message.c:2164
> usb_generic_driver_probe+0xba/0x100 drivers/usb/core/generic.c:238
> usb_probe_device+0xd9/0x2c0 drivers/usb/core/driver.c:293
> really_probe+0x291/0xe60 drivers/base/dd.c:554
> driver_probe_device+0x26b/0x3d0 drivers/base/dd.c:740
> __device_attach_driver+0x1d1/0x290 drivers/base/dd.c:846
> bus_for_each_drv+0x15f/0x1e0 drivers/base/bus.c:431
> __device_attach+0x228/0x4a0 drivers/base/dd.c:914
> bus_probe_device+0x1e4/0x290 drivers/base/bus.c:491
> device_add+0xbdb/0x1db0 drivers/base/core.c:3242
> usb_new_device.cold+0x721/0x1058 drivers/usb/core/hub.c:2555
> hub_port_connect drivers/usb/core/hub.c:5223 [inline]
> hub_port_connect_change drivers/usb/core/hub.c:5363 [inline]
> port_event drivers/usb/core/hub.c:5509 [inline]
> hub_event+0x2357/0x4320 drivers/usb/core/hub.c:5591
> process_one_work+0x98d/0x1600 kernel/workqueue.c:2275
> worker_thread+0x64c/0x1120 kernel/workqueue.c:2421
> kthread+0x3b1/0x4a0 kernel/kthread.c:292
> ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:294
>
> Reported-by: syzbot+719da9b149a931f5143f@syzkaller.appspotmail.com
> Fixes: 9799110825db ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()")
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH next 2/2] sound: usb: fix use after free in usb_audio_disconnect
2021-03-08 22:30 ` Pavel Skripkin
@ 2021-03-09 6:43 ` Takashi Iwai
-1 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2021-03-09 6:43 UTC (permalink / raw)
To: Pavel Skripkin; +Cc: perex, tiwai, kai.heng.feng, alsa-devel, linux-kernel
On Mon, 08 Mar 2021 23:30:57 +0100,
Pavel Skripkin wrote:
>
> The problem was in wrong "if" placement. chip->quirk_type is freed
> in snd_card_free_when_closed(), but inside if statement it's accesed.
>
> Fixes: 9799110825db ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()"
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH next 2/2] sound: usb: fix use after free in usb_audio_disconnect
@ 2021-03-09 6:43 ` Takashi Iwai
0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2021-03-09 6:43 UTC (permalink / raw)
To: Pavel Skripkin; +Cc: linux-kernel, alsa-devel, kai.heng.feng, tiwai
On Mon, 08 Mar 2021 23:30:57 +0100,
Pavel Skripkin wrote:
>
> The problem was in wrong "if" placement. chip->quirk_type is freed
> in snd_card_free_when_closed(), but inside if statement it's accesed.
>
> Fixes: 9799110825db ("ALSA: usb-audio: Disable USB autosuspend properly in setup_disable_autosuspend()"
> Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-03-09 7:06 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08 22:29 [PATCH next 0/2] fixes for sound: usb: Pavel Skripkin
2021-03-08 22:29 ` Pavel Skripkin
2021-03-08 22:30 ` [PATCH next 1/2] sound: usb: fix NULL ptr dereference in usb_audio_probe Pavel Skripkin
2021-03-08 22:30 ` Pavel Skripkin
2021-03-09 6:37 ` Takashi Iwai
2021-03-09 6:37 ` Takashi Iwai
2021-03-08 22:30 ` [PATCH next 2/2] sound: usb: fix use after free in usb_audio_disconnect Pavel Skripkin
2021-03-08 22:30 ` Pavel Skripkin
2021-03-09 6:43 ` Takashi Iwai
2021-03-09 6:43 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.