Skip to content

Commit 79fb051

Browse files
committed
ALSA: timer: Add missing mutex lock for compat ioctls
The races among ioctl and other operations were protected by the commit af36802 ("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: af36802 ("ALSA: timer: Fix race among timer ioctls") Reference: http://lkml.kernel.org/r/[email protected] Reported-by: syzbot <bot+e5f3c9783e7048a74233054febbe9f1bdf54b6da@syzkaller.appspotmail.com> Cc: <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
1 parent f265788 commit 79fb051

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

sound/core/timer_compat.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ enum {
133133
#endif /* CONFIG_X86_X32 */
134134
};
135135

136-
static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, unsigned long arg)
136+
static long __snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
137+
unsigned long arg)
137138
{
138139
void __user *argp = compat_ptr(arg);
139140

@@ -153,7 +154,7 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns
153154
case SNDRV_TIMER_IOCTL_PAUSE:
154155
case SNDRV_TIMER_IOCTL_PAUSE_OLD:
155156
case SNDRV_TIMER_IOCTL_NEXT_DEVICE:
156-
return snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
157+
return __snd_timer_user_ioctl(file, cmd, (unsigned long)argp);
157158
case SNDRV_TIMER_IOCTL_GPARAMS32:
158159
return snd_timer_user_gparams_compat(file, argp);
159160
case SNDRV_TIMER_IOCTL_INFO32:
@@ -167,3 +168,15 @@ static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd, uns
167168
}
168169
return -ENOIOCTLCMD;
169170
}
171+
172+
static long snd_timer_user_ioctl_compat(struct file *file, unsigned int cmd,
173+
unsigned long arg)
174+
{
175+
struct snd_timer_user *tu = file->private_data;
176+
long ret;
177+
178+
mutex_lock(&tu->ioctl_lock);
179+
ret = __snd_timer_user_ioctl_compat(file, cmd, arg);
180+
mutex_unlock(&tu->ioctl_lock);
181+
return ret;
182+
}

0 commit comments

Comments
 (0)