linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [syzbot] UBSAN: shift-out-of-bounds in snd_timer_user_ccallback
@ 2021-06-02 13:18 Dongliang Mu
  2021-06-02 14:19 ` Jaroslav Kysela
  0 siblings, 1 reply; 5+ messages in thread
From: Dongliang Mu @ 2021-06-02 13:18 UTC (permalink / raw)
  To: allen.lkml, alsa-devel, Joe Perches, linux-kernel, perex,
	pierre-louis.bossart, romain.perier, syzkaller-bugs, tiwai

> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 5ff2756a Merge tag 'nfs-for-5.13-2' of git://git.linux-nfs..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=17872d5bd00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=770708ea7cfd4916
> dashboard link: https://syzkaller.appspot.com/bug?extid=d102fa5b35335a7e544e
>
> Unfortunately, I don't have any reproducer for this issue yet.
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+d102fa...@syzkaller.appspotmail.com
>
> ================================================================================
> UBSAN: shift-out-of-bounds in sound/core/timer.c:1376:23
> shift exponent 105 is too large for 32-bit type 'int'
> CPU: 1 PID: 10368 Comm: syz-executor.1 Not tainted 5.13.0-rc3-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> Call Trace:
> __dump_stack lib/dump_stack.c:79 [inline]
> dump_stack+0x141/0x1d7 lib/dump_stack.c:120
> ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
> __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:327
> snd_timer_user_ccallback.cold+0x19/0x1e sound/core/timer.c:1376
>
> snd_timer_notify1+0x243/0x3b0 sound/core/timer.c:525

The root cause of this bug is in the snd_timer_notify1 [1]. At the end
of this function, it calls "ts->ccallback(ts, event + 100, &tstamp,
resolution)".

Here the variable event is 5. It adds 100 and is passed as 2nd
argument of snd_timer_user_ccallback.

From the variable naming, the 2nd argument should an event, and in the
range of event enumeration. In fact, 105 (event + 100) is out of this
range. I don't quite understand the meaning of adding 100. Any thought
here?

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/core/timer.c?id=5ff2756afde08b266fbb673849899fec694f39f1#n497

--
My best regards to you.

     No System Is Safe!
     Dongliang Mu

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] UBSAN: shift-out-of-bounds in snd_timer_user_ccallback
  2021-06-02 13:18 [syzbot] UBSAN: shift-out-of-bounds in snd_timer_user_ccallback Dongliang Mu
@ 2021-06-02 14:19 ` Jaroslav Kysela
  2021-06-02 14:24   ` Takashi Iwai
  2021-06-02 14:42   ` Dongliang Mu
  0 siblings, 2 replies; 5+ messages in thread
From: Jaroslav Kysela @ 2021-06-02 14:19 UTC (permalink / raw)
  To: Dongliang Mu, allen.lkml, alsa-devel, Joe Perches, linux-kernel,
	pierre-louis.bossart, romain.perier, syzkaller-bugs, tiwai

On 02. 06. 21 15:18, Dongliang Mu wrote:
>> Hello,
>>
>> syzbot found the following issue on:
>>
>> HEAD commit: 5ff2756a Merge tag 'nfs-for-5.13-2' of git://git.linux-nfs..
>> git tree: upstream
>> console output: https://syzkaller.appspot.com/x/log.txt?x=17872d5bd00000
>> kernel config: https://syzkaller.appspot.com/x/.config?x=770708ea7cfd4916
>> dashboard link: https://syzkaller.appspot.com/bug?extid=d102fa5b35335a7e544e
>>
>> Unfortunately, I don't have any reproducer for this issue yet.
>>
>> IMPORTANT: if you fix the issue, please add the following tag to the commit:
>> Reported-by: syzbot+d102fa...@syzkaller.appspotmail.com
>>
>> ================================================================================
>> UBSAN: shift-out-of-bounds in sound/core/timer.c:1376:23
>> shift exponent 105 is too large for 32-bit type 'int'
>> CPU: 1 PID: 10368 Comm: syz-executor.1 Not tainted 5.13.0-rc3-syzkaller #0
>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
>> Call Trace:
>> __dump_stack lib/dump_stack.c:79 [inline]
>> dump_stack+0x141/0x1d7 lib/dump_stack.c:120
>> ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
>> __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:327
>> snd_timer_user_ccallback.cold+0x19/0x1e sound/core/timer.c:1376
>>
>> snd_timer_notify1+0x243/0x3b0 sound/core/timer.c:525
> 
> The root cause of this bug is in the snd_timer_notify1 [1]. At the end
> of this function, it calls "ts->ccallback(ts, event + 100, &tstamp,
> resolution)".
> 
> Here the variable event is 5. It adds 100 and is passed as 2nd
> argument of snd_timer_user_ccallback.
> 
>>From the variable naming, the 2nd argument should an event, and in the
> range of event enumeration. In fact, 105 (event + 100) is out of this
> range. I don't quite understand the meaning of adding 100. Any thought
> here?

