Skip to contentSkip to conversation

there are unencrypted files in an encrypted directory in F2FS

DISCUSSION xiakaixu 1 participant 1 message Sep 19, 2016

lore
Share & tools
lore

xiakaixu

author
#0 lore 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 :)

Signature · 5 lines
Regards
Kaixu Xia


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