From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751376AbdFDPG0 (ORCPT ); Sun, 4 Jun 2017 11:06:26 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:48045 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751159AbdFDPGW (ORCPT ); Sun, 4 Jun 2017 11:06:22 -0400 Date: Sun, 4 Jun 2017 17:06:11 +0200 (CEST) From: Thomas Gleixner To: Xishi Qiu cc: LKML , Ingo Molnar , fenghua.yu@intel.com, Peter Zijlstra , John Stultz Subject: Re: [RFC] ubsan: signed integer overflow in setitimer() In-Reply-To: <59300285.6090105@huawei.com> Message-ID: References: <59300285.6090105@huawei.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 1 Jun 2017, Xishi Qiu wrote: Cc'ed John Stultz > Hi, this is the test case, and then I got ubsan error > (signed integer overflow) report, so the root cause is from > user or kernel? Shall we change something in timeval_valid()? > > > struct itimerval new_value; > int ret; > > new_value.it_interval.tv_sec = 140673496649799L; > new_value.it_interval.tv_usec = 6; > new_value.it_value.tv_sec = 140673496649807L; > new_value.it_value.tv_usec = 5; > > ret = setitimer(ITIMER_VIRTUAL, &new_value, NULL); > > > [ 533.326588] ================================================================================ > [ 533.335346] UBSAN: Undefined behaviour in ./include/linux/time.h:239:27 > [ 533.342155] signed integer overflow: > [ 533.345837] 140673496649807 * 1000000000 cannot be represented in type 'long int' > [ 533.422181] set_cpu_itimer+0x49c/0x540 > [ 533.442127] do_setitimer+0xe1/0x540 We need a similar clamping of the conversion as we have for timespec/val_to_ktime(). I'll have a look in the next days unless John beats me to it. Thanks, tglx