Messages in this thread | | | Date | Fri, 16 Dec 2022 12:42:02 -0800 | From | Eric Biggers <> | Subject | Re: [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
| |