All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: UBSAN: Undefined error in time.h signed integer overflow
       [not found] <CAASgV=vRCcjLxPfPq3T47wUU41arPDrZb=O1N7bktZh3ebcJpg@mail.gmail.com>
@ 2017-09-06  4:55 ` John Stultz
  2017-09-06  8:07   ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: John Stultz @ 2017-09-06  4:55 UTC (permalink / raw)
  To: Shankara Pailoor; +Cc: lkml, syzkaller, Thomas Gleixner, Stephen Boyd

On Tue, Sep 5, 2017 at 9:30 PM, Shankara Pailoor <sp3485@columbia.edu> wrote:
> Hi,
>
> I encountered this bug while fuzzing linux kernel 4.13-rc7 with syzkaller.
>
> ================================================================================
> UBSAN: Undefined behaviour in ./include/linux/time.h:233:27
> signed integer overflow:
> 8391720337152500783 * 1000000000 cannot be represented in type 'long int'
> CPU: 0 PID: 31798 Comm: syz-executor2 Not tainted 4.13.0-rc7 #2
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> Ubuntu-1.8.2-1ubuntu1 04/01/2014
> Call Trace:
>  __dump_stack lib/dump_stack.c:16 [inline]
>  dump_stack+0xf7/0x1ae lib/dump_stack.c:52
>  ubsan_epilogue+0x12/0x8f lib/ubsan.c:164
>  handle_overflow+0x21e/0x292 lib/ubsan.c:195
>  __ubsan_handle_mul_overflow+0x2a/0x3e lib/ubsan.c:219
>  timespec_to_ns include/linux/time.h:233 [inline]
>  posix_cpu_timer_set+0xb5c/0xf20 kernel/time/posix-cpu-timers.c:686
>  do_timer_settime+0x1f4/0x390 kernel/time/posix-timers.c:890
>  SYSC_timer_settime kernel/time/posix-timers.c:916 [inline]
>  SyS_timer_settime+0xea/0x170 kernel/time/posix-timers.c:902
>  entry_SYSCALL_64_fastpath+0x18/0xad
> RIP: 0033:0x451e59
> RSP: 002b:00007fb62af4fc08 EFLAGS: 00000216 ORIG_RAX: 00000000000000df
> RAX: ffffffffffffffda RBX: 0000000000718000 RCX: 0000000000451e59
> RDX: 0000000020006000 RSI: 0000000000000000 RDI: 0000000000000000
> RBP: 0000000000000046 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000020003fe0 R11: 0000000000000216 R12: 00000000004be920
> R13: 00000000ffffffff R14: ffffffffffffffff R15: 0000000000000000
> ================================================================================

Looks similar to the issue Thomas fixed here:
   https://patchwork.kernel.org/patch/9799827/


Thomas: Should we change timespec_to_ns() to use the same transition
internally rather then trying to track all the callers?

thanks
-john

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

* Re: UBSAN: Undefined error in time.h signed integer overflow
  2017-09-06  4:55 ` UBSAN: Undefined error in time.h signed integer overflow John Stultz
