* [RFC] Detecting missing null pointer checks after memory allocations
@ 2025-11-01 12:42 Markus Elfring
2025-11-03 6:33 ` Markus Elfring
0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2025-11-01 12:42 UTC (permalink / raw)
To: cocci, kernel-janitors; +Cc: LKML, linux-fsdevel, linux-xfs
Hello,
I got into the mood to try another simple source code search out which
can be achieved also by the means of the semantic patch language.
@display@
expression size, source, target;
@@
target =
(
*kmalloc
|
*vmalloc
|
*malloc
)(...);
memcpy(target, source, size);
It can be determined then from the generated diff file that mentioned
implementation details can be found at 11 places (4 source files) of
the software “Linux next-20251031”.
Will such analysis information trigger further collateral evolution?
Regards,
Markus
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [RFC] Detecting missing null pointer checks after memory allocations
2025-11-01 12:42 [RFC] Detecting missing null pointer checks after memory allocations Markus Elfring
@ 2025-11-03 6:33 ` Markus Elfring
0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2025-11-03 6:33 UTC (permalink / raw)
To: cocci, kernel-janitors; +Cc: LKML
> I got into the mood to try another simple source code search out which
> can be achieved also by the means of the semantic patch language.
I would like to present further data processing approaches accordingly.
The application of a tiny function name selection was demonstrated
by an SmPL disjunction (which can be extended on demand).
Additional techniques can become more helpful for advanced code reviews.
* Further preparations would be needed in software infrastructures (ACID properties)
if you would like to benefit more from parallel data processing here.
* It might be easier for a while to stick to a serial data processing approach
like the following.
@initialize:python@
@@
import sys
records = []
def store_data(id, places):
"""Add data to an internal list."""
for place in places:
records.append((id, place.current_element, place.file, place.line, str(int(place.column) + 1)))
@searching@
expression size, source, target;
identifier action;
position pos;
@@
target = action@pos(...);
memcpy(target, source, size);
@script:python collection@
id << searching.action;
place << searching.pos;
@@
store_data(id, place)
@finalize:python@
@@
if records:
delimiter = "|"
sys.stdout.write(delimiter.join(["action", '"function name"', '"source file"', "line", "column"]) + "\n")
for record in records:
sys.stdout.write(delimiter.join(record) + "\n")
else:
sys.stderr.write("No result for this analysis!\n")
A text file can accordingly be generated by the Coccinelle software. It can be
imported into a spreadsheet application. A Pivot table can be constructed then.
Would you become interested to take another look at the 71 called actions
(from 121 source files of the software “Linux next-20251031”) if they would need
the check for a failure predicate before copying data to affected memory areas?
https://cwe.mitre.org/data/definitions/252.html
Under which circumstances will error detection and corresponding exception
handling be completed?
https://wiki.sei.cmu.edu/confluence/display/c/EXP34-C.+Do+not+dereference+null+pointers#EXP34C.Donotdereferencenullpointers-AutomatedDetection
Regards,
Markus
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-03 6:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-01 12:42 [RFC] Detecting missing null pointer checks after memory allocations Markus Elfring
2025-11-03 6:33 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®