All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: cocci@inria.fr, linux-hardening@vger.kernel.org,
	linux-mm@kvack.org, Julia Lawall <Julia.Lawall@inria.fr>,
	Nicolas Palix <nicolas.palix@imag.fr>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-doc@vger.kernel.org, llvm@lists.linux.dev,
	Alexander Lobakin <aleksander.lobakin@intel.com>,
	Alexander Potapenko <glider@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Bill Wendling <morbo@google.com>,
	Christoph Lameter <cl@linux.com>,
	David Rientjes <rientjes@google.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Harry Yoo <harry.yoo@oracle.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Jan Hendrik Farr <kernel@jfarr.cc>, Jann Horn <jannh@google.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	Justin Stitt <justinstitt@google.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Marco Elver <elver@google.com>,
	Matthew Wilcox <willy@infradead.org>,
	Miguel Ojeda <ojeda@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Pekka Enberg <penberg@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Przemek Kitszel <przemyslaw.kitszel@intel.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Sasha Levin <sashal@kernel.org>,
	Tony Ambardar <tony.ambardar@gmail.com>,
	Vegard Nossum <vegard.nossum@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Yafang Shao <laoar.shao@gmail.com>
Subject: Re: [cocci] [PATCH v5 4/4] coccinelle: Add kmalloc_objs conversion script
Date: Thu, 11 Dec 2025 14:00:02 -0800	[thread overview]
Message-ID: <202512111352.387A339CE@keescook> (raw)
In-Reply-To: <71d406fb-9fb1-44a9-912a-7a0d270b9577@web.de>

On Mon, Nov 24, 2025 at 01:50:23PM +0100, Markus Elfring wrote:
> > Finds and converts sized kmalloc-family of allocations into the
> > typed kmalloc_obj-family of allocations.
> 
> See also:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc7#n94

"Describe your changes in imperative mood"

I guess I can try rewording this, but it is describing the behavior of
the script. Normally the imperative language for a patch is about what
the patch accomplishes. In this case, I've added a script and it does a
thing itself.

> …
> > +++ b/scripts/coccinelle/api/kmalloc_objs.cocci
> > @@ -0,0 +1,168 @@
> …
> > +// Comments:
> …
> 
> * Please omit such an empty information line.

Agreed; I removed this in v5.

> 
> * Would a field like “Keywords” become helpful?

I only see a few using this -- what benefit is there to adding it? It
seems redundant to the rest of the file, its opening comment, etc.

> > +virtual patch
> 
> Will additional operation modes become relevant after clarification of implementation details?

I am not interested in other modes; if people want to contribute them,
they are welcome. :)

> 
> 
> …
> > +def alloc_array(name):
> > +	func = "FAILED_RENAME"
> > +	if name == "kmalloc_array":
> > +		func = "kmalloc_objs"
> …
> 
> * I suggest to avoid duplicate variable assignments.
> 
> * How do you think about to collaborate with the Python data structure “dictionary”?

I wanted the stderr warning when there was no match, but to return
"FAILED_RENAME" in such a case. Using a dictionary was basically the
same length as the elif stack. If you have an alternative, I'm happy to
replace it with what you come up with.

> 
> 
> …
> > +type TYPE;
> > +TYPE *P;
> > +TYPE INST;
> > +expression VAR;
> > +expression GFP;
> …
> 
> Such repetition of SmPL key words can eventually be also avoided.

That is true, but I like having them separated -- I find it more
readable that way.

-- 
Kees Cook

  reply	other threads:[~2025-12-11 22:00 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-22  1:42 [PATCH v5 0/4] slab: Introduce kmalloc_obj() and family Kees Cook
2025-11-22  1:42 ` [PATCH v5 1/4] compiler_types: Introduce __flex_counter() " Kees Cook
2025-11-22  1:42 ` [PATCH v5 2/4] slab: Introduce kmalloc_obj() " Kees Cook
2025-11-22 19:53   ` Linus Torvalds
2025-11-22 20:54     ` Linus Torvalds
2025-11-25 18:56       ` Vlastimil Babka
2025-11-25 22:41         ` Linus Torvalds
2025-11-24 20:38     ` Kees Cook
2025-11-24 21:12       ` Matthew Wilcox
2025-11-24 21:20         ` Kees Cook
2025-11-24 21:33           ` Matthew Wilcox
2025-11-24 21:44           ` Matthew Wilcox
2025-11-24 21:50             ` Kees Cook
2025-11-24 23:30             ` Linus Torvalds
2025-11-25  1:09               ` Matthew Wilcox
2025-11-25  3:47                 ` Kees Cook
2025-11-25 11:54                 ` david laight
2025-11-26  0:49                 ` John Hubbard
2025-11-24 21:35       ` Linus Torvalds
2025-11-25  0:29         ` Kees Cook
2025-11-25  1:25           ` Linus Torvalds
2025-12-01 10:49             ` Przemek Kitszel
2025-11-22  1:42 ` [PATCH v5 3/4] checkpatch: Suggest kmalloc_obj family for sizeof allocations Kees Cook
2025-11-22  4:51   ` Joe Perches
2025-12-03 23:12     ` Kees Cook
2025-11-22  1:43 ` [cocci] [PATCH v5 4/4] coccinelle: Add kmalloc_objs conversion script Kees Cook
2025-11-22  1:43   ` Kees Cook
2025-11-24 12:50   ` [cocci] " Markus Elfring
2025-12-11 22:00     ` Kees Cook [this message]
2025-12-12  9:51       ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202512111352.387A339CE@keescook \
    --to=kees@kernel.org \
    --cc=Julia.Lawall@inria.fr \
    --cc=Markus.Elfring@web.de \
    --cc=akpm@linux-foundation.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=cl@linux.com \
    --cc=cocci@inria.fr \
    --cc=corbet@lwn.net \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=harry.yoo@oracle.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jannh@google.com \
    --cc=justinstitt@google.com \
    --cc=kernel@jfarr.cc \
    --cc=kuba@kernel.org \
    --cc=laoar.shao@gmail.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=nicolas.palix@imag.fr \
    --cc=ojeda@kernel.org \
    --cc=penberg@kernel.org \
    --cc=peterz@infradead.org \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=rdunlap@infradead.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=sashal@kernel.org \
    --cc=tony.ambardar@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    --cc=vegard.nossum@oracle.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.