* [[PATCH v1]] hdlcdrv: fix divide error bug if bitrate is 0
@ 2017-05-18 4:02 Firo Yang
2017-05-19 0:31 ` Andrey Konovalov
0 siblings, 1 reply; 2+ messages in thread
From: Firo Yang @ 2017-05-18 4:02 UTC (permalink / raw)
To: t.sailer, wharms
Cc: linux-hams, netdev, dvyukov, syzkaller, davem, gregkh, Firo Yang
The divisor s->par.bitrate will always be 0 until initialized by
ndo_open() and hdlcdrv_open().
In order to fix this divide zero error, check whether the netdevice was
opened by ndo_open() before performing divide.And we also check the the
value of bitrate in case of bad setting of it.
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Firo Yang <firogm@gmail.com>
---
v0->v1:
Reviewed by walter harms <wharms@bfs.de>.
Return ENODEV instead of EPERM if !netif_running(dev)
Check if s->par.bitrate > 0.
drivers/net/hamradio/hdlcdrv.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
index 8c3633c..b0f417f 100644
--- a/drivers/net/hamradio/hdlcdrv.c
+++ b/drivers/net/hamradio/hdlcdrv.c
@@ -576,6 +576,10 @@ static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
case HDLCDRVCTL_CALIBRATE:
if(!capable(CAP_SYS_RAWIO))
return -EPERM;
+ if (!netif_running(dev))
+ return -ENODEV;
+ if (!(s->par.bitrate > 0))
+ return -EINVAL;
if (bi.data.calibrate > INT_MAX / s->par.bitrate)
return -EINVAL;
s->hdlctx.calibrate = bi.data.calibrate * s->par.bitrate / 16;
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [[PATCH v1]] hdlcdrv: fix divide error bug if bitrate is 0
2017-05-18 4:02 [[PATCH v1]] hdlcdrv: fix divide error bug if bitrate is 0 Firo Yang
@ 2017-05-19 0:31 ` Andrey Konovalov
0 siblings, 0 replies; 2+ messages in thread
From: Andrey Konovalov @ 2017-05-19 0:31 UTC (permalink / raw)
To: Firo Yang
Cc: t.sailer, wharms, linux-hams, netdev, Dmitry Vyukov, syzkaller,
David S. Miller, Greg Kroah-Hartman
On Thu, May 18, 2017 at 6:02 AM, Firo Yang <firogm@gmail.com> wrote:
> The divisor s->par.bitrate will always be 0 until initialized by
> ndo_open() and hdlcdrv_open().
>
> In order to fix this divide zero error, check whether the netdevice was
> opened by ndo_open() before performing divide.And we also check the the
> value of bitrate in case of bad setting of it.
>
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Signed-off-by: Firo Yang <firogm@gmail.com>
Hi Firo,
Please reply to the original report thread when you send a fix, so
other people won't start working on the same patch.
BTW, it was reported by me, but I don't think it's important.
Thanks!
> ---
> v0->v1:
> Reviewed by walter harms <wharms@bfs.de>.
> Return ENODEV instead of EPERM if !netif_running(dev)
> Check if s->par.bitrate > 0.
>
> drivers/net/hamradio/hdlcdrv.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
> index 8c3633c..b0f417f 100644
> --- a/drivers/net/hamradio/hdlcdrv.c
> +++ b/drivers/net/hamradio/hdlcdrv.c
> @@ -576,6 +576,10 @@ static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
> case HDLCDRVCTL_CALIBRATE:
> if(!capable(CAP_SYS_RAWIO))
> return -EPERM;
> + if (!netif_running(dev))
> + return -ENODEV;
> + if (!(s->par.bitrate > 0))
> + return -EINVAL;
> if (bi.data.calibrate > INT_MAX / s->par.bitrate)
> return -EINVAL;
> s->hdlctx.calibrate = bi.data.calibrate * s->par.bitrate / 16;
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-05-19 0:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-18 4:02 [[PATCH v1]] hdlcdrv: fix divide error bug if bitrate is 0 Firo Yang
2017-05-19 0:31 ` Andrey Konovalov
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.