Skip to content

Commit 4cdfb6e

Browse files
fs/ntfs3: Disable ATTR_LIST_ENTRY size check
The use of sizeof(struct ATTR_LIST_ENTRY) has been replaced with le_size(0) due to alignment peculiarities on different platforms. Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Signed-off-by: Konstantin Komarov <[email protected]>
1 parent 652483b commit 4cdfb6e

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

fs/ntfs3/attrlist.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,13 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct ntfs_inode *ni,
127127
{
128128
size_t off;
129129
u16 sz;
130+
const unsigned le_min_size = le_size(0);
130131

131132
if (!le) {
132133
le = ni->attr_list.le;
133134
} else {
134135
sz = le16_to_cpu(le->size);
135-
if (sz < sizeof(struct ATTR_LIST_ENTRY)) {
136+
if (sz < le_min_size) {
136137
/* Impossible 'cause we should not return such le. */
137138
return NULL;
138139
}
@@ -141,16 +142,15 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct ntfs_inode *ni,
141142

142143
/* Check boundary. */
143144
off = PtrOffset(ni->attr_list.le, le);
144-
if (off + sizeof(struct ATTR_LIST_ENTRY) > ni->attr_list.size) {
145+
if (off + le_min_size > ni->attr_list.size) {
145146
/* The regular end of list. */
146147
return NULL;
147148
}
148149

149150
sz = le16_to_cpu(le->size);
150151

151152
/* Check le for errors. */
152-
if (sz < sizeof(struct ATTR_LIST_ENTRY) ||
153-
off + sz > ni->attr_list.size ||
153+
if (sz < le_min_size || off + sz > ni->attr_list.size ||
154154
sz < le->name_off + le->name_len * sizeof(short)) {
155155
return NULL;
156156
}

fs/ntfs3/ntfs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,6 @@ struct ATTR_LIST_ENTRY {
527527

528528
}; // sizeof(0x20)
529529

530-
static_assert(sizeof(struct ATTR_LIST_ENTRY) == 0x20);
531-
532530
static inline u32 le_size(u8 name_len)
533531
{
534532
return ALIGN(offsetof(struct ATTR_LIST_ENTRY, name) +

0 commit comments

Comments
 (0)