From: Laura Garcia <nevola@gmail.com>
To: Liping Zhang <zlpnobody@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v2] netfilter: nft_hash: Add hash offset value
Date: Tue, 13 Sep 2016 09:59:32 +0200 [thread overview]
Message-ID: <20160913075931.GA4977@sonyv> (raw)
In-Reply-To: <CAML_gOefwHzNg=PNEPKTpUMxjLZkJQcnQkKchL3Np3vNpA_Ehw@mail.gmail.com>
On Tue, Sep 13, 2016 at 02:25:03PM +0800, Liping Zhang wrote:
> Hi Laura,
>
> 2016-09-06 14:44 GMT+08:00 Laura Garcia Liebana <nevola@gmail.com>:
> > static int nft_hash_init(const struct nft_ctx *ctx,
> > @@ -60,6 +62,11 @@ static int nft_hash_init(const struct nft_ctx *ctx,
> > !tb[NFTA_HASH_MODULUS])
> > return -EINVAL;
> >
> > + if (tb[NFTA_HASH_SUM])
> > + priv->sum = ntohl(nla_get_be32(tb[NFTA_HASH_SUM]));
> > + else
> > + priv->sum = 0;
> > +
> > priv->sreg = nft_parse_register(tb[NFTA_HASH_SREG]);
> > if (priv->sreg < 0)
> > return -ERANGE;
> > @@ -77,6 +84,9 @@ static int nft_hash_init(const struct nft_ctx *ctx,
> > if (priv->modulus <= 1)
> > return -ERANGE;
> >
> > + if (priv->sum + priv->modulus - 1 < U32_MAX)
> > + return -EOVERFLOW;
>
> I think this judgement here is wrong, it is likely to be true...
>
> When two integer a and b do addition operation, and the calculation
> results satisfy the
> following conditions: (a + b < a) or (a + b < b), then we can assure
> that integer overflow
> happened.
>
> So the judgement should be converted to:
> if (priv->sum + priv->modulus - 1 < priv->sum)
>
Absolutely true, i'll send a patch to fix that.
Thank you!
> > +
> > priv->seed = ntohl(nla_get_be32(tb[NFTA_HASH_SEED]));
> >
> > return nft_validate_register_load(priv->sreg, priv->len) &&
prev parent reply other threads:[~2016-09-13 7:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-06 6:44 [PATCH v2] netfilter: nft_hash: Add hash offset value Laura Garcia Liebana
2016-09-12 16:34 ` Pablo Neira Ayuso
2016-09-12 16:57 ` Laura Garcia
2016-09-12 18:31 ` Pablo Neira Ayuso
2016-09-13 6:25 ` Liping Zhang
2016-09-13 7:59 ` Laura Garcia [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=20160913075931.GA4977@sonyv \
--to=nevola@gmail.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=zlpnobody@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;
as well as URLs for NNTP newsgroup(s).