Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1413107pxk; Sun, 13 Sep 2020 01:39:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRX7nGJGIx6mysVj6Ty3ovHbGZI8qR0iAAp4YzyicB7hE1VhfoZUCwSfSEyBBpv5AXrHkD X-Received: by 2002:a17:907:685:: with SMTP id wn5mr1789593ejb.285.1599986348430; Sun, 13 Sep 2020 01:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599986348; cv=none; d=google.com; s=arc-20160816; b=zXzgHUE4OFaxDYfR95pbUTP/iVIPIPSCyYJ7Lyl9cj23505bBYCOZol7/uoQ6scDy3 be8FJoUElSBw9vbyVSIF2qUKtdhQBT290q9WtgXuQnK9s2PYAqoDGDe+2QEy+bohPdoI q0A0HbA08+Lzy3+Qyd2+s1dIrJZ9kuwTfhZQC3cN8YV3llSl2yp5iZ4HjUUx3DIHlpjc f6qhzwuhiarB7PYTfV8nRfbkSaBBU60v2fBOX6yD7IAWgMaAzGCkir+Sar2JU5FXNDu4 VGOQp/iSVeb2CV0lrOCJxSuBCGNhRWeuP/MLIiJpKUtJ6WMNlfWiNTxRzQcBAnjmQmV0 Wojw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EyjFKoST5U0kuWnqnUhGCsU4YqesdRAlUpxPIzb2lI0=; b=Iw0wAITRxh6TDpH2TLvUHd/DOBDC6MkFYoWW3HzUN20f7yo1I/QVxbA2iMWOEuhYfp hWf0kLr2cy1w7UsEE37vHBAvxGEkx/W48BRtYONmm+73RBuD0IKiHmPALNfHsRVZ3oj+ 9z5cR8cxHHEHbXql5qGBLCoIq/X8k1ah2lcZwu+lB523ITnaejYKqAmE/zM1PpiC+tDA muJPItNT3nvQ2wah5+XYlfd+leUFQAfsYAP2at6aREfD99GgUQwtrVdOnuw0Debnk2di MX+AsX39frSK986ruLKvW9KLAlVBw/+TwfNE4VlisJkV/wJHVNh8X0IWeaAMFd+se5st 6EIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zwrK+k53; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si5029436edr.13.2020.09.13.01.38.44; Sun, 13 Sep 2020 01:39:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zwrK+k53; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725992AbgIMIi2 (ORCPT + 99 others); Sun, 13 Sep 2020 04:38:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:60910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725972AbgIMIiF (ORCPT ); Sun, 13 Sep 2020 04:38:05 -0400 Received: from sol.attlocal.net (172-10-235-113.lightspeed.sntcca.sbcglobal.net [172.10.235.113]) (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 47AB12177B; Sun, 13 Sep 2020 08:38:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599986280; bh=7wQf9Y1Ge/SR2fWtRDGBHBDQ9VcJIvgAiZJHiDlXVEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zwrK+k53ctQTtemSNOcktR68ukUN1sYgfusdrpKvROi2SHYNuhB0Z3cuqHWUGFP+g D2zzBdN5bj+hkP9FDiiRMu1yN1xOPI6llElIUCFMZUmWhRfYKVknYCFWCbL+MExBGt IiJc+P2KyMx7HAYgKeD5Zic2/IUSD9CeQNNYj2I0= From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, ceph-devel@vger.kernel.org, Jeff Layton , Daniel Rosenberg Subject: [PATCH v2 09/11] fscrypt: make "#define fscrypt_policy" user-only Date: Sun, 13 Sep 2020 01:36:18 -0700 Message-Id: <20200913083620.170627-10-ebiggers@kernel.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200913083620.170627-1-ebiggers@kernel.org> References: <20200913083620.170627-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Eric Biggers The fscrypt UAPI header defines fscrypt_policy to fscrypt_policy_v1, for source compatibility with old userspace programs. Internally, the kernel doesn't want that compatibility definition. Instead, fscrypt_private.h #undefs it and re-defines it to a union. That works for now. However, in order to add fscrypt_operations::get_dummy_policy(), we'll need to forward declare 'union fscrypt_policy' in include/linux/fscrypt.h. That would cause build errors because "fscrypt_policy" is used in ioctl numbers. To avoid this, modify the UAPI header to make the fscrypt_policy compatibility definition conditional on !__KERNEL__, and make the ioctls use fscrypt_policy_v1 instead of fscrypt_policy. Note that this doesn't change the actual ioctl numbers. Signed-off-by: Eric Biggers --- fs/crypto/fscrypt_private.h | 1 - include/uapi/linux/fscrypt.h | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index 355f6d9377517..ac3352086ee44 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -97,7 +97,6 @@ static inline const u8 *fscrypt_context_nonce(const union fscrypt_context *ctx) return NULL; } -#undef fscrypt_policy union fscrypt_policy { u8 version; struct fscrypt_policy_v1 v1; diff --git a/include/uapi/linux/fscrypt.h b/include/uapi/linux/fscrypt.h index 7875709ccfebf..e5de603369381 100644 --- a/include/uapi/linux/fscrypt.h +++ b/include/uapi/linux/fscrypt.h @@ -45,7 +45,6 @@ struct fscrypt_policy_v1 { __u8 flags; __u8 master_key_descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE]; }; -#define fscrypt_policy fscrypt_policy_v1 /* * Process-subscribed "logon" key description prefix and payload format. @@ -156,9 +155,9 @@ struct fscrypt_get_key_status_arg { __u32 __out_reserved[13]; }; -#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy) +#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy_v1) #define FS_IOC_GET_ENCRYPTION_PWSALT _IOW('f', 20, __u8[16]) -#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy) +#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy_v1) #define FS_IOC_GET_ENCRYPTION_POLICY_EX _IOWR('f', 22, __u8[9]) /* size + version */ #define FS_IOC_ADD_ENCRYPTION_KEY _IOWR('f', 23, struct fscrypt_add_key_arg) #define FS_IOC_REMOVE_ENCRYPTION_KEY _IOWR('f', 24, struct fscrypt_remove_key_arg) @@ -170,6 +169,7 @@ struct fscrypt_get_key_status_arg { /* old names; don't add anything new here! */ #ifndef __KERNEL__ +#define fscrypt_policy fscrypt_policy_v1 #define FS_KEY_DESCRIPTOR_SIZE FSCRYPT_KEY_DESCRIPTOR_SIZE #define FS_POLICY_FLAGS_PAD_4 FSCRYPT_POLICY_FLAGS_PAD_4 #define FS_POLICY_FLAGS_PAD_8 FSCRYPT_POLICY_FLAGS_PAD_8 -- 2.28.0