All of lore.kernel.org
 help / color / mirror / Atom feed
From: xiakaixu <xiakaixu@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: guoweichao@huawei.com,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: there are unencrypted files in an encrypted directory in F2FS
Date: Mon, 19 Sep 2016 12:16:16 +0800	[thread overview]
Message-ID: <57DF6690.9080305@huawei.com> (raw)

Hi Kim,

According to the encryption design policy "all of the  files or
subdirectories in an encrypted directory must be encrypted". But
the current f2fs code seems allow to there are unencrypted files
in an encrypted directory. For example, the f2fs_create() and
f2fs_mknod() functions call f2fs_new_inode() to check the child inode.

         /* If the directory encrypted, then we should encrypt the inode. */
   	if (f2fs_encrypted_inode(dir) && f2fs_may_encrypt(inode))
                 f2fs_set_encrypted_inode(inode);

	static inline bool f2fs_may_encrypt(struct inode *inode)
	{
	#ifdef CONFIG_F2FS_FS_ENCRYPTION
         	umode_t mode = inode->i_mode;

	        return (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode));
	#else
         	return 0;
	#endif
	}

So even if the child inode is not REG/DIR/LNK and it still can be created
successfully which is unencrypted file. Instead, maybe here we can return
-EACCESS. Not sure about it :)

-- 
Regards
Kaixu Xia


------------------------------------------------------------------------------

WARNING: multiple messages have this Message-ID (diff)
From: xiakaixu <xiakaixu@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: <linux-f2fs-devel@lists.sourceforge.net>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	liushuoran <liushuoran@huawei.com>, <guoweichao@huawei.com>,
	Bintian <bintian.wang@huawei.com>
Subject: there are unencrypted files in an encrypted directory in F2FS
Date: Mon, 19 Sep 2016 12:16:16 +0800	[thread overview]
Message-ID: <57DF6690.9080305@huawei.com> (raw)

Hi Kim,

According to the encryption design policy "all of the  files or
subdirectories in an encrypted directory must be encrypted". But
the current f2fs code seems allow to there are unencrypted files
in an encrypted directory. For example, the f2fs_create() and
f2fs_mknod() functions call f2fs_new_inode() to check the child inode.

         /* If the directory encrypted, then we should encrypt the inode. */
   	if (f2fs_encrypted_inode(dir) && f2fs_may_encrypt(inode))
                 f2fs_set_encrypted_inode(inode);

	static inline bool f2fs_may_encrypt(struct inode *inode)
	{
	#ifdef CONFIG_F2FS_FS_ENCRYPTION
         	umode_t mode = inode->i_mode;

	        return (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode));
	#else
         	return 0;
	#endif
	}

So even if the child inode is not REG/DIR/LNK and it still can be created
successfully which is unencrypted file. Instead, maybe here we can return
-EACCESS. Not sure about it :)

-- 
Regards
Kaixu Xia

             reply	other threads:[~2016-09-19  4:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-19  4:16 xiakaixu [this message]
2016-09-19  4:16 ` there are unencrypted files in an encrypted directory in F2FS xiakaixu

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=57DF6690.9080305@huawei.com \
    --to=xiakaixu@huawei.com \
    --cc=guoweichao@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.