Skip to content

Commit

Permalink
ext4 crypto: Use a larger on-stack file name buffer
Browse files Browse the repository at this point in the history
32 bytes for the on-stack file name buffer is rather small and doesn't
fit many file names, causing dynamic allocation to be used more often
than necessary instead. Increasing the on-stack buffer to 4 KiB is safe
and helps this function avoid dynamic memory allocations far more
frequently.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
  • Loading branch information
kerneltoast committed Aug 5, 2019
1 parent 7599a41 commit da915d3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/ext4/crypto_fname.c
Expand Up @@ -74,7 +74,8 @@ static int ext4_fname_encrypt(struct inode *inode,
char iv[EXT4_CRYPTO_BLOCK_SIZE];
struct scatterlist src_sg, dst_sg;
int padding = 4 << (ci->ci_flags & EXT4_POLICY_FLAGS_PAD_MASK);
char *workbuf, buf[32], *alloc_buf = NULL;
char *workbuf, *alloc_buf = NULL;
char buf[SZ_4K] __aligned(sizeof(long));
unsigned lim = max_name_len(inode);

if (iname->len <= 0 || iname->len > lim)
Expand Down

0 comments on commit da915d3

Please sign in to comment.