Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp246799imj; Thu, 7 Feb 2019 03:45:39 -0800 (PST) X-Google-Smtp-Source: AHgI3IYFS5KsS3Ca61awAXj4erAQIu0mug3so7Skmeq+htZhs4oShB7yf0gL5K9whvxTCqHSaL4v X-Received: by 2002:a17:902:129:: with SMTP id 38mr16108218plb.140.1549539939509; Thu, 07 Feb 2019 03:45:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549539939; cv=none; d=google.com; s=arc-20160816; b=U70AjfTpGg6XlG6BAll99IvbF1no6qQzttl+ncfn9z/b8oCNPTPjqYvsEPlTazoTF6 l/4QScv9WuUTRgMzSOvOH18EtWKtj8sGlLpZckAUN6a76lv9DdR3wTCF3TUpFNV7pyNL 7djjfYs+dQoNwQPBfiVEDSvBvfyBDpwal+XlgdnXEuYHoYX92wS8Cyxl6uWXhPy7lCai Etf7srppAQro0bFeicnAwGzO1FP2m4eFPKYXS8LjIVojRPfOnREbMhPKdSl3ExdA0tUI zgHclmah3lH/UcN8Tgi4dHH3zRKIw+TVdklyVKx49BvSOu92BMHN7grfqLlGu+gNzDcb upDA== 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=Y3gB9v1ZNuv5+GUzfwNsc+fd98tfhLyjpAgcpd5fNMI=; b=NW94ySxlUdPgGp19aMs5G9+ODIWZ5eZUXo9haMPCW5SNy8UDZbWMrfU0EzmqCv/5HT KofUNMzyc+1CAClUWDSTpvFDr21OztMOnOmAMkk/6LBVMKtDV2Qw186jbnyu4W38ctzb mjQ0joLVkhnsI1VbcSNKrmkQ7uwULaDHz3BZrjRqy8NplCqd22ElvEyPfkv425DF9KX+ ZoXulqSNktdGK6Sv6jHRHgQwPUAtUVb6HtjK5c0DEe+KqiuWB5kuhrlW/6Ask0Vtfh+p E7MvpTJmXMIbvvIo7LLlv4QkkRM1SVePXWT1eby3b2wAGhLl/tWxCdHgkw4XUpDRPD0/ WCfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u6LyEOsp; 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 v8si8931206plp.215.2019.02.07.03.45.23; Thu, 07 Feb 2019 03:45: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=u6LyEOsp; 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 S1727503AbfBGLnf (ORCPT + 99 others); Thu, 7 Feb 2019 06:43:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:33822 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727479AbfBGLnb (ORCPT ); Thu, 7 Feb 2019 06:43:31 -0500 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 B103521908; Thu, 7 Feb 2019 11:43:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549539811; bh=SkoBuGxzXOo+XiTqE7OBF+mUE4OmG305FdFr7+VFD50=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u6LyEOspeEV0wiyZaRm6O2HbMU2SL/h7jkNLtWBuw7+qVE9ZIcu6B8bYnRt1zFUzw 5iCtnUFXH1FIZkMF/fnT2ScKwELC9sWLSbYxnjMSQqlBm7DoClaoZkq92MS5nL75CH X2eJPdmLpGM2RclnZduAiIfpEzIjb/bv0YDU23Is= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , "David S. Miller" , Ben Hutchings Subject: [PATCH 4.4 16/34] inet: frags: do not clone skb in ip_expire() Date: Thu, 7 Feb 2019 12:41:58 +0100 Message-Id: <20190207113026.216027585@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190207113025.552605181@linuxfoundation.org> References: <20190207113025.552605181@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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: Eric Dumazet commit 1eec5d5670084ee644597bd26c25e22c69b9f748 upstream. 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 Signed-off-by: Ben Hutchings 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 @@ -143,8 +143,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; @@ -187,16 +187,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: