Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp905833rwb; Tue, 29 Nov 2022 06:48:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf71lJ6yp6I+iCzdy4a6PpWmqL3zWwz2szH0GRxjEkIrHuVn7O+hWkgc00/35KSMVtG+Mafd X-Received: by 2002:a63:548:0:b0:477:b4f4:84c with SMTP id 69-20020a630548000000b00477b4f4084cmr28371745pgf.24.1669733310853; Tue, 29 Nov 2022 06:48:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669733310; cv=none; d=google.com; s=arc-20160816; b=i8E7eqKevLK6/vHqrqbg/KYxqe0v62WvRndu8PWME5yceTjpIL4W2AMCcr+7iYBwiX 1sCFHWd+U8Hh9jfaGwgom2EZ0BiDPB1zrCKvYPPAYq3sg8gE8TDlNLLTB4j0O7bAx6sG 6Uo2FMXqv/J9Si8BMJ5VC8P+kPQc4Jpf+3NZm0rOEWDMKbPjg1GiI869AW4sxnDzqOs9 2Gy3rgMGKplCFHN88Db3S0pHyWJQf905v+ii3qqJzwEeYhkOmOGD7JwGxjJFu2Anvmou zwmVSRJUAh80tvtSXEo+dJfimehzYJPijO8oe1dBnsn1mwad3JVtgc1x1e16n6teQduv YjoA== 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 :message-id:date:subject:cc:to:from; bh=DS4fYXBwdH3hiorzZMRrl4o8b/RKc2yam5oy5Fk/o6o=; b=v6m4wUNVhwVGgIr/5++aejyEvzO+QRE/8u85LpweRbPTWUcNQiB5Kvde7YfuIIIkH8 F61GT0eFeHHI/hezkQgGkXM5q3331Xk0NDnmwnT9DCU4bumysYOpn7WePQSEhxrod5BH sbG05DMlXK9yg56cGW5WoM1YRmRwMWkp3fTJuacpnf5P64jShP3sslNMkp3qI/n88I0o pPxd3fQSqSjF8dg/qDFqyQet3sid9plejlorV4lKWrkOj/bA8bG3889+j1tQlpcjaw8z O4Y9IX9KvZG9Rciv+V6RoKr44cVyW4j6vQDIqYDqgXYxrWyCJcLq5lu8bNDJzkuQidKL k/Lg== 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 f16-20020a170902ce9000b00186b1459953si16360287plg.382.2022.11.29.06.48.19; Tue, 29 Nov 2022 06:48:30 -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 S233685AbiK2OIi (ORCPT + 83 others); Tue, 29 Nov 2022 09:08:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234981AbiK2OIV (ORCPT ); Tue, 29 Nov 2022 09:08:21 -0500 Received: from gw.red-soft.ru (red-soft.ru [188.246.186.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 77A9B12AC4 for ; Tue, 29 Nov 2022 06:08:18 -0800 (PST) Received: from localhost.biz (unknown [10.81.81.211]) by gw.red-soft.ru (Postfix) with ESMTPA id EF03F3E31CB; Tue, 29 Nov 2022 17:08:14 +0300 (MSK) From: Artem Chernyshev To: Woojung Huh , Andrew Lunn Cc: Artem Chernyshev , Florian Fainelli , "David S . Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] net: dsa: ksz: Check proper trim in ksz_common_rcv() Date: Tue, 29 Nov 2022 17:08:09 +0300 Message-Id: <20221129140809.2755960-1-artem.chernyshev@red-soft.ru> X-Mailer: git-send-email 2.30.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 173826 [Nov 29 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}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;red-soft.ru:7.1.1;127.0.0.199:7.1.2;localhost.biz:7.1.1 X-MS-Exchange-Organization-SCL: -1 X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, bases: 2022/11/29 11:22:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2022/11/29 08:46:00 #20623389 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() Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: bafe9ba7d908 ("net: dsa: ksz: Factor out common tag code") Signed-off-by: Artem Chernyshev --- net/dsa/tag_ksz.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/dsa/tag_ksz.c b/net/dsa/tag_ksz.c index 38fa19c1e2d5..429250298ac4 100644 --- a/net/dsa/tag_ksz.c +++ b/net/dsa/tag_ksz.c @@ -21,7 +21,8 @@ static struct sk_buff *ksz_common_rcv(struct sk_buff *skb, if (!skb->dev) return NULL; - pskb_trim_rcsum(skb, skb->len - len); + if (pskb_trim_rcsum(skb, skb->len - len)) + return NULL; dsa_default_offload_fwd_mark(skb); -- 2.30.3