Convert jffs2 acl to struct_size

Need to tell the compiler that the acl entries follow the acl header.

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
Matthew Wilcox 2018-06-07 07:57:19 -07:00 committed by Kees Cook
parent b2303d7bf7
commit a3ac973076
2 changed files with 3 additions and 1 deletions

View File

@ -133,7 +133,8 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
size_t i; size_t i;
*size = jffs2_acl_size(acl->a_count); *size = jffs2_acl_size(acl->a_count);
header = kmalloc(sizeof(*header) + acl->a_count * sizeof(*entry), GFP_KERNEL); header = kmalloc(struct_size(header, a_entries, acl->a_count),
GFP_KERNEL);
if (!header) if (!header)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
header->a_version = cpu_to_je32(JFFS2_ACL_VERSION); header->a_version = cpu_to_je32(JFFS2_ACL_VERSION);

View File

@ -22,6 +22,7 @@ struct jffs2_acl_entry_short {
struct jffs2_acl_header { struct jffs2_acl_header {
jint32_t a_version; jint32_t a_version;
struct jffs2_acl_entry a_entries[];
}; };
#ifdef CONFIG_JFFS2_FS_POSIX_ACL #ifdef CONFIG_JFFS2_FS_POSIX_ACL