Skip to contentSkip to conversation

Checking evaluation of another SmPL script

cocci Markus Elfring 2 participants 17 messages May 23 – May 26 11 messages not in the archive

lore
Share & tools
lore
#0 lore raw

Hello,

I would like to try another small SmPL script out.

Example:
// See also:
// [PATCH] pNFS: Fix use-after-free in pnfs_update_layout()
// https://lore.kernel.org/linux-nfs/[email protected]/

// https://elixir.bootlin.com/linux/v7.1-rc4/source/fs/nfs/pnfs.c#L2128-L2385
@display@
identifier i;
expression e;
@@
*pnfs_put_layout_hdr(i);
... when != i = e
*trace_pnfs_update_layout(..., i, ...)

Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> /usr/bin/spatch --version spatch version 1.3.1 compiled with OCaml version 4.14.3
…

Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> /usr/bin/spatch --no-loops …/Projekte/Coccinelle/janitor/show_UAF_1.cocci fs/nfs/pnfs.c …
@@ -2169,9 +2169,6 @@ pnfs_update_layout(struct inode *ino,

lookup_again:

        if (!nfs4_valid_open_stateid(ctx->state)) {
-               trace_pnfs_update_layout(ino, pos, count,
-                                        iomode, lo, lseg,
-                                        PNFS_UPDATE_LAYOUT_INVALID_OPEN);
                lseg = ERR_PTR(-EIO);
                goto out;
        }
@@ -2216,7 +2213,6 @@ lookup_again:
                                           TASK_KILLABLE));
                if (IS_ERR(lseg))
                        goto out_put_layout_hdr;
-               pnfs_put_layout_hdr(lo);
                goto lookup_again;
        }

@@ -2229,11 +2225,7 @@ lookup_again:

                dprintk("%s wait for layoutreturn\n", __func__);
                lseg = ERR_PTR(pnfs_prepare_to_retry_layoutget(lo));
                if (!IS_ERR(lseg)) {
-                       pnfs_put_layout_hdr(lo);
                        dprintk("%s retrying\n", __func__);
-                       trace_pnfs_update_layout(ino, pos, count, iomode, lo,
-                                                lseg,
-                                                PNFS_UPDATE_LAYOUT_RETRY);
                        goto lookup_again;
                }
                trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,
@@ -2268,7 +2260,6 @@ lookup_again:
                                                TASK_KILLABLE));
                        if (IS_ERR(lseg))
                                goto out_put_layout_hdr;
-                       pnfs_put_layout_hdr(lo);
                        dprintk("%s retrying\n", __func__);
                        goto lookup_again;
                }
@@ -2285,7 +2276,6 @@ lookup_again:
                                        PNFS_UPDATE_LAYOUT_INVALID_OPEN);
                        nfs4_schedule_stateid_recovery(server, ctx->state);
                        pnfs_clear_first_layoutget(lo);
-                       pnfs_put_layout_hdr(lo);
                        goto lookup_again;
                }
                spin_lock(&ino->i_lock);
@@ -2356,7 +2346,6 @@ lookup_again:
                                pnfs_clear_first_layoutget(lo);
                        trace_pnfs_update_layout(ino, pos, count,
                                iomode, lo, lseg, PNFS_UPDATE_LAYOUT_RETRY);
