* [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct midi_runtime
@ 2023-09-29 16:06 Gustavo A. R. Silva
2023-09-29 17:27 ` Kees Cook
2023-10-06 9:01 ` Takashi Iwai
0 siblings, 2 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-29 16:06 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai, Torsten Schenk
Cc: alsa-devel, linux-kernel, Gustavo A. R. Silva, linux-hardening
`struct urb` is a flexible structure, which means that it contains a
flexible-array member at the bottom. This could potentially lead to an
overwrite of the objects following `out_urb` in `struct midi_runtime`,
among them a function pointer.
Fix this by placing the declaration of object `out_urb` at the end of
`struct midi_runtime`.
Fixes: c6d43ba816d1 ("ALSA: usb/6fire - Driver for TerraTec DMX 6Fire USB")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
sound/usb/6fire/midi.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/usb/6fire/midi.h b/sound/usb/6fire/midi.h
index 47640c845903..df3f41913274 100644
--- a/sound/usb/6fire/midi.h
+++ b/sound/usb/6fire/midi.h
@@ -22,12 +22,12 @@ struct midi_runtime {
spinlock_t in_lock;
spinlock_t out_lock;
struct snd_rawmidi_substream *out;
- struct urb out_urb;
u8 out_serial; /* serial number of out packet */
u8 *out_buffer;
int buffer_offset;
void (*in_received)(struct midi_runtime *rt, u8 *data, int length);
+ struct urb out_urb;
};
int usb6fire_midi_init(struct sfire_chip *chip);
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct midi_runtime
2023-09-29 16:06 [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct midi_runtime Gustavo A. R. Silva
@ 2023-09-29 17:27 ` Kees Cook
2023-10-01 6:53 ` Gustavo A. R. Silva
2023-10-06 9:01 ` Takashi Iwai
1 sibling, 1 reply; 4+ messages in thread
From: Kees Cook @ 2023-09-29 17:27 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Jaroslav Kysela, Takashi Iwai, Torsten Schenk, alsa-devel,
linux-kernel, linux-hardening
On Fri, Sep 29, 2023 at 06:06:32PM +0200, Gustavo A. R. Silva wrote:
> `struct urb` is a flexible structure, which means that it contains a
> flexible-array member at the bottom. This could potentially lead to an
> overwrite of the objects following `out_urb` in `struct midi_runtime`,
> among them a function pointer.
>
> Fix this by placing the declaration of object `out_urb` at the end of
> `struct midi_runtime`.
>
> Fixes: c6d43ba816d1 ("ALSA: usb/6fire - Driver for TerraTec DMX 6Fire USB")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Another good find. :)
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct midi_runtime
2023-09-29 17:27 ` Kees Cook
@ 2023-10-01 6:53 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2023-10-01 6:53 UTC (permalink / raw)
To: Kees Cook, Gustavo A. R. Silva
Cc: Jaroslav Kysela, Takashi Iwai, Torsten Schenk, alsa-devel,
linux-kernel, linux-hardening
On 9/29/23 19:27, Kees Cook wrote:
> On Fri, Sep 29, 2023 at 06:06:32PM +0200, Gustavo A. R. Silva wrote:
>> `struct urb` is a flexible structure, which means that it contains a
>> flexible-array member at the bottom. This could potentially lead to an
>> overwrite of the objects following `out_urb` in `struct midi_runtime`,
>> among them a function pointer.
>>
>> Fix this by placing the declaration of object `out_urb` at the end of
>> `struct midi_runtime`.
>>
>> Fixes: c6d43ba816d1 ("ALSA: usb/6fire - Driver for TerraTec DMX 6Fire USB")
>> Cc: stable@vger.kernel.org
>> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>
> Another good find. :)
There are more coming. :)
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
>
Thanks!
--
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct midi_runtime
2023-09-29 16:06 [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct midi_runtime Gustavo A. R. Silva
2023-09-29 17:27 ` Kees Cook
@ 2023-10-06 9:01 ` Takashi Iwai
1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2023-10-06 9:01 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Jaroslav Kysela, Takashi Iwai, Torsten Schenk, alsa-devel,
linux-kernel, linux-hardening
On Fri, 29 Sep 2023 18:06:32 +0200,
Gustavo A. R. Silva wrote:
>
> `struct urb` is a flexible structure, which means that it contains a
> flexible-array member at the bottom. This could potentially lead to an
> overwrite of the objects following `out_urb` in `struct midi_runtime`,
> among them a function pointer.
>
> Fix this by placing the declaration of object `out_urb` at the end of
> `struct midi_runtime`.
>
> Fixes: c6d43ba816d1 ("ALSA: usb/6fire - Driver for TerraTec DMX 6Fire USB")
> Cc: stable@vger.kernel.org
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
The same question as your another 6fire patch is applied here: does it
"fix" anything real?
thanks,
Takashi
> ---
> sound/usb/6fire/midi.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/usb/6fire/midi.h b/sound/usb/6fire/midi.h
> index 47640c845903..df3f41913274 100644
> --- a/sound/usb/6fire/midi.h
> +++ b/sound/usb/6fire/midi.h
> @@ -22,12 +22,12 @@ struct midi_runtime {
> spinlock_t in_lock;
> spinlock_t out_lock;
> struct snd_rawmidi_substream *out;
> - struct urb out_urb;
> u8 out_serial; /* serial number of out packet */
> u8 *out_buffer;
> int buffer_offset;
>
> void (*in_received)(struct midi_runtime *rt, u8 *data, int length);
> + struct urb out_urb;
> };
>
> int usb6fire_midi_init(struct sfire_chip *chip);
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-06 9:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-29 16:06 [PATCH][next] ALSA: 6fire: Fix undefined behavior bug in struct midi_runtime Gustavo A. R. Silva
2023-09-29 17:27 ` Kees Cook
2023-10-01 6:53 ` Gustavo A. R. Silva
2023-10-06 9:01 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).