Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3837180pxv; Mon, 28 Jun 2021 14:16:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh7jKwQsSIkNlvDXYAIC9uOlMOWrE877hRdMzbtRsO3O/Latt/lyfTc+a93uoTV12KNEsn X-Received: by 2002:a05:6e02:c74:: with SMTP id f20mr20258091ilj.85.1624915012485; Mon, 28 Jun 2021 14:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624915012; cv=none; d=google.com; s=arc-20160816; b=zJE8EHEzndkaaGQqEtmf3/ZIiT6hSUkfsfQxDceei3UxLIwJ7aMw9bv7MFknWd4bMD ORmO9NgvbAHyTAztk/c+I0mhAcFCGwWYAm+4x+WpcCR4GWmPrdoZgAdcsDsGB/ff+ue1 iDOtuixy/taujwMSC5Fs9nEIuHwnYYtMqiET3+kYtJGcgeGi1Wwo2m/0sx3QWyZJE6u2 vHFKdYv4A0orbIAttZ+laId9ZxLpVB8iOdyurWX12GSRipGgEdDw9FCE5iRciUtHPbOa cef5LPpUW9gr2ov+6NKlEM2d8qftHag3DNZBLclFsCrKQQnzoEbk+mcXv553LnuzPnLE G0RA== 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=ovoMoou5l92SIL4/QLAG5GTz8rPO0a9dFB/wJaoWGkM=; b=DKIgFlpqoGy6EjjGWY59N7aRTWvySafU9Z/PLOv91h857xNTTsZsxyO1l/Bs/TPI/4 Dqa8p4SbVrnZT+uJy2HAOWr9cmqalGK9T8CLb25qx3bnzke2d8BizFUwz2r0KVIwH78R aR902izFSXRnXFq4YFJ97yauB0JDRROiB9hiyu/hlrJ9bBnJhIJDFHYCnuP6wte1AF2E Si5Se7y/jMgBiwDqHEPBWY+c4FtuWTa6DiXGLomtc6oeGMbsI2/prc8REXcgQyJ9sIh2 bIO9xulma9GQK2Dvx1h+2PCr3a6OwSN27IQKQsgTJavwLbDl2pWG6lsJPEQ2yGPI7PaB H2PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JtX0i8eZ; 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 p14si19935416iov.42.2021.06.28.14.16.36; Mon, 28 Jun 2021 14:16:52 -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=JtX0i8eZ; 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 S235432AbhF1PPx (ORCPT + 99 others); Mon, 28 Jun 2021 11:15:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:34084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236179AbhF1Oyz (ORCPT ); Mon, 28 Jun 2021 10:54:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 52FCE61D46; Mon, 28 Jun 2021 14:37:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891054; bh=0k/dbRhB3OSnM4i6+Q1qXH5roZi+Qm4SlE6OQ0FRZN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JtX0i8eZ5TqwNhZWu6A66f7h6NBQkkDlhusWU2Obtv+a1BmTmxUqzUi7/KR6dkeZj W1wEtnqVbSnfnErSwxwUWHyuDgwFU7gMjpazY+BqlFEwP4gebcd2ywIn6fb2DvjdVZ pVfS8fp8Ht20CBEE21nB9FK6z9PUnYxVwaxDuKeQJ6PV/P9m2kAirqOtUxvkkHN/fa xAinQxMZSVvIK+PGNc77B73KkxC1MqrKygLvtX2B+ZO+i4KQLFozPZaB9paK6YnksW EGy46f6MARMP2ZXBnzMJLZRwAwlzpA7ac6MLy1VPbQ26dD+tuUaOazvjrAeaJ0fPIu Hy4VBg5u18+9g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zheng Yongjun , "David S . Miller" , Sasha Levin Subject: [PATCH 4.14 75/88] ping: Check return value of function 'ping_queue_rcv_skb' Date: Mon, 28 Jun 2021 10:36:15 -0400 Message-Id: <20210628143628.33342-76-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143628.33342-1-sashal@kernel.org> References: <20210628143628.33342-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.238-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.238-rc1 X-KernelTest-Deadline: 2021-06-30T14:36+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 186fdf0922d2..aab141c4a389 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -978,6 +978,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 */ @@ -992,14 +993,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