Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1911939imm; Thu, 24 May 2018 02:48:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpSYzsva0MskQGDzMLboZ1Q7KWFdULfIiYA07UNjq5xOzCA8ZEDBdWaVm9h3vqOGQ4MesFy X-Received: by 2002:a63:4003:: with SMTP id n3-v6mr4712404pga.184.1527155314360; Thu, 24 May 2018 02:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527155314; cv=none; d=google.com; s=arc-20160816; b=Xu+mDSdH4r3pRCtetuA07PKXyvNhzwtqKJT65m/eqwpy4heXcM8vDbNKK0Pwx3nXaA rS/ktTKioZEn40nns46BlEu/mNSwGwWaSqsXEz1IGGprpoTkcG58u79S9vS7yN6BGFRC eJuFFPRDnKZTDoeFo0DVmXG51syXGNl0m3OxaB5uoNiyub7h3viuLu1ctrATNRZe97CX 90s24ldTosH2XUgA+UKOVqvpCEeLumIl4hjljKec2gb2gExvj6k+fetkXgVJaQ1jgnVY 2BvZnpbKhEZ1A93U8nniQCDXAHmwCTPF0WwaOdJZlYTTFHk8cyc9e/gKX5hOatLPWNIT IQRw== 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=I6hQhum/IBIxi/qb0AEkDDLdkhyuihfozc6dkDrvKEE=; b=WxP8dk6JdeFrL4J4SfOa0PuB/x8oH6uI52x52f7L9PhnO6b1Cpw+vbPKckGkZnIGSS ky5RQMxGQPOo/Kk017GThR5YprJjzJ3thuY7rULgC9p+htBRtrlWA1cIrotL37C0FQEK rWW4DnPEIeuH/QB9kixBDuwdnDwiquh7/KGc4F67mEPsfg+LuoWFaeEGWC40DJ+VrdDU /QSkv79PHD35XxmrI3ehELXIuA5GjH4vgn+O207/qZKN1ikEYeOJVS7OyYtHrAGlAM65 80vAQKAVmFGI5rk2CxJ7ss1PUZozyMpv94fHu3AuJ+skxcUxfD38m+m5aYEeSldRdI0b hYUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GBUfDmTT; 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 e7-v6si7579131pgc.78.2018.05.24.02.48.19; Thu, 24 May 2018 02:48:34 -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=GBUfDmTT; 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 S967093AbeEXJrn (ORCPT + 99 others); Thu, 24 May 2018 05:47:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:60318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967068AbeEXJrg (ORCPT ); Thu, 24 May 2018 05:47:36 -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 8B774208DE; Thu, 24 May 2018 09:47:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155256; bh=QYpYl6xuVryzFpepD6Pz5Jhl7kyRW/ymuBlCT7ysCzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GBUfDmTT0jx4JS44EuoAAjZVTb/zEQaK+EIfC1MEmr1ygUgRmLSA59IXip8v30UUa 6GRK1aKGCKSS7p/uXPkmFzO+JoMjv/L16TFRHvb78NTfgS3a0ddA6ruTYegR0fjsA1 r6j19bZGgDFBF3vM0MX+DAd8jwTqMrn26LiYXIgc= 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.9 02/96] net: test tailroom before appending to linear skb Date: Thu, 24 May 2018 11:37:45 +0200 Message-Id: <20180524093605.765130252@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093605.602125311@linuxfoundation.org> References: <20180524093605.602125311@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.9-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 @@ -1076,7 +1076,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 @@ -1545,7 +1545,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;