Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5316824rwb; Sun, 4 Dec 2022 19:10:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf4oJscpcqSws7wTFOOapqHRAVj0jfB05SPzsefsK7XFjq4zbbH3+3hSdcGZ9yMXQXLXq7NU X-Received: by 2002:a17:907:20e1:b0:7c0:f90c:43ab with SMTP id rh1-20020a17090720e100b007c0f90c43abmr1472727ejb.452.1670209806207; Sun, 04 Dec 2022 19:10:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670209806; cv=none; d=google.com; s=arc-20160816; b=DXZkH7zTxPHKfTOTUYo6Hwpim2ADkDmN9OsgXYAhNRrAWW/LTotGjokDHQtfpkIQc4 fa1oRseQVdGgysEbmS3Y88yl8Q9ZerLytOozcvzlQquNoUjrjw+W2nvjOcVVxEqaVRxi TaqCh2Q9Z73q06BICS3ZmNQRHl7721nFb+o+MiIYA8nBhPEl5o/LR9HGhWU1mQ8Ge2Xc /j7SXISoeCk2LEKrpn4sb997uFM6FQzGjOmmAyOBy+AwwmFonwbaxuMWcb/BG4zd+nUR 3+ahV2LMnPCfie/F+spOLO1CprnqimSL9zXHkAGxxyq8UGYVzQ/JJALjCInwM7c/bCiR jU3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=pmzU61z7cujSm8w4oNeXR7rsqt9+8ObFT1XhJ3KL7Ig=; b=TuGFGDlWCl7s+tnpfzoB5wd54BorxwJQhEPlP0r969Fc1xYDune8O7eA5CndvVWdAB OvS1kU3wUzb/dW5l+AD26tHorldP930QURDVCKPjoj557UvK7ITH2NGkQ1lqSay4KzjD PY/uj3p4Qkpbxgc8/g2UIlTGFrsIswus3og220SQOrAESzY+BICMxHbZOodjE+qoojch uwQISdGFDHvJMQ/+0546A4b1B6dsu4Q3Fq++/gDDI1oQyMfssLop+AJnoGlncUwGweSF ZHLyJITyn8amXL9wI7zlqbPVjaAOZW34CSju6b8m1V5kyBf3+f9qSsob6k/3qF64XLv1 LyzA== 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 bb6-20020a1709070a0600b007baa6e2275asi11455270ejc.236.2022.12.04.19.09.46; Sun, 04 Dec 2022 19:10:06 -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 S231255AbiLECgK (ORCPT + 82 others); Sun, 4 Dec 2022 21:36:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230479AbiLECgI (ORCPT ); Sun, 4 Dec 2022 21:36:08 -0500 Received: from mail.nfschina.com (unknown [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6D48E640C; Sun, 4 Dec 2022 18:36:05 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 942291E80D0B; Mon, 5 Dec 2022 10:31:51 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8G1ifBev-PxQ; Mon, 5 Dec 2022 10:31:48 +0800 (CST) Received: from [172.30.38.124] (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 4DF011E80C97; Mon, 5 Dec 2022 10:31:48 +0800 (CST) Subject: Re: [PATCH] net: sched: fix a error path in fw_change() To: Cong Wang Cc: Jamal Hadi Salim , Jiri Pirko , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yu Zhe References: <20221201151532.25433-1-liqiong@nfschina.com> From: liqiong Message-ID: <6a8a4c34-83bf-9418-987e-56ac4b44ccc6@nfschina.com> Date: Mon, 5 Dec 2022 10:36:00 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,MAY_BE_FORGED, NICE_REPLY_A,SPF_HELO_NONE,SPF_NONE autolearn=no 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 在 2022年12月04日 03:46, Cong Wang 写道: > On Thu, Dec 01, 2022 at 11:15:32PM +0800, Li Qiong wrote: >> The 'pfp' pointer could be null if can't find the target filter. >> Check 'pfp' pointer and fix this error path. > Did you see any actual kernel crash? And do you have a reproducer too? > Please include them if you do. Found this by 'smatch' tool, I check and find it may be a real problem at the risk of NULL pointer. Like 'fw_delete()', It checks 'pfp' and 'pfp == f' too. > >> Signed-off-by: Li Qiong >> --- >> net/sched/cls_fw.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c >> index a32351da968c..b898e4a81146 100644 >> --- a/net/sched/cls_fw.c >> +++ b/net/sched/cls_fw.c >> @@ -289,6 +289,12 @@ static int fw_change(struct net *net, struct sk_buff *in_skb, >> if (pfp == f) >> break; >> >> + if (!pfp) { >> + tcf_exts_destroy(&fnew->exts); >> + kfree(fnew); >> + return err; > > BTW, err is 0 here, you have to set some error here. You are right, It should return '-EINVAL' -- can't get the target filter. > > Thanks.