Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2063833imm; Thu, 24 May 2018 05:17:20 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoQ5uGwDhhQGskulzknW5h/GaoJbDLwUpd33VxzWyvAHYnEYwxLpGnASsrX9p41NlMxrJfS X-Received: by 2002:a62:c2c7:: with SMTP id w68-v6mr7035317pfk.174.1527164240004; Thu, 24 May 2018 05:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527164239; cv=none; d=google.com; s=arc-20160816; b=kgFba7ki1DagIM1K5GB+VHB1B5TwTkUXb+AH7aBEWDgwZpKv3Ykh3jJSRL1owKwz5Z 0K2V3SecxjB0EmoM0JxN+g66SoOoGPG8GxAeZaJ/iLDL8hUz3Ztaf6ocP9XzvGFnDT7Y qwpSYAaQ/qRm7Xh+Cj1ygHHDKLE2eyRr+sEL9GIKkjj8SjoviMeha/TVDMW0PAGXSeg4 DYKdVKIwzHn7dhTk9B2ds6Eekf2TzMWmyXchZNUYL7u+gXXHIK37r68jNNOwUdM2rsyV V7BmGos+GId+vYqg3QxRZGB0G2+9NsGrzKaOU1TmJZLD88luHhpsBMJ0Sj9faVYKGbBf xe3Q== 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=j09sftvpOOAaCkgELEB0298E2Hwird+MS/wPzeHaCB0=; b=vKcJ3h4Emypw7bp/rhU+NzQ613Tl7g3SuS1GS5UgqS8XBCa21yxeDkYqFZMH7T0/e6 fb3Nh7yteaV9n+eN9bjdrvurLba/7YpR38KWH2jQ251n16dBOO6S7i/tM175fai5cAZJ M79aOiPCVTethfhR687pfKPJLFo+jloCcpx6/u1QxgjpTzzCzsk6NylnkSZu1siH3h4I FA/zuLKu+Zfeti1GAhZOr47RI3gz7FRL2l83WO7m3pWQffWLOn7DFQC6rg75UfDNz3R4 xepW6l2s25oiQ20SZ3foIzpmVKKhjhZbB8Tqxy9GBlVK+gboRH3aTi7XYScqhqd0D3zv iPbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ockp+oBo; 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 b14-v6si2941986pge.71.2018.05.24.05.17.05; Thu, 24 May 2018 05:17:19 -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=Ockp+oBo; 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 S969895AbeEXMQV (ORCPT + 99 others); Thu, 24 May 2018 08:16:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:53876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966278AbeEXJmK (ORCPT ); Thu, 24 May 2018 05:42:10 -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 5A5462087E; Thu, 24 May 2018 09:42:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527154929; bh=T0g4nA3nZ5inMdlz4t+2hOLpdlsA0snKvFFUrHCq1HA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ockp+oBoeCDjlRiYmKR9LUHjcoOJ0iSvyKmFSeA7hZF5PX+s3Xk8ibgRLuOdFYHpN 7IFUZnJ9ludSNXTa/LpBXKSEpSagSoue6VyBpyPDSTLQKGqlccOXBT2O9BRAeb1TxM pEwxHJR2wZTB71o8YKR2ia0dHWkvZcRmNmMnw+zk= 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 3.18 38/45] net: test tailroom before appending to linear skb Date: Thu, 24 May 2018 11:38:46 +0200 Message-Id: <20180524093125.654005307@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093120.599252450@linuxfoundation.org> References: <20180524093120.599252450@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 3.18-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 @@ -1028,7 +1028,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 @@ -1462,7 +1462,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;