mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anirudh Gupta <anirudhrudr@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Steffen Klassert <steffen.klassert@secunet.com>,
	Anirudh Gupta <anirudh.gupta@sophos.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] xfrm: Fix xfrm sel prefix length validation
Date: Mon, 20 May 2019 22:35:24 +0530	[thread overview]
Message-ID: <CAN2cbVc3bbEcDB87S4UpySnMtC7oi40bWPK8bd4wW_nv5qEDJg@mail.gmail.com> (raw)
In-Reply-To: <20190520153219.oq3se5wvkasgbtkp@gondor.apana.org.au>

Hi Herbert,
Yes, I notice that is the only verification of p->family from userspace.
However, the underlying conditions added in commit '07bf7908950a',
validates the selector src/dest prefix len.

So, In case when adding a new SA entry, the family of Selector src/dst
is IPv6 and state id src/dst family is IPv4.
Then, the IPv6 selector prefix verification falls in IPv4 switch case.
This results in not being able to provide prefix length of more than
32, even for IPv6 src/dst.

The above mentioned behaviour can easily be reproduced using below
command having IPv6 selector src/dst with greater than 32 prefix
length.
ip xfrm state add src 1.1.6.1 dst 1.1.6.2 proto esp spi 4260196 \
reqid 20004 mode tunnel aead "rfc4106(gcm(aes))" \
0x1111016400000000000000000000000044440001 128 \
sel src 1011:1:4::2/128 sel dst 1021:1:4::2/128 dev Port5

Please let me know, if I fail to explain my point or I am overlooking anything.

Thanks & Regards,
Anirudh


On Mon, May 20, 2019 at 9:02 PM Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Mon, May 20, 2019 at 03:01:56PM +0530, Anirudh Gupta wrote:
> >
> > diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
> > index eb8d14389601..fc2a8c08091b 100644
> > --- a/net/xfrm/xfrm_user.c
> > +++ b/net/xfrm/xfrm_user.c
> > @@ -149,7 +149,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
> >       int err;
> >
> >       err = -EINVAL;
> > -     switch (p->family) {
> > +     switch (p->sel.family) {
> >       case AF_INET:
> >               if (p->sel.prefixlen_d > 32 || p->sel.prefixlen_s > 32)
> >                       goto out;
>
> You just removed the only verification of p->family...
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt



-- 
Regards

Anirudh Gupta

  reply	other threads:[~2019-05-20 17:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20  9:31 Anirudh Gupta
2019-05-20 15:32 ` Herbert Xu
2019-05-20 17:05   ` Anirudh Gupta [this message]
     [not found]   ` <CAN2cbVe3WNj8cR1dLysCP46-LwiHZYMWRpowA+bzNpyZRexSaA@mail.gmail.com>
2019-05-21  2:49     ` Herbert Xu
2019-05-21  8:22 Anirudh Gupta
2019-05-21 12:22 ` Herbert Xu
2019-05-21 15:29 Anirudh Gupta
2019-05-22  3:17 ` Herbert Xu
2019-05-28  7:44   ` Steffen Klassert

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=CAN2cbVc3bbEcDB87S4UpySnMtC7oi40bWPK8bd4wW_nv5qEDJg@mail.gmail.com \
    --to=anirudhrudr@gmail.com \
    --cc=anirudh.gupta@sophos.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.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

all inboxes | Powered by JetHome®