mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Javier Carrasco <javier.carrasco.cruz@gmail.com>
To: Johan Hovold <johan@kernel.org>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	 Nathan Chancellor <nathan@kernel.org>,
	 Nick Desaulniers <ndesaulniers@google.com>,
	 Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-hardening@vger.kernel.org, llvm@lists.linux.dev,
	 Javier Carrasco <javier.carrasco.cruz@gmail.com>
Subject: [PATCH] USB: serial: garmin_gps: annotate struct garmin_packet with __counted_by
Date: Wed, 19 Jun 2024 11:40:57 +0200	[thread overview]
Message-ID: <20240619-garmin_gps_counted_by-v1-1-d8d816f085d9@gmail.com> (raw)

Use the __counted_by compiler attribute for the data[] flexible array member
to improve the results of array bound sanitizers.

Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
The size is assigned before the first reference to the flexible array
(see pkt_add()), which allows for a straightforward annotation without
further modifications.
---
 drivers/usb/serial/garmin_gps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/serial/garmin_gps.c b/drivers/usb/serial/garmin_gps.c
index 670e942fdaaa..57df6ad183ff 100644
--- a/drivers/usb/serial/garmin_gps.c
+++ b/drivers/usb/serial/garmin_gps.c
@@ -104,7 +104,7 @@ struct garmin_packet {
 	int               seq;
 	/* the real size of the data array, always > 0 */
 	int               size;
-	__u8              data[];
+	__u8              data[] __counted_by(size);
 };
 
 /* structure used to keep the current state of the driver */

---
base-commit: 0c52056d9f77508cb6d4d68d3fc91c6c08ec71af
change-id: 20240619-garmin_gps_counted_by-376545960353

Best regards,
-- 
Javier Carrasco <javier.carrasco.cruz@gmail.com>


             reply	other threads:[~2024-06-19  9:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19  9:40 Javier Carrasco [this message]
2024-06-19 14:43 ` Nathan Chancellor
2024-06-19 15:27   ` Gustavo A. R. Silva
2024-06-19 16:12   ` Javier Carrasco

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=20240619-garmin_gps_counted_by-v1-1-d8d816f085d9@gmail.com \
    --to=javier.carrasco.cruz@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=johan@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.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 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®