Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1790007imi; Sat, 23 Jul 2022 18:19:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vCFD4P8mQL5QoUtcbGLEGnoyR+6wJlxOLW0RG2XGWHRchZ+tWd2xYpiVfKckLi9ODfS3wa X-Received: by 2002:a05:6402:1909:b0:43a:64bb:9f27 with SMTP id e9-20020a056402190900b0043a64bb9f27mr6668000edz.24.1658625571825; Sat, 23 Jul 2022 18:19:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658625571; cv=none; d=google.com; s=arc-20160816; b=BEc7lKYBgr358l6X363g535B9uqkGGIgqcsLYowjyAF1b6PEMBJfiu/ZhV0U/5TnbH xvSx7H2E2ZyS7BoBAGcnaQZn6z29ciPja7FpENnoRPxyWX+bRRvPs5zCIiyiXfiKhHmw twjK66JRSywaC4G3Sj5dTY47RyKJQTeZ0m6ooagi79PAim6LCSBXO3r3O+PoCaqBN0Ec 6LXQOekYU9wS8+VfxRbmBRi4jRNHbo+Qq1v0LSXldySvg58FKmkp4NT7vs9ca3FpgATX UQYHJJIqS7e9yjRm7ukDCLpqKMKv+DJtHTAK8nR3Of7egAe7Aq03B54xqeHhEFhIFZDW 7Dxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ejqHup1Liuq+fHTnBB4o/V3WEQ8BwfsKk1RD1hLHGDI=; b=c0H2koS5kg1P9HfWY3A6bCaxp0BoHH85hCn0N8mO2HsZ8ZJ97qFvvHJZUltg94XuJ9 VI6cqe8ADK45GX2dIBNlMljrXwa8lbGN5ctGTVIadIRZkV0fyvmG/39gVtnN06taM8zy PLyTDbzuSTejKwjSptjKCCskQ/fzCo5dnQJ3jt4Zlfwp5J0spSwNmebGD17RH0j8rb7o 8G5zKEFjdnqAXdSeyiMSpN42U9KmVQUNoFoN4xTFABFPL6/ZDly0i3hSC0wd7gCRK/xp JqHOrgbHqolODD7etj+//ePn8gyvJOvt09hvI6zwXM5PY0jHGYLJC3/DTfjf0/w5SXOO ye3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (bad format) header.i=@dorminy.me header.s=mail header.b=RRcRnkwR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dorminy.me Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l26-20020a056402345a00b0042ddac25209si9035668edc.92.2022.07.23.18.19.06; Sat, 23 Jul 2022 18:19:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=neutral (bad format) header.i=@dorminy.me header.s=mail header.b=RRcRnkwR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=dorminy.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239751AbiGXAzv (ORCPT + 99 others); Sat, 23 Jul 2022 20:55:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239645AbiGXAza (ORCPT ); Sat, 23 Jul 2022 20:55:30 -0400 Received: from box.fidei.email (box.fidei.email [IPv6:2605:2700:0:2:a800:ff:feba:dc44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C482A1AF0D; Sat, 23 Jul 2022 17:55:02 -0700 (PDT) Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 96322807A4; Sat, 23 Jul 2022 20:55:01 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1658624102; bh=eVguuHHegnTXNgvA1tG76WR6VpqBsMJVZtUKyb1tRVw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RRcRnkwRtoTWoAd7/i4fqTHDWN86KcAT1TZ5cBeaMlOJ5w2W1hZuBkabwYjTbeKse XsdMf07AkcEWhnOr9e5f6a6Qpt9GNTOMW9+QaVDknqzmf2NT2ylHS+faHtOLRu6cCI y+BQXiDC1t5UTNHNK8oQbRcZ3SiYHncTzKUTJbfDDaN572k5PTkUwSHFPwDeOZKu+b /9lShn7XHc+Q14ppDYAMCIctgJ1XAYlDmWGLnRUapurow1k3mpFlviRHvvWe59fDP9 nraXqo1x5lRZsKU/jjkJb7NpcjP/fsY8LhNkYttYYAJ6U+c1wbx0XT20weMqvEN3pH M4nvmaQpIS9kA== From: Sweet Tea Dorminy To: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, osandov@osandov.com, kernel-team@fb.com Cc: Sweet Tea Dorminy Subject: [PATCH RFC v2 16/16] btrfs: implement fscrypt ioctls Date: Sat, 23 Jul 2022 20:54:01 -0400 Message-Id: <0f50c0da5b20c80dfd415ae03ec98c8939ec1454.1658623319.git.sweettea-kernel@dorminy.me> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Omar Sandoval These ioctls allow encryption to be set up. Signed-off-by: Omar Sandoval Signed-off-by: Sweet Tea Dorminy --- fs/btrfs/ioctl.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 708e514aca25..2f91abb62a1d 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -5457,6 +5457,34 @@ long btrfs_ioctl(struct file *file, unsigned int return btrfs_ioctl_get_fslabel(fs_info, argp); case FS_IOC_SETFSLABEL: return btrfs_ioctl_set_fslabel(file, argp); + case FS_IOC_SET_ENCRYPTION_POLICY: { + if (!IS_ENABLED(CONFIG_FS_ENCRYPTION)) + return -EOPNOTSUPP; + if (sb_rdonly(fs_info->sb)) + return -EOPNOTSUPP; + /* + * If we crash before we commit, nothing encrypted could have + * been written so it doesn't matter whether the encrypted + * state persists. + */ + btrfs_set_fs_incompat(fs_info, FSCRYPT); + return fscrypt_ioctl_set_policy(file, (const void __user *)arg); + } + case FS_IOC_GET_ENCRYPTION_POLICY: + return fscrypt_ioctl_get_policy(file, (void __user *)arg); + case FS_IOC_GET_ENCRYPTION_POLICY_EX: + return fscrypt_ioctl_get_policy_ex(file, (void __user *)arg); + case FS_IOC_ADD_ENCRYPTION_KEY: + return fscrypt_ioctl_add_key(file, (void __user *)arg); + case FS_IOC_REMOVE_ENCRYPTION_KEY: + return fscrypt_ioctl_remove_key(file, (void __user *)arg); + case FS_IOC_REMOVE_ENCRYPTION_KEY_ALL_USERS: + return fscrypt_ioctl_remove_key_all_users(file, + (void __user *)arg); + case FS_IOC_GET_ENCRYPTION_KEY_STATUS: + return fscrypt_ioctl_get_key_status(file, (void __user *)arg); + case FS_IOC_GET_ENCRYPTION_NONCE: + return fscrypt_ioctl_get_nonce(file, (void __user *)arg); case FITRIM: return btrfs_ioctl_fitrim(fs_info, argp); case BTRFS_IOC_SNAP_CREATE: -- 2.35.1