Skip to content

Commit 7035878

Browse files
tiwaigregkh
authored andcommitted
ALSA: timer: Add missing mutex lock for compat ioctls
commit 79fb0518fec8c8b4ea7f1729f54f293724b3dbb0 upstream. The races among ioctl and other operations were protected by the commit af368027a49a ("ALSA: timer: Fix race among timer ioctls") and later fixes, but one code path was forgotten in the scenario: the 32bit compat ioctl. As syzkaller recently spotted, a very similar use-after-free may happen with the combination of compat ioctls. The fix is simply to apply the same ioctl_lock to the compat_ioctl callback, too. Fixes: af368027a49a ("ALSA: timer: Fix race among timer ioctls") Reference: http://lkml.kernel.org/r/089e082686ac9b482e055c832617@google.com Reported-by: syzbot <bot+e5f3c9783e7048a74233054febbe9f1bdf54b6da@syzkaller.appspotmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 27e68f1 commit 7035878

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

sound/core/timer_compat.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ enum {
106106
#endif /* CONFIG_X86_X32 */
107107
};
108108

109-
static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
109+
static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
110+
unsigned long arg)
110111
{
111112
void __user *argp = compat_ptr(arg);
112113

@@ -127,7 +128,7 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns
127128
case SNDRV_TIMER_IOCTL_PAUSE:
128129
case SNDRV_TIMER_IOCTL_PAUSE_OLD:
129130
case SNDRV_TIMER_IOCTL_NEXT_DEVICE:
130-
return snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
131+
return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
131132
case SNDRV_TIMER_IOCTL_INFO32:
132133
return snd_timer_user_info_compat(file, argp);
133134
case SNDRV_TIMER_IOCTL_STATUS32:
@@ -139,3 +140,15 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns
139140
}
140141
return -ENOIOCTLCMD;
141142
}
143+
144+
static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
145+
unsigned long arg)
146+
{
147+
struct snd_timer_user *tu = file->private_data;
148+
long ret;
149+
150+
mutex_lock(&tu->ioctl_lock);
151+
ret = __snd_timer_user_ioctl_compat(file, cmd, arg);
152+
mutex_unlock(&tu->ioctl_lock);
153+
return ret;
154+
}

0 commit comments

Comments
 (0)