All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Adriana Nicolae <adriana@arista.com>
Cc: u-boot@lists.denx.de
Subject: Re: New Defects reported by Coverity Scan for Das U-Boot
Date: Tue, 9 Dec 2025 08:24:36 -0600	[thread overview]
Message-ID: <20251209142436.GW303283@bill-the-cat> (raw)
In-Reply-To: <CAERbo5wWCSdxcN3mgf+GxGLNQf6mP5cvbNm_qq7LkY77bupwzQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1574 bytes --]

On Tue, Dec 09, 2025 at 01:06:28PM +0200, Adriana Nicolae wrote:

> Hello,
> 
> A possible fix for fdtdec.c tests would be to validate the fdt size
> before using it.
> All 3 tests in this file are using the same approach, if the previous tests were
> acceptable the newly added one has some identical parts.
> 
> If there is a way to test and fix all these 3 errors, I've put some
> changes which
> might be enough for Coverity to assume that the size of the fdt is safe. Let me
> know how I can test it or should I send an email to post it as a
> separate change?

Thanks. A frustrating thing to me with Coverity is I've never seen a way
to test if a change fixes a bug (if you *pay* for Coverity then you can
do many more runs, and also run it on CI test branches and not pollute
your main results I believe, is why). So we need to do it as a regular
patch.

> diff --git a/test/dm/fdtdec.c b/test/dm/fdtdec.c
> index ea5a494612c..a3c90d38115 100644
> --- a/test/dm/fdtdec.c
> +++ b/test/dm/fdtdec.c
> @@ -14,14 +14,21 @@
> 
>  DECLARE_GLOBAL_DATA_PTR;
> 
> +#define FDTDEC_MAX_SIZE  (2 * 1024 * 1024)
> +
>  static int dm_test_fdtdec_set_carveout(struct unit_test_state *uts)
>  {
>   struct fdt_memory resv;
>   void *blob;
>   const fdt32_t *prop;
> - int blob_sz, len, offset;
> + int blob_sz, len, offset, fdt_sz;
> +
> + fdt_sz = fdt_totalsize(gd->fdt_blob);
> + if (fdt_sz <= 0 || fdt_sz > FDTDEC_MAX_SIZE) {
> + return -EINVAL;
> + }

Since these are tests, can we ut_assertsomething here instead? Thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2025-12-09 14:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-08 19:38 Fwd: New Defects reported by Coverity Scan for Das U-Boot Tom Rini
2025-12-09 11:06 ` Adriana Nicolae
2025-12-09 14:24   ` Tom Rini [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-04-28 14:04 Fwd: " Tom Rini
2026-05-01 22:50 ` Raymond Mao
2026-04-06 19:12 Fwd: " Tom Rini
2026-04-07 20:44 ` Raymond Mao
2025-11-10 18:55 Fwd: " Tom Rini
2025-11-12  8:53 ` Kory Maincent
2025-08-06 18:35 Fwd: " Tom Rini
2025-08-07  1:50 ` Maniyam, Dinesh
2025-07-08 14:10 Fwd: " Tom Rini
2025-07-09  9:13 ` Sughosh Ganu
2025-02-10 22:26 Fwd: " Tom Rini
2025-02-11 22:24 ` Raymond Mao
2025-02-11 22:30   ` Tom Rini
2024-12-31 13:55 Fwd: " Tom Rini
2025-01-01 10:50 ` Abbarapu, Venkatesh
2025-01-02 16:59   ` Tom Rini
2024-10-16  3:47 Fwd: " Tom Rini
2024-10-16  6:12 ` Ilias Apalodimas
2024-10-16  8:20   ` Abbarapu, Venkatesh
2024-10-16 15:23 ` Raymond Mao
2024-10-07 17:15 Fwd: " Tom Rini
2024-10-07 18:17 ` Richard Weinberger
2024-10-07 20:01   ` Tom Rini
2024-04-22 21:48 Fwd: " Tom Rini
2024-04-23  6:19 ` Ilias Apalodimas
     [not found] <65a933ab652b3_da12cbd3e77f998728e5@prd-scan-dashboard-0.mail>
2024-01-19  8:47 ` Fwd: " Heinrich Schuchardt
2024-01-22  6:44   ` Masahisa Kojima

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=20251209142436.GW303283@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=adriana@arista.com \
    --cc=u-boot@lists.denx.de \
    /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.