pstore: Replace classic kmalloc code pattern with typed argument
Using a short Coccinelle script, it is possible to replace the classic
kmalloc code patterns with the typed information:
@alloc@
type TYPE;
TYPE *P;
expression GFP;
identifier ALLOC =~ "k[mz]alloc";
@@
P = ALLOC(
- \(sizeof(*P)\|sizeof(TYPE)\), GFP)
+ P, GFP)
Show this just for kmalloc/kzalloc usage in fs/pstore as an example.
Doing this for all allocator calls in the kernel touches much more:
11941 files changed, 22459 insertions(+), 22345 deletions(-)
And obviously requires some more wrappers for kv*alloc, devm_*alloc,
etc.
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Tony Luck <tony.luck@intel.com>
Cc: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Cc: linux-hardening@vger.kernel.org
5 files changed