From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3883C47089 for ; Mon, 5 Dec 2022 02:36:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231279AbiLECgL (ORCPT ); Sun, 4 Dec 2022 21:36:11 -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 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.