mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Xishi Qiu <qiuxishi@huawei.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	fenghua.yu@intel.com, Peter Zijlstra <peterz@infradead.org>,
	John Stultz <john.stultz@linaro.org>
Subject: Re: [RFC] ubsan: signed integer overflow in setitimer()
Date: Sun, 4 Jun 2017 17:06:11 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1706041703500.2813@nanos> (raw)
In-Reply-To: <59300285.6090105@huawei.com>

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

  reply	other threads:[~2017-06-04 15:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-01 12:03 Xishi Qiu
2017-06-04 15:06 ` Thomas Gleixner [this message]
2017-06-06  6:07   ` Xishi Qiu
2017-06-06  7:43     ` Thomas Gleixner

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.20.1706041703500.2813@nanos \
    --to=tglx@linutronix.de \
    --cc=fenghua.yu@intel.com \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=qiuxishi@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®