From: Florian Westphal <fw@strlen.de>
To: Visa Hankala <visa@hankala.org>
Cc: Florian Westphal <fw@strlen.de>,
Steffen Klassert <steffen.klassert@secunet.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: Re: [PATCH] xfrm: Fix wraparound in xfrm_policy_addr_delta()
Date: Tue, 29 Dec 2020 17:01:27 +0100 [thread overview]
Message-ID: <20201229160127.GA30823@breakpoint.cc> (raw)
In-Reply-To: <20201229145009.cGOUak0JdKIIgGAv@hankala.org>
Visa Hankala <visa@hankala.org> wrote:
> Use three-way comparison for address elements to avoid integer
> wraparound in the result of xfrm_policy_addr_delta().
>
> This ensures that the search trees are built and traversed correctly
> when the difference between compared address elements is larger
> than INT_MAX.
Please provide an update to tools/testing/selftests/net/xfrm_policy.sh
that shows that this is a problem.
> switch (family) {
> case AF_INET:
> - if (sizeof(long) == 4 && prefixlen == 0)
> - return ntohl(a->a4) - ntohl(b->a4);
> - return (ntohl(a->a4) & ((~0UL << (32 - prefixlen)))) -
> - (ntohl(b->a4) & ((~0UL << (32 - prefixlen))));
> + mask = ~0U << (32 - prefixlen);
> + ma = ntohl(a->a4) & mask;
> + mb = ntohl(b->a4) & mask;
This is suspicious. Is prefixlen == 0 impossible?
If not, then after patch
mask = ~0U << 32;
... and function returns 0.
next prev parent reply other threads:[~2020-12-29 16:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-29 14:58 [PATCH] xfrm: Fix wraparound in xfrm_policy_addr_delta() Visa Hankala
2020-12-29 16:01 ` Florian Westphal [this message]
2020-12-30 12:06 ` Visa Hankala
2020-12-30 12:46 ` Florian Westphal
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=20201229160127.GA30823@breakpoint.cc \
--to=fw@strlen.de \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=visa@hankala.org \
/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.