Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755268AbcJLMqk (ORCPT ); Wed, 12 Oct 2016 08:46:40 -0400 Received: from mail.kernel.org ([198.145.29.136]:49312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755224AbcJLMqa (ORCPT ); Wed, 12 Oct 2016 08:46:30 -0400 From: lizf@kernel.org To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Konstantin Khlebnikov , "David S. Miller" , Zefan Li Subject: [PATCH 3.4 044/125] net/neighbour: fix crash at dumping device-agnostic proxy entries Date: Wed, 12 Oct 2016 20:32:40 +0800 Message-Id: <1476275641-4697-44-git-send-email-lizf@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476275600-4626-1-git-send-email-lizf@kernel.org> References: <1476275600-4626-1-git-send-email-lizf@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1446 Lines: 44 From: Konstantin Khlebnikov 3.4.113-rc1 review patch. If anyone has any objections, please let me know. ------------------ commit 6adc5fd6a142c6e2c80574c1db0c7c17dedaa42e upstream. Proxy entries could have null pointer to net-device. Signed-off-by: Konstantin Khlebnikov Fixes: 84920c1420e2 ("net: Allow ipv6 proxies and arp proxies be shown with iproute2") Signed-off-by: David S. Miller [lizf: Backported to 3.4: adjust context] Signed-off-by: Zefan Li --- net/core/neighbour.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index ebd4b21..dbd00df 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -2186,7 +2186,7 @@ static int pneigh_fill_info(struct sk_buff *skb, struct pneigh_entry *pn, ndm->ndm_pad2 = 0; ndm->ndm_flags = pn->flags | NTF_PROXY; ndm->ndm_type = NDA_DST; - ndm->ndm_ifindex = pn->dev->ifindex; + ndm->ndm_ifindex = pn->dev ? pn->dev->ifindex : 0; ndm->ndm_state = NUD_NONE; NLA_PUT(skb, NDA_DST, tbl->key_len, pn->key); @@ -2259,7 +2259,7 @@ static int pneigh_dump_table(struct neigh_table *tbl, struct sk_buff *skb, if (h > s_h) s_idx = 0; for (n = tbl->phash_buckets[h], idx = 0; n; n = n->next) { - if (dev_net(n->dev) != net) + if (pneigh_net(n) != net) continue; if (idx < s_idx) goto next; -- 1.9.1