From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D03EC282DA for ; Sat, 6 Apr 2019 13:06:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EA2882146F for ; Sat, 6 Apr 2019 13:06:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726535AbfDFNGf (ORCPT ); Sat, 6 Apr 2019 09:06:35 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:50429 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726404AbfDFNGf (ORCPT ); Sat, 6 Apr 2019 09:06:35 -0400 X-Originating-IP: 86.202.231.219 Received: from localhost (lfbn-lyo-1-149-219.w86-202.abo.wanadoo.fr [86.202.231.219]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 0591D20008; Sat, 6 Apr 2019 13:06:30 +0000 (UTC) Date: Sat, 6 Apr 2019 15:06:30 +0200 From: Alexandre Belloni To: Xuefeng Wang 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 Message-ID: <20190406130630.GB7480@piout.net> References: <1550200439-62533-1-git-send-email-wxf.wang@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1550200439-62533-1-git-send-email-wxf.wang@hisilicon.com> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > drivers/rtc/rtc-lib.c | 1 + > 1 file changed, 1 insertion(+) > Applied, thanks. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com