lkml.org 
[lkml]   [2022]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [f2fs-dev] [PATCH] f2fs: fix to avoid potential deadlock
On Fri, Dec 16, 2022 at 11:50:00PM +0800, Chao Yu wrote:
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index cad4bdd6f097..4bc98dbe8292 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2336,6 +2336,7 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg)
> {
> struct inode *inode = file_inode(filp);
> struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> + u8 encrypt_pw_salt[16];
> int err;
>
> if (!f2fs_sb_has_encrypt(sbi))
> @@ -2360,12 +2361,14 @@ static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg)
> goto out_err;
> }
> got_it:
> - if (copy_to_user((__u8 __user *)arg, sbi->raw_super->encrypt_pw_salt,
> - 16))
> - err = -EFAULT;
> + memcpy(encrypt_pw_salt, sbi->raw_super->encrypt_pw_salt, 16);
> out_err:
> f2fs_up_write(&sbi->sb_lock);
> mnt_drop_write_file(filp);
> +
> + if (!err && copy_to_user((__u8 __user *)arg, encrypt_pw_salt, 16))
> + err = -EFAULT;
> +
> return err;

Reviewed-by: Eric Biggers <ebiggers@google.com>

- Eric

\
 
 \ /
  Last update: 2022-12-16 21:42    [W:0.032 / U:0.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site