It seems that the original intent was to move the event to the M... events:

     SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10,

So the added value should be 10 which should not break the shift range (8
/resume/ + 10 = 18).

					Jaroslav

> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/core/timer.c?id=5ff2756afde08b266fbb673849899fec694f39f1#n497
> 
> --
> My best regards to you.
> 
>      No System Is Safe!
>      Dongliang Mu
> 


-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] UBSAN: shift-out-of-bounds in snd_timer_user_ccallback
  2021-06-02 14:19 ` Jaroslav Kysela
@ 2021-06-02 14:24   ` Takashi Iwai
  2021-06-02 14:42   ` Dongliang Mu
  1 sibling, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2021-06-02 14:24 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: Dongliang Mu, allen.lkml, alsa-devel, Joe Perches, linux-kernel,
	pierre-louis.bossart, romain.perier, syzkaller-bugs, tiwai

On Wed, 02 Jun 2021 16:19:13 +0200,
Jaroslav Kysela wrote:
> 
> On 02. 06. 21 15:18, Dongliang Mu wrote:
> >> Hello,
> >>
> >> syzbot found the following issue on:
> >>
> >> HEAD commit: 5ff2756a Merge tag 'nfs-for-5.13-2' of git://git.linux-nfs..
> >> git tree: upstream
> >> console output: https://syzkaller.appspot.com/x/log.txt?x=17872d5bd00000
> >> kernel config: https://syzkaller.appspot.com/x/.config?x=770708ea7cfd4916
> >> dashboard link: https://syzkaller.appspot.com/bug?extid=d102fa5b35335a7e544e
> >>
> >> Unfortunately, I don't have any reproducer for this issue yet.
> >>
> >> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> >> Reported-by: syzbot+d102fa...@syzkaller.appspotmail.com
> >>
> >> ================================================================================
> >> UBSAN: shift-out-of-bounds in sound/core/timer.c:1376:23
> >> shift exponent 105 is too large for 32-bit type 'int'
> >> CPU: 1 PID: 10368 Comm: syz-executor.1 Not tainted 5.13.0-rc3-syzkaller #0
> >> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> >> Call Trace:
> >> __dump_stack lib/dump_stack.c:79 [inline]
> >> dump_stack+0x141/0x1d7 lib/dump_stack.c:120
> >> ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
> >> __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:327
> >> snd_timer_user_ccallback.cold+0x19/0x1e sound/core/timer.c:1376
> >>
> >> snd_timer_notify1+0x243/0x3b0 sound/core/timer.c:525
> > 
> > The root cause of this bug is in the snd_timer_notify1 [1]. At the end
> > of this function, it calls "ts->ccallback(ts, event + 100, &tstamp,
> > resolution)".
> > 
> > Here the variable event is 5. It adds 100 and is passed as 2nd
> > argument of snd_timer_user_ccallback.
> > 
> >>From the variable naming, the 2nd argument should an event, and in the
> > range of event enumeration. In fact, 105 (event + 100) is out of this
> > range. I don't quite understand the meaning of adding 100. Any thought
> > here?
> 
> It seems that the original intent was to move the event to the M... events:
> 
>      SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10,
> 
> So the added value should be 10 which should not break the shift range (8
> /resume/ + 10 = 18).

I've already submitted the fix patch, but it doesn't seem reaching
properly to ML.  Hmm.  Will resend.


Takashi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [syzbot] UBSAN: shift-out-of-bounds in snd_timer_user_ccallback
  2021-06-02 14:19 ` Jaroslav Kysela
  2021-06-02 14:24   ` Takashi Iwai
@ 2021-06-02 14:42   ` Dongliang Mu
  1 sibling, 0 replies; 5+ messages in thread
