Message ID | 187e9624fed68512970e337a98fc7f07487150cf.1519680601.git.joseph.salisbury@canonical.com |
---|---|
State | New |
Headers | show |
Series | [SRU,Xenial,1/1] s390/qeth: fix L3 next-hop in xmit qeth hdr | expand |
On 2018-03-01 14:01:53 , Joseph Salisbury wrote: > From: Julian Wiedmann <jwi@linux.vnet.ibm.com> > > BugLink: http://bugs.launchpad.net/bugs/1750813 > > 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> > (cherry picked from commit ec2c6726322f0d270bab477e4904bf9496f70ee5) > Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com> > --- > drivers/s390/net/qeth_l3_main.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c > index bf3c1b2..84774c3 100644 > --- a/drivers/s390/net/qeth_l3_main.c > +++ b/drivers/s390/net/qeth_l3_main.c > @@ -2727,7 +2727,7 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, > struct rtable *rt = (struct rtable *) dst; > __be32 *pkey = &ip_hdr(skb)->daddr; > > - if (rt->rt_gateway) > + if (rt && rt->rt_gateway) > pkey = &rt->rt_gateway; > > /* IPv4 */ > @@ -2738,7 +2738,7 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, > struct rt6_info *rt = (struct rt6_info *) dst; > struct in6_addr *pkey = &ipv6_hdr(skb)->daddr; > > - if (!ipv6_addr_any(&rt->rt6i_gateway)) > + if (rt && !ipv6_addr_any(&rt->rt6i_gateway)) > pkey = &rt->rt6i_gateway; > > /* IPv6 */ > -- > 2.7.4 > > Acked-by: Khalid Elmously <khalid.elmously@canonical.com>
On 03/01/18 20:01, Joseph Salisbury wrote: > From: Julian Wiedmann <jwi@linux.vnet.ibm.com> > > BugLink: http://bugs.launchpad.net/bugs/1750813 > > 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> > (cherry picked from commit ec2c6726322f0d270bab477e4904bf9496f70ee5) > Signed-off-by: Joseph Salisbury <joseph.salisbury@canonical.com> > --- > drivers/s390/net/qeth_l3_main.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c > index bf3c1b2..84774c3 100644 > --- a/drivers/s390/net/qeth_l3_main.c > +++ b/drivers/s390/net/qeth_l3_main.c > @@ -2727,7 +2727,7 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, > struct rtable *rt = (struct rtable *) dst; > __be32 *pkey = &ip_hdr(skb)->daddr; > > - if (rt->rt_gateway) > + if (rt && rt->rt_gateway) > pkey = &rt->rt_gateway; > > /* IPv4 */ > @@ -2738,7 +2738,7 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, > struct rt6_info *rt = (struct rt6_info *) dst; > struct in6_addr *pkey = &ipv6_hdr(skb)->daddr; > > - if (!ipv6_addr_any(&rt->rt6i_gateway)) > + if (rt && !ipv6_addr_any(&rt->rt6i_gateway)) > pkey = &rt->rt6i_gateway; > > /* IPv6 */ > Scope limited to an architecture specific driver, tested by the vendor. Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index bf3c1b2..84774c3 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -2727,7 +2727,7 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, struct rtable *rt = (struct rtable *) dst; __be32 *pkey = &ip_hdr(skb)->daddr; - if (rt->rt_gateway) + if (rt && rt->rt_gateway) pkey = &rt->rt_gateway; /* IPv4 */ @@ -2738,7 +2738,7 @@ static void qeth_l3_fill_header(struct qeth_card *card, struct qeth_hdr *hdr, struct rt6_info *rt = (struct rt6_info *) dst; struct in6_addr *pkey = &ipv6_hdr(skb)->daddr; - if (!ipv6_addr_any(&rt->rt6i_gateway)) + if (rt && !ipv6_addr_any(&rt->rt6i_gateway)) pkey = &rt->rt6i_gateway; /* IPv6 */