-                       pnfs_put_layout_hdr(lo);
                        goto lookup_again;
                }
        } else {

I find some generated diff hunks inappropriate for the mentioned source code search pattern.
How can such questionable data be avoided here?

Regards,
Markus

#1 lore raw
Quoted 82 lines · Markus Elfring

Hello,

I would like to try another small SmPL script out.

Example:
// See also:
// [PATCH] pNFS: Fix use-after-free in pnfs_update_layout()
// https://lore.kernel.org/linux-nfs/[email protected]/

// https://elixir.bootlin.com/linux/v7.1-rc4/source/fs/nfs/pnfs.c#L2128-L2385
@display@
identifier i;
expression e;
@@
*pnfs_put_layout_hdr(i);
... when != i = e
*trace_pnfs_update_layout(..., i, ...)

Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> /usr/bin/spatch --version spatch version 1.3.1 compiled with OCaml version 4.14.3
…

Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> /usr/bin/spatch --no-loops …/Projekte/Coccinelle/janitor/show_UAF_1.cocci fs/nfs/pnfs.c …

(quoted diff) +0 -11
@@ -2169,9 +2169,6 @@ pnfs_update_layout(struct inode *ino,
 
 lookup_again:
        if (!nfs4_valid_open_stateid(ctx->state)) {
-               trace_pnfs_update_layout(ino, pos, count,
-                                        iomode, lo, lseg,
-                                        PNFS_UPDATE_LAYOUT_INVALID_OPEN);
                lseg = ERR_PTR(-EIO);
                goto out;
        }
@@ -2216,7 +2213,6 @@ lookup_again:
                                           TASK_KILLABLE));
                if (IS_ERR(lseg))
                        goto out_put_layout_hdr;
-               pnfs_put_layout_hdr(lo);
                goto lookup_again;
        }
 
@@ -2229,11 +2225,7 @@ lookup_again:
                dprintk("%s wait for layoutreturn\n", __func__);
                lseg = ERR_PTR(pnfs_prepare_to_retry_layoutget(lo));
                if (!IS_ERR(lseg)) {
-                       pnfs_put_layout_hdr(lo);
                        dprintk("%s retrying\n", __func__);
-                       trace_pnfs_update_layout(ino, pos, count, iomode, lo,
-                                                lseg,
-                                                PNFS_UPDATE_LAYOUT_RETRY);
                        goto lookup_again;
                }
                trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,
@@ -2268,7 +2260,6 @@ lookup_again:
                                                TASK_KILLABLE));
                        if (IS_ERR(lseg))
                                goto out_put_layout_hdr;
-                       pnfs_put_layout_hdr(lo);
                        dprintk("%s retrying\n", __func__);
                        goto lookup_again;
                }
@@ -2285,7 +2276,6 @@ lookup_again:
                                        PNFS_UPDATE_LAYOUT_INVALID_OPEN);
                        nfs4_schedule_stateid_recovery(server, ctx->state);
                        pnfs_clear_first_layoutget(lo);
-                       pnfs_put_layout_hdr(lo);
                        goto lookup_again;
                }
                spin_lock(&ino->i_lock);
@@ -2356,7 +2346,6 @@ lookup_again:
                                pnfs_clear_first_layoutget(lo);
                        trace_pnfs_update_layout(ino, pos, count,
                                iomode, lo, lseg, PNFS_UPDATE_LAYOUT_RETRY);
