From: Mark Huang <mlhuang@cs.princeton.edu>
Date: Fri, 1 Oct 2004 20:09:49 +0000 (+0000)
Subject: - Fix thinko. Bypass xid checks if socket was created in the root
X-Git-Tag: before-enable-kexec-patch~47
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=5ceb4a1e953e6fa0cea4e694ba0ac7ef11a2ddeb;p=linux-2.6.git

- Fix thinko. Bypass xid checks if socket was created in the root
context, like the freaking comment says.
---

diff --git a/include/net/sock.h b/include/net/sock.h
index a2aba080f..0d3da11ec 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1086,7 +1086,7 @@ static inline int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
 	 * packet.
 	 */
 	if (inet_stream_ops.bind != inet_bind &&
-	    (int) sk->sk_xid >= 0 && sk->sk_xid != skb->xid)
+	    (int) sk->sk_xid > 0 && sk->sk_xid != skb->xid)
 		goto out;
 
 	/* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 7bbe1cb55..70945b48a 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1822,7 +1822,7 @@ process:
 	 * packet.
 	 */
 	if (inet_stream_ops.bind != inet_bind &&
-	    (int) sk->sk_xid >= 0 && sk->sk_xid != skb->xid)
+	    (int) sk->sk_xid > 0 && sk->sk_xid != skb->xid)
 		goto discard_it;
 
 	if (sk->sk_state == TCP_TIME_WAIT)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 5edc92cf8..844a087b0 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -451,7 +451,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,  struct packe
 	sk = pt->af_packet_priv;
 	po = pkt_sk(sk);
 
-	if (sk->sk_xid && sk->sk_xid != skb->xid)
+	if ((int) sk->sk_xid > 0 && sk->sk_xid != skb->xid)
 		goto drop;
 
 	skb->dev = dev;