Skip to contentSkip to conversation

coccinelle: kmalloc_obj: Remove default GFP_KERNEL arg

PATCH In review Kees Cook 2 participants 2 messages Mar 20 – Mar 27 Coccinelle/Semantic Patches (SmPL)

lore
Share & tools
lore

Kees Cook

author
#0 lore raw

PATCH 1/1 coccinelle: kmalloc_obj: Remove default GFP_KERNEL arg

Remove any GFP_KERNEL arguments found in the new kmalloc_obj-family helpers. This captures the script used in commit 189f164e573e ("Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL uses").

---
Cc: Julia Lawall <[email protected]>
Cc: Nicolas Palix <[email protected]>
Cc: <[email protected]>

---
 scripts/coccinelle/api/kmalloc_objs.cocci | 11 +++++++++++
 1 file changed, 11 insertions(+)
scripts/coccinelle/api/kmalloc_objs.cocci +11 -0
index db12b7be7247..e9a415b7b6f4 100644
@@ -122,3 +122,14 @@ fresh identifier ALLOC_OBJS = script:python(ALLOC_ARRAY) { alloc_array(ALLOC_ARR
 -	ALLOC(struct_size_t(TYPE, FLEX, COUNT), GFP)
 +	ALLOC_FLEX(TYPE, FLEX, COUNT, GFP)
 )
+
+@drop_gfp_kernel depends on patch && !(file in "tools") && !(file in "samples")@
+identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex,
+		    kzalloc_obj,kzalloc_objs,kzalloc_flex,
+		    kvmalloc_obj,kvmalloc_objs,kvmalloc_flex,
+		    kvzalloc_obj,kvzalloc_objs,kvzalloc_flex};
+@@
+
+	ALLOC(...
+-		 , GFP_KERNEL
+	     )
Signature · 1 line
2.34.1
#1 lore raw

…

Quoted 6 lines

+++ b/scripts/coccinelle/api/kmalloc_objs.cocci

scripts/coccinelle/api/kmalloc_objs.cocci +1 -0
@@ -122,3 +122,14 @@ fresh identifier ALLOC_OBJS = script:python(ALLOC_ARRAY) { alloc_array(ALLOC_ARR
 -	ALLOC(struct_size_t(TYPE, FLEX, COUNT), GFP)
 +	ALLOC_FLEX(TYPE, FLEX, COUNT, GFP)
 )
+

scripts/coccinelle/api/kmalloc_objs.cocci fresh identifier ALLOC_OBJS = script:python(ALLOC_ARRAY) { alloc_array(ALLOC_ARR · line 135

Quoted 10 lines
scripts/coccinelle/api/kmalloc_objs.cocci +10 -0
+@drop_gfp_kernel depends on patch && !(file in "tools") && !(file in "samples")@
+identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex,
+		    kzalloc_obj,kzalloc_objs,kzalloc_flex,
+		    kvmalloc_obj,kvmalloc_objs,kvmalloc_flex,
+		    kvzalloc_obj,kvzalloc_objs,kvzalloc_flex};
+@@
+
+	ALLOC(...
+-		 , GFP_KERNEL
+	     )

Would it become helpful to clarify the software run time characteristics any further for the selection of mentioned identifiers?

* SmPL disjunction

* Regular expression

Regards,
Markus