diff options
author | Takashi Iwai <tiwai@suse.de> | 2022-06-09 15:02:19 +0300 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2022-06-15 08:45:28 +0300 |
commit | f5e829f92a494a0b66d309497bab4e9d10d4ce3e (patch) | |
tree | 291439188b9d68267c060514dd02f86d924a4499 /sound/core/Kconfig | |
parent | 4e54316ad2485dedf8570fc2afa6fa6ce32db207 (diff) | |
download | linux-f5e829f92a494a0b66d309497bab4e9d10d4ce3e.tar.xz |
ALSA: control: Add input validation
This patch adds a new feature to enable the validation of input data
to control elements in the ALSA core side. When
CONFIG_SND_CTL_INPUT_VALIDATION is set, ALSA core verifies whether the
each input value via control API is in the defined ranges, also checks
whether it's aligned to the defined steps. If an invalid value is
detected, ALSA core returns -EINVAL error immediately without passing
further to the driver's callback. So this is a kind of hardening for
(badly written) drivers that have no proper error checks, at the cost
of a slight performance overhead.
Technically seen, this reuses a part of the existing validation code
for CONFIG_SND_CTL_DEBUG case with a slight modification to suppress
error prints for the input validation.
Link: https://lore.kernel.org/r/20220609120219.3937-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/Kconfig')
-rw-r--r-- | sound/core/Kconfig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sound/core/Kconfig b/sound/core/Kconfig index 5289bb29131b..12990d9a4dff 100644 --- a/sound/core/Kconfig +++ b/sound/core/Kconfig @@ -188,6 +188,16 @@ config SND_PCM_XRUN_DEBUG sound clicking when system is loaded, it may help to determine the process or driver which causes the scheduling gaps. +config SND_CTL_INPUT_VALIDATION + bool "Validate input data to control API" + help + Say Y to enable the additional validation for the input data to + each control element, including the value range checks. + An error is returned from ALSA core for invalid inputs without + passing to the driver. This is a kind of hardening for drivers + that have no proper error checks, at the cost of a slight + performance overhead. + config SND_CTL_DEBUG bool "Enable debugging feature for control API" depends on SND_DEBUG |