linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] coccinelle: misc: add array_size_dup script to detect missed overflow checks
@ 2020-06-17 16:14 Markus Elfring
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2020-06-17 16:14 UTC (permalink / raw)
  To: Denis Efremov, Julia Lawall, Coccinelle
  Cc: Gustavo A. R. Silva, Kees Cook, linux-kernel

> (
> * size = E1 * E2;@p
> |
> * size = E1 * E2 * E3;@p
> |
> * size = E1 * E2 + E3;@p
> )

I suggest to reconsider also the order of elements for such a SmPL disjunction.

Can a computation like “E2 * E3” also be matched by the expression
metavariable “E2” alone?

Regards,
Markus

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

* Re: [PATCH] coccinelle: misc: Add array_size_dup script to detect missed overflow checks
@ 2020-06-17 14:36 Markus Elfring
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2020-06-17 14:36 UTC (permalink / raw)
  To: Denis Efremov, Gustavo A. R. Silva, Kees Cook, Coccinelle
  Cc: linux-kernel, Julia Lawall

I propose once more to avoid a typo in the previous patch subject.


…
> (
> - size = E1 * E2;
> + size = array_size(E1, E2);
> |
> - size = E1 * E2 * E3;
> + size = array3_size(E1, E2, E3);
> |
> - size = E1 * E2 + E3;
> + size = struct_size(E1, E2, E3);
> )

How do you think about to use SmPL disjunctions like the following?

 size =
(
-       (E1) * (E2)
+       array_size(E1, E2)
|
-       (E1) * (E2) * (E3)
+       array3_size(E1, E2, E3)
|
-       (E1) * (E2) + (E3)
+       struct_size(E1, E2, E3)
);


>   ... when != size = E4
>       when != size += E4
…

Can it become helpful to express a constraint for a metavariable of
the type “assignment operator”?


> (
> * size = E1 * E2;@p
> |
> * size = E1 * E2 * E3;@p
> |
> * size = E1 * E2 + E3;@p
> )

*size =@p \( (E1) * (E2) \| (E1) * (E2) * (E3) \| (E1) * (E2) + (E3) \)

Regards,
Markus

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

* Re: [PATCH] coccinelle: misc: add array_size_dup script to detect missed overflow checks
@ 2020-06-15 12:25 Markus Elfring
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2020-06-15 12:25 UTC (permalink / raw)
  To: Denis Efremov, Coccinelle, Gilles Muller, Julia Lawall,
	Masahiro Yamada, Michal Marek, Nicolas Palix
  Cc: kernel-janitors, linux-kernel, Kees Cook

I suggest to avoid a typo in the previous patch subject.


…
> +virtual context
> +virtual report
> +virtual org

+virtual context, report, org

Is such a SmPL code variant more succinct?


…
> +@as_next@
> +expression subE1 <= as.E1;
> +expression as.E1;
…

I propose to reduce the repetition of this SmPL key word.


…
> +  ... when != \(E1\|E2\|subE1\|subE2\)=E3
> +      when != \(E1\|E2\|subE1\|subE2\)+=E3
…

Can it make sense to express a constraint for a metavariable of
the type “assignment operator”?


> +      when != \(&E1\|&E2\|&subE1\|&subE2\)

How do you think about to use the following code exclusion specification?

+      when != & \(E1 \| E2 \| subE1 \| subE2\)


…
> +msg = "WARNING: same struct_size (line %s)" % (p1[0].line)
> +coccilib.org.print_todo(p2[0], msg)

I suggest once more to pass the desired message object directly as a function argument
(without using an extra Python variable).

Regards,
Markus

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

end of thread, other threads:[~2020-06-17 16:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-17 16:14 [PATCH] coccinelle: misc: add array_size_dup script to detect missed overflow checks Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-06-17 14:36 [PATCH] coccinelle: misc: Add " Markus Elfring
2020-06-15 12:25 [PATCH] coccinelle: misc: add " Markus Elfring

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 NNTP newsgroup(s).