Re: [PATCH] net: geneve: modify IP header check in geneve6_xmit_skb

Eric Dumazet
2021-04-22T16:52:26Z

On Thu, Apr 22, 2021 at 6:04 PM Sabrina Dubroca <sd@queasysnail.net> wrote:
>
> 2021-04-22, 02:39:42 +0200, Florian Westphal wrote:
> > Phillip Potter <phil@philpotter.co.uk> wrote:
> > > Modify the check in geneve6_xmit_skb to use the size of a struct iphdr
> > > rather than struct ipv6hdr. This fixes two kernel selftest failures
> > > introduced by commit 6628ddfec758
> > > ("net: geneve: check skb is large enough for IPv4/IPv6 header"), without
> > > diminishing the fix provided by that commit.
> >
> > What errors?
> >
> > > Reported-by: kernel test robot <oliver.sang@intel.com>
> > > Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
> > > ---
> > > drivers/net/geneve.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
> > > index 42f31c681846..a57a5e6f614f 100644
> > > --- a/drivers/net/geneve.c
> > > +++ b/drivers/net/geneve.c
> > > @@ -988,7 +988,7 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev,
> > > __be16 sport;
> > > int err;
> > >
> > > - if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr)))
> > > + if (!pskb_network_may_pull(skb, sizeof(struct iphdr)))
> > > return -EINVAL;
> >
> > Seems this is papering over some bug, this change makes no sense to
> > me. Can you please explain this?
>
> I'm not sure the original commit (6628ddfec758 ("net: geneve: check
> skb is large enough for IPv4/IPv6 header")) is correct either. GENEVE
> isn't limited to carrying IP, I think an ethernet header with not much
> else on top should be valid.

Maybe, but we still attempt to use ip_hdr() in this case, from
geneve_get_v6_dst()

So there is something fishy.