mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: "Marek Behún" <kabel@kernel.org>
Subject: [PATCH] firmware: turris-mox-rwtm: fix fortify memcpy warning
Date: Wed,  3 Jun 2026 16:20:22 -0700	[thread overview]
Message-ID: <20260603232022.7550-1-rosenp@gmail.com> (raw)

Cast tmp to u8* instead of void* before pointer arithmetic to allow
the fortified memcpy to correctly bounds-check the access. Using void*
hides the underlying type and triggers:

  call to '__read_overflow2_field' declared with 'warning' attribute:
  detected read beyond size of field (2nd parameter)

The access is valid: tmp is __be32[17] (68 bytes), and we copy 66 bytes
starting at offset 2.

Fixes: eaa915c7b8da ("firmware: turris-mox-rwtm: add rrpc support")
Assisted-by: Opencode:BigPickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/firmware/turris-mox-rwtm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/turris-mox-rwtm.c b/drivers/firmware/turris-mox-rwtm.c
index 1eac9948148f..3a7d960ea480 100644
--- a/drivers/firmware/turris-mox-rwtm.c
+++ b/drivers/firmware/turris-mox-rwtm.c
@@ -286,7 +286,7 @@ static void mox_ecc_number_to_bin(void *dst, const u32 *src)
 
 	cpu_to_be32_array(tmp, src, MOX_ECC_NUM_WORDS);
 
-	memcpy(dst, (void *)tmp + 2, MOX_ECC_NUM_LEN);
+	memcpy(dst, (u8 *)tmp + 2, MOX_ECC_NUM_LEN);
 }
 
 static void mox_ecc_public_key_to_bin(void *dst, u32 src_first,
-- 
2.54.0


             reply	other threads:[~2026-06-03 23:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-03 23:20 Rosen Penev [this message]
2026-06-04 10:09 ` Marek Behún

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=20260603232022.7550-1-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=kabel@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®