Handle 'sk' being NULL in UID-based routing.
authorSreeram Ramachandran <sreeram@google.com>
Tue, 8 Jul 2014 18:57:14 +0000 (11:57 -0700)
committerSreeram Ramachandran <sreeram@google.com>
Tue, 8 Jul 2014 18:58:21 +0000 (18:58 +0000)
Bug: 15413527
Change-Id: Iab1fae9da6053b284591628ef1de878761b137b1
Signed-off-by: Sreeram Ramachandran <sreeram@google.com>
include/net/route.h
net/ipv4/route.c

index b5b44875543e86768a7fe110520157077b0c9d22..647bb2adbffd55608afe36e365a90c7c39a9a48f 100644 (file)
@@ -142,7 +142,7 @@ static inline struct rtable *ip_route_output_ports(struct net *net, struct flowi
        flowi4_init_output(fl4, oif, sk ? sk->sk_mark : 0, tos,
                           RT_SCOPE_UNIVERSE, proto,
                           sk ? inet_sk_flowi_flags(sk) : 0,
-                          daddr, saddr, dport, sport, sock_i_uid(sk));
+                          daddr, saddr, dport, sport, sk ? sock_i_uid(sk) : 0);
        if (sk)
                security_sk_classify_flow(sk, flowi4_to_flowi(fl4));
        return ip_route_output_flow(net, fl4, sk);
index ef2fe9d2e9e66f56cdb7f3e3b75b968bebcc76ce..42cd979d16333c1d23ae95c5fe01ee675d5c7ff0 100644 (file)
@@ -517,7 +517,7 @@ static void __build_flow_key(struct flowi4 *fl4, struct sock *sk,
                           RT_SCOPE_UNIVERSE, prot,
                           flow_flags,
                           iph->daddr, iph->saddr, 0, 0,
-                          sock_i_uid(sk));
+                          sk ? sock_i_uid(sk) : 0);
 }
 
 static void build_skb_flow_key(struct flowi4 *fl4, const struct sk_buff *skb,