@ 2017-09-06  8:07   ` Thomas Gleixner
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2017-09-06  8:07 UTC (permalink / raw)
  To: John Stultz; +Cc: Shankara Pailoor, lkml, syzkaller, Stephen Boyd

On Tue, 5 Sep 2017, John Stultz wrote:
> On Tue, Sep 5, 2017 at 9:30 PM, Shankara Pailoor <sp3485@columbia.edu> wrote:
> > Hi,
> >
> > I encountered this bug while fuzzing linux kernel 4.13-rc7 with syzkaller.
> >
> > ================================================================================
> > UBSAN: Undefined behaviour in ./include/linux/time.h:233:27
> > signed integer overflow:
> > 8391720337152500783 * 1000000000 cannot be represented in type 'long int'
> > CPU: 0 PID: 31798 Comm: syz-executor2 Not tainted 4.13.0-rc7 #2
> > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> > Ubuntu-1.8.2-1ubuntu1 04/01/2014
> > Call Trace:
> >  __dump_stack lib/dump_stack.c:16 [inline]
> >  dump_stack+0xf7/0x1ae lib/dump_stack.c:52
> >  ubsan_epilogue+0x12/0x8f lib/ubsan.c:164
> >  handle_overflow+0x21e/0x292 lib/ubsan.c:195
> >  __ubsan_handle_mul_overflow+0x2a/0x3e lib/ubsan.c:219
> >  timespec_to_ns include/linux/time.h:233 [inline]
> >  posix_cpu_timer_set+0xb5c/0xf20 kernel/time/posix-cpu-timers.c:686
> >  do_timer_settime+0x1f4/0x390 kernel/time/posix-timers.c:890
> >  SYSC_timer_settime kernel/time/posix-timers.c:916 [inline]
> >  SyS_timer_settime+0xea/0x170 kernel/time/posix-timers.c:902
> >  entry_SYSCALL_64_fastpath+0x18/0xad
> > RIP: 0033:0x451e59
> > RSP: 002b:00007fb62af4fc08 EFLAGS: 00000216 ORIG_RAX: 00000000000000df
> > RAX: ffffffffffffffda RBX: 0000000000718000 RCX: 0000000000451e59
> > RDX: 0000000020006000 RSI: 0000000000000000 RDI: 0000000000000000
> > RBP: 0000000000000046 R08: 0000000000000000 R09: 0000000000000000
> > R10: 0000000020003fe0 R11: 0000000000000216 R12: 00000000004be920
> > R13: 00000000ffffffff R14: ffffffffffffffff R15: 0000000000000000
> > ================================================================================
> 
> Looks similar to the issue Thomas fixed here:
>    https://patchwork.kernel.org/patch/9799827/
> 
> 
> Thomas: Should we change timespec_to_ns() to use the same transition
> internally rather then trying to track all the callers?

Probably.

Thanks,

	tglx

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

* UBSAN: Undefined error in time.h signed integer overflow
@ 2017-09-06  4:32 Shankara Pailoor
  0 siblings, 0 replies; 3+ messages in thread
From: Shankara Pailoor @ 2017-09-06  4:32 UTC (permalink / raw)
  To: linux-kernel

Hi,

I encountered this bug while fuzzing linux kernel 4.13-rc7 with syzkaller.

================================================================================
UBSAN: Undefined behaviour in ./include/linux/time.h:233:27
signed integer overflow:
8391720337152500783 * 1000000000 cannot be represented in type 'long int'
CPU: 0 PID: 31798 Comm: syz-executor2 Not tainted 4.13.0-rc7 #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
Ubuntu-1.8.2-1ubuntu1 04/01/2014
Call Trace:
 __dump_stack lib/dump_stack.c:16 [inline]
 dump_stack+0xf7/0x1ae lib/dump_stack.c:52
 ubsan_epilogue+0x12/0x8f lib/ubsan.c:164
 handle_overflow+0x21e/0x292 lib/ubsan.c:195
 __ubsan_handle_mul_overflow+0x2a/0x3e lib/ubsan.c:219
 timespec_to_ns include/linux/time.h:233 [inline]
 posix_cpu_timer_set+0xb5c/0xf20 kernel/time/posix-cpu-timers.c:686
 do_timer_settime+0x1f4/0x390 kernel/time/posix-timers.c:890
 SYSC_timer_settime kernel/time/posix-timers.c:916 [inline]
 SyS_timer_settime+0xea/0x170 kernel/time/posix-timers.c:902
 entry_SYSCALL_64_fastpath+0x18/0xad
RIP: 0033:0x451e59
RSP: 002b:00007fb62af4fc08 EFLAGS: 00000216 ORIG_RAX: 00000000000000df
RAX: ffffffffffffffda RBX: 0000000000718000 RCX: 0000000000451e59
RDX: 0000000020006000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000046 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000020003fe0 R11: 0000000000000216 R12: 00000000004be920
R13: 00000000ffffffff R14: ffffffffffffffff R15: 0000000000000000
================================================================================


Here is the full reproducer program: https://pastebin.com/xucAtmbD

Below is the core of the reproducer:

long r[16];
void *thr(void *arg)
{
switch ((long)arg) {
case 0:
r[0] = syscall(__NR_mmap, 0x20000000ul, 0xd000ul, 0x3ul, 0x32ul,
0xfffffffffffffffful, 0x0ul);
break;
case 1:
NONFAILING(*(uint64_t*)0x20001fb0 = (uint64_t)0x0);
NONFAILING(*(uint32_t*)0x20001fb8 = (uint32_t)0x1);
NONFAILING(*(uint32_t*)0x20001fbc = (uint32_t)0x0);
NONFAILING(*(uint64_t*)0x20001fc0 = (uint64_t)0x20007fcd);
NONFAILING(*(uint64_t*)0x20001fc8 = (uint64_t)0x20005000);
r[6] = syscall(__NR_timer_create, 0x3ul, 0x20001fb0ul, 0x20000000ul);
break;
case 2:
r[7] = syscall(__NR_clock_gettime, 0x0ul, 0x20004000ul);
if (r[7] != -1)
NONFAILING(r[8] = *(uint64_t*)0x20004008);
break;
case 3:
NONFAILING(*(uint64_t*)0x20006000 = (uint64_t)0x0);
NONFAILING(*(uint64_t*)0x20006008 = (uint64_t)0x0);
NONFAILING(*(uint64_t*)0x20006010 = (uint64_t)0x0);
NONFAILING(*(uint64_t*)0x20006018 = r[8]+10000000);
r[13] = syscall(__NR_timer_settime, 0x0ul, 0x0ul, 0x20006000ul, 0x20003fe0ul);
break;
case 4:
NONFAILING(memcpy((void*)0x20006000,
"\x2f\x64\x65\x76\x2f\x61\x75\x74\x6f\x66\x73\x00", 12));
r[15] = syscall(__NR_openat, 0xffffffffffffff9cul, 0x20006000ul,
0x8000ul, 0x0ul);
break;
}
return 0;
}

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

end of thread, other threads:[~2017-09-06  8:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAASgV=vRCcjLxPfPq3T47wUU41arPDrZb=O1N7bktZh3ebcJpg@mail.gmail.com>
2017-09-06  4:55 ` UBSAN: Undefined error in time.h signed integer overflow John Stultz
2017-09-06  8:07   ` Thomas Gleixner
2017-09-06  4:32 Shankara Pailoor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.