mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: Julia Lawall <Julia.Lawall@lip6.fr>,
	Kees Cook <keescook@chromium.org>,
	"Gustavo A . R . Silva" <gustavoars@kernel.org>,
	cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org,
	Harshit Mogalapalli <harshit.m.mogalapalli@gmail.com>
Subject: Re: [PATCH] coccinelle: semantic patch to check for potential struct_size calls
Date: Tue, 16 Jan 2024 10:03:20 +0300	[thread overview]
Message-ID: <6ee33330-134c-4bdd-a5eb-e8ff0db6cc8b@moroto.mountain> (raw)
In-Reply-To: <20230227202428.3657443-1-jacob.e.keller@intel.com>

What happened to this patch?  These sorts of patches go through Kees?

Also it would be nice if it could handle char arrays.  It doesn't warn
for the kmalloc in dg_dispatch_as_host():

drivers/misc/vmw_vmci/vmci_datagram.c
   227                          dg_info = kmalloc(sizeof(*dg_info) +
   228                                      (size_t) dg->payload_size, GFP_ATOMIC);

The Cocci check is looking specifically for:

	sizeof(*dg_info) + (sizeof(*dg_info->msg_payload) * dg->payload_size)

But since this flex array is u8 there is no multiply.  I don't know how
are it is to add support for char arrays...

Also another common way to write the multiply is:

	sizeof(*dg_info) + (sizeof(dg_info->msg_payload[0]) * dg->payload_size)

That should be pretty straight forward to add.

regards,
dan carpenter



  parent reply	other threads:[~2024-01-16  7:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27 20:24 Jacob Keller
2023-08-27  1:19 ` Kees Cook
2023-08-29 19:25   ` Jacob Keller
2024-01-16  7:03 ` Dan Carpenter [this message]
2024-01-17 21:54   ` Keller, Jacob E
2024-01-18  5:18     ` Dan Carpenter
2024-02-19  4:38 ` Kees Cook

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=6ee33330-134c-4bdd-a5eb-e8ff0db6cc8b@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=Julia.Lawall@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=gustavoars@kernel.org \
    --cc=harshit.m.mogalapalli@gmail.com \
    --cc=jacob.e.keller@intel.com \
    --cc=keescook@chromium.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®