Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp596089rwb; Thu, 1 Dec 2022 06:12:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf6KUWp06rRBy15O0XtKZ/nGjsuKm/wGYPEMix7ahvq/Kaee64r0j8OS835qh/BBoYyBjLBx X-Received: by 2002:a63:5d55:0:b0:46e:fd0a:fe7a with SMTP id o21-20020a635d55000000b0046efd0afe7amr42344920pgm.59.1669903955297; Thu, 01 Dec 2022 06:12:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669903955; cv=none; d=google.com; s=arc-20160816; b=JA7tNoK81dPEkITrA+Qi0mTlCOpC2I0xxCicbmEzxq7vjZSeVwlN5+cMxzMlVFkMIn Ic6zsBVDIVGSKNoLvH/cPuRjlMsWS0P4QhVivq4Xg5BzlLsCFAlx/oScglLhdPbdem9e ql0LQ39lPUx/+EJeZObZ+6VMaIpnPNF8njJoWdcV7uur3XUbr2/OTpeG/wgUgOgcaDzI X0WqvZI5huywUm4qNexyx3Bv4LvF6XT/mpMSGUwJLja+p3nqAKsG+oQbWlhqa232M2qn Q7QASImkPXL0zXDt1UiEs96xYharEwlphn2oPdFAjo0aRaE+0V0+z/Ozwhp7buqnm89m 0eng== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Z4YsErWz/tmmYr2MvIZkpghYc7Sf6Ztb2RO4ghqxl+Q=; b=LXKzslWLhfVGLLSq5RDj52KFOj2aN0diEiKcOuPYNsw/243yK8RVV9P1EglUHuslUY pCtS2xaZrKJmLHjlBpgq/rnqOJDCdFrlCpswv4DyZ2A1UyXB9tiso/ov30b2htGHlLCJ uR9kGULUWCV/a70KbKYnYVAXaMtJNyDtI+x9NpNk2TGKw3O7HWNposAMhqqBptGj3r04 hKvrMll5PBk7Yl2z5rHLqPCfVoL2oz7aeSBH+SSyqTmuz4iP8at1xTJ5Oub57GZQIGLv LfJAhkEBFhS0evtgTYV0W6rGNGUMWXCQL71+TIblrtdTtic+w6IUasR5Gl05+xkL8mYK n8WQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x10-20020a170902ea8a00b00188fe19d3dbsi4335988plb.163.2022.12.01.06.12.20; Thu, 01 Dec 2022 06:12:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231724AbiLAOB3 (ORCPT + 82 others); Thu, 1 Dec 2022 09:01:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231703AbiLAOBS (ORCPT ); Thu, 1 Dec 2022 09:01:18 -0500 Received: from gw.red-soft.ru (red-soft.ru [188.246.186.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E71049075D; Thu, 1 Dec 2022 06:01:16 -0800 (PST) Received: from localhost.biz (unknown [10.81.81.211]) by gw.red-soft.ru (Postfix) with ESMTPA id BB5DD3E42FA; Thu, 1 Dec 2022 17:01:15 +0300 (MSK) From: Artem Chernyshev To: artem.chernyshev@red-soft.ru, Florian Fainelli , Vladimir Oltean Cc: Andrew Lunn , "David S . Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH v3 3/3] net: dsa: sja1105: Check return value Date: Thu, 1 Dec 2022 17:00:32 +0300 Message-Id: <20221201140032.26746-3-artem.chernyshev@red-soft.ru> X-Mailer: git-send-email 2.30.3 In-Reply-To: <20221201140032.26746-1-artem.chernyshev@red-soft.ru> References: <20221201140032.26746-1-artem.chernyshev@red-soft.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 173880 [Dec 01 2022] X-KLMS-AntiSpam-Version: 5.9.59.0 X-KLMS-AntiSpam-Envelope-From: artem.chernyshev@red-soft.ru X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Auth: dkim=none X-KLMS-AntiSpam-Info: LuaCore: 502 502 69dee8ef46717dd3cb3eeb129cb7cc8dab9e30f6, {Tracking_from_domain_doesnt_match_to}, localhost.biz:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;red-soft.ru:7.1.1;127.0.0.199:7.1.2 X-MS-Exchange-Organization-SCL: -1 X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, bases: 2022/12/01 13:03:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2022/12/01 11:49:00 #20632713 X-KLMS-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return NULL if we got unexpected value from skb_trim_rcsum() in sja1110_rcv_inband_control_extension() Fixes: 4913b8ebf8a9 ("net: dsa: add support for the SJA1110 native tagging protocol") Signed-off-by: Artem Chernyshev --- V1->V2 Fixes for tag_hellcreek.c and tag_sja1105.c V2->V3 Split patch in 3 separate parts net/dsa/tag_sja1105.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c index 83e4136516b0..1a85125bda6d 100644 --- a/net/dsa/tag_sja1105.c +++ b/net/dsa/tag_sja1105.c @@ -665,7 +665,8 @@ static struct sk_buff *sja1110_rcv_inband_control_extension(struct sk_buff *skb, * padding and trailer we need to account for the fact that * skb->data points to skb_mac_header(skb) + ETH_HLEN. */ - pskb_trim_rcsum(skb, start_of_padding - ETH_HLEN); + if (pskb_trim_rcsum(skb, start_of_padding - ETH_HLEN)) + return NULL; /* Trap-to-host frame, no timestamp trailer */ } else { *source_port = SJA1110_RX_HEADER_SRC_PORT(rx_header); -- 2.30.3