Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4138487pxb; Mon, 8 Feb 2021 08:49:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmeTWOYGxGAmcN0bPqXs1kNMHSZZtFiQcqw8zQO8whgVTgEBKPRfB5D58wpzZVaEdpKiLj X-Received: by 2002:a17:906:ae50:: with SMTP id lf16mr18195603ejb.66.1612802971066; Mon, 08 Feb 2021 08:49:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612802971; cv=none; d=google.com; s=arc-20160816; b=R9yw+Lybk5nDKLljJ34Xur0AXmyRsluJg8hnXIex4wdAK5GNox19aICBQ08kF8bVnI bzxwkWM9tqCPVM4Hl7QVTlg4g4mKBGT+F+2K8MgE7kibedgZN6bNEV20uuwBnkbWK7G4 JWebb6aggMTmABDDyxi/IKjLb5ecSTh0NpWQWqHJt8yJlMq4ricd78B5hx6f+Tqj4K5v zJhi3BJJmpArEpyZazc1XjMPVONecUbBGwXpLNnPx6FZ5Ke4kLjye5OLWE+PIaT7uDfT fmm5bBDGmzdc0RG+kwIc/4ojmeNN+RVmMXisxxxGd17SjgQ0UlKswAqIKWTmZrjfwbLW TeUQ== 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=uqFikLTOslT/M7HHippf4rujPn7sOg3fHjZ/l8eN1Vw=; b=bXibKiKm1or2kepaJ2vOpGkG+Fayd5pJP+Yo7UnisUuWF6Pa6QWtZhhmfUJ9NxEwnd /0yB5oK68Poc6ZQSrA8jVzFus62xKifWE2pUaKzcu3CP5svCu2SuTAcyW4Xp1cywJCGd AFunBEhs3PtTZcg7k11NQ/uMlTk2C4Rv4RXA+bcTdlbCi1Og/LAhnnUvqn7GsUC+9nha 6JYPmehtTXmOPFcd6U8ZRQ+1vo5xbaLIegrZhxqN1UvRiUwhMKTLybfufGqn60UmSwaW PM+9jWn0G16Jn2StqrDEi0WqixTR7HVlqzuJWwDqbFZMKHLlaR69TN+lCsxsxiIDo1JU GFXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n1HARHMk; 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 22si10709886ejc.181.2021.02.08.08.49.05; Mon, 08 Feb 2021 08:49:31 -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=n1HARHMk; 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 S234554AbhBHQq6 (ORCPT + 99 others); Mon, 8 Feb 2021 11:46:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:60982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233564AbhBHPQM (ORCPT ); Mon, 8 Feb 2021 10:16:12 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 74D7164E54; Mon, 8 Feb 2021 15:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612797077; bh=wsePVODvHzqZzM2F4SMDDr4A52UH3jf6jXA59xBor3E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n1HARHMkUcblyrxL0LsETBeNBdQ9LCbYMqyvV4zv8UEUueqmdyfpS9SDmy5mVOqt2 J/kEq/JPWpLeEFxqyQ1F60B3gTBXZDI67XuZNuTyuMUZCC3aCRlJnXhd49AvEZVb02 1X2Oj0yPl+EldiSMF1b++mvGXq233AIRIA5BnGN8= 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 5.4 17/65] net: lapb: Copy the skb before sending a packet Date: Mon, 8 Feb 2021 16:00:49 +0100 Message-Id: <20210208145810.907176671@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145810.230485165@linuxfoundation.org> References: <20210208145810.230485165@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 7a4d0715d1c32..a966d29c772d9 100644 --- a/net/lapb/lapb_out.c +++ b/net/lapb/lapb_out.c @@ -82,7 +82,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