public inbox for cocci@systeme.lip6.fr
 help / color / mirror / Atom feed
* [cocci] [PATCH v6 5/5] coccinelle: Add kmalloc_objs conversion script
       [not found] <20251203233029.it.641-kees@kernel.org>
@ 2025-12-03 23:30 ` Kees Cook
  2025-12-11 14:15   ` Markus Elfring
                     ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Kees Cook @ 2025-12-03 23:30 UTC (permalink / raw)
  To: Vlastimil Babka
  Cc: Kees Cook, Julia Lawall, Nicolas Palix, cocci, Linus Torvalds,
	Randy Dunlap, Miguel Ojeda, Przemek Kitszel, Gustavo A. R. Silva,
	Matthew Wilcox, John Hubbard, Joe Perches, Christoph Lameter,
	Marco Elver, Vegard Nossum, Pekka Enberg, David Rientjes,
	Joonsoo Kim, Andrew Morton, Roman Gushchin, Harry Yoo,
	Bill Wendling, Justin Stitt, Jann Horn, Greg Kroah-Hartman,
	Sasha Levin, linux-mm, Nathan Chancellor, Peter Zijlstra,
	Nick Desaulniers, Jonathan Corbet, Jakub Kicinski, Yafang Shao,
	Tony Ambardar, Alexander Lobakin, Jan Hendrik Farr,
	Alexander Potapenko, linux-kernel, linux-hardening, linux-doc,
	llvm

Finds and converts sized kmalloc-family of allocations into the
typed kmalloc_obj-family of allocations.

Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Julia Lawall <Julia.Lawall@inria.fr>
Cc: Nicolas Palix <nicolas.palix@imag.fr>
Cc: cocci@inria.fr
---
 scripts/coccinelle/api/kmalloc_objs.cocci | 109 ++++++++++++++++++++++
 1 file changed, 109 insertions(+)
 create mode 100644 scripts/coccinelle/api/kmalloc_objs.cocci

