Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3862741pxv; Mon, 28 Jun 2021 15:02:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySn4KhA3cA2vwKZ5Ui91/mir88DunZBxCbrrSsuWE0LQ24kdElQ76IzaArwOqz4Zk6INF1 X-Received: by 2002:a05:6402:100e:: with SMTP id c14mr35071723edu.51.1624917771020; Mon, 28 Jun 2021 15:02:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624917771; cv=none; d=google.com; s=arc-20160816; b=PqDJe9tjB3pFTCCmHLEtkzyR5UbK/bjWwFlN2TWDVZPQym7HSlJNKDbwUpkyfuo5nJ 0FCCap2CKcL7FvFDjWuA1ugxAjW5SIf+GR1Zz0Hwp8hSTB8lLU/U37arWIhHFV4fQGeU 2k5v9BLgZ+qnJk7tO5zSnQ5idMgJiFGUi1xWGKAECRQio7QX75jMm6kdl7uNSe231bZb kJagP0CCI8YYmiyrXjuAxNGqKFjVGfoCufUnCKxpS9xVAA7ixtuFmQCeXUwrk7Vu4vIP weHpXT4espAPhRPNjbyms3pLs8sp/nBB8CoR0EEFDWJD5NQiDldl7QgEFzc3BsxKW80N k7uQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=aZulBCtshIRgTaWwKVr+otGLeVVPY540pWxIWidjt5s=; b=caJHkFe1SS6xN3eAzUFwQMzz9nAMZPNB5C3Qcao4ZCXeMAoNve14UO5zkRsu7wsP2j /ubcDYYnWfyPc1Tr8wn0IxmGrYpvuU3pDPLfI1YZk+C9rgWUCKPQW0wUvJUM8HlGdn+x ehQuddsahpNvvyBdbub6bINKPfRJfEG3EvwJQ6hkD1c8CITZc7hBk8TcPYclBpzz+YGH GWgnVeWfisoqaLf7n3K67BKdhKETV6+91PV4pBR50Mxx8drXyYbC4ZScrA7U8arxHwC5 GX7zcJmS+1RtqBsCX+Bkahs6fBFCRfF4aHo3vu7nn2TP2RSxT4+zT+JYuTRI11e7kpUi iUUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CGe+plBR; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f9si1192733edf.277.2021.06.28.15.02.25; Mon, 28 Jun 2021 15:02:51 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=CGe+plBR; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238131AbhF1PY2 (ORCPT + 99 others); Mon, 28 Jun 2021 11:24:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:36566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235107AbhF1PAi (ORCPT ); Mon, 28 Jun 2021 11:00:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C1D7661D72; Mon, 28 Jun 2021 14:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891256; bh=z9PiDDo3d78e7qT/+lcHSgMWPdALTe13TDpAblYVG2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CGe+plBRDJOjbgy0dqUh90FDMDkdZcl/FmeCFsfXnPVZgjjL5QaUFsNW/+VIHxoqo zvZdjBrs9M+eC8fwJrxn4+JnLc5jMcRYSXiuE9OdfwFPaonRc5yfSKg0owM/kscn3u msMfeEQSAMhyL8tWKj/49wXiq5ceSlC9MyQDCGmscl/RzCHiXvhCOUmeUQAqGL+7fg EmYtAgICF40FLCvHdDd+tl5yXm28Y8r8aVH09k7P7bBq1RdKMqhVc5IxazhzmuZQWG FwYiHjwVLUT6c/8t5hkDXeucVazHiGM8ZfhMBvQkT6CpWaJ/GKRjTYULe30epOsKcs RpBDvakv9w6+Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zheng Yongjun , "David S . Miller" , Sasha Levin Subject: [PATCH 4.9 59/71] ping: Check return value of function 'ping_queue_rcv_skb' Date: Mon, 28 Jun 2021 10:39:51 -0400 Message-Id: <20210628144003.34260-60-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628144003.34260-1-sashal@kernel.org> References: <20210628144003.34260-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.274-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.9.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.9.274-rc1 X-KernelTest-Deadline: 2021-06-30T14:39+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zheng Yongjun [ Upstream commit 9d44fa3e50cc91691896934d106c86e4027e61ca ] Function 'ping_queue_rcv_skb' not always return success, which will also return fail. If not check the wrong return value of it, lead to function `ping_rcv` return success. Signed-off-by: Zheng Yongjun Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/ping.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 4fda9abf38ee..dd4e46af1e53 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -976,6 +976,7 @@ bool ping_rcv(struct sk_buff *skb) struct sock *sk; struct net *net = dev_net(skb->dev); struct icmphdr *icmph = icmp_hdr(skb); + bool rc = false; /* We assume the packet has already been checked by icmp_rcv */ @@ -990,14 +991,15 @@ bool ping_rcv(struct sk_buff *skb) struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); pr_debug("rcv on socket %p\n", sk); - if (skb2) - ping_queue_rcv_skb(sk, skb2); + if (skb2 && !ping_queue_rcv_skb(sk, skb2)) + rc = true; sock_put(sk); - return true; } - pr_debug("no socket, dropping\n"); - return false; + if (!rc) + pr_debug("no socket, dropping\n"); + + return rc; } EXPORT_SYMBOL_GPL(ping_rcv); -- 2.30.2