[PATCH] nvme: Annotate struct nvme_dhchap_key with __counted_by

Thorsten Blum posted 1 patch 1 month, 1 week ago
include/linux/nvme-auth.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] nvme: Annotate struct nvme_dhchap_key with __counted_by
Posted by Thorsten Blum 1 month, 1 week ago
Add the __counted_by() compiler attribute to the flexible array member
'key' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 include/linux/nvme-auth.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/nvme-auth.h b/include/linux/nvme-auth.h
index 60e069a6757f..e75c29c51464 100644
--- a/include/linux/nvme-auth.h
+++ b/include/linux/nvme-auth.h
@@ -11,7 +11,7 @@
 struct nvme_dhchap_key {
 	size_t len;
 	u8 hash;
-	u8 key[];
+	u8 key[] __counted_by(len);
 };
 
 u32 nvme_auth_get_seqnum(void);
-- 
Thorsten Blum <thorsten.blum@linux.dev>
GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
Re: [PATCH] nvme: Annotate struct nvme_dhchap_key with __counted_by
Posted by Christoph Hellwig 1 month ago
On Tue, Mar 03, 2026 at 10:31:01PM +0100, Thorsten Blum wrote:
> Add the __counted_by() compiler attribute to the flexible array member
> 'key' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Re: [PATCH] nvme: Annotate struct nvme_dhchap_key with __counted_by
Posted by Keith Busch 1 month ago
On Tue, Mar 10, 2026 at 03:20:49PM +0100, Christoph Hellwig wrote:
> On Tue, Mar 03, 2026 at 10:31:01PM +0100, Thorsten Blum wrote:
> > Add the __counted_by() compiler attribute to the flexible array member
> > 'key' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> > CONFIG_FORTIFY_SOURCE.

Thanks, applied.