Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp46427imu; Thu, 8 Nov 2018 14:30:39 -0800 (PST) X-Google-Smtp-Source: AJdET5cUbNkWiA10Scuua6xORtsgYgOMkhoF/pJJfFiqPPovmyWgeZGMIjTxg0aKfardVcwKvEYM X-Received: by 2002:a65:4646:: with SMTP id k6mr5261192pgr.153.1541716239071; Thu, 08 Nov 2018 14:30:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541716239; cv=none; d=google.com; s=arc-20160816; b=EwESrGeH1iqJOrQXc2PQHlbjvDulcY/fKbaPdEWIXf20tPqj+q/zb0eCl1visOFMsN 4SNr2LFbFnOhQU9XsBMJZSB9qwQKtPbh0NbyK76+JD8LDT0x/00x/94sxBc3y/6vpx2/ glAknVEw/MLvhV1HGTKS90k0SplzjDG8RVONYADZLlwFzzC/H+SR9EdjpJte3erJOWA+ 1cUhinK+Ws/QYpB0iJJMrz9tiJppz4yZXr1zdNa2WvqMC0nhSP+tg239YZWgUG2pSB2l VJXXgYhTPThb7Y/DJh7gRjPek6p20+GYjHe8i31FOpTLgMRRPFdIl9b/cmEehZvhBdCw QHfg== 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=CtZik/mip+Qli7TnyYRaCD3J3uyjdYrW9RevrQRsOtA=; b=RG7HLD/ZSo8/aq7NbUEecsDD4Uwddv6Facn69hU67xPvwSl53HLyeR/fUNH+8Pu+SS aav82sBwmc839PG5EssBq6NgPRohd3uFRwZAt6MV5oArQ0fyMWUKLA3XzbbD3ssU6LML GsW0dNt1BZKYvAx5QAvWvSsdSdaH1d0I30zV9nPofkqcvxr7CMCZ/9pmQuSI8kWpp8I3 mAvEVwtlRqbIi6Ju+60IOXBSr8bXC4QCtYoQWvRMnmgQz/kz/bHe+jNzme+vCQlULp/8 DOI40HUrKmUyOnSZ8BQwj7yRFo5A8ZmA+OLer2wd1wonx9YGiKOaTG8PD1UnPmv18u9G 2Ieg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=snMo4Inn; 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 d8-v6si5264916pgh.45.2018.11.08.14.30.16; Thu, 08 Nov 2018 14:30:39 -0800 (PST) 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=snMo4Inn; 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 S1730691AbeKIHi2 (ORCPT + 99 others); Fri, 9 Nov 2018 02:38:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:57626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729311AbeKIHi1 (ORCPT ); Fri, 9 Nov 2018 02:38:27 -0500 Received: from localhost (unknown [208.72.13.198]) (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 6064420892; Thu, 8 Nov 2018 22:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541714458; bh=F0230BpA3XnUZENUKAztiV+zRfv54FNYfA5no/vZt5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=snMo4InnGPtAhWgbk9vEXaQ9dAeAl4CPxK34O19Sqf4D7r/DgmtxG5FXJ5tM77ZLp j5URFBHbtcZKDxZTTjRiibfGBPIva0g2ZrVCrzaiRwoKKBGm6qo+oXZsHM3mHUx526 W0Z501dvH171i8ufqmXx4UIP1Y5UFvWKWYAuYF1c= 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.4 098/114] net: drop skb on failure in ip_check_defrag() Date: Thu, 8 Nov 2018 13:51:53 -0800 Message-Id: <20181108215109.581756001@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108215059.051093652@linuxfoundation.org> References: <20181108215059.051093652@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.4-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 @@ -716,10 +716,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;