Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752602AbbEYKJv (ORCPT ); Mon, 25 May 2015 06:09:51 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:62734 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752585AbbEYKJt (ORCPT ); Mon, 25 May 2015 06:09:49 -0400 X-AuditID: cbfee61a-f79516d000006302-4a-5562f4ebdb0c From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] f2fs crypto: allow setting encryption policy once Date: Mon, 25 May 2015 18:09:03 +0800 Message-id: <00d601d096d2$ee2c65d0$ca853170$@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: AdCW0iFbL7qDMQAPRem0VSDfaNjrQA== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t9jQd03X5JCDd5OZ7W4tq+RyeLJ+lnM FpcWuVtc3jWHzYHFY9OqTjaP3Qs+M3n0bVnF6PF5k1wASxSXTUpqTmZZapG+XQJXxoddF9kK +jkrDn/sYG1gvMbexcjJISFgItFzYB8LhC0mceHeerYuRi4OIYHpjBIdDy+xQjivGCWuHXnJ BlLFJqAisbzjPxOILSLgJTFp/wmwbmYBD4nGju+sILawgJvEgva3QPUcHCwCqhLHJnODhHkF LCXOfV3FCGELSvyYfA+qVUti/c7jTBC2vMTmNW+ZIQ5SkNhx9jUjxCo9iU1zvjJD1IhLbDxy i2UCo8AsJKNmIRk1C8moWUhaFjCyrGIUTS1ILihOSs811CtOzC0uzUvXS87P3cQIDulnUjsY VzZYHGIU4GBU4uGNyEgKFWJNLCuuzD3EKMHBrCTCG/IRKMSbklhZlVqUH19UmpNafIhRmoNF SZz3ZL5PqJBAemJJanZqakFqEUyWiYNTqoGxOul0y5ZHec+tCxcn71ywjj8lOdp65hXh9lVn D1S4Vsx9c3eRSjLz+3C55yahu5NDuyXnKG7mi7nquSo5fF1XSm5Oh5uPzcPUV+eWS1xktZIz DZ7+uPszoxzjz47+hJjgsmqrO6+Fj2yaFh67ltH/0+dFLK5bpzMIhCVzato5if3Oy3wX2KzE UpyRaKjFXFScCAANYE6QZQIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1379 Lines: 38 This patch add XATTR_CREATE flag in setxattr when setting encryption context for inode. Without this flag the context could be set more than once, this should never happen. So, fix it. Signed-off-by: Chao Yu --- fs/f2fs/crypto_policy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/crypto_policy.c b/fs/f2fs/crypto_policy.c index 56b2ac0..71b3a5a 100644 --- a/fs/f2fs/crypto_policy.c +++ b/fs/f2fs/crypto_policy.c @@ -83,7 +83,7 @@ static int f2fs_create_encryption_context_from_policy( return f2fs_setxattr(inode, F2FS_XATTR_INDEX_ENCRYPTION, F2FS_XATTR_NAME_ENCRYPTION_CONTEXT, &ctx, - sizeof(ctx), NULL, 0); + sizeof(ctx), NULL, XATTR_CREATE); } int f2fs_process_policy(const struct f2fs_encryption_policy *policy, @@ -202,5 +202,5 @@ int f2fs_inherit_context(struct inode *parent, struct inode *child, get_random_bytes(ctx.nonce, F2FS_KEY_DERIVATION_NONCE_SIZE); return f2fs_setxattr(child, F2FS_XATTR_INDEX_ENCRYPTION, F2FS_XATTR_NAME_ENCRYPTION_CONTEXT, &ctx, - sizeof(ctx), ipage, 0); + sizeof(ctx), ipage, XATTR_CREATE); } -- 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/