Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1954102imm; Thu, 24 May 2018 03:32:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrr92g+P8WFTyjy+b6xvDIYrr9ZjiJud/WrRazS6lEOvxE6bHsNvwjzGgLBEe54qvFpadaD X-Received: by 2002:a65:608d:: with SMTP id t13-v6mr2174752pgu.266.1527157949178; Thu, 24 May 2018 03:32:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527157949; cv=none; d=google.com; s=arc-20160816; b=r1oChU6GXy7ErxnoAJu/ufQSRCFrGmT6gKwgIxQjBsPq7ULuYZ1BJoD6rPYmOG3+hq 2F1+GMGrhW9SwxdMhvXDBdCHXen+Qwy746uChUaUplNBuq0Hl5P7mO1Q5UVIHlPbChxP IgNoBN/RFEQMarPr78VyekvYbjC6Sr7AYDHlPIXdvbHR7iIBDho4kOdn48XpR7c3wkAQ ULaN7fmUZpWaJHEVIu5hegnw69G5GRp9spee0M5qQIqsWnwOyRVkUpK9RI5ZRuZLr3+C ftK3kg7HsbUZYMYsv77NcGK0o17Uw0ATCEVDB2rmpM3+H/6IqHoI/BJGPByfAOGszgLn p9eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=g4OuDBBg8YgALk3avBthbYdaaCgQW7kAimuxcgXcYKo=; b=Ds84EGWxfM618BotjoVdnwmnHFDZ70Pp5cYCYFZc5EY6DUKU0IA2dQdijn1Hu913mF nDEDY+06DY7iwYzV2Fv/xmWbglauOzFicujhdEB5vmE+4d0kdWrBcx3rvLZE4OYAw24g Qdoe78c6hDzOu37i6qD7O5xxKPLpCjgOACG5sF0uUq2R8u1NBYaXXRoMVMAo/VyrXmfO Zg3eD1ob3Aa3bG0I6ZN6dC8wBRxcCecJ27sCt4Iw6x7ZCEfU517LqKsU9OYfg+wxqvAi EsEkwpe8WqKT2Pveq/zneCjVH2UogZ2C2jnDjM2mKELUZz8sh8wrLfhiT5xm9Qxg1yW9 s08Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rETxsgin; 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 v1-v6si16095185pgr.30.2018.05.24.03.32.14; Thu, 24 May 2018 03:32:29 -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=rETxsgin; 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 S1030874AbeEXKBF (ORCPT + 99 others); Thu, 24 May 2018 06:01:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:41364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030879AbeEXJ74 (ORCPT ); Thu, 24 May 2018 05:59:56 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 B3D0320870; Thu, 24 May 2018 09:59:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155996; bh=TZhzGekf+OJ0AMLLQlxcZ9AhBxrxOlNS7Cq47524yLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rETxsginKO7C5TfCNYfuZgZCXK9TTPC5MC36eZIZ0FDTZZxso/iOJRhcosiOzLpT2 crWBXmTsy+9KWIRU7htMky9TrN292CF06YE76UTdCn0v/VEmC3a+derEYDs6/MpzM0 +mS6K1oGT9nG9xs2DPTk2YtuCjL8lLSglE17gqhE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Willem de Bruijn , "David S. Miller" Subject: [PATCH 4.16 007/161] net: test tailroom before appending to linear skb Date: Thu, 24 May 2018 11:37:12 +0200 Message-Id: <20180524093019.221178851@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093018.331893860@linuxfoundation.org> References: <20180524093018.331893860@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Willem de Bruijn [ Upstream commit 113f99c3358564a0647d444c2ae34e8b1abfd5b9 ] Device features may change during transmission. In particular with corking, a device may toggle scatter-gather in between allocating and writing to an skb. Do not unconditionally assume that !NETIF_F_SG at write time implies that the same held at alloc time and thus the skb has sufficient tailroom. This issue predates git history. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Eric Dumazet Signed-off-by: Willem de Bruijn Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_output.c | 3 ++- net/ipv6/ip6_output.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1040,7 +1040,8 @@ alloc_new_skb: if (copy > length) copy = length; - if (!(rt->dst.dev->features&NETIF_F_SG)) { + if (!(rt->dst.dev->features&NETIF_F_SG) && + skb_tailroom(skb) >= copy) { unsigned int off; off = skb->len; --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1489,7 +1489,8 @@ alloc_new_skb: if (copy > length) copy = length; - if (!(rt->dst.dev->features&NETIF_F_SG)) { + if (!(rt->dst.dev->features&NETIF_F_SG) && + skb_tailroom(skb) >= copy) { unsigned int off; off = skb->len;