mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 11:56:58 +00:00
ocfs2: annotate flexible array members with __counted_by_le()
Annotate flexible array members of 'struct ocfs2_extent_list', 'struct ocfs2_chain_list', 'struct ocfs2_truncate_log', 'struct ocfs2_dx_entry_list', 'ocfs2_refcount_list' and 'struct ocfs2_xattr_header' with '__counted_by_le()' attribute to improve array bounds checking when CONFIG_UBSAN_BOUNDS is enabled. [dmantipov@yandex.ru: fix __counted_by_le() usage in ocfs2_expand_inline_dx_root()] Link: https://lkml.kernel.org/r/20251014070324.130313-1-dmantipov@yandex.ru Link: https://lkml.kernel.org/r/20251007123526.213150-1-dmantipov@yandex.ru Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Reviewed-by: Heming Zhao <heming.zhao@suse.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Jun Piao <piaojun@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
cd4eaccc00
commit
2f26f58df0
@@ -4104,10 +4104,15 @@ static int ocfs2_expand_inline_dx_root(struct inode *dir,
|
||||
}
|
||||
|
||||
dx_root->dr_flags &= ~OCFS2_DX_FLAG_INLINE;
|
||||
memset(&dx_root->dr_list, 0, osb->sb->s_blocksize -
|
||||
offsetof(struct ocfs2_dx_root_block, dr_list));
|
||||
|
||||
dx_root->dr_list.l_tree_depth = 0;
|
||||
dx_root->dr_list.l_count =
|
||||
cpu_to_le16(ocfs2_extent_recs_per_dx_root(osb->sb));
|
||||
dx_root->dr_list.l_next_free_rec = 0;
|
||||
memset(&dx_root->dr_list.l_recs, 0,
|
||||
osb->sb->s_blocksize -
|
||||
(offsetof(struct ocfs2_dx_root_block, dr_list) +
|
||||
offsetof(struct ocfs2_extent_list, l_recs)));
|
||||
|
||||
/* This should never fail considering we start with an empty
|
||||
* dx_root. */
|
||||
|
||||
@@ -468,7 +468,8 @@ struct ocfs2_extent_list {
|
||||
__le16 l_reserved1;
|
||||
__le64 l_reserved2; /* Pad to
|
||||
sizeof(ocfs2_extent_rec) */
|
||||
/*10*/ struct ocfs2_extent_rec l_recs[]; /* Extent records */
|
||||
/* Extent records */
|
||||
/*10*/ struct ocfs2_extent_rec l_recs[] __counted_by_le(l_count);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -482,7 +483,8 @@ struct ocfs2_chain_list {
|
||||
__le16 cl_count; /* Total chains in this list */
|
||||
__le16 cl_next_free_rec; /* Next unused chain slot */
|
||||
__le64 cl_reserved1;
|
||||
/*10*/ struct ocfs2_chain_rec cl_recs[]; /* Chain records */
|
||||
/* Chain records */
|
||||
/*10*/ struct ocfs2_chain_rec cl_recs[] __counted_by_le(cl_count);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -494,7 +496,8 @@ struct ocfs2_truncate_log {
|
||||
/*00*/ __le16 tl_count; /* Total records in this log */
|
||||
__le16 tl_used; /* Number of records in use */
|
||||
__le32 tl_reserved1;
|
||||
/*08*/ struct ocfs2_truncate_rec tl_recs[]; /* Truncate records */
|
||||
/* Truncate records */
|
||||
/*08*/ struct ocfs2_truncate_rec tl_recs[] __counted_by_le(tl_count);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -796,9 +799,10 @@ struct ocfs2_dx_entry_list {
|
||||
* possible in de_entries */
|
||||
__le16 de_num_used; /* Current number of
|
||||
* de_entries entries */
|
||||
struct ocfs2_dx_entry de_entries[]; /* Indexed dir entries
|
||||
* in a packed array of
|
||||
* length de_num_used */
|
||||
/* Indexed dir entries in a packed
|
||||
* array of length de_num_used.
|
||||
*/
|
||||
struct ocfs2_dx_entry de_entries[] __counted_by_le(de_count);
|
||||
};
|
||||
|
||||
#define OCFS2_DX_FLAG_INLINE 0x01
|
||||
@@ -934,7 +938,8 @@ struct ocfs2_refcount_list {
|
||||
__le16 rl_used; /* Current number of used records */
|
||||
__le32 rl_reserved2;
|
||||
__le64 rl_reserved1; /* Pad to sizeof(ocfs2_refcount_record) */
|
||||
/*10*/ struct ocfs2_refcount_rec rl_recs[]; /* Refcount records */
|
||||
/* Refcount records */
|
||||
/*10*/ struct ocfs2_refcount_rec rl_recs[] __counted_by_le(rl_count);
|
||||
};
|
||||
|
||||
|
||||
@@ -1020,7 +1025,8 @@ struct ocfs2_xattr_header {
|
||||
buckets. A block uses
|
||||
xb_check and sets
|
||||
this field to zero.) */
|
||||
struct ocfs2_xattr_entry xh_entries[]; /* xattr entry list. */
|
||||
/* xattr entry list. */
|
||||
struct ocfs2_xattr_entry xh_entries[] __counted_by_le(xh_count);
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user