From patchwork Wed Jul 14 19:17:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 477281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 087F4C12002 for ; Wed, 14 Jul 2021 19:18:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1270613C8 for ; Wed, 14 Jul 2021 19:18:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240101AbhGNTVN (ORCPT ); Wed, 14 Jul 2021 15:21:13 -0400 Received: from mout.gmx.net ([212.227.15.15]:33871 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230139AbhGNTVL (ORCPT ); Wed, 14 Jul 2021 15:21:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1626290287; bh=1NBRlTgjfqUeCWVZMGYnD8k80BqYbSqvVSZtm5STHYw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=iwjHP7qUtqKnQKBWIxYUHizE+HCQt/zk9Eow4mRTslk5m+/3Kr8ZAjtyJ589s02Tw ZrHnROogL083TTqUcFTDJ94tUZNI5ur8x6Mrvym4b1dmzC0dQ4MdCbWt+3/RtC3iua fnKIOmTV3nhYZ1XKhXqbfW9IJ/chSdxOeKXeG2gs= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from Venus.fritz.box ([149.172.237.67]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mq2nA-1lPgk9046k-00n8DO; Wed, 14 Jul 2021 21:18:07 +0200 From: Lino Sanfilippo To: woojung.huh@microchip.com Cc: UNGLinuxDriver@microchip.com, andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lino Sanfilippo Subject: [PATCH 1/2] net: dsa: tag_ksz: linearize SKB before adding DSA tag Date: Wed, 14 Jul 2021 21:17:22 +0200 Message-Id: <20210714191723.31294-2-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210714191723.31294-1-LinoSanfilippo@gmx.de> References: <20210714191723.31294-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:zG9W3k55wS/h0OdIs+SlIeLtet69YyCpxgFOl5IYJvy4b/Nigpi HFDEIoFeEx/5nfNXKJwgyEyt9p/fzo2c06lbL3Mns/iyo3g2C77QW9br1evxgLVAdfwyosn 6LR5E4HhR1kH2u1cqEhZVqf0gcNE/uWQQFbE3wQlTeyZoamC9vKKteEMBX31l5dBBNuRGFW OLexEsVIsFCaxg0LHegXw== X-UI-Out-Filterresults: notjunk:1; V03:K0:Ylk+XbVU5vY=:hTz0CNh5cPeJvElCX4T9Xi KqnxY0hlGQvK6WKNlAj27HEb8+LLnwnY2RJ+4rvR37WMjTTtfJJuyicysYGcyMsUui6F4AoiI 2jUjOMSxO8MUDR9gCaMqf/aUgOqXk+7i+uUlOpdDrWDto/WWw2QQ3lNrdctSYbjtQzzhgBa3c dEdPOmNwiWBn4QMr3W8+RbyJyb0EgnqXSBlrmDNBCpcf1UFVSCcIbnNeaSkZFiwrtIix+78vs jr+PU7hp477mMrmzzbkwqkbRL59u6daS0JxPDFDbCqPan0HTNU5D55BZ1HR4/i5iHizv1dcyI NP6dSGF/12+esVHBmLSdayRqmdwebZwfEXHnrUTi1sfSzq17mYR8yBKs570GPXQT6FbNlDgab ep2fEA/4nf3Gp6C6ophWmOslaHcHmhgoCSrg6rJzkxbg8prjSW526hURcibibwyckPfRG0CXo GWJA/7/b/3/dHtRyDDkPBiPS0K/Fav/Mzrl7fqgx7LLzrJkelEcki2rdof+3Ci3OSEUjtwwRr Jsec/gTGzMHwtnDL5FS275csKJP45nn9pbwPoFWYNXjys93mzSCe/YfdJpvUMtXlw482Z5ky0 QiHIBkuWUpQcMl9/DR7LdLROeQR7fxWpPv2EuAphWIr7fAazv318XVnwZlCSJ2One2jQQgwhN BY4x6yrImXMTvfpJgcF6Wc1g6xORGUfBbxzVbsRtvPCU7wbP7dlu/AKQWneZt+DvkQgUBWLoE 14U104iZ1MH5G/7u9UEUPU6mlEGvu2LjkZxyKJXN0TUBImQG5+MQ8Ee8eOHFhqu0VNA83p2R1 lNvXxXxs+Eh5F7Qzn/lUcfviZNDGaFC7ggtRLC5BuuOfy9wlW2cko4Hs1J0PQz0/o/hdfnyO+ 9lliX1sY7qR2t+OPDQ/kzBakzH4I3WgibQQ+soYHhl3yPGGX7qgkxo1VqqNZrXM/JOcjB27eI Ts83rIincMFfqU3ZuZTxypwJ40EOChHGdzzs9rOkMZZ2x4PmTt2j/ix5Qb2ICztkCFY5A1OwO q/bxTRcZ0fLxIL639Ov6VObXggg4QBXWUHz3eFBNwNnJiAE3guEbUSpzQTVtxOw23YOUuYq1u dToMamxLde9ugNG+gmcK6kfIvN7w2oFunnQ5vy/NPc6reAqLbfEffStRQ== Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In ksz9477_xmit() skb_put() is used to add the DSA tag to the passed SKB. However skb_put() must only be called for linear SKBs which may not be the case if the DSA slave device inherited NETIF_F_SG from the master device. So make sure the SKB is always linearized. Signed-off-by: Lino Sanfilippo --- net/dsa/tag_ksz.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index 53565f48934c..364f509d7cd7 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c @@ -53,6 +53,9 @@ static struct sk_buff *ksz8795_xmit(struct sk_buff *skb, struct net_device *dev) u8 *tag; u8 *addr; + if (skb_linearize(skb)) + return NULL; + /* Tag encoding */ tag = skb_put(skb, KSZ_INGRESS_TAG_LEN); addr = skb_mac_header(skb); @@ -114,6 +117,9 @@ static struct sk_buff *ksz9477_xmit(struct sk_buff *skb, u8 *addr; u16 val; + if (skb_linearize(skb)) + return NULL; + /* Tag encoding */ tag = skb_put(skb, KSZ9477_INGRESS_TAG_LEN); addr = skb_mac_header(skb); @@ -164,6 +170,9 @@ static struct sk_buff *ksz9893_xmit(struct sk_buff *skb, u8 *addr; u8 *tag; + if (skb_linearize(skb)) + return NULL; + /* Tag encoding */ tag = skb_put(skb, KSZ_INGRESS_TAG_LEN); addr = skb_mac_header(skb);