linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 1/2] Coccinelle: extend memdup_user transformation with GFP_USER
@ 2020-05-31 17:36 Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2020-05-31 17:36 UTC (permalink / raw)
  To: Denis Efremov, Gilles Muller, Julia Lawall, Masahiro Yamada,
	Michal Marek, Nicolas Palix, Coccinelle
  Cc: kernel-janitors, linux-kernel, Joe Perches

> Match GFP_USER allocations with memdup_user.cocci rule.

Can this software extension help also for the clarification of the topic
“Safer source code analysis by "memdup_user.cocci"”?
https://github.com/coccinelle/coccinelle/issues/78

Regards,
Markus

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

* [PATCH 1/2] Coccinelle: extend memdup_user transformation with GFP_USER
  2020-05-30 20:53 [PATCH 0/2] Update memdup_user.cocci Denis Efremov
@ 2020-05-30 20:53 ` Denis Efremov
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Efremov @ 2020-05-30 20:53 UTC (permalink / raw)
  To: Julia Lawall, Joe Perches; +Cc: Denis Efremov, cocci, linux-kernel

Match GFP_USER allocations with memdup_user.cocci rule.
Commit 6c2c97a24f09 ("memdup_user(): switch to GFP_USER") switched
memdup_user() from GFP_KERNEL to GFP_USER. In most cases it is still
a good idea to use memdup_user() for GFP_KERNEL allocations. The
motivation behind altering memdup_user() to GFP_USER is here:
https://lkml.org/lkml/2018/1/6/333

Signed-off-by: Denis Efremov <efremov@linux.com>
---
 scripts/coccinelle/api/memdup_user.cocci | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci
index c809ab10bbce..49f487e6a5c8 100644
--- a/scripts/coccinelle/api/memdup_user.cocci
+++ b/scripts/coccinelle/api/memdup_user.cocci
@@ -20,7 +20,7 @@ expression from,to,size;
 identifier l1,l2;
 @@
 
--  to = \(kmalloc\|kzalloc\)(size,GFP_KERNEL);
+-  to = \(kmalloc\|kzalloc\)(size,\(GFP_KERNEL\|GFP_USER\));
 +  to = memdup_user(from,size);
    if (
 -      to==NULL
@@ -43,7 +43,7 @@ position p;
 statement S1,S2;
 @@
 
-*  to = \(kmalloc@p\|kzalloc@p\)(size,GFP_KERNEL);
+*  to = \(kmalloc@p\|kzalloc@p\)(size,\(GFP_KERNEL\|GFP_USER\));
    if (to==NULL || ...) S1
    if (copy_from_user(to, from, size) != 0)
    S2
-- 
2.26.2


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

end of thread, other threads:[~2020-05-31 17:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-31 17:36 [PATCH 1/2] Coccinelle: extend memdup_user transformation with GFP_USER Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-05-30 20:53 [PATCH 0/2] Update memdup_user.cocci Denis Efremov
2020-05-30 20:53 ` [PATCH 1/2] Coccinelle: extend memdup_user transformation with GFP_USER Denis Efremov

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).