All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bill Wendling <morbo@google.com>
To: Moritz Fischer <mdf@kernel.org>, Xu Yilun <yilun.xu@intel.com>
Cc: Tom Rix <trix@redhat.com>, Kees Cook <kees@kernel.org>,
	 "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-fpga@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org,
	 Bill Wendling <morbo@google.com>,
	codemender-patching+linux@google.com
Subject: [PATCH] fpga: Add __counted_by_ptr annotation to fpga_image_info
Date: Fri, 25 Sep 2026 20:54:53 +0000	[thread overview]
Message-ID: <20260925205453.93297-1-morbo@google.com> (raw)

The 'const char *buf' pointer in 'struct fpga_image_info' is used to hold
the FPGA image data, and its element count is stored in 'size_t count'.
To strengthen runtime boundary checks via KASAN and
'__builtin_dynamic_object_size', annotate the 'buf' field with the
'__counted_by_ptr' attribute, pointing to 'count'.

All allocation and assignment paths of 'struct fpga_image_info' have been
verified to ensure that 'count' is initialized before or alongside 'buf',
and 'buf' is never accessed before 'count' is set.

Cc: codemender-patching+linux@google.com
Assisted-by: LLM
Signed-off-by: Bill Wendling <morbo@google.com>
---
 include/linux/fpga/fpga-mgr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index 0d4fe068f3d8..fb9b0978bd34 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -103,7 +103,7 @@ struct fpga_image_info {
 	u32 config_complete_timeout_us;
 	char *firmware_name;
 	struct sg_table *sgt;
-	const char *buf;
+	const char *buf __counted_by_ptr(count);
 	size_t count;
 	size_t header_size;
 	size_t data_size;
-- 
2.56.0.rc1.315.gc6ed9934b7-goog


                 reply	other threads:[~2026-09-25 20:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260925205453.93297-1-morbo@google.com \
    --to=morbo@google.com \
    --cc=codemender-patching+linux@google.com \
    --cc=gustavoars@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.com \
    /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.