* Possible NULL dereference caused by -stable commit ef81bb40bf15f350fe865f31fa42f1082772a576
@ 2011-09-28 10:51 Jason Wang
2011-09-28 12:09 ` Eric Dumazet
0 siblings, 1 reply; 4+ messages in thread
From: Jason Wang @ 2011-09-28 10:51 UTC (permalink / raw)
To: netdev, eric.dumazet, David S. Miller, linux-kernel, Greg KH,
stable
Cc: Michael S. Tsirkin, Amos Kong
Hi all:
A possible NULL dereference were noticed by the stable commit
ef81bb40bf15f350fe865f31fa42f1082772a576 (which is a backport of
87c48fa3b4630905f98268dde838ee43626a060c). The case happens when bridge
froward a packet from guest to a physical nic, at this time no route is
attached to the skb which may lead a NULL dereference in
ipv6_select_ident(). -Next version have this check so it is fine. The
following patch may be used to avoid this but may also lead the ip
identification predicable, and this defect is also exist -next version
when no route because we still depends on a global variable to generate
the identification. Any thought on this?
Thanks.
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 4ea6e21..414e2f4 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -622,7 +622,9 @@ static u32 __ipv6_select_ident(const struct in6_addr
*addr)
void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
{
- fhdr->identification =
htonl(__ipv6_select_ident(&rt->rt6i_dst.addr));
+ const struct in6_addr addr = IN6ADDR_ANY_INIT;
+ fhdr->identification =
+ htonl(__ipv6_select_ident(rt ? &rt->rt6i_dst.addr : &addr));
}
int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: Possible NULL dereference caused by -stable commit ef81bb40bf15f350fe865f31fa42f1082772a576
2011-09-28 10:51 Possible NULL dereference caused by -stable commit ef81bb40bf15f350fe865f31fa42f1082772a576 Jason Wang
@ 2011-09-28 12:09 ` Eric Dumazet
2011-09-28 17:12 ` David Miller
2011-09-28 18:32 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2011-09-28 12:09 UTC (permalink / raw)
To: Jason Wang
Cc: netdev, David S. Miller, linux-kernel, Greg KH, stable,
Michael S. Tsirkin, Amos Kong
Le mercredi 28 septembre 2011 à 18:51 +0800, Jason Wang a écrit :
> Hi all:
>
> A possible NULL dereference were noticed by the stable commit
> ef81bb40bf15f350fe865f31fa42f1082772a576 (which is a backport of
> 87c48fa3b4630905f98268dde838ee43626a060c). The case happens when bridge
> froward a packet from guest to a physical nic, at this time no route is
> attached to the skb which may lead a NULL dereference in
> ipv6_select_ident(). -Next version have this check so it is fine. The
> following patch may be used to avoid this but may also lead the ip
> identification predicable, and this defect is also exist -next version
> when no route because we still depends on a global variable to generate
> the identification. Any thought on this?
1) Discussion on current kernel :
All we need here is not the route but inet_peer, so that inet_getid()
can be called on it.
If no route is given to ipv6_select_ident(), at least we can try to get
inet_peer, and release it before exiting from ipv6_select_ident()
2) On stable kernel, we already use an array
(ipv6_fragmentation_id[FID_HASH_SZ];) to make less predictables
fragments ids.
So we could get dst addr from the packet to be forwarded instead of the
(possibly NULL) route.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Possible NULL dereference caused by -stable commit ef81bb40bf15f350fe865f31fa42f1082772a576
2011-09-28 12:09 ` Eric Dumazet
@ 2011-09-28 17:12 ` David Miller
2011-09-28 18:32 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2011-09-28 17:12 UTC (permalink / raw)
To: eric.dumazet; +Cc: jasowang, netdev, linux-kernel, gregkh, stable, mst, akong
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 28 Sep 2011 14:09:09 +0200
> All we need here is not the route but inet_peer, so that inet_getid()
> can be called on it.
It's not exactly that simple, you have to parse all hop-by-hop options
to get the correct "destination" address.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Possible NULL dereference caused by -stable commit ef81bb40bf15f350fe865f31fa42f1082772a576
2011-09-28 12:09 ` Eric Dumazet
2011-09-28 17:12 ` David Miller
@ 2011-09-28 18:32 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2011-09-28 18:32 UTC (permalink / raw)
To: eric.dumazet; +Cc: jasowang, netdev, linux-kernel, gregkh, stable, mst, akong
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 28 Sep 2011 14:09:09 +0200
> 1) Discussion on current kernel :
>
> All we need here is not the route but inet_peer, so that inet_getid()
> can be called on it.
>
> If no route is given to ipv6_select_ident(), at least we can try to get
> inet_peer, and release it before exiting from ipv6_select_ident()
Ok, after some auditing, there is only one call site of ipv6_select_ident()
that can happen with a NULL route and that is udp6_ufo_fragment().
ipv6_gso_segment() already walks the extension headers via
ipv6_gso_pull_exthdrs() so maybe we can calculate the true destination
address there and get that passed down somehow into the fragment ID
selection for an inetpeer lookup.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-09-28 18:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-28 10:51 Possible NULL dereference caused by -stable commit ef81bb40bf15f350fe865f31fa42f1082772a576 Jason Wang
2011-09-28 12:09 ` Eric Dumazet
2011-09-28 17:12 ` David Miller
2011-09-28 18:32 ` David Miller
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).