linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao2.yu@samsung.com>
To: 'Jaegeuk Kim' <jaegeuk@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: RE: [f2fs-dev] [PATCH 3/4] f2fs crypto: check encryption for tmpfile
Date: Thu, 28 May 2015 18:20:05 +0800	[thread overview]
Message-ID: <007001d0992f$f77f6ba0$e67e42e0$@samsung.com> (raw)
In-Reply-To: <1432082606-55975-3-git-send-email-jaegeuk@kernel.org>

Hi Jaegeuk,

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Wednesday, May 20, 2015 8:43 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 3/4] f2fs crypto: check encryption for tmpfile
> 
> This patch adds to check encryption for tmpfile in early stage.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/namei.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index dded2b0..47066b0 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -531,6 +531,11 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
>  	}
> 
>  	f2fs_lock_op(sbi);
> +
> +	err = f2fs_get_encryption_info(dir);
> +	if (err)
> +		goto out;
> +
>  	err = acquire_orphan_inode(sbi);
>  	if (err)
>  		goto out;
> --
> 2.1.1

I can't find the original thread, so I reply here.
Merged patch in dev branch shows that our code is modified as below:

static int f2fs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
 {
+	int err = f2fs_get_encryption_info(dir);
+	if (err)
+		return err;
+
 	return __f2fs_tmpfile(dir, dentry, mode, NULL);
 }

It seems that, if we try to make a temp file in an unencrypted dir, we will
always fail with -ENODATA in f2fs_get_encryption_info because encryption
context is not exist in xattr.

So we should check dir with f2fs_encrypted_inode() before
f2fs_get_encryption_info() to avoid that.

Thanks,


  parent reply	other threads:[~2015-05-28 10:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-20  0:43 [PATCH 1/4] f2fs crypto: preallocate a tfm for the data path Jaegeuk Kim
2015-05-20  0:43 ` [PATCH 2/4] f2fs crypto: add two spinlocks to avoid data races Jaegeuk Kim
2015-05-20  0:43 ` [PATCH 3/4] f2fs crypto: check encryption for tmpfile Jaegeuk Kim
2015-05-20  4:46   ` Theodore Ts'o
2015-05-20  5:01     ` Jaegeuk Kim
2015-05-20  6:00       ` [f2fs-dev] " Jaegeuk Kim
2015-05-28 10:20   ` Chao Yu [this message]
2015-05-28 17:01     ` Jaegeuk Kim
2015-05-20  0:43 ` [PATCH 4/4] f2fs crypto: assign GFP_KERNEL for f2fs_derive_key_aes Jaegeuk Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='007001d0992f$f77f6ba0$e67e42e0$@samsung.com' \
    --to=chao2.yu@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).