ext4: allocate extended attribute value in vmalloc area
authorYe Bin <yebin10@huawei.com>
Thu, 8 Dec 2022 02:32:31 +0000 (10:32 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 9 Dec 2022 05:56:47 +0000 (00:56 -0500)
Now, extended attribute value maximum length is 64K. The memory
requested here does not need continuous physical addresses, so it is
appropriate to use kvmalloc to request memory. At the same time, it
can also cope with the situation that the extended attribute will
become longer in the future.

Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20221208023233.1231330-3-yebin@huaweicloud.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
fs/ext4/xattr.c

index 6bdd502527f896288d232dff0427470bbd47a0b2..b666d3bf8b3813beaba559f7767e7c52fc9ec97b 100644 (file)
@@ -2548,7 +2548,7 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
 
        is = kzalloc(sizeof(struct ext4_xattr_ibody_find), GFP_NOFS);
        bs = kzalloc(sizeof(struct ext4_xattr_block_find), GFP_NOFS);
-       buffer = kmalloc(value_size, GFP_NOFS);
+       buffer = kvmalloc(value_size, GFP_NOFS);
        b_entry_name = kmalloc(entry->e_name_len + 1, GFP_NOFS);
        if (!is || !bs || !buffer || !b_entry_name) {
                error = -ENOMEM;
@@ -2600,7 +2600,7 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode,
        error = 0;
 out:
        kfree(b_entry_name);
-       kfree(buffer);
+       kvfree(buffer);
        if (is)
                brelse(is->iloc.bh);
        if (bs)