Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4108996pxb; Mon, 8 Feb 2021 08:09:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzEo75yd0tQGAi5sZHA7quyFlRm/wL7JurKvZFKislMdV+Uac+VaQ9h7pfQtft4UkrNOFaK X-Received: by 2002:a2e:9801:: with SMTP id a1mr415082ljj.267.1612800551590; Mon, 08 Feb 2021 08:09:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612800551; cv=none; d=google.com; s=arc-20160816; b=f6NV1RiXVwBNsHzDvBpsUiF+8X95FwH6rAks2zHLt2A+wXT8POXqSqjsI/rJmYtJ0r DY65Ea9C30TlrrWjJ4kbtdSECB4kOB4osGgBcruvma5G022AwpbMW/lGkOqMOl2XEME7 wTsqzKTfhBwgeKYZ2qMa4ckB4wuv+vmAaJElm3gQT1lTU+1b82vCh7coxGUNW6F+tlpu ameEzW5hPe++vHUfdgosBGO0TKmK+rf2br7xQcDMHkkaZwF+RDXtskZ6Mshz4tjLCNhp gtUDduJyU2Gh1uG0qbdnF1vILo/Nbh5Yh3PKwwjpoDatrSzo4WrIl14r4+lN1Ra9WcwK urBA== 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=kxBXBVbJJ+D+XaPrE/ZK71oqWdEy8Nm6ck22W6ejYguFyl05i1bicuiHn7n9WkGLxC rdAtJ+9LJFb1JrK0UwuIKxOTgHuiGx1ABpPPFG+MyC1UL8zeZH/+htndQcXnqjAm3BA5 uqKO1ai/+77hQpiHucDcT2qe3wNeez/+lnrcQASz81mx0NnU1ZLMJRwWe5KJzAoto7VF 2PD5rr7Kp24UnH60vAf18VGrtAEjNgjXSIh+TsWjD3DZOXdmKPNMDeMdLnw/gZIlVy/+ 2VMngRjsWmy9epELgFvr+7ZLiqGx/+Kiy7IaAN6z3h5h2oAGYihXoFMEApJ6jzkQT1TN GLQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dxy9j1dd; 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 s8si11209877edd.534.2021.02.08.08.08.47; Mon, 08 Feb 2021 08:09:11 -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=Dxy9j1dd; 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 S233495AbhBHQFj (ORCPT + 99 others); Mon, 8 Feb 2021 11:05:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:56626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233039AbhBHPKR (ORCPT ); Mon, 8 Feb 2021 10:10:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E024164ED3; Mon, 8 Feb 2021 15:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612796829; bh=p3pdBOXEm9sCnNMBb9NfCLPMjcdD5ya/XoThH5uT9vQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dxy9j1ddyjYwcbYL6+TrvGNjRxoZKWXWACljTGMHGKAmoyjyIp/XCaRtSl9jnWO8Z Cq4Y2O3lCCp55Y+KkkeE+LmDF1vOP+l5xcsbSt6Bv5ePIzUkU7fOQfKRx4fi474ebL ZTwnvTdGXUufNLb5hVgrNypW2YYTPt3ubZjiqnmI= 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.14 06/30] net: lapb: Copy the skb before sending a packet Date: Mon, 8 Feb 2021 16:00:52 +0100 Message-Id: <20210208145805.513373363@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145805.239714726@linuxfoundation.org> References: <20210208145805.239714726@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