mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 01:59:54 +00:00
Remove unnecessary __attribute__((packed)) annotations
commit 1612bf99de322e2554a90dced7337ff2d8d1ded6 category: bugfix issue: #I6VAS0 CVE: NA Signed-off-by: DongSenhao <dongsenhao2@huawei.com> --------------------------------------- Applying the __attribute__((packed)) annotation to members that do not need it impacts performance negatively on architectures that do not support efficient unaligned accesses (e.g. ARMv7). Hence minimize the __attribute__((packed)) annotations. See also CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS in the Linux kernel. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: dongsenhao <dongsenhao2@huawei.com>
This commit is contained in:
parent
445873df9c
commit
ed86f575e9
@ -31,7 +31,7 @@ static const char * const extensions[MAXQUOTAS] = {
|
|||||||
struct disk_dqheader {
|
struct disk_dqheader {
|
||||||
__le32 dqh_magic;
|
__le32 dqh_magic;
|
||||||
__le32 dqh_version;
|
__le32 dqh_version;
|
||||||
} __attribute__ ((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct disk_dqheader) == 8, "");
|
static_assert(sizeof(struct disk_dqheader) == 8, "");
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ struct qt_disk_dqdbheader {
|
|||||||
__le16 dqdh_entries; /* Number of valid entries in block */
|
__le16 dqdh_entries; /* Number of valid entries in block */
|
||||||
__le16 dqdh_pad1;
|
__le16 dqdh_pad1;
|
||||||
__le32 dqdh_pad2;
|
__le32 dqdh_pad2;
|
||||||
} __attribute__ ((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct qt_disk_dqdbheader) == 16, "");
|
static_assert(sizeof(struct qt_disk_dqdbheader) == 16, "");
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
struct v2_disk_dqheader {
|
struct v2_disk_dqheader {
|
||||||
__le32 dqh_magic; /* Magic number identifying file */
|
__le32 dqh_magic; /* Magic number identifying file */
|
||||||
__le32 dqh_version; /* File version */
|
__le32 dqh_version; /* File version */
|
||||||
} __attribute__ ((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct v2_disk_dqheader) == 8, "");
|
static_assert(sizeof(struct v2_disk_dqheader) == 8, "");
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ struct v2_disk_dqinfo {
|
|||||||
__le32 dqi_free_blk; /* Number of first free block in the list */
|
__le32 dqi_free_blk; /* Number of first free block in the list */
|
||||||
__le32 dqi_free_entry; /* Number of block with at least one
|
__le32 dqi_free_entry; /* Number of block with at least one
|
||||||
* free entry */
|
* free entry */
|
||||||
} __attribute__ ((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct v2_disk_dqinfo) == 24, "");
|
static_assert(sizeof(struct v2_disk_dqinfo) == 24, "");
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ struct v2r1_disk_dqblk {
|
|||||||
__le64 dqb_curspace; /* current space occupied (in bytes) */
|
__le64 dqb_curspace; /* current space occupied (in bytes) */
|
||||||
__le64 dqb_btime; /* time limit for excessive disk use */
|
__le64 dqb_btime; /* time limit for excessive disk use */
|
||||||
__le64 dqb_itime; /* time limit for excessive inode use */
|
__le64 dqb_itime; /* time limit for excessive inode use */
|
||||||
} __attribute__ ((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct v2r1_disk_dqblk) == 72, "");
|
static_assert(sizeof(struct v2r1_disk_dqblk) == 72, "");
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ struct fscrypt_context {
|
|||||||
u8 flags;
|
u8 flags;
|
||||||
u8 master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE];
|
u8 master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE];
|
||||||
u8 nonce[FS_KEY_DERIVATION_NONCE_SIZE];
|
u8 nonce[FS_KEY_DERIVATION_NONCE_SIZE];
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct fscrypt_context) == 28, "");
|
static_assert(sizeof(struct fscrypt_context) == 28, "");
|
||||||
|
|
||||||
|
@ -736,11 +736,10 @@ enum {
|
|||||||
/*
|
/*
|
||||||
* For superblock
|
* For superblock
|
||||||
*/
|
*/
|
||||||
#pragma pack(push, 1)
|
|
||||||
struct f2fs_device {
|
struct f2fs_device {
|
||||||
__u8 path[MAX_PATH_LEN];
|
__u8 path[MAX_PATH_LEN];
|
||||||
__le32 total_segments;
|
__le32 total_segments;
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_device) == 68, "");
|
static_assert(sizeof(struct f2fs_device) == 68, "");
|
||||||
|
|
||||||
@ -755,7 +754,8 @@ struct f2fs_super_block {
|
|||||||
__le32 segs_per_sec; /* # of segments per section */
|
__le32 segs_per_sec; /* # of segments per section */
|
||||||
__le32 secs_per_zone; /* # of sections per zone */
|
__le32 secs_per_zone; /* # of sections per zone */
|
||||||
__le32 checksum_offset; /* checksum offset inside super block */
|
__le32 checksum_offset; /* checksum offset inside super block */
|
||||||
__le64 block_count; /* total # of user blocks */
|
__le64 block_count __attribute__((packed));
|
||||||
|
/* total # of user blocks */
|
||||||
__le32 section_count; /* total # of sections */
|
__le32 section_count; /* total # of sections */
|
||||||
__le32 segment_count; /* total # of segments */
|
__le32 segment_count; /* total # of segments */
|
||||||
__le32 segment_count_ckpt; /* # of segments for checkpoint */
|
__le32 segment_count_ckpt; /* # of segments for checkpoint */
|
||||||
@ -782,14 +782,14 @@ struct f2fs_super_block {
|
|||||||
__le32 feature; /* defined features */
|
__le32 feature; /* defined features */
|
||||||
__u8 encryption_level; /* versioning level for encryption */
|
__u8 encryption_level; /* versioning level for encryption */
|
||||||
__u8 encrypt_pw_salt[16]; /* Salt used for string2key algorithm */
|
__u8 encrypt_pw_salt[16]; /* Salt used for string2key algorithm */
|
||||||
struct f2fs_device devs[MAX_DEVICES]; /* device list */
|
struct f2fs_device devs[MAX_DEVICES] __attribute__((packed)); /* device list */
|
||||||
__le32 qf_ino[F2FS_MAX_QUOTAS]; /* quota inode numbers */
|
__le32 qf_ino[F2FS_MAX_QUOTAS] __attribute__((packed)); /* quota inode numbers */
|
||||||
__u8 hot_ext_count; /* # of hot file extension */
|
__u8 hot_ext_count; /* # of hot file extension */
|
||||||
__le16 s_encoding; /* Filename charset encoding */
|
__le16 s_encoding; /* Filename charset encoding */
|
||||||
__le16 s_encoding_flags; /* Filename charset encoding flags */
|
__le16 s_encoding_flags; /* Filename charset encoding flags */
|
||||||
__u8 reserved[306]; /* valid reserved region */
|
__u8 reserved[306]; /* valid reserved region */
|
||||||
__le32 crc; /* checksum of superblock */
|
__le32 crc; /* checksum of superblock */
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_super_block) == 3072, "");
|
static_assert(sizeof(struct f2fs_super_block) == 3072, "");
|
||||||
|
|
||||||
@ -842,7 +842,7 @@ struct f2fs_checkpoint {
|
|||||||
|
|
||||||
/* SIT and NAT version bitmap */
|
/* SIT and NAT version bitmap */
|
||||||
unsigned char sit_nat_version_bitmap[];
|
unsigned char sit_nat_version_bitmap[];
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_checkpoint) == 192, "");
|
static_assert(sizeof(struct f2fs_checkpoint) == 192, "");
|
||||||
|
|
||||||
@ -868,7 +868,7 @@ struct f2fs_orphan_block {
|
|||||||
__le16 blk_count; /* Number of orphan inode blocks in CP */
|
__le16 blk_count; /* Number of orphan inode blocks in CP */
|
||||||
__le32 entry_count; /* Total number of orphan nodes in current CP */
|
__le32 entry_count; /* Total number of orphan nodes in current CP */
|
||||||
__le32 check_sum; /* CRC32 for orphan inode block */
|
__le32 check_sum; /* CRC32 for orphan inode block */
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_orphan_block) == 4096, "");
|
static_assert(sizeof(struct f2fs_orphan_block) == 4096, "");
|
||||||
|
|
||||||
@ -879,7 +879,7 @@ struct f2fs_extent {
|
|||||||
__le32 fofs; /* start file offset of the extent */
|
__le32 fofs; /* start file offset of the extent */
|
||||||
__le32 blk_addr; /* start block address of the extent */
|
__le32 blk_addr; /* start block address of the extent */
|
||||||
__le32 len; /* lengh of the extent */
|
__le32 len; /* lengh of the extent */
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_extent) == 12, "");
|
static_assert(sizeof(struct f2fs_extent) == 12, "");
|
||||||
|
|
||||||
@ -1006,7 +1006,7 @@ struct f2fs_inode {
|
|||||||
__u8 i_name[F2FS_NAME_LEN]; /* file name for SPOR */
|
__u8 i_name[F2FS_NAME_LEN]; /* file name for SPOR */
|
||||||
__u8 i_dir_level; /* dentry_level for large dir */
|
__u8 i_dir_level; /* dentry_level for large dir */
|
||||||
|
|
||||||
struct f2fs_extent i_ext; /* caching a largest extent */
|
struct f2fs_extent i_ext __attribute__((packed)); /* caching a largest extent */
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
@ -1026,19 +1026,21 @@ struct f2fs_inode {
|
|||||||
};
|
};
|
||||||
__le32 i_nid[5]; /* direct(2), indirect(2),
|
__le32 i_nid[5]; /* direct(2), indirect(2),
|
||||||
double_indirect(1) node id */
|
double_indirect(1) node id */
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
|
static_assert(offsetof(struct f2fs_inode, i_extra_end) -
|
||||||
|
offsetof(struct f2fs_inode, i_extra_isize) == 36, "");
|
||||||
static_assert(sizeof(struct f2fs_inode) == 4072, "");
|
static_assert(sizeof(struct f2fs_inode) == 4072, "");
|
||||||
|
|
||||||
struct direct_node {
|
struct direct_node {
|
||||||
__le32 addr[DEF_ADDRS_PER_BLOCK]; /* array of data block address */
|
__le32 addr[DEF_ADDRS_PER_BLOCK]; /* array of data block address */
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct direct_node) == 4072, "");
|
static_assert(sizeof(struct direct_node) == 4072, "");
|
||||||
|
|
||||||
struct indirect_node {
|
struct indirect_node {
|
||||||
__le32 nid[NIDS_PER_BLOCK]; /* array of data block address */
|
__le32 nid[NIDS_PER_BLOCK]; /* array of data block address */
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct indirect_node) == 4072, "");
|
static_assert(sizeof(struct indirect_node) == 4072, "");
|
||||||
|
|
||||||
@ -1055,9 +1057,9 @@ struct node_footer {
|
|||||||
__le32 nid; /* node id */
|
__le32 nid; /* node id */
|
||||||
__le32 ino; /* inode nunmber */
|
__le32 ino; /* inode nunmber */
|
||||||
__le32 flag; /* include cold/fsync/dentry marks and offset */
|
__le32 flag; /* include cold/fsync/dentry marks and offset */
|
||||||
__le64 cp_ver; /* checkpoint version */
|
__le64 cp_ver __attribute__((packed)); /* checkpoint version */
|
||||||
__le32 next_blkaddr; /* next node page block address */
|
__le32 next_blkaddr; /* next node page block address */
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct node_footer) == 24, "");
|
static_assert(sizeof(struct node_footer) == 24, "");
|
||||||
|
|
||||||
@ -1069,7 +1071,7 @@ struct f2fs_node {
|
|||||||
struct indirect_node in;
|
struct indirect_node in;
|
||||||
};
|
};
|
||||||
struct node_footer footer;
|
struct node_footer footer;
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_node) == 4096, "");
|
static_assert(sizeof(struct f2fs_node) == 4096, "");
|
||||||
|
|
||||||
@ -1091,7 +1093,7 @@ static_assert(sizeof(struct f2fs_nat_entry) == 9, "");
|
|||||||
|
|
||||||
struct f2fs_nat_block {
|
struct f2fs_nat_block {
|
||||||
struct f2fs_nat_entry entries[NAT_ENTRY_PER_BLOCK];
|
struct f2fs_nat_entry entries[NAT_ENTRY_PER_BLOCK];
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_nat_block) == 4095, "");
|
static_assert(sizeof(struct f2fs_nat_block) == 4095, "");
|
||||||
|
|
||||||
@ -1138,7 +1140,7 @@ static_assert(sizeof(struct f2fs_sit_entry) == 74, "");
|
|||||||
|
|
||||||
struct f2fs_sit_block {
|
struct f2fs_sit_block {
|
||||||
struct f2fs_sit_entry entries[SIT_ENTRY_PER_BLOCK];
|
struct f2fs_sit_entry entries[SIT_ENTRY_PER_BLOCK];
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_sit_block) == 4070, "");
|
static_assert(sizeof(struct f2fs_sit_block) == 4070, "");
|
||||||
|
|
||||||
@ -1182,8 +1184,8 @@ static_assert(sizeof(struct f2fs_summary) == 7, "");
|
|||||||
|
|
||||||
struct summary_footer {
|
struct summary_footer {
|
||||||
unsigned char entry_type; /* SUM_TYPE_XXX */
|
unsigned char entry_type; /* SUM_TYPE_XXX */
|
||||||
__le32 check_sum; /* summary checksum */
|
__le32 check_sum __attribute__((packed)); /* summary checksum */
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct summary_footer) == 5, "");
|
static_assert(sizeof(struct summary_footer) == 5, "");
|
||||||
|
|
||||||
@ -1223,7 +1225,7 @@ static_assert(sizeof(struct nat_journal_entry) == 13, "");
|
|||||||
struct nat_journal {
|
struct nat_journal {
|
||||||
struct nat_journal_entry entries[NAT_JOURNAL_ENTRIES];
|
struct nat_journal_entry entries[NAT_JOURNAL_ENTRIES];
|
||||||
__u8 reserved[NAT_JOURNAL_RESERVED];
|
__u8 reserved[NAT_JOURNAL_RESERVED];
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct nat_journal) == 505, "");
|
static_assert(sizeof(struct nat_journal) == 505, "");
|
||||||
|
|
||||||
@ -1237,7 +1239,7 @@ static_assert(sizeof(struct sit_journal_entry) == 78, "");
|
|||||||
struct sit_journal {
|
struct sit_journal {
|
||||||
struct sit_journal_entry entries[SIT_JOURNAL_ENTRIES];
|
struct sit_journal_entry entries[SIT_JOURNAL_ENTRIES];
|
||||||
__u8 reserved[SIT_JOURNAL_RESERVED];
|
__u8 reserved[SIT_JOURNAL_RESERVED];
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct sit_journal) == 505, "");
|
static_assert(sizeof(struct sit_journal) == 505, "");
|
||||||
|
|
||||||
@ -1268,7 +1270,7 @@ struct f2fs_summary_block {
|
|||||||
struct f2fs_summary entries[ENTRIES_IN_SUM];
|
struct f2fs_summary entries[ENTRIES_IN_SUM];
|
||||||
struct f2fs_journal journal;
|
struct f2fs_journal journal;
|
||||||
struct summary_footer footer;
|
struct summary_footer footer;
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_summary_block) == 4096, "");
|
static_assert(sizeof(struct f2fs_summary_block) == 4096, "");
|
||||||
|
|
||||||
@ -1322,12 +1324,10 @@ struct f2fs_dentry_block {
|
|||||||
__u8 reserved[SIZE_OF_RESERVED];
|
__u8 reserved[SIZE_OF_RESERVED];
|
||||||
struct f2fs_dir_entry dentry[NR_DENTRY_IN_BLOCK];
|
struct f2fs_dir_entry dentry[NR_DENTRY_IN_BLOCK];
|
||||||
__u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN];
|
__u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN];
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_dentry_block) == 4096, "");
|
static_assert(sizeof(struct f2fs_dentry_block) == 4096, "");
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
/* for inline stuff */
|
/* for inline stuff */
|
||||||
#define DEF_INLINE_RESERVED_SIZE 1
|
#define DEF_INLINE_RESERVED_SIZE 1
|
||||||
|
|
||||||
|
@ -44,11 +44,10 @@ enum quota_type {
|
|||||||
|
|
||||||
#define QT_TREEOFF 1 /* Offset of tree in file in blocks */
|
#define QT_TREEOFF 1 /* Offset of tree in file in blocks */
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
|
||||||
struct v2_disk_dqheader {
|
struct v2_disk_dqheader {
|
||||||
uint32_t dqh_magic; /* Magic number identifying file */
|
uint32_t dqh_magic; /* Magic number identifying file */
|
||||||
uint32_t dqh_version; /* File version */
|
uint32_t dqh_version; /* File version */
|
||||||
} __attribute__ ((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct v2_disk_dqheader) == 8, "");
|
static_assert(sizeof(struct v2_disk_dqheader) == 8, "");
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ struct v2_disk_dqinfo {
|
|||||||
uint32_t dqi_blocks; /* Number of blocks in file */
|
uint32_t dqi_blocks; /* Number of blocks in file */
|
||||||
uint32_t dqi_free_blk; /* Number of first free block in the list */
|
uint32_t dqi_free_blk; /* Number of first free block in the list */
|
||||||
uint32_t dqi_free_entry; /* Number of block with at least one free entry */
|
uint32_t dqi_free_entry; /* Number of block with at least one free entry */
|
||||||
} __attribute__ ((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct v2_disk_dqinfo) == 24, "");
|
static_assert(sizeof(struct v2_disk_dqinfo) == 24, "");
|
||||||
|
|
||||||
@ -77,10 +76,8 @@ struct v2r1_disk_dqblk {
|
|||||||
__le64 dqb_curspace; /* current space occupied (in bytes) */
|
__le64 dqb_curspace; /* current space occupied (in bytes) */
|
||||||
__le64 dqb_btime; /* time limit for excessive disk use */
|
__le64 dqb_btime; /* time limit for excessive disk use */
|
||||||
__le64 dqb_itime; /* time limit for excessive inode use */
|
__le64 dqb_itime; /* time limit for excessive inode use */
|
||||||
} __attribute__ ((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct v2r1_disk_dqblk) == 72, "");
|
static_assert(sizeof(struct v2r1_disk_dqblk) == 72, "");
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -102,7 +102,7 @@ struct f2fs_fscrypt_policy {
|
|||||||
__u8 filenames_encryption_mode;
|
__u8 filenames_encryption_mode;
|
||||||
__u8 flags;
|
__u8 flags;
|
||||||
__u8 master_key_descriptor[F2FS_KEY_DESCRIPTOR_SIZE];
|
__u8 master_key_descriptor[F2FS_KEY_DESCRIPTOR_SIZE];
|
||||||
} __attribute__((packed));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_fscrypt_policy) == 12, "");
|
static_assert(sizeof(struct f2fs_fscrypt_policy) == 12, "");
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ struct f2fs_encryption_key {
|
|||||||
__u32 mode;
|
__u32 mode;
|
||||||
char raw[F2FS_MAX_KEY_SIZE];
|
char raw[F2FS_MAX_KEY_SIZE];
|
||||||
__u32 size;
|
__u32 size;
|
||||||
} __attribute__((__packed__));
|
};
|
||||||
|
|
||||||
static_assert(sizeof(struct f2fs_encryption_key) == 72, "");
|
static_assert(sizeof(struct f2fs_encryption_key) == 72, "");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user