Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 2f3e176

Browse files
fs/ntfs3: Fix field-spanning write in INDEX_HDR
Fields flags and res[3] replaced with one 4 byte flags. Fixes: 4534a70 ("fs/ntfs3: Add headers and misc files") Signed-off-by: Konstantin Komarov <[email protected]>
1 parent c091354 commit 2f3e176

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

fs/ntfs3/index.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ static struct indx_node *indx_new(struct ntfs_index *indx,
978978
hdr->used =
979979
cpu_to_le32(eo + sizeof(struct NTFS_DE) + sizeof(u64));
980980
de_set_vbn_le(e, *sub_vbn);
981-
hdr->flags = 1;
981+
hdr->flags = NTFS_INDEX_HDR_HAS_SUBNODES;
982982
} else {
983983
e->size = cpu_to_le16(sizeof(struct NTFS_DE));
984984
hdr->used = cpu_to_le32(eo + sizeof(struct NTFS_DE));
@@ -1683,7 +1683,7 @@ static int indx_insert_into_root(struct ntfs_index *indx, struct ntfs_inode *ni,
16831683
e->size = cpu_to_le16(sizeof(struct NTFS_DE) + sizeof(u64));
16841684
e->flags = NTFS_IE_HAS_SUBNODES | NTFS_IE_LAST;
16851685

1686-
hdr->flags = 1;
1686+
hdr->flags = NTFS_INDEX_HDR_HAS_SUBNODES;
16871687
hdr->used = hdr->total =
16881688
cpu_to_le32(new_root_size - offsetof(struct INDEX_ROOT, ihdr));
16891689

fs/ntfs3/ntfs.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -693,14 +693,15 @@ static inline bool de_has_vcn_ex(const struct NTFS_DE *e)
693693
offsetof(struct ATTR_FILE_NAME, name) + \
694694
NTFS_NAME_LEN * sizeof(short), 8)
695695

696+
#define NTFS_INDEX_HDR_HAS_SUBNODES cpu_to_le32(1)
697+
696698
struct INDEX_HDR {
697699
__le32 de_off; // 0x00: The offset from the start of this structure
698700
// to the first NTFS_DE.
699701
__le32 used; // 0x04: The size of this structure plus all
700702
// entries (quad-word aligned).
701703
__le32 total; // 0x08: The allocated size of for this structure plus all entries.
702-
u8 flags; // 0x0C: 0x00 = Small directory, 0x01 = Large directory.
703-
u8 res[3];
704+
__le32 flags; // 0x0C: 0x00 = Small directory, 0x01 = Large directory.
704705

705706
//
706707
// de_off + used <= total
@@ -748,7 +749,7 @@ static inline struct NTFS_DE *hdr_next_de(const struct INDEX_HDR *hdr,
748749

749750
static inline bool hdr_has_subnode(const struct INDEX_HDR *hdr)
750751
{
751-
return hdr->flags & 1;
752+
return hdr->flags & NTFS_INDEX_HDR_HAS_SUBNODES;
752753
}
753754

754755
struct INDEX_BUFFER {
@@ -768,7 +769,7 @@ static inline bool ib_is_empty(const struct INDEX_BUFFER *ib)
768769

769770
static inline bool ib_is_leaf(const struct INDEX_BUFFER *ib)
770771
{
771-
return !(ib->ihdr.flags & 1);
772+
return !(ib->ihdr.flags & NTFS_INDEX_HDR_HAS_SUBNODES);
772773
}
773774

774775
/* Index root structure ( 0x90 ). */

0 commit comments

Comments
 (0)