Skip to contentSkip to conversation

coccinelle: api: extend memdup_user rule with vmemdup_user()

PATCH Markus Elfring 2 participants 8 messages Jul 21, 2020 – Jul 22, 2020 Kernel janitors

lore
Share & tools
lore
#0 lore raw

…

Quoted 2 lines

+++ 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 propose 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

* Can it be helpful to omit the SmPL asterisk functionality from the operation modes “org” and “report”?

* Should the operation mode “context” work without an extra position metavariable?

Regards,
Markus

#1 lore raw
Quoted 30 lines · Markus Elfring

…

Quoted 2 lines

+++ 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 propose 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

* Can it be helpful to omit the SmPL asterisk functionality from the operation modes “org” and “report”?

Quoted 1 line

* Should the operation mode “context” work without an extra position metavariable?

This is fine as is in all three aspects.

julia

#2 lore raw
Quoted 1 line

This is fine as is in all three aspects.

I have tried again to point specific data processing consequences out for operation modes of scripts in the semantic patch language.

Regards,
Markus

#3 lore raw
In reply to Julia Lawall
Quoted 10 lines
Quoted 10 lines

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 propose to combine the desired adjustment with the previous SmPL rule by using another disjunction.

How do you think about to check run time characteristics for the following SmPL script sketches?

A)
@R1@
@@
// Change something

@R2@
@@
// Change another thing

B)
@Replacement_with_disjunction@
@@
(
// R1: Change something
|
// R2: Change another thing
)

Quoted 14 lines
Quoted 14 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

* Can it be helpful to omit the SmPL asterisk functionality from the operation modes “org” and “report”?

Quoted 3 lines
Quoted 1 line

* Should the operation mode “context” work without an extra position metavariable?

This is fine as is in all three aspects.

Is every technique from the Coccinelle software required for each operation mode in such data processing approaches?

Regards,
Markus

#4 lore raw
Quoted 24 lines · Markus Elfring
Quoted 10 lines
Quoted 10 lines

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 propose to combine the desired adjustment with the previous SmPL rule by using another disjunction.

How do you think about to check run time characteristics for the following SmPL script sketches?

A)
@R1@
@@
// Change something

@R2@
@@
// Change another thing

Quoted 8 lines

B)
@Replacement_with_disjunction@
@@
(
// R1: Change something
|
// R2: Change another thing
)

Markus, you are welcome to try this since you are concerned about it. But it doesn't matter.

julia

Quoted 26 lines
Quoted 16 lines
Quoted 16 lines

Review

Quoted 12 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

* Can it be helpful to omit the SmPL asterisk functionality from the operation modes “org” and “report”?

Quoted 3 lines
Quoted 1 line

* Should the operation mode “context” work without an extra position metavariable?

This is fine as is in all three aspects.

Is every technique from the Coccinelle software required for each operation mode in such data processing approaches?

Regards,
Markus

#5 lore raw
Quoted 1 line

Markus, you are welcome to try this since you are concerned about it.

I dare to point software design variations for some reasons.

Quoted 1 line

But it doesn't matter.

Under which circumstances would you begin to care more for involved differences in corresponding run time characteristics?

Regards,
Markus

#6 lore raw
Quoted 9 lines · Markus Elfring
Quoted 1 line

Markus, you are welcome to try this since you are concerned about it.

I dare to point software design variations for some reasons.

Quoted 1 line

But it doesn't matter.

Under which circumstances would you begin to care more for involved differences in corresponding run time characteristics?

When the difference is hours vs seconds. In this case, there are tradeoffs between the two options, andI don't know which would be faster, but I think it is extremely unlikely that the difference is noticible. But if you are concerned about it, you are welcome to try.

julia

#7 lore raw
Quoted 4 lines
Quoted 2 lines

Under which circumstances would you begin to care more for involved differences in corresponding run time characteristics?

When the difference is hours vs seconds.

Such a view can be influenced by execution environments in considerable ways.

Quoted 1 line

In this case, there are tradeoffs between the two options,

I am trying to improve the awareness for possible software design variations.

Quoted 1 line

andI don't know which would be faster,

I am curious if more contributors would get into the mood to compare data processing approaches a bit more.

Quoted 1 line

but I think it is extremely unlikely that the difference is noticible.

But the following effects may be known for the evaluation of a SmPL rule which was combined for two code parts.

* The SmPL dependencies are checked only once.

* Can the source code search efforts be reduced a bit?

Quoted 1 line

But if you are concerned about it, you are welcome to try.

Will anybody become interested to measure the software behaviour exactly?

Regards,
Markus