[PATCH] smb: Annotate struct xattr_smb_acl with __counted_by()

Thorsten Blum posted 1 patch 1 year, 5 months ago
fs/smb/server/xattr.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] smb: Annotate struct xattr_smb_acl with __counted_by()
Posted by Thorsten Blum 1 year, 5 months ago
Add the __counted_by compiler attribute to the flexible array member
entries to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE.

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 fs/smb/server/xattr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/smb/server/xattr.h b/fs/smb/server/xattr.h
index 16499ca5c82d..fa3e27d6971b 100644
--- a/fs/smb/server/xattr.h
+++ b/fs/smb/server/xattr.h
@@ -76,7 +76,7 @@ struct xattr_acl_entry {
 struct xattr_smb_acl {
 	int count;
 	int next;
-	struct xattr_acl_entry entries[];
+	struct xattr_acl_entry entries[] __counted_by(count);
 };
 
 /* 64bytes hash in xattr_ntacl is computed with sha256 */
-- 
2.46.0
Re: [PATCH] smb: Annotate struct xattr_smb_acl with __counted_by()
Posted by Namjae Jeon 1 year, 5 months ago
On Fri, Aug 23, 2024 at 8:48 PM Thorsten Blum <thorsten.blum@toblux.com> wrote:
>
> Add the __counted_by compiler attribute to the flexible array member
> entries to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Applied it to #ksmbd-for-next-next.
Thanks!