reiserfs: Replace 1-element array with C99 style flex-array
PATCH 1/1 reiserfs: Replace 1-element array with C99 style flex-array
UBSAN found the following issue:
================================================================================
UBSAN: array-index-out-of-bounds in fs/reiserfs/journal.c:4166:22
index 1 is out of range for type '__le32 [1]'
This is because struct reiserfs_journal_desc uses 1-element array for dynamically sized array member, j_realblock.
This patch fixes this issue by replacing the 1-element array member with C99 style flex-array. This patch also fixes the same issue in struct reiserfs_journal_commit as the same manner.
--- fs/reiserfs/reiserfs.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/reiserfs/reiserfs.h +3 -3
@@ -2699,7 +2699,7 @@ struct reiserfs_iget_args {#define get_journal_desc_magic (bh) (bh->b_data + bh->b_size - 12)#define journal_trans_half (blocksize) \ - ((blocksize - sizeof (struct reiserfs_journal_desc) + sizeof (__u32) - 12) / sizeof (__u32)) + ((blocksize - sizeof(struct reiserfs_journal_desc) - 12) / sizeof(__u32))/* journal.c see journal.c for all the comments here */
@@ -2711,7 +2711,7 @@ struct reiserfs_journal_desc {__le32 j_len;__le32 j_mount_id;/* mount id of this trans */ -__le32 j_realblock[1 ];/* real locations for each block */ +__le32 j_realblock[];/* real locations for each block */ };#define get_desc_trans_id (d) le32_to_cpu((d)->j_trans_id)
@@ -2726,7 +2726,7 @@ struct reiserfs_journal_desc {struct reiserfs_journal_commit {__le32 j_trans_id;/* must match j_trans_id from the desc block */ __le32 j_len;/* ditto */ -__le32 j_realblock[1 ];/* real locations for each block */ +__le32 j_realblock[];/* real locations for each block */ };#define get_commit_trans_id (c) le32_to_cpu((c)->j_trans_id)
Signature · 1 line
2.41.0
Christian Brauner
AppliedQuoted 10 lines · Shigeru Yoshida
UBSAN found the following issue:
================================================================================
UBSAN: array-index-out-of-bounds in fs/reiserfs/journal.c:4166:22index 1 is out of range for type '
__le32[1]'This is because struct
reiserfs_journal_descuses 1-element array for dynamically sized array member,j_realblock.[...]
Applied to the vfs.misc branch of the vfs/vfs.git tree. Patches in the vfs.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.misc
[1/1] reiserfs: Replace 1-element array with C99 style flex-array
https://git.kernel.org/vfs/vfs/c/a7cb8be34170