linux-stable/sound/hda
Tuo Li b32e40379e ALSA: hda: fix a possible null-pointer dereference due to data race in snd_hdac_regmap_sync()
[ Upstream commit 1f4a08fed4 ]

The variable codec->regmap is often protected by the lock
codec->regmap_lock when is accessed. However, it is accessed without
holding the lock when is accessed in snd_hdac_regmap_sync():

  if (codec->regmap)

In my opinion, this may be a harmful race, because if codec->regmap is
set to NULL right after the condition is checked, a null-pointer
dereference can occur in the called function regcache_sync():

  map->lock(map->lock_arg); --> Line 360 in drivers/base/regmap/regcache.c

To fix this possible null-pointer dereference caused by data race, the
mutex_lock coverage is extended to protect the if statement as well as the
function call to regcache_sync().

[ Note: the lack of the regmap_lock itself is harmless for the current
  codec driver implementations, as snd_hdac_regmap_sync() is only for
  PM runtime resume that is prohibited during the codec probe.
  But the change makes the whole code more consistent, so it's merged
  as is -- tiwai ]

Reported-by: BassCheck <bass@buaa.edu.cn>
Signed-off-by: Tuo Li <islituo@gmail.com>
Link: https://lore.kernel.org/r/20230703031016.1184711-1-islituo@gmail.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-08-23 17:32:33 +02:00
..
ext ALSA: hda: Allow for compress stream to hdac_ext_stream assignment 2022-12-05 14:05:18 +00:00
Kconfig ALSA: hda: Revert "ALSA: hda: Allow setting preallocation again for x86" 2021-03-19 16:55:11 +01:00
Makefile ALSA: hda: move Intel SoundWire ACPI scan to dedicated module 2021-03-02 15:33:00 +01:00
array.c
hda_bus_type.c driver core: make struct bus_type.uevent() take a const * 2023-01-27 13:45:52 +01:00
hdac_bus.c ALSA: hda: Skip event processing for unregistered codecs 2022-07-15 16:26:50 +02:00
hdac_component.c
hdac_controller.c ALSA: hda: Interrupt servicing and BDL setup for compress streams 2022-12-05 14:05:20 +00:00
hdac_device.c ALSA: hda: Fix unhandled register update during auto-suspend period 2023-05-22 14:20:29 +02:00
hdac_i915.c ALSA: hda: Fix discovery of i915 graphics PCI device 2022-06-21 14:05:12 +02:00
hdac_regmap.c ALSA: hda: fix a possible null-pointer dereference due to data race in snd_hdac_regmap_sync() 2023-08-23 17:32:33 +02:00
hdac_stream.c ALSA: hda: remove redundant variable in snd_hdac_stream_start() 2023-02-10 10:06:50 +01:00
hdac_sysfs.c ALSA: hda: make kobj_type structure constant 2023-02-11 09:37:42 +01:00
hdmi_chmap.c ALSA: hda: Replace runtime->status->state reference to runtime->state 2022-09-27 08:47:33 +02:00
intel-dsp-config.c ALSA: hda: intel-dsp-config: add MTL PCI id 2023-03-08 06:37:19 +01:00
intel-nhlt.c ALSA: hda: intel-nhlt: add intel_nhlt_ssp_mclk_mask() 2022-09-20 12:25:03 +01:00
intel-sdw-acpi.c ALSA: Replace acpi_bus_get_device() 2022-02-01 08:08:08 +01:00
local.h
trace.c
trace.h tracing: ALSA: hda: Remove string manipulation out of the fast path 2022-07-04 14:31:19 +02:00