From: Andrew Morton <akpm@linux-foundation.org>
To: xqx12 <s2exqx@gmail.com>
Cc: giometti@enneenne.com, linux-kernel@vger.kernel.org,
chyyuu@gmail.com, xuyongjiande@gmail.com,
xqx12 <xiaoqixue_1@163.com>
Subject: Re: [PATCH] a multiplication overflow in drivers/pps/pps.c
Date: Thu, 19 Dec 2013 16:37:36 -0800 [thread overview]
Message-ID: <20131219163736.56144b5368be511af2df5a73@linux-foundation.org> (raw)
In-Reply-To: <1387352171-3811-1-git-send-email-xiaoqixue_1@163.com>
On Wed, 18 Dec 2013 15:36:11 +0800 xqx12 <s2exqx@gmail.com> wrote:
> there is an overflow in the following code :
>
> ticks = fdata.timeout.sec * HZ;
>
> while ticks is a signed 64-bit, but the result of fdata.timeout.sec *
> HZ will be converted be 32-bit first. So ticks will be a wrong value
> after multiplication overflow.
When fixing a bug, please always include a full description of the
user-visible effects of that bug. This helps others decide which
kernel version(s) should be fixed.
> ...
>
> --- a/drivers/pps/pps.c
> +++ b/drivers/pps/pps.c
> @@ -164,7 +164,7 @@ static long pps_cdev_ioctl(struct file *file,
> dev_dbg(pps->dev, "timeout %lld.%09d\n",
> (long long) fdata.timeout.sec,
> fdata.timeout.nsec);
> - ticks = fdata.timeout.sec * HZ;
> + ticks = (s64)(fdata.timeout.sec) * HZ;
> ticks += fdata.timeout.nsec / (NSEC_PER_SEC / HZ);
>
> if (ticks != 0) {
pps_fdata.timeout.sec has type __s64, so the patch should be a no-op?
Did you really observe a runtime problem from this? If so, I suspect
your compiler is busted.
prev parent reply other threads:[~2013-12-20 0:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-18 7:36 xqx12
2013-12-20 0:37 ` Andrew Morton [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=20131219163736.56144b5368be511af2df5a73@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=chyyuu@gmail.com \
--cc=giometti@enneenne.com \
--cc=linux-kernel@vger.kernel.org \
--cc=s2exqx@gmail.com \
--cc=xiaoqixue_1@163.com \
--cc=xuyongjiande@gmail.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®