Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2459926imd; Fri, 2 Nov 2018 11:47:03 -0700 (PDT) X-Google-Smtp-Source: AJdET5cP+rY9gKNWJs122ef5qTerQpegnPiaZysyLYJxJmMm19SvIY+fIOyKMrGzC/GglaF87+lL X-Received: by 2002:a17:902:5a2:: with SMTP id f31-v6mr12583911plf.320.1541184423896; Fri, 02 Nov 2018 11:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184423; cv=none; d=google.com; s=arc-20160816; b=ygN/tWt9nDp4qf2Qq7j7PE+w3wzJH2dZZ0v+vESCCpdYHzHNYcOD+Y/3Cw0d3rw4eZ wA6Yh33HfWP/vCmmaUYlTZxvYuAQww3TlU6fsKPeq3ik/1ufaIq3AAr/Y8j5sw/zKsaY kU+jDgt4Iu9oUBSTPzqUs364LHdXAlwIJ7T+PkWfIBQBn9s6f1iZvsxleMkNcgJo4hAZ /syK92Z3RaNcr07RWuawu8GpJffW9SifjKLLnZC3MKWrMSxiEebmQFjzFZabSOFhnVad JdzpHUzifK4hxjjfu1VKEItCCqsAEykmPcuMqoc78Oh0/4ZJNXLOTKkuQsR4GOxaT0te tptg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bOtug/K8SAnAgGNxZr8znk7hqGhzRycSAfsrXjYpn10=; b=sAkxODS3qvGPquAmjkTG5jHVtM9zBlxTvgwfRwcb+JoZ3E+auXbShnK3EGVOUge+nb 5uX1lflOALlvW4dckDHyp7VbRu9b07mpuxcpxGXRsNPapY81DkpRKLCDb+aQqae+Q866 IqvKKutgiD24BpJu3lPW1JHARYzp1owgLPXlWqTMbHrV0wJB1bu5MYIe5/2bmDBKxB+u /+wvfuWzSMrv32gvwZwx79sk9Xmv3zfVO1xl+kETDiKVLiWSFlJw/dfxkSUJJogXzRRn ewNYffk1zn8pKlMmDGEy/GIpiEXS1cmJz63Oom51YWNtWXJf+aDM48yn94j6cD+S3Kzb iaDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kj4If907; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b28-v6si28948022pgm.568.2018.11.02.11.46.49; Fri, 02 Nov 2018 11:47:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kj4If907; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729944AbeKCDxz (ORCPT + 99 others); Fri, 2 Nov 2018 23:53:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:49566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729310AbeKCDxt (ORCPT ); Fri, 2 Nov 2018 23:53:49 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C658720837; Fri, 2 Nov 2018 18:45:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184336; bh=e2zXX02PZtjIwxaOY4RuQaHPUcqy9AKMZ2iTGz3LpPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kj4If907aum9ag0z18OnnyUUblS4LrV5VI01Ah6bcs1qQ9fgFJIG4zOC4PMMZv7m+ dlLCFAS43J4WXZVto98UP316IMFnGo2bbRNarDfWQee+HoXwxYymnQFPBonSydgCXP zAYu6UWNnS/fqVE2YfaeJLtIHhJ+TKkIPjWt4LZw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Cong Wang , "David S. Miller" Subject: [PATCH 4.18 138/150] net: drop skb on failure in ip_check_defrag() Date: Fri, 2 Nov 2018 19:35:00 +0100 Message-Id: <20181102182912.195954573@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit 7de414a9dd91426318df7b63da024b2b07e53df5 ] Most callers of pskb_trim_rcsum() simply drop the skb when it fails, however, ip_check_defrag() still continues to pass the skb up to stack. This is suspicious. In ip_check_defrag(), after we learn the skb is an IP fragment, passing the skb to callers makes no sense, because callers expect fragments are defrag'ed on success. So, dropping the skb when we can't defrag it is reasonable. Note, prior to commit 88078d98d1bb, this is not a big problem as checksum will be fixed up anyway. After it, the checksum is not correct on failure. Found this during code review. Fixes: 88078d98d1bb ("net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends") Cc: Eric Dumazet Signed-off-by: Cong Wang Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_fragment.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -657,10 +657,14 @@ struct sk_buff *ip_check_defrag(struct n if (ip_is_fragment(&iph)) { skb = skb_share_check(skb, GFP_ATOMIC); if (skb) { - if (!pskb_may_pull(skb, netoff + iph.ihl * 4)) - return skb; - if (pskb_trim_rcsum(skb, netoff + len)) - return skb; + if (!pskb_may_pull(skb, netoff + iph.ihl * 4)) { + kfree_skb(skb); + return NULL; + } + if (pskb_trim_rcsum(skb, netoff + len)) { + kfree_skb(skb); + return NULL; + } memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); if (ip_defrag(net, skb, user)) return NULL;