-                       pnfs_put_layout_hdr(lo);
                        goto lookup_again;
                }
        } else {
Quoted 3 lines

I find some generated diff hunks inappropriate for the mentioned source code search pattern.
How can such questionable data be avoided here?

Due to the goto, they all look fine to me. What did you intend?

If you consider that some output is unsuitable, it would help a lot if you would indicate which output you are concerned about, and not just dump the whole thing and hopw taht the reader will figure it out in the same way you did.

julia

Quoted 4 lines

Regards,
Markus

#2 lore raw
Quoted 5 lines
Quoted 3 lines

I find some generated diff hunks inappropriate for the mentioned source code search pattern.
How can such questionable data be avoided here?

Due to the goto, they all look fine to me. What did you intend?

Does the statement “goto lookup_again;” represent a jump backwards?
https://elixir.bootlin.com/linux/v7.1-rc4/source/fs/nfs/pnfs.c#L2170

Would it form a loop?

Quoted 2 lines

If you consider that some output is unsuitable, it would help a lot if you would indicate which output you are concerned about,

I am trying again to clarify development challenges together with variations of the semantic patch language.

Quoted 3 lines

and not just dump
the whole thing and hopw taht the reader will figure it out in the same way you did.

Wentao Liang pointed only a single source place out for an improvement according to the affected function implementation.
Thus I hope that the other diff hunks can trigger more desirable collateral evolution.

Can the program parameter “--no-loops” have a bigger effect?
https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/03a1af0a3316ddfc2b54d827b8b9627a841c85c9/docs/manual/spatch_options.tex#L373-375

Regards,
Markus

#3 lore raw
In reply to Julia Lawall
Quoted 1 line

Due to the goto, they all look fine to me. …

Which data processing effects do you expect according to the program option “--no-loops” for the presented source code search pattern?

Regards,
Markus

#4 lore raw
Quoted 4 lines · Markus Elfring
Quoted 1 line

Due to the goto, they all look fine to me. …

Which data processing effects do you expect according to the program option “--no-loops” for the presented source code search pattern?

I don't remember whether no loops looks at backward gotos. Maybe try --no-gotos.

julia

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw
Quoted 11 lines · Markus Elfring
Quoted 4 lines
Quoted 2 lines

Which data processing effects do you expect according to the program option “--no-loops” for the presented source code search pattern?

I don't remember whether no loops looks at backward gotos.

How will chances evolve to agree on corresponding information so that it can be integrated for a better software documentation?

Quoted 1 line

Maybe try --no-gotos.

Where is such a program parameter explained?

spatch --help. Like all the other command line arguments.

julia

Quoted 4 lines

Regards,
Markus

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 7 lines · Markus Elfring
Quoted 4 lines
Quoted 2 lines
Quoted 1 line

Maybe try --no-gotos.

Where is such a program parameter explained?

spatch --help. Like all the other command line arguments.

https://gitlab.inria.fr/coccinelle/coccinelle/-/blob/03a1af0a3316ddfc2b54d827b8b9627a841c85c9/enter.ml#L650-651

Would you expect that a more detailed explanation will appear also in the document “spatch_options.tex”?

I added an entry to this file.

julia

Quoted 6 lines

Are we still looking for more helpful guidance than the hint “drop all jumps derived from gotos - unsafe”?

Regards,
Markus

#9 lore raw

For the case of --no-loops, backward jumps are detected as loops for other pruposes. But they are maintained in the case of --no-loops. I'm not sure what encoding one would want. Should a backward goto just exit the function? Should it fall through to the next statement, as done for --no-gotos? --no-gotos is in general really nonsense. --no-loops for for, while etc loops does consider a subset of meaningful paths.

julia

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw
Quoted 3 lines · Markus Elfring
Quoted 1 line

For the case of --no-loops, backward jumps are detected as loops for other pruposes.

Which purposes do you imagine here?

Loops require the use of the CTL operator AW, not AU.

Quoted 5 lines
Quoted 3 lines

But they are maintained in the case of --no-loops.

How does such “maintenance” look like?

The edge connecting the goto to the label is present.

Quoted 17 lines
Quoted 2 lines

I'm not sure what encoding one would want.

I am curious how clarifications will evolve further.

Quoted 1 line

Should a backward goto just exit the function?

Will other development ideas become more reasonable?

Quoted 1 line

Should it fall through to the next statement, as done for --no-gotos?

I see a need that selected jumps would occasionally be skipped (or “ignored” for some data processing).

Quoted 7 lines
Quoted 1 line

--no-gotos is in general really nonsense.

Interesting view …

Quoted 1 line

--no-loops for for, while etc loops does consider a subset of meaningful paths.

How will software design approaches evolve accordingly?

As I said, I don't know what is the best thing to do. If you have an actual proposal., propose it. If you don't have a proposal, plase stop the discussion, because nothing is going to change.

julia

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw
Quoted 82 lines · Markus Elfring
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

For the case of --no-loops, backward jumps are detected as loops for other pruposes.

Which purposes do you imagine here?

Loops require the use of the CTL operator AW, not AU.

Thanks for such background information on computation tree logic.

Quoted 6 lines
Quoted 2 lines
Quoted 1 line

--no-loops for for, while etc loops does consider a subset of meaningful paths.

How will software design approaches evolve accordingly?

As I said, I don't know what is the best thing to do. If you have an actual proposal., propose it. If you don't have a proposal, plase stop the discussion, because nothing is going to change.

Will another clarification approach become helpful?

Do you find it easier to clarify a reduced test case?

Source file example:
// See also:
// * CWE-416: Use After Free
// https://cwe.mitre.org/data/definitions/416.html
//
// * MEM30-C: Do not access freed memory
// https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/memory-management-mem/mem30-c/

#include <stdlib.h>

struct my_point
{
int x, y;
};

void my_test(void)
{
// A few variables
size_t s = 0;
struct my_point * mp;

allocation:
mp = malloc(sizeof(*mp));
if (mp)
{
free(mp);
// Demonstration of a programming mistake
mp->x = 2;

// Trigger a repetition eventually
if (++s < 5)

    goto allocation;

}
}

SmPL script:
@display@
identifier i;
expression e;
@@
*i = malloc(...);
... when != i = e
*i->x = e

Questionable test result:
Markus_Elfring@Sonne:…/Projekte/Coccinelle/janitor> time /usr/bin/spatch --no-loops show_UAF_2.cocci ../Probe/demo-UAF2.c …

(quoted diff) +0 -2
@@ -19,12 +19,10 @@ void my_test(void)
  struct my_point * mp;
 
 allocation:
- mp = malloc(sizeof(*mp));
  if (mp)
  {
   free(mp);
   // Demonstration of a programming mistake
-  mp->x = 2;
 
   // Trigger a repetition eventually
   if (++s < 5)
Quoted 7 lines
real    0m0,078s
user    0m0,053s
sys     0m0,022s

How will development ideas evolve accordingly?

I don't know what the above is supposed to do. The semantic patch looks completely wrong to detect a use after free. One would expect thta a detection of use after free would mention free somewhere. But the obtained result looks completely correct for the provided semantic patch (as well as a hypothetical semantic patch that would check for use after free).

julia

A message that is not in the archive (sent off-list or not yet received): [email protected]

#15 lore raw
Quoted 24 lines · Markus Elfring
Quoted 5 lines
Quoted 1 line

How will development ideas evolve accordingly?

I don't know what the above is supposed to do. The semantic patch looks completely wrong to detect a use after free. One would expect thta a detection of use after free would mention free somewhere.

The following SmPL script variant expresses a known implementation detail explicitly.

@display@
identifier i;
expression e;
@@
*i = malloc(...);
... when != i = e
*free(i);
*i->x = e

Quoted 4 lines

But the
obtained result looks completely correct for the provided semantic patch (as well as a hypothetical semantic patch that would check for use after free).

Quoted 5 lines

The result for this reduced test shows so far that a single diff hunk is generated (while additional ones occurred according to the bigger implementation of the function “pnfs_update_layout”).
Function sizes probably influence hunk generation.
Will such case distinctions become more interesting?

If you want me to comment on something, you have to include both the semantic patch and the C code. I can't guess whether you have used again the C code that you provided in a previous email (where obtaining a single huk seemed fine). Please also provide precise information about the result you expect.

julia

A message that is not in the archive (sent off-list or not yet received): [email protected]

#17 lore raw
Quoted 14 lines · Markus Elfring
Quoted 5 lines
Quoted 2 lines

Function sizes probably influence hunk generation. Will such case distinctions become more interesting?

If you want me to comment on something, you have to include both the semantic patch and the C code.

The corresponding data should be available also by known mailing list archive interfaces, shouldn't they?

Quoted 3 lines

I can't guess whether you have used again
the C code that you provided in a previous email (where obtaining a single huk seemed fine).

Quoted 7 lines

This is the case for the discussion at the moment.

Quoted 2 lines

Please also provide precise information about the
result you expect.

We are trying to clarify different expectations for SmPL data processing with goto statements.

Please actually clarify your expectations. Don't just say that you didn't get what you expected. Also say what you expected to get. I can't guess what that is.

Please send one single mail with the semantic patch, the C file, and a precise description of what you find unsatisfactory about the result, ie what specific line should have been marked in a way that is different than the way it currently is.

julia

A message that is not in the archive (sent off-list or not yet received): [email protected]

#19 lore raw
Quoted 44 lines · Markus Elfring
Quoted 3 lines
Quoted 2 lines

We are trying to clarify different expectations for SmPL data processing with goto statements.

Please actually clarify your expectations. …

Would you find the following test result “reasonable”?

https://elixir.bootlin.com/linux/v7.1-rc4/source/fs/nfs/pnfs.c#L2128-L2385

Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> time /usr/bin/spatch --show-ctl-text --no-gotos …/Projekte/Coccinelle/janitor/show_UAF_1.cocci fs/nfs/pnfs.c …
@display@
identifier i;
expression e;
@@

*pnfs_put_layout_hdr*(*i*)*;
... WHEN != i = e

*trace_pnfs_update_layout*(*...*, *i*, *...*)

CTL =

(!EX(EX(EX(Exit))) &,
(Ex_ i .
((Ex _v . pnfs_put_layout_hdr(i);) &,
EX(E[(!After &

         (!(pnfs_put_layout_hdr(i); v
            InnerAnd(trace_pnfs_update_layout(..., i, ...)))
          & !(After v InnerAnd((Ex_ e . i = e)))))
      U InnerAnd((Ex _v . trace_pnfs_update_layout(..., i, ...)))]))))

diff =
…

(quoted diff) +0 -1
@@ -2216,7 +2216,6 @@ lookup_again:
                                           TASK_KILLABLE));
                if (IS_ERR(lseg))
                        goto out_put_layout_hdr;
-               pnfs_put_layout_hdr(lo);
                goto lookup_again;
        }
 
@@ -2229,22 +2228,14 @@ lookup_again:
                dprintk("%s wait for layoutreturn\n", __func__);
                lseg = ERR_PTR(pnfs_prepare_to_retry_layoutget(lo));

Review lookup_again: · line 2240

Quoted 10 lines
(quoted diff) +0 -6
                if (!IS_ERR(lseg)) {
-                       pnfs_put_layout_hdr(lo);
                        dprintk("%s retrying\n", __func__);
-                       trace_pnfs_update_layout(ino, pos, count, iomode, lo,
-                                                lseg,
-                                                PNFS_UPDATE_LAYOUT_RETRY);
                        goto lookup_again;
                }
-               trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,
-                                        PNFS_UPDATE_LAYOUT_RETURN);

When you use * there s no way to go what matches with what. But this line looks questionable because there isn't an obvious path from the pnfs_put_layout_hdr above to the trace_pnfs_update_layout here. You get this because of the no-gotos flag not taking the goto lookup_again;

julia

Quoted 87 lines
(quoted diff) +0 -16
                goto out_put_layout_hdr;
        }
 
        lseg = pnfs_find_lseg(lo, &arg, strict_iomode);
        if (lseg) {
-               trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,
-                               PNFS_UPDATE_LAYOUT_FOUND_CACHED);
                goto out_unlock;
        }
 
@@ -2268,7 +2259,6 @@ lookup_again:
                                                TASK_KILLABLE));
                        if (IS_ERR(lseg))
                                goto out_put_layout_hdr;
-                       pnfs_put_layout_hdr(lo);
                        dprintk("%s retrying\n", __func__);
                        goto lookup_again;
                }
@@ -2280,12 +2270,8 @@ lookup_again:
                                        NULL, &stateid, NULL);
                if (status != 0) {
                        lseg = ERR_PTR(status);
-                       trace_pnfs_update_layout(ino, pos, count,
-                                       iomode, lo, lseg,
-                                       PNFS_UPDATE_LAYOUT_INVALID_OPEN);
                        nfs4_schedule_stateid_recovery(server, ctx->state);
                        pnfs_clear_first_layoutget(lo);
-                       pnfs_put_layout_hdr(lo);
                        goto lookup_again;
                }
                spin_lock(&ino->i_lock);
@@ -2294,8 +2280,6 @@ lookup_again:
        }
 
        if (pnfs_layoutgets_blocked(lo)) {
-               trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,
-                               PNFS_UPDATE_LAYOUT_BLOCKED);
                goto out_unlock;
        }
        nfs_layoutget_begin(lo);
@@ -2314,8 +2298,6 @@ lookup_again:
        lgp = pnfs_alloc_init_layoutget_args(ino, ctx, &stateid, &arg, gfp_flags);
        if (!lgp) {
                lseg = ERR_PTR(-ENOMEM);
-               trace_pnfs_update_layout(ino, pos, count, iomode, lo, NULL,
-                                        PNFS_UPDATE_LAYOUT_NOMEM);
                nfs_layoutget_end(lo);
                goto out_put_layout_hdr;
        }
@@ -2324,8 +2306,6 @@ lookup_again:
        pnfs_get_layout_hdr(lo);
 
        lseg = nfs4_proc_layoutget(lgp, &exception);
-       trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,
-                                PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET);
        nfs_layoutget_end(lo);
        if (IS_ERR(lseg)) {
                switch(PTR_ERR(lseg)) {
@@ -2356,7 +2336,6 @@ lookup_again:
                                pnfs_clear_first_layoutget(lo);
                        trace_pnfs_update_layout(ino, pos, count,
                                iomode, lo, lseg, PNFS_UPDATE_LAYOUT_RETRY);
-                       pnfs_put_layout_hdr(lo);
                        goto lookup_again;
                }
        } else {
@@ -2366,8 +2345,6 @@ lookup_again:
 out_put_layout_hdr:
        if (first)
                pnfs_clear_first_layoutget(lo);
-       trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,
-                                PNFS_UPDATE_LAYOUT_EXIT);
        pnfs_put_layout_hdr(lo);
 out:
        dprintk("%s: inode %s/%llu pNFS layout segment %s for "
real    0m1,038s
user    0m0,997s
sys     0m0,036s

Are such technical details still questionable?

Regards,
Markus

A message that is not in the archive (sent off-list or not yet received): [email protected]

#21 lore raw
Quoted 15 lines · Markus Elfring

…

Quoted 6 lines
Quoted 6 lines
(quoted diff) +0 -1
@@ -2229,22 +2228,14 @@ lookup_again:
                dprintk("%s wait for layoutreturn\n", __func__);
                lseg = ERR_PTR(pnfs_prepare_to_retry_layoutget(lo));
                if (!IS_ERR(lseg)) {
-                       pnfs_put_layout_hdr(lo);
                        dprintk("%s retrying\n", __func__);
Quoted 8 lines

Review lookup_again: · line 2240

Quoted 7 lines
(quoted diff) +0 -5
-                       trace_pnfs_update_layout(ino, pos, count, iomode, lo,
-                                                lseg,
-                                                PNFS_UPDATE_LAYOUT_RETRY);
                        goto lookup_again;
                }
-               trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,
-                                        PNFS_UPDATE_LAYOUT_RETURN);

When you use * there s no way to go what matches with what.

Sorry, typo here: there's no way to know what matches with what

Quoted 3 lines

How would anybody get such an information from the software documentation with sufficient certainty (according to usage of SmPL asterisks)?

Well, * puts a - on every line that contains a matched token. - is a single character and there can be multiple matches, so it seems pretty obvious.

Quoted 5 lines
Quoted 4 lines

But this line
looks questionable because there isn't an obvious path from the pnfs_put_layout_hdr above to the trace_pnfs_update_layout here.

Quoted 8 lines

Will any more users of the Coccinelle software find such a view interesting?

Quoted 2 lines

You get
this because of the no-gotos flag not taking the goto lookup_again;

Will further clarifications become relevant also for any related program parameters like “--no-loops”?

--no-loops doesn't introduce non existent paths. It only removes the back edges in loop operators.

julia

A message that is not in the archive (sent off-list or not yet received): [email protected]

#23 lore raw
Quoted 10 lines · Markus Elfring
Quoted 4 lines
Quoted 2 lines

How would anybody get such an information from the software documentation with sufficient certainty (according to usage of SmPL asterisks)?

Well, * puts a - on every line that contains a matched token.

Fine.

The clarification is continuing.

Quoted 8 lines
Quoted 3 lines

- is a
single character and there can be multiple matches, so it seems pretty obvious.

The discussion is evolving around the source code search for a selected pair of function calls.
Did you notice that more code was marked than intended because of long lines? Are other application concerns more relevant here?

When there is a token that is matched by *, the whole line is marked with -. In the patch notation there is no way to mark only part of a line. It is done this way ebcause in emacs it is possible to jump directly from a diff line to the affected line in the code. If you want a different behavior, you can use position variables to print information about the precise matched position.

Quoted 4 lines
Quoted 3 lines

--no-loops doesn't introduce non existent paths. It only removes the back edges in loop operators.

Did you indicate uncertainty about corresponding software functionality?

No uncertainty.

julia

A message that is not in the archive (sent off-list or not yet received): [email protected]

#25 lore raw
Quoted 9 lines · Markus Elfring
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines

--no-loops doesn't introduce non existent paths. It only removes the back edges in loop operators.

Did you indicate uncertainty about corresponding software functionality?

No uncertainty.

How does this feedback fit to the information “I don't remember whether no loops looks at backward gotos.” from 2026-05-23?
https://lore.kernel.org/cocci/[email protected]/
https://sympa.inria.fr/sympa/arc/cocci/2026-05/msg00020.html

I didn't remember, I looked at the code, and I reported back to you on it. --no-loops has no impact on the handling of backwards jumps. It only works on structured loops, in which case the back edge is simply deleted.

julia

A message that is not in the archive (sent off-list or not yet received): [email protected]

#27 lore raw
Quoted 50 lines · Markus Elfring
Quoted 1 line

Loops require the use of the CTL operator AW, not AU.

Further development considerations might become more interesting for desirable clarifications according to computation tree logic variants.

@display@
identifier i;
expression e;
@@
*i = malloc(...);
... when != i = e
*free(i);
*i->x = e

Markus_Elfring@Sonne:/home/altes_Heim2/elfring/Projekte/Coccinelle/janitor> /usr/bin/spatch --show-ctl-text --no-loops show_UAF_3.cocci ../Probe/demo-UAF2.c …
CTL =

(!EX(EX(EX(Exit))) &,
(Ex_ i .
((Ex _v . i = malloc(...);) &,
EX((Ex_ e .

      E[(!After &
         (!(i = malloc(...); v free(i);) & !(After v InnerAnd(i = e))))
       U
       ((Ex _v . free(i);) &,
        EX(InnerAnd(((Ex_ _pos . (Ex _v . i->x = e)) v
                    (Ex_ _pos .
                     ((Ex_ _E2_0 . (Ex _v . i[_E2_0].x = e)) &
                      !Uncheck(i->x = e)))))))])))))

diff =
…

(quoted diff) +0 -3
@@ -19,12 +19,9 @@ void my_test(void)
  struct my_point * mp;
 
 allocation:
- mp = malloc(sizeof(*mp));
  if (mp)
  {
-  free(mp);
   // Demonstration of a programming mistake
-  mp->x = 2;
 
   // Trigger a repetition eventually
   if (++s < 5)
Quoted 1 line

Where is the mentioned CTL operator applied here?

Nowhere. Loops are only an issue for the forall case, because we need to ignore the path that goes around the loop infinitely. You semantic patch doesn't use any forall path operators, only exists.

julia