From: Victor Gambier <victor.gambier@inria.fr>
To: devnoname120 <devnoname120@gmail.com>,
Julia Lawall <julia.lawall@inria.fr>
Cc: cocci@inria.fr
Subject: Re: [cocci] [HELP] Using macro `randomized_struct_fields_end` as context?
Date: Wed, 16 Jul 2025 14:02:44 +0200 [thread overview]
Message-ID: <e9bc7027-5eba-461d-a659-4037849e3760@inria.fr> (raw)
In-Reply-To: <033af1c6-e410-4ccb-8bed-41a308d66f1e@Spark>
[-- Attachment #1: Type: text/plain, Size: 4445 bytes --]
Thanks for all the information. You need two things:
1. A version of Coccinelle that has Julia's recent patch (b00c5adb1a48).
It is available on GitLab, but not on Github, and you'd need to compile
it yourself or wait until a new version is released. Let me know if you
need help with that, it shouldn't be too time-consuming.
2. Remove the "depends" line. This script can work:
```
@@
field f : script:python () { f == "randomized_struct_fields_end" };
@@
struct task_struct {
...
+#ifdef CONFIG_KSU_SUSFS
+ u64 susfs_task_state;
+ u64 susfs_last_fake_mnt_id;
+#endif
f
...
};
```
(Maybe this was only necessary on my end, but I suggest you try that if
it does not work.)
I can confirm that script with that version of Coccinelle works.
As for the original issue with the MacOS brew version, I unfortunately
don't have reliable access to a MacOS machine to figure out the issue.
Let me know if you'd like to spend some time troubleshooting that.
Victor
On 14/07/2025 20:00, devnoname120 wrote:
> Here is the information that you requested:
>
> ❯ paul@ubuntu:/Users/paul$ spatch --version
> spatch version 1.3 compiled with OCaml version 5.3.0
> Flags passed to the configure script: --prefix=/usr --sysconfdir=/etc
> --libdir=/usr/lib --enable-ocaml --enable-python --with-python=python3
> --enable-opt
> OCaml scripting support: yes
> Python scripting support: yes
> Syntax of regular expressions: Str
>
> ❯ paul@ubuntu:/Users/paul$ apt info coccinelle
> Package: coccinelle
> Version: 1.3.0.deb-1build2
> Priority: optional
> Section: universe/devel
> Origin: Ubuntu
> Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
> Original-Maintainer: Debian OCaml Maintainers
> <debian-ocaml-maint@lists.debian.org>
> Bugs: https://bugs.launchpad.net/ubuntu/+filebug
> Installed-Size: 59.0 MB
> Depends: libparmap-ocaml, ocaml-findlib, libstdcompat-ocaml-iy6x7,
> libstdlib-ocaml-fxjy5, python3:any, libc6 (>= 2.38), libzstd1 (>= 1.5.5)
> Suggests: coccinelle-doc, vim-addon-manager
> Homepage: http://coccinelle.lip6.fr
> Download-Size: 13.8 MB
> APT-Manual-Installed: yes
> APT-Sources: http://ports.ubuntu.com/ubuntu-ports plucky/universe
> arm64 Packages
> Description: semantic patching tool for C
> Coccinelle is a program matching and transformation tool for C.
> The programmer describes the code to match and the transformation to
> perform as a semantic patch, which looks like a standard patch, but can
> transform multiple files at any number of code sites.
> Thank you,
> Paul
> On 13 Jul 2025 at 22:58 +0200, Julia Lawall <julia.lawall@inria.fr>,
> wrote:
>
>
> On Sun, 13 Jul 2025, devnoname120 wrote:
>
> I just attempted to run this command on Ubuntu and although it
> didn't return
> any error, no change was done:
>
> ❯ spatch --sp-file include/linux/sched.h.cocci --in-place
> --linux-spacing
> include/linux/sched.h
> init_defs_builtins: /usr/lib/coccinelle/standard.h
> SPECIAL NAMES: adding u64 as a type
> HANDLING: include/linux/sched.h
>
> Here is the content of `include/linux/sched.h.cocci`:
>
> ```
> @depends on file in "include/linux/sched.h" exists@
> field f : script:python () { f ==
> "randomized_struct_fields_end" };
> @@
>
> struct task_struct {
> ...
> +#ifdef CONFIG_KSU_SUSFS
> + u64 susfs_task_state;
> + u64 susfs_last_fake_mnt_id;
> +#endif
> f
> ...
> };
> ```
>
> The `include/linux/sched.h` file remains the same as before.
>
>
> It all works fine for me. What version of Coccinelle do you have?
>
> julia
>
>
>
> Thank you,
> Paul
> On Jun 30, 2025 at 10:52 +0200, Julia Lawall
> <julia.lawall@inria.fr>, wrote:
> randomized_struct_fields_end will soon be supported in the C
> parser. It
> is not currently supported in the semantic patch parser, but you
> can get
> the same effect as illustrated by the example below.
>
> I will let you know when this is all available on github.
>
> julia
>
>
> @@
> field f : script:python () { f == "randomized_struct_fields_end"
> };
> @@
>
> struct task_struct {
> ...
> + int something;
> f
> ...
> };
>
>
[-- Attachment #2: Type: text/html, Size: 8280 bytes --]
prev parent reply other threads:[~2025-07-16 12:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-29 17:04 [cocci] [HELP] Using macro `randomized_struct_fields_end` as context? devnoname120
2025-06-29 17:26 ` Julia Lawall
2025-06-29 17:41 ` devnoname120
2025-06-29 18:58 ` Julia Lawall
2025-06-29 19:19 ` devnoname120
2025-06-29 19:18 ` Julia Lawall
2025-06-29 19:27 ` devnoname120
2025-06-29 20:11 ` Julia Lawall
2025-06-30 8:51 ` Julia Lawall
[not found] ` <5d6b297d-2139-4732-acbd-92270ecfd4e7@Spark>
2025-07-07 10:15 ` Victor Gambier
2025-07-13 20:34 ` devnoname120
[not found] ` <68edca4d-74e7-4b83-9813-03d8fd7eae4e@Spark>
2025-07-13 20:58 ` Julia Lawall
[not found] ` <033af1c6-e410-4ccb-8bed-41a308d66f1e@Spark>
2025-07-16 12:02 ` Victor Gambier [this message]
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=e9bc7027-5eba-461d-a659-4037849e3760@inria.fr \
--to=victor.gambier@inria.fr \
--cc=cocci@inria.fr \
--cc=devnoname120@gmail.com \
--cc=julia.lawall@inria.fr \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).