Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4119914pxb; Mon, 8 Feb 2021 08:24:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCn8Va2lh/zfTf35e4ZhCgPVa9GC4wU5xqJN0/a8EKGqgCLaatm4G5GQJ8ZsQHSZ3mIVGE X-Received: by 2002:adf:f009:: with SMTP id j9mr20588574wro.35.1612801463276; Mon, 08 Feb 2021 08:24:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612801463; cv=none; d=google.com; s=arc-20160816; b=sDNhTmzPPxAVkLeGnwNBm9o1mIVxDFW9IKs2ZQk6NP3oTmKuG1HSrRMSvpu4/aj8PV PquT3N3qaSswyGvboWZN4Ps0oKjvMBjQuYyMnFUHxci/VEdYNMJa/lk4qqixyMG4eiZQ NhhR2qfB8JdZbx1P6XpK5A/TltFtlqnliqmAdimw59+jMGLY6lWbneaNI+afnzwgIAdm ajpgftQMCrkC7WqJ2396eAS/Jx5FhPr2pBeXbxIE/AmqyIMpDaMRXh9vHno8s0iv++ms Mus1vWsRfRg1BSKZWv8JoldDWmABikui6VvRqsdIQNcqkmAoEXJVtTxhkE1e/AYcgg8Q B54Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jCGo4hdbW84C/Nl7XoGz5++LEDGd3z2eas4yQaR+g54=; b=JLCcBBec1JwXyfI/dNPVIwkEo/mQ1SJBC4ANoGrYWB9xnbLL6LwaTL9V/8bzaE0NPK 7R/DxwRKCwVvACzsjx7OdbMSKocrzXFnYUvB4ahrI6GRLIo8bUwjAChpJHjDSlfS5qVl +bnz/ENdsUz174CBh0NpG5cIhaU7pFI1mCvwyEaySv2CwqQDArZyDzQh/9eXcBMGNy5y 0Y08ZZAZywvStq6aniua6KeGazKxHjqeyFX5E+Xv5LV0Y9EyWZ6YV7QC7JxQX1CSIry9 vkVoZuAAqTZq9unpHaUa3EnUztjv1BWW87HLEfAwyXK6rlk4edcv9LxH3Bz/DhXB7ISl y/1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LoTBWchD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a10si10669949edq.269.2021.02.08.08.23.58; Mon, 08 Feb 2021 08:24:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LoTBWchD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234369AbhBHQWw (ORCPT + 99 others); Mon, 8 Feb 2021 11:22:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:56402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233296AbhBHPLr (ORCPT ); Mon, 8 Feb 2021 10:11:47 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 07DD064EEE; Mon, 8 Feb 2021 15:08:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612796932; bh=p3pdBOXEm9sCnNMBb9NfCLPMjcdD5ya/XoThH5uT9vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LoTBWchDlkzzcRlAc0V08eowlS4T3HB4ypUSlGktOOneN94QGxvZ8owrzGlMD3aL9 vAbSn0fpAihCDnrC2DMHQ5Ok9w+7uUwM4mkFgCJXOg60UGawCuTHtEls7GyZB7BLHT KHqddyDS4B9U8f7stXup7Wfq9E3x4fpsqrsw0QY8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xie He , Martin Schiller , Jakub Kicinski , Sasha Levin Subject: [PATCH 4.19 08/38] net: lapb: Copy the skb before sending a packet Date: Mon, 8 Feb 2021 16:00:55 +0100 Message-Id: <20210208145806.464568818@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145806.141056364@linuxfoundation.org> References: <20210208145806.141056364@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xie He [ Upstream commit 88c7a9fd9bdd3e453f04018920964c6f848a591a ] When sending a packet, we will prepend it with an LAPB header. This modifies the shared parts of a cloned skb, so we should copy the skb rather than just clone it, before we prepend the header. In "Documentation/networking/driver.rst" (the 2nd point), it states that drivers shouldn't modify the shared parts of a cloned skb when transmitting. The "dev_queue_xmit_nit" function in "net/core/dev.c", which is called when an skb is being sent, clones the skb and sents the clone to AF_PACKET sockets. Because the LAPB drivers first remove a 1-byte pseudo-header before handing over the skb to us, if we don't copy the skb before prepending the LAPB header, the first byte of the packets received on AF_PACKET sockets can be corrupted. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Xie He Acked-by: Martin Schiller Link: https://lore.kernel.org/r/20210201055706.415842-1-xie.he.0141@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/lapb/lapb_out.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/lapb/lapb_out.c b/net/lapb/lapb_out.c index eda726e22f645..621c66f001177 100644 --- a/net/lapb/lapb_out.c +++ b/net/lapb/lapb_out.c @@ -87,7 +87,8 @@ void lapb_kick(struct lapb_cb *lapb) skb = skb_dequeue(&lapb->write_queue); do { - if ((skbn = skb_clone(skb, GFP_ATOMIC)) == NULL) { + skbn = skb_copy(skb, GFP_ATOMIC); + if (!skbn) { skb_queue_head(&lapb->write_queue, skb); break; } -- 2.27.0