From patchwork Mon Dec 15 19:26:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kamal Mostafa X-Patchwork-Id: 421877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id E2D1814011B; Tue, 16 Dec 2014 22:48:13 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1Y0qbn-00009P-CM; Tue, 16 Dec 2014 11:48:07 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1Y0bMt-0005l9-7K for kernel-team@lists.ubuntu.com; Mon, 15 Dec 2014 19:31:43 +0000 Received: from c-76-102-4-12.hsd1.ca.comcast.net ([76.102.4.12] helo=fourier) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1Y0bIU-0005Ji-GP; Mon, 15 Dec 2014 19:27:10 +0000 Received: from kamal by fourier with local (Exim 4.82) (envelope-from ) id 1Y0bIS-0006jx-O0; Mon, 15 Dec 2014 11:27:08 -0800 From: Kamal Mostafa To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Subject: [PATCH 3.13.y-ckt 60/96] net/ping: handle protocol mismatching scenario Date: Mon, 15 Dec 2014 11:26:20 -0800 Message-Id: <1418671616-25482-61-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418671616-25482-1-git-send-email-kamal@canonical.com> References: <1418671616-25482-1-git-send-email-kamal@canonical.com> X-Extended-Stable: 3.13 X-Mailman-Approved-At: Tue, 16 Dec 2014 11:48:06 +0000 Cc: Hideaki YOSHIFUJI , netdev@vger.kernel.org, Kamal Mostafa , James Morris , "David S. Miller" , Yiwei Zhao , Alexey Kuznetsov , Jane Zhou , Patrick McHardy X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com 3.13.11-ckt13 -stable review patch. If anyone has any objections, please let me know. ------------------ From: Jane Zhou commit 91a0b603469069cdcce4d572b7525ffc9fd352a6 upstream. ping_lookup() may return a wrong sock if sk_buff's and sock's protocols dont' match. For example, sk_buff's protocol is ETH_P_IPV6, but sock's sk_family is AF_INET, in that case, if sk->sk_bound_dev_if is zero, a wrong sock will be returned. the fix is to "continue" the searching, if no matching, return NULL. Cc: "David S. Miller" Cc: Alexey Kuznetsov Cc: James Morris Cc: Hideaki YOSHIFUJI Cc: Patrick McHardy Cc: netdev@vger.kernel.org Signed-off-by: Jane Zhou Signed-off-by: Yiwei Zhao Signed-off-by: David S. Miller Signed-off-by: Kamal Mostafa --- net/ipv4/ping.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 3ef2919..8e0f65c 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -213,6 +213,8 @@ static struct sock *ping_lookup(struct net *net, struct sk_buff *skb, u16 ident) &ipv6_hdr(skb)->daddr)) continue; #endif + } else { + continue; } if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif)