linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Xuefeng Wang <wxf.wang@hisilicon.com>
Cc: a.zummo@towertech.it, linux-rtc@vger.kernel.org,
	linux-kernel@vger.kernel.org, tanxiaojun@huawei.com
Subject: Re: [PATCH] drivers/rtc/rtc-lib.c: check whether tm->tm_year in int32 range
Date: Sat, 6 Apr 2019 15:06:30 +0200	[thread overview]
Message-ID: <20190406130630.GB7480@piout.net> (raw)
In-Reply-To: <1550200439-62533-1-git-send-email-wxf.wang@hisilicon.com>

On 15/02/2019 11:13:59+0800, Xuefeng Wang wrote:
> When setting rtc alarm (RTC_WKALM_SET), the tm_year is not checked if it
> is in suiteable range. Use INT_MAX - 1900 to check it.
> 
> UBSAN: Undefined behaviour in drivers/rtc/rtc-lib.c:119:30
> signed integer overflow:
> 2147483647 + 1900 cannot be represented in type 'int'
> CPU: 1 PID: 20994 Comm: syz-executor0 Not tainted 4.19.18-514.55.6.9.x86_64
> + #1
> 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
>  rtc_tm_to_time64+0x267/0x280 drivers/rtc/rtc-lib.c:119
>  rtc_tm_to_ktime+0x16/0x70 drivers/rtc/rtc-lib.c:129
>  rtc_set_alarm+0x1a9/0x2d0 drivers/rtc/interface.c:466
>  rtc_dev_ioctl+0x6db/0x810 drivers/rtc/rtc-dev.c:380
>  vfs_ioctl fs/ioctl.c:46 [inline]
>  do_vfs_ioctl+0x1a5/0x10b0 fs/ioctl.c:690
>  ksys_ioctl+0x89/0xa0 fs/ioctl.c:705
>  __do_sys_ioctl fs/ioctl.c:712 [inline]
>  __se_sys_ioctl fs/ioctl.c:710 [inline]
>  __x64_sys_ioctl+0x74/0xb0 fs/ioctl.c:710
>  do_syscall_64+0xc8/0x580 arch/x86/entry/common.c:290
>  entry_SYSCALL_64_after_hwframe+0x49/0xbe
> RIP: 0033:0x462589
> Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89
> f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08
> 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8
> 64 89 01 48
> RSP: 002b:00007f5348896c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 000000000072bf00 RCX: 0000000000462589
> RDX: 0000000020000000 RSI: 000000004028700f RDI: 0000000000000003
> RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 00007f53488976bc
> R13: 00000000004bf67e R14: 00000000006f96e0 R15: 00000000ffffffff
> ==========================================================================
> 
> Signed-off-by: Xuefeng Wang <wxf.wang@hisilicon.com>
> ---
>  drivers/rtc/rtc-lib.c | 1 +
>  1 file changed, 1 insertion(+)
> 
Applied, thanks.

-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

      reply	other threads:[~2019-04-06 13:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-15  3:13 [PATCH] drivers/rtc/rtc-lib.c: check whether tm->tm_year in int32 range Xuefeng Wang
2019-04-06 13:06 ` Alexandre Belloni [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=20190406130630.GB7480@piout.net \
    --to=alexandre.belloni@bootlin.com \
    --cc=a.zummo@towertech.it \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=tanxiaojun@huawei.com \
    --cc=wxf.wang@hisilicon.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;
as well as URLs for NNTP newsgroup(s).