Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752420AbbEYKHu (ORCPT ); Mon, 25 May 2015 06:07:50 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:31421 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752390AbbEYKHr (ORCPT ); Mon, 25 May 2015 06:07:47 -0400 X-AuditID: cbfee61b-f79416d0000014c0-c6-5562f472b0a4 From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] f2fs crypto: check context consistent for rename2 Date: Mon, 25 May 2015 18:07:02 +0800 Message-id: <00d401d096d2$a58db310$f0a91930$@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: AdCW0b+k6KOnlrxhSnSp4anqva2CYQ== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t9jQd2iL0mhBh3r+Syu7Wtksniyfhaz xaVF7haXd81hc2Dx2LSqk81j94LPTB59W1YxenzeJBfAEsVlk5Kak1mWWqRvl8CV8fDcdraC Q+wVJ+78YWxgnMjWxcjJISFgIjFzwS12CFtM4sK99UBxLg4hgemMEks+bGCEcF4xShx8uIQV pIpNQEViecd/JhBbRMBLYtL+EywgNrOAh0Rjx3ewGmEBN4md5yYyg9gsAqoSN65eYASxeQUs Jf7u2gtlC0r8mHwPqldLYv3O40wQtrzE5jVvmSEuUpDYcfY1UD0H0C49iVXf+CBKxCU2HrnF MoFRYBaSSbOQTJqFZNIsJC0LGFlWMYqmFiQXFCel5xrpFSfmFpfmpesl5+duYgSH9DPpHYyr GiwOMQpwMCrx8EZkJIUKsSaWFVfmHmKU4GBWEuEN+QgU4k1JrKxKLcqPLyrNSS0+xCjNwaIk znsy3ydUSCA9sSQ1OzW1ILUIJsvEwSnVwBhht29h97IrXx38FnZNaWuQv+unlacocOSiTFvm yYluv/1/zdjZdS5r5sZQUY8DPkyXJs5cej608HucySp/Tp9VaXrazzhiGffs3Lh6fpKgm8GP JPN3zkn9PJN36sbGhd27tW3BN6UmOT/f2zo8E9bKy+bHp0elZWfMYpt5f9PDMNOq12qz9iix FGckGmoxFxUnAgABX/BlZQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1174 Lines: 38 For exchange rename, we should check context consistent of encryption between new_dir and old_inode or old_dir and new_inode. Otherwise inheritance of parent's encryption context will be broken. Signed-off-by: Chao Yu --- fs/f2fs/namei.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index daed09c..3188464 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -754,6 +754,15 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, int old_nlink = 0, new_nlink = 0; int err = -ENOENT; + if ((old_dir != new_dir) && + (!f2fs_is_child_context_consistent_with_parent(new_dir, + old_inode) || + !f2fs_is_child_context_consistent_with_parent(old_dir, + new_inode))) { + err = -EPERM; + goto out; + } + f2fs_balance_fs(sbi); old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page); -- 2.3.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/