diff --git a/scripts/coccinelle/api/kmalloc_objs.cocci b/scripts/coccinelle/api/kmalloc_objs.cocci
new file mode 100644
index 000000000000..916cc3a661b9
--- /dev/null
+++ b/scripts/coccinelle/api/kmalloc_objs.cocci
@@ -0,0 +1,109 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/// Use kmalloc_obj family of macros for allocations
+///
+// Confidence: High
+// Options: --include-headers-for-types --all-includes --include-headers --keep-comments
+
+virtual patch
+
+@initialize:python@
+@@
+import sys
+
+def alloc_array(name):
+	func = "FAILED_RENAME"
+	if name == "kmalloc_array":
+		func = "kmalloc_objs"
+	elif name == "kvmalloc_array":
+		func = "kvmalloc_objs"
+	elif name == "kcalloc":
+		func = "kzalloc_objs"
+	elif name == "kvcalloc":
+		func = "kvzalloc_objs"
+	else:
+		print(f"Unknown transform for {name}", file=sys.stderr)
+	return func
+
+// This excludes anything that is assigning to or from integral types or
+// string literals. Everything else gets the sizeof() extracted for the
+// kmalloc_obj() type/var argument. sizeof(void *) is also excluded because
+// it will need case-by-case double-checking to make sure the right type is
+// being assigned.
+@direct depends on patch && !(file in "tools") && !(file in "samples")@
+typedef u8, u16, u32, u64;
+typedef __u8, __u16, __u32, __u64;
+typedef uint8_t, uint16_t, uint32_t, uint64_t;
+typedef __le16, __le32, __le64;
+typedef __be16, __be32, __be64;
+type INTEGRAL = {u8,__u8,uint8_t,char,unsigned char,
+		 u16,__u16,uint16_t,unsigned short,
+		 u32,__u32,uint32_t,unsigned int,
+		 u64,__u64,uint64_t,unsigned long,
+		 __le16,__le32,__le64,__be16,__be32,__be64};
+char [] STRING;
+INTEGRAL *BYTES;
+type TYPE;
+expression VAR;
+expression GFP;
+expression COUNT;
+expression FLEX;
+expression E;
+identifier ALLOC =~ "^kv?[mz]alloc$";
+fresh identifier ALLOC_OBJ = ALLOC ## "_obj";
+fresh identifier ALLOC_FLEX = ALLOC ## "_flex";
+identifier ALLOC_ARRAY = {kmalloc_array,kvmalloc_array,kcalloc,kvcalloc};
+fresh identifier ALLOC_OBJS = script:python(ALLOC_ARRAY) { alloc_array(ALLOC_ARRAY) };
+@@
+
+(
+-	VAR = ALLOC((sizeof(*VAR)), GFP)
++	VAR = ALLOC_OBJ(*VAR, GFP)
+|
+	ALLOC((\(sizeof(STRING)\|sizeof(INTEGRAL)\|sizeof(INTEGRAL *)\)), GFP)
+|
+	BYTES = ALLOC((sizeof(E)), GFP)
+|
+	BYTES = ALLOC((sizeof(TYPE)), GFP)
+|
+	ALLOC((sizeof(void *)), GFP)
+|
+-	ALLOC((sizeof(E)), GFP)
++	ALLOC_OBJ(E, GFP)
+|
+-	ALLOC((sizeof(TYPE)), GFP)
++	ALLOC_OBJ(TYPE, GFP)
+|
+	ALLOC_ARRAY(COUNT, (\(sizeof(STRING)\|sizeof(INTEGRAL)\|sizeof(INTEGRAL *)\)), GFP)
+|
+	BYTES = ALLOC_ARRAY(COUNT, (sizeof(E)), GFP)
+|
+	BYTES = ALLOC_ARRAY(COUNT, (sizeof(TYPE)), GFP)
+|
+	ALLOC_ARRAY((\(sizeof(STRING)\|sizeof(INTEGRAL)\|sizeof(INTEGRAL *)\)), COUNT, GFP)
+|
+	BYTES = ALLOC_ARRAY((sizeof(E)), COUNT, GFP)
+|
+	BYTES = ALLOC_ARRAY((sizeof(TYPE)), COUNT, GFP)
+|
+	ALLOC_ARRAY(COUNT, (sizeof(void *)), GFP)
+|
+	ALLOC_ARRAY((sizeof(void *)), COUNT, GFP)
+|
+-	ALLOC_ARRAY(COUNT, (sizeof(E)), GFP)
++	ALLOC_OBJS(E, COUNT, GFP)
+|
+-	ALLOC_ARRAY(COUNT, (sizeof(TYPE)), GFP)
++	ALLOC_OBJS(TYPE, COUNT, GFP)
+|
+-	ALLOC_ARRAY((sizeof(E)), COUNT, GFP)
++	ALLOC_OBJS(E, COUNT, GFP)
+|
+-	ALLOC_ARRAY((sizeof(TYPE)), COUNT, GFP)
++	ALLOC_OBJS(TYPE, COUNT, GFP)
+|
+-	ALLOC(struct_size(VAR, FLEX, COUNT), GFP)
++	ALLOC_FLEX(*VAR, FLEX, COUNT, GFP)
+|
+-	ALLOC(struct_size_t(TYPE, FLEX, COUNT), GFP)
++	ALLOC_FLEX(TYPE, FLEX, COUNT, GFP)
+)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH v6 5/5] coccinelle: Add kmalloc_objs conversion script
  2025-12-03 23:30 ` [cocci] [PATCH v6 5/5] coccinelle: Add kmalloc_objs conversion script Kees Cook
@ 2025-12-11 14:15   ` Markus Elfring
  2025-12-16 21:56   ` Julia Lawall
  2026-02-22  4:13   ` Eric Biggers
  2 siblings, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2025-12-11 14:15 UTC (permalink / raw)
  To: Kees Cook, cocci, linux-hardening, linux-mm, Julia Lawall,
	Nicolas Palix, Vlastimil Babka
  Cc: LKML, linux-doc, llvm, Alexander Lobakin, Alexander Potapenko,
	Andrew Morton, Bill Wendling, Christoph Lameter, David Rientjes,
	Greg Kroah-Hartman, Gustavo A. R. Silva, Harry Yoo,
	Jakub Kicinski, Jan Hendrik Farr, Jann Horn, Jonathan Corbet,
	Joonsoo Kim, Justin Stitt, Linus Torvalds, Marco Elver,
	Matthew Wilcox, Miguel Ojeda, Nathan Chancellor, Nick Desaulniers,
	Pekka Enberg, Peter Zijlstra, Przemek Kitszel, Randy Dunlap,
	Roman Gushchin, Sasha Levin, Tony Ambardar, Vegard Nossum,
	Yafang Shao

