mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
ALSA: rawmidi: Fix missing input substream checks in compat ioctls
commit 8a56ef4f3ffba9ebf4967b61ef600b0a7ba10f11 upstream. Some rawmidi compat ioctls lack of the input substream checks (although they do check only for rfile->output). This many eventually lead to an Oops as NULL substream is passed to the rawmidi core functions. Fix it by adding the proper checks before each function call. The bug was spotted by syzkaller. Reported-by: syzbot+f7a0348affc3b67bc617@syzkaller.appspotmail.com Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
43b3e7915e
commit
fcf38cf55e
@ -36,8 +36,6 @@ static int snd_rawmidi_ioctl_params_compat(struct snd_rawmidi_file *rfile,
|
||||
struct snd_rawmidi_params params;
|
||||
unsigned int val;
|
||||
|
||||
if (rfile->output == NULL)
|
||||
return -EINVAL;
|
||||
if (get_user(params.stream, &src->stream) ||
|
||||
get_user(params.buffer_size, &src->buffer_size) ||
|
||||
get_user(params.avail_min, &src->avail_min) ||
|
||||
@ -46,8 +44,12 @@ static int snd_rawmidi_ioctl_params_compat(struct snd_rawmidi_file *rfile,
|
||||
params.no_active_sensing = val;
|
||||
switch (params.stream) {
|
||||
case SNDRV_RAWMIDI_STREAM_OUTPUT:
|
||||
if (!rfile->output)
|
||||
return -EINVAL;
|
||||
return snd_rawmidi_output_params(rfile->output, ¶ms);
|
||||
case SNDRV_RAWMIDI_STREAM_INPUT:
|
||||
if (!rfile->input)
|
||||
return -EINVAL;
|
||||
return snd_rawmidi_input_params(rfile->input, ¶ms);
|
||||
}
|
||||
return -EINVAL;
|
||||
@ -67,16 +69,18 @@ static int snd_rawmidi_ioctl_status_compat(struct snd_rawmidi_file *rfile,
|
||||
int err;
|
||||
struct snd_rawmidi_status status;
|
||||
|
||||
if (rfile->output == NULL)
|
||||
return -EINVAL;
|
||||
if (get_user(status.stream, &src->stream))
|
||||
return -EFAULT;
|
||||
|
||||
switch (status.stream) {
|
||||
case SNDRV_RAWMIDI_STREAM_OUTPUT:
|
||||
if (!rfile->output)
|
||||
return -EINVAL;
|
||||
err = snd_rawmidi_output_status(rfile->output, &status);
|
||||
break;
|
||||
case SNDRV_RAWMIDI_STREAM_INPUT:
|
||||
if (!rfile->input)
|
||||
return -EINVAL;
|
||||
err = snd_rawmidi_input_status(rfile->input, &status);
|
||||
break;
|
||||
default:
|
||||
@ -112,16 +116,18 @@ static int snd_rawmidi_ioctl_status_x32(struct snd_rawmidi_file *rfile,
|
||||
int err;
|
||||
struct snd_rawmidi_status status;
|
||||
|
||||
if (rfile->output == NULL)
|
||||
return -EINVAL;
|
||||
if (get_user(status.stream, &src->stream))
|
||||
return -EFAULT;
|
||||
|
||||
switch (status.stream) {
|
||||
case SNDRV_RAWMIDI_STREAM_OUTPUT:
|
||||
if (!rfile->output)
|
||||
return -EINVAL;
|
||||
err = snd_rawmidi_output_status(rfile->output, &status);
|
||||
break;
|
||||
case SNDRV_RAWMIDI_STREAM_INPUT:
|
||||
if (!rfile->input)
|
||||
return -EINVAL;
|
||||
err = snd_rawmidi_input_status(rfile->input, &status);
|
||||
break;
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user