From: Dongliang Mu @ 2021-06-02 14:42 UTC (permalink / raw)
  To: Jaroslav Kysela
  Cc: allen.lkml, alsa-devel, Joe Perches, linux-kernel,
	pierre-louis.bossart, romain.perier, syzkaller-bugs, tiwai

On Wed, Jun 2, 2021 at 10:19 PM Jaroslav Kysela <perex@perex.cz> wrote:
>
> On 02. 06. 21 15:18, Dongliang Mu wrote:
> >> Hello,
> >>
> >> syzbot found the following issue on:
> >>
> >> HEAD commit: 5ff2756a Merge tag 'nfs-for-5.13-2' of git://git.linux-nfs..
> >> git tree: upstream
> >> console output: https://syzkaller.appspot.com/x/log.txt?x=17872d5bd00000
> >> kernel config: https://syzkaller.appspot.com/x/.config?x=770708ea7cfd4916
> >> dashboard link: https://syzkaller.appspot.com/bug?extid=d102fa5b35335a7e544e
> >>
> >> Unfortunately, I don't have any reproducer for this issue yet.
> >>
> >> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> >> Reported-by: syzbot+d102fa...@syzkaller.appspotmail.com
> >>
> >> ================================================================================
> >> UBSAN: shift-out-of-bounds in sound/core/timer.c:1376:23
> >> shift exponent 105 is too large for 32-bit type 'int'
> >> CPU: 1 PID: 10368 Comm: syz-executor.1 Not tainted 5.13.0-rc3-syzkaller #0
> >> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> >> Call Trace:
> >> __dump_stack lib/dump_stack.c:79 [inline]
> >> dump_stack+0x141/0x1d7 lib/dump_stack.c:120
> >> ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
> >> __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:327
> >> snd_timer_user_ccallback.cold+0x19/0x1e sound/core/timer.c:1376
> >>
> >> snd_timer_notify1+0x243/0x3b0 sound/core/timer.c:525
> >
> > The root cause of this bug is in the snd_timer_notify1 [1]. At the end
> > of this function, it calls "ts->ccallback(ts, event + 100, &tstamp,
> > resolution)".
> >
> > Here the variable event is 5. It adds 100 and is passed as 2nd
> > argument of snd_timer_user_ccallback.
> >
> >>From the variable naming, the 2nd argument should an event, and in the
> > range of event enumeration. In fact, 105 (event + 100) is out of this
> > range. I don't quite understand the meaning of adding 100. Any thought
> > here?
>
> It seems that the original intent was to move the event to the M... events:
>
>      SNDRV_TIMER_EVENT_MSTART = SNDRV_TIMER_EVENT_START + 10,
>
> So the added value should be 10 which should not break the shift range (8
> /resume/ + 10 = 18).

It seems you are right. Then event should be between
SNDRV_TIMER_EVENT_MSTART and SNDRV_TIMER_EVENT_MPAUSE.

I double check all the ccallback site, only snd_timer_notify1 invokes
ccallback with event + 100, others seem ok.

1 timer.c snd_timer_notify1        515 if (ti->ccallback)
2 timer.c snd_timer_notify1        516 ti->ccallback(ti, event,
&tstamp, resolution);
3 timer.c snd_timer_notify1        524 if (ts->ccallback)
4 timer.c snd_timer_notify1        525 ts->ccallback(ts, event + 100,
&tstamp, resolution);
5 timer.c snd_timer_notify        1092 if (ti->ccallback)
6 timer.c snd_timer_notify        1093 ti->ccallback(ti, event,
tstamp, resolution);
7 timer.c snd_timer_notify        1095 if (ts->ccallback)
8 timer.c snd_timer_notify        1096 ts->ccallback(ts, event,
tstamp, resolution);
9 timer.c snd_timer_user_tselect  1782 tu->timeri->ccallback =
snd_timer_user_ccallback;
a aloop.c loopback_snd_timer_open 1137 timeri->ccallback =
loopback_snd_timer_event;



