linux-stable/sound/core
Takashi Iwai 3cae4f4153 ALSA: seq: fix function cast warnings
[ Upstream commit d7bf738098 ]

clang-16 points out a control flow integrity (kcfi) issue when event
callbacks get converted to incompatible types:

sound/core/seq/seq_midi.c:135:30: error: cast from 'int (*)(struct snd_rawmidi_substream *, const char *, int)' to 'snd_seq_dump_func_t' (aka 'int (*)(void *, void *, int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
  135 |                 snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)dump_midi, substream);
      |                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/core/seq/seq_virmidi.c:83:31: error: cast from 'int (*)(struct snd_rawmidi_substream *, const unsigned char *, int)' to 'snd_seq_dump_func_t' (aka 'int (*)(void *, void *, int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
   83 |                         snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)snd_rawmidi_receive, vmidi->substream);
      |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

For addressing those errors, introduce wrapper functions that are used
for callbacks and bridge to the actual function call with pointer
cast.

The code was originally added with the initial ALSA merge in linux-2.5.4.

[ the patch description shamelessly copied from Arnd's original patch
  -- tiwai ]

Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20240213101020.459183-1-arnd@kernel.org
Link: https://lore.kernel.org/r/20240213135343.16411-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-03-26 18:21:27 -04:00
..
oss ALSA: oss: avoid missing-prototype warnings 2023-06-09 10:32:26 +02:00
seq ALSA: seq: fix function cast warnings 2024-03-26 18:21:27 -04:00
Kconfig
Makefile ALSA: Drop leftover snd-rtctimer stuff from Makefile 2024-03-06 14:38:48 +00:00
compress_offload.c
control.c ALSA: pcm: Move rwsem lock inside snd_ctl_elem_read to prevent UAF 2023-01-14 10:23:28 +01:00
control_compat.c ALSA: ctl: Fix copy of updated id with element read/write 2021-12-14 10:57:11 +01:00
control_led.c ALSA: control-led: use strscpy in set_led_id() 2023-01-18 11:48:46 +01:00
ctljack.c
device.c
hrtimer.c
hwdep.c
hwdep_compat.c
info.c ALSA: info: Fix potential deadlock at disconnection 2023-11-28 16:56:32 +00:00
info_oss.c
init.c ALSA: core: Fix double-free at snd_card_new() 2022-09-28 11:11:40 +02:00
isadma.c
jack.c ALSA: jack: Fix mutex call in snd_jack_report() 2023-07-23 13:47:19 +02:00
memalloc.c ALSA: memalloc: Catch call with NULL snd_dma_buffer pointer 2021-11-18 19:17:08 +01:00
memalloc_local.h
memory.c
misc.c ALSA: core: Add async signal helpers 2022-08-25 11:40:44 +02:00
pcm.c ALSA: pcm: fix out-of-bounds in snd_pcm_state_names 2023-12-13 18:36:42 +01:00
pcm_compat.c ALSA: pcm: Fix missing fixup call in compat hw_refine ioctl 2023-09-19 12:22:50 +02:00
pcm_dmaengine.c ALSA: dmaengine: increment buffer pointer atomically 2022-10-26 12:34:56 +02:00
pcm_drm_eld.c
pcm_iec958.c
pcm_lib.c ALSA: usb-audio: Fix recursive locking at XRUN during syncing 2023-04-05 11:24:54 +02:00
pcm_local.h
pcm_memory.c ALSA: pcm: Fix potential data race at PCM memory allocation helpers 2023-08-30 16:18:12 +02:00
pcm_misc.c ALSA: pcm: Test for "silence" field in struct "pcm_format_data" 2022-04-20 09:34:19 +02:00
pcm_native.c ASoC: soc-pcm: Fix DPCM lockdep warning due to nested stream locks 2023-05-17 11:50:26 +02:00
pcm_param_trace.h
pcm_timer.c
pcm_trace.h
rawmidi.c ALSA: rawmidi: Drop register_mutex in snd_rawmidi_free() 2022-10-26 12:34:17 +02:00
rawmidi_compat.c
seq_device.c ALSA: seq: Fix a potential UAF by wrong private_free call order 2021-09-30 14:13:22 +02:00
sgbuf.c
sound.c
sound_oss.c ALSA: oss: Fix potential deadlock at unregistration 2022-10-26 12:34:17 +02:00
timer.c ALSA: timer: Use deferred fasync helper 2022-08-25 11:40:44 +02:00
timer_compat.c
vmaster.c