From: Alan Cox <gnomes@lxorguk.ukuu.org.uk>
To: Andrey Konovalov <andreyknvl@google.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Alan Cox <alan@linux.intel.com>,
Thomas Osterried <thomas@osterried.de>,
Javier Martinez Canillas <javier@osg.samsung.com>,
David Howells <dhowells@redhat.com>,
Geliang Tang <geliangtang@gmail.com>,
netdev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: drivers/net/hamradio: divide error in hdlcdrv_ioctl
Date: Wed, 17 May 2017 21:07:40 +0100 [thread overview]
Message-ID: <20170517210740.20cbbb82@alans-desktop> (raw)
In-Reply-To: <CAAeHK+ya2sAtLmJ0VyP6e=13OXUw98dp1WdRFU=o5+xGFGPtbQ@mail.gmail.com>
On Tue, 16 May 2017 17:05:32 +0200
Andrey Konovalov <andreyknvl@google.com> wrote:
> Hi,
>
> I've got the following error report while fuzzing the kernel with syzkaller.
>
> On commit 2ea659a9ef488125eb46da6eb571de5eae5c43f6 (4.12-rc1).
>
> A reproducer and .config are attached.
This should fix it.
commit 37b3fa4b617681f00cfa1f76d6d7716cc6d9f79a
Author: Alan Cox <alan@llwyncelyn.cymru>
Date: Wed May 17 21:04:27 2017 +0100
hdlcdrv: Fix division by zero when bitrate is unset
The code attempts to check for out of range calibration. What it forgets to do
is check for the 0 bitrate case. As a result the range check itself oopses the
kernel.
Found by Andrey Konovalov using Syzkaller.
Signed-off-by: Alan Cox <alan@linux.intel.com>
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 8c3633c..9f34a48 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -576,7 +576,7 @@ static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
case HDLCDRVCTL_CALIBRATE:
if(!capable(CAP_SYS_RAWIO))
return -EPERM;
- if (bi.data.calibrate > INT_MAX / s->par.bitrate)
+ if (!s->par.bitrate || bi.data.calibrate > INT_MAX / s->par.bitrate)
return -EINVAL;
s->hdlctx.calibrate = bi.data.calibrate * s->par.bitrate / 16;
return 0;
next prev parent reply other threads:[~2017-05-17 20:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-16 15:05 drivers/net/hamradio: divide error in hdlcdrv_ioctl Andrey Konovalov
2017-05-16 15:05 ` Andrey Konovalov
2017-05-17 20:07 ` Alan Cox [this message]
2017-05-19 0:29 ` Andrey Konovalov
2017-05-19 13:21 ` [PATCH v2] hdlcdrv: fix divide error bug if bitrate is 0 Firo Yang
2017-05-19 21:41 ` David Miller
2017-05-26 14:37 ` [PATCH v3] hdlcdrv: Fix divide by zero in hdlcdrv_ioctl Firo Yang
2017-05-27 22:45 ` David Miller
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=20170517210740.20cbbb82@alans-desktop \
--to=gnomes@lxorguk.ukuu.org.uk \
--cc=alan@linux.intel.com \
--cc=andreyknvl@google.com \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=geliangtang@gmail.com \
--cc=javier@osg.samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=thomas@osterried.de \
/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;
as well as URLs for NNTP newsgroup(s).