[PATCH] ALSA: pcm: Need to check whether runtime is valid or not
From: eunwoo kim ew.kim@samsung.com
Since snd_pcm_ioctl_sw_params_compat has no runtime variable check, if application call the ioctl after close, it can make kernel crash. So, snd_pcm_ioctl_sw_params_compat needs to check the runtime variable at the beginning of the function.
Signed-off-by: eunwoo kim ew.kim@samsung.com Signed-off-by: Chanho Park chanho61.park@samsung.com --- sound/core/pcm_compat.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 590a46a9e78d..ff0de4252ff4 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c @@ -90,6 +90,9 @@ static int snd_pcm_ioctl_sw_params_compat(struct snd_pcm_substream *substream, snd_pcm_uframes_t boundary; int err;
+ if (!substream->runtime) + return -ENOTTY; + memset(¶ms, 0, sizeof(params)); if (get_user(params.tstamp_mode, &src->tstamp_mode) || get_user(params.period_step, &src->period_step) ||
On Wed, 12 May 2021 06:43:23 +0200, Chanho Park wrote:
From: eunwoo kim ew.kim@samsung.com
Since snd_pcm_ioctl_sw_params_compat has no runtime variable check, if application call the ioctl after close, it can make kernel crash. So, snd_pcm_ioctl_sw_params_compat needs to check the runtime variable at the beginning of the function.
In principle, you cannot call ioctl for an already closed file. Or do you mean other code path?
Takashi
participants (2)
-
Chanho Park
-
Takashi Iwai