mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: cocci@inria.fr, kernel-janitors@vger.kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Detecting missing null pointer checks after memory allocations
Date: Mon, 3 Nov 2025 07:33:42 +0100	[thread overview]
Message-ID: <61ead92e-c65e-4872-843b-4a71b395d486@web.de> (raw)
In-Reply-To: <52e58416-d75f-4a47-9555-88a99d664069@web.de>

> 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

      reply	other threads:[~2025-11-03  6:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-01 12:42 Markus Elfring
2025-11-03  6:33 ` Markus Elfring [this message]

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=61ead92e-c65e-4872-843b-4a71b395d486@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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 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®