Skip to content

Commit 19c4096

Browse files
arndbtiwai
authored andcommitted
ALSA: compress_offload: tighten ioctl command number checks
The snd_compr_ioctl() ignores the upper 24 bits of the ioctl command number and only compares the number of the ioctl command, which can cause unintended behavior if an application tries to use an unsupprted command that happens to have the same _IOC_NR() value. Remove the truncation to the low bits and compare the entire ioctl command code like every other driver does. Fixes: b21c60a ("ALSA: core: add support for compress_offload") Signed-off-by: Arnd Bergmann <[email protected]> Acked-by: Vinod Koul <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent d78f764 commit 19c4096

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

sound/core/compress_offload.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,62 +1269,62 @@ static long snd_compr_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
12691269
stream = &data->stream;
12701270

12711271
guard(mutex)(&stream->device->lock);
1272-
switch (_IOC_NR(cmd)) {
1273-
case _IOC_NR(SNDRV_COMPRESS_IOCTL_VERSION):
1272+
switch (cmd) {
1273+
case SNDRV_COMPRESS_IOCTL_VERSION:
12741274
return put_user(SNDRV_COMPRESS_VERSION,
12751275
(int __user *)arg) ? -EFAULT : 0;
1276-
case _IOC_NR(SNDRV_COMPRESS_GET_CAPS):
1276+
case SNDRV_COMPRESS_GET_CAPS:
12771277
return snd_compr_get_caps(stream, arg);
12781278
#ifndef COMPR_CODEC_CAPS_OVERFLOW
1279-
case _IOC_NR(SNDRV_COMPRESS_GET_CODEC_CAPS):
1279+
case SNDRV_COMPRESS_GET_CODEC_CAPS:
12801280
return snd_compr_get_codec_caps(stream, arg);
12811281
#endif
1282-
case _IOC_NR(SNDRV_COMPRESS_SET_PARAMS):
1282+
case SNDRV_COMPRESS_SET_PARAMS:
12831283
return snd_compr_set_params(stream, arg);
1284-
case _IOC_NR(SNDRV_COMPRESS_GET_PARAMS):
1284+
case SNDRV_COMPRESS_GET_PARAMS:
12851285
return snd_compr_get_params(stream, arg);
1286-
case _IOC_NR(SNDRV_COMPRESS_SET_METADATA):
1286+
case SNDRV_COMPRESS_SET_METADATA:
12871287
return snd_compr_set_metadata(stream, arg);
1288-
case _IOC_NR(SNDRV_COMPRESS_GET_METADATA):
1288+
case SNDRV_COMPRESS_GET_METADATA:
12891289
return snd_compr_get_metadata(stream, arg);
12901290
}
12911291

12921292
if (stream->direction == SND_COMPRESS_ACCEL) {
12931293
#if IS_ENABLED(CONFIG_SND_COMPRESS_ACCEL)
1294-
switch (_IOC_NR(cmd)) {
1295-
case _IOC_NR(SNDRV_COMPRESS_TASK_CREATE):
1294+
switch (cmd) {
1295+
case SNDRV_COMPRESS_TASK_CREATE:
12961296
return snd_compr_task_create(stream, arg);
1297-
case _IOC_NR(SNDRV_COMPRESS_TASK_FREE):
1297+
case SNDRV_COMPRESS_TASK_FREE:
12981298
return snd_compr_task_seq(stream, arg, snd_compr_task_free_one);
1299-
case _IOC_NR(SNDRV_COMPRESS_TASK_START):
1299+
case SNDRV_COMPRESS_TASK_START:
13001300
return snd_compr_task_start_ioctl(stream, arg);
1301-
case _IOC_NR(SNDRV_COMPRESS_TASK_STOP):
1301+
case SNDRV_COMPRESS_TASK_STOP:
13021302
return snd_compr_task_seq(stream, arg, snd_compr_task_stop_one);
1303-
case _IOC_NR(SNDRV_COMPRESS_TASK_STATUS):
1303+
case SNDRV_COMPRESS_TASK_STATUS:
13041304
return snd_compr_task_status_ioctl(stream, arg);
13051305
}
13061306
#endif
13071307
return -ENOTTY;
13081308
}
13091309

1310-
switch (_IOC_NR(cmd)) {
1311-
case _IOC_NR(SNDRV_COMPRESS_TSTAMP):
1310+
switch (cmd) {
1311+
case SNDRV_COMPRESS_TSTAMP:
13121312
return snd_compr_tstamp(stream, arg);
1313-
case _IOC_NR(SNDRV_COMPRESS_AVAIL):
1313+
case SNDRV_COMPRESS_AVAIL:
13141314
return snd_compr_ioctl_avail(stream, arg);
1315-
case _IOC_NR(SNDRV_COMPRESS_PAUSE):
1315+
case SNDRV_COMPRESS_PAUSE:
13161316
return snd_compr_pause(stream);
1317-
case _IOC_NR(SNDRV_COMPRESS_RESUME):
1317+
case SNDRV_COMPRESS_RESUME:
13181318
return snd_compr_resume(stream);
1319-
case _IOC_NR(SNDRV_COMPRESS_START):
1319+
case SNDRV_COMPRESS_START:
13201320
return snd_compr_start(stream);
1321-
case _IOC_NR(SNDRV_COMPRESS_STOP):
1321+
case SNDRV_COMPRESS_STOP:
13221322
return snd_compr_stop(stream);
1323-
case _IOC_NR(SNDRV_COMPRESS_DRAIN):
1323+
case SNDRV_COMPRESS_DRAIN:
13241324
return snd_compr_drain(stream);
1325-
case _IOC_NR(SNDRV_COMPRESS_PARTIAL_DRAIN):
1325+
case SNDRV_COMPRESS_PARTIAL_DRAIN:
13261326
return snd_compr_partial_drain(stream);
1327-
case _IOC_NR(SNDRV_COMPRESS_NEXT_TRACK):
1327+
case SNDRV_COMPRESS_NEXT_TRACK:
13281328
return snd_compr_next_track(stream);
13291329
}
13301330

0 commit comments

Comments
 (0)