> Finds and converts sized kmalloc-family of allocations into the
> typed kmalloc_obj-family of allocations.

Can previous patch review concerns get more development attention anyhow?
https://lore.kernel.org/cocci/71d406fb-9fb1-44a9-912a-7a0d270b9577@web.de/
https://sympa.inria.fr/sympa/arc/cocci/2025-11/msg00066.html

Regards,
Markus

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH v6 5/5] coccinelle: Add kmalloc_objs conversion script
  2025-12-03 23:30 ` [cocci] [PATCH v6 5/5] coccinelle: Add kmalloc_objs conversion script Kees Cook
  2025-12-11 14:15   ` Markus Elfring
@ 2025-12-16 21:56   ` Julia Lawall
  2026-02-22  4:13   ` Eric Biggers
  2 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2025-12-16 21:56 UTC (permalink / raw)
  To: Kees Cook
  Cc: Vlastimil Babka, Julia Lawall, Nicolas Palix, cocci,
	Linus Torvalds, Randy Dunlap, Miguel Ojeda, Przemek Kitszel,
	Gustavo A. R. Silva, Matthew Wilcox, John Hubbard, Joe Perches,
	Christoph Lameter, Marco Elver, Vegard Nossum, Pekka Enberg,
	David Rientjes, Joonsoo Kim, Andrew Morton, Roman Gushchin,
	Harry Yoo, Bill Wendling, Justin Stitt, Jann Horn,
	Greg Kroah-Hartman, Sasha Levin, linux-mm, Nathan Chancellor,
	Peter Zijlstra, Nick Desaulniers, Jonathan Corbet, Jakub Kicinski,
	Yafang Shao, Tony Ambardar, Alexander Lobakin, Jan Hendrik Farr,
	Alexander Potapenko, linux-kernel, linux-hardening, linux-doc,
	llvm



On Wed, 3 Dec 2025, Kees Cook wrote:

> Finds and converts sized kmalloc-family of allocations into the
> typed kmalloc_obj-family of allocations.

The combination of the use of a regular expression to find the function
names and the big disjunction makes this unnecessarily slow.  I will try
to propose something shortly.

julia

