Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2001879imm; Thu, 24 May 2018 04:19:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoJ05UTr/LOh2zDZrlEpgwjVo2/oc0SPx6wZMpOQPYxgbh+LAO94pqG9oc0cKUys8o8whal X-Received: by 2002:a65:6005:: with SMTP id m5-v6mr5545996pgu.241.1527160767118; Thu, 24 May 2018 04:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527160767; cv=none; d=google.com; s=arc-20160816; b=mBISu8X9oIbMAnp22Ox7QQX7q6b+C+0/JAgxmMde3S1+cO4us4+fhL46SdPukG9AL2 2lxKiMkei+cHvoU9lmZV8bSYOsvNkZHgHaHMlc+jY52GIjJKGlN1Ld9NU67Q32673zYR quxvwTafmfIpBcop4S3gY5RBaUxIKUHsTPf2wACTGsa2UHsf2w3o7DbKSBX60blXry0H rxaGe16XtWSbQEqBrue5l4uFsuQXt4kX8aSaA5/J0QiXjvn4Tvz4oVdkThp2BCEdOEaA Mv6DfVw+4Ye4GuWXpsDrDLrWxciP7NkxmHduUOZuFlY/XP28aAhnnSJhSH1wbJ7F1yOU Lf+w== 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=jKInOCiZGt2oo5FUGXhp0y3U4qwoVTQL2f/+WCwRjWA=; b=fDgTdG9xJ32tlaxmM0GDQUZfiURYOB5SvWJGtctkRysMfihwOYWP8gZFzNmmYs86r0 nsTsqA0+eVLZblHyibniKjdtYWyRpcHfvi/aNMAWhbwHkucMXTZkIicx2kzT5jLLXxoG o7S8ZMrVcO3MVLP7m07rmC/dzL1CyaVNn7IObxJn59lVmOF2x14IcBo8aJjwTR93gg3J J71k1KivGmvC17vMA4nh+BJXS65PCFNjeD7LYhlnf3sc4a33vn5/CyuphovOO4vMIntK EXTt78SgTyTfMw3JFSXmZwzLnS+Sxuy1MlOmvQoankwCLLpSlatjwjKC/konT1IW53Cb morg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DGURxHzQ; 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 a92-v6si21196521pla.291.2018.05.24.04.19.12; Thu, 24 May 2018 04:19:27 -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=DGURxHzQ; 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 S967652AbeEXJxE (ORCPT + 99 others); Thu, 24 May 2018 05:53:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:55870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966810AbeEXJxA (ORCPT ); Thu, 24 May 2018 05:53:00 -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 4103A20847; Thu, 24 May 2018 09:52:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155579; bh=/ClngrzeHGBo3vNmyhb7yJWN53BGsrufcEMJ8fgeQ68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DGURxHzQgwsJcuyDNh5dvqT+yAcDk9JgvrrcX6qSr0OaGE5ddF8vT+uvLzrJrlPd3 4sKcWOTilv7mSZW0j4gYu4GOTjDxpaIt6xUq4/dkiV12qjEhrvxT5W6c3zLripILVz fWuUHZV2WtYxbssO3RZulMbQFwd/eI9XQ18mvSlQ= 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.14 006/165] net: test tailroom before appending to linear skb Date: Thu, 24 May 2018 11:36:52 +0200 Message-Id: <20180524093622.232282889@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093621.979359379@linuxfoundation.org> References: <20180524093621.979359379@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.14-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 @@ -1488,7 +1488,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;