Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/qeth: fix L3 next-hop in xmit qeth hdr

On L3, the qeth_hdr struct needs to be filled with the next-hop
IP address.
The current code accesses rtable->rt_gateway without checking that
rtable is a valid address. The accidental access to a lowcore area
results in a random next-hop address in the qeth_hdr.
rtable (or more precisely, skb_dst(skb)) can be NULL in rare cases
(for instance together with AF_PACKET sockets).
This patch adds the missing NULL-ptr checks.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Signed-off-by: Ursula Braun <ubraun@linux.vnet.ibm.com>
Fixes: 87e7597b5a3 qeth: Move away from using neighbour entries in qeth_l3_fill_header()
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Julian Wiedmann and committed by
David S. Miller
ec2c6726 c0e0fb83

+2 -2
+2 -2
drivers/s390/net/qeth_l3_main.c
··· 2512 2512 struct rtable *rt = (struct rtable *) dst; 2513 2513 __be32 *pkey = &ip_hdr(skb)->daddr; 2514 2514 2515 - if (rt->rt_gateway) 2515 + if (rt && rt->rt_gateway) 2516 2516 pkey = &rt->rt_gateway; 2517 2517 2518 2518 /* IPv4 */ ··· 2523 2523 struct rt6_info *rt = (struct rt6_info *) dst; 2524 2524 struct in6_addr *pkey = &ipv6_hdr(skb)->daddr; 2525 2525 2526 - if (!ipv6_addr_any(&rt->rt6i_gateway)) 2526 + if (rt && !ipv6_addr_any(&rt->rt6i_gateway)) 2527 2527 pkey = &rt->rt6i_gateway; 2528 2528 2529 2529 /* IPv6 */