lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 23 May 2023 16:41:27 +0200
From: Simon Horman <simon.horman@...igine.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Jakub Kicinski <kuba@...nel.org>,
	"David S . Miller" <davem@...emloft.net>,
	Paolo Abeni <pabeni@...hat.com>,
	Alexander Aring <alex.aring@...il.com>, netdev@...r.kernel.org,
	eric.dumazet@...il.com
Subject: Re: [PATCH net 1/3] ipv6: exthdrs: fix potential use-after-free in
 ipv6_rpl_srh_rcv()

On Tue, May 23, 2023 at 12:45:34PM +0200, Eric Dumazet wrote:
> On Tue, May 23, 2023 at 10:47 AM Simon Horman <simon.horman@...igine.com> wrote:
> >
> > On Mon, May 22, 2023 at 01:00:50PM -0700, Jakub Kicinski wrote:
> > > On Sun, 21 May 2023 20:22:16 +0200 Eric Dumazet wrote:
> > > > On Thu, May 18, 2023 at 7:05 PM Simon Horman <simon.horman@...igine.com> wrote:
> > > > > Not far below this line there is a call to pskb_pull():
> > > > >
> > > > >                 if (hdr->nexthdr == NEXTHDR_IPV6) {
> > > > >                         int offset = (hdr->hdrlen + 1) << 3;
> > > > >
> > > > >                         skb_postpull_rcsum(skb, skb_network_header(skb),
> > > > >                                            skb_network_header_len(skb));
> > > > >
> > > > >                         if (!pskb_pull(skb, offset)) {
> > > > >                                 kfree_skb(skb);
> > > > >                                 return -1;
> > > > >                         }
> > > > >                         skb_postpull_rcsum(skb, skb_transport_header(skb),
> > > > >                                            offset);
> > > > >
> > > > > Should hdr be reloaded after the call to pskb_pull() too?
> > > >
> > > > I do not think so, because @hdr is not used between this pskb_pull()
> > > > and the return -1:
> > > >
> > > >        if (hdr->nexthdr == NEXTHDR_IPV6) {
> > > >             int offset = (hdr->hdrlen + 1) << 3;
> > > >
> > > >             skb_postpull_rcsum(skb, skb_network_header(skb),
> > > >                        skb_network_header_len(skb));
> > > >
> > > >             if (!pskb_pull(skb, offset)) {
> > > >                 kfree_skb(skb);
> > > >                 return -1;
> > > >             }
> > > >             skb_postpull_rcsum(skb, skb_transport_header(skb),
> > > >                        offset);
> > > >
> > > >             skb_reset_network_header(skb);
> > > >             skb_reset_transport_header(skb);
> > > >             skb->encapsulation = 0;
> > > >
> > > >             __skb_tunnel_rx(skb, skb->dev, net);
> > > >
> > > >             netif_rx(skb);
> > > >             return -1;
> > > >         }
> > >
> > > Hum, there's very similar code in ipv6_srh_rcv() (a different function
> > > but with a very similar name) which calls pskb_pull() and then checks
> > > if hdr->nexthdr is v4. I'm guessing that's the one Simon was referring
> > > to.
> >
> > Yes, that does seem to be the case.
> 
> I think ipv6_srh_rcv() is fine.
> 
> The "goto looped_back" does not need to reload hdr.
> 
> The only point where skb->head can change is at the pskb_expand_head() call,
> which is properly followed by:
> 
> hdr = (struct ipv6_sr_hdr *)skb_transport_header(skb);
> 
> I will send a V2, because this first patch in the series can also make
> ipv6_rpl_srh_rcv() similar.
> (No need to move around the pskb_may_pull(skb, sizeof(*hdr)
> 

Hi Eric,

Thanks for the analysis.
And sorry for the noise on this one.



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