Skip to contentSkip to conversation

coccinelle: api: extend memdup_user rule with vmemdup_user()

PATCH Markus Elfring 2 participants 3 messages Jun 8, 2020 Kernel janitors

lore
Share & tools
lore
#0 lore raw

…
+++ b/scripts/coccinelle/api/memdup_user.cocci
@@ -39,6 +39,28 @@ …
…

Review

Quoted 7 lines

+@depends on patch@

(quoted diff) +6 -0
+expression from,to,size;
+identifier l1,l2;
+@@
+
+-  to = \(kvmalloc\|kvzalloc\)(size,\(GFP_KERNEL\|GFP_USER\));
++  to = vmemdup_user(from,size);

I suggest to combine the desired adjustment with the previous SmPL rule by using another disjunction.

Review

Quoted 10 lines

+@rv depends on !patch@

(quoted diff) +9 -0
+expression from,to,size;
+position p;
+statement S1,S2;
+@@
+
+*  to = \(kvmalloc@p\|kvzalloc@p\)(size,\(GFP_KERNEL\|GFP_USER\));
+   if (to==NULL || ...) S1
+   if (copy_from_user(to, from, size) != 0)
+   S2

How does the SmPL asterisk functionality fit to the operation modes “org” and “report”?

Regards,
Markus

#1 lore raw
Quoted 16 lines · Markus Elfring

…
+++ b/scripts/coccinelle/api/memdup_user.cocci

(quoted diff) +0 -0
@@ -39,6 +39,28 @@ …
…

Review

Quoted 7 lines

+@depends on patch@

(quoted diff) +6 -0
+expression from,to,size;
+identifier l1,l2;
+@@
+
+-  to = \(kvmalloc\|kvzalloc\)(size,\(GFP_KERNEL\|GFP_USER\));
++  to = vmemdup_user(from,size);

I suggest to combine the desired adjustment with the previous SmPL rule by using another disjunction.

Quoted 13 lines

Review

Quoted 10 lines

+@rv depends on !patch@

(quoted diff) +9 -0
+expression from,to,size;
+position p;
+statement S1,S2;
+@@
+
+*  to = \(kvmalloc@p\|kvzalloc@p\)(size,\(GFP_KERNEL\|GFP_USER\));
+   if (to==NULL || ...) S1
+   if (copy_from_user(to, from, size) != 0)
+   S2

How does the SmPL asterisk functionality fit to the operation modes “org” and “report”?

Make coccicheck uses --no-show-diff for org and report modes, so the * has no effect in those cases.

julia

#2 lore raw
Quoted 10 lines
Quoted 7 lines

Review

Quoted 4 lines
(quoted diff) +4 -0
+*  to = \(kvmalloc@p\|kvzalloc@p\)(size,\(GFP_KERNEL\|GFP_USER\));
+   if (to==NULL || ...) S1
+   if (copy_from_user(to, from, size) != 0)
+   S2

How does the SmPL asterisk functionality fit to the operation modes “org” and “report”?

Make coccicheck uses --no-show-diff for org and report modes, so the * has no effect in those cases.

* Can it be nicer to generate only required data for each operation mode?

* Would you like to compare the usage of this command parameter with other design approaches?

Regards,
Markus