f3dc4203dd
When the kernel supports the new fscrypt key management ioctls, use them instead of add_key() and keyctl_unlink(). This will be needed in order to support v2 encryption policies, since v2 encryption policies only support the new ioctls. The new ioctls have other advantages too. For example, FS_IOC_REMOVE_ENCRYPTION_KEY automatically evicts exactly the necessary kernel objects, so the drop_caches sysctl is no longer needed. This makes evicting keys faster and more reliable. FS_IOC_REMOVE_ENCRYPTION_KEY also detects if any files are still open and therefore couldn't be "locked", whereas this went undetected before. Therefore, to start out this patch adds support for using the new ioctls for v1 encryption policies, i.e. on existing devices. (Originally based on a patch by Satya Tangirala <satyat@google.com>) Bug: 140500828 Test: tested that a device using v1 policies continues to work, both with and without an updated kernel. See If64028d8580584b2c33c614cabd5d6b93657f608 for more details. Also checked via the log that the filesystem-level keyring is in fact used when supported. Change-Id: I296ef78138578a3fd773797ac0cd46af1296b959
48 lines
1.3 KiB
C
48 lines
1.3 KiB
C
#ifndef _UAPI_LINUX_FSCRYPT_H
|
|
#define _UAPI_LINUX_FSCRYPT_H
|
|
|
|
// Definitions for FS_IOC_ADD_ENCRYPTION_KEY and FS_IOC_REMOVE_ENCRYPTION_KEY
|
|
|
|
// TODO: switch to <linux/fscrypt.h> once it's in Bionic
|
|
|
|
#ifndef FS_IOC_ADD_ENCRYPTION_KEY
|
|
|
|
#include <linux/types.h>
|
|
|
|
#define FSCRYPT_KEY_DESCRIPTOR_SIZE 8
|
|
#define FSCRYPT_KEY_IDENTIFIER_SIZE 16
|
|
|
|
#define FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR 1
|
|
#define FSCRYPT_KEY_SPEC_TYPE_IDENTIFIER 2
|
|
|
|
struct fscrypt_key_specifier {
|
|
__u32 type;
|
|
__u32 __reserved;
|
|
union {
|
|
__u8 __reserved[32];
|
|
__u8 descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE];
|
|
__u8 identifier[FSCRYPT_KEY_IDENTIFIER_SIZE];
|
|
} u;
|
|
};
|
|
|
|
struct fscrypt_add_key_arg {
|
|
struct fscrypt_key_specifier key_spec;
|
|
__u32 raw_size;
|
|
__u32 __reserved[9];
|
|
__u8 raw[];
|
|
};
|
|
|
|
struct fscrypt_remove_key_arg {
|
|
struct fscrypt_key_specifier key_spec;
|
|
#define FSCRYPT_KEY_REMOVAL_STATUS_FLAG_FILES_BUSY 0x00000001
|
|
#define FSCRYPT_KEY_REMOVAL_STATUS_FLAG_OTHER_USERS 0x00000002
|
|
__u32 removal_status_flags;
|
|
__u32 __reserved[5];
|
|
};
|
|
|
|
#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)
|
|
|
|
#endif /* FS_IOC_ADD_ENCRYPTION_KEY */
|
|
|
|
#endif /* _UAPI_LINUX_FSCRYPT_H */
|