>
> Signed-off-by: Kees Cook <kees@kernel.org>
> ---
> Cc: Julia Lawall <Julia.Lawall@inria.fr>
> Cc: Nicolas Palix <nicolas.palix@imag.fr>
> Cc: cocci@inria.fr
> ---
>  scripts/coccinelle/api/kmalloc_objs.cocci | 109 ++++++++++++++++++++++
>  1 file changed, 109 insertions(+)
>  create mode 100644 scripts/coccinelle/api/kmalloc_objs.cocci
>
> diff --git a/scripts/coccinelle/api/kmalloc_objs.cocci b/scripts/coccinelle/api/kmalloc_objs.cocci
> new file mode 100644
> index 000000000000..916cc3a661b9
> --- /dev/null
> +++ b/scripts/coccinelle/api/kmalloc_objs.cocci
> @@ -0,0 +1,109 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/// Use kmalloc_obj family of macros for allocations
> +///
> +// Confidence: High
> +// Options: --include-headers-for-types --all-includes --include-headers --keep-comments
> +
> +virtual patch
> +
> +@initialize:python@
> +@@
> +import sys
> +
> +def alloc_array(name):
> +	func = "FAILED_RENAME"
> +	if name == "kmalloc_array":
> +		func = "kmalloc_objs"
> +	elif name == "kvmalloc_array":
> +		func = "kvmalloc_objs"
> +	elif name == "kcalloc":
> +		func = "kzalloc_objs"
> +	elif name == "kvcalloc":
> +		func = "kvzalloc_objs"
> +	else:
> +		print(f"Unknown transform for {name}", file=sys.stderr)
> +	return func
> +
> +// This excludes anything that is assigning to or from integral types or
> +// string literals. Everything else gets the sizeof() extracted for the
> +// kmalloc_obj() type/var argument. sizeof(void *) is also excluded because
> +// it will need case-by-case double-checking to make sure the right type is
> +// being assigned.
> +@direct depends on patch && !(file in "tools") && !(file in "samples")@
> +typedef u8, u16, u32, u64;
> +typedef __u8, __u16, __u32, __u64;
> +typedef uint8_t, uint16_t, uint32_t, uint64_t;
> +typedef __le16, __le32, __le64;
> +typedef __be16, __be32, __be64;
> +type INTEGRAL = {u8,__u8,uint8_t,char,unsigned char,
> +		 u16,__u16,uint16_t,unsigned short,
> +		 u32,__u32,uint32_t,unsigned int,
> +		 u64,__u64,uint64_t,unsigned long,
> +		 __le16,__le32,__le64,__be16,__be32,__be64};
> +char [] STRING;
> +INTEGRAL *BYTES;
> +type TYPE;
> +expression VAR;
> +expression GFP;
> +expression COUNT;
> +expression FLEX;
> +expression E;
> +identifier ALLOC =~ "^kv?[mz]alloc$";
> +fresh identifier ALLOC_OBJ = ALLOC ## "_obj";
> +fresh identifier ALLOC_FLEX = ALLOC ## "_flex";
> +identifier ALLOC_ARRAY = {kmalloc_array,kvmalloc_array,kcalloc,kvcalloc};
> +fresh identifier ALLOC_OBJS = script:python(ALLOC_ARRAY) { alloc_array(ALLOC_ARRAY) };
> +@@
> +
> +(
> +-	VAR = ALLOC((sizeof(*VAR)), GFP)
> ++	VAR = ALLOC_OBJ(*VAR, GFP)
> +|
> +	ALLOC((\(sizeof(STRING)\|sizeof(INTEGRAL)\|sizeof(INTEGRAL *)\)), GFP)
> +|
> +	BYTES = ALLOC((sizeof(E)), GFP)
> +|
> +	BYTES = ALLOC((sizeof(TYPE)), GFP)
> +|
> +	ALLOC((sizeof(void *)), GFP)
> +|
> +-	ALLOC((sizeof(E)), GFP)
> ++	ALLOC_OBJ(E, GFP)
> +|
> +-	ALLOC((sizeof(TYPE)), GFP)
> ++	ALLOC_OBJ(TYPE, GFP)
> +|
> +	ALLOC_ARRAY(COUNT, (\(sizeof(STRING)\|sizeof(INTEGRAL)\|sizeof(INTEGRAL *)\)), GFP)
> +|
> +	BYTES = ALLOC_ARRAY(COUNT, (sizeof(E)), GFP)
> +|
> +	BYTES = ALLOC_ARRAY(COUNT, (sizeof(TYPE)), GFP)
> +|
> +	ALLOC_ARRAY((\(sizeof(STRING)\|sizeof(INTEGRAL)\|sizeof(INTEGRAL *)\)), COUNT, GFP)
> +|
> +	BYTES = ALLOC_ARRAY((sizeof(E)), COUNT, GFP)
> +|
> +	BYTES = ALLOC_ARRAY((sizeof(TYPE)), COUNT, GFP)
> +|
> +	ALLOC_ARRAY(COUNT, (sizeof(void *)), GFP)
> +|
> +	ALLOC_ARRAY((sizeof(void *)), COUNT, GFP)
> +|
> +-	ALLOC_ARRAY(COUNT, (sizeof(E)), GFP)
> ++	ALLOC_OBJS(E, COUNT, GFP)
> +|
> +-	ALLOC_ARRAY(COUNT, (sizeof(TYPE)), GFP)
> ++	ALLOC_OBJS(TYPE, COUNT, GFP)
> +|
> +-	ALLOC_ARRAY((sizeof(E)), COUNT, GFP)
> ++	ALLOC_OBJS(E, COUNT, GFP)
> +|
> +-	ALLOC_ARRAY((sizeof(TYPE)), COUNT, GFP)
> ++	ALLOC_OBJS(TYPE, COUNT, GFP)
> +|
> +-	ALLOC(struct_size(VAR, FLEX, COUNT), GFP)
> ++	ALLOC_FLEX(*VAR, FLEX, COUNT, GFP)
> +|
> +-	ALLOC(struct_size_t(TYPE, FLEX, COUNT), GFP)
> ++	ALLOC_FLEX(TYPE, FLEX, COUNT, GFP)
> +)
> --
> 2.34.1
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH v6 5/5] coccinelle: Add kmalloc_objs conversion script
  2025-12-03 23:30 ` [cocci] [PATCH v6 5/5] coccinelle: Add kmalloc_objs conversion script Kees Cook
  2025-12-11 14:15   ` Markus Elfring
  2025-12-16 21:56   ` Julia Lawall
@ 2026-02-22  4:13   ` Eric Biggers
  2026-02-22  7:12     ` Kees Cook
  2026-02-22  9:31     ` Julia Lawall
  2 siblings, 2 replies; 6+ messages in thread
