Skip to content

Commit a3ac973

Browse files
Matthew Wilcoxkees
authored andcommitted
Convert jffs2 acl to struct_size
Need to tell the compiler that the acl entries follow the acl header. Signed-off-by: Matthew Wilcox <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent b2303d7 commit a3ac973

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

fs/jffs2/acl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
133133
size_t i;
134134

135135
*size = jffs2_acl_size(acl->a_count);
136-
header = kmalloc(sizeof(*header) + acl->a_count * sizeof(*entry), GFP_KERNEL);
136+
header = kmalloc(struct_size(header, a_entries, acl->a_count),
137+
GFP_KERNEL);
137138
if (!header)
138139
return ERR_PTR(-ENOMEM);
139140
header->a_version = cpu_to_je32(JFFS2_ACL_VERSION);

fs/jffs2/acl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct jffs2_acl_entry_short {
2222

2323
struct jffs2_acl_header {
2424
jint32_t a_version;
25+
struct jffs2_acl_entry a_entries[];
2526
};
2627

2728
#ifdef CONFIG_JFFS2_FS_POSIX_ACL

0 commit comments

Comments
 (0)