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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 58D27C54EE9 for ; Mon, 19 Sep 2022 08:01:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=message-id:date:mime-version:to:cc:references:from: in-reply-to:content-transfer-encoding:subject:reply-to: sender:list-id:list-help:list-subscribe:list-unsubscribe: list-post:list-owner:list-archive; bh=C489eacv+Y/I5B6V9dF4nFV/S/IjFPcTL3UGXEmd5dE=; b=TSdijfSt8hyIVbnPTv8+IHwSgpmFeN9m63L15o2oA8WbZOewrDamUkst MM+cwjTpWHEzii45pm93IPed2M7nbH8lQ+kxaB9ZCedGGnbDT9BPGpAHn G8xePRON5f0pKi4eFaozY/8MzBrH9WYJe9VEcwBk28g+Jx5WjymxF8e1H k=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=cocci-owner@inria.fr; spf=None smtp.helo=postmaster@sympa.inria.fr Received-SPF: SoftFail (mail2-relais-roc.national.inria.fr: domain of cocci-owner@inria.fr is inclined to not designate 128.93.162.160 as permitted sender) identity=mailfrom; client-ip=128.93.162.160; receiver=mail2-relais-roc.national.inria.fr; envelope-from="cocci-owner@inria.fr"; x-sender="cocci-owner@inria.fr"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:192.134.164.0/24 mx ~all" Received-SPF: None (mail2-relais-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@sympa.inria.fr) identity=helo; client-ip=128.93.162.160; receiver=mail2-relais-roc.national.inria.fr; envelope-from="cocci-owner@inria.fr"; x-sender="postmaster@sympa.inria.fr"; x-conformance=spf_only X-IronPort-AV: E=Sophos;i="5.93,327,1654552800"; d="scan'208";a="53369056" Received: from prod-listesu18.inria.fr (HELO sympa.inria.fr) ([128.93.162.160]) by mail2-relais-roc.national.inria.fr with ESMTP; 19 Sep 2022 10:01:53 +0200 Received: by sympa.inria.fr (Postfix, from userid 20132) id 2D16CE039B; Mon, 19 Sep 2022 10:01:53 +0200 (CEST) Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id E4890E0157 for ; Mon, 19 Sep 2022 09:55:36 +0200 (CEST) IronPort-SDR: 63282078_lvKj64lpqD5YoaUCxZ/3fD7ngFaqceFiDNfCIk0NlRapElm rkKz/tCf0mSmlr/4o9V3LUQcMafyTJ/Bkxd3lOQ== X-IPAS-Result: =?us-ascii?q?A0ALAAB9HyhjmLzU+S1aHAEBAQEBAQcBARIBAQQEAQFAg?= =?us-ascii?q?TsHAQELAYIjgVYvBAtFF4Q3iB+IRy4DhCaTFYVVFIFoCwEDAQwBQgQBAYUFA?= =?us-ascii?q?oRqAh0HAQQwCQ4BAgQBAQEBAwIDAQEBAQEBAwEBBQEBAQIBAQIEBAETAQEBA?= =?us-ascii?q?QEBAQEUCRkFDhAFIoV1gjUpAYNjAQEBAQIBIwQLAQVBBQsJAhgCAiYCAlcGD?= =?us-ascii?q?QEFAgEBgnmCfiMDjyGbHXp/MoEBiB2BZYERLAGIRoMhglmBYyccgUlEgRUng?= =?us-ascii?q?RVtgQE+hAeEE4JmBIEKkSuCTYNgHCYEDgMaKx1BAgELQjQYAxQDBSQHAxkPI?= =?us-ascii?q?w0NBBYHDAMDBSUDAgIbBwICAwIGEwUCAk04CAQIBCskDwUCBy8FBC8CHgQFB?= =?us-ascii?q?hEIAhYCBgQEBAQVAhAIAggmFwcTGBsZAQVZEAkhHAoEGg0FBhMDIG8FCjsPK?= =?us-ascii?q?DJrKx0bCoEMKigVAwQEAwIGEwMDIg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,327,1654552800"; d="scan'208";a="24045582" X-MGA-submission: =?us-ascii?q?MDFQrbLuwHo/uGij9JntFDxOWdgSKjCAZxNbox?= =?us-ascii?q?gxdQ/DLdxhyV1aMc+bOSlYMl3tAZ04LGt7gtRR9Yq6YR31c0Dc2Qa0to?= =?us-ascii?q?t92laurVDumXPhOVuYIbeX7DiiFGXIFtKtChw621zj+Ux9CCV1m0Yqlc?= =?us-ascii?q?h4v0EsTAv41+NM4aCWuFJjMg=3D=3D?= Received: from szxga02-in.huawei.com ([45.249.212.188]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Sep 2022 09:55:35 +0200 Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MWH1h6BBZzmVNX; Mon, 19 Sep 2022 15:51:36 +0800 (CST) Received: from [10.174.178.41] (10.174.178.41) 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, 19 Sep 2022 15:55:29 +0800 Message-ID: Date: Mon, 19 Sep 2022 15:55:12 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0 To: Julia Lawall CC: , References: <20220916061923.29759-1-yuancan@huawei.com> From: Yuan Can In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.41] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected X-Validation-by: julia.lawall@inria.fr Subject: Re: [cocci] [PATCH 1/2] coccinelle: locks: add missing_mutex_init.cocci script Reply-To: Yuan Can X-Loop: cocci@inria.fr X-Sequence: 556 Errors-To: cocci-owner@inria.fr Precedence: list Precedence: bulk Sender: cocci-request@inria.fr X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: 在 2022/9/19 3:39, Julia Lawall 写道: > On Fri, 16 Sep 2022, Yuan Can wrote: > >> Find mutex used without init, and point out the >> place the mutex is allocated. > Thank for the semantic patches. > > Traditionally, the semantic patches in the Linux kernel have a Confidence: > tag above the Coyright: line. I would suggest to put such a line in this > case, based on your experience. From looking at a few results with the > mutex semantic patch (I didn't get any results with the spin lock semantic > patch, is that normal?), I would suggest a Low confidence. The cases I Thanks for your suggestion, I will add Confidence tag in the v2 patch. About the spin lock semantic, by excuting "make coccicheck COCCI=scripts/coccinelle/locks/missing_spin_lock_init.cocci MODE=report", I get the following output: 12419 files match ./drivers/net/ethernet/mellanox/mlx4/en_ethtool.c:1851:1-4: Spin lock inside the struct malloced here is possibly used without init. ./drivers/net/ethernet/mellanox/mlx4/en_ethtool.c:1180:1-4: Spin lock inside the struct malloced here is possibly used without init. ./fs/ext4/super.c:4292:1-4: Spin lock inside the struct malloced here is possibly used without init. ./drivers/net/wan/fsl_ucc_hdlc.c:1172:1-11: Spin lock inside the struct malloced here is possibly used without init. ./drivers/usb/cdns3/cdnsp-pci.c:95:2-7: Spin lock inside the struct malloced here is possibly used without init. ./fs/cifs/smb2pdu.c:3854:1-5: Spin lock inside the struct malloced here is possibly used without init. ./drivers/net/ethernet/broadcom/bnxt/bnxt.c:7618:2-5: Spin lock inside the struct malloced here is possibly used without init. ./drivers/clk/x86/clk-cgu.c:592:2-6: Spin lock inside the struct malloced here is possibly used without init. ./drivers/clk/x86/clk-cgu.c:228:1-4: Spin lock inside the struct malloced here is possibly used without init. ./drivers/clk/x86/clk-cgu.c:346:1-5: Spin lock inside the struct malloced here is possibly used without init. ./drivers/clk/x86/clk-cgu.c:103:1-4: Spin lock inside the struct malloced here is possibly used without init. ./drivers/gpu/drm/amd/amdkfd/kfd_device.c:426:1-4: Spin lock inside the struct malloced here is possibly used without init. ./drivers/clk/x86/clk-cgu-pll.c:119:1-4: Spin lock inside the struct malloced here is possibly used without init. ./drivers/scsi/aacraid/dpcsup.c:187:7-10: Spin lock inside the struct malloced here is possibly used without init. ./drivers/scsi/aacraid/dpcsup.c:287:9-12: Spin lock inside the struct malloced here is possibly used without init. ./drivers/usb/cdns3/cdns3-plat.c:60:1-5: Spin lock inside the struct malloced here is possibly used without init. ./drivers/media/platform/renesas/vsp1/vsp1_video.c:667:2-6: Spin lock inside the struct malloced here is possibly used without init. ./drivers/net/wireless/marvell/mwifiex/main.c:83:2-18: Spin lock inside the struct malloced here is possibly used without init. ./drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c:1268:1-14: Spin lock inside the struct malloced here is possibly used without init. ./drivers/mtd/ubi/build.c:896:1-4: Spin lock inside the struct malloced here is possibly used without init. ./drivers/misc/cxl/guest.c:1110:7-21: Spin lock inside the struct malloced here is possibly used without init. ./drivers/vfio/pci/mlx5/main.c:607:1-6: Spin lock inside the struct malloced here is possibly used without init. > looked at seemed to involve calls across different files, and Coccinelle > is looking at only one file at a time. > > I would also suggest to print out more information, to help the user > better undestand where the problem may be. Specifically, it would be nice > to have the name of the lock field, the position of the declaration of > this field, and the position of the call to mutex_lock. You already have > the relevant metavariables in r3, and can add a position metavariable in > r4. Agreed, but how could I fetch the name of the lock field? I cannot find a doc describes how to achieve this(or did I miss it?). > > Finally, you have a * at the beginning of the matched line in r5, so the > rule seems to support the context mode. But if you want to support the > context mode and to highlight all of the mentioned places, you would have > to duplicate r3 and r4 with a depends on for r5, so that the context is > only shown when all of the conditions are satisfied. For example, you > could have: > > @dupr3 depends on r5@ > identifier s, fld; > position r3.p; > @@ > > struct s { > ... > * struct mutex fld@p; > ... > }; Ok, thanks for the explanation. > > Are there some patches in the Linux kernel that are based on these rules? Yes, there are many patches based on the two rules. Best regards, Yuan Can > > thanks, > julia > >> Signed-off-by: Yuan Can >> --- >> .../coccinelle/locks/missing_mutex_init.cocci | 68 +++++++++++++++++++ >> 1 file changed, 68 insertions(+) >> create mode 100644 scripts/coccinelle/locks/missing_mutex_init.cocci >> >> diff --git a/scripts/coccinelle/locks/missing_mutex_init.cocci b/scripts/coccinelle/locks/missing_mutex_init.cocci >> new file mode 100644 >> index 000000000000..bec8ce60d0c5 >> --- /dev/null >> +++ b/scripts/coccinelle/locks/missing_mutex_init.cocci >> @@ -0,0 +1,68 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +/// report missing mutex_init() >> +/// >> +/// Report mutex used without initialize. False positives can occur >> +/// when the mutex allocation and initialization happens in two >> +/// different files. >> +/// >> +// Copyright: (C) 2022 Huawei Technologies Co, Ltd. >> +// Comments: >> +// Options: --include-headers >> + >> +virtual org >> +virtual report >> + >> +@r1@ >> +identifier s, fld; >> +struct s *mm; >> +@@ >> +mutex_init(\(&mm->fld\|&(mm->fld)\)) >> + >> +@r2@ >> +identifier r1.s, r1.fld; >> +position p; >> +@@ >> + >> +struct s { >> + ... >> + struct mutex fld@p; >> + ... >> +}; >> + >> +@r3@ >> +identifier s, fld; >> +position p != {r2.p}; >> +@@ >> + >> +struct s { >> + ... >> + struct mutex fld@p; >> + ... >> +}; >> + >> +@r4@ >> +identifier r3.fld; >> +identifier r3.s; >> +struct s *mm; >> +@@ >> + >> +mutex_lock(&mm->fld) >> + >> +@r5 depends on r4@ >> +identifier r3.s; >> +struct s *mm; >> +position p; >> +@@ >> +* mm@p = \(kmalloc\|kzalloc\|devm_kmalloc\|devm_kzalloc\)(...) >> + >> +@script:python depends on org@ >> +p << r5.p; >> +@@ >> +cocci.print_main("Mutex inside the struct malloced here is possibly used without init.", p) >> + >> +@script:python depends on report@ >> +p << r5.p; >> +@@ >> + >> +msg = "Mutex inside the struct malloced here is possibly used without init." >> +coccilib.report.print_report(p[0], msg) >> -- >> 2.17.1 >> >>