Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5453293imm; Tue, 16 Oct 2018 10:26:47 -0700 (PDT) X-Google-Smtp-Source: ACcGV61axTZCux1Fbu1/xVp9/321hIx6KyBx+6q8DptfQ4M9dxjx3lCRN2rCDoqGFZBBN0SWY90Q X-Received: by 2002:a62:6506:: with SMTP id z6-v6mr22869132pfb.20.1539710807143; Tue, 16 Oct 2018 10:26:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539710807; cv=none; d=google.com; s=arc-20160816; b=bVgvIlqa+VLirGuCiGgdlW5hSghzry9IlIsx+G4OZTkFCY5fqPXHirjAGaK8NNbbSX UWZeUCGEA4JDrVIpSmwhIeooZJVDkykc21N6FacciMVh+DL5GYZuS6JCG65rQWznP56S /QNqIzVc+MoXDhP3pvM27SLzpGBBw00CaDCWxivbm4QeO5NIijZnkwvf6G2wEWS94bM7 cibh4pVyQWgzzO+qK6H9+weqIGETDWK2HtKGzxGZ1PuZKSbAGxB/et0OljYoFZsIgOEp AeQCiCimVKVESB+DrqvSH9YTMvOP8IjuLrE0hypuLmjUg1/q8tyrTHzZpYXb0H4SGtI3 i4BQ== 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=yIBtL5MKdikBdo6u4LNyfeUb8huYtCQaol0JB+Y9kD0=; b=ToGYdwo24JOmKc7NHuBRP0p67PheVELNEnVnGPUB7/A/3B3TY+yJJPzZMlL4eNyT/J UXQo5On05ka/Mz49j3qCKgJq+L8kCG8OCBYbd+5TkH1S/5F2albZRbyzewq1umcO8Z+u SGd+ajL4jpprD09CPopD08BK/G+32P1LAmQCIzLNht89J+AM/UEVfjn4hs0sTlBkVT+R WDB9zIMigRdEWG+zcB8ZQerpLjVpnAFXq/omXcnWL/wC4olutVbpL7FAA2rDHgsJOhvL RKCvbJFMHF5UrpwK3wqlvzltgkQHi8kh45/5cmvqqsjwxicXkGUTLTqDwp8vXJt6Gx4L FaWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=htXhAqXb; 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 f63-v6si16033298pfb.0.2018.10.16.10.26.31; Tue, 16 Oct 2018 10:26:47 -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=htXhAqXb; 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 S1732204AbeJQBR0 (ORCPT + 99 others); Tue, 16 Oct 2018 21:17:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:36232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730677AbeJQBRZ (ORCPT ); Tue, 16 Oct 2018 21:17:25 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 EA7B4204EC; Tue, 16 Oct 2018 17:25:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539710759; bh=C/in+rhltW4nHOk2LpLH2B01nocaZhixx65+YtiH3qQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=htXhAqXbxnYRexJ5XRS6PbFiQcrgaC5shgL7F1gSbtG01KsgGVfVcddq0u7FHhn1t vGCCA1Rav3TYtRBDdz8GhkDJpbBEQK/E0FDULOg/Z9LKi3V40q/TofmyiWbg2eBaLu vyWOM1qN/mPobsGql1TvAYWoTxLnCk3EJOD/vPnI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" Subject: [PATCH 4.9 55/71] inet: frags: do not clone skb in ip_expire() Date: Tue, 16 Oct 2018 19:09:52 +0200 Message-Id: <20181016170542.123827549@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170539.315587743@linuxfoundation.org> References: <20181016170539.315587743@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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet An skb_clone() was added in commit ec4fbd64751d ("inet: frag: release spinlock before calling icmp_send()") While fixing the bug at that time, it also added a very high cost for DDOS frags, as the ICMP rate limit is applied after this expensive operation (skb_clone() + consume_skb(), implying memory allocations, copy, and freeing) We can use skb_get(head) here, all we want is to make sure skb wont be freed by another cpu. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller (cherry picked from commit 1eec5d5670084ee644597bd26c25e22c69b9f748) Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_fragment.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -141,8 +141,8 @@ static bool frag_expire_skip_icmp(u32 us */ static void ip_expire(unsigned long arg) { - struct sk_buff *clone, *head; const struct iphdr *iph; + struct sk_buff *head; struct net *net; struct ipq *qp; int err; @@ -185,16 +185,12 @@ static void ip_expire(unsigned long arg) (skb_rtable(head)->rt_type != RTN_LOCAL)) goto out; - clone = skb_clone(head, GFP_ATOMIC); + skb_get(head); + spin_unlock(&qp->q.lock); + icmp_send(head, ICMP_TIME_EXCEEDED, ICMP_EXC_FRAGTIME, 0); + kfree_skb(head); + goto out_rcu_unlock; - /* Send an ICMP "Fragment Reassembly Timeout" message. */ - if (clone) { - spin_unlock(&qp->q.lock); - icmp_send(clone, ICMP_TIME_EXCEEDED, - ICMP_EXC_FRAGTIME, 0); - consume_skb(clone); - goto out_rcu_unlock; - } out: spin_unlock(&qp->q.lock); out_rcu_unlock: