From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbbE0H2l (ORCPT ); Wed, 27 May 2015 03:28:41 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:30142 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752434AbbE0H2f (ORCPT ); Wed, 27 May 2015 03:28:35 -0400 X-AuditID: cbfee61a-f79516d000006302-07-55657221c5dc From: Chao Yu To: "'Jaegeuk Kim'" , "'Changman Lee'" Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <00d501d096d2$cdd373f0$697a5bd0$@samsung.com> In-reply-to: <00d501d096d2$cdd373f0$697a5bd0$@samsung.com> Subject: RE: [f2fs-dev] [PATCH 2/3] f2fs crypto: check dir entry just for directory Date: Wed, 27 May 2015 15:27:49 +0800 Message-id: <003201d0984e$bccd8140$366883c0$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AQIYa6+j//CpQgK5TzfLV3lH3avKgZz/vBlw Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRmVeSWpSXmKPExsVy+t9jAV3FotRQg5kz2C2u7Wtksniyfhaz xaVF7haXd81hc2Dx2LSqk81j94LPTB59W1YxenzeJBfAEsVlk5Kak1mWWqRvl8CVMbPrB1NB r3DF4+5fzA2MN/i7GDk5JARMJNb8/8sGYYtJXLi3Hsjm4hASWMQose3xBhYI5xWjxIvvExlB qtgEVCSWd/xnArFFBPwkpt//CtTBwcEs4CGx61gpSFhIwFJi4uWTLCBhTgEria8bbUHCwgKh Er0r/oB1sgioSmxsusIKYvMCle++MpsZwhaU+DH5HguIzSygJbF+53EmCFteYvOat8wQdypI 7Dj7mhFkvIiAkcSNbV4QJeISG4/cYpnAKDQLyaRZSCbNQjJpFpKWBYwsqxhFUwuSC4qT0nMN 9YoTc4tL89L1kvNzNzGCw/+Z1A7GlQ0WhxgFOBiVeHgzJFNDhVgTy4orcw8xSnAwK4nwzvAC CvGmJFZWpRblxxeV5qQWH2KU5mBREuc9me8TKiSQnliSmp2aWpBaBJNl4uCUamBc7PX3lrje dA6nLUGK1zc8dS2I+THBmH1LzUxp52hV7eBvge2e0Q+PSG5QN5664ixjXsxtBQU9xRvl84z3 tk490Gf4Ytam4yvOCWnvMUhnu89wvZAnSYKte7aOyFmb170HD32VeRT1aK4+88E7hwS5TFLn Tme9ZJUW/FIn8U+Eq/yPsw0JBwqVWIozEg21mIuKEwHeOcZzewIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, > -----Original Message----- > From: Chao Yu [mailto:chao2.yu@samsung.com] > Sent: Monday, May 25, 2015 6:08 PM > To: Jaegeuk Kim; Changman Lee > Cc: linux-kernel@vger.kernel.org; linux-f2fs-devel@lists.sourceforge.net > Subject: [f2fs-dev] [PATCH 2/3] f2fs crypto: check dir entry just for directory > > This patch fixes to add a judgement condition to verify type of the > target inode before empty directory verification. > > So wrong verification could be avoided for non-directory inode. Proposal for ext4 encryption indicated that encryption policy will only be set to an directory in below link: https://lwn.net/Articles/639427/ So the previous patch could not fix the issue exactly, I'd like to use the below patch instead. >>From 28540d2ab2150e586a96314336651eea74f48c7d Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Wed, 27 May 2015 14:51:52 +0800 Subject: [PATCH] f2fs: do not set encryption policy for non-directory by ioctl Encryption policy should only be set to an empty directory through ioctl, This patch add a judgement condition to verify type of the target inode to avoid incorrectly configuring for non-directory. Additionally, remove unneeded inline data conversion since regular or symlink file should not be processed here. Signed-off-by: Chao Yu --- fs/f2fs/crypto_policy.c | 3 +++ fs/f2fs/file.c | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/crypto_policy.c b/fs/f2fs/crypto_policy.c index 30b0b73..d4a96af 100644 --- a/fs/f2fs/crypto_policy.c +++ b/fs/f2fs/crypto_policy.c @@ -92,6 +92,9 @@ int f2fs_process_policy(const struct f2fs_encryption_policy *policy, if (policy->version != 0) return -EINVAL; + if (!S_ISDIR(inode->i_mode)) + return -EINVAL; + if (!f2fs_inode_has_encryption_context(inode)) { if (!f2fs_empty_dir(inode)) return -ENOTEMPTY; diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index af5ef5f..4d42d66 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1485,12 +1485,6 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) sizeof(policy))) return -EFAULT; - if (f2fs_has_inline_data(inode)) { - int ret = f2fs_convert_inline_inode(inode); - if (ret) - return ret; - } - return f2fs_process_policy(&policy, inode); #else return -EOPNOTSUPP; -- 2.3.3