Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3B8FC10F01 for ; Wed, 20 Feb 2019 06:55:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 951632183F for ; Wed, 20 Feb 2019 06:55:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550645707; bh=Yl72G8Px+w81VjnchbBVOixaEKXn7RhCHk00tFP77j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EmpKh2Qz0RYDWhHcdlx9GjI6LuTzQKb1ICGgRWAxXhMzDJ5mjnE7onmmPnj7RCjxG YVPEOuwKGuAk06zui4EwODAF/OZ+MwRXmP/wgxfhlZRwam7qggX0WmrKWMnvt0RV2L V3yCvbWrVcUdJyE6VjrDP7L49U6SdXVU7vWR9x7M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726910AbfBTGzG (ORCPT ); Wed, 20 Feb 2019 01:55:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:54406 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730677AbfBTGyn (ORCPT ); Wed, 20 Feb 2019 01:54:43 -0500 Received: from sol.localdomain (c-107-3-167-184.hsd1.ca.comcast.net [107.3.167.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 304D221929; Wed, 20 Feb 2019 06:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550645682; bh=Yl72G8Px+w81VjnchbBVOixaEKXn7RhCHk00tFP77j8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TFVCKoeDorjuLOJcYaFvzGVJlR2tIY97XtcKEHLm8wI0rFQwPSP8mr/f9qXxmKz9+ gEjV9MVMksJlSn7AP2pQatgkO5TlAEYvGuJzc/XgfyDNLbIbdr89Nzt7S6doW/qXEg nMzl1IsI25lnY5izhG/tF238oJUcbw+NL9F9+LYg= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: Satya Tangirala , linux-api@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, keyrings@vger.kernel.org, linux-mtd@lists.infradead.org, linux-crypto@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Paul Crowley Subject: [RFC PATCH v3 15/18] ext4: wire up new fscrypt ioctls Date: Tue, 19 Feb 2019 22:52:46 -0800 Message-Id: <20190220065249.32099-16-ebiggers@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190220065249.32099-1-ebiggers@kernel.org> References: <20190220065249.32099-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers Wire up the new ioctls for adding and removing fscrypt keys to/from the filesystem, and the new ioctl for retrieving v2 encryption policies. FS_IOC_REMOVE_ENCRYPTION_KEY also required making ext4_drop_inode() call fscrypt_drop_inode(). For more details see Documentation/filesystems/fscrypt.rst, as well as the fscrypt patches that added the implementation of these ioctls. Signed-off-by: Eric Biggers --- fs/ext4/ioctl.c | 24 ++++++++++++++++++++++++ fs/ext4/super.c | 3 +++ 2 files changed, 27 insertions(+) diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index d26bcac291bb..c939dbd2f2ac 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -1020,6 +1020,26 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) case EXT4_IOC_GET_ENCRYPTION_POLICY: return fscrypt_ioctl_get_policy(filp, (void __user *)arg); + case FS_IOC_GET_ENCRYPTION_POLICY_EX: + if (!ext4_has_feature_encrypt(sb)) + return -EOPNOTSUPP; + return fscrypt_ioctl_get_policy_ex(filp, (void __user *)arg); + + case FS_IOC_ADD_ENCRYPTION_KEY: + if (!ext4_has_feature_encrypt(sb)) + return -EOPNOTSUPP; + return fscrypt_ioctl_add_key(filp, (void __user *)arg); + + case FS_IOC_REMOVE_ENCRYPTION_KEY: + if (!ext4_has_feature_encrypt(sb)) + return -EOPNOTSUPP; + return fscrypt_ioctl_remove_key(filp, (const void __user *)arg); + + case FS_IOC_GET_ENCRYPTION_KEY_STATUS: + if (!ext4_has_feature_encrypt(sb)) + return -EOPNOTSUPP; + return fscrypt_ioctl_get_key_status(filp, (void __user *)arg); + case EXT4_IOC_FSGETXATTR: { struct fsxattr fa; @@ -1138,6 +1158,10 @@ long ext4_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case EXT4_IOC_SET_ENCRYPTION_POLICY: case EXT4_IOC_GET_ENCRYPTION_PWSALT: case EXT4_IOC_GET_ENCRYPTION_POLICY: + case FS_IOC_GET_ENCRYPTION_POLICY_EX: + case FS_IOC_ADD_ENCRYPTION_KEY: + case FS_IOC_REMOVE_ENCRYPTION_KEY: + case FS_IOC_GET_ENCRYPTION_KEY_STATUS: case EXT4_IOC_SHUTDOWN: case FS_IOC_GETFSMAP: break; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 60da0a6e4d86..5b260f88c19f 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1093,6 +1093,9 @@ static int ext4_drop_inode(struct inode *inode) { int drop = generic_drop_inode(inode); + if (!drop) + drop = fscrypt_drop_inode(inode); + trace_ext4_drop_inode(inode, drop); return drop; } -- 2.20.1