Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp478652rwb; Mon, 26 Sep 2022 01:21:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM661E3P644j4habEt1zvWvvYV1ye7bHGBNTZWfifyd1exc8GPX2ll+lLzKH/ak6V/7PsdWj X-Received: by 2002:a17:907:7e88:b0:783:305:8cac with SMTP id qb8-20020a1709077e8800b0078303058cacmr7860508ejc.439.1664180489528; Mon, 26 Sep 2022 01:21:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664180489; cv=none; d=google.com; s=arc-20160816; b=IGBlbTkhkPHhhbvU2BiJ+nwBd4qzUUDgXeazHaJGYcQgvfGzcIFqWZeTyidEop2ZU+ lpRNUh9uKDP9rxiPi1QLUy4bHxZOfWEHldgNbAgBVTXbJvzhsKR6nqNbICdUwGqOLGfG 1rO73AbnPPalzR8nIe2D37tdksjRmWjVkG/2S7nod2Tta0PfbCfYr60YsdE5nMGv2LIw JAnhoaJxY8POyPD7s1u32eWN2oOEnSvUEhXaoEY370wXCiCyV8U8PD9w0slkUBkGjWNX 1QnPrh2RoBpMR6FjVvMnGKXDPn9j713wiqKVvHXv4CiKaWB+18dgIvVONJDzJ9aLpTcm f+AA== 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=PQG2NDPJFJmuqB/ExauEswah/n1vhZTbxFDqyet04T4=; b=q1VV9HZcA4BCHSqxSml2boa22BKoMdJDuVxnLDZXUoHFPYWj5krghloWXBbxgJuVzr MaLLKIYdXb6n7Rk7uCZxs1/2zdh1Go04lAzYeO3a6VeLXwAu1t80PIgK2scyL2xoM6WC 3SCXvtujq+WGYr6yMaq8/yBiDAG1bi4YCLFcoTsWWVOwK6qhCRwAztVfbuEEGv3+WAKL o149m78GBwj3Q45/1X58ku/usuBsUIaoVcjIOtTZmTxYlL7Yhn/LMh7enorYCsOw/y+W bg9jLL5TAG356r3X3N/Dl3OlYGAf6m5y0ikQcd4WxZOjHLbgq0O2E6EGIqgu7QXjpUNa MKnw== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id au16-20020a170907093000b0077b2e822b5dsi12054421ejc.674.2022.09.26.01.21.04; Mon, 26 Sep 2022 01:21:29 -0700 (PDT) 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234019AbiIZHSQ (ORCPT + 99 others); Mon, 26 Sep 2022 03:18:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233214AbiIZHSN (ORCPT ); Mon, 26 Sep 2022 03:18:13 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A80A82EF07 for ; Mon, 26 Sep 2022 00:18:11 -0700 (PDT) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MbYs057hkz1P71t; Mon, 26 Sep 2022 15:13:56 +0800 (CST) Received: from dggpeml100012.china.huawei.com (7.185.36.121) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 26 Sep 2022 15:18:09 +0800 Received: from localhost.localdomain (10.67.175.61) by dggpeml100012.china.huawei.com (7.185.36.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 26 Sep 2022 15:18:09 +0800 From: Zheng Yejian To: , , CC: Subject: [PATCH] ftrace: Properly unset FTRACE_HASH_FL_MOD Date: Mon, 26 Sep 2022 15:20:08 +0000 Message-ID: <20220926152008.2239274-1-zhengyejian1@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.175.61] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpeml100012.china.huawei.com (7.185.36.121) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DATE_IN_FUTURE_06_12, RCVD_IN_DNSWL_MED,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 When executing following commands like what document said, but the log "#### all functions enabled ####" was not shown as expect: 1. Set a 'mod' filter: $ echo 'write*:mod:ext3' > /sys/kernel/tracing/set_ftrace_filter 2. Invert above filter: $ echo '!write*:mod:ext3' >> /sys/kernel/tracing/set_ftrace_filter 3. Read the file: $ cat /sys/kernel/tracing/set_ftrace_filter By some debugging, I found that flag FTRACE_HASH_FL_MOD was not unset after inversion like above step 2 and then result of ftrace_hash_empty() is incorrect. Cc: stable@vger.kernel.org Fixes: 8c08f0d5c6fb ("ftrace: Have cached module filters be an active filter") Signed-off-by: Zheng Yejian --- kernel/trace/ftrace.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 439e2ab6905e..5a1ec7e1af33 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -6081,8 +6081,12 @@ int ftrace_regex_release(struct inode *inode, struct file *file) if (filter_hash) { orig_hash = &iter->ops->func_hash->filter_hash; - if (iter->tr && !list_empty(&iter->tr->mod_trace)) - iter->hash->flags |= FTRACE_HASH_FL_MOD; + if (iter->tr) { + if (list_empty(&iter->tr->mod_trace)) + iter->hash->flags &= ~FTRACE_HASH_FL_MOD; + else + iter->hash->flags |= FTRACE_HASH_FL_MOD; + } } else orig_hash = &iter->ops->func_hash->notrace_hash; -- 2.25.1