From: Eric Biggers @ 2026-02-22  4:13 UTC (permalink / raw)
  To: Kees Cook
  Cc: Vlastimil Babka, Julia Lawall, Nicolas Palix, cocci,
	Linus Torvalds, Randy Dunlap, Miguel Ojeda, Przemek Kitszel,
	Gustavo A. R. Silva, Matthew Wilcox, John Hubbard, Joe Perches,
	Christoph Lameter, Marco Elver, Vegard Nossum, Pekka Enberg,
	David Rientjes, Joonsoo Kim, Andrew Morton, Roman Gushchin,
	Harry Yoo, Bill Wendling, Justin Stitt, Jann Horn,
	Greg Kroah-Hartman, Sasha Levin, linux-mm, Nathan Chancellor,
	Peter Zijlstra, Nick Desaulniers, Jonathan Corbet, Jakub Kicinski,
	Yafang Shao, Tony Ambardar, Alexander Lobakin, Jan Hendrik Farr,
	Alexander Potapenko, linux-kernel, linux-hardening, linux-doc,
	llvm

On Wed, Dec 03, 2025 at 03:30:35PM -0800, Kees Cook wrote:
> Finds and converts sized kmalloc-family of allocations into the
> typed kmalloc_obj-family of allocations.
> 
> Signed-off-by: Kees Cook <kees@kernel.org>
> ---
> Cc: Julia Lawall <Julia.Lawall@inria.fr>
> Cc: Nicolas Palix <nicolas.palix@imag.fr>
> Cc: cocci@inria.fr
> ---
>  scripts/coccinelle/api/kmalloc_objs.cocci | 109 ++++++++++++++++++++++
>  1 file changed, 109 insertions(+)
>  create mode 100644 scripts/coccinelle/api/kmalloc_objs.cocci

Is there a way to reproduce commit 69050f8d6d075dc using this semantic
patch as claimed?  I spend a while installing the latest version of
spatch (which was quite hard to do due to all the unusual dependencies),
but it complains that no rules apply:

