Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2038721imm; Thu, 24 May 2018 04:57:44 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqhjnFF87l5FnbeSdW3uwi/2vNuciweK9IVd1L5ua8sl/BaRXkoEeme5K9It/qCIMbxrvgs X-Received: by 2002:a65:6489:: with SMTP id e9-v6mr5669594pgv.44.1527163064818; Thu, 24 May 2018 04:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527163064; cv=none; d=google.com; s=arc-20160816; b=LM/a0uyLbddDZTKuWVytV1IDxNUcGy7OEtuTJLQtEzcjM33pwvzt69nZp48IOsxFR2 HpD/SjOh5gF4sPn1Df4YgWHyfHLpybwPNXsXGAW3OGM7+Ce5gfoN9rrggVXN50rkfTrS GmNBxHuRZxcdziBVLkWXdLMdHpnSkVXfpudv2iKJgCPItjMRGzvW4bD59rzYPjLNSy2l 3twEyBeaYGhhR0I164hfNyblKDFvq8oD68sARaprBi53PP2ShQSXEgM8vmnanGG0BtA4 9gSHPkjjQjnlzFLt+ou7HMJychwGF2DjRNHicyK1PL+KMDIAtgzmUDoUtKr2vcX27XvN OVJg== 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=zJoZ3MZLVLIpMA+g4i2l76XhzwSwah0D48+H2OiZF0M=; b=mD77XHLHY5dvyi6WdPbfbQ8Eqog9B0kjpe3ZNIoh0vxGW5+jyiDI4c3O5Hu6mEg9Cr RyphyyKCna4RnKTnINH7EaLcUosJiRnwcgFC2A/rj89m6xd23FiB+rCxjD9DBf0j5sqp M3BOnYEzEPT1SW+PJF5y5p8HlWfA/WAPYt9doYO8K8TVlfyiGL7ZcyjqeAilGkkuytwx a8DvDru7ERaR99j2rH7Vntail/3YI3jYnCCPIKxWYpi3dbaF5pf6vhCemsSkXUdKOehX qmtB704KqsDMTyTBx5V3O2f7yWz7HidUQm8AO43VWtMJhzITOgZB/k89pc3Ru3gzpXcS zrkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UYizxom0; 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 81-v6si20817789pfl.295.2018.05.24.04.57.30; Thu, 24 May 2018 04:57:44 -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=UYizxom0; 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 S969432AbeEXL4x (ORCPT + 99 others); Thu, 24 May 2018 07:56:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:56900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966369AbeEXJpp (ORCPT ); Thu, 24 May 2018 05:45:45 -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 D4B1B208BA; Thu, 24 May 2018 09:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155145; bh=/PaokbgMxHJ4my2f9QqgWvYhjdGRKp7119TDi8ZWyek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UYizxom0oFSo1732clGm+OHxg7mvy1k40eNZ0ZRbssn19rjykTDBGoJvLUo/Vtko/ v45OA4suQH3I8LXNRR+Hnyj3XMUKIhhJ43n/jD1gED95nT424KR6pkEkWgNc9S6hcY qb0mD0kJ9/67oAnqd4N8TEeDDX/4iZIBcWc5zLbs= 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.4 71/92] net: test tailroom before appending to linear skb Date: Thu, 24 May 2018 11:38:48 +0200 Message-Id: <20180524093206.154970920@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@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.4-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 @@ -1062,7 +1062,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 @@ -1529,7 +1529,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;