>
>                                         Jaroslav
>
> >
> > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/core/timer.c?id=5ff2756afde08b266fbb673849899fec694f39f1#n497
> >
> > --
> > My best regards to you.
> >
> >      No System Is Safe!
> >      Dongliang Mu
> >
>
>
> --
> Jaroslav Kysela <perex@perex.cz>
> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [syzbot] UBSAN: shift-out-of-bounds in snd_timer_user_ccallback
@ 2021-06-01 23:58 syzbot
  0 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2021-06-01 23:58 UTC (permalink / raw)
  To: allen.lkml, alsa-devel, joe, linux-kernel, perex,
	pierre-louis.bossart, romain.perier, syzkaller-bugs, tiwai

Hello,

syzbot found the following issue on:

HEAD commit:    5ff2756a Merge tag 'nfs-for-5.13-2' of git://git.linux-nfs..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17872d5bd00000
kernel config:  https://syzkaller.appspot.com/x/.config?x=770708ea7cfd4916
dashboard link: https://syzkaller.appspot.com/bug?extid=d102fa5b35335a7e544e

Unfortunately, I don't have any reproducer for this issue yet.

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+d102fa5b35335a7e544e@syzkaller.appspotmail.com

================================================================================
UBSAN: shift-out-of-bounds in sound/core/timer.c:1376:23
shift exponent 105 is too large for 32-bit type 'int'
CPU: 1 PID: 10368 Comm: syz-executor.1 Not tainted 5.13.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:79 [inline]
 dump_stack+0x141/0x1d7 lib/dump_stack.c:120
 ubsan_epilogue+0xb/0x5a lib/ubsan.c:148
 __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x181 lib/ubsan.c:327
 snd_timer_user_ccallback.cold+0x19/0x1e sound/core/timer.c:1376
 snd_timer_notify1+0x243/0x3b0 sound/core/timer.c:525
 snd_timer_stop1+0x641/0x890 sound/core/timer.c:656
 snd_timer_pause+0x6e/0x90 sound/core/timer.c:738
 seq_timer_stop sound/core/seq/seq_timer.c:331 [inline]
 snd_seq_timer_stop+0x93/0xd0 sound/core/seq/seq_timer.c:341
 queue_delete+0x42/0xa0 sound/core/seq/seq_queue.c:133
 snd_seq_queue_client_leave+0x37/0x1a0 sound/core/seq/seq_queue.c:552
 seq_free_client1.part.0+0x10a/0x260 sound/core/seq/seq_clientmgr.c:280
 seq_free_client1 sound/core/seq/seq_clientmgr.c:273 [inline]
 seq_free_client+0x7b/0xf0 sound/core/seq/seq_clientmgr.c:301
 snd_seq_release+0x4d/0xe0 sound/core/seq/seq_clientmgr.c:382
 __fput+0x288/0x920 fs/file_table.c:280
 task_work_run+0xdd/0x1a0 kernel/task_work.c:164
 tracehook_notify_resume include/linux/tracehook.h:189 [inline]
 exit_to_user_mode_loop kernel/entry/common.c:174 [inline]
 exit_to_user_mode_prepare+0x272/0x280 kernel/entry/common.c:208
 __syscall_exit_to_user_mode_work kernel/entry/common.c:290 [inline]
 syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:301
 do_syscall_64+0x47/0xb0 arch/x86/entry/common.c:57
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x4193eb
Code: 0f 05 48 3d 00 f0 ff ff 77 45 c3 0f 1f 40 00 48 83 ec 18 89 7c 24 0c e8 63 fc ff ff 8b 7c 24 0c 41 89 c0 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 35 44 89 c7 89 44 24 0c e8 a1 fc ff ff 8b 44
RSP: 002b:0000000000a9fb80 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000005 RCX: 00000000004193eb
RDX: 0000000000571b58 RSI: ffffffff89166efe RDI: 0000000000000004
RBP: 0000000000000001 R08: 0000000000000000 R09: 0000001b2ea280a8
R10: 00000000000001d1 R11: 0000000000000293 R12: 000000000014d248
R13: 00000000000003e8 R14: 000000000056bf80 R15: 000000000014d1dd
================================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-02 15:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-02 13:18 [syzbot] UBSAN: shift-out-of-bounds in snd_timer_user_ccallback Dongliang Mu
2021-06-02 14:19 ` Jaroslav Kysela
2021-06-02 14:24   ` Takashi Iwai
2021-06-02 14:42   ` Dongliang Mu
  -- strict thread matches above, loose matches on Subject: below --
2021-06-01 23:58 syzbot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).