$ /usr/local/bin/spatch --sp-file scripts/coccinelle/api/kmalloc_objs.cocci --dir . --in-place
init_defs_builtins: /usr/local/lib/coccinelle/standard.h
SPECIAL NAMES: adding u8 as a type
SPECIAL NAMES: adding u16 as a type
SPECIAL NAMES: adding u32 as a type
SPECIAL NAMES: adding u64 as a type
SPECIAL NAMES: adding __u8 as a type
SPECIAL NAMES: adding __u16 as a type
SPECIAL NAMES: adding __u32 as a type
SPECIAL NAMES: adding __u64 as a type
SPECIAL NAMES: adding uint8_t as a type
SPECIAL NAMES: adding uint16_t as a type
SPECIAL NAMES: adding uint32_t as a type
SPECIAL NAMES: adding uint64_t as a type
SPECIAL NAMES: adding uchar as a type
SPECIAL NAMES: adding ushort as a type
SPECIAL NAMES: adding uint as a type
SPECIAL NAMES: adding ulong as a type
SPECIAL NAMES: adding __le16 as a type
SPECIAL NAMES: adding __le32 as a type
SPECIAL NAMES: adding __le64 as a type
SPECIAL NAMES: adding __be16 as a type
SPECIAL NAMES: adding __be32 as a type
SPECIAL NAMES: adding __be64 as a type
SPECIAL NAMES: adding wchar_t as a type
No rules apply.  Perhaps your semantic patch doesn't contain any +/-/* code, or you have a failed dependency.  If the problem is not clear, try --debug-parse-cocci or check whether any virtual rules (e.g., patch) should be defined.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH v6 5/5] coccinelle: Add kmalloc_objs conversion script
  2026-02-22  4:13   ` Eric Biggers
@ 2026-02-22  7:12     ` Kees Cook
  2026-02-22  9:31     ` Julia Lawall
  1 sibling, 0 replies; 6+ messages in thread
From: Kees Cook @ 2026-02-22  7:12 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Vlastimil Babka, Julia Lawall, Nicolas Palix, cocci,
	Linus Torvalds, Randy Dunlap, Miguel Ojeda, Przemek Kitszel,
	Gustavo A. R. Silva, Matthew Wilcox, John Hubbard, Joe Perches,
	Christoph Lameter, Marco Elver, Vegard Nossum, Pekka Enberg,
	David Rientjes, Joonsoo Kim, Andrew Morton, Roman Gushchin,
	Harry Yoo, Bill Wendling, Justin Stitt, Jann Horn,
	Greg Kroah-Hartman, Sasha Levin, linux-mm, Nathan Chancellor,
	Peter Zijlstra, Nick Desaulniers, Jonathan Corbet, Jakub Kicinski,
	Yafang Shao, Tony Ambardar, Alexander Lobakin, Jan Hendrik Farr,
	Alexander Potapenko, linux-kernel, linux-hardening, linux-doc,
	llvm

On Sat, Feb 21, 2026 at 08:13:24PM -0800, Eric Biggers wrote:
> On Wed, Dec 03, 2025 at 03:30:35PM -0800, Kees Cook wrote:
> > Finds and converts sized kmalloc-family of allocations into the
> > typed kmalloc_obj-family of allocations.
> > 
> > Signed-off-by: Kees Cook <kees@kernel.org>
> > ---
> > Cc: Julia Lawall <Julia.Lawall@inria.fr>
> > Cc: Nicolas Palix <nicolas.palix@imag.fr>
> > Cc: cocci@inria.fr
> > ---
> >  scripts/coccinelle/api/kmalloc_objs.cocci | 109 ++++++++++++++++++++++
> >  1 file changed, 109 insertions(+)
> >  create mode 100644 scripts/coccinelle/api/kmalloc_objs.cocci
> 
> Is there a way to reproduce commit 69050f8d6d075dc using this semantic
> patch as claimed?  I spend a while installing the latest version of
> spatch (which was quite hard to do due to all the unusual dependencies),
> but it complains that no rules apply:
> 
> $ /usr/local/bin/spatch --sp-file scripts/coccinelle/api/kmalloc_objs.cocci --dir . --in-place
> init_defs_builtins: /usr/local/lib/coccinelle/standard.h
> SPECIAL NAMES: adding u8 as a type
> SPECIAL NAMES: adding u16 as a type
> SPECIAL NAMES: adding u32 as a type
> SPECIAL NAMES: adding u64 as a type
> SPECIAL NAMES: adding __u8 as a type
> SPECIAL NAMES: adding __u16 as a type
> SPECIAL NAMES: adding __u32 as a type
> SPECIAL NAMES: adding __u64 as a type
> SPECIAL NAMES: adding uint8_t as a type
> SPECIAL NAMES: adding uint16_t as a type
> SPECIAL NAMES: adding uint32_t as a type
> SPECIAL NAMES: adding uint64_t as a type
> SPECIAL NAMES: adding uchar as a type
> SPECIAL NAMES: adding ushort as a type
> SPECIAL NAMES: adding uint as a type
> SPECIAL NAMES: adding ulong as a type
> SPECIAL NAMES: adding __le16 as a type
> SPECIAL NAMES: adding __le32 as a type
> SPECIAL NAMES: adding __le64 as a type
> SPECIAL NAMES: adding __be16 as a type
> SPECIAL NAMES: adding __be32 as a type
> SPECIAL NAMES: adding __be64 as a type
> SPECIAL NAMES: adding wchar_t as a type
> No rules apply.  Perhaps your semantic patch doesn't contain any +/-/* code, or you have a failed dependency.  If the problem is not clear, try --debug-parse-cocci or check whether any virtual rules (e.g., patch) should be defined.

I'm running:

$ spatch --version
spatch version 1.1.1-00467-g578998d7826c compiled with OCaml version 4.13.1

Running Coccinelle scripts is normally done with the coccicheck target:

$ make coccicheck V=1 MODE=patch COCCI=scripts/coccinelle/api/kmalloc_objs.cocci

-Kees

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [cocci] [PATCH v6 5/5] coccinelle: Add kmalloc_objs conversion script
  2026-02-22  4:13   ` Eric Biggers
  2026-02-22  7:12     ` Kees Cook
@ 2026-02-22  9:31     ` Julia Lawall
  1 sibling, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2026-02-22  9:31 UTC (permalink / raw)
  To: Eric Biggers
  Cc: Kees Cook, Vlastimil Babka, Julia Lawall, Nicolas Palix, cocci,
	Linus Torvalds, Randy Dunlap, Miguel Ojeda, Przemek Kitszel,
	Gustavo A. R. Silva, Matthew Wilcox, John Hubbard, Joe Perches,
	Christoph Lameter, Marco Elver, Vegard Nossum, Pekka Enberg,
	David Rientjes, Joonsoo Kim, Andrew Morton, Roman Gushchin,
	Harry Yoo, Bill Wendling, Justin Stitt, Jann Horn,
	Greg Kroah-Hartman, Sasha Levin, linux-mm, Nathan Chancellor,
	Peter Zijlstra, Nick Desaulniers, Jonathan Corbet, Jakub Kicinski,
	Yafang Shao, Tony Ambardar, Alexander Lobakin, Jan Hendrik Farr,
	Alexander Potapenko, linux-kernel, linux-hardening, linux-doc,
	llvm



