All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Julia Lawall <julia.lawall@inria.fr>
Cc: Yuan Can <yuancan@huawei.com>,
	cocci@inria.fr, Nicolas Palix <nicolas.palix@imag.fr>,
	kernel-janitors@vger.kernel.org
Subject: Re: [cocci] [v3 1/2] coccinelle: locks: add missing_mutex_init.cocci script
Date: Fri, 23 Sep 2022 19:02:22 +0200	[thread overview]
Message-ID: <6a0600c7-dcdd-f37d-9a6d-cc734cf88dd1@web.de> (raw)
In-Reply-To: <2274a1a9-4b13-7677-9cf7-55ea960d8be@inria.fr>

>>> +@r3@
>>> +identifier s, fld;
>>> +position p != {r2.p};
>>> +@@
>>> +
>>> +struct s {
>>> +  ...
>>> +  struct mutex fld@p;
>>> +  ...
>>> +};
>>
>> How many mutexes (or spin locks) should be initialised before further data
>> processing can be safely performed with corresponding structures?
> I tried the semantic patch on this file:
>
> struct s {
>   struct mutex fld;
> };
>
> int main () {
>   struct s *mm;
>   mm = kmalloc();
>   mutex_lock(&mm->fld);
> }
>
> and it reported the expected error message.


This test result might be nice.


> So what exactly is the concern, Markus?


I just suggest to check once more if it would be really required to determine
the position for a data structure member twice (as proposed by the SmPL rules
“r2” and “r3”).

Would you like to compare the data processing for a SmPL code variant
like the following?

@find_member@
identifier s1, s2, f;
position p;
@@
 struct s1
 {
 ...
 struct s2 f@p;
 ...
 };

@show_member@
identifier s1, s2, f;
position p != find_member.p;
@@
 struct s1
 {
 ...
*struct s2 f@p;
 ...
 };


# How do you think about the handling of multiple members within data structures?

# How much does it matter here that curly brackets are used for a proposed SmPL constraint?



I got another development concern for the presented algorithm.
Why is a data initialisation function call searched in the first SmPL rule at all?

I imagine that potentially missing function calls can be determined also
by other approaches.

Regards,
Markus


  reply	other threads:[~2022-09-23 17:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 11:55 [cocci] [PATCH v3 0/2] coccinelle: Introduce cocci script to detect missing mutext and spin lock initialization Yuan Can
2022-09-22 11:55 ` [cocci] [PATCH v3 1/2] coccinelle: locks: add missing_mutex_init.cocci script Yuan Can
2022-09-22 18:11   ` Markus Elfring
2022-09-23 14:21     ` Julia Lawall
2022-09-23 17:02       ` Markus Elfring [this message]
2022-09-23 17:08         ` [cocci] [v3 " Julia Lawall
2022-09-23 17:47           ` Markus Elfring
2022-09-23 19:27             ` Julia Lawall
2022-09-24  8:15               ` Markus Elfring
2022-09-24  8:36   ` [cocci] [PATCH v3 " Markus Elfring
2022-09-24 15:40   ` Markus Elfring
2022-09-25 20:33   ` Markus Elfring
2022-09-22 11:55 ` [cocci] [PATCH v3 2/2] coccinelle: locks: add missing_spin_lock_init.cocci script Yuan Can
2022-09-22 17:19 ` [cocci] [PATCH v3 0/2] coccinelle: Introduce cocci script to detect missing mutext and spin lock initialization Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a0600c7-dcdd-f37d-9a6d-cc734cf88dd1@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=julia.lawall@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=nicolas.palix@imag.fr \
    --cc=yuancan@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.