All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Aleksandr Nogikh <aleksandrnogikh@gmail.com>
Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us,
	davem@davemloft.net, kuba@kernel.org, andreyknvl@google.com,
	dvyukov@google.com, elver@google.com, rdunlap@infradead.org,
	dave.taht@gmail.com, edumazet@google.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Aleksandr Nogikh <nogikh@google.com>,
	syzbot+ec762a6342ad0d3c0d8f@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] netem: fix zero division in tabledist
Date: Wed, 28 Oct 2020 11:19:59 -0700	[thread overview]
Message-ID: <20201028111959.6ed6d2c2@hermes.local> (raw)
In-Reply-To: <20201028170731.1383332-1-aleksandrnogikh@gmail.com>

On Wed, 28 Oct 2020 17:07:31 +0000
Aleksandr Nogikh <aleksandrnogikh@gmail.com> wrote:

> From: Aleksandr Nogikh <nogikh@google.com>
> 
> Currently it is possible to craft a special netlink RTM_NEWQDISC
> command that can result in jitter being equal to 0x80000000. It is
> enough to set the 32 bit jitter to 0x02000000 (it will later be
> multiplied by 2^6) or just set the 64 bit jitter via
> TCA_NETEM_JITTER64. This causes an overflow during the generation of
> uniformly distributed numbers in tabledist(), which in turn leads to
> division by zero (sigma != 0, but sigma * 2 is 0).
> 
> The related fragment of code needs 32-bit division - see commit
> 9b0ed89 ("netem: remove unnecessary 64 bit modulus"), so switching to
> 64 bit is not an option.
> 
> Fix the issue by keeping the value of jitter within the range that can
> be adequately handled by tabledist() - [0;INT_MAX]. As negative std
> deviation makes no sense, take the absolute value of the passed value
> and cap it at INT_MAX. Inside tabledist(), switch to unsigned 32 bit
> arithmetic in order to prevent overflows.
> 
> Signed-off-by: Aleksandr Nogikh <nogikh@google.com>
> Reported-by: syzbot+ec762a6342ad0d3c0d8f@syzkaller.appspotmail.com

Acked-by: Stephen Hemminger <stephen@networkplumber.org>

  reply	other threads:[~2020-10-28 22:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 17:07 [PATCH v2] netem: fix zero division in tabledist Aleksandr Nogikh
2020-10-28 18:19 ` Stephen Hemminger [this message]
2020-10-29 18:46   ` Jakub Kicinski

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=20201028111959.6ed6d2c2@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=aleksandrnogikh@gmail.com \
    --cc=andreyknvl@google.com \
    --cc=dave.taht@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=edumazet@google.com \
    --cc=elver@google.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nogikh@google.com \
    --cc=rdunlap@infradead.org \
    --cc=syzbot+ec762a6342ad0d3c0d8f@syzkaller.appspotmail.com \
    --cc=xiyou.wangcong@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 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.