On Sat, 21 Feb 2026, Eric Biggers wrote:

> On Wed, Dec 03, 2025 at 03:30:35PM -0800, Kees Cook wrote:
> > Finds and converts sized kmalloc-family of allocations into the
> > typed kmalloc_obj-family of allocations.
> >
> > Signed-off-by: Kees Cook <kees@kernel.org>
> > ---
> > Cc: Julia Lawall <Julia.Lawall@inria.fr>
> > Cc: Nicolas Palix <nicolas.palix@imag.fr>
> > Cc: cocci@inria.fr
> > ---
> >  scripts/coccinelle/api/kmalloc_objs.cocci | 109 ++++++++++++++++++++++
> >  1 file changed, 109 insertions(+)
> >  create mode 100644 scripts/coccinelle/api/kmalloc_objs.cocci
>
> Is there a way to reproduce commit 69050f8d6d075dc using this semantic
> patch as claimed?  I spend a while installing the latest version of
> spatch (which was quite hard to do due to all the unusual dependencies),
> but it complains that no rules apply:

I guess you would have to write on the command line -D patch?

julia

>
> $ /usr/local/bin/spatch --sp-file scripts/coccinelle/api/kmalloc_objs.cocci --dir . --in-place
> init_defs_builtins: /usr/local/lib/coccinelle/standard.h
> SPECIAL NAMES: adding u8 as a type
> SPECIAL NAMES: adding u16 as a type
> SPECIAL NAMES: adding u32 as a type
> SPECIAL NAMES: adding u64 as a type
> SPECIAL NAMES: adding __u8 as a type
> SPECIAL NAMES: adding __u16 as a type
> SPECIAL NAMES: adding __u32 as a type
> SPECIAL NAMES: adding __u64 as a type
> SPECIAL NAMES: adding uint8_t as a type
> SPECIAL NAMES: adding uint16_t as a type
> SPECIAL NAMES: adding uint32_t as a type
> SPECIAL NAMES: adding uint64_t as a type
> SPECIAL NAMES: adding uchar as a type
> SPECIAL NAMES: adding ushort as a type
> SPECIAL NAMES: adding uint as a type
> SPECIAL NAMES: adding ulong as a type
> SPECIAL NAMES: adding __le16 as a type
> SPECIAL NAMES: adding __le32 as a type
> SPECIAL NAMES: adding __le64 as a type
> SPECIAL NAMES: adding __be16 as a type
> SPECIAL NAMES: adding __be32 as a type
> SPECIAL NAMES: adding __be64 as a type
> SPECIAL NAMES: adding wchar_t as a type
> No rules apply.  Perhaps your semantic patch doesn't contain any +/-/* code, or you have a failed dependency.  If the problem is not clear, try --debug-parse-cocci or check whether any virtual rules (e.g., patch) should be defined.
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-02-24 11:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20251203233029.it.641-kees@kernel.org>
2025-12-03 23:30 ` [cocci] [PATCH v6 5/5] coccinelle: Add kmalloc_objs conversion script Kees Cook
2025-12-11 14:15   ` Markus Elfring
2025-12-16 21:56   ` Julia Lawall
2026-02-22  4:13   ` Eric Biggers
2026-02-22  7:12     ` Kees Cook
2026-02-22  9:31     ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox