Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp858782pxb; Tue, 1 Feb 2022 11:54:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0EoU122m6lx1lhB6mGs0gJHKYYSW/OPefwT9u7fu1k5Z7sEZ/pvixkj1okf6vuakQaQEs X-Received: by 2002:a50:cdcc:: with SMTP id h12mr26358709edj.107.1643745293627; Tue, 01 Feb 2022 11:54:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745293; cv=none; d=google.com; s=arc-20160816; b=di/NrWE0JWljqW6nazv+bQTwKJhN+5/0kZVP2pnq8NIPChpRMDDQZGyrx/pOHU2zZ5 MyBFJvWLdqRq+LY2fHgDv+9h9j/C47pUe5XGQBH7k4nT6vcAGXKDZeopkRpDYYzS2Ryd H7B7cqE66AVvj/0r5LcdX/niow3mRsL28eJukz3stkRPomZtOaRf1OPhLgRRd+XDBzvN ysosZAVABloHLQBvWRBGqvdv+z5EpuLp7zqRk713D5lEEWwbZVyQj92qwx4QfQWYXw5+ EqXYLe2PVQWj5Fb6eN4BPzl2nVpFa9fS4x2186VhOxjub0tbEoyp4MYtV7IhQiFH94Ld m6tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VOqK+RLpz+GurirXHgMn7rvVGgNuMslrlILtY7m6C1k=; b=bKQZTRPy1oOUdmOAT3Uox7Emw8BtOumumtHKUDclkvJTv+mD44n/Vcxj+b9//2l+Ed aYETQArZcgCP/lypbj+LmJ6P9V84B0rJOqm/zArcF+9odot2rOifhw+PIhlckBs+5h3g 3jR0ajwibBVRkwiDiXIsoxP41GLzci9HuhkHdLQ3eds2WFewdRRid7j4JLRCMi7t9WMv X+X6cHMvGO0moY1D+J5mg0VDhkqPhM6jFRZcWZ8PsNeRJY70DrDO2pyWzl6FpND4Vrg1 CLQPhMioo1REVycxvAZUxFaYsoicgKSGk7JNNRtT6bHDaNeovnWgy5PvE5+wRvB88Ou1 TpbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XotECHmP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m10si11329325edd.152.2022.02.01.11.54.28; Tue, 01 Feb 2022 11:54:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XotECHmP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359220AbiAaLEp (ORCPT + 99 others); Mon, 31 Jan 2022 06:04:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358449AbiAaLCW (ORCPT ); Mon, 31 Jan 2022 06:02:22 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B613C061769; Mon, 31 Jan 2022 03:00:36 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 08196B82A5F; Mon, 31 Jan 2022 11:00:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6370EC340E8; Mon, 31 Jan 2022 11:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643626833; bh=pprbZsg+C92F/5sdWdHZshcc/eOL9hMtUXknEI2V4gg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XotECHmPjk9O0L5lvD/cEr/tH6iE418LtXaPGdAdsxzokpA+NWo4zBpW8mq6E67x+ ycDuBTikh0v3hWZrAkEC0KPqh1Iz3KtX7IqUwuf7JDtRcB941wYT9qwWWaT2Xi4M1L 6/emaA0T9OCkwh4ZohjQz7WtFU4l+1D9F7dgIWmg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangbin Liu , Xin Long , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 37/64] ping: fix the sk_bound_dev_if match in ping_lookup Date: Mon, 31 Jan 2022 11:56:22 +0100 Message-Id: <20220131105216.930543828@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105215.644174521@linuxfoundation.org> References: <20220131105215.644174521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xin Long commit 2afc3b5a31f9edf3ef0f374f5d70610c79c93a42 upstream. When 'ping' changes to use PING socket instead of RAW socket by: # sysctl -w net.ipv4.ping_group_range="0 100" the selftests 'router_broadcast.sh' will fail, as such command # ip vrf exec vrf-h1 ping -I veth0 198.51.100.255 -b can't receive the response skb by the PING socket. It's caused by mismatch of sk_bound_dev_if and dif in ping_rcv() when looking up the PING socket, as dif is vrf-h1 if dif's master was set to vrf-h1. This patch is to fix this regression by also checking the sk_bound_dev_if against sdif so that the packets can stil be received even if the socket is not bound to the vrf device but to the real iif. Fixes: c319b4d76b9e ("net: ipv4: add IPPROTO_ICMP socket kind") Reported-by: Hangbin Liu Signed-off-by: Xin Long Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- net/ipv4/ping.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -220,7 +220,8 @@ static struct sock *ping_lookup(struct n continue; } - if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif) + if (sk->sk_bound_dev_if && sk->sk_bound_dev_if != dif && + sk->sk_bound_dev_if != inet_sdif(skb)) continue; sock_hold(sk);