From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
"Ardelean, Alexandru" <alexandru.Ardelean@analog.com>,
"lars@metafoo.de" <lars@metafoo.de>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"Popa, Stefan Serban" <StefanSerban.Popa@analog.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Hennerich, Michael" <Michael.Hennerich@analog.com>,
"pmeerw@pmeerw.net" <pmeerw@pmeerw.net>,
"knaack.h@gmx.de" <knaack.h@gmx.de>
Subject: Re: [PATCH] iio: imu: adis16480: clean up a condition
Date: Mon, 07 Oct 2019 09:21:07 +0000 [thread overview]
Message-ID: <20191007102107.000067b6@huawei.com> (raw)
In-Reply-To: <20191006181439.GU22609@kadam>
On Sun, 6 Oct 2019 21:14:40 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Sun, Oct 06, 2019 at 09:51:33AM +0100, Jonathan Cameron wrote:
> > On Thu, 26 Sep 2019 14:36:30 +0300
> > Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > > On Thu, Sep 26, 2019 at 11:06:39AM +0000, Ardelean, Alexandru wrote:
> > > > On Thu, 2019-09-26 at 11:10 +0300, Dan Carpenter wrote:
> > > > > [External]
> > > > >
> > > > > The "t" variable is unsigned so it can't be less than zero. We really
> > > > > are just trying to prevent divide by zero bugs so just checking against
> > > > > zero is sufficient.
> >
> > I'm not sure that true. It if were signed we'd be detecting that the
> > input from userspace was negative.
>
> It does a really bad job of that though so it raises more questions than
> answers. Maybe just one of the parameters is negative or maybe the
> multiply or the addition overflowed? Should scenarios those be checked?
>
> It turns out none of those situations matter, only divide by zero needs
> to be checked.
It isn't being nearly paranoid enough. Either val or val2 being
negative is a reason to fault out. Divide by zero needs handling after
that. Obviously divide by zero is the only one that causes a crash but
negatives are going to cause rather 'unexpected' results.
What fun.
Jonathan
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jonathan.cameron@huawei.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
"Ardelean, Alexandru" <alexandru.Ardelean@analog.com>,
"lars@metafoo.de" <lars@metafoo.de>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"Popa, Stefan Serban" <StefanSerban.Popa@analog.com>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Hennerich, Michael" <Michael.Hennerich@analog.com>,
"pmeerw@pmeerw.net" <pmeerw@pmeerw.net>,
"knaack.h@gmx.de" <knaack.h@gmx.de>
Subject: Re: [PATCH] iio: imu: adis16480: clean up a condition
Date: Mon, 7 Oct 2019 10:21:07 +0100 [thread overview]
Message-ID: <20191007102107.000067b6@huawei.com> (raw)
In-Reply-To: <20191006181439.GU22609@kadam>
On Sun, 6 Oct 2019 21:14:40 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Sun, Oct 06, 2019 at 09:51:33AM +0100, Jonathan Cameron wrote:
> > On Thu, 26 Sep 2019 14:36:30 +0300
> > Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > > On Thu, Sep 26, 2019 at 11:06:39AM +0000, Ardelean, Alexandru wrote:
> > > > On Thu, 2019-09-26 at 11:10 +0300, Dan Carpenter wrote:
> > > > > [External]
> > > > >
> > > > > The "t" variable is unsigned so it can't be less than zero. We really
> > > > > are just trying to prevent divide by zero bugs so just checking against
> > > > > zero is sufficient.
> >
> > I'm not sure that true. It if were signed we'd be detecting that the
> > input from userspace was negative.
>
> It does a really bad job of that though so it raises more questions than
> answers. Maybe just one of the parameters is negative or maybe the
> multiply or the addition overflowed? Should scenarios those be checked?
>
> It turns out none of those situations matter, only divide by zero needs
> to be checked.
It isn't being nearly paranoid enough. Either val or val2 being
negative is a reason to fault out. Divide by zero needs handling after
that. Obviously divide by zero is the only one that causes a crash but
negatives are going to cause rather 'unexpected' results.
What fun.
Jonathan
next prev parent reply other threads:[~2019-10-07 9:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-26 8:10 [PATCH] iio: imu: adis16480: clean up a condition Dan Carpenter
2019-09-26 8:10 ` Dan Carpenter
2019-09-26 11:06 ` Ardelean, Alexandru
2019-09-26 11:06 ` Ardelean, Alexandru
2019-09-26 11:36 ` Dan Carpenter
2019-09-26 11:36 ` Dan Carpenter
2019-10-06 8:51 ` Jonathan Cameron
2019-10-06 8:51 ` Jonathan Cameron
2019-10-06 18:14 ` Dan Carpenter
2019-10-06 18:14 ` Dan Carpenter
2019-10-07 9:21 ` Jonathan Cameron [this message]
2019-10-07 9:21 ` Jonathan Cameron
2019-10-07 14:18 ` Dan Carpenter
2019-10-07 14:18 ` Dan Carpenter
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=20191007102107.000067b6@huawei.com \
--to=jonathan.cameron@huawei.com \
--cc=Michael.Hennerich@analog.com \
--cc=StefanSerban.Popa@analog.com \
--cc=alexandru.Ardelean@analog.com \
--cc=dan.carpenter@oracle.com \
--cc=jic23@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.