Skip to content

Commit

Permalink
fs/ntfs3: Disable ATTR_LIST_ENTRY size check
Browse files Browse the repository at this point in the history
[ Upstream commit 4cdfb6e ]

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 <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202312071005.g6YrbaIe-lkp@intel.com/
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
aalexandrovich authored and gregkh committed Mar 1, 2024
1 parent 947c3f3 commit adcc0ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 4 additions & 4 deletions fs/ntfs3/attrlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,13 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct ntfs_inode *ni,
{
size_t off;
u16 sz;
const unsigned le_min_size = le_size(0);

if (!le) {
le = ni->attr_list.le;
} else {
sz = le16_to_cpu(le->size);
if (sz < sizeof(struct ATTR_LIST_ENTRY)) {
if (sz < le_min_size) {
/* Impossible 'cause we should not return such le. */
return NULL;
}
Expand All @@ -141,16 +142,15 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct ntfs_inode *ni,

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

sz = le16_to_cpu(le->size);

/* Check le for errors. */
if (sz < sizeof(struct ATTR_LIST_ENTRY) ||
off + sz > ni->attr_list.size ||
if (sz < le_min_size || off + sz > ni->attr_list.size ||
sz < le->name_off + le->name_len * sizeof(short)) {
return NULL;
}
Expand Down
2 changes: 0 additions & 2 deletions fs/ntfs3/ntfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,6 @@ struct ATTR_LIST_ENTRY {

}; // sizeof(0x20)

static_assert(sizeof(struct ATTR_LIST_ENTRY) == 0x20);

static inline u32 le_size(u8 name_len)
{
return ALIGN(offsetof(struct ATTR_LIST_ENTRY, name) +
Expand Down

0 comments on commit adcc0ab

Please sign in to comment.