From: Thomas Gleixner <tglx@linutronix.de>
To: Yao HongBo <yaohongbo@huawei.com>
Cc: Deepa Dinamani <deepa.kernel@gmail.com>,
Arnd Bergmann <arnd@arndb.de>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linuxarm@huawei.com
Subject: Re: [PATCH] time64: Avoid undefined behaviour in timespec64_add()
Date: Wed, 27 Feb 2019 16:52:47 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.21.1902271651330.26197@nanos.tec.linutronix.de> (raw)
In-Reply-To: <6a50f6ed-aa5f-cf3b-71c5-ebd9cbfc29f6@huawei.com>
On Mon, 25 Feb 2019, Yao HongBo wrote:
> On 2/25/2019 12:53 PM, Deepa Dinamani wrote:
> > On Sun, Feb 24, 2019 at 7:13 PM Hongbo Yao <yaohongbo@huawei.com> wrote:
> >> I ran into this:
> >> UBSAN: Undefined behaviour in ./include/linux/time64.h:70:2
> >> signed integer overflow:
> >> 1551059291 + 9223372036854775807 cannot be represented in type 'long
> >> long int'
> >> CPU: 5 PID: 20064 Comm: syz-executor.2 Not tainted 4.19.24 #4
> >> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> >> 1.10.2-1ubuntu1 04/01/2014
> >> Call Trace:
> >> __dump_stack lib/dump_stack.c:77 [inline]
> >> dump_stack+0xca/0x13e lib/dump_stack.c:113
> >> ubsan_epilogue+0xe/0x81 lib/ubsan.c:159
> >> handle_overflow+0x193/0x1e2 lib/ubsan.c:190
> >> timespec64_add include/linux/time64.h:70 [inline]
> >> timekeeping_inject_offset+0x3ed/0x4e0 kernel/time/timekeeping.c:1301
> >> do_adjtimex+0x1e5/0x6c0 kernel/time/timekeeping.c:2360
> >> __do_sys_clock_adjtime+0x122/0x200 kernel/time/posix-timers.c:1086
>
> > You seem to be adding INT64_MAX here. Maybe the right thing to do is
> > to add a check at the syscall interface rather than here.
>
> Thanks for this suggestion. Looks like that is a better way.
> I will try it.
Yes, the input to sys_clock_adjtime() needs to be sanity checked.
Thanks,
tglx
prev parent reply other threads:[~2019-02-27 15:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-25 3:26 Hongbo Yao
2019-02-25 4:53 ` Deepa Dinamani
2019-02-25 9:01 ` Arnd Bergmann
2019-02-25 9:07 ` Arnd Bergmann
2019-02-25 14:19 ` Arnd Bergmann
2019-02-26 1:22 ` Deepa Dinamani
2019-02-25 13:22 ` Yao HongBo
2019-02-27 15:52 ` Thomas Gleixner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.21.1902271651330.26197@nanos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=arnd@arndb.de \
--cc=deepa.kernel@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=yaohongbo@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®