From b01c73ea7129745ce9d94b8d3b35663b716cd95b Mon Sep 17 00:00:00 2001 From: Satya Tangirala Date: Tue, 17 Dec 2019 14:26:29 -0800 Subject: [PATCH] BACKPORT: FROMLIST: Update Inline Encryption from v5 to v6 of patch series Changes v5 => v6: - Blk-crypto's kernel crypto API fallback is no longer restricted to 8-byte DUNs. It's also now separately configurable from blk-crypto, and can be disabled entirely, while still allowing the kernel to use inline encryption hardware. Further, struct bio_crypt_ctx takes up less space, and no longer contains the information needed by the crypto API fallback - the fallback allocates the required memory when necessary. - Blk-crypto now supports all file content encryption modes supported by fscrypt. - Fixed bio merging logic in blk-merge.c - Fscrypt now supports inline encryption with the direct key policy, since blk-crypto now has support for larger DUNs. - Keyslot manager now uses a hashtable to lookup which keyslot contains any particular key (thanks Eric!) - Fscrypt support for inline encryption now handles filesystems with multiple underlying block devices (thanks Eric!) - Numerous cleanups Bug: 137270441 Test: refer to I26376479ee38259b8c35732cb3a1d7e15f9b05a3 Change-Id: I13e2e327e0b4784b394cb1e7cf32a04856d95f01 Link: https://lore.kernel.org/linux-block/20191218145136.172774-1-satyat@google.com/ Signed-off-by: Satya Tangirala --- Documentation/block/inline-encryption.rst | 8 +- abi_gki_aarch64.xml | 37089 ++++++++++---------- block/Kconfig | 15 +- block/Makefile | 1 + block/bio-crypt-ctx.c | 117 +- block/bio.c | 8 +- block/blk-core.c | 12 +- block/blk-crypto-fallback.c | 647 + block/blk-crypto-internal.h | 58 + block/blk-crypto.c | 747 +- block/blk-merge.c | 32 +- block/bounce.c | 5 +- block/keyslot-manager.c | 256 +- drivers/md/dm.c | 14 +- drivers/scsi/ufs/ufshcd-crypto.c | 235 +- drivers/scsi/ufs/ufshcd-crypto.h | 18 +- drivers/scsi/ufs/ufshcd.c | 10 +- drivers/scsi/ufs/ufshcd.h | 4 +- fs/buffer.c | 2 +- fs/crypto/bio.c | 7 +- fs/crypto/crypto.c | 2 +- fs/crypto/fname.c | 4 +- fs/crypto/fscrypt_private.h | 136 +- fs/crypto/inline_crypt.c | 301 +- fs/crypto/keyring.c | 6 +- fs/crypto/keysetup.c | 102 +- fs/crypto/keysetup_v1.c | 16 +- fs/ext4/page-io.c | 7 +- fs/ext4/readpage.c | 8 +- fs/f2fs/data.c | 28 +- fs/f2fs/super.c | 21 + include/linux/bio-crypt-ctx.h | 291 +- include/linux/blk-crypto.h | 39 +- include/linux/fscrypt.h | 34 +- include/linux/keyslot-manager.h | 94 +- 35 files changed, 20245 insertions(+), 20129 deletions(-) create mode 100644 block/blk-crypto-fallback.c create mode 100644 block/blk-crypto-internal.h diff --git a/Documentation/block/inline-encryption.rst b/Documentation/block/inline-encryption.rst index 202826cee95e..330106b23c09 100644 --- a/Documentation/block/inline-encryption.rst +++ b/Documentation/block/inline-encryption.rst @@ -97,7 +97,7 @@ Blk-crypto ensures that: - The bio's encryption context is programmed into a keyslot in the KSM of the request queue that the bio is being submitted to (or the crypto API fallback - KSM if the request queue doesn't have a KSM), and that the ``processing_ksm`` + KSM if the request queue doesn't have a KSM), and that the ``bc_ksm`` in the ``bi_crypt_context`` is set to this KSM - That the bio has its own individual reference to the keyslot in this KSM. @@ -107,7 +107,7 @@ Blk-crypto ensures that: ensuring that the bio has a valid reference to the keyslot when, for e.g., the crypto API fallback KSM in blk-crypto performs crypto on the device's behalf. The individual references are ensured by increasing the refcount for the - keyslot in the ``processing_ksm`` when a bio with a programmed encryption + keyslot in the ``bc_ksm`` when a bio with a programmed encryption context is cloned. @@ -120,7 +120,7 @@ been programmed into any keyslot in any KSM (for e.g. a bio from the FS). request queue the bio is being submitted to (and if this KSM does not exist, then it will program it into blk-crypto's internal KSM for crypto API fallback). The KSM that this encryption context was programmed into is stored - as the ``processing_ksm`` in the bio's ``bi_crypt_context``. + as the ``bc_ksm`` in the bio's ``bi_crypt_context``. **Case 2:** blk-crypto is given a bio whose encryption context has already been programmed into a keyslot in the *crypto API fallback* KSM. @@ -138,7 +138,7 @@ KSM). This way, when a device driver is processing a bio, it can be sure that the bio's encryption context has been programmed into some KSM (either the device driver's request queue's KSM, or blk-crypto's crypto API fallback KSM). -It then simply needs to check if the bio's processing_ksm is the device's +It then simply needs to check if the bio's ``bc_ksm`` is the device's request queue's KSM. If so, then it should proceed with IE. If not, it should simply do nothing with respect to crypto, because some other KSM (perhaps the blk-crypto crypto API fallback KSM) is handling the en/decryption. diff --git a/abi_gki_aarch64.xml b/abi_gki_aarch64.xml index 1bba8b45cf63..eaa82a7d5a5e 100644 --- a/abi_gki_aarch64.xml +++ b/abi_gki_aarch64.xml @@ -1699,70 +1699,74 @@ - + + + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1777,69 +1781,69 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1848,7 +1852,7 @@ - + @@ -1878,19 +1882,19 @@ - + - + - + - + - + @@ -1899,7 +1903,7 @@ - + @@ -1908,30 +1912,30 @@ - + - + - + - + - + - + - + @@ -1952,74 +1956,74 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2028,33 +2032,33 @@ - + - + - - - - + + + + - + - + - + - + - + - + @@ -2063,10 +2067,10 @@ - + - + @@ -2075,19 +2079,19 @@ - + - + - + - + - + @@ -2099,30 +2103,30 @@ - + - + - + - + - + - + - + @@ -2131,12 +2135,12 @@ - + - + - + @@ -2154,160 +2158,160 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2321,7 +2325,7 @@ - + @@ -2338,15 +2342,15 @@ - + - + - + - + @@ -2360,56 +2364,56 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + @@ -2420,7 +2424,7 @@ - + @@ -2432,37 +2436,37 @@ - + - + - + - + - + - + - + @@ -2473,91 +2477,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2566,29 +2570,29 @@ - + - + - + - + - + - + - - - + + + @@ -2605,17 +2609,17 @@ - + - + - + - + @@ -2624,29 +2628,29 @@ - + - + - + - + - + - + - + @@ -2654,17 +2658,17 @@ - + - + - + @@ -2672,38 +2676,38 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -2715,55 +2719,55 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2774,10 +2778,10 @@ - + - + @@ -2786,16 +2790,16 @@ - + - + - + - + @@ -2804,33 +2808,33 @@ - + - + - + - + - + - + - + - + @@ -2842,27 +2846,27 @@ - + - + - + - + - + - + - + @@ -2871,7 +2875,7 @@ - + @@ -2880,35 +2884,35 @@ - + - + - + - + - + - + - + - + - + @@ -2917,50 +2921,50 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2981,13 +2985,13 @@ - + - + @@ -3011,22 +3015,22 @@ - + - + - + - + @@ -3035,16 +3039,16 @@ - + - + - + - + @@ -3053,10 +3057,10 @@ - + - + @@ -3067,7 +3071,7 @@ - + @@ -3076,7 +3080,7 @@ - + @@ -3094,34 +3098,34 @@ - + - + - + - + - + - + - + - + - + @@ -3130,25 +3134,25 @@ - - + + - + - + - + - + @@ -3159,7 +3163,7 @@ - + @@ -3171,39 +3175,39 @@ - + - + - + - + - + - + - + - + - + - + @@ -3224,19 +3228,19 @@ - + - + - + - + - + @@ -3245,25 +3249,25 @@ - + - + - + - + - + @@ -3287,7 +3291,7 @@ - + @@ -3299,19 +3303,19 @@ - + - + - + @@ -3319,7 +3323,7 @@ - + @@ -3333,7 +3337,7 @@ - + @@ -3360,7 +3364,7 @@ - + @@ -3374,27 +3378,27 @@ - + - + - + - + - + - + - + @@ -3407,46 +3411,46 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -3458,7 +3462,7 @@ - + @@ -3466,30 +3470,30 @@ - + - + - + - + - + - + - + @@ -3501,15 +3505,15 @@ - + - + - + @@ -3518,23 +3522,23 @@ - + - + - + - + - + - + - + @@ -3552,19 +3556,19 @@ - + - + - + - + @@ -3573,42 +3577,42 @@ - + - + - + - + - + - + - + - + - + - + @@ -3617,10 +3621,10 @@ - + - + @@ -3644,7 +3648,7 @@ - + @@ -3653,10 +3657,10 @@ - + - + @@ -3665,7 +3669,7 @@ - + @@ -3683,7 +3687,7 @@ - + @@ -3692,9 +3696,9 @@ - + - + @@ -3703,7 +3707,7 @@ - + @@ -3714,12 +3718,12 @@ - + - + - + @@ -3730,27 +3734,27 @@ - + - + - + - + - + - + @@ -3758,96 +3762,96 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3856,22 +3860,22 @@ - + - + - + - + - + @@ -3886,22 +3890,22 @@ - + - + - + - + - + - + @@ -3934,19 +3938,19 @@ - + - + - + @@ -3955,16 +3959,16 @@ - + - + - + @@ -3973,16 +3977,16 @@ - + - + - + @@ -3994,19 +3998,19 @@ - + - + - + - + @@ -4015,31 +4019,31 @@ - + - + - + - + - + - + - + @@ -4057,18 +4061,18 @@ - + - + - + - + - + @@ -4083,19 +4087,19 @@ - + - + - + - + - + @@ -4103,10 +4107,10 @@ - + - + @@ -4115,7 +4119,7 @@ - + @@ -4127,22 +4131,22 @@ - + - + - + - + - + @@ -4154,13 +4158,13 @@ - + - + - + @@ -4169,10 +4173,10 @@ - + - + @@ -4184,22 +4188,22 @@ - + - + - + - + - + @@ -4208,15 +4212,15 @@ - + - + - + - + @@ -4224,23 +4228,23 @@ - + - - - + + + - + - + - + @@ -4249,51 +4253,51 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4302,16 +4306,16 @@ - + - + - + @@ -4329,18 +4333,18 @@ - + - + - + - + - + @@ -4355,18 +4359,18 @@ - + - + - + - + @@ -4374,18 +4378,18 @@ - + - + - - + + - + @@ -4394,35 +4398,35 @@ - + - + - + - + - - - + + + - + - + - + @@ -4434,12 +4438,12 @@ - + - + - + @@ -4448,7 +4452,7 @@ - + @@ -4457,16 +4461,16 @@ - + - + - + @@ -4475,200 +4479,200 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - + + + + + + + + + - - - - - + + + + + - + @@ -4706,7 +4710,7 @@ - + @@ -4762,80 +4766,80 @@ - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -4844,31 +4848,31 @@ - + - + - + - + - + - + - + - + @@ -4877,84 +4881,84 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + @@ -4969,61 +4973,72 @@ - - + + - + - + - + - - - - - - - - - - + - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + @@ -5056,7 +5071,7 @@ - + @@ -5065,7 +5080,7 @@ - + @@ -5080,21 +5095,21 @@ - + - + - + - + - + @@ -5106,10 +5121,10 @@ - + - + @@ -5124,78 +5139,78 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -5207,10 +5222,10 @@ - + - + @@ -5225,7 +5240,7 @@ - + @@ -5236,7 +5251,7 @@ - + @@ -5245,7 +5260,7 @@ - + @@ -5260,22 +5275,22 @@ - + - + - + - + @@ -5293,22 +5308,22 @@ - + - + - + - + - + - + @@ -5320,13 +5335,13 @@ - + - + @@ -5338,10 +5353,10 @@ - + - + @@ -5359,10 +5374,10 @@ - + - + @@ -5374,46 +5389,46 @@ - + - + - + - + - + - + - + - + - + - + @@ -5428,7 +5443,7 @@ - + @@ -5437,33 +5452,33 @@ - - + + - + - - + + - + - + - + - + - + @@ -5480,7 +5495,7 @@ - + @@ -5496,16 +5511,16 @@ - + - + - + @@ -5601,7 +5616,7 @@ - + @@ -5610,16 +5625,16 @@ - + - + - + @@ -5628,7 +5643,7 @@ - + @@ -5636,12 +5651,12 @@ - + - + - + @@ -5653,7 +5668,7 @@ - + @@ -5662,7 +5677,7 @@ - + @@ -5677,23 +5692,23 @@ - + - + - + - + - + @@ -5703,9 +5718,9 @@ - + - + @@ -5713,15 +5728,15 @@ - + - + - + - + @@ -5732,10 +5747,10 @@ - + - + @@ -5761,13 +5776,13 @@ - + - + - + @@ -5781,7 +5796,7 @@ - + @@ -5789,10 +5804,10 @@ - + - + @@ -5809,18 +5824,18 @@ - + - + - + - + @@ -5831,7 +5846,7 @@ - + @@ -5839,16 +5854,16 @@ - - + + - + - + @@ -5860,7 +5875,7 @@ - + @@ -5869,7 +5884,7 @@ - + @@ -5881,19 +5896,19 @@ - + - + - + - + - + @@ -5902,20 +5917,20 @@ - + - + - + - + - + @@ -5924,16 +5939,16 @@ - + - + - - + + @@ -5970,15 +5985,15 @@ - + - + - + @@ -6007,7 +6022,7 @@ - + @@ -6015,7 +6030,7 @@ - + @@ -6023,31 +6038,31 @@ - + - + - + - + - + - + - + @@ -6059,18 +6074,18 @@ - + - + - + - + - + @@ -6084,7 +6099,7 @@ - + @@ -6098,18 +6113,18 @@ - + - + - + - + @@ -6130,16 +6145,16 @@ - + - + - + - + @@ -6150,22 +6165,22 @@ - + - + - + - + - + @@ -6176,9 +6191,9 @@ - + - + @@ -6187,24 +6202,24 @@ - + - + - + - + - + - + - + @@ -6212,15 +6227,15 @@ - + - + - + @@ -6229,10 +6244,10 @@ - + - + @@ -6250,7 +6265,7 @@ - + @@ -6268,7 +6283,7 @@ - + @@ -6276,16 +6291,16 @@ - + - + - + @@ -6296,935 +6311,937 @@ - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - - - + + + - - - - - + + + + + - + - + - - + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - - - - - - - - - - - - + + - - + - - + - - - - - + - - - - - - - - - - - - - - - - - - - - - + - - - + + + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + - + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - + - + + + - - - - + + - - + + - + - - + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + + - - + + - - - - - - - - - - - - - - - - - + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - - - - - - - - + + + + - - - - + + + - - - - - - - - - - - - - - - - - - - - + + + + - - - + + + + - - - - + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - + - - + + - + - + - - + + - + - - - - - - - - - - - - - - - - - + + - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - + + - - + + + - - - + + - - + + + + + + + - - + + + - - - + + - - - - + + - - - - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - + - - - + - - + - - + + - - + + + + - - + + - - + + - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -7247,17 +7264,17 @@ - - - - - + + + + + - - + + - + @@ -7282,11 +7299,11 @@ - + - + @@ -7296,45 +7313,45 @@ - - + + - - + + - - + + - + - + - + - + - + - + - + - + @@ -7343,7 +7360,7 @@ - + @@ -7352,7 +7369,7 @@ - + @@ -7361,10 +7378,10 @@ - + - + @@ -7391,15 +7408,15 @@ - + - + - + @@ -7419,50 +7436,50 @@ - - - - - + + + - + + + - - - + + + - - - + + + - - - - - - - + + + - - + + - - + + + + + + - + - + @@ -7474,7 +7491,7 @@ - + @@ -7486,9 +7503,9 @@ - + - + @@ -7500,74 +7517,74 @@ - + - - + + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + @@ -7575,18 +7592,18 @@ - - + + - + - + @@ -7626,124 +7643,124 @@ - - + + - + - + - + - + - + - - + + - + - + - + - + - + - - + + - + - - + + - + - + - - + + - + - - + + - - + + - - + + - - + + - + - + - - + + - + - - + + - - + + - + @@ -7751,556 +7768,556 @@ - - + + - - + + - - + + - - + + - + - + - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - - + + - + - + - + - + - + - - + + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - - - - - - - - + + + - - + + + - + + + + + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - + - - - - + + + + - + - - + + - + - + - + - + - - + + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - - + + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8309,24 +8326,24 @@ - + - + - + - + - + - - - + + + @@ -8351,7 +8368,7 @@ - + @@ -8374,11 +8391,11 @@ - - - - - + + + + + @@ -8401,34 +8418,34 @@ - + - + - + - + - + - + - + @@ -8437,66 +8454,66 @@ - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8504,12 +8521,12 @@ - + - + - + @@ -8518,75 +8535,75 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8594,74 +8611,74 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8669,18 +8686,18 @@ - + - + - + - + - + @@ -8689,86 +8706,86 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8777,18 +8794,18 @@ - + - + - + - + @@ -8818,13 +8835,13 @@ - + - + @@ -8833,80 +8850,80 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -8915,22 +8932,22 @@ - + - + - + - + - + - + @@ -8948,18 +8965,18 @@ - + - + - + - + - + @@ -8967,49 +8984,49 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -9021,7 +9038,7 @@ - + @@ -9030,40 +9047,40 @@ - + - - + + - + - + - + - + - + - + - + - + - + @@ -9071,29 +9088,29 @@ - + - + - + - + - + - + @@ -9104,34 +9121,34 @@ - + - + - + - + - + - + - + @@ -9140,43 +9157,43 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -9185,22 +9202,22 @@ - + - + - + - + @@ -9224,187 +9241,187 @@ - + - + - + - + - + - + - + - + - - - + + + - + - - - - + + + + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - - - + + + - + - - - + + + - + - + @@ -9416,41 +9433,41 @@ - + - + - + - + - + - + - + - + - - - + + + - + @@ -9461,10 +9478,10 @@ - + - + @@ -9475,45 +9492,45 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -9528,7 +9545,7 @@ - + @@ -9540,49 +9557,49 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -9591,25 +9608,25 @@ - + - + - + - + @@ -9621,46 +9638,46 @@ - + - + - + - + - + - + - + - + - + - + @@ -9668,63 +9685,63 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -9733,25 +9750,25 @@ - + - + - + - + - + - + @@ -9760,10 +9777,10 @@ - + - + @@ -9772,10 +9789,10 @@ - + - + @@ -9784,19 +9801,19 @@ - + - + - + - + - + @@ -9808,19 +9825,19 @@ - + - + - + - + - + @@ -9835,22 +9852,22 @@ - + - + - + - + @@ -9862,37 +9879,37 @@ - + - + - + - + - + - + - + - + - + @@ -9900,19 +9917,19 @@ - + - + - + - + - + @@ -9930,50 +9947,50 @@ - + - + - + - + - - + + - + - + - + - + - - + + - + - + - + - + - + @@ -9981,108 +9998,108 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -10090,13 +10107,13 @@ - + - + @@ -10105,60 +10122,60 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -10167,18 +10184,18 @@ - + - + - + - + @@ -10187,76 +10204,76 @@ - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -10273,119 +10290,119 @@ - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -10394,18 +10411,18 @@ - + - + - + - + - + @@ -10417,10 +10434,10 @@ - + - + @@ -10441,51 +10458,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -10493,19 +10510,19 @@ - + - + - + - + @@ -10514,16 +10531,16 @@ - + - + - + @@ -10538,29 +10555,29 @@ - + - + - + - + - + - + - + - + @@ -10575,7 +10592,7 @@ - + @@ -10590,10 +10607,10 @@ - + - + @@ -10626,7 +10643,7 @@ - + @@ -10662,37 +10679,37 @@ - + - + - + - + - + - + - + - + - + @@ -10701,20 +10718,20 @@ - + - + - - + + - + - - + + @@ -10725,19 +10742,19 @@ - + - + - - + + - + - + @@ -10752,7 +10769,7 @@ - + @@ -10767,7 +10784,7 @@ - + @@ -10791,19 +10808,19 @@ - + - + - + - + - + @@ -10812,28 +10829,28 @@ - + - + - + - + - + @@ -10842,28 +10859,28 @@ - + - + - + - + - + - + - + @@ -10920,7 +10937,7 @@ - + @@ -10932,10 +10949,10 @@ - + - + @@ -10944,7 +10961,7 @@ - + @@ -10953,10 +10970,10 @@ - + - + @@ -10965,13 +10982,13 @@ - + - + - + @@ -10983,13 +11000,13 @@ - + - + @@ -11010,52 +11027,52 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -11070,7 +11087,7 @@ - + @@ -11079,7 +11096,7 @@ - + @@ -11088,49 +11105,49 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -11145,10 +11162,10 @@ - + - + @@ -11157,28 +11174,28 @@ - + - + - + - + - + - + @@ -11187,16 +11204,16 @@ - + - + - + @@ -11220,10 +11237,10 @@ - + - + @@ -11232,22 +11249,22 @@ - + - + - + - + - + @@ -11256,15 +11273,15 @@ - + - + - + @@ -11276,16 +11293,16 @@ - - + + - + - + @@ -11309,25 +11326,25 @@ - + - + - + - + - + - + @@ -11335,7 +11352,7 @@ - + @@ -11361,7 +11378,7 @@ - + @@ -11418,8 +11435,8 @@ - - + + @@ -11445,10 +11462,10 @@ - + - + @@ -11456,7 +11473,7 @@ - + @@ -11470,27 +11487,27 @@ - + - + - + - + - + - + - + - + @@ -11508,7 +11525,7 @@ - + @@ -11532,76 +11549,76 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + @@ -11630,61 +11647,61 @@ - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - + - + - + - + @@ -11698,7 +11715,7 @@ - + @@ -11709,44 +11726,44 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -11761,60 +11778,60 @@ - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - - - + + + + - + @@ -11829,9 +11846,9 @@ - - - + + + @@ -11839,16 +11856,16 @@ - + - + - + - + @@ -11856,49 +11873,49 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -11907,16 +11924,16 @@ - + - + - + - + @@ -11925,35 +11942,35 @@ - + - + - + - - + + - + - + - + - + - + @@ -11962,47 +11979,47 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -12013,26 +12030,26 @@ - + - + - + - + - + - + @@ -12040,63 +12057,63 @@ - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -12108,7 +12125,7 @@ - + @@ -12119,16 +12136,16 @@ - + - + - + - + @@ -12137,51 +12154,51 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -12190,10 +12207,10 @@ - + - + @@ -12204,7 +12221,7 @@ - + @@ -12215,7 +12232,7 @@ - + @@ -12223,166 +12240,166 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + + + + - + @@ -12391,45 +12408,45 @@ - + - + - + - + - + - + - + - + - + - + - - + + - + @@ -12450,13 +12467,13 @@ - + - + - + @@ -12465,10 +12482,10 @@ - + - + @@ -12491,7 +12508,7 @@ - + @@ -12499,41 +12516,41 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -12548,49 +12565,49 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -12608,75 +12625,75 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -12712,28 +12729,28 @@ - + - + - + - + - + - + - + - + @@ -12742,7 +12759,7 @@ - + @@ -12760,22 +12777,22 @@ - + - + - + - + - + - + @@ -12784,22 +12801,22 @@ - + - + - + - + - + - + @@ -12811,64 +12828,64 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -12877,25 +12894,25 @@ - + - + - + - + - + - + - + @@ -12904,37 +12921,37 @@ - + - + - + - + - + - + - + - + @@ -12943,34 +12960,34 @@ - + - + - + - + - + - + - + - + @@ -12979,64 +12996,64 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -13045,15 +13062,15 @@ - + - + - + - + @@ -13061,8 +13078,8 @@ - - + + @@ -13133,213 +13150,213 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + @@ -13348,9 +13365,9 @@ - + - + @@ -13359,9 +13376,9 @@ - + - + @@ -13370,18 +13387,18 @@ - + - + - + - + @@ -13392,33 +13409,33 @@ - + - + - + - + - + - + - + - + - + @@ -13439,130 +13456,130 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -13574,7 +13591,7 @@ - + @@ -13586,56 +13603,56 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + @@ -13643,40 +13660,40 @@ - - - - + + + + - + - + - + - + - + - + - + - + - + - + @@ -13685,7 +13702,7 @@ - + @@ -13697,20 +13714,20 @@ - + - + - + - + - - - + + + @@ -13718,19 +13735,19 @@ - + - + - + - + - + @@ -13738,43 +13755,43 @@ - + - + - + - + - + - + - + - + - + - - + + - + - + - - + + @@ -13782,8 +13799,8 @@ - - + + @@ -13800,20 +13817,20 @@ - + - + - - + + - - + + @@ -13821,8 +13838,8 @@ - - + + @@ -13830,11 +13847,11 @@ - + - - + + @@ -13842,13 +13859,13 @@ - + - + @@ -13922,42 +13939,42 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -13983,7 +14000,7 @@ - + @@ -13991,7 +14008,7 @@ - + @@ -14005,67 +14022,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -14074,12 +14091,12 @@ - + - + - + @@ -14088,29 +14105,29 @@ - + - + - + - + - + - + - + - + @@ -14124,9 +14141,9 @@ - + - + @@ -14136,63 +14153,63 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -14201,49 +14218,49 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -14251,946 +14268,946 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + @@ -15198,59 +15215,59 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -15259,44 +15276,44 @@ - + - - - + + + - + - + - + - + - + - + - + - + - + @@ -15305,39 +15322,39 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -15345,24 +15362,24 @@ - + - + - + - + - + - + - + @@ -15370,58 +15387,58 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + @@ -15436,13 +15453,13 @@ - + - + @@ -15453,10 +15470,10 @@ - + - + @@ -15474,15 +15491,15 @@ - + - + - + - + @@ -15491,13 +15508,13 @@ - + - + - + @@ -15506,60 +15523,60 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -15571,107 +15588,107 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -15680,10 +15697,10 @@ - + - + @@ -15695,10 +15712,10 @@ - + - + @@ -15739,38 +15756,38 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -15788,61 +15805,61 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -15860,52 +15877,52 @@ - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + @@ -15913,23 +15930,23 @@ - + - + - + - + - + - + @@ -15937,27 +15954,27 @@ - + - + - + - + - + - + @@ -15966,14 +15983,14 @@ - + - - - + + + @@ -15987,33 +16004,33 @@ - + - + - + - + - + - + - + - + - + @@ -16022,28 +16039,28 @@ - + - + - + - + - + - + - + @@ -16055,55 +16072,55 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -16118,46 +16135,46 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -16166,87 +16183,87 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -16254,78 +16271,78 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -16334,59 +16351,59 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + @@ -16403,19 +16420,19 @@ - + - + - + - + @@ -16451,16 +16468,16 @@ - + - + - + @@ -16478,19 +16495,19 @@ - + - + - + - + @@ -16535,10 +16552,10 @@ - + - + @@ -16559,16 +16576,16 @@ - + - + - + - + @@ -16579,31 +16596,31 @@ - + - + - + - + - + - + - + - + @@ -16621,7 +16638,7 @@ - + @@ -16630,7 +16647,7 @@ - + @@ -16638,16 +16655,16 @@ - + - + - + @@ -16656,80 +16673,80 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + @@ -16738,7 +16755,7 @@ - + @@ -16749,15 +16766,15 @@ - + - + - + @@ -16776,21 +16793,21 @@ - + - + - + - + @@ -16799,21 +16816,21 @@ - + - + - + - + - + @@ -16825,16 +16842,16 @@ - + - + - + @@ -16843,92 +16860,92 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + @@ -16937,20 +16954,20 @@ - + - + - + - + - + @@ -16964,32 +16981,32 @@ - + - + - + - + - + - + - + - + @@ -16997,12 +17014,12 @@ - + - + - + @@ -17032,24 +17049,24 @@ - + - + - + - + - + - + - + @@ -17058,49 +17075,49 @@ - + - + - - + + - + - - + + - + - + - + - + - + - + - + - + @@ -17109,7 +17126,7 @@ - + @@ -17118,24 +17135,24 @@ - + - + - + - + - + - + @@ -17143,18 +17160,18 @@ - + - - - + + + - + @@ -17163,7 +17180,7 @@ - + @@ -17174,62 +17191,62 @@ - - + + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - - - + + + - + - + @@ -17241,12 +17258,12 @@ - + - + - + @@ -17258,17 +17275,17 @@ - + - + - + - - + + @@ -17276,33 +17293,33 @@ - + - + - + - - + + - + - + @@ -17310,7 +17327,7 @@ - + @@ -17318,79 +17335,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -17398,10 +17415,10 @@ - + - + @@ -17409,57 +17426,57 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -17470,242 +17487,242 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -17714,55 +17731,55 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -17783,7 +17800,7 @@ - + @@ -17966,10 +17983,10 @@ - + - + @@ -17978,7 +17995,7 @@ - + @@ -17987,13 +18004,13 @@ - + - + - + @@ -18023,7 +18040,7 @@ - + @@ -18035,13 +18052,13 @@ - + - + @@ -18050,10 +18067,10 @@ - + - + @@ -18067,68 +18084,68 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -18137,37 +18154,37 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -18176,94 +18193,94 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + + + + - + - + - + @@ -18272,120 +18289,120 @@ - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -18400,31 +18417,31 @@ - + - + - + - + - + - + - + - + - + @@ -18433,36 +18450,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -18543,57 +18560,57 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -18604,47 +18621,47 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -18653,9 +18670,9 @@ - + - + @@ -18664,7 +18681,7 @@ - + @@ -18672,25 +18689,25 @@ - + - + - + - + - + - + @@ -18714,60 +18731,60 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -18805,54 +18822,54 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -18864,58 +18881,58 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -18924,37 +18941,37 @@ - + - + - + - + - + - + - + - + - + @@ -18969,146 +18986,146 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -19126,7 +19143,7 @@ - + @@ -19135,7 +19152,7 @@ - + @@ -19147,30 +19164,30 @@ - + - + - + - + - + - + - + - + @@ -19194,18 +19211,18 @@ - + - + - + - + - + @@ -19241,98 +19258,98 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -19341,7 +19358,7 @@ - + @@ -19356,46 +19373,46 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -19404,31 +19421,31 @@ - + - + - + - + - + - + - + @@ -19437,7 +19454,7 @@ - + @@ -19446,32 +19463,32 @@ - + - + - + - + - + - + - + @@ -19480,155 +19497,155 @@ - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -19655,27 +19672,27 @@ - + - + - + - + - + - + @@ -19690,64 +19707,64 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + @@ -19761,13 +19778,13 @@ - + - + - + @@ -19779,7 +19796,7 @@ - + @@ -19800,40 +19817,40 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -19854,7 +19871,7 @@ - + @@ -19899,54 +19916,54 @@ - + - + - + - + - + - + - + - + - + - + - - + + - + - + @@ -19954,9 +19971,9 @@ - + - + @@ -19965,7 +19982,7 @@ - + @@ -19976,7 +19993,7 @@ - + @@ -20002,26 +20019,26 @@ - + - + - + - + - + - + - + @@ -20048,28 +20065,28 @@ - + - + - + - + - + - + - + - + @@ -20147,57 +20164,57 @@ - + - + - + - + - + - + - + - + - + - + - - - - - + + + + + - + - + - + - + @@ -20208,10 +20225,10 @@ - + - + @@ -20220,44 +20237,44 @@ - + - + - + - + - + - + - + - + - + - + - - + + @@ -20268,60 +20285,60 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + @@ -20329,57 +20346,57 @@ - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + @@ -20388,15 +20405,15 @@ - + - + - + - + @@ -20404,7 +20421,7 @@ - + @@ -20415,74 +20432,74 @@ - - + + - + - + - + - + - + - + - + - - - - + + + + - + - + - + - + - + - + - + - + - + - + - + - + @@ -20490,21 +20507,21 @@ - + - + - + - - + + - + @@ -20519,12 +20536,12 @@ - + - + - + @@ -20536,7 +20553,7 @@ - + @@ -20548,12 +20565,12 @@ - + - + - + @@ -20574,10 +20591,10 @@ - + - + @@ -20618,7 +20635,7 @@ - + @@ -20626,24 +20643,24 @@ - + - + - + - + - + - + - + @@ -20654,19 +20671,19 @@ - + - + - + - + - - + + @@ -20677,49 +20694,49 @@ - + - + - + - + - + - + - + - + - + - + - - - + + + - + - + @@ -20728,60 +20745,60 @@ - + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + @@ -20789,27 +20806,27 @@ - + - + - + - + - + - + - + - + @@ -20817,58 +20834,58 @@ - - - + + + - + - + - + - + - + - + - + - + - + - - + + - + - + - + @@ -20876,7 +20893,7 @@ - + @@ -20884,16 +20901,16 @@ - + - + - + @@ -20901,7 +20918,7 @@ - + @@ -20918,31 +20935,31 @@ - + - + - + - + - + - + - + - + - + - + @@ -20951,58 +20968,58 @@ - + - + - + - + - + - + - + - + - + - + - + - - - - - + + + + + - + - + - + - + - - + + @@ -21010,15 +21027,15 @@ - + - + - + - + @@ -21027,52 +21044,52 @@ - - + + - + - + - + - + - + - + - - - + + + - + - + - + - + - + - + @@ -21083,98 +21100,98 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -21186,10 +21203,10 @@ - + - + @@ -21198,83 +21215,83 @@ - + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - + - + - + - + - - + + - + @@ -21286,80 +21303,80 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -21385,7 +21402,7 @@ - + @@ -21408,10 +21425,10 @@ - + - + @@ -21429,21 +21446,21 @@ - + - + - + - + @@ -21469,33 +21486,33 @@ - + - + - - + + - + - + - + - + - + @@ -21513,16 +21530,16 @@ - + - + - + @@ -21531,13 +21548,13 @@ - + - + - + @@ -21549,29 +21566,29 @@ - + - + - + - + - + - + - + - + @@ -21589,84 +21606,84 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -21674,86 +21691,86 @@ - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -21771,12 +21788,12 @@ - + - + - + @@ -21788,21 +21805,21 @@ - + - + - + - + - + @@ -21810,143 +21827,143 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + @@ -21955,19 +21972,19 @@ - + - + - + - + @@ -21976,69 +21993,69 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -22046,9 +22063,9 @@ - + - + @@ -22060,28 +22077,28 @@ - + - + - + - + - + - + - + @@ -22090,15 +22107,15 @@ - + - + - + - + @@ -22110,7 +22127,7 @@ - + @@ -22118,7 +22135,7 @@ - + @@ -22135,27 +22152,27 @@ - + - + - + - + - + - + - + - + @@ -22179,12 +22196,12 @@ - + - + - + @@ -22196,7 +22213,7 @@ - + @@ -22205,2747 +22222,2747 @@ - + - + - + - + - + - + - + - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - - - + + + - - - + + + - + - - - + + + - - - - - + + + + + - - - - - - - - - - - - + + + - - - + + + + - - - + + + - + + + + + + + + + - + - - + + - - + + - - - + + + - + - - - - - - - - - - - - + + + - - - + + + - - - + + + + - - + + + + + + + + + + - + - - - - + + + + - - - - - - - - - - - - - - - - - - - - - + + + - - - + + - - - - - - - - + + - - + + + - - - - - + + - - - + + + + + + - - - - + + - - + + - - - - + + + + + - - + + + - + + + + - - + + - - - + + + + - - - - + + - - + - - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - + - - - + + + - - + + + - + - - + + - - - - + + + - - - + - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - + + - - - + + + - - + + - + - - - + + + - - + + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - + + - - + + + + + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + - - + + + - - - + + + + + + - - - + + + + + + - + - + + - - - - + + + - - - + + + - + - - + + - - + + + + + - + + + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + + + + + - - + + + - - + + + + - - + + + + - - - + + + + - - + + - - + - - + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + - - - + + + - - - - + + + - - + + + + + + - - - + + + + + + + + + + - - - - - - - - - + + - - - - - - - - - - - - - - + + + - - - - - - - - - + - - - + + + + + - - - - - + + + + + + - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - + + + - - - + + + + - - + + + + - - + + + + + + - - + + - - - - - - - + + + + + + + - + - + - - - - - - - + + + + + + + - + - + + - + - - + + - - + + - + - - - + + - - + + - - + + - - - + + + - - + + - - - + + - - - + + - - + + - - - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - + + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - + + + + - - - - - + + - - + + - - + + - - - - + + + - - - + + + + + - - + + - - - + + - - + + + + - - + + + - - + + - - - + + + - - + + - - - - + + - - - - + - - + + + - + + - - - + + + + - + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - + + + - - + + - - - + + - - + + - + - - - + + - - + + + - - - + + - - - - + + - - + + - - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + + + + - - - + + + + + + - - - - - - - - - - + - - + + - - + + + - - - - - - - + + - + - - - + + + - + + + - + + + + + + + + - - - - - + + - - - - + + + - - - + - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + - - + + - - + + - + - + - - + + - + - - + + - + - - - - - - + - - - + + + + + + + + - + - - - + + + - - - - - - - - + + + - + + + + + + - + - - + + - + - - - - - - - + + + - + + + + + - - - - - - - - - - - - - - - - - - - - + + - - + + + - - - + + + - - - + + - - + - - + + - - - - - - - + + + - - - - - - + + - - + + + - + + + - - - - + + + + + + + - - - + + + + + + - - - - + + - - - - - - - + - - - + + + + - - - + + + - - + + + + - - - + + + + + + + - + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + - + + + + + + + + + + + - - - - - - - - - - - - - - - + + + + + + - - - + + + + + - - + + + - - + + + + + + + + + + + + + - + + + + + + + + + + + + + + @@ -24953,739 +24970,739 @@ - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - + + + + + - - - + - - - + + + - - - - + + - - - - + + - - + + + + - - - + + + - - - + + + + + + + + + + + + + + - + + + - - - - - - - - - - - - + + + - - - - + - - - - - - + + - - + + + - - + + - + + + - - + + + + + + - - + + + - - + + + - - - + + - - - + + - - - + - + - - + + - + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + - - + + - - - - + - + - - + + - + + - - - + + + + - - - - + - - - - - + + - - + - - - - + + + - - - - - + + + + - - - - - - - - - + + + + + + + + + - - + + - + - + + + + + - + + - - - + + + + + - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - + - - - + - + + - - + + - + - - - - - - + + + - + - - - + + - + - - - + + + + + + - + - + + + - - + - + + + - - + - - + - - + + - - - + - - + + - - - + + - - - + + - - + + + - - + + - - + + + - - + + + - - + + - - + + - - - + + - - + + - - + + - + + - - - + + + - - - + + - + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - + - + - + - - - + + - + + - - - + - + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + - - + - - + + + + + - - - + + + + - - + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -25693,15 +25710,15 @@ - + - + - + @@ -25709,15 +25726,15 @@ - + - + - + @@ -25725,7 +25742,7 @@ - + @@ -25738,28 +25755,28 @@ - + - + - + - + - + - + @@ -25770,62 +25787,62 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -25839,9 +25856,9 @@ - + - + @@ -25851,12 +25868,12 @@ - + - + @@ -25872,33 +25889,33 @@ - + - + - + - + - + - + - + - + - + @@ -25906,15 +25923,15 @@ - + - + - + @@ -25922,28 +25939,28 @@ - + - + - + - + - + - + @@ -25954,47 +25971,47 @@ - + - + - + - + - + - + - - + + - + - + - + - + - + - + @@ -26003,20 +26020,20 @@ - + - + - + - + - + @@ -26028,25 +26045,25 @@ - + - + - + - + - + - + - + - + @@ -26064,25 +26081,25 @@ - - - - + + + + - - - + + + - + - + @@ -26090,18 +26107,18 @@ - - + + - + - + @@ -26119,295 +26136,295 @@ - + - + - + - - - + + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - + + - - - + + + + + + - + - - + + - + - + - + - - + + - - + + - + - + - + - + - + - + - + - - - + + + - + - - + + - + - + - + - + - - + + - - + + - + - + @@ -26416,116 +26433,116 @@ - + - - + + - + - + - - + + - + - + - - + + - - - - + + + + - + - + - + - + - - + + - - + + - + - - + + - + - + - - + + - - + + - + - + @@ -26549,40 +26566,40 @@ - - + + - - - - - - - + + + + + + + - - + + - - + + - - + + - - + + - + - + @@ -26590,7 +26607,7 @@ - + @@ -26608,7 +26625,7 @@ - + @@ -26617,37 +26634,37 @@ - + - + - + - + - + - + - + - + @@ -26668,10 +26685,10 @@ - + - + @@ -26683,7 +26700,7 @@ - + @@ -26695,7 +26712,7 @@ - + @@ -26707,10 +26724,10 @@ - + - + @@ -26734,13 +26751,13 @@ - + - + - + @@ -26761,16 +26778,16 @@ - + - + - + @@ -26787,15 +26804,15 @@ - + - + - + - + @@ -26803,38 +26820,38 @@ - + - + - + - + - - + + - + - + @@ -26843,7 +26860,7 @@ - + @@ -26858,7 +26875,7 @@ - + @@ -26866,18 +26883,18 @@ - + - + - + - + @@ -26892,7 +26909,7 @@ - + @@ -26907,10 +26924,10 @@ - + - + @@ -26943,7 +26960,7 @@ - + @@ -26979,37 +26996,37 @@ - + - + - + - + - + - + - + - + - + @@ -27018,24 +27035,24 @@ - + - + - + - + - + - + @@ -27056,7 +27073,7 @@ - + @@ -27089,15 +27106,15 @@ - + - + - + - + @@ -27109,13 +27126,13 @@ - + - + - + @@ -27123,7 +27140,7 @@ - + @@ -27144,13 +27161,13 @@ - + - + - + @@ -27171,16 +27188,16 @@ - + - + - + - + @@ -27191,7 +27208,7 @@ - + @@ -27202,10 +27219,10 @@ - + - + @@ -27216,15 +27233,15 @@ - + - + - + - + @@ -27232,7 +27249,7 @@ - + @@ -27243,29 +27260,29 @@ - + - + - + - + - + - + - + - + @@ -27276,15 +27293,15 @@ - + - + - + - + @@ -27347,28 +27364,28 @@ - + - + - + - + - + - + - + - + @@ -27410,21 +27427,21 @@ - + - + - + - + - + @@ -27433,16 +27450,16 @@ - + - + - + @@ -27465,18 +27482,18 @@ - + - + - + - + @@ -27487,28 +27504,28 @@ - + - + - + - - - + + + - + @@ -27526,16 +27543,16 @@ - + - + - + - + @@ -27555,22 +27572,22 @@ - + - + - + - + - + @@ -27587,12 +27604,12 @@ - + - + @@ -27601,7 +27618,7 @@ - + @@ -27610,51 +27627,51 @@ - + - + - + - - + + - + - + - + - + - + - + - + - + - - + + @@ -27662,69 +27679,69 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - + + + + @@ -27737,7 +27754,7 @@ - + @@ -27747,101 +27764,101 @@ - + - + - + - - - - - - - - - - - - - - - - + - + + + + + + + + - + + + + + + + + + - - + + - - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - - - - - - - - - - + - - + + - + + + + + + + + + + + + @@ -27862,7 +27879,7 @@ - + @@ -27875,76 +27892,76 @@ - - - + + + - - - + + + - - + + - + - + - + - - - + + + - + - + - + - + - + - - + + - - + + - - - + + + - + - + @@ -27952,30 +27969,30 @@ - + - + - + - + - + - + - + - + @@ -27990,29 +28007,29 @@ - + - + - + - + - + - + - + - + @@ -28024,7 +28041,7 @@ - + @@ -28042,15 +28059,15 @@ - + - + - + - + @@ -28080,31 +28097,31 @@ - + - + - + - + - + - + - + @@ -28113,15 +28130,15 @@ - + - + - + - + @@ -28132,75 +28149,75 @@ - + - + - + - - - - - - - - + + + + + + + + - + - + - - + + - + - - + + - + - + - + - + - + - + - + @@ -28213,66 +28230,66 @@ - - - + + + - + - - + + - - - + + + - + - + - + - + - - + + - + - + - + - + @@ -28286,43 +28303,43 @@ - + - + - + - + - + - - - - - - + + + + + + - + - + - + - + @@ -28331,107 +28348,107 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - + + + + + + + + - + - + - + - + - + - + - + - - + + - - + + - + - + - - - + + + - + @@ -28442,7 +28459,7 @@ - + @@ -28461,25 +28478,25 @@ - - + + - + - + - + - - + + @@ -28493,52 +28510,52 @@ - + - + - + - + - + - + - - + + - + - + - + @@ -28549,7 +28566,7 @@ - + @@ -28563,29 +28580,27 @@ - + - + - - - - - + + + - - - - - - + + + + + + @@ -28596,127 +28611,129 @@ + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - + + - - + + - - + + - + - + - - - - - - - - - - - - + + + - - - + + - + + + + + + + + + + + - - + + - - - - - - - - - - - - + + + - - + + - - + - + + + + + + + + + + + - - + + - - + + @@ -28724,31 +28741,31 @@ - + - + - + - + - + - + - + - + @@ -28757,8 +28774,8 @@ - - + + @@ -28769,23 +28786,23 @@ - + - + - - + + - + - - + + - + @@ -28798,7 +28815,7 @@ - + @@ -28807,34 +28824,34 @@ - + - + - + - - - + + + - - + + - + - + - + - + @@ -28847,28 +28864,28 @@ - - + + - + - + - + - + - + @@ -28886,7 +28903,7 @@ - + @@ -28894,37 +28911,37 @@ - + - - + + - + - + - + - + - - + + - - + + @@ -28935,42 +28952,42 @@ - + - + - + - + - + - + - + - + - - + + - + - + @@ -28979,7 +28996,7 @@ - + @@ -28994,10 +29011,10 @@ - + - + @@ -29008,13 +29025,13 @@ - + - + - + @@ -29023,37 +29040,37 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -29065,125 +29082,125 @@ - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - - + + - - + + - + - - - - - - - - - - + + + + + + + + + + - + - + - + - + @@ -29193,28 +29210,28 @@ - + - + - + - + - + @@ -29222,33 +29239,33 @@ - - + + - + - + - + - + - + - - + + - + @@ -29288,22 +29305,22 @@ - + - + - - + + - + @@ -29317,18 +29334,18 @@ - + - + - + @@ -29340,7 +29357,7 @@ - + @@ -29356,22 +29373,22 @@ - + - + - + - + - + @@ -29380,35 +29397,35 @@ - + - - + + - - + + - + - + - - - - + + + + @@ -29419,11 +29436,11 @@ - + - - + + @@ -29437,71 +29454,71 @@ - + - + - - - - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -29510,35 +29527,35 @@ - + - + - + - + - - + + - + - + - - + + - + @@ -29550,17 +29567,17 @@ - + - + - + @@ -29568,7 +29585,7 @@ - + @@ -29582,69 +29599,69 @@ - + - - + + - + - + - + - + - - - + + + - + - + - - + + - - + + - + - + @@ -29663,27 +29680,27 @@ - + - + - + - + - + - + - + - + @@ -29693,9 +29710,9 @@ - + - + @@ -29706,20 +29723,20 @@ - + - + - - + + - + @@ -29731,36 +29748,36 @@ - + - - + + - - + + - - + + - + - + - + @@ -29772,15 +29789,15 @@ - + - - + + - + @@ -29795,41 +29812,41 @@ - + - + - + - - - + + + - + - + - + - + - + - + @@ -29843,15 +29860,15 @@ - + - + - + @@ -29863,18 +29880,18 @@ - + - + - + - + @@ -29889,7 +29906,7 @@ - + @@ -29904,10 +29921,10 @@ - + - + @@ -29940,7 +29957,7 @@ - + @@ -29976,37 +29993,37 @@ - + - + - + - + - + - + - + - + - + @@ -30015,18 +30032,18 @@ - + - + - + - + - + @@ -30034,15 +30051,15 @@ - + - + - + @@ -30050,37 +30067,37 @@ - + - + - + - + - + - + - + - + @@ -30089,17 +30106,17 @@ - + - + - + - + @@ -30108,40 +30125,40 @@ - + - + - + - + - + - - - - - - + + + + - - + + + + - + - - + + @@ -30154,7 +30171,7 @@ - + @@ -30172,66 +30189,66 @@ - + - + - + - + - - - - - - - - - - - - - - - - - - - - + + + + - - - - + + + + + + + + + + + + + + + + + + + + - + - + - + @@ -30242,10 +30259,10 @@ - + - + @@ -30257,7 +30274,7 @@ - + @@ -30268,792 +30285,94 @@ - - - + + + - - + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - - + + - + - + @@ -31071,19 +30390,19 @@ - + - + - + - + @@ -31092,22 +30411,22 @@ - + - + - + - + - + @@ -31116,7 +30435,7 @@ - + @@ -31131,10 +30450,10 @@ - + - + @@ -31152,12 +30471,12 @@ - + - + - + @@ -31166,7 +30485,7 @@ - + @@ -31177,28 +30496,28 @@ - + - + - + - + - + - + @@ -31209,10 +30528,10 @@ - + - + @@ -31220,7 +30539,7 @@ - + @@ -31231,27 +30550,27 @@ - + - + - + - + - + - + - + @@ -31260,7 +30579,7 @@ - + @@ -31269,29 +30588,29 @@ - + - + - + - + - + - + - + - + @@ -31309,39 +30628,39 @@ - + - + - + - + - + - + - + - + - + @@ -31350,18 +30669,18 @@ - + - + - + - + - + @@ -31373,13 +30692,13 @@ - + - + - + @@ -31388,18 +30707,18 @@ - + - + - + - + @@ -31408,27 +30727,27 @@ - + - + - - - - - - - - + + + + + + + + - + - + @@ -31455,287 +30774,993 @@ - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - - + + - + - - - - + + + + - - + + - + - - + + - - + + - - + + - - - + + + - - + + - - - - + + + + - - + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - - - + + + + - - - + + + - - - - + + + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - - - - - - - - - - + + - + - - - + + + - - - + + + @@ -31743,7 +31768,7 @@ - + @@ -31756,35 +31781,35 @@ - - + + - + - + - + - + - - + + - + @@ -31798,19 +31823,19 @@ - + - + - + - + - + @@ -31822,67 +31847,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -31894,16 +31919,16 @@ - - + + - + - + - + @@ -31914,247 +31939,247 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + + + + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + - - + + + + + + + + - - + + + + + + + + + + - - + + - - - + + - + + + + + + + + + + + + + + - - - + + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - + @@ -32176,176 +32201,176 @@ - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -32399,10 +32424,10 @@ - + - + @@ -32411,7 +32436,7 @@ - + @@ -32510,34 +32535,34 @@ - + - + - + - + - + - + - + @@ -32552,12 +32577,12 @@ - + - + @@ -32566,108 +32591,108 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + @@ -32675,195 +32700,195 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + - + - - + + - - - + + + - - + + - - - + + + - - - + + + - - - - + + + + - - + + - - + + - - + + @@ -32871,135 +32896,135 @@ - - - + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - + + + + + + + - + - - + + - + - + - + - + - + - + - - + + - - + + - - + + - - - + + + - - - + + + @@ -33010,53 +33035,53 @@ - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + @@ -33064,108 +33089,108 @@ - - + + - + - + - + - + - + - + - - + + - + - + - + - - + + - + - - + + - + - + - + - + - - - + + + - + - + - + - + - + - - + + - + - + - + @@ -33180,22 +33205,22 @@ - + - + - + - + @@ -33203,20 +33228,20 @@ - + - + - + - + - + - + @@ -33237,40 +33262,40 @@ - + - + - + - + - + - + - + - + - + - + @@ -33282,7 +33307,7 @@ - + @@ -33294,7 +33319,7 @@ - + @@ -33308,7 +33333,7 @@ - + @@ -33320,16 +33345,16 @@ - + - + - + @@ -33350,13 +33375,13 @@ - + - + @@ -33440,24 +33465,24 @@ - + - + - + - + - + - + @@ -33466,7 +33491,7 @@ - + @@ -33475,27 +33500,27 @@ - + - + - + - + - + @@ -33533,16 +33558,16 @@ - + - + - + - + @@ -33587,7 +33612,7 @@ - + @@ -33607,8 +33632,8 @@ - - + + @@ -33616,113 +33641,113 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -33736,9 +33761,9 @@ - + - + @@ -33747,20 +33772,20 @@ - + - + - + - + - + @@ -33772,188 +33797,188 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + - - + + - - + + - + - - - - - - - - + + + + + + + + - + - + - + - - + + - + - + @@ -33965,33 +33990,33 @@ - + - + - + - + - + - + - + - + @@ -34006,7 +34031,7 @@ - + @@ -34014,7 +34039,7 @@ - + @@ -34026,19 +34051,19 @@ - + - + - + - + - + @@ -34047,48 +34072,48 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -34098,19 +34123,19 @@ - + - + - + - - + + @@ -34121,22 +34146,22 @@ - + - + - + - + - + @@ -34144,7 +34169,7 @@ - + @@ -34153,111 +34178,111 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -34271,13 +34296,13 @@ - + - + - + @@ -34285,7 +34310,7 @@ - + @@ -34293,16 +34318,16 @@ - + - + - + - + @@ -34338,24 +34363,24 @@ - + - + - + - + - + - + @@ -34364,10 +34389,10 @@ - + - + @@ -34390,21 +34415,21 @@ - + - + - + - + - + - + @@ -34440,16 +34465,16 @@ - + - + - + - + @@ -34458,7 +34483,7 @@ - + @@ -34473,82 +34498,82 @@ - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -34557,7 +34582,7 @@ - + @@ -34566,39 +34591,39 @@ - + - + - + - + - + - + - + - + - + - + @@ -34610,10 +34635,10 @@ - + - + @@ -34628,18 +34653,18 @@ - + - + - + - + @@ -34648,403 +34673,403 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - - - - + + + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + - - - - - - + + + - - - + + + - - + + - - - + + - - - - + + - + + + - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + - + - - + + - - + + - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - - - - + + + + - + - + - + - + - + - + - + - + - + - + - + - + @@ -35056,10 +35081,10 @@ - + - + @@ -35095,13 +35120,13 @@ - + - + @@ -35113,109 +35138,109 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -35229,10 +35254,10 @@ - + - + @@ -35240,120 +35265,120 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - + + - - + + - - + + - + - + - + - + @@ -35362,7 +35387,7 @@ - + @@ -35377,12 +35402,12 @@ - + - + - + @@ -35391,104 +35416,104 @@ - + - + - + - + - + - + - + - + - - - - - - + + + + + + - + - + - + - + - - - + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -35506,10 +35531,10 @@ - + - + @@ -35518,10 +35543,10 @@ - + - + @@ -35530,110 +35555,110 @@ - - - - - - - - - - + + + + + + + + + + - + - + - + - - + + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + @@ -35642,7 +35667,7 @@ - + @@ -35651,123 +35676,123 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -35782,16 +35807,16 @@ - + - + - + - + @@ -35800,13 +35825,13 @@ - + - + - + @@ -35815,10 +35840,10 @@ - + - + @@ -35833,7 +35858,7 @@ - + @@ -35845,88 +35870,88 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -35937,68 +35962,68 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -36007,83 +36032,83 @@ - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -36109,28 +36134,28 @@ - + - + - + - + - + - + @@ -36139,15 +36164,15 @@ - + - + - + - + @@ -36156,16 +36181,16 @@ - + - + - + - + @@ -36174,16 +36199,16 @@ - + - + - + - + @@ -36195,36 +36220,36 @@ - + - + - + - + - + - + - + - + - + @@ -36233,7 +36258,7 @@ - + @@ -36242,7 +36267,7 @@ - + @@ -36256,34 +36281,34 @@ - + - + - + - + - + - + - + - + - + @@ -36301,85 +36326,85 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + @@ -36390,13 +36415,13 @@ - - + + - + - + @@ -36406,46 +36431,46 @@ - + - + - + - + - + - + - + - + - + - + - + - - + + @@ -36456,55 +36481,55 @@ - - - + + + - + - + - + - + - + - + - + - + - + - + - + - + @@ -36512,15 +36537,15 @@ - + - + - + - + @@ -36541,10 +36566,10 @@ - + - + @@ -36558,9 +36583,9 @@ - + - + @@ -36569,10 +36594,10 @@ - + - + @@ -36593,7 +36618,7 @@ - + @@ -36605,39 +36630,39 @@ - + - + - + - + - + - + - + - + - + @@ -36645,113 +36670,113 @@ - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + - + @@ -36762,288 +36787,288 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - + + + - + - - - + + + + - + - - - + + + + - + - - - - + + - + - - - - - + + + + - + + - - - + + + + - + - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + - - - - - - - - - - - - - - - - - - - - + + + - - + + + + - - + + - + + + + - + + + - - + - - + - + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - + + - - - + + + - - + + - - + + - - + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - + + - - + - - - + - - + + - - - + - - + + - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + @@ -37055,7 +37080,7 @@ - + @@ -37063,227 +37088,227 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - + + + + + + - + - + - - + + - - + + - - - + + + - - + + - - + + - - + + - + - + - + - + - + - + - + - + - - + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + - - + + - - + + - + - - + + - - + + - + - + - + - + - + - + - + @@ -37313,67 +37338,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -37388,43 +37413,43 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -37432,49 +37457,49 @@ - + - + - + - + - + - + - + - + - + - + @@ -37483,7 +37508,7 @@ - + @@ -37492,7 +37517,7 @@ - + @@ -37501,25 +37526,25 @@ - + - + - + - + - + @@ -37534,13 +37559,13 @@ - + - + - + @@ -37549,174 +37574,174 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -37740,37 +37765,37 @@ - + - + - + - + - + - + - + - + @@ -37793,31 +37818,31 @@ - + - + - + - + - + - + - + - + @@ -37829,13 +37854,13 @@ - + - + @@ -37847,17 +37872,17 @@ - + - + - - + + @@ -37865,10 +37890,10 @@ - + - + @@ -37877,32 +37902,32 @@ - + - + - + - + - + - + - + - + - + @@ -37992,7 +38017,7 @@ - + @@ -38004,67 +38029,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -38107,7 +38132,7 @@ - + @@ -38116,12 +38141,12 @@ - + - + - + @@ -38130,17 +38155,17 @@ - + - + - - - + + + @@ -38157,18 +38182,18 @@ - + - + - + - + @@ -38183,7 +38208,7 @@ - + @@ -38198,10 +38223,10 @@ - + - + @@ -38234,7 +38259,7 @@ - + @@ -38270,37 +38295,37 @@ - + - + - + - + - + - + - + - + - + @@ -38309,50 +38334,50 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -38360,33 +38385,33 @@ - - + + - + - + - + - + - + - + - + - + @@ -38410,15 +38435,15 @@ - + - + - + @@ -38427,7 +38452,7 @@ - + @@ -38448,15 +38473,15 @@ - + - + - + - + @@ -38480,59 +38505,59 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -38541,22 +38566,22 @@ - + - + - + - + @@ -38592,10 +38617,10 @@ - + - + @@ -38607,169 +38632,169 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -38781,35 +38806,35 @@ - + - + - + - + - + - + - + - + - + - + @@ -38821,62 +38846,62 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -38897,27 +38922,27 @@ - + - + - + - + - + - + - + @@ -38926,83 +38951,83 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -39014,31 +39039,31 @@ - + - + - + - + - + - + - + - + - + @@ -39053,9 +39078,9 @@ - + - + @@ -39064,29 +39089,29 @@ - + - + - + - + - + - + - + - + - + @@ -39095,21 +39120,21 @@ - + - + - + - + - + @@ -39121,35 +39146,35 @@ - + - + - + - + - + - + - + - + - + - + @@ -39158,16 +39183,16 @@ - + - + - + - + @@ -39182,10 +39207,10 @@ - + - + @@ -39194,51 +39219,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -39247,16 +39272,16 @@ - + - + - + - + @@ -39265,134 +39290,134 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -39404,42 +39429,42 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -39451,52 +39476,52 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -39510,103 +39535,103 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -39615,24 +39640,24 @@ - + - + - + - + - + - + - + @@ -39641,51 +39666,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -39724,22 +39749,22 @@ - + - + - + - + - + - + @@ -39748,21 +39773,21 @@ - + - + - + - + - + - + @@ -39777,62 +39802,62 @@ - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -39844,7 +39869,7 @@ - + @@ -39856,34 +39881,34 @@ - + - + - + - + - + - + - + - + - + - + @@ -39903,7 +39928,7 @@ - + @@ -39911,7 +39936,7 @@ - + @@ -39925,58 +39950,58 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -39994,113 +40019,113 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -40108,16 +40133,16 @@ - + - + - + - + @@ -40129,69 +40154,69 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -40218,45 +40243,45 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -40300,9 +40325,9 @@ - + - + @@ -40329,190 +40354,190 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -40526,13 +40551,13 @@ - + - + - + @@ -40540,7 +40565,7 @@ - + @@ -40554,7 +40579,7 @@ - + @@ -40562,15 +40587,15 @@ - + - + - + @@ -40585,7 +40610,7 @@ - + @@ -40594,7 +40619,7 @@ - + @@ -40612,19 +40637,19 @@ - + - + - + - + @@ -40633,24 +40658,24 @@ - + - + - + - + - + - + @@ -40658,10 +40683,10 @@ - + - + @@ -40669,74 +40694,74 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -40748,18 +40773,18 @@ - + - + - + - + @@ -40771,51 +40796,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -40826,98 +40851,98 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -40941,7 +40966,7 @@ - + @@ -40952,7 +40977,7 @@ - + @@ -40966,31 +40991,31 @@ - - + + - + - + - + - + - + - + - + - + @@ -41025,1163 +41050,1163 @@ - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - + - + - - + + - - - - - - - - - - - - - - - - - + + + - - + + + + - - - - - - - + + + - - - + + + + + + + + + + + + + + - - - - + + + - - - - - - - - - - - - - - - + + + + + - - + + + + + + + + + - - - - - - - - - - - - - + + + - - - - - - - - + + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + - - - - + - - - + - - - + - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + - + - - - - + + - - - - - - - - - - - - + + - - + - - + + - - - - + - - - + + + + - - + + + + + + + + + + + + - + + - - + + - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - + + - - - + - - - - - - - + + + - - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + + + - - + - + - - + + + - - + - + - - + + - - + - - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + + - + - - + + + - - + + + - + + - - + - - + - - + + - - + + - - + - - - + + - - + + - + + - - + + - - + + - - + + + - - - + + - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - + - + - + - + - - + + - - - + + + - + - - + + - + - + - + - - + + - + - + - + @@ -42193,315 +42218,315 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - - + + + - + - - + + - - + + - - - + + + - - - - - + + + + + - - + + - - + + - + - - - - - + + + + + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - - - + + + - - - + + + - - - + + + - + - + - + - + - + @@ -42510,27 +42535,27 @@ - + - + - + - + - + - + - + @@ -42541,7 +42566,7 @@ - + @@ -42550,13 +42575,13 @@ - + - + - + @@ -42571,30 +42596,30 @@ - + - + - + - + - + - + - + @@ -42605,10 +42630,10 @@ - + - + @@ -42623,7 +42648,7 @@ - + @@ -42632,62 +42657,62 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -42696,26 +42721,26 @@ - + - + - + - + - + - + - + - + @@ -42724,146 +42749,146 @@ - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - + + + - - - - + + + - - - + + + - - - + + + + - - + - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + @@ -42876,78 +42901,70 @@ - - + + - - - - - - - - - - + + - + - + - + - - - + + + - + - - + + - + - + - + - + - + - + - + - + @@ -42955,7 +42972,7 @@ - + @@ -42964,7 +42981,7 @@ - + @@ -42973,7 +42990,7 @@ - + @@ -42996,16 +43013,16 @@ - + - + - + - + @@ -43014,7 +43031,7 @@ - + @@ -43023,7 +43040,7 @@ - + @@ -43032,9 +43049,9 @@ - + - + @@ -43043,14 +43060,14 @@ - + - + @@ -43059,7 +43076,7 @@ - + @@ -43070,31 +43087,31 @@ - - - - - + + + + + - + - + - + - - - + + + - + @@ -43109,53 +43126,53 @@ - + - + - + - + - + - + - + - - - + + + - + - - + + - - + + @@ -43163,23 +43180,23 @@ - + - + - - + + - + - + @@ -43189,78 +43206,78 @@ - - - - - + + + + + - - + + - + - + - + - + - - + + - - + + - + - + - + - + - - - - - + + + + + - + - + - + @@ -43269,379 +43286,379 @@ - - + + - + - + - - - - - - - - + + + + + + + + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - + - + - + - + - + - + - + @@ -43650,157 +43667,157 @@ - + - + - + - - - + + + - + - + - - + + - - + + - - + + - + - - - - - + + + + + - - + + - - - + + + - - + + - + - + - + - + - + - + - + - + - - + + - - + + - - - + + + - - - + + + - + - - - - + + + + - - - - - + + + + + - - + + - + - - + + @@ -43817,8 +43834,8 @@ - - + + @@ -43832,43 +43849,43 @@ - + - + - - + + - + - + - - + + - + - - - + + + - + - + @@ -43878,30 +43895,30 @@ - + - - - + + + - + - + - + - - + + @@ -43909,93 +43926,93 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -44004,29 +44021,29 @@ - + - - + + - - + + - + - + - + @@ -44036,31 +44053,31 @@ - + - + - + - + - + - - - + + + @@ -44068,116 +44085,116 @@ - + - + - - + + - - + + - - + + - + - + - - + + - + - + - + - + - - - + + + - - + + - + - - + + - - - - - + + + + + - - + + - + - + - + - + - + - + - + @@ -44186,7 +44203,7 @@ - + @@ -44195,42 +44212,42 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -44239,25 +44256,25 @@ - + - + - + - + - + @@ -44278,119 +44295,119 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -44405,8 +44422,8 @@ - - + + @@ -44433,204 +44450,204 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + - - + + + + - - - + - - + + + - - + + - - + + - - - + + + - - - - + + - - + + + + + + + + + + + + + + + + + + + + - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - + + - + - + - + - + - + - + - + - + - + - + - + @@ -44644,31 +44661,31 @@ - + - + - + - + - + - + - + @@ -44676,121 +44693,121 @@ - + - + - - - - + + + + - + - + - + - + - - + + - + - - + + - + - + - + - + - + - + - - - + + + - - - + + + - + - + - - + + - + - - + + - - + + - - + + - - - + + + - - + + @@ -44801,33 +44818,33 @@ - + - - - + + + - + - - + + - + - - + + - + @@ -44838,10 +44855,10 @@ - + - + @@ -44850,55 +44867,55 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -44979,31 +44996,31 @@ - + - + - + - + - + - + - + @@ -45015,7 +45032,7 @@ - + @@ -45025,9 +45042,9 @@ - + - + @@ -45039,21 +45056,21 @@ - + - + - + - + - + @@ -45062,13 +45079,13 @@ - + - + - + @@ -45089,16 +45106,16 @@ - + - + - + - + @@ -45113,20 +45130,20 @@ - + - + - + - + - + - + @@ -45135,10 +45152,10 @@ - + - + @@ -45150,328 +45167,328 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -45498,86 +45515,86 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -45585,7 +45602,7 @@ - + @@ -45599,57 +45616,57 @@ - - - - - - - - - - - - - - - + + - - - + + + + + + + + + + + + + + + + - - + + - + - - - - - - + + + + + + - + - + - + - + @@ -45658,25 +45675,25 @@ - + - + - + - + - + - + - + @@ -45724,45 +45741,45 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -45783,13 +45800,13 @@ - + - + - + @@ -45807,10 +45824,10 @@ - + - + @@ -45825,10 +45842,10 @@ - + - + @@ -45846,21 +45863,21 @@ - + - + - + - + - + @@ -45869,8 +45886,8 @@ - - + + @@ -45884,7 +45901,7 @@ - + @@ -45895,142 +45912,142 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -46039,97 +46056,97 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -46137,53 +46154,53 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -46192,39 +46209,39 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -46244,15 +46261,15 @@ - + - + - + @@ -46269,15 +46286,15 @@ - + - + - + - + @@ -46285,13 +46302,13 @@ - + - + @@ -46317,357 +46334,357 @@ - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + - + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - + - + - + - + - - - - - - - - - - - - - - - - - - - - + + - - + - - - + + - - + - - - - + - - - - - - - - + + + + + + + - - - + + - - + + + + + + - - - + + - - + + - - - + + + - - - - - + + - - - - - - + + + - - - - + + + - + + + - - + + + + + - - + + + + + + - - + + + + - + - - - - - - - - - - - + + + + + + + + + + + - - + - - - + + - - + + - - + + + - - + + + + + + + + + - - + + + - - + + - - - - - - - - + + - - + - - + - + + + + + + + + + + + + + + + + + + + + + - - + + @@ -46675,13 +46692,13 @@ - + - + @@ -46705,51 +46722,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -46757,10 +46774,10 @@ - + - + @@ -46784,7 +46801,7 @@ - + @@ -46799,7 +46816,7 @@ - + @@ -46819,15 +46836,15 @@ - + - + - + - + @@ -46836,36 +46853,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -46877,248 +46894,248 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - + - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - - + + - - + + - + - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - - - + + + + + + - - + + + - + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - + + + + + - - - - - - - - - - - + + + - - + + + + + + + + + + + + + + + + + + + - + - + - + - + - - + + - + - + - + @@ -47129,37 +47146,37 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -47174,61 +47191,61 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -47237,7 +47254,7 @@ - + @@ -47252,13 +47269,13 @@ - + - + @@ -47272,82 +47289,82 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -47355,7 +47372,7 @@ - + @@ -47363,32 +47380,32 @@ - + - + - + - + - + - + - + - + - + - + @@ -47402,18 +47419,18 @@ - + - + - + - + - + @@ -47421,25 +47438,25 @@ - + - + - + - + - + - + @@ -47447,19 +47464,19 @@ - + - + - + - + @@ -47467,7 +47484,7 @@ - + @@ -47484,15 +47501,15 @@ - + - + - + - + @@ -47501,27 +47518,27 @@ - + - + - + - + - + - + - + - + @@ -47532,10 +47549,10 @@ - + - + @@ -47544,30 +47561,30 @@ - + - + - + - + - + - + - + - + @@ -47579,7 +47596,7 @@ - + @@ -47588,7 +47605,7 @@ - + @@ -47596,12 +47613,12 @@ - + - + - + @@ -47616,88 +47633,88 @@ - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + @@ -47706,104 +47723,104 @@ - + - + - + - - - - - - - - - - - - - - - - - - - - - - - + - - + + + - - - + + + - - - - + + - - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + @@ -47812,14 +47829,14 @@ - + - + @@ -47848,37 +47865,37 @@ - + - - + + - - + + - - + + - + - + - + - + - + @@ -47887,13 +47904,13 @@ - + - + - + @@ -47902,22 +47919,22 @@ - + - + - + - + - + @@ -47929,88 +47946,88 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -48019,177 +48036,185 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - + + + + + + - + - + + + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -48206,10 +48231,10 @@ - + - + @@ -48233,7 +48258,7 @@ - + @@ -48242,28 +48267,28 @@ - + - + - + - + - + - + - + @@ -48287,22 +48312,22 @@ - + - + - + - + - + @@ -48313,30 +48338,30 @@ - + - + - + - + - + - + - + - + @@ -48345,10 +48370,10 @@ - + - + @@ -48356,7 +48381,7 @@ - + @@ -48367,97 +48392,97 @@ - + - + - + - + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - + - + - + @@ -48466,22 +48491,22 @@ - + - + - + - + - + - + @@ -48496,7 +48521,7 @@ - + @@ -48505,19 +48530,19 @@ - + - + - + - + @@ -48529,28 +48554,28 @@ - + - + - + - + - + - + @@ -48559,117 +48584,117 @@ - + - - - - - - - - + + + + + + + + - - - + + + - + - - - - - - - - - - - - - - - - - - - - - + + - - + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - + - + - + - + - + - + - + - + - - - - - - - - + + + + + + + + - + @@ -48677,48 +48702,48 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -48727,13 +48752,13 @@ - + - + - + @@ -48748,19 +48773,19 @@ - + - + - + - + - + @@ -48772,22 +48797,22 @@ - + - + - + - + @@ -48796,13 +48821,13 @@ - + - + - + @@ -48811,16 +48836,16 @@ - + - + - + - + @@ -48829,13 +48854,13 @@ - + - + - + @@ -48859,19 +48884,19 @@ - + - + - + - + @@ -48889,22 +48914,22 @@ - + - + - + - + - + @@ -48913,19 +48938,19 @@ - + - + - + - + - + @@ -48934,98 +48959,98 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -49038,7 +49063,7 @@ - + @@ -49051,186 +49076,186 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -49245,13 +49270,13 @@ - + - + @@ -49260,31 +49285,31 @@ - + - + - + - + - + - + - + - + @@ -49292,60 +49317,60 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -49354,9 +49379,9 @@ - + - + @@ -49365,33 +49390,33 @@ - + - + - + - + - - + + - + - + - + @@ -49399,43 +49424,43 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -49444,25 +49469,25 @@ - + - + - + - + - + - + - + @@ -49474,44 +49499,44 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -49534,52 +49559,52 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -49602,31 +49627,31 @@ - + - + - + - + - + - + - + - + @@ -49644,20 +49669,20 @@ - + - + - + - + - - + + @@ -49665,7 +49690,7 @@ - + @@ -49673,26 +49698,26 @@ - + - + - + - + - + - + - + - + @@ -49700,133 +49725,133 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -49837,7 +49862,7 @@ - + @@ -49846,36 +49871,36 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -49883,51 +49908,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - - + + @@ -49935,94 +49960,94 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + @@ -50030,13 +50055,13 @@ - + - + @@ -50044,631 +50069,631 @@ - - + + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - + - - - + + + - - + + + - - - + + + - - - - + + + - + + + + + - + + + - - + + - + + - - - - - - + + + - - - + - - - + - - - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + - - + - - + + + - - + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + + + + + + - - + + - - - + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - + + + + + - - + + - - + + - + - + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -50683,107 +50708,107 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + @@ -50809,7 +50834,7 @@ - + @@ -50823,66 +50848,66 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -50894,51 +50919,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -50947,19 +50972,19 @@ - + - + - + - + @@ -50968,43 +50993,43 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -51015,31 +51040,31 @@ - + - + - + - + - + - + - + - + @@ -51060,68 +51085,68 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -51130,22 +51155,22 @@ - + - + - + - + - + @@ -51183,38 +51208,38 @@ - + - + - + - + - + - + - + - + - + - + @@ -51223,18 +51248,18 @@ - + - + - + @@ -51242,7 +51267,7 @@ - + @@ -51275,18 +51300,18 @@ - + - + - + - + - + @@ -51298,90 +51323,90 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -51396,25 +51421,25 @@ - + - + - + - + - + - + - + @@ -51423,66 +51448,66 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -51491,10 +51516,10 @@ - + - + @@ -51503,41 +51528,41 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -51546,31 +51571,31 @@ - + - + - + - + - + - + - + - + - + - + @@ -51578,15 +51603,15 @@ - + - + - + - + @@ -51598,33 +51623,33 @@ - + - + - + - + - + - + - + - + - + - + @@ -51636,55 +51661,55 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -51696,115 +51721,115 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -51816,12 +51841,12 @@ - + - + - + @@ -51830,23 +51855,23 @@ - + - + - + - + - + - + @@ -51855,99 +51880,99 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -51956,68 +51981,68 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -52026,7 +52051,7 @@ - + @@ -52034,285 +52059,285 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - + + + + - + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - + - - + + - + - + - + - + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + @@ -52320,388 +52345,388 @@ - + - + - - + + - - + + - - + + - + - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - + + + - - + + + + + - - + + - + + - - - + - - + + - - - - - - - - - + - - - + - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - + - - - + + + - - + + - - + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - + + + + + - - + - - + + - - - + + + + + + + + + + + + + + + + + - - - - - - + - - - - + + + - - - + + + - - - + + + + + + + + - - - - - - - - + + + - - - - - - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - + - - + + - - + + - - - + + + - + - + - + - + - + - + - + - + - + - + - - - - + + + + - + - + - - + + - - + + - - + + - - + + - + - + - + - - + + - + @@ -52709,36 +52734,36 @@ - + - - - - + + + + - - + + - + - - + + - - + + - - + + @@ -52746,63 +52771,63 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -52813,51 +52838,51 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -52869,90 +52894,90 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - + @@ -52970,75 +52995,75 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -53047,84 +53072,84 @@ - + - + - + - + - + - + - + - + - + - + - + - - + + - + - + - + - + - + - + - - + + - + - + - + - + - + @@ -53132,48 +53157,48 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -53182,13 +53207,13 @@ - + - - + + @@ -53197,365 +53222,365 @@ - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - + + + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - + - + - - + + - + - + - + - - - - + + + + - + - + - + - - + + - + - - - + + + - + - + - + - + - + - + - - - + + + - - + + - + - + - + - + - - + + - + - + - - - + + + - - + + - + - + - - - - + + + + - + - - - + + + - - - - - + + + + + - - - - - - + + + + + + - + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + - + @@ -53572,270 +53597,270 @@ - + - - - - + + + + - + - - - - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + + + + - - + + - + - + - - - + + + - - - + + + - - - + + + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - + - - + + - + - + - + - + - + - + - + - - + + - + - + - - + + - - + + - - + + - + - + - + - + - - + + - + - + - + - + - + - + - + - + - + - + @@ -53847,34 +53872,34 @@ - + - + - + - + - + - + - + - + @@ -53889,13 +53914,13 @@ - + - + - + @@ -53904,25 +53929,25 @@ - + - + - + - + - + - + @@ -53934,16 +53959,16 @@ - + - + - + - + @@ -53952,16 +53977,16 @@ - + - + - + - + @@ -53970,25 +53995,25 @@ - + - + - + - + - + - + @@ -53997,13 +54022,13 @@ - + - + - + @@ -54012,7 +54037,7 @@ - + @@ -54024,63 +54049,63 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -54100,12 +54125,12 @@ - + - + - + @@ -54120,18 +54145,18 @@ - + - + - + - + - + @@ -54154,24 +54179,24 @@ - + - + - + - + - + - + @@ -54180,33 +54205,33 @@ - + - + - + - + - + - + - + - + - + @@ -54215,30 +54240,30 @@ - + - + - + - + - + - + - + @@ -54253,7 +54278,7 @@ - + @@ -54268,10 +54293,10 @@ - + - + @@ -54304,7 +54329,7 @@ - + @@ -54340,37 +54365,37 @@ - + - + - + - + - + - + - + - + - + @@ -54379,48 +54404,48 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -54429,10 +54454,10 @@ - + - + @@ -54441,28 +54466,28 @@ - + - + - + - + - + @@ -54471,13 +54496,13 @@ - + - + - + @@ -54486,7 +54511,7 @@ - + @@ -54498,35 +54523,35 @@ - + - + - + - + - + - + - + - + - + - + @@ -54534,33 +54559,33 @@ - + - + - + - + - + - + - + @@ -54569,10 +54594,10 @@ - + - + @@ -54581,52 +54606,52 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -54662,10 +54687,10 @@ - + - + @@ -54683,23 +54708,23 @@ - + - + - + - + - + - + @@ -54711,7 +54736,7 @@ - + @@ -54719,7 +54744,7 @@ - + @@ -54727,7 +54752,7 @@ - + @@ -54745,62 +54770,62 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -54827,7 +54852,7 @@ - + @@ -54836,18 +54861,18 @@ - + - + - + @@ -54856,15 +54881,15 @@ - + - + - + - + @@ -54873,7 +54898,7 @@ - + @@ -54884,43 +54909,43 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -54929,64 +54954,64 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -54994,91 +55019,91 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -55087,64 +55112,64 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -55156,7 +55181,7 @@ - + @@ -55167,7 +55192,7 @@ - + @@ -55175,76 +55200,76 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -55264,370 +55289,370 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -55635,21 +55660,21 @@ - + - + - + - + - + - + @@ -55658,49 +55683,49 @@ - + - + - + - + - + - + - + - + - + - + @@ -55709,24 +55734,24 @@ - + - + - + - + - + - + - + @@ -55747,13 +55772,13 @@ - + - + @@ -55764,19 +55789,19 @@ - + - + - + @@ -55785,16 +55810,16 @@ - + - + - + @@ -55808,7 +55833,7 @@ - + @@ -55816,53 +55841,53 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -55877,58 +55902,58 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -55937,13 +55962,13 @@ - + - + - + @@ -55952,18 +55977,18 @@ - + - + - + - + - + @@ -55980,13 +56005,13 @@ - + - + - + @@ -55995,19 +56020,19 @@ - + - + - + - + - + @@ -56025,16 +56050,16 @@ - + - + - + @@ -56043,16 +56068,16 @@ - + - + - + - + @@ -56064,10 +56089,10 @@ - + - + @@ -56076,52 +56101,52 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -56138,10 +56163,10 @@ - + - + @@ -56179,7 +56204,7 @@ - + @@ -56199,36 +56224,36 @@ - + - + - + - + - + - + - + - + - + - + @@ -56237,31 +56262,31 @@ - + - + - + - + - + - + - + @@ -56270,57 +56295,57 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -56332,19 +56357,19 @@ - + - + - + - + @@ -56353,12 +56378,12 @@ - + - + - + @@ -56369,10 +56394,10 @@ - + - + @@ -56387,24 +56412,24 @@ - + - + - + - + - + - + - + @@ -56412,9 +56437,9 @@ - + - + @@ -56423,16 +56448,16 @@ - + - + - + @@ -56441,28 +56466,28 @@ - + - + - + - + - + - + - + @@ -56471,64 +56496,64 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -56537,85 +56562,85 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -56624,19 +56649,19 @@ - + - + - + - + - + @@ -56645,43 +56670,43 @@ - + - + - + - + - + - + - + - + - + - + @@ -56690,21 +56715,21 @@ - + - + - + - + - + @@ -56713,35 +56738,35 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -56762,30 +56787,30 @@ - + - + - + - + - + - + - + @@ -56812,32 +56837,32 @@ - + - + - + - + - + - + - + - + @@ -56846,7 +56871,7 @@ - + @@ -56861,21 +56886,21 @@ - + - + - + - + - + - + @@ -56883,18 +56908,18 @@ - + - + - + - + @@ -56902,45 +56927,45 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -56949,7 +56974,7 @@ - + @@ -56958,53 +56983,53 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -57016,61 +57041,61 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -57078,858 +57103,858 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + - - - + + - - - + + - - + + - - - - + + + - - + + - - - - - - - - - + + - - - + + + - - - + + + - - - - + + + + + - - - + + + + + + + + + + - - + + - - - + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + + + - - - - - + + + + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + - - - + + + - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + @@ -57938,49 +57963,49 @@ - + - + - + - + - - + + - - + + - - - - + + + + - - - + + + - - + + - - + + - + @@ -57995,7 +58020,7 @@ - + @@ -58004,60 +58029,60 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -58066,39 +58091,39 @@ - + - + - + - + - + - - - + + + - - - + + + - + @@ -58111,65 +58136,65 @@ - + - + - + - + - + - + - + - + - - - + + + - + - + - + - + @@ -58177,7 +58202,7 @@ - + @@ -58209,81 +58234,89 @@ - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/block/Kconfig b/block/Kconfig index f8543037e2ac..1a4929c49f08 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -202,13 +202,20 @@ config BLK_SED_OPAL config BLK_INLINE_ENCRYPTION bool "Enable inline encryption support in block layer" + help + Build the blk-crypto subsystem. Enabling this lets the + block layer handle encryption, so users can take + advantage of inline encryption hardware if present. + +config BLK_INLINE_ENCRYPTION_FALLBACK + bool "Enable crypto API fallback for blk-crypto" + depends on BLK_INLINE_ENCRYPTION select CRYPTO select CRYPTO_BLKCIPHER help - Build the blk-crypto subsystem. - Enabling this lets the block layer handle encryption, - so users can take advantage of inline encryption - hardware if present. + Enabling this lets the block layer handle inline encryption + by falling back to the kernel crypto API when inline + encryption hardware is not present. menu "Partition Types" diff --git a/block/Makefile b/block/Makefile index 550f616a3bd1..a2e05332682f 100644 --- a/block/Makefile +++ b/block/Makefile @@ -39,3 +39,4 @@ obj-$(CONFIG_BLK_DEBUG_FS_ZONED)+= blk-mq-debugfs-zoned.o obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o obj-$(CONFIG_BLK_INLINE_ENCRYPTION) += keyslot-manager.o bio-crypt-ctx.o \ blk-crypto.o +obj-$(CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK) += blk-crypto-fallback.o \ No newline at end of file diff --git a/block/bio-crypt-ctx.c b/block/bio-crypt-ctx.c index 0f7641b875e9..75982dabc7a3 100644 --- a/block/bio-crypt-ctx.c +++ b/block/bio-crypt-ctx.c @@ -5,26 +5,43 @@ #include #include -#include #include +#include +#include + +#include "blk-crypto-internal.h" static int num_prealloc_crypt_ctxs = 128; + +module_param(num_prealloc_crypt_ctxs, int, 0444); +MODULE_PARM_DESC(num_prealloc_crypt_ctxs, + "Number of bio crypto contexts to preallocate"); + static struct kmem_cache *bio_crypt_ctx_cache; static mempool_t *bio_crypt_ctx_pool; -int bio_crypt_ctx_init(void) +int __init bio_crypt_ctx_init(void) { + size_t i; + bio_crypt_ctx_cache = KMEM_CACHE(bio_crypt_ctx, 0); if (!bio_crypt_ctx_cache) return -ENOMEM; - bio_crypt_ctx_pool = mempool_create_slab_pool( - num_prealloc_crypt_ctxs, - bio_crypt_ctx_cache); - + bio_crypt_ctx_pool = mempool_create_slab_pool(num_prealloc_crypt_ctxs, + bio_crypt_ctx_cache); if (!bio_crypt_ctx_pool) return -ENOMEM; + /* This is assumed in various places. */ + BUILD_BUG_ON(BLK_ENCRYPTION_MODE_INVALID != 0); + + /* Sanity check that no algorithm exceeds the defined limits. */ + for (i = 0; i < BLK_ENCRYPTION_MODE_MAX; i++) { + BUG_ON(blk_crypto_modes[i].keysize > BLK_CRYPTO_MAX_KEY_SIZE); + BUG_ON(blk_crypto_modes[i].ivsize > BLK_CRYPTO_MAX_IV_SIZE); + } + return 0; } @@ -32,51 +49,43 @@ struct bio_crypt_ctx *bio_crypt_alloc_ctx(gfp_t gfp_mask) { return mempool_alloc(bio_crypt_ctx_pool, gfp_mask); } -EXPORT_SYMBOL(bio_crypt_alloc_ctx); void bio_crypt_free_ctx(struct bio *bio) { mempool_free(bio->bi_crypt_context, bio_crypt_ctx_pool); bio->bi_crypt_context = NULL; } -EXPORT_SYMBOL(bio_crypt_free_ctx); -int bio_crypt_clone(struct bio *dst, struct bio *src, gfp_t gfp_mask) +void bio_crypt_clone(struct bio *dst, struct bio *src, gfp_t gfp_mask) { + const struct bio_crypt_ctx *src_bc = src->bi_crypt_context; + /* - * If a bio is swhandled, then it will be decrypted when bio_endio - * is called. As we only want the data to be decrypted once, copies - * of the bio must not have have a crypt context. + * If a bio is fallback_crypted, then it will be decrypted when + * bio_endio is called. As we only want the data to be decrypted once, + * copies of the bio must not have have a crypt context. */ - if (!bio_has_crypt_ctx(src) || bio_crypt_swhandled(src)) - return 0; + if (!src_bc || bio_crypt_fallback_crypted(src_bc)) + return; dst->bi_crypt_context = bio_crypt_alloc_ctx(gfp_mask); - if (!dst->bi_crypt_context) - return -ENOMEM; + *dst->bi_crypt_context = *src_bc; - *dst->bi_crypt_context = *src->bi_crypt_context; - - if (bio_crypt_has_keyslot(src)) - keyslot_manager_get_slot(src->bi_crypt_context->processing_ksm, - src->bi_crypt_context->keyslot); - - return 0; + if (src_bc->bc_keyslot >= 0) + keyslot_manager_get_slot(src_bc->bc_ksm, src_bc->bc_keyslot); } -EXPORT_SYMBOL(bio_crypt_clone); +EXPORT_SYMBOL_GPL(bio_crypt_clone); -bool bio_crypt_should_process(struct bio *bio, struct request_queue *q) +bool bio_crypt_should_process(struct request *rq) { - if (!bio_has_crypt_ctx(bio)) + struct bio *bio = rq->bio; + + if (!bio || !bio->bi_crypt_context) return false; - if (q->ksm != bio->bi_crypt_context->processing_ksm) - return false; - - WARN_ON(!bio_crypt_has_keyslot(bio)); - return true; + return rq->q->ksm == bio->bi_crypt_context->bc_ksm; } -EXPORT_SYMBOL(bio_crypt_should_process); +EXPORT_SYMBOL_GPL(bio_crypt_should_process); /* * Checks that two bio crypt contexts are compatible - i.e. that @@ -87,23 +96,19 @@ bool bio_crypt_ctx_compatible(struct bio *b_1, struct bio *b_2) struct bio_crypt_ctx *bc1 = b_1->bi_crypt_context; struct bio_crypt_ctx *bc2 = b_2->bi_crypt_context; - if (bio_has_crypt_ctx(b_1) != bio_has_crypt_ctx(b_2)) + if (bc1 != bc2) return false; - if (!bio_has_crypt_ctx(b_1)) - return true; - - return bc1->keyslot == bc2->keyslot && - bc1->data_unit_size_bits == bc2->data_unit_size_bits; + return !bc1 || bc1->bc_key == bc2->bc_key; } /* * Checks that two bio crypt contexts are compatible, and also * that their data_unit_nums are continuous (and can hence be merged) + * in the order b_1 followed by b_2. */ -bool bio_crypt_ctx_back_mergeable(struct bio *b_1, - unsigned int b1_sectors, - struct bio *b_2) +bool bio_crypt_ctx_mergeable(struct bio *b_1, unsigned int b1_bytes, + struct bio *b_2) { struct bio_crypt_ctx *bc1 = b_1->bi_crypt_context; struct bio_crypt_ctx *bc2 = b_2->bi_crypt_context; @@ -111,35 +116,25 @@ bool bio_crypt_ctx_back_mergeable(struct bio *b_1, if (!bio_crypt_ctx_compatible(b_1, b_2)) return false; - return !bio_has_crypt_ctx(b_1) || - (bc1->data_unit_num + - (b1_sectors >> (bc1->data_unit_size_bits - 9)) == - bc2->data_unit_num); + return !bc1 || bio_crypt_dun_is_contiguous(bc1, b1_bytes, bc2->bc_dun); } -void bio_crypt_ctx_release_keyslot(struct bio *bio) +void bio_crypt_ctx_release_keyslot(struct bio_crypt_ctx *bc) { - struct bio_crypt_ctx *crypt_ctx = bio->bi_crypt_context; - - keyslot_manager_put_slot(crypt_ctx->processing_ksm, crypt_ctx->keyslot); - bio->bi_crypt_context->processing_ksm = NULL; - bio->bi_crypt_context->keyslot = -1; + keyslot_manager_put_slot(bc->bc_ksm, bc->bc_keyslot); + bc->bc_ksm = NULL; + bc->bc_keyslot = -1; } -int bio_crypt_ctx_acquire_keyslot(struct bio *bio, struct keyslot_manager *ksm) +int bio_crypt_ctx_acquire_keyslot(struct bio_crypt_ctx *bc, + struct keyslot_manager *ksm) { - int slot; - enum blk_crypto_mode_num crypto_mode = bio_crypto_mode(bio); + int slot = keyslot_manager_get_slot_for_key(ksm, bc->bc_key); - if (!ksm) - return -ENOMEM; - - slot = keyslot_manager_get_slot_for_key(ksm, - bio_crypt_raw_key(bio), crypto_mode, - 1 << bio->bi_crypt_context->data_unit_size_bits); if (slot < 0) return slot; - bio_crypt_set_keyslot(bio, slot, ksm); + bc->bc_keyslot = slot; + bc->bc_ksm = ksm; return 0; } diff --git a/block/bio.c b/block/bio.c index 62a293b1d427..ee3bae8b9dcd 100644 --- a/block/bio.c +++ b/block/bio.c @@ -246,6 +246,8 @@ struct bio_vec *bvec_alloc(gfp_t gfp_mask, int nr, unsigned long *idx, void bio_uninit(struct bio *bio) { bio_disassociate_task(bio); + + bio_crypt_free_ctx(bio); } EXPORT_SYMBOL(bio_uninit); @@ -254,7 +256,6 @@ static void bio_free(struct bio *bio) struct bio_set *bs = bio->bi_pool; void *p; - bio_crypt_free_ctx(bio); bio_uninit(bio); if (bs) { @@ -634,10 +635,7 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs) __bio_clone_fast(b, bio); - if (bio_crypt_clone(b, bio, gfp_mask) < 0) { - bio_put(b); - return NULL; - } + bio_crypt_clone(b, bio, gfp_mask); if (bio_integrity(bio) && bio_integrity_clone(b, bio, gfp_mask) < 0) { diff --git a/block/blk-core.c b/block/blk-core.c index 4a9730f757f6..f61a9f139cf8 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2514,14 +2514,11 @@ blk_qc_t direct_make_request(struct bio *bio) { struct request_queue *q = bio->bi_disk->queue; bool nowait = bio->bi_opf & REQ_NOWAIT; - blk_qc_t ret; + blk_qc_t ret = BLK_QC_T_NONE; if (!generic_make_request_checks(bio)) return BLK_QC_T_NONE; - if (blk_crypto_submit_bio(&bio)) - return BLK_QC_T_NONE; - if (unlikely(blk_queue_enter(q, nowait ? BLK_MQ_REQ_NOWAIT : 0))) { if (nowait && !blk_queue_dying(q)) bio->bi_status = BLK_STS_AGAIN; @@ -2531,7 +2528,8 @@ blk_qc_t direct_make_request(struct bio *bio) return BLK_QC_T_NONE; } - ret = q->make_request_fn(q, bio); + if (!blk_crypto_submit_bio(&bio)) + ret = q->make_request_fn(q, bio); blk_queue_exit(q); return ret; } @@ -4001,8 +3999,8 @@ int __init blk_dev_init(void) if (bio_crypt_ctx_init() < 0) panic("Failed to allocate mem for bio crypt ctxs\n"); - if (blk_crypto_init() < 0) - panic("Failed to init blk-crypto\n"); + if (blk_crypto_fallback_init() < 0) + panic("Failed to init blk-crypto-fallback\n"); return 0; } diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c new file mode 100644 index 000000000000..3f2a7d3be07b --- /dev/null +++ b/block/blk-crypto-fallback.c @@ -0,0 +1,647 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright 2019 Google LLC + */ + +/* + * Refer to Documentation/block/inline-encryption.rst for detailed explanation. + */ + +#define pr_fmt(fmt) "blk-crypto-fallback: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "blk-crypto-internal.h" + +static unsigned int num_prealloc_bounce_pg = 32; +module_param(num_prealloc_bounce_pg, uint, 0); +MODULE_PARM_DESC(num_prealloc_bounce_pg, + "Number of preallocated bounce pages for the blk-crypto crypto API fallback"); + +static unsigned int blk_crypto_num_keyslots = 100; +module_param_named(num_keyslots, blk_crypto_num_keyslots, uint, 0); +MODULE_PARM_DESC(num_keyslots, + "Number of keyslots for the blk-crypto crypto API fallback"); + +static unsigned int num_prealloc_fallback_crypt_ctxs = 128; +module_param(num_prealloc_fallback_crypt_ctxs, uint, 0); +MODULE_PARM_DESC(num_prealloc_crypt_fallback_ctxs, + "Number of preallocated bio fallback crypto contexts for blk-crypto to use during crypto API fallback"); + +struct bio_fallback_crypt_ctx { + struct bio_crypt_ctx crypt_ctx; + /* + * Copy of the bvec_iter when this bio was submitted. + * We only want to en/decrypt the part of the bio as described by the + * bvec_iter upon submission because bio might be split before being + * resubmitted + */ + struct bvec_iter crypt_iter; + u64 fallback_dun[BLK_CRYPTO_DUN_ARRAY_SIZE]; +}; + +/* The following few vars are only used during the crypto API fallback */ +static struct kmem_cache *bio_fallback_crypt_ctx_cache; +static mempool_t *bio_fallback_crypt_ctx_pool; + +/* + * Allocating a crypto tfm during I/O can deadlock, so we have to preallocate + * all of a mode's tfms when that mode starts being used. Since each mode may + * need all the keyslots at some point, each mode needs its own tfm for each + * keyslot; thus, a keyslot may contain tfms for multiple modes. However, to + * match the behavior of real inline encryption hardware (which only supports a + * single encryption context per keyslot), we only allow one tfm per keyslot to + * be used at a time - the rest of the unused tfms have their keys cleared. + */ +static DEFINE_MUTEX(tfms_init_lock); +static bool tfms_inited[BLK_ENCRYPTION_MODE_MAX]; + +struct blk_crypto_decrypt_work { + struct work_struct work; + struct bio *bio; +}; + +static struct blk_crypto_keyslot { + struct crypto_skcipher *tfm; + enum blk_crypto_mode_num crypto_mode; + struct crypto_skcipher *tfms[BLK_ENCRYPTION_MODE_MAX]; +} *blk_crypto_keyslots; + +/* The following few vars are only used during the crypto API fallback */ +static struct keyslot_manager *blk_crypto_ksm; +static struct workqueue_struct *blk_crypto_wq; +static mempool_t *blk_crypto_bounce_page_pool; +static struct kmem_cache *blk_crypto_decrypt_work_cache; + +bool bio_crypt_fallback_crypted(const struct bio_crypt_ctx *bc) +{ + return bc && bc->bc_ksm == blk_crypto_ksm; +} + +/* + * This is the key we set when evicting a keyslot. This *should* be the all 0's + * key, but AES-XTS rejects that key, so we use some random bytes instead. + */ +static u8 blank_key[BLK_CRYPTO_MAX_KEY_SIZE]; + +static void blk_crypto_evict_keyslot(unsigned int slot) +{ + struct blk_crypto_keyslot *slotp = &blk_crypto_keyslots[slot]; + enum blk_crypto_mode_num crypto_mode = slotp->crypto_mode; + int err; + + WARN_ON(slotp->crypto_mode == BLK_ENCRYPTION_MODE_INVALID); + + /* Clear the key in the skcipher */ + err = crypto_skcipher_setkey(slotp->tfms[crypto_mode], blank_key, + blk_crypto_modes[crypto_mode].keysize); + WARN_ON(err); + slotp->crypto_mode = BLK_ENCRYPTION_MODE_INVALID; +} + +static int blk_crypto_keyslot_program(struct keyslot_manager *ksm, + const struct blk_crypto_key *key, + unsigned int slot) +{ + struct blk_crypto_keyslot *slotp = &blk_crypto_keyslots[slot]; + const enum blk_crypto_mode_num crypto_mode = key->crypto_mode; + int err; + + if (crypto_mode != slotp->crypto_mode && + slotp->crypto_mode != BLK_ENCRYPTION_MODE_INVALID) { + blk_crypto_evict_keyslot(slot); + } + + if (!slotp->tfms[crypto_mode]) + return -ENOMEM; + slotp->crypto_mode = crypto_mode; + err = crypto_skcipher_setkey(slotp->tfms[crypto_mode], key->raw, + key->size); + if (err) { + blk_crypto_evict_keyslot(slot); + return err; + } + return 0; +} + +static int blk_crypto_keyslot_evict(struct keyslot_manager *ksm, + const struct blk_crypto_key *key, + unsigned int slot) +{ + blk_crypto_evict_keyslot(slot); + return 0; +} + +/* + * The crypto API fallback KSM ops - only used for a bio when it specifies a + * blk_crypto_mode for which we failed to get a keyslot in the device's inline + * encryption hardware (which probably means the device doesn't have inline + * encryption hardware that supports that crypto mode). + */ +static const struct keyslot_mgmt_ll_ops blk_crypto_ksm_ll_ops = { + .keyslot_program = blk_crypto_keyslot_program, + .keyslot_evict = blk_crypto_keyslot_evict, +}; + +static void blk_crypto_encrypt_endio(struct bio *enc_bio) +{ + struct bio *src_bio = enc_bio->bi_private; + int i; + + for (i = 0; i < enc_bio->bi_vcnt; i++) + mempool_free(enc_bio->bi_io_vec[i].bv_page, + blk_crypto_bounce_page_pool); + + src_bio->bi_status = enc_bio->bi_status; + + bio_put(enc_bio); + bio_endio(src_bio); +} + +static struct bio *blk_crypto_clone_bio(struct bio *bio_src) +{ + struct bvec_iter iter; + struct bio_vec bv; + struct bio *bio; + + bio = bio_alloc_bioset(GFP_NOIO, bio_segments(bio_src), NULL); + if (!bio) + return NULL; + bio->bi_disk = bio_src->bi_disk; + bio->bi_opf = bio_src->bi_opf; + bio->bi_ioprio = bio_src->bi_ioprio; + bio->bi_write_hint = bio_src->bi_write_hint; + bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; + bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; + + bio_for_each_segment(bv, bio_src, iter) + bio->bi_io_vec[bio->bi_vcnt++] = bv; + + if (bio_integrity(bio_src) && + bio_integrity_clone(bio, bio_src, GFP_NOIO) < 0) { + bio_put(bio); + return NULL; + } + + bio_clone_blkcg_association(bio, bio_src); + + return bio; +} + +static int blk_crypto_alloc_cipher_req(struct bio *src_bio, + struct skcipher_request **ciph_req_ret, + struct crypto_wait *wait) +{ + struct skcipher_request *ciph_req; + const struct blk_crypto_keyslot *slotp; + + slotp = &blk_crypto_keyslots[src_bio->bi_crypt_context->bc_keyslot]; + ciph_req = skcipher_request_alloc(slotp->tfms[slotp->crypto_mode], + GFP_NOIO); + if (!ciph_req) { + src_bio->bi_status = BLK_STS_RESOURCE; + return -ENOMEM; + } + + skcipher_request_set_callback(ciph_req, + CRYPTO_TFM_REQ_MAY_BACKLOG | + CRYPTO_TFM_REQ_MAY_SLEEP, + crypto_req_done, wait); + *ciph_req_ret = ciph_req; + return 0; +} + +static int blk_crypto_split_bio_if_needed(struct bio **bio_ptr) +{ + struct bio *bio = *bio_ptr; + unsigned int i = 0; + unsigned int num_sectors = 0; + struct bio_vec bv; + struct bvec_iter iter; + + bio_for_each_segment(bv, bio, iter) { + num_sectors += bv.bv_len >> SECTOR_SHIFT; + if (++i == BIO_MAX_PAGES) + break; + } + if (num_sectors < bio_sectors(bio)) { + struct bio *split_bio; + + split_bio = bio_split(bio, num_sectors, GFP_NOIO, NULL); + if (!split_bio) { + bio->bi_status = BLK_STS_RESOURCE; + return -ENOMEM; + } + bio_chain(split_bio, bio); + generic_make_request(bio); + *bio_ptr = split_bio; + } + return 0; +} + +union blk_crypto_iv { + __le64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE]; + u8 bytes[BLK_CRYPTO_MAX_IV_SIZE]; +}; + +static void blk_crypto_dun_to_iv(const u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE], + union blk_crypto_iv *iv) +{ + int i; + + for (i = 0; i < BLK_CRYPTO_DUN_ARRAY_SIZE; i++) + iv->dun[i] = cpu_to_le64(dun[i]); +} + +/* + * The crypto API fallback's encryption routine. + * Allocate a bounce bio for encryption, encrypt the input bio using crypto API, + * and replace *bio_ptr with the bounce bio. May split input bio if it's too + * large. + */ +static int blk_crypto_encrypt_bio(struct bio **bio_ptr) +{ + struct bio *src_bio; + struct skcipher_request *ciph_req = NULL; + DECLARE_CRYPTO_WAIT(wait); + u64 curr_dun[BLK_CRYPTO_DUN_ARRAY_SIZE]; + union blk_crypto_iv iv; + struct scatterlist src, dst; + struct bio *enc_bio; + unsigned int i, j; + int data_unit_size; + struct bio_crypt_ctx *bc; + int err = 0; + + /* Split the bio if it's too big for single page bvec */ + err = blk_crypto_split_bio_if_needed(bio_ptr); + if (err) + return err; + + src_bio = *bio_ptr; + bc = src_bio->bi_crypt_context; + data_unit_size = bc->bc_key->data_unit_size; + + /* Allocate bounce bio for encryption */ + enc_bio = blk_crypto_clone_bio(src_bio); + if (!enc_bio) { + src_bio->bi_status = BLK_STS_RESOURCE; + return -ENOMEM; + } + + /* + * Use the crypto API fallback keyslot manager to get a crypto_skcipher + * for the algorithm and key specified for this bio. + */ + err = bio_crypt_ctx_acquire_keyslot(bc, blk_crypto_ksm); + if (err) { + src_bio->bi_status = BLK_STS_IOERR; + goto out_put_enc_bio; + } + + /* and then allocate an skcipher_request for it */ + err = blk_crypto_alloc_cipher_req(src_bio, &ciph_req, &wait); + if (err) + goto out_release_keyslot; + + memcpy(curr_dun, bc->bc_dun, sizeof(curr_dun)); + sg_init_table(&src, 1); + sg_init_table(&dst, 1); + + skcipher_request_set_crypt(ciph_req, &src, &dst, data_unit_size, + iv.bytes); + + /* Encrypt each page in the bounce bio */ + for (i = 0; i < enc_bio->bi_vcnt; i++) { + struct bio_vec *enc_bvec = &enc_bio->bi_io_vec[i]; + struct page *plaintext_page = enc_bvec->bv_page; + struct page *ciphertext_page = + mempool_alloc(blk_crypto_bounce_page_pool, GFP_NOIO); + + enc_bvec->bv_page = ciphertext_page; + + if (!ciphertext_page) { + src_bio->bi_status = BLK_STS_RESOURCE; + err = -ENOMEM; + goto out_free_bounce_pages; + } + + sg_set_page(&src, plaintext_page, data_unit_size, + enc_bvec->bv_offset); + sg_set_page(&dst, ciphertext_page, data_unit_size, + enc_bvec->bv_offset); + + /* Encrypt each data unit in this page */ + for (j = 0; j < enc_bvec->bv_len; j += data_unit_size) { + blk_crypto_dun_to_iv(curr_dun, &iv); + err = crypto_wait_req(crypto_skcipher_encrypt(ciph_req), + &wait); + if (err) { + i++; + src_bio->bi_status = BLK_STS_RESOURCE; + goto out_free_bounce_pages; + } + bio_crypt_dun_increment(curr_dun, 1); + src.offset += data_unit_size; + dst.offset += data_unit_size; + } + } + + enc_bio->bi_private = src_bio; + enc_bio->bi_end_io = blk_crypto_encrypt_endio; + *bio_ptr = enc_bio; + + enc_bio = NULL; + err = 0; + goto out_free_ciph_req; + +out_free_bounce_pages: + while (i > 0) + mempool_free(enc_bio->bi_io_vec[--i].bv_page, + blk_crypto_bounce_page_pool); +out_free_ciph_req: + skcipher_request_free(ciph_req); +out_release_keyslot: + bio_crypt_ctx_release_keyslot(bc); +out_put_enc_bio: + if (enc_bio) + bio_put(enc_bio); + + return err; +} + +static void blk_crypto_free_fallback_crypt_ctx(struct bio *bio) +{ + mempool_free(container_of(bio->bi_crypt_context, + struct bio_fallback_crypt_ctx, + crypt_ctx), + bio_fallback_crypt_ctx_pool); + bio->bi_crypt_context = NULL; +} + +/* + * The crypto API fallback's main decryption routine. + * Decrypts input bio in place. + */ +static void blk_crypto_decrypt_bio(struct work_struct *work) +{ + struct blk_crypto_decrypt_work *decrypt_work = + container_of(work, struct blk_crypto_decrypt_work, work); + struct bio *bio = decrypt_work->bio; + struct skcipher_request *ciph_req = NULL; + DECLARE_CRYPTO_WAIT(wait); + struct bio_vec bv; + struct bvec_iter iter; + u64 curr_dun[BLK_CRYPTO_DUN_ARRAY_SIZE]; + union blk_crypto_iv iv; + struct scatterlist sg; + struct bio_crypt_ctx *bc = bio->bi_crypt_context; + struct bio_fallback_crypt_ctx *f_ctx = + container_of(bc, struct bio_fallback_crypt_ctx, crypt_ctx); + const int data_unit_size = bc->bc_key->data_unit_size; + unsigned int i; + int err; + + /* + * Use the crypto API fallback keyslot manager to get a crypto_skcipher + * for the algorithm and key specified for this bio. + */ + if (bio_crypt_ctx_acquire_keyslot(bc, blk_crypto_ksm)) { + bio->bi_status = BLK_STS_RESOURCE; + goto out_no_keyslot; + } + + /* and then allocate an skcipher_request for it */ + err = blk_crypto_alloc_cipher_req(bio, &ciph_req, &wait); + if (err) + goto out; + + memcpy(curr_dun, f_ctx->fallback_dun, sizeof(curr_dun)); + sg_init_table(&sg, 1); + skcipher_request_set_crypt(ciph_req, &sg, &sg, data_unit_size, + iv.bytes); + + /* Decrypt each segment in the bio */ + __bio_for_each_segment(bv, bio, iter, f_ctx->crypt_iter) { + struct page *page = bv.bv_page; + + sg_set_page(&sg, page, data_unit_size, bv.bv_offset); + + /* Decrypt each data unit in the segment */ + for (i = 0; i < bv.bv_len; i += data_unit_size) { + blk_crypto_dun_to_iv(curr_dun, &iv); + if (crypto_wait_req(crypto_skcipher_decrypt(ciph_req), + &wait)) { + bio->bi_status = BLK_STS_IOERR; + goto out; + } + bio_crypt_dun_increment(curr_dun, 1); + sg.offset += data_unit_size; + } + } + +out: + skcipher_request_free(ciph_req); + bio_crypt_ctx_release_keyslot(bc); +out_no_keyslot: + kmem_cache_free(blk_crypto_decrypt_work_cache, decrypt_work); + blk_crypto_free_fallback_crypt_ctx(bio); + bio_endio(bio); +} + +/* + * Queue bio for decryption. + * Returns true iff bio was queued for decryption. + */ +bool blk_crypto_queue_decrypt_bio(struct bio *bio) +{ + struct blk_crypto_decrypt_work *decrypt_work; + + /* If there was an IO error, don't queue for decrypt. */ + if (bio->bi_status) + goto out; + + decrypt_work = kmem_cache_zalloc(blk_crypto_decrypt_work_cache, + GFP_ATOMIC); + if (!decrypt_work) { + bio->bi_status = BLK_STS_RESOURCE; + goto out; + } + + INIT_WORK(&decrypt_work->work, blk_crypto_decrypt_bio); + decrypt_work->bio = bio; + queue_work(blk_crypto_wq, &decrypt_work->work); + + return true; +out: + blk_crypto_free_fallback_crypt_ctx(bio); + return false; +} + +/** + * blk_crypto_start_using_mode() - Start using a crypto algorithm on a device + * @mode_num: the blk_crypto_mode we want to allocate ciphers for. + * @data_unit_size: the data unit size that will be used + * @q: the request queue for the device + * + * Upper layers must call this function to ensure that a the crypto API fallback + * has transforms for this algorithm, if they become necessary. + * + * Return: 0 on success and -err on error. + */ +int blk_crypto_start_using_mode(enum blk_crypto_mode_num mode_num, + unsigned int data_unit_size, + struct request_queue *q) +{ + struct blk_crypto_keyslot *slotp; + unsigned int i; + int err = 0; + + /* + * Fast path + * Ensure that updates to blk_crypto_keyslots[i].tfms[mode_num] + * for each i are visible before we try to access them. + */ + if (likely(smp_load_acquire(&tfms_inited[mode_num]))) + return 0; + + /* + * If the keyslot manager of the request queue supports this + * crypto mode, then we don't need to allocate this mode. + */ + if (keyslot_manager_crypto_mode_supported(q->ksm, mode_num, + data_unit_size)) + return 0; + + mutex_lock(&tfms_init_lock); + if (likely(tfms_inited[mode_num])) + goto out; + + for (i = 0; i < blk_crypto_num_keyslots; i++) { + slotp = &blk_crypto_keyslots[i]; + slotp->tfms[mode_num] = crypto_alloc_skcipher( + blk_crypto_modes[mode_num].cipher_str, + 0, 0); + if (IS_ERR(slotp->tfms[mode_num])) { + err = PTR_ERR(slotp->tfms[mode_num]); + slotp->tfms[mode_num] = NULL; + goto out_free_tfms; + } + + crypto_skcipher_set_flags(slotp->tfms[mode_num], + CRYPTO_TFM_REQ_WEAK_KEY); + } + + /* + * Ensure that updates to blk_crypto_keyslots[i].tfms[mode_num] + * for each i are visible before we set tfms_inited[mode_num]. + */ + smp_store_release(&tfms_inited[mode_num], true); + goto out; + +out_free_tfms: + for (i = 0; i < blk_crypto_num_keyslots; i++) { + slotp = &blk_crypto_keyslots[i]; + crypto_free_skcipher(slotp->tfms[mode_num]); + slotp->tfms[mode_num] = NULL; + } +out: + mutex_unlock(&tfms_init_lock); + return err; +} + +int blk_crypto_fallback_evict_key(const struct blk_crypto_key *key) +{ + return keyslot_manager_evict_key(blk_crypto_ksm, key); +} + +int blk_crypto_fallback_submit_bio(struct bio **bio_ptr) +{ + struct bio *bio = *bio_ptr; + struct bio_crypt_ctx *bc = bio->bi_crypt_context; + struct bio_fallback_crypt_ctx *f_ctx; + + if (WARN_ON_ONCE(!tfms_inited[bc->bc_key->crypto_mode])) { + bio->bi_status = BLK_STS_IOERR; + return -EIO; + } + + if (bio_data_dir(bio) == WRITE) + return blk_crypto_encrypt_bio(bio_ptr); + + /* + * Mark bio as fallback crypted and replace the bio_crypt_ctx with + * another one contained in a bio_fallback_crypt_ctx, so that the + * fallback has space to store the info it needs for decryption. + */ + bc->bc_ksm = blk_crypto_ksm; + f_ctx = mempool_alloc(bio_fallback_crypt_ctx_pool, GFP_NOIO); + f_ctx->crypt_ctx = *bc; + memcpy(f_ctx->fallback_dun, bc->bc_dun, sizeof(f_ctx->fallback_dun)); + f_ctx->crypt_iter = bio->bi_iter; + + bio_crypt_free_ctx(bio); + bio->bi_crypt_context = &f_ctx->crypt_ctx; + + return 0; +} + +int __init blk_crypto_fallback_init(void) +{ + int i; + unsigned int crypto_mode_supported[BLK_ENCRYPTION_MODE_MAX]; + + prandom_bytes(blank_key, BLK_CRYPTO_MAX_KEY_SIZE); + + /* All blk-crypto modes have a crypto API fallback. */ + for (i = 0; i < BLK_ENCRYPTION_MODE_MAX; i++) + crypto_mode_supported[i] = 0xFFFFFFFF; + crypto_mode_supported[BLK_ENCRYPTION_MODE_INVALID] = 0; + + blk_crypto_ksm = keyslot_manager_create(blk_crypto_num_keyslots, + &blk_crypto_ksm_ll_ops, + crypto_mode_supported, NULL); + if (!blk_crypto_ksm) + return -ENOMEM; + + blk_crypto_wq = alloc_workqueue("blk_crypto_wq", + WQ_UNBOUND | WQ_HIGHPRI | + WQ_MEM_RECLAIM, num_online_cpus()); + if (!blk_crypto_wq) + return -ENOMEM; + + blk_crypto_keyslots = kcalloc(blk_crypto_num_keyslots, + sizeof(blk_crypto_keyslots[0]), + GFP_KERNEL); + if (!blk_crypto_keyslots) + return -ENOMEM; + + blk_crypto_bounce_page_pool = + mempool_create_page_pool(num_prealloc_bounce_pg, 0); + if (!blk_crypto_bounce_page_pool) + return -ENOMEM; + + blk_crypto_decrypt_work_cache = KMEM_CACHE(blk_crypto_decrypt_work, + SLAB_RECLAIM_ACCOUNT); + if (!blk_crypto_decrypt_work_cache) + return -ENOMEM; + + bio_fallback_crypt_ctx_cache = KMEM_CACHE(bio_fallback_crypt_ctx, 0); + if (!bio_fallback_crypt_ctx_cache) + return -ENOMEM; + + bio_fallback_crypt_ctx_pool = + mempool_create_slab_pool(num_prealloc_fallback_crypt_ctxs, + bio_fallback_crypt_ctx_cache); + if (!bio_fallback_crypt_ctx_pool) + return -ENOMEM; + + return 0; +} diff --git a/block/blk-crypto-internal.h b/block/blk-crypto-internal.h new file mode 100644 index 000000000000..43351eecc97a --- /dev/null +++ b/block/blk-crypto-internal.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright 2019 Google LLC + */ + +#ifndef __LINUX_BLK_CRYPTO_INTERNAL_H +#define __LINUX_BLK_CRYPTO_INTERNAL_H + +#include + +/* Represents a crypto mode supported by blk-crypto */ +struct blk_crypto_mode { + const char *cipher_str; /* crypto API name (for fallback case) */ + unsigned int keysize; /* key size in bytes */ + unsigned int ivsize; /* iv size in bytes */ +}; + +extern const struct blk_crypto_mode blk_crypto_modes[]; + +#ifdef CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK + +int blk_crypto_fallback_submit_bio(struct bio **bio_ptr); + +bool blk_crypto_queue_decrypt_bio(struct bio *bio); + +int blk_crypto_fallback_evict_key(const struct blk_crypto_key *key); + +bool bio_crypt_fallback_crypted(const struct bio_crypt_ctx *bc); + +#else /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */ + +static inline bool bio_crypt_fallback_crypted(const struct bio_crypt_ctx *bc) +{ + return false; +} + +static inline int blk_crypto_fallback_submit_bio(struct bio **bio_ptr) +{ + pr_warn_once("blk-crypto crypto API fallback disabled; failing request"); + (*bio_ptr)->bi_status = BLK_STS_NOTSUPP; + return -EIO; +} + +static inline bool blk_crypto_queue_decrypt_bio(struct bio *bio) +{ + WARN_ON(1); + return false; +} + +static inline int +blk_crypto_fallback_evict_key(const struct blk_crypto_key *key) +{ + return 0; +} + +#endif /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */ + +#endif /* __LINUX_BLK_CRYPTO_INTERNAL_H */ diff --git a/block/blk-crypto.c b/block/blk-crypto.c index 3cb3412665b2..2c47e8eec865 100644 --- a/block/blk-crypto.c +++ b/block/blk-crypto.c @@ -10,218 +10,36 @@ #define pr_fmt(fmt) "blk-crypto: " fmt #include +#include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include -/* Represents a crypto mode supported by blk-crypto */ -struct blk_crypto_mode { - const char *cipher_str; /* crypto API name (for fallback case) */ - size_t keysize; /* key size in bytes */ -}; +#include "blk-crypto-internal.h" -static const struct blk_crypto_mode blk_crypto_modes[] = { +const struct blk_crypto_mode blk_crypto_modes[] = { [BLK_ENCRYPTION_MODE_AES_256_XTS] = { .cipher_str = "xts(aes)", .keysize = 64, + .ivsize = 16, + }, + [BLK_ENCRYPTION_MODE_AES_128_CBC_ESSIV] = { + .cipher_str = "essiv(cbc(aes),sha256)", + .keysize = 16, + .ivsize = 16, + }, + [BLK_ENCRYPTION_MODE_ADIANTUM] = { + .cipher_str = "adiantum(xchacha12,aes)", + .keysize = 32, + .ivsize = 32, }, }; -static unsigned int num_prealloc_bounce_pg = 32; -module_param(num_prealloc_bounce_pg, uint, 0); -MODULE_PARM_DESC(num_prealloc_bounce_pg, - "Number of preallocated bounce pages for blk-crypto to use during crypto API fallback encryption"); - -#define BLK_CRYPTO_MAX_KEY_SIZE 64 -static int blk_crypto_num_keyslots = 100; -module_param_named(num_keyslots, blk_crypto_num_keyslots, int, 0); -MODULE_PARM_DESC(num_keyslots, - "Number of keyslots for crypto API fallback in blk-crypto."); - -static struct blk_crypto_keyslot { - struct crypto_skcipher *tfm; - enum blk_crypto_mode_num crypto_mode; - u8 key[BLK_CRYPTO_MAX_KEY_SIZE]; - struct crypto_skcipher *tfms[ARRAY_SIZE(blk_crypto_modes)]; -} *blk_crypto_keyslots; - -/* - * Allocating a crypto tfm during I/O can deadlock, so we have to preallocate - * all of a mode's tfms when that mode starts being used. Since each mode may - * need all the keyslots at some point, each mode needs its own tfm for each - * keyslot; thus, a keyslot may contain tfms for multiple modes. However, to - * match the behavior of real inline encryption hardware (which only supports a - * single encryption context per keyslot), we only allow one tfm per keyslot to - * be used at a time - the rest of the unused tfms have their keys cleared. - */ -static struct mutex tfms_lock[ARRAY_SIZE(blk_crypto_modes)]; -static bool tfms_inited[ARRAY_SIZE(blk_crypto_modes)]; - -struct work_mem { - struct work_struct crypto_work; - struct bio *bio; -}; - -/* The following few vars are only used during the crypto API fallback */ -static struct keyslot_manager *blk_crypto_ksm; -static struct workqueue_struct *blk_crypto_wq; -static mempool_t *blk_crypto_page_pool; -static struct kmem_cache *blk_crypto_work_mem_cache; - -bool bio_crypt_swhandled(struct bio *bio) -{ - return bio_has_crypt_ctx(bio) && - bio->bi_crypt_context->processing_ksm == blk_crypto_ksm; -} - -static u8 blank_key[BLK_CRYPTO_MAX_KEY_SIZE]; -static void evict_keyslot(unsigned int slot) -{ - struct blk_crypto_keyslot *slotp = &blk_crypto_keyslots[slot]; - enum blk_crypto_mode_num crypto_mode = slotp->crypto_mode; - int err; - - WARN_ON(slotp->crypto_mode == BLK_ENCRYPTION_MODE_INVALID); - - /* Clear the key in the skcipher */ - err = crypto_skcipher_setkey(slotp->tfms[crypto_mode], blank_key, - blk_crypto_modes[crypto_mode].keysize); - WARN_ON(err); - memzero_explicit(slotp->key, BLK_CRYPTO_MAX_KEY_SIZE); - slotp->crypto_mode = BLK_ENCRYPTION_MODE_INVALID; -} - -static int blk_crypto_keyslot_program(void *priv, const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size, - unsigned int slot) -{ - struct blk_crypto_keyslot *slotp = &blk_crypto_keyslots[slot]; - const struct blk_crypto_mode *mode = &blk_crypto_modes[crypto_mode]; - size_t keysize = mode->keysize; - int err; - - if (crypto_mode != slotp->crypto_mode && - slotp->crypto_mode != BLK_ENCRYPTION_MODE_INVALID) { - evict_keyslot(slot); - } - - if (!slotp->tfms[crypto_mode]) - return -ENOMEM; - slotp->crypto_mode = crypto_mode; - err = crypto_skcipher_setkey(slotp->tfms[crypto_mode], key, keysize); - - if (err) { - evict_keyslot(slot); - return err; - } - - memcpy(slotp->key, key, keysize); - - return 0; -} - -static int blk_crypto_keyslot_evict(void *priv, const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size, - unsigned int slot) -{ - evict_keyslot(slot); - return 0; -} - -static int blk_crypto_keyslot_find(void *priv, - const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size_bytes) -{ - int slot; - const size_t keysize = blk_crypto_modes[crypto_mode].keysize; - - for (slot = 0; slot < blk_crypto_num_keyslots; slot++) { - if (blk_crypto_keyslots[slot].crypto_mode == crypto_mode && - !crypto_memneq(blk_crypto_keyslots[slot].key, key, keysize)) - return slot; - } - - return -ENOKEY; -} - -static bool blk_crypto_mode_supported(void *priv, - enum blk_crypto_mode_num crypt_mode, - unsigned int data_unit_size) -{ - /* All blk_crypto_modes are required to have a crypto API fallback. */ - return true; -} - -/* - * The crypto API fallback KSM ops - only used for a bio when it specifies a - * blk_crypto_mode for which we failed to get a keyslot in the device's inline - * encryption hardware (which probably means the device doesn't have inline - * encryption hardware that supports that crypto mode). - */ -static const struct keyslot_mgmt_ll_ops blk_crypto_ksm_ll_ops = { - .keyslot_program = blk_crypto_keyslot_program, - .keyslot_evict = blk_crypto_keyslot_evict, - .keyslot_find = blk_crypto_keyslot_find, - .crypto_mode_supported = blk_crypto_mode_supported, -}; - -static void blk_crypto_encrypt_endio(struct bio *enc_bio) -{ - struct bio *src_bio = enc_bio->bi_private; - int i; - - for (i = 0; i < enc_bio->bi_vcnt; i++) - mempool_free(enc_bio->bi_io_vec[i].bv_page, - blk_crypto_page_pool); - - src_bio->bi_status = enc_bio->bi_status; - - bio_put(enc_bio); - bio_endio(src_bio); -} - -static struct bio *blk_crypto_clone_bio(struct bio *bio_src) -{ - struct bvec_iter iter; - struct bio_vec bv; - struct bio *bio; - - bio = bio_alloc_bioset(GFP_NOIO, bio_segments(bio_src), NULL); - if (!bio) - return NULL; - bio->bi_disk = bio_src->bi_disk; - bio->bi_opf = bio_src->bi_opf; - bio->bi_ioprio = bio_src->bi_ioprio; - bio->bi_write_hint = bio_src->bi_write_hint; - bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; - bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; - - bio_for_each_segment(bv, bio_src, iter) - bio->bi_io_vec[bio->bi_vcnt++] = bv; - - if (bio_integrity(bio_src) && - bio_integrity_clone(bio, bio_src, GFP_NOIO) < 0) { - bio_put(bio); - return NULL; - } - - bio_clone_blkcg_association(bio, bio_src); - - return bio; -} - /* Check that all I/O segments are data unit aligned */ static int bio_crypt_check_alignment(struct bio *bio) { - int data_unit_size = 1 << bio->bi_crypt_context->data_unit_size_bits; + const unsigned int data_unit_size = + bio->bi_crypt_context->bc_key->data_unit_size; struct bvec_iter iter; struct bio_vec bv; @@ -232,268 +50,6 @@ static int bio_crypt_check_alignment(struct bio *bio) return 0; } -static int blk_crypto_alloc_cipher_req(struct bio *src_bio, - struct skcipher_request **ciph_req_ptr, - struct crypto_wait *wait) -{ - int slot; - struct skcipher_request *ciph_req; - struct blk_crypto_keyslot *slotp; - - slot = bio_crypt_get_keyslot(src_bio); - slotp = &blk_crypto_keyslots[slot]; - ciph_req = skcipher_request_alloc(slotp->tfms[slotp->crypto_mode], - GFP_NOIO); - if (!ciph_req) { - src_bio->bi_status = BLK_STS_RESOURCE; - return -ENOMEM; - } - - skcipher_request_set_callback(ciph_req, - CRYPTO_TFM_REQ_MAY_BACKLOG | - CRYPTO_TFM_REQ_MAY_SLEEP, - crypto_req_done, wait); - *ciph_req_ptr = ciph_req; - return 0; -} - -static int blk_crypto_split_bio_if_needed(struct bio **bio_ptr) -{ - struct bio *bio = *bio_ptr; - unsigned int i = 0; - unsigned int num_sectors = 0; - struct bio_vec bv; - struct bvec_iter iter; - - bio_for_each_segment(bv, bio, iter) { - num_sectors += bv.bv_len >> SECTOR_SHIFT; - if (++i == BIO_MAX_PAGES) - break; - } - if (num_sectors < bio_sectors(bio)) { - struct bio *split_bio; - - split_bio = bio_split(bio, num_sectors, GFP_NOIO, NULL); - if (!split_bio) { - bio->bi_status = BLK_STS_RESOURCE; - return -ENOMEM; - } - bio_chain(split_bio, bio); - generic_make_request(bio); - *bio_ptr = split_bio; - } - return 0; -} - -/* - * The crypto API fallback's encryption routine. - * Allocate a bounce bio for encryption, encrypt the input bio using - * crypto API, and replace *bio_ptr with the bounce bio. May split input - * bio if it's too large. - */ -static int blk_crypto_encrypt_bio(struct bio **bio_ptr) -{ - struct bio *src_bio; - struct skcipher_request *ciph_req = NULL; - DECLARE_CRYPTO_WAIT(wait); - int err = 0; - u64 curr_dun; - union { - __le64 dun; - u8 bytes[16]; - } iv; - struct scatterlist src, dst; - struct bio *enc_bio; - struct bio_vec *enc_bvec; - int i, j; - int data_unit_size; - - /* Split the bio if it's too big for single page bvec */ - err = blk_crypto_split_bio_if_needed(bio_ptr); - if (err) - return err; - - src_bio = *bio_ptr; - data_unit_size = 1 << src_bio->bi_crypt_context->data_unit_size_bits; - - /* Allocate bounce bio for encryption */ - enc_bio = blk_crypto_clone_bio(src_bio); - if (!enc_bio) { - src_bio->bi_status = BLK_STS_RESOURCE; - return -ENOMEM; - } - - /* - * Use the crypto API fallback keyslot manager to get a crypto_skcipher - * for the algorithm and key specified for this bio. - */ - err = bio_crypt_ctx_acquire_keyslot(src_bio, blk_crypto_ksm); - if (err) { - src_bio->bi_status = BLK_STS_IOERR; - goto out_put_enc_bio; - } - - /* and then allocate an skcipher_request for it */ - err = blk_crypto_alloc_cipher_req(src_bio, &ciph_req, &wait); - if (err) - goto out_release_keyslot; - - curr_dun = bio_crypt_data_unit_num(src_bio); - sg_init_table(&src, 1); - sg_init_table(&dst, 1); - - skcipher_request_set_crypt(ciph_req, &src, &dst, - data_unit_size, iv.bytes); - - /* Encrypt each page in the bounce bio */ - for (i = 0, enc_bvec = enc_bio->bi_io_vec; i < enc_bio->bi_vcnt; - enc_bvec++, i++) { - struct page *plaintext_page = enc_bvec->bv_page; - struct page *ciphertext_page = - mempool_alloc(blk_crypto_page_pool, GFP_NOIO); - - enc_bvec->bv_page = ciphertext_page; - - if (!ciphertext_page) { - src_bio->bi_status = BLK_STS_RESOURCE; - err = -ENOMEM; - goto out_free_bounce_pages; - } - - sg_set_page(&src, plaintext_page, data_unit_size, - enc_bvec->bv_offset); - sg_set_page(&dst, ciphertext_page, data_unit_size, - enc_bvec->bv_offset); - - /* Encrypt each data unit in this page */ - for (j = 0; j < enc_bvec->bv_len; j += data_unit_size) { - memset(&iv, 0, sizeof(iv)); - iv.dun = cpu_to_le64(curr_dun); - - err = crypto_wait_req(crypto_skcipher_encrypt(ciph_req), - &wait); - if (err) { - i++; - src_bio->bi_status = BLK_STS_RESOURCE; - goto out_free_bounce_pages; - } - curr_dun++; - src.offset += data_unit_size; - dst.offset += data_unit_size; - } - } - - enc_bio->bi_private = src_bio; - enc_bio->bi_end_io = blk_crypto_encrypt_endio; - *bio_ptr = enc_bio; - - enc_bio = NULL; - err = 0; - goto out_free_ciph_req; - -out_free_bounce_pages: - while (i > 0) - mempool_free(enc_bio->bi_io_vec[--i].bv_page, - blk_crypto_page_pool); -out_free_ciph_req: - skcipher_request_free(ciph_req); -out_release_keyslot: - bio_crypt_ctx_release_keyslot(src_bio); -out_put_enc_bio: - if (enc_bio) - bio_put(enc_bio); - - return err; -} - -/* - * The crypto API fallback's main decryption routine. - * Decrypts input bio in place. - */ -static void blk_crypto_decrypt_bio(struct work_struct *w) -{ - struct work_mem *work_mem = - container_of(w, struct work_mem, crypto_work); - struct bio *bio = work_mem->bio; - struct skcipher_request *ciph_req = NULL; - DECLARE_CRYPTO_WAIT(wait); - struct bio_vec bv; - struct bvec_iter iter; - u64 curr_dun; - union { - __le64 dun; - u8 bytes[16]; - } iv; - struct scatterlist sg; - int data_unit_size = 1 << bio->bi_crypt_context->data_unit_size_bits; - int i; - int err; - - /* - * Use the crypto API fallback keyslot manager to get a crypto_skcipher - * for the algorithm and key specified for this bio. - */ - if (bio_crypt_ctx_acquire_keyslot(bio, blk_crypto_ksm)) { - bio->bi_status = BLK_STS_RESOURCE; - goto out_no_keyslot; - } - - /* and then allocate an skcipher_request for it */ - err = blk_crypto_alloc_cipher_req(bio, &ciph_req, &wait); - if (err) - goto out; - - curr_dun = bio_crypt_sw_data_unit_num(bio); - sg_init_table(&sg, 1); - skcipher_request_set_crypt(ciph_req, &sg, &sg, data_unit_size, - iv.bytes); - - /* Decrypt each segment in the bio */ - __bio_for_each_segment(bv, bio, iter, - bio->bi_crypt_context->crypt_iter) { - struct page *page = bv.bv_page; - - sg_set_page(&sg, page, data_unit_size, bv.bv_offset); - - /* Decrypt each data unit in the segment */ - for (i = 0; i < bv.bv_len; i += data_unit_size) { - memset(&iv, 0, sizeof(iv)); - iv.dun = cpu_to_le64(curr_dun); - if (crypto_wait_req(crypto_skcipher_decrypt(ciph_req), - &wait)) { - bio->bi_status = BLK_STS_IOERR; - goto out; - } - curr_dun++; - sg.offset += data_unit_size; - } - } - -out: - skcipher_request_free(ciph_req); - bio_crypt_ctx_release_keyslot(bio); -out_no_keyslot: - kmem_cache_free(blk_crypto_work_mem_cache, work_mem); - bio_endio(bio); -} - -/* Queue bio for decryption */ -static void blk_crypto_queue_decrypt_bio(struct bio *bio) -{ - struct work_mem *work_mem = - kmem_cache_zalloc(blk_crypto_work_mem_cache, GFP_ATOMIC); - - if (!work_mem) { - bio->bi_status = BLK_STS_RESOURCE; - bio_endio(bio); - return; - } - - INIT_WORK(&work_mem->crypto_work, blk_crypto_decrypt_bio); - work_mem->bio = bio; - queue_work(blk_crypto_wq, &work_mem->crypto_work); -} - /** * blk_crypto_submit_bio - handle submitting bio for inline encryption * @@ -517,20 +73,20 @@ int blk_crypto_submit_bio(struct bio **bio_ptr) { struct bio *bio = *bio_ptr; struct request_queue *q; + struct bio_crypt_ctx *bc = bio->bi_crypt_context; int err; - struct bio_crypt_ctx *crypt_ctx; - if (!bio_has_crypt_ctx(bio) || !bio_has_data(bio)) + if (!bc || !bio_has_data(bio)) return 0; /* - * When a read bio is marked for sw decryption, its bi_iter is saved - * so that when we decrypt the bio later, we know what part of it was - * marked for sw decryption (when the bio is passed down after + * When a read bio is marked for fallback decryption, its bi_iter is + * saved so that when we decrypt the bio later, we know what part of it + * was marked for fallback decryption (when the bio is passed down after * blk_crypto_submit bio, it may be split or advanced so we cannot rely * on the bi_iter while decrypting in blk_crypto_endio) */ - if (bio_crypt_swhandled(bio)) + if (bio_crypt_fallback_crypted(bc)) return 0; err = bio_crypt_check_alignment(bio); @@ -539,21 +95,22 @@ int blk_crypto_submit_bio(struct bio **bio_ptr) goto out; } - crypt_ctx = bio->bi_crypt_context; q = bio->bi_disk->queue; - if (bio_crypt_has_keyslot(bio)) { + if (bc->bc_ksm) { /* Key already programmed into device? */ - if (q->ksm == crypt_ctx->processing_ksm) + if (q->ksm == bc->bc_ksm) return 0; /* Nope, release the existing keyslot. */ - bio_crypt_ctx_release_keyslot(bio); + bio_crypt_ctx_release_keyslot(bc); } /* Get device keyslot if supported */ - if (q->ksm) { - err = bio_crypt_ctx_acquire_keyslot(bio, q->ksm); + if (keyslot_manager_crypto_mode_supported(q->ksm, + bc->bc_key->crypto_mode, + bc->bc_key->data_unit_size)) { + err = bio_crypt_ctx_acquire_keyslot(bc, q->ksm); if (!err) return 0; @@ -562,24 +119,10 @@ int blk_crypto_submit_bio(struct bio **bio_ptr) } /* Fallback to crypto API */ - if (!READ_ONCE(tfms_inited[bio->bi_crypt_context->crypto_mode])) { - err = -EIO; - bio->bi_status = BLK_STS_IOERR; + err = blk_crypto_fallback_submit_bio(bio_ptr); + if (err) goto out; - } - if (bio_data_dir(bio) == WRITE) { - /* Encrypt the data now */ - err = blk_crypto_encrypt_bio(bio_ptr); - if (err) - goto out; - } else { - /* Mark bio as swhandled */ - bio->bi_crypt_context->processing_ksm = blk_crypto_ksm; - bio->bi_crypt_context->crypt_iter = bio->bi_iter; - bio->bi_crypt_context->sw_data_unit_num = - bio->bi_crypt_context->data_unit_num; - } return 0; out: bio_endio(*bio_ptr); @@ -589,10 +132,10 @@ int blk_crypto_submit_bio(struct bio **bio_ptr) /** * blk_crypto_endio - clean up bio w.r.t inline encryption during bio_endio * - * @bio - the bio to clean up + * @bio: the bio to clean up * - * If blk_crypto_submit_bio decided to fallback to crypto API for this - * bio, we queue the bio for decryption into a workqueue and return false, + * If blk_crypto_submit_bio decided to fallback to crypto API for this bio, + * we queue the bio for decryption into a workqueue and return false, * and call bio_endio(bio) at a later time (after the bio has been decrypted). * * If the bio is not to be decrypted by the crypto API, this function releases @@ -603,195 +146,97 @@ int blk_crypto_submit_bio(struct bio **bio_ptr) */ bool blk_crypto_endio(struct bio *bio) { - if (!bio_has_crypt_ctx(bio)) + struct bio_crypt_ctx *bc = bio->bi_crypt_context; + + if (!bc) return true; - if (bio_crypt_swhandled(bio)) { + if (bio_crypt_fallback_crypted(bc)) { /* - * The only bios that are swhandled when they reach here - * are those with bio_data_dir(bio) == READ, since WRITE - * bios that are encrypted by the crypto API fallback are - * handled by blk_crypto_encrypt_endio. + * The only bios who's crypto is handled by the blk-crypto + * fallback when they reach here are those with + * bio_data_dir(bio) == READ, since WRITE bios that are + * encrypted by the crypto API fallback are handled by + * blk_crypto_encrypt_endio(). */ - - /* If there was an IO error, don't decrypt. */ - if (bio->bi_status) - return true; - - blk_crypto_queue_decrypt_bio(bio); - return false; + return !blk_crypto_queue_decrypt_bio(bio); } - if (bio_crypt_has_keyslot(bio)) - bio_crypt_ctx_release_keyslot(bio); + if (bc->bc_keyslot >= 0) + bio_crypt_ctx_release_keyslot(bc); return true; } /** - * blk_crypto_start_using_mode() - Allocate skciphers for a - * mode_num for all keyslots - * @mode_num - the blk_crypto_mode we want to allocate ciphers for. + * blk_crypto_init_key() - Prepare a key for use with blk-crypto + * @blk_key: Pointer to the blk_crypto_key to initialize. + * @raw_key: Pointer to the raw key. Must be the correct length for the chosen + * @crypto_mode; see blk_crypto_modes[]. + * @crypto_mode: identifier for the encryption algorithm to use + * @data_unit_size: the data unit size to use for en/decryption * - * Upper layers (filesystems) should call this function to ensure that a - * the crypto API fallback has transforms for this algorithm, if they become - * necessary. - * - * Return: 0 on success and -err on error. + * Return: The blk_crypto_key that was prepared, or an ERR_PTR() on error. When + * done using the key, it must be freed with blk_crypto_free_key(). */ -int blk_crypto_start_using_mode(enum blk_crypto_mode_num mode_num, - unsigned int data_unit_size, - struct request_queue *q) +int blk_crypto_init_key(struct blk_crypto_key *blk_key, const u8 *raw_key, + enum blk_crypto_mode_num crypto_mode, + unsigned int data_unit_size) { - struct blk_crypto_keyslot *slotp; - int err = 0; - int i; + const struct blk_crypto_mode *mode; + static siphash_key_t hash_key; + + memset(blk_key, 0, sizeof(*blk_key)); + + if (crypto_mode >= ARRAY_SIZE(blk_crypto_modes)) + return -EINVAL; + + mode = &blk_crypto_modes[crypto_mode]; + if (mode->keysize == 0) + return -EINVAL; + + if (!is_power_of_2(data_unit_size)) + return -EINVAL; + + blk_key->crypto_mode = crypto_mode; + blk_key->data_unit_size = data_unit_size; + blk_key->data_unit_size_bits = ilog2(data_unit_size); + blk_key->size = mode->keysize; + memcpy(blk_key->raw, raw_key, mode->keysize); /* - * Fast path - * Ensure that updates to blk_crypto_keyslots[i].tfms[mode_num] - * for each i are visible before we try to access them. + * The keyslot manager uses the SipHash of the key to implement O(1) key + * lookups while avoiding leaking information about the keys. It's + * precomputed here so that it only needs to be computed once per key. */ - if (likely(smp_load_acquire(&tfms_inited[mode_num]))) - return 0; + get_random_once(&hash_key, sizeof(hash_key)); + blk_key->hash = siphash(raw_key, mode->keysize, &hash_key); - /* - * If the keyslot manager of the request queue supports this - * crypto mode, then we don't need to allocate this mode. - */ - if (keyslot_manager_crypto_mode_supported(q->ksm, mode_num, - data_unit_size)) { - return 0; - } - - mutex_lock(&tfms_lock[mode_num]); - if (likely(tfms_inited[mode_num])) - goto out; - - for (i = 0; i < blk_crypto_num_keyslots; i++) { - slotp = &blk_crypto_keyslots[i]; - slotp->tfms[mode_num] = crypto_alloc_skcipher( - blk_crypto_modes[mode_num].cipher_str, - 0, 0); - if (IS_ERR(slotp->tfms[mode_num])) { - err = PTR_ERR(slotp->tfms[mode_num]); - slotp->tfms[mode_num] = NULL; - goto out_free_tfms; - } - - crypto_skcipher_set_flags(slotp->tfms[mode_num], - CRYPTO_TFM_REQ_WEAK_KEY); - } - - /* - * Ensure that updates to blk_crypto_keyslots[i].tfms[mode_num] - * for each i are visible before we set tfms_inited[mode_num]. - */ - smp_store_release(&tfms_inited[mode_num], true); - goto out; - -out_free_tfms: - for (i = 0; i < blk_crypto_num_keyslots; i++) { - slotp = &blk_crypto_keyslots[i]; - crypto_free_skcipher(slotp->tfms[mode_num]); - slotp->tfms[mode_num] = NULL; - } -out: - mutex_unlock(&tfms_lock[mode_num]); - return err; + return 0; } -EXPORT_SYMBOL(blk_crypto_start_using_mode); /** * blk_crypto_evict_key() - Evict a key from any inline encryption hardware * it may have been programmed into - * @q - The request queue who's keyslot manager this key might have been - * programmed into - * @key - The key to evict - * @mode - The blk_crypto_mode_num used with this key - * @data_unit_size - The data unit size used with this key + * @q: The request queue who's keyslot manager this key might have been + * programmed into + * @key: The key to evict * * Upper layers (filesystems) should call this function to ensure that a key * is evicted from hardware that it might have been programmed into. This * will call keyslot_manager_evict_key on the queue's keyslot manager, if one * exists, and supports the crypto algorithm with the specified data unit size. - * Otherwise, it will evict the key from the blk_crypto_ksm. + * Otherwise, it will evict the key from the blk-crypto-fallback's ksm. * * Return: 0 on success, -err on error. */ -int blk_crypto_evict_key(struct request_queue *q, const u8 *key, - enum blk_crypto_mode_num mode, - unsigned int data_unit_size) +int blk_crypto_evict_key(struct request_queue *q, + const struct blk_crypto_key *key) { - struct keyslot_manager *ksm = blk_crypto_ksm; + if (q->ksm && + keyslot_manager_crypto_mode_supported(q->ksm, key->crypto_mode, + key->data_unit_size)) + return keyslot_manager_evict_key(q->ksm, key); - if (q && q->ksm && keyslot_manager_crypto_mode_supported(q->ksm, mode, - data_unit_size)) { - ksm = q->ksm; - } - - return keyslot_manager_evict_key(ksm, key, mode, data_unit_size); -} -EXPORT_SYMBOL(blk_crypto_evict_key); - -int __init blk_crypto_init(void) -{ - int i; - int err = -ENOMEM; - - prandom_bytes(blank_key, BLK_CRYPTO_MAX_KEY_SIZE); - - blk_crypto_ksm = keyslot_manager_create(blk_crypto_num_keyslots, - &blk_crypto_ksm_ll_ops, - NULL); - if (!blk_crypto_ksm) - goto out; - - blk_crypto_wq = alloc_workqueue("blk_crypto_wq", - WQ_UNBOUND | WQ_HIGHPRI | - WQ_MEM_RECLAIM, - num_online_cpus()); - if (!blk_crypto_wq) - goto out_free_ksm; - - blk_crypto_keyslots = kcalloc(blk_crypto_num_keyslots, - sizeof(*blk_crypto_keyslots), - GFP_KERNEL); - if (!blk_crypto_keyslots) - goto out_free_workqueue; - - for (i = 0; i < blk_crypto_num_keyslots; i++) { - blk_crypto_keyslots[i].crypto_mode = - BLK_ENCRYPTION_MODE_INVALID; - } - - for (i = 0; i < ARRAY_SIZE(blk_crypto_modes); i++) - mutex_init(&tfms_lock[i]); - - blk_crypto_page_pool = - mempool_create_page_pool(num_prealloc_bounce_pg, 0); - if (!blk_crypto_page_pool) - goto out_free_keyslots; - - blk_crypto_work_mem_cache = KMEM_CACHE(work_mem, SLAB_RECLAIM_ACCOUNT); - if (!blk_crypto_work_mem_cache) - goto out_free_page_pool; - - return 0; - -out_free_page_pool: - mempool_destroy(blk_crypto_page_pool); - blk_crypto_page_pool = NULL; -out_free_keyslots: - kzfree(blk_crypto_keyslots); - blk_crypto_keyslots = NULL; -out_free_workqueue: - destroy_workqueue(blk_crypto_wq); - blk_crypto_wq = NULL; -out_free_ksm: - keyslot_manager_destroy(blk_crypto_ksm); - blk_crypto_ksm = NULL; -out: - pr_warn("No memory for blk-crypto crypto API fallback."); - return err; + return blk_crypto_fallback_evict_key(key); } diff --git a/block/blk-merge.c b/block/blk-merge.c index 970351945431..22ecdbe4bd03 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -495,9 +495,6 @@ static inline int ll_new_hw_segment(struct request_queue *q, if (blk_integrity_merge_bio(q, req, bio) == false) goto no_merge; - if (WARN_ON_ONCE(!bio_crypt_ctx_compatible(bio, req->bio))) - goto no_merge; - /* * This will form the start of a new hw segment. Bump both * counters. @@ -523,6 +520,8 @@ int ll_back_merge_fn(struct request_queue *q, struct request *req, req_set_nomerge(q, req); return 0; } + if (!bio_crypt_ctx_mergeable(req->bio, blk_rq_bytes(req), bio)) + return 0; if (!bio_flagged(req->biotail, BIO_SEG_VALID)) blk_recount_segments(q, req->biotail); if (!bio_flagged(bio, BIO_SEG_VALID)) @@ -545,6 +544,8 @@ int ll_front_merge_fn(struct request_queue *q, struct request *req, req_set_nomerge(q, req); return 0; } + if (!bio_crypt_ctx_mergeable(bio, bio->bi_iter.bi_size, req->bio)) + return 0; if (!bio_flagged(bio, BIO_SEG_VALID)) blk_recount_segments(q, bio); if (!bio_flagged(req->bio, BIO_SEG_VALID)) @@ -621,6 +622,9 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req, if (blk_integrity_merge_rq(q, req, next) == false) return 0; + if (!bio_crypt_ctx_mergeable(req->bio, blk_rq_bytes(req), next->bio)) + return 0; + /* Merge is OK... */ req->nr_phys_segments = total_phys_segments; return 1; @@ -730,11 +734,6 @@ static struct request *attempt_merge(struct request_queue *q, if (req->write_hint != next->write_hint) return NULL; - if (!bio_crypt_ctx_back_mergeable(req->bio, blk_rq_sectors(req), - next->bio)) { - return NULL; - } - /* * If we are allowed to merge, then append bio list * from next to rq and release next. merge_requests_fn @@ -882,22 +881,11 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio) enum elv_merge blk_try_merge(struct request *rq, struct bio *bio) { - if (blk_discard_mergable(rq)) { + if (blk_discard_mergable(rq)) return ELEVATOR_DISCARD_MERGE; - } else if (blk_rq_pos(rq) + blk_rq_sectors(rq) == - bio->bi_iter.bi_sector) { - if (!bio_crypt_ctx_back_mergeable(rq->bio, - blk_rq_sectors(rq), bio)) { - return ELEVATOR_NO_MERGE; - } + else if (blk_rq_pos(rq) + blk_rq_sectors(rq) == bio->bi_iter.bi_sector) return ELEVATOR_BACK_MERGE; - } else if (blk_rq_pos(rq) - bio_sectors(bio) == - bio->bi_iter.bi_sector) { - if (!bio_crypt_ctx_back_mergeable(bio, - bio_sectors(bio), rq->bio)) { - return ELEVATOR_NO_MERGE; - } + else if (blk_rq_pos(rq) - bio_sectors(bio) == bio->bi_iter.bi_sector) return ELEVATOR_FRONT_MERGE; - } return ELEVATOR_NO_MERGE; } diff --git a/block/bounce.c b/block/bounce.c index 40a385616a1f..dc37375abfed 100644 --- a/block/bounce.c +++ b/block/bounce.c @@ -267,10 +267,7 @@ static struct bio *bounce_clone_bio(struct bio *bio_src, gfp_t gfp_mask, break; } - if (bio_crypt_clone(bio, bio_src, gfp_mask) < 0) { - bio_put(bio); - return NULL; - } + bio_crypt_clone(bio, bio_src, gfp_mask); if (bio_integrity(bio_src) && bio_integrity_clone(bio, bio_src, gfp_mask) < 0) { diff --git a/block/keyslot-manager.c b/block/keyslot-manager.c index 020931fc9f7d..cdf0607019d4 100644 --- a/block/keyslot-manager.c +++ b/block/keyslot-manager.c @@ -1,7 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 /* - * keyslot-manager.c - * * Copyright 2019 Google LLC */ @@ -27,6 +25,7 @@ * Upper layers will call keyslot_manager_get_slot_for_key() to program a * key into some slot in the inline encryption hardware. */ +#include #include #include #include @@ -36,12 +35,14 @@ struct keyslot { atomic_t slot_refs; struct list_head idle_slot_node; + struct hlist_node hash_node; + struct blk_crypto_key key; }; struct keyslot_manager { unsigned int num_slots; - atomic_t num_idle_slots; struct keyslot_mgmt_ll_ops ksm_ll_ops; + unsigned int crypto_mode_supported[BLK_ENCRYPTION_MODE_MAX]; void *ll_priv_data; /* Protects programming and evicting keys from the device */ @@ -52,6 +53,15 @@ struct keyslot_manager { struct list_head idle_slots; spinlock_t idle_slots_lock; + /* + * Hash table which maps key hashes to keyslots, so that we can find a + * key's keyslot in O(1) time rather than O(num_slots). Protected by + * 'lock'. A cryptographic hash function is used so that timing attacks + * can't leak information about the raw keys. + */ + struct hlist_head *slot_hashtable; + unsigned int slot_hashtable_size; + /* Per-keyslot data */ struct keyslot slots[]; }; @@ -62,6 +72,13 @@ struct keyslot_manager { * @ksm_ll_ops: The struct keyslot_mgmt_ll_ops for the device that this keyslot * manager will use to perform operations like programming and * evicting keys. + * @crypto_mode_supported: Array of size BLK_ENCRYPTION_MODE_MAX of + * bitmasks that represents whether a crypto mode + * and data unit size are supported. The i'th bit + * of crypto_mode_supported[crypto_mode] is set iff + * a data unit size of (1 << i) is supported. We + * only support data unit sizes that are powers of + * 2. * @ll_priv_data: Private data passed as is to the functions in ksm_ll_ops. * * Allocate memory for and initialize a keyslot manager. Called by e.g. @@ -71,20 +88,20 @@ struct keyslot_manager { * Return: Pointer to constructed keyslot manager or NULL on error. */ struct keyslot_manager *keyslot_manager_create(unsigned int num_slots, - const struct keyslot_mgmt_ll_ops *ksm_ll_ops, - void *ll_priv_data) + const struct keyslot_mgmt_ll_ops *ksm_ll_ops, + const unsigned int crypto_mode_supported[BLK_ENCRYPTION_MODE_MAX], + void *ll_priv_data) { struct keyslot_manager *ksm; - int slot; + unsigned int slot; + unsigned int i; if (num_slots == 0) return NULL; /* Check that all ops are specified */ if (ksm_ll_ops->keyslot_program == NULL || - ksm_ll_ops->keyslot_evict == NULL || - ksm_ll_ops->crypto_mode_supported == NULL || - ksm_ll_ops->keyslot_find == NULL) + ksm_ll_ops->keyslot_evict == NULL) return NULL; ksm = kvzalloc(struct_size(ksm, slots, num_slots), GFP_KERNEL); @@ -92,8 +109,9 @@ struct keyslot_manager *keyslot_manager_create(unsigned int num_slots, return NULL; ksm->num_slots = num_slots; - atomic_set(&ksm->num_idle_slots, num_slots); ksm->ksm_ll_ops = *ksm_ll_ops; + memcpy(ksm->crypto_mode_supported, crypto_mode_supported, + sizeof(ksm->crypto_mode_supported)); ksm->ll_priv_data = ll_priv_data; init_rwsem(&ksm->lock); @@ -108,9 +126,29 @@ struct keyslot_manager *keyslot_manager_create(unsigned int num_slots, spin_lock_init(&ksm->idle_slots_lock); + ksm->slot_hashtable_size = roundup_pow_of_two(num_slots); + ksm->slot_hashtable = kvmalloc_array(ksm->slot_hashtable_size, + sizeof(ksm->slot_hashtable[0]), + GFP_KERNEL); + if (!ksm->slot_hashtable) + goto err_free_ksm; + for (i = 0; i < ksm->slot_hashtable_size; i++) + INIT_HLIST_HEAD(&ksm->slot_hashtable[i]); + return ksm; + +err_free_ksm: + keyslot_manager_destroy(ksm); + return NULL; +} +EXPORT_SYMBOL_GPL(keyslot_manager_create); + +static inline struct hlist_head * +hash_bucket_for_key(struct keyslot_manager *ksm, + const struct blk_crypto_key *key) +{ + return &ksm->slot_hashtable[key->hash & (ksm->slot_hashtable_size - 1)]; } -EXPORT_SYMBOL(keyslot_manager_create); static void remove_slot_from_lru_list(struct keyslot_manager *ksm, int slot) { @@ -119,22 +157,32 @@ static void remove_slot_from_lru_list(struct keyslot_manager *ksm, int slot) spin_lock_irqsave(&ksm->idle_slots_lock, flags); list_del(&ksm->slots[slot].idle_slot_node); spin_unlock_irqrestore(&ksm->idle_slots_lock, flags); - - atomic_dec(&ksm->num_idle_slots); } -static int find_and_grab_keyslot(struct keyslot_manager *ksm, const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size) +static int find_keyslot(struct keyslot_manager *ksm, + const struct blk_crypto_key *key) +{ + const struct hlist_head *head = hash_bucket_for_key(ksm, key); + const struct keyslot *slotp; + + hlist_for_each_entry(slotp, head, hash_node) { + if (slotp->key.hash == key->hash && + slotp->key.crypto_mode == key->crypto_mode && + slotp->key.data_unit_size == key->data_unit_size && + !crypto_memneq(slotp->key.raw, key->raw, key->size)) + return slotp - ksm->slots; + } + return -ENOKEY; +} + +static int find_and_grab_keyslot(struct keyslot_manager *ksm, + const struct blk_crypto_key *key) { int slot; - slot = ksm->ksm_ll_ops.keyslot_find(ksm->ll_priv_data, key, - crypto_mode, data_unit_size); + slot = find_keyslot(ksm, key); if (slot < 0) return slot; - if (WARN_ON(slot >= ksm->num_slots)) - return -EINVAL; if (atomic_inc_return(&ksm->slots[slot].slot_refs) == 1) { /* Took first reference to this slot; remove it from LRU list */ remove_slot_from_lru_list(ksm, slot); @@ -145,37 +193,32 @@ static int find_and_grab_keyslot(struct keyslot_manager *ksm, const u8 *key, /** * keyslot_manager_get_slot_for_key() - Program a key into a keyslot. * @ksm: The keyslot manager to program the key into. - * @key: Pointer to the bytes of the key to program. Must be the correct length - * for the chosen @crypto_mode; see blk_crypto_modes in blk-crypto.c. - * @crypto_mode: Identifier for the encryption algorithm to use. - * @data_unit_size: The data unit size to use for en/decryption. + * @key: Pointer to the key object to program, including the raw key, crypto + * mode, and data unit size. * - * Get a keyslot that's been programmed with the specified key, crypto_mode, and - * data_unit_size. If one already exists, return it with incremented refcount. - * Otherwise, wait for a keyslot to become idle and program it. + * Get a keyslot that's been programmed with the specified key. If one already + * exists, return it with incremented refcount. Otherwise, wait for a keyslot + * to become idle and program it. * * Context: Process context. Takes and releases ksm->lock. * Return: The keyslot on success, else a -errno value. */ int keyslot_manager_get_slot_for_key(struct keyslot_manager *ksm, - const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size) + const struct blk_crypto_key *key) { int slot; int err; struct keyslot *idle_slot; down_read(&ksm->lock); - slot = find_and_grab_keyslot(ksm, key, crypto_mode, data_unit_size); + slot = find_and_grab_keyslot(ksm, key); up_read(&ksm->lock); if (slot != -ENOKEY) return slot; for (;;) { down_write(&ksm->lock); - slot = find_and_grab_keyslot(ksm, key, crypto_mode, - data_unit_size); + slot = find_and_grab_keyslot(ksm, key); if (slot != -ENOKEY) { up_write(&ksm->lock); return slot; @@ -185,42 +228,43 @@ int keyslot_manager_get_slot_for_key(struct keyslot_manager *ksm, * If we're here, that means there wasn't a slot that was * already programmed with the key. So try to program it. */ - if (atomic_read(&ksm->num_idle_slots) > 0) + if (!list_empty(&ksm->idle_slots)) break; up_write(&ksm->lock); wait_event(ksm->idle_slots_wait_queue, - (atomic_read(&ksm->num_idle_slots) > 0)); + !list_empty(&ksm->idle_slots)); } idle_slot = list_first_entry(&ksm->idle_slots, struct keyslot, idle_slot_node); slot = idle_slot - ksm->slots; - err = ksm->ksm_ll_ops.keyslot_program(ksm->ll_priv_data, key, - crypto_mode, - data_unit_size, - slot); - + err = ksm->ksm_ll_ops.keyslot_program(ksm, key, slot); if (err) { wake_up(&ksm->idle_slots_wait_queue); up_write(&ksm->lock); return err; } - atomic_set(&ksm->slots[slot].slot_refs, 1); + /* Move this slot to the hash list for the new key. */ + if (idle_slot->key.crypto_mode != BLK_ENCRYPTION_MODE_INVALID) + hlist_del(&idle_slot->hash_node); + hlist_add_head(&idle_slot->hash_node, hash_bucket_for_key(ksm, key)); + + atomic_set(&idle_slot->slot_refs, 1); + idle_slot->key = *key; + remove_slot_from_lru_list(ksm, slot); up_write(&ksm->lock); return slot; - } -EXPORT_SYMBOL(keyslot_manager_get_slot_for_key); /** * keyslot_manager_get_slot() - Increment the refcount on the specified slot. - * @ksm - The keyslot manager that we want to modify. - * @slot - The slot to increment the refcount of. + * @ksm: The keyslot manager that we want to modify. + * @slot: The slot to increment the refcount of. * * This function assumes that there is already an active reference to that slot * and simply increments the refcount. This is useful when cloning a bio that @@ -236,7 +280,6 @@ void keyslot_manager_get_slot(struct keyslot_manager *ksm, unsigned int slot) WARN_ON(atomic_inc_return(&ksm->slots[slot].slot_refs) < 2); } -EXPORT_SYMBOL(keyslot_manager_get_slot); /** * keyslot_manager_put_slot() - Release a reference to a slot @@ -257,19 +300,17 @@ void keyslot_manager_put_slot(struct keyslot_manager *ksm, unsigned int slot) list_add_tail(&ksm->slots[slot].idle_slot_node, &ksm->idle_slots); spin_unlock_irqrestore(&ksm->idle_slots_lock, flags); - atomic_inc(&ksm->num_idle_slots); wake_up(&ksm->idle_slots_wait_queue); } } -EXPORT_SYMBOL(keyslot_manager_put_slot); /** * keyslot_manager_crypto_mode_supported() - Find out if a crypto_mode/data * unit size combination is supported * by a ksm. - * @ksm - The keyslot manager to check - * @crypto_mode - The crypto mode to check for. - * @data_unit_size - The data_unit_size for the mode. + * @ksm: The keyslot manager to check + * @crypto_mode: The crypto mode to check for. + * @data_unit_size: The data_unit_size for the mode. * * Calls and returns the result of the crypto_mode_supported function specified * by the ksm. @@ -284,69 +325,102 @@ bool keyslot_manager_crypto_mode_supported(struct keyslot_manager *ksm, { if (!ksm) return false; - return ksm->ksm_ll_ops.crypto_mode_supported(ksm->ll_priv_data, - crypto_mode, - data_unit_size); + if (WARN_ON(crypto_mode >= BLK_ENCRYPTION_MODE_MAX)) + return false; + if (WARN_ON(!is_power_of_2(data_unit_size))) + return false; + return ksm->crypto_mode_supported[crypto_mode] & data_unit_size; } -EXPORT_SYMBOL(keyslot_manager_crypto_mode_supported); - -bool keyslot_manager_rq_crypto_mode_supported(struct request_queue *q, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size) -{ - return keyslot_manager_crypto_mode_supported(q->ksm, crypto_mode, - data_unit_size); -} -EXPORT_SYMBOL(keyslot_manager_rq_crypto_mode_supported); /** * keyslot_manager_evict_key() - Evict a key from the lower layer device. - * @ksm - The keyslot manager to evict from - * @key - The key to evict - * @crypto_mode - The crypto algorithm the key was programmed with. - * @data_unit_size - The data_unit_size the key was programmed with. + * @ksm: The keyslot manager to evict from + * @key: The key to evict * - * Finds the slot that the specified key, crypto_mode, data_unit_size combo - * was programmed into, and evicts that slot from the lower layer device if - * the refcount on the slot is 0. Returns -EBUSY if the refcount is not 0, and - * -errno on error. + * Find the keyslot that the specified key was programmed into, and evict that + * slot from the lower layer device if that slot is not currently in use. * * Context: Process context. Takes and releases ksm->lock. + * Return: 0 on success, -EBUSY if the key is still in use, or another + * -errno value on other error. */ int keyslot_manager_evict_key(struct keyslot_manager *ksm, - const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size) + const struct blk_crypto_key *key) { int slot; - int err = 0; + int err; + struct keyslot *slotp; down_write(&ksm->lock); - slot = ksm->ksm_ll_ops.keyslot_find(ksm->ll_priv_data, key, - crypto_mode, - data_unit_size); - + slot = find_keyslot(ksm, key); if (slot < 0) { - up_write(&ksm->lock); - return slot; + err = slot; + goto out_unlock; } + slotp = &ksm->slots[slot]; - if (atomic_read(&ksm->slots[slot].slot_refs) == 0) { - err = ksm->ksm_ll_ops.keyslot_evict(ksm->ll_priv_data, key, - crypto_mode, - data_unit_size, - slot); - } else { + if (atomic_read(&slotp->slot_refs) != 0) { err = -EBUSY; + goto out_unlock; } + err = ksm->ksm_ll_ops.keyslot_evict(ksm, key, slot); + if (err) + goto out_unlock; + hlist_del(&slotp->hash_node); + memzero_explicit(&slotp->key, sizeof(slotp->key)); + err = 0; +out_unlock: up_write(&ksm->lock); return err; } -EXPORT_SYMBOL(keyslot_manager_evict_key); + +/** + * keyslot_manager_reprogram_all_keys() - Re-program all keyslots. + * @ksm: The keyslot manager + * + * Re-program all keyslots that are supposed to have a key programmed. This is + * intended only for use by drivers for hardware that loses its keys on reset. + * + * Context: Process context. Takes and releases ksm->lock. + */ +void keyslot_manager_reprogram_all_keys(struct keyslot_manager *ksm) +{ + unsigned int slot; + + down_write(&ksm->lock); + for (slot = 0; slot < ksm->num_slots; slot++) { + const struct keyslot *slotp = &ksm->slots[slot]; + int err; + + if (slotp->key.crypto_mode == BLK_ENCRYPTION_MODE_INVALID) + continue; + + err = ksm->ksm_ll_ops.keyslot_program(ksm, &slotp->key, slot); + WARN_ON(err); + } + up_write(&ksm->lock); +} +EXPORT_SYMBOL_GPL(keyslot_manager_reprogram_all_keys); + +/** + * keyslot_manager_private() - return the private data stored with ksm + * @ksm: The keyslot manager + * + * Returns the private data passed to the ksm when it was created. + */ +void *keyslot_manager_private(struct keyslot_manager *ksm) +{ + return ksm->ll_priv_data; +} +EXPORT_SYMBOL_GPL(keyslot_manager_private); void keyslot_manager_destroy(struct keyslot_manager *ksm) { - kvfree(ksm); + if (ksm) { + kvfree(ksm->slot_hashtable); + memzero_explicit(ksm, struct_size(ksm, slots, ksm->num_slots)); + kvfree(ksm); + } } -EXPORT_SYMBOL(keyslot_manager_destroy); +EXPORT_SYMBOL_GPL(keyslot_manager_destroy); diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 8a68c17a40b1..926eeef42608 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1312,15 +1312,13 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio, sector_t sector, unsigned len) { struct bio *clone = &tio->clone; - int ret; __bio_clone_fast(clone, bio); - ret = bio_crypt_clone(clone, bio, GFP_NOIO); - if (ret < 0) - return ret; + bio_crypt_clone(clone, bio, GFP_NOIO); if (unlikely(bio_integrity(bio) != NULL)) { + int r; if (unlikely(!dm_target_has_integrity(tio->ti->type) && !dm_target_passes_integrity(tio->ti->type))) { DMWARN("%s: the target %s doesn't support integrity data.", @@ -1329,11 +1327,9 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio, return -EIO; } - ret = bio_integrity_clone(clone, bio, GFP_NOIO); - if (ret < 0) { - bio_crypt_free_ctx(clone); - return ret; - } + r = bio_integrity_clone(clone, bio, GFP_NOIO); + if (r < 0) + return r; } if (bio_op(bio) != REQ_OP_ZONE_REPORT) diff --git a/drivers/scsi/ufs/ufshcd-crypto.c b/drivers/scsi/ufs/ufshcd-crypto.c index 75d834180f8b..1cfd9a327049 100644 --- a/drivers/scsi/ufs/ufshcd-crypto.c +++ b/drivers/scsi/ufs/ufshcd-crypto.c @@ -3,8 +3,7 @@ * Copyright 2019 Google LLC */ -#include - +#include #include "ufshcd.h" #include "ufshcd-crypto.h" @@ -25,19 +24,23 @@ static u8 get_data_unit_size_mask(unsigned int data_unit_size) static size_t get_keysize_bytes(enum ufs_crypto_key_size size) { switch (size) { - case UFS_CRYPTO_KEY_SIZE_128: return 16; - case UFS_CRYPTO_KEY_SIZE_192: return 24; - case UFS_CRYPTO_KEY_SIZE_256: return 32; - case UFS_CRYPTO_KEY_SIZE_512: return 64; - default: return 0; + case UFS_CRYPTO_KEY_SIZE_128: + return 16; + case UFS_CRYPTO_KEY_SIZE_192: + return 24; + case UFS_CRYPTO_KEY_SIZE_256: + return 32; + case UFS_CRYPTO_KEY_SIZE_512: + return 64; + default: + return 0; } } -static int ufshcd_crypto_cap_find(void *hba_p, +static int ufshcd_crypto_cap_find(struct ufs_hba *hba, enum blk_crypto_mode_num crypto_mode, unsigned int data_unit_size) { - struct ufs_hba *hba = hba_p; enum ufs_crypto_alg ufs_alg; u8 data_unit_mask; int cap_idx; @@ -52,7 +55,8 @@ static int ufshcd_crypto_cap_find(void *hba_p, ufs_alg = UFS_CRYPTO_ALG_AES_XTS; ufs_key_size = UFS_CRYPTO_KEY_SIZE_256; break; - default: return -EINVAL; + default: + return -EINVAL; } data_unit_mask = get_data_unit_size_mask(data_unit_size); @@ -101,8 +105,10 @@ static int ufshcd_crypto_cfg_entry_write_key(union ufs_crypto_cfg_entry *cfg, memcpy(cfg->crypto_key + UFS_CRYPTO_KEY_MAX_SIZE/2, key + key_size_bytes/2, key_size_bytes/2); return 0; - case UFS_CRYPTO_ALG_BITLOCKER_AES_CBC: // fallthrough - case UFS_CRYPTO_ALG_AES_ECB: // fallthrough + case UFS_CRYPTO_ALG_BITLOCKER_AES_CBC: + /* fall through */ + case UFS_CRYPTO_ALG_AES_ECB: + /* fall through */ case UFS_CRYPTO_ALG_ESSIV_AES_CBC: memcpy(cfg->crypto_key, key, key_size_bytes); return 0; @@ -111,13 +117,15 @@ static int ufshcd_crypto_cfg_entry_write_key(union ufs_crypto_cfg_entry *cfg, return -EINVAL; } -static void program_key(struct ufs_hba *hba, - const union ufs_crypto_cfg_entry *cfg, - int slot) +static void ufshcd_program_key(struct ufs_hba *hba, + const union ufs_crypto_cfg_entry *cfg, + int slot) { int i; u32 slot_offset = hba->crypto_cfg_register + slot * sizeof(*cfg); + pm_runtime_get_sync(hba->dev); + ufshcd_hold(hba, false); /* Clear the dword 16 */ ufshcd_writel(hba, 0, slot_offset + 16 * sizeof(cfg->reg_val[0])); /* Ensure that CFGE is cleared before programming the key */ @@ -137,29 +145,45 @@ static void program_key(struct ufs_hba *hba, ufshcd_writel(hba, le32_to_cpu(cfg->reg_val[16]), slot_offset + 16 * sizeof(cfg->reg_val[0])); wmb(); + ufshcd_release(hba); + pm_runtime_put_sync(hba->dev); } -static int ufshcd_crypto_keyslot_program(void *hba_p, const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size, +static void ufshcd_clear_keyslot(struct ufs_hba *hba, int slot) +{ + union ufs_crypto_cfg_entry cfg = { 0 }; + + ufshcd_program_key(hba, &cfg, slot); +} + +/* Clear all keyslots at driver init time */ +static void ufshcd_clear_all_keyslots(struct ufs_hba *hba) +{ + int slot; + + for (slot = 0; slot < ufshcd_num_keyslots(hba); slot++) + ufshcd_clear_keyslot(hba, slot); +} + +static int ufshcd_crypto_keyslot_program(struct keyslot_manager *ksm, + const struct blk_crypto_key *key, unsigned int slot) { - struct ufs_hba *hba = hba_p; + struct ufs_hba *hba = keyslot_manager_private(ksm); int err = 0; u8 data_unit_mask; union ufs_crypto_cfg_entry cfg; - union ufs_crypto_cfg_entry *cfg_arr = hba->crypto_cfgs; int cap_idx; - cap_idx = ufshcd_crypto_cap_find(hba_p, crypto_mode, - data_unit_size); + cap_idx = ufshcd_crypto_cap_find(hba, key->crypto_mode, + key->data_unit_size); if (!ufshcd_is_crypto_enabled(hba) || !ufshcd_keyslot_valid(hba, slot) || !ufshcd_cap_idx_valid(hba, cap_idx)) return -EINVAL; - data_unit_mask = get_data_unit_size_mask(data_unit_size); + data_unit_mask = get_data_unit_size_mask(key->data_unit_size); if (!(data_unit_mask & hba->crypto_cap_array[cap_idx].sdus_mask)) return -EINVAL; @@ -169,134 +193,74 @@ static int ufshcd_crypto_keyslot_program(void *hba_p, const u8 *key, cfg.crypto_cap_idx = cap_idx; cfg.config_enable |= UFS_CRYPTO_CONFIGURATION_ENABLE; - err = ufshcd_crypto_cfg_entry_write_key(&cfg, key, - hba->crypto_cap_array[cap_idx]); + err = ufshcd_crypto_cfg_entry_write_key(&cfg, key->raw, + hba->crypto_cap_array[cap_idx]); if (err) return err; - program_key(hba, &cfg, slot); + ufshcd_program_key(hba, &cfg, slot); - memcpy(&cfg_arr[slot], &cfg, sizeof(cfg)); memzero_explicit(&cfg, sizeof(cfg)); - return 0; } -static int ufshcd_crypto_keyslot_find(void *hba_p, - const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size) -{ - struct ufs_hba *hba = hba_p; - int err = 0; - int slot; - u8 data_unit_mask; - union ufs_crypto_cfg_entry cfg; - union ufs_crypto_cfg_entry *cfg_arr = hba->crypto_cfgs; - int cap_idx; - - cap_idx = ufshcd_crypto_cap_find(hba_p, crypto_mode, - data_unit_size); - - if (!ufshcd_is_crypto_enabled(hba) || - !ufshcd_cap_idx_valid(hba, cap_idx)) - return -EINVAL; - - data_unit_mask = get_data_unit_size_mask(data_unit_size); - - if (!(data_unit_mask & hba->crypto_cap_array[cap_idx].sdus_mask)) - return -EINVAL; - - memset(&cfg, 0, sizeof(cfg)); - err = ufshcd_crypto_cfg_entry_write_key(&cfg, key, - hba->crypto_cap_array[cap_idx]); - - if (err) - return -EINVAL; - - for (slot = 0; slot < NUM_KEYSLOTS(hba); slot++) { - if ((cfg_arr[slot].config_enable & - UFS_CRYPTO_CONFIGURATION_ENABLE) && - data_unit_mask == cfg_arr[slot].data_unit_size && - cap_idx == cfg_arr[slot].crypto_cap_idx && - !crypto_memneq(&cfg.crypto_key, cfg_arr[slot].crypto_key, - UFS_CRYPTO_KEY_MAX_SIZE)) { - memzero_explicit(&cfg, sizeof(cfg)); - return slot; - } - } - - memzero_explicit(&cfg, sizeof(cfg)); - return -ENOKEY; -} - -static int ufshcd_crypto_keyslot_evict(void *hba_p, const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size, +static int ufshcd_crypto_keyslot_evict(struct keyslot_manager *ksm, + const struct blk_crypto_key *key, unsigned int slot) { - struct ufs_hba *hba = hba_p; - int i = 0; - u32 reg_base; - union ufs_crypto_cfg_entry *cfg_arr = hba->crypto_cfgs; + struct ufs_hba *hba = keyslot_manager_private(ksm); if (!ufshcd_is_crypto_enabled(hba) || !ufshcd_keyslot_valid(hba, slot)) return -EINVAL; - memset(&cfg_arr[slot], 0, sizeof(cfg_arr[slot])); - reg_base = hba->crypto_cfg_register + slot * sizeof(cfg_arr[0]); - /* * Clear the crypto cfg on the device. Clearing CFGE * might not be sufficient, so just clear the entire cfg. */ - for (i = 0; i < sizeof(cfg_arr[0]); i += sizeof(__le32)) - ufshcd_writel(hba, 0, reg_base + i); - wmb(); + ufshcd_clear_keyslot(hba, slot); return 0; } -static bool ufshcd_crypto_mode_supported(void *hba_p, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size) -{ - return ufshcd_crypto_cap_find(hba_p, crypto_mode, data_unit_size) >= 0; -} - /* Functions implementing UFSHCI v2.1 specification behaviour */ void ufshcd_crypto_enable_spec(struct ufs_hba *hba) { - union ufs_crypto_cfg_entry *cfg_arr = hba->crypto_cfgs; - int slot; - if (!ufshcd_hba_is_crypto_supported(hba)) return; hba->caps |= UFSHCD_CAP_CRYPTO; - /* - * Reset might clear all keys, so reprogram all the keys. - * Also serves to clear keys on driver init. - */ - for (slot = 0; slot < NUM_KEYSLOTS(hba); slot++) - program_key(hba, &cfg_arr[slot], slot); + + /* Reset might clear all keys, so reprogram all the keys. */ + keyslot_manager_reprogram_all_keys(hba->ksm); } -EXPORT_SYMBOL(ufshcd_crypto_enable_spec); +EXPORT_SYMBOL_GPL(ufshcd_crypto_enable_spec); void ufshcd_crypto_disable_spec(struct ufs_hba *hba) { hba->caps &= ~UFSHCD_CAP_CRYPTO; } -EXPORT_SYMBOL(ufshcd_crypto_disable_spec); +EXPORT_SYMBOL_GPL(ufshcd_crypto_disable_spec); static const struct keyslot_mgmt_ll_ops ufshcd_ksm_ops = { .keyslot_program = ufshcd_crypto_keyslot_program, .keyslot_evict = ufshcd_crypto_keyslot_evict, - .keyslot_find = ufshcd_crypto_keyslot_find, - .crypto_mode_supported = ufshcd_crypto_mode_supported, }; +enum blk_crypto_mode_num ufshcd_blk_crypto_mode_num_for_alg_dusize( + enum ufs_crypto_alg ufs_crypto_alg, + enum ufs_crypto_key_size key_size) +{ + /* + * This is currently the only mode that UFS and blk-crypto both support. + */ + if (ufs_crypto_alg == UFS_CRYPTO_ALG_AES_XTS && + key_size == UFS_CRYPTO_KEY_SIZE_256) + return BLK_ENCRYPTION_MODE_AES_256_XTS; + + return BLK_ENCRYPTION_MODE_INVALID; +} + /** * ufshcd_hba_init_crypto - Read crypto capabilities, init crypto fields in hba * @hba: Per adapter instance @@ -308,6 +272,8 @@ int ufshcd_hba_init_crypto_spec(struct ufs_hba *hba, { int cap_idx = 0; int err = 0; + unsigned int crypto_modes_supported[BLK_ENCRYPTION_MODE_MAX]; + enum blk_crypto_mode_num blk_mode_num; /* Default to disabling crypto */ hba->caps &= ~UFSHCD_CAP_CRYPTO; @@ -336,16 +302,7 @@ int ufshcd_hba_init_crypto_spec(struct ufs_hba *hba, goto out; } - hba->crypto_cfgs = - devm_kcalloc(hba->dev, - NUM_KEYSLOTS(hba), - sizeof(hba->crypto_cfgs[0]), - GFP_KERNEL); - if (!hba->crypto_cfgs) { - err = -ENOMEM; - goto out_free_cfg_mem; - } - + memset(crypto_modes_supported, 0, sizeof(crypto_modes_supported)); /* * Store all the capabilities now so that we don't need to repeatedly * access the device each time we want to know its capabilities @@ -356,26 +313,35 @@ int ufshcd_hba_init_crypto_spec(struct ufs_hba *hba, cpu_to_le32(ufshcd_readl(hba, REG_UFS_CRYPTOCAP + cap_idx * sizeof(__le32))); + blk_mode_num = ufshcd_blk_crypto_mode_num_for_alg_dusize( + hba->crypto_cap_array[cap_idx].algorithm_id, + hba->crypto_cap_array[cap_idx].key_size); + if (blk_mode_num == BLK_ENCRYPTION_MODE_INVALID) + continue; + crypto_modes_supported[blk_mode_num] |= + hba->crypto_cap_array[cap_idx].sdus_mask * 512; } - hba->ksm = keyslot_manager_create(NUM_KEYSLOTS(hba), ksm_ops, hba); + ufshcd_clear_all_keyslots(hba); + + hba->ksm = keyslot_manager_create(ufshcd_num_keyslots(hba), ksm_ops, + crypto_modes_supported, hba); if (!hba->ksm) { err = -ENOMEM; - goto out_free_crypto_cfgs; + goto out_free_caps; } return 0; -out_free_crypto_cfgs: - devm_kfree(hba->dev, hba->crypto_cfgs); -out_free_cfg_mem: + +out_free_caps: devm_kfree(hba->dev, hba->crypto_cap_array); out: /* Indicate that init failed by setting crypto_capabilities to 0 */ hba->crypto_capabilities.reg_val = 0; return err; } -EXPORT_SYMBOL(ufshcd_hba_init_crypto_spec); +EXPORT_SYMBOL_GPL(ufshcd_hba_init_crypto_spec); void ufshcd_crypto_setup_rq_keyslot_manager_spec(struct ufs_hba *hba, struct request_queue *q) @@ -385,26 +351,26 @@ void ufshcd_crypto_setup_rq_keyslot_manager_spec(struct ufs_hba *hba, q->ksm = hba->ksm; } -EXPORT_SYMBOL(ufshcd_crypto_setup_rq_keyslot_manager_spec); +EXPORT_SYMBOL_GPL(ufshcd_crypto_setup_rq_keyslot_manager_spec); void ufshcd_crypto_destroy_rq_keyslot_manager_spec(struct ufs_hba *hba, struct request_queue *q) { keyslot_manager_destroy(hba->ksm); } -EXPORT_SYMBOL(ufshcd_crypto_destroy_rq_keyslot_manager_spec); +EXPORT_SYMBOL_GPL(ufshcd_crypto_destroy_rq_keyslot_manager_spec); int ufshcd_prepare_lrbp_crypto_spec(struct ufs_hba *hba, struct scsi_cmnd *cmd, struct ufshcd_lrb *lrbp) { - int key_slot; + struct bio_crypt_ctx *bc; - if (!cmd->request->bio || - !bio_crypt_should_process(cmd->request->bio, cmd->request->q)) { + if (!bio_crypt_should_process(cmd->request)) { lrbp->crypto_enable = false; return 0; } + bc = cmd->request->bio->bi_crypt_context; if (WARN_ON(!ufshcd_is_crypto_enabled(hba))) { /* @@ -413,17 +379,16 @@ int ufshcd_prepare_lrbp_crypto_spec(struct ufs_hba *hba, */ return -EINVAL; } - key_slot = bio_crypt_get_keyslot(cmd->request->bio); - if (!ufshcd_keyslot_valid(hba, key_slot)) + if (!ufshcd_keyslot_valid(hba, bc->bc_keyslot)) return -EINVAL; lrbp->crypto_enable = true; - lrbp->crypto_key_slot = key_slot; - lrbp->data_unit_num = bio_crypt_data_unit_num(cmd->request->bio); + lrbp->crypto_key_slot = bc->bc_keyslot; + lrbp->data_unit_num = bc->bc_dun[0]; return 0; } -EXPORT_SYMBOL(ufshcd_prepare_lrbp_crypto_spec); +EXPORT_SYMBOL_GPL(ufshcd_prepare_lrbp_crypto_spec); /* Crypto Variant Ops Support */ diff --git a/drivers/scsi/ufs/ufshcd-crypto.h b/drivers/scsi/ufs/ufshcd-crypto.h index 3c03d0e23e87..24a587c7a94e 100644 --- a/drivers/scsi/ufs/ufshcd-crypto.h +++ b/drivers/scsi/ufs/ufshcd-crypto.h @@ -11,7 +11,10 @@ #include "ufshcd.h" #include "ufshci.h" -#define NUM_KEYSLOTS(hba) (hba->crypto_capabilities.config_count + 1) +static inline int ufshcd_num_keyslots(struct ufs_hba *hba) +{ + return hba->crypto_capabilities.config_count + 1; +} static inline bool ufshcd_keyslot_valid(struct ufs_hba *hba, unsigned int slot) { @@ -19,7 +22,7 @@ static inline bool ufshcd_keyslot_valid(struct ufs_hba *hba, unsigned int slot) * The actual number of configurations supported is (CFGC+1), so slot * numbers range from 0 to config_count inclusive. */ - return slot < NUM_KEYSLOTS(hba); + return slot < ufshcd_num_keyslots(hba); } static inline bool ufshcd_hba_is_crypto_supported(struct ufs_hba *hba) @@ -51,6 +54,11 @@ void ufshcd_crypto_setup_rq_keyslot_manager_spec(struct ufs_hba *hba, void ufshcd_crypto_destroy_rq_keyslot_manager_spec(struct ufs_hba *hba, struct request_queue *q); +static inline bool ufshcd_lrbp_crypto_enabled(struct ufshcd_lrb *lrbp) +{ + return lrbp->crypto_enable; +} + /* Crypto Variant Ops Support */ void ufshcd_crypto_enable(struct ufs_hba *hba); @@ -118,10 +126,14 @@ static inline int ufshcd_prepare_lrbp_crypto(struct ufs_hba *hba, struct scsi_cmnd *cmd, struct ufshcd_lrb *lrbp) { - lrbp->crypto_enable = false; return 0; } +static inline bool ufshcd_lrbp_crypto_enabled(struct ufshcd_lrb *lrbp) +{ + return false; +} + static inline int ufshcd_complete_lrbp_crypto(struct ufs_hba *hba, struct scsi_cmnd *cmd, struct ufshcd_lrb *lrbp) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 935aef786fff..0f62b42d39ab 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -2248,13 +2248,15 @@ static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp, dword_0 |= UTP_REQ_DESC_INT_CMD; /* Transfer request descriptor header fields */ - if (lrbp->crypto_enable) { + if (ufshcd_lrbp_crypto_enabled(lrbp)) { +#if IS_ENABLED(CONFIG_SCSI_UFS_CRYPTO) dword_0 |= UTP_REQ_DESC_CRYPTO_ENABLE_CMD; dword_0 |= lrbp->crypto_key_slot; req_desc->header.dword_1 = - cpu_to_le32((u32)lrbp->data_unit_num); + cpu_to_le32(lower_32_bits(lrbp->data_unit_num)); req_desc->header.dword_3 = - cpu_to_le32((u32)(lrbp->data_unit_num >> 32)); + cpu_to_le32(upper_32_bits(lrbp->data_unit_num)); +#endif /* CONFIG_SCSI_UFS_CRYPTO */ } else { /* dword_1 and dword_3 are reserved, hence they are set to 0 */ req_desc->header.dword_1 = 0; @@ -2557,7 +2559,9 @@ static int ufshcd_compose_dev_cmd(struct ufs_hba *hba, lrbp->task_tag = tag; lrbp->lun = 0; /* device management cmd is not specific to any LUN */ lrbp->intr_cmd = true; /* No interrupt aggregation */ +#if IS_ENABLED(CONFIG_SCSI_UFS_CRYPTO) lrbp->crypto_enable = false; /* No crypto operations */ +#endif hba->dev_cmd.type = cmd_type; return ufshcd_comp_devman_upiu(hba, lrbp); diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 80f8315bc256..63e2fd0add2b 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -194,9 +194,11 @@ struct ufshcd_lrb { bool intr_cmd; ktime_t issue_time_stamp; ktime_t compl_time_stamp; +#if IS_ENABLED(CONFIG_SCSI_UFS_CRYPTO) bool crypto_enable; u8 crypto_key_slot; u64 data_unit_num; +#endif /* CONFIG_SCSI_UFS_CRYPTO */ bool req_abort_skip; }; @@ -532,7 +534,6 @@ struct ufs_stats { * @crypto_capabilities: Content of crypto capabilities register (0x100) * @crypto_cap_array: Array of crypto capabilities * @crypto_cfg_register: Start of the crypto cfg array - * @crypto_cfgs: Array of crypto configurations (i.e. config for each slot) * @ksm: the keyslot manager tied to this hba */ struct ufs_hba { @@ -760,7 +761,6 @@ struct ufs_hba { union ufs_crypto_capabilities crypto_capabilities; union ufs_crypto_cap_entry *crypto_cap_array; u32 crypto_cfg_register; - union ufs_crypto_cfg_entry *crypto_cfgs; struct keyslot_manager *ksm; #endif /* CONFIG_SCSI_UFS_CRYPTO */ }; diff --git a/fs/buffer.c b/fs/buffer.c index 88d222f7ee93..d32364efd39d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -3069,7 +3069,7 @@ static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh, */ bio = bio_alloc(GFP_NOIO, 1); - fscrypt_set_bio_crypt_ctx_bh(bio, bh, GFP_NOIO | __GFP_NOFAIL); + fscrypt_set_bio_crypt_ctx_bh(bio, bh, GFP_NOIO); if (wbc) { wbc_init_bio(wbc, bio); diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 9dcb57089f4d..f62375d39b0f 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c @@ -73,11 +73,8 @@ int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, err = -ENOMEM; goto errout; } - err = fscrypt_set_bio_crypt_ctx(bio, inode, lblk, GFP_NOIO); - if (err) { - bio_put(bio); - goto errout; - } + fscrypt_set_bio_crypt_ctx(bio, inode, lblk, GFP_NOIO); + bio_set_dev(bio, inode->i_sb->s_bdev); bio->bi_iter.bi_sector = pblk << (blockbits - 9); bio_set_op_attrs(bio, REQ_OP_WRITE, 0); diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index 6e6f39ea18a7..41b4fe15b4b6 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -96,7 +96,7 @@ int fscrypt_crypt_block(const struct inode *inode, fscrypt_direction_t rw, DECLARE_CRYPTO_WAIT(wait); struct scatterlist dst, src; struct fscrypt_info *ci = inode->i_crypt_info; - struct crypto_skcipher *tfm = ci->ci_ctfm; + struct crypto_skcipher *tfm = ci->ci_key.tfm; int res = 0; if (WARN_ON_ONCE(len <= 0)) diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index 3da3707c10e3..3aafddaab703 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -40,7 +40,7 @@ int fname_encrypt(struct inode *inode, const struct qstr *iname, struct skcipher_request *req = NULL; DECLARE_CRYPTO_WAIT(wait); struct fscrypt_info *ci = inode->i_crypt_info; - struct crypto_skcipher *tfm = ci->ci_ctfm; + struct crypto_skcipher *tfm = ci->ci_key.tfm; union fscrypt_iv iv; struct scatterlist sg; int res; @@ -93,7 +93,7 @@ static int fname_decrypt(struct inode *inode, DECLARE_CRYPTO_WAIT(wait); struct scatterlist src_sg, dst_sg; struct fscrypt_info *ci = inode->i_crypt_info; - struct crypto_skcipher *tfm = ci->ci_ctfm; + struct crypto_skcipher *tfm = ci->ci_key.tfm; union fscrypt_iv iv; int res; diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index c731bd4245c5..6aac05cf2348 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -15,8 +15,6 @@ #include #include -struct fscrypt_master_key; - #define CONST_STRLEN(str) (sizeof(str) - 1) #define FS_KEY_DERIVATION_NONCE_SIZE 16 @@ -154,6 +152,20 @@ struct fscrypt_symlink_data { char encrypted_path[1]; } __packed; +/** + * struct fscrypt_prepared_key - a key prepared for actual encryption/decryption + * @tfm: crypto API transform object + * @blk_key: key for blk-crypto + * + * Normally only one of the fields will be non-NULL. + */ +struct fscrypt_prepared_key { + struct crypto_skcipher *tfm; +#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT + struct fscrypt_blk_crypto_key *blk_key; +#endif +}; + /* * fscrypt_info - the "encryption key" for an inode * @@ -163,20 +175,20 @@ struct fscrypt_symlink_data { */ struct fscrypt_info { - /* The actual crypto transform used for encryption and decryption */ - struct crypto_skcipher *ci_ctfm; - -#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT - /* - * The raw key for inline encryption, if this file is using inline - * encryption rather than the traditional filesystem layer encryption. - */ - const u8 *ci_inline_crypt_key; -#endif + /* The key in a form prepared for actual encryption/decryption */ + struct fscrypt_prepared_key ci_key; /* True if the key should be freed when this fscrypt_info is freed */ bool ci_owns_key; +#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT + /* + * True if this inode will use inline encryption (blk-crypto) instead of + * the traditional filesystem-layer encryption. + */ + bool ci_inlinecrypt; +#endif + /* * Encryption mode used for this inode. It corresponds to either the * contents or filenames encryption mode, depending on the inode type. @@ -201,7 +213,7 @@ struct fscrypt_info { /* * If non-NULL, then encryption is done using the master key directly - * and ci_ctfm will equal ci_direct_key->dk_ctfm. + * and ci_key will equal ci_direct_key->dk_key. */ struct fscrypt_direct_key *ci_direct_key; @@ -265,6 +277,7 @@ union fscrypt_iv { u8 nonce[FS_KEY_DERIVATION_NONCE_SIZE]; }; u8 raw[FSCRYPT_MAX_IV_SIZE]; + __le64 dun[FSCRYPT_MAX_IV_SIZE / sizeof(__le64)]; }; void fscrypt_generate_iv(union fscrypt_iv *iv, u64 lblk_num, @@ -306,49 +319,71 @@ extern void fscrypt_destroy_hkdf(struct fscrypt_hkdf *hkdf); /* inline_crypt.c */ #ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT -extern bool fscrypt_should_use_inline_encryption(const struct fscrypt_info *ci); +extern void fscrypt_select_encryption_impl(struct fscrypt_info *ci); -extern int fscrypt_set_inline_crypt_key(struct fscrypt_info *ci, - const u8 *derived_key); +static inline bool +fscrypt_using_inline_encryption(const struct fscrypt_info *ci) +{ + return ci->ci_inlinecrypt; +} -extern void fscrypt_free_inline_crypt_key(struct fscrypt_info *ci); +extern int fscrypt_prepare_inline_crypt_key( + struct fscrypt_prepared_key *prep_key, + const u8 *raw_key, + const struct fscrypt_info *ci); -extern int fscrypt_setup_per_mode_inline_crypt_key( - struct fscrypt_info *ci, - struct fscrypt_master_key *mk); +extern void fscrypt_destroy_inline_crypt_key( + struct fscrypt_prepared_key *prep_key); -extern void fscrypt_evict_inline_crypt_keys(struct fscrypt_master_key *mk); +/* + * Check whether the crypto transform or blk-crypto key has been allocated in + * @prep_key, depending on which encryption implementation the file will use. + */ +static inline bool +fscrypt_is_key_prepared(struct fscrypt_prepared_key *prep_key, + const struct fscrypt_info *ci) +{ + /* + * The READ_ONCE() here pairs with the smp_store_release() in + * fscrypt_prepare_key(). (This only matters for the per-mode keys, + * which are shared by multiple inodes.) + */ + if (fscrypt_using_inline_encryption(ci)) + return READ_ONCE(prep_key->blk_key) != NULL; + return READ_ONCE(prep_key->tfm) != NULL; +} #else /* CONFIG_FS_ENCRYPTION_INLINE_CRYPT */ -static inline bool fscrypt_should_use_inline_encryption( +static inline void fscrypt_select_encryption_impl(struct fscrypt_info *ci) +{ +} + +static inline bool fscrypt_using_inline_encryption( const struct fscrypt_info *ci) { return false; } -static inline int fscrypt_set_inline_crypt_key(struct fscrypt_info *ci, - const u8 *derived_key) +static inline int +fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key, + const u8 *raw_key, + const struct fscrypt_info *ci) { WARN_ON(1); return -EOPNOTSUPP; } -static inline void fscrypt_free_inline_crypt_key(struct fscrypt_info *ci) +static inline void +fscrypt_destroy_inline_crypt_key(struct fscrypt_prepared_key *prep_key) { } -static inline int fscrypt_setup_per_mode_inline_crypt_key( - struct fscrypt_info *ci, - struct fscrypt_master_key *mk) -{ - WARN_ON(1); - return -EOPNOTSUPP; -} - -static inline void fscrypt_evict_inline_crypt_keys( - struct fscrypt_master_key *mk) +static inline bool +fscrypt_is_key_prepared(struct fscrypt_prepared_key *prep_key, + const struct fscrypt_info *ci) { + return READ_ONCE(prep_key->tfm) != NULL; } #endif /* !CONFIG_FS_ENCRYPTION_INLINE_CRYPT */ @@ -441,25 +476,12 @@ struct fscrypt_master_key { struct list_head mk_decrypted_inodes; spinlock_t mk_decrypted_inodes_lock; - /* Crypto API transforms for DIRECT_KEY policies, allocated on-demand */ - struct crypto_skcipher *mk_direct_tfms[__FSCRYPT_MODE_MAX + 1]; + /* Per-mode keys for DIRECT_KEY policies, allocated on-demand */ + struct fscrypt_prepared_key mk_direct_keys[__FSCRYPT_MODE_MAX + 1]; - /* - * Crypto API transforms for filesystem-layer implementation of - * IV_INO_LBLK_64 policies, allocated on-demand. - */ - struct crypto_skcipher *mk_iv_ino_lblk_64_tfms[__FSCRYPT_MODE_MAX + 1]; + /* Per-mode keys for IV_INO_LBLK_64 policies, allocated on-demand */ + struct fscrypt_prepared_key mk_iv_ino_lblk_64_keys[__FSCRYPT_MODE_MAX + 1]; -#ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT - /* Raw keys for IV_INO_LBLK_64 policies, allocated on-demand */ - u8 *mk_iv_ino_lblk_64_raw_keys[__FSCRYPT_MODE_MAX + 1]; - - /* The data unit size being used for inline encryption */ - unsigned int mk_data_unit_size; - - /* The filesystem's block device */ - struct block_device *mk_bdev; -#endif } __randomize_layout; static inline bool @@ -514,8 +536,8 @@ struct fscrypt_mode { const char *cipher_str; int keysize; int ivsize; - enum blk_crypto_mode_num blk_crypto_mode; bool logged_impl_name; + enum blk_crypto_mode_num blk_crypto_mode; }; extern struct fscrypt_mode fscrypt_modes[]; @@ -526,9 +548,11 @@ fscrypt_mode_supports_direct_key(const struct fscrypt_mode *mode) return mode->ivsize >= offsetofend(union fscrypt_iv, nonce); } -extern struct crypto_skcipher * -fscrypt_allocate_skcipher(struct fscrypt_mode *mode, const u8 *raw_key, - const struct inode *inode); +extern int fscrypt_prepare_key(struct fscrypt_prepared_key *prep_key, + const u8 *raw_key, + const struct fscrypt_info *ci); + +extern void fscrypt_destroy_prepared_key(struct fscrypt_prepared_key *prep_key); extern int fscrypt_set_derived_key(struct fscrypt_info *ci, const u8 *derived_key); diff --git a/fs/crypto/inline_crypt.c b/fs/crypto/inline_crypt.c index e41c6d66ff0d..aa04e8a7d674 100644 --- a/fs/crypto/inline_crypt.c +++ b/fs/crypto/inline_crypt.c @@ -15,187 +15,126 @@ #include #include #include -#include #include "fscrypt_private.h" -/* Return true iff inline encryption should be used for this file */ -bool fscrypt_should_use_inline_encryption(const struct fscrypt_info *ci) +struct fscrypt_blk_crypto_key { + struct blk_crypto_key base; + int num_devs; + struct request_queue *devs[]; +}; + +/* Enable inline encryption for this file if supported. */ +void fscrypt_select_encryption_impl(struct fscrypt_info *ci) { const struct inode *inode = ci->ci_inode; struct super_block *sb = inode->i_sb; /* The file must need contents encryption, not filenames encryption */ if (!S_ISREG(inode->i_mode)) - return false; + return; /* blk-crypto must implement the needed encryption algorithm */ if (ci->ci_mode->blk_crypto_mode == BLK_ENCRYPTION_MODE_INVALID) - return false; - - /* DIRECT_KEY needs a 24+ byte IV, so it can't work with 8-byte DUNs */ - if (fscrypt_is_direct_key_policy(&ci->ci_policy)) - return false; + return; /* The filesystem must be mounted with -o inlinecrypt */ if (!sb->s_cop->inline_crypt_enabled || !sb->s_cop->inline_crypt_enabled(sb)) - return false; + return; - return true; + ci->ci_inlinecrypt = true; } -/* Set a per-file inline encryption key (for passing to blk-crypto) */ -int fscrypt_set_inline_crypt_key(struct fscrypt_info *ci, const u8 *derived_key) +int fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key, + const u8 *raw_key, + const struct fscrypt_info *ci) { - const struct fscrypt_mode *mode = ci->ci_mode; - const struct super_block *sb = ci->ci_inode->i_sb; - - ci->ci_inline_crypt_key = kmemdup(derived_key, mode->keysize, GFP_NOFS); - if (!ci->ci_inline_crypt_key) - return -ENOMEM; - ci->ci_owns_key = true; - - return blk_crypto_start_using_mode(mode->blk_crypto_mode, - sb->s_blocksize, - sb->s_bdev->bd_queue); -} - -/* Free a per-file inline encryption key and evict it from blk-crypto */ -void fscrypt_free_inline_crypt_key(struct fscrypt_info *ci) -{ - if (ci->ci_inline_crypt_key != NULL) { - const struct fscrypt_mode *mode = ci->ci_mode; - const struct super_block *sb = ci->ci_inode->i_sb; - - blk_crypto_evict_key(sb->s_bdev->bd_queue, - ci->ci_inline_crypt_key, - mode->blk_crypto_mode, sb->s_blocksize); - kzfree(ci->ci_inline_crypt_key); - } -} - -/* - * Set up ->inline_crypt_key (for passing to blk-crypto) for inodes which use an - * IV_INO_LBLK_64 encryption policy. - * - * Return: 0 on success, -errno on failure - */ -int fscrypt_setup_per_mode_inline_crypt_key(struct fscrypt_info *ci, - struct fscrypt_master_key *mk) -{ - static DEFINE_MUTEX(inline_crypt_setup_mutex); - const struct super_block *sb = ci->ci_inode->i_sb; - struct block_device *bdev = sb->s_bdev; - const struct fscrypt_mode *mode = ci->ci_mode; - const u8 mode_num = mode - fscrypt_modes; - u8 *raw_key; - u8 hkdf_info[sizeof(mode_num) + sizeof(sb->s_uuid)]; + const struct inode *inode = ci->ci_inode; + struct super_block *sb = inode->i_sb; + enum blk_crypto_mode_num crypto_mode = ci->ci_mode->blk_crypto_mode; + int num_devs = 1; + int queue_refs = 0; + struct fscrypt_blk_crypto_key *blk_key; int err; + int i; - if (WARN_ON(mode_num > __FSCRYPT_MODE_MAX)) + if (sb->s_cop->get_num_devices) + num_devs = sb->s_cop->get_num_devices(sb); + if (WARN_ON(num_devs < 1)) return -EINVAL; - /* pairs with smp_store_release() below */ - raw_key = smp_load_acquire(&mk->mk_iv_ino_lblk_64_raw_keys[mode_num]); - if (raw_key) { - err = 0; - goto out; + blk_key = kzalloc(struct_size(blk_key, devs, num_devs), GFP_NOFS); + if (!blk_key) + return -ENOMEM; + + blk_key->num_devs = num_devs; + if (num_devs == 1) + blk_key->devs[0] = bdev_get_queue(sb->s_bdev); + else + sb->s_cop->get_devices(sb, blk_key->devs); + + err = blk_crypto_init_key(&blk_key->base, raw_key, crypto_mode, + sb->s_blocksize); + if (err) { + fscrypt_err(inode, "error %d initializing blk-crypto key", err); + goto fail; } - mutex_lock(&inline_crypt_setup_mutex); - - raw_key = mk->mk_iv_ino_lblk_64_raw_keys[mode_num]; - if (raw_key) { - err = 0; - goto out_unlock; - } - - raw_key = kmalloc(mode->keysize, GFP_NOFS); - if (!raw_key) { - err = -ENOMEM; - goto out_unlock; - } - - BUILD_BUG_ON(sizeof(mode_num) != 1); - BUILD_BUG_ON(sizeof(sb->s_uuid) != 16); - BUILD_BUG_ON(sizeof(hkdf_info) != 17); - hkdf_info[0] = mode_num; - memcpy(&hkdf_info[1], &sb->s_uuid, sizeof(sb->s_uuid)); - - err = fscrypt_hkdf_expand(&mk->mk_secret.hkdf, - HKDF_CONTEXT_IV_INO_LBLK_64_KEY, - hkdf_info, sizeof(hkdf_info), - raw_key, mode->keysize); - if (err) - goto out_unlock; - - err = blk_crypto_start_using_mode(mode->blk_crypto_mode, - sb->s_blocksize, bdev->bd_queue); - if (err) - goto out_unlock; - /* - * When a master key's first inline encryption key is set up, save a - * reference to the filesystem's block device so that the inline - * encryption keys can be evicted when the master key is destroyed. + * We have to start using blk-crypto on all the filesystem's devices. + * We also have to save all the request_queue's for later so that the + * key can be evicted from them. This is needed because some keys + * aren't destroyed until after the filesystem was already unmounted + * (namely, the per-mode keys in struct fscrypt_master_key). */ - if (!mk->mk_bdev) { - mk->mk_bdev = bdgrab(bdev); - mk->mk_data_unit_size = sb->s_blocksize; - } + for (i = 0; i < num_devs; i++) { + if (!blk_get_queue(blk_key->devs[i])) { + fscrypt_err(inode, "couldn't get request_queue"); + err = -EAGAIN; + goto fail; + } + queue_refs++; - /* pairs with smp_load_acquire() above */ - smp_store_release(&mk->mk_iv_ino_lblk_64_raw_keys[mode_num], raw_key); - err = 0; -out_unlock: - mutex_unlock(&inline_crypt_setup_mutex); -out: - if (err == 0) { - ci->ci_inline_crypt_key = raw_key; - /* - * Since each struct fscrypt_master_key belongs to a particular - * filesystem (a struct super_block), there should be only one - * block device, and only one data unit size as it should equal - * the filesystem's blocksize (i.e. s_blocksize). - */ - if (WARN_ON(mk->mk_bdev != bdev)) - err = -EINVAL; - if (WARN_ON(mk->mk_data_unit_size != sb->s_blocksize)) - err = -EINVAL; - } else { - kzfree(raw_key); + err = blk_crypto_start_using_mode(crypto_mode, sb->s_blocksize, + blk_key->devs[i]); + if (err) { + fscrypt_err(inode, + "error %d starting to use blk-crypto", err); + goto fail; + } } + /* + * Pairs with READ_ONCE() in fscrypt_is_key_prepared(). (Only matters + * for the per-mode keys, which are shared by multiple inodes.) + */ + smp_store_release(&prep_key->blk_key, blk_key); + return 0; + +fail: + for (i = 0; i < queue_refs; i++) + blk_put_queue(blk_key->devs[i]); + kzfree(blk_key); return err; } -/* - * Evict per-mode inline encryption keys from blk-crypto when a master key is - * destroyed. - */ -void fscrypt_evict_inline_crypt_keys(struct fscrypt_master_key *mk) +void fscrypt_destroy_inline_crypt_key(struct fscrypt_prepared_key *prep_key) { - struct block_device *bdev = mk->mk_bdev; - size_t i; + struct fscrypt_blk_crypto_key *blk_key = prep_key->blk_key; + int i; - if (!bdev) /* No inline encryption keys? */ - return; - - for (i = 0; i < ARRAY_SIZE(mk->mk_iv_ino_lblk_64_raw_keys); i++) { - u8 *raw_key = mk->mk_iv_ino_lblk_64_raw_keys[i]; - - if (raw_key != NULL) { - blk_crypto_evict_key(bdev->bd_queue, raw_key, - fscrypt_modes[i].blk_crypto_mode, - mk->mk_data_unit_size); - kzfree(raw_key); + if (blk_key) { + for (i = 0; i < blk_key->num_devs; i++) { + blk_crypto_evict_key(blk_key->devs[i], &blk_key->base); + blk_put_queue(blk_key->devs[i]); } + kzfree(blk_key); } - bdput(bdev); } /** - * fscrypt_inode_uses_inline_crypto - test whether an inode uses inline encryption + * fscrypt_inode_uses_inline_crypto - test whether an inode uses inline + * encryption * @inode: an inode * * Return: true if the inode requires file contents encryption and if the @@ -205,12 +144,13 @@ void fscrypt_evict_inline_crypt_keys(struct fscrypt_master_key *mk) bool fscrypt_inode_uses_inline_crypto(const struct inode *inode) { return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode) && - inode->i_crypt_info->ci_inline_crypt_key != NULL; + inode->i_crypt_info->ci_inlinecrypt; } EXPORT_SYMBOL_GPL(fscrypt_inode_uses_inline_crypto); /** - * fscrypt_inode_uses_fs_layer_crypto - test whether an inode uses fs-layer encryption + * fscrypt_inode_uses_fs_layer_crypto - test whether an inode uses fs-layer + * encryption * @inode: an inode * * Return: true if the inode requires file contents encryption and if the @@ -220,22 +160,22 @@ EXPORT_SYMBOL_GPL(fscrypt_inode_uses_inline_crypto); bool fscrypt_inode_uses_fs_layer_crypto(const struct inode *inode) { return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode) && - inode->i_crypt_info->ci_inline_crypt_key == NULL; + !inode->i_crypt_info->ci_inlinecrypt; } EXPORT_SYMBOL_GPL(fscrypt_inode_uses_fs_layer_crypto); -static inline u64 fscrypt_generate_dun(const struct fscrypt_info *ci, - u64 lblk_num) +static void fscrypt_generate_dun(const struct fscrypt_info *ci, u64 lblk_num, + u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE]) { union fscrypt_iv iv; + int i; fscrypt_generate_iv(&iv, lblk_num, ci); - /* - * fscrypt_should_use_inline_encryption() ensures we never get here if - * more than the first 8 bytes of the IV are nonzero. - */ - BUG_ON(memchr_inv(&iv.raw[8], 0, ci->ci_mode->ivsize - 8)); - return le64_to_cpu(iv.lblk_num); + + BUILD_BUG_ON(FSCRYPT_MAX_IV_SIZE > BLK_CRYPTO_MAX_IV_SIZE); + memset(dun, 0, BLK_CRYPTO_MAX_IV_SIZE); + for (i = 0; i < ci->ci_mode->ivsize/sizeof(dun[0]); i++) + dun[i] = le64_to_cpu(iv.dun[i]); } /** @@ -243,7 +183,8 @@ static inline u64 fscrypt_generate_dun(const struct fscrypt_info *ci, * @bio: a bio which will eventually be submitted to the file * @inode: the file's inode * @first_lblk: the first file logical block number in the I/O - * @gfp_mask: memory allocation flags + * @gfp_mask: memory allocation flags - these must be a waiting mask so that + * bio_crypt_set_ctx can't fail. * * If the contents of the file should be encrypted (or decrypted) with inline * encryption, then assign the appropriate encryption context to the bio. @@ -252,24 +193,18 @@ static inline u64 fscrypt_generate_dun(const struct fscrypt_info *ci, * otherwise fscrypt_mergeable_bio() won't work as intended. * * The encryption context will be freed automatically when the bio is freed. - * - * Return: 0 on success, -errno on failure. If __GFP_NOFAIL is specified, this - * is guaranteed to succeed. */ -int fscrypt_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode, - u64 first_lblk, gfp_t gfp_mask) +void fscrypt_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode, + u64 first_lblk, gfp_t gfp_mask) { const struct fscrypt_info *ci = inode->i_crypt_info; - u64 dun; + u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE]; if (!fscrypt_inode_uses_inline_crypto(inode)) - return 0; + return; - dun = fscrypt_generate_dun(ci, first_lblk); - - return bio_crypt_set_ctx(bio, ci->ci_inline_crypt_key, - ci->ci_mode->blk_crypto_mode, - dun, inode->i_blkbits, gfp_mask); + fscrypt_generate_dun(ci, first_lblk, dun); + bio_crypt_set_ctx(bio, &ci->ci_key.blk_key->base, dun, gfp_mask); } EXPORT_SYMBOL_GPL(fscrypt_set_bio_crypt_ctx); @@ -298,27 +233,24 @@ static bool bh_get_inode_and_lblk_num(const struct buffer_head *bh, } /** - * fscrypt_set_bio_crypt_ctx_bh - prepare a file contents bio for inline encryption + * fscrypt_set_bio_crypt_ctx_bh - prepare a file contents bio for inline + * encryption * @bio: a bio which will eventually be submitted to the file * @first_bh: the first buffer_head for which I/O will be submitted * @gfp_mask: memory allocation flags * * Same as fscrypt_set_bio_crypt_ctx(), except this takes a buffer_head instead * of an inode and block number directly. - * - * Return: 0 on success, -errno on failure */ -int fscrypt_set_bio_crypt_ctx_bh(struct bio *bio, +void fscrypt_set_bio_crypt_ctx_bh(struct bio *bio, const struct buffer_head *first_bh, gfp_t gfp_mask) { const struct inode *inode; u64 first_lblk; - if (!bh_get_inode_and_lblk_num(first_bh, &inode, &first_lblk)) - return 0; - - return fscrypt_set_bio_crypt_ctx(bio, inode, first_lblk, gfp_mask); + if (bh_get_inode_and_lblk_num(first_bh, &inode, &first_lblk)) + fscrypt_set_bio_crypt_ctx(bio, inode, first_lblk, gfp_mask); } EXPORT_SYMBOL_GPL(fscrypt_set_bio_crypt_ctx_bh); @@ -342,27 +274,24 @@ EXPORT_SYMBOL_GPL(fscrypt_set_bio_crypt_ctx_bh); bool fscrypt_mergeable_bio(struct bio *bio, const struct inode *inode, u64 next_lblk) { - const struct bio_crypt_ctx *bc; - const u8 *next_key; - u64 next_dun; + const struct bio_crypt_ctx *bc = bio->bi_crypt_context; + u64 next_dun[BLK_CRYPTO_DUN_ARRAY_SIZE]; - if (bio_has_crypt_ctx(bio) != fscrypt_inode_uses_inline_crypto(inode)) + if (!!bc != fscrypt_inode_uses_inline_crypto(inode)) return false; - if (!bio_has_crypt_ctx(bio)) + if (!bc) return true; - bc = bio->bi_crypt_context; - next_key = inode->i_crypt_info->ci_inline_crypt_key; - next_dun = fscrypt_generate_dun(inode->i_crypt_info, next_lblk); /* * Comparing the key pointers is good enough, as all I/O for each key * uses the same pointer. I.e., there's currently no need to support * merging requests where the keys are the same but the pointers differ. */ - return next_key == bc->raw_key && - next_dun == bc->data_unit_num + - (bio_sectors(bio) >> - (bc->data_unit_size_bits - SECTOR_SHIFT)); + if (bc->bc_key != &inode->i_crypt_info->ci_key.blk_key->base) + return false; + + fscrypt_generate_dun(inode->i_crypt_info, next_lblk, next_dun); + return bio_crypt_dun_is_contiguous(bc, bio->bi_iter.bi_size, next_dun); } EXPORT_SYMBOL_GPL(fscrypt_mergeable_bio); @@ -383,7 +312,7 @@ bool fscrypt_mergeable_bio_bh(struct bio *bio, u64 next_lblk; if (!bh_get_inode_and_lblk_num(next_bh, &inode, &next_lblk)) - return !bio_has_crypt_ctx(bio); + return !bio->bi_crypt_context; return fscrypt_mergeable_bio(bio, inode, next_lblk); } diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c index 48d3a0c9a415..9052197d8f5a 100644 --- a/fs/crypto/keyring.c +++ b/fs/crypto/keyring.c @@ -44,12 +44,10 @@ static void free_master_key(struct fscrypt_master_key *mk) wipe_master_key_secret(&mk->mk_secret); for (i = 0; i <= __FSCRYPT_MODE_MAX; i++) { - crypto_free_skcipher(mk->mk_direct_tfms[i]); - crypto_free_skcipher(mk->mk_iv_ino_lblk_64_tfms[i]); + fscrypt_destroy_prepared_key(&mk->mk_direct_keys[i]); + fscrypt_destroy_prepared_key(&mk->mk_iv_ino_lblk_64_keys[i]); } - fscrypt_evict_inline_crypt_keys(mk); - key_put(mk->mk_users); kzfree(mk); } diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c index 3734ccca4f7a..5a5a6c39c442 100644 --- a/fs/crypto/keysetup.c +++ b/fs/crypto/keysetup.c @@ -32,6 +32,7 @@ struct fscrypt_mode fscrypt_modes[] = { .cipher_str = "essiv(cbc(aes),sha256)", .keysize = 16, .ivsize = 16, + .blk_crypto_mode = BLK_ENCRYPTION_MODE_AES_128_CBC_ESSIV, }, [FSCRYPT_MODE_AES_128_CTS] = { .friendly_name = "AES-128-CTS-CBC", @@ -44,6 +45,7 @@ struct fscrypt_mode fscrypt_modes[] = { .cipher_str = "adiantum(xchacha12,aes)", .keysize = 32, .ivsize = 32, + .blk_crypto_mode = BLK_ENCRYPTION_MODE_ADIANTUM, }, }; @@ -63,9 +65,9 @@ select_encryption_mode(const union fscrypt_policy *policy, } /* Create a symmetric cipher object for the given encryption mode and key */ -struct crypto_skcipher *fscrypt_allocate_skcipher(struct fscrypt_mode *mode, - const u8 *raw_key, - const struct inode *inode) +static struct crypto_skcipher * +fscrypt_allocate_skcipher(struct fscrypt_mode *mode, const u8 *raw_key, + const struct inode *inode) { struct crypto_skcipher *tfm; int err; @@ -107,33 +109,55 @@ struct crypto_skcipher *fscrypt_allocate_skcipher(struct fscrypt_mode *mode, return ERR_PTR(err); } -/* Given the per-file key, set up the file's crypto transform object */ -int fscrypt_set_derived_key(struct fscrypt_info *ci, const u8 *derived_key) +/* + * Prepare the crypto transform object or blk-crypto key in @prep_key, given the + * raw key, encryption mode, and flag indicating which encryption implementation + * (fs-layer or blk-crypto) will be used. + */ +int fscrypt_prepare_key(struct fscrypt_prepared_key *prep_key, + const u8 *raw_key, const struct fscrypt_info *ci) { struct crypto_skcipher *tfm; - if (fscrypt_should_use_inline_encryption(ci)) - return fscrypt_set_inline_crypt_key(ci, derived_key); + if (fscrypt_using_inline_encryption(ci)) + return fscrypt_prepare_inline_crypt_key(prep_key, raw_key, ci); - tfm = fscrypt_allocate_skcipher(ci->ci_mode, derived_key, ci->ci_inode); + tfm = fscrypt_allocate_skcipher(ci->ci_mode, raw_key, ci->ci_inode); if (IS_ERR(tfm)) return PTR_ERR(tfm); - - ci->ci_ctfm = tfm; - ci->ci_owns_key = true; + /* + * Pairs with READ_ONCE() in fscrypt_is_key_prepared(). (Only matters + * for the per-mode keys, which are shared by multiple inodes.) + */ + smp_store_release(&prep_key->tfm, tfm); return 0; } +/* Destroy a crypto transform object and/or blk-crypto key. */ +void fscrypt_destroy_prepared_key(struct fscrypt_prepared_key *prep_key) +{ + crypto_free_skcipher(prep_key->tfm); + fscrypt_destroy_inline_crypt_key(prep_key); +} + +/* Given the per-file key, set up the file's crypto transform object */ +int fscrypt_set_derived_key(struct fscrypt_info *ci, const u8 *derived_key) +{ + ci->ci_owns_key = true; + return fscrypt_prepare_key(&ci->ci_key, derived_key, ci); +} + static int setup_per_mode_key(struct fscrypt_info *ci, struct fscrypt_master_key *mk, - struct crypto_skcipher **tfms, + struct fscrypt_prepared_key *keys, u8 hkdf_context, bool include_fs_uuid) { + static DEFINE_MUTEX(mode_key_setup_mutex); const struct inode *inode = ci->ci_inode; const struct super_block *sb = inode->i_sb; struct fscrypt_mode *mode = ci->ci_mode; const u8 mode_num = mode - fscrypt_modes; - struct crypto_skcipher *tfm, *prev_tfm; + struct fscrypt_prepared_key *prep_key; u8 mode_key[FSCRYPT_MAX_KEY_SIZE]; u8 hkdf_info[sizeof(mode_num) + sizeof(sb->s_uuid)]; unsigned int hkdf_infolen = 0; @@ -142,10 +166,16 @@ static int setup_per_mode_key(struct fscrypt_info *ci, if (WARN_ON(mode_num > __FSCRYPT_MODE_MAX)) return -EINVAL; - /* pairs with cmpxchg() below */ - tfm = READ_ONCE(tfms[mode_num]); - if (likely(tfm != NULL)) - goto done; + prep_key = &keys[mode_num]; + if (fscrypt_is_key_prepared(prep_key, ci)) { + ci->ci_key = *prep_key; + return 0; + } + + mutex_lock(&mode_key_setup_mutex); + + if (fscrypt_is_key_prepared(prep_key, ci)) + goto done_unlock; BUILD_BUG_ON(sizeof(mode_num) != 1); BUILD_BUG_ON(sizeof(sb->s_uuid) != 16); @@ -160,21 +190,17 @@ static int setup_per_mode_key(struct fscrypt_info *ci, hkdf_context, hkdf_info, hkdf_infolen, mode_key, mode->keysize); if (err) - return err; - tfm = fscrypt_allocate_skcipher(mode, mode_key, inode); + goto out_unlock; + err = fscrypt_prepare_key(prep_key, mode_key, ci); memzero_explicit(mode_key, mode->keysize); - if (IS_ERR(tfm)) - return PTR_ERR(tfm); - - /* pairs with READ_ONCE() above */ - prev_tfm = cmpxchg(&tfms[mode_num], NULL, tfm); - if (prev_tfm != NULL) { - crypto_free_skcipher(tfm); - tfm = prev_tfm; - } -done: - ci->ci_ctfm = tfm; - return 0; + if (err) + goto out_unlock; +done_unlock: + ci->ci_key = *prep_key; + err = 0; +out_unlock: + mutex_unlock(&mode_key_setup_mutex); + return err; } static int fscrypt_setup_v2_file_key(struct fscrypt_info *ci, @@ -198,7 +224,7 @@ static int fscrypt_setup_v2_file_key(struct fscrypt_info *ci, ci->ci_mode->friendly_name); return -EINVAL; } - return setup_per_mode_key(ci, mk, mk->mk_direct_tfms, + return setup_per_mode_key(ci, mk, mk->mk_direct_keys, HKDF_CONTEXT_DIRECT_KEY, false); } else if (ci->ci_policy.v2.flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64) { @@ -208,9 +234,7 @@ static int fscrypt_setup_v2_file_key(struct fscrypt_info *ci, * the IVs. This format is optimized for use with inline * encryption hardware compliant with the UFS or eMMC standards. */ - if (fscrypt_should_use_inline_encryption(ci)) - return fscrypt_setup_per_mode_inline_crypt_key(ci, mk); - return setup_per_mode_key(ci, mk, mk->mk_iv_ino_lblk_64_tfms, + return setup_per_mode_key(ci, mk, mk->mk_iv_ino_lblk_64_keys, HKDF_CONTEXT_IV_INO_LBLK_64_KEY, true); } @@ -245,6 +269,8 @@ static int setup_file_encryption_key(struct fscrypt_info *ci, struct fscrypt_key_specifier mk_spec; int err; + fscrypt_select_encryption_impl(ci); + switch (ci->ci_policy.version) { case FSCRYPT_POLICY_V1: mk_spec.type = FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR; @@ -336,10 +362,8 @@ static void put_crypt_info(struct fscrypt_info *ci) if (ci->ci_direct_key) fscrypt_put_direct_key(ci->ci_direct_key); - else if (ci->ci_owns_key) { - crypto_free_skcipher(ci->ci_ctfm); - fscrypt_free_inline_crypt_key(ci); - } + else if (ci->ci_owns_key) + fscrypt_destroy_prepared_key(&ci->ci_key); key = ci->ci_master_key; if (key) { diff --git a/fs/crypto/keysetup_v1.c b/fs/crypto/keysetup_v1.c index 454fb03fc30e..8cafdbf47002 100644 --- a/fs/crypto/keysetup_v1.c +++ b/fs/crypto/keysetup_v1.c @@ -146,7 +146,7 @@ struct fscrypt_direct_key { struct hlist_node dk_node; refcount_t dk_refcount; const struct fscrypt_mode *dk_mode; - struct crypto_skcipher *dk_ctfm; + struct fscrypt_prepared_key dk_key; u8 dk_descriptor[FSCRYPT_KEY_DESCRIPTOR_SIZE]; u8 dk_raw[FSCRYPT_MAX_KEY_SIZE]; }; @@ -154,7 +154,7 @@ struct fscrypt_direct_key { static void free_direct_key(struct fscrypt_direct_key *dk) { if (dk) { - crypto_free_skcipher(dk->dk_ctfm); + fscrypt_destroy_prepared_key(&dk->dk_key); kzfree(dk); } } @@ -199,6 +199,8 @@ find_or_insert_direct_key(struct fscrypt_direct_key *to_insert, continue; if (ci->ci_mode != dk->dk_mode) continue; + if (!fscrypt_is_key_prepared(&dk->dk_key, ci)) + continue; if (crypto_memneq(raw_key, dk->dk_raw, ci->ci_mode->keysize)) continue; /* using existing tfm with same (descriptor, mode, raw_key) */ @@ -231,13 +233,9 @@ fscrypt_get_direct_key(const struct fscrypt_info *ci, const u8 *raw_key) return ERR_PTR(-ENOMEM); refcount_set(&dk->dk_refcount, 1); dk->dk_mode = ci->ci_mode; - dk->dk_ctfm = fscrypt_allocate_skcipher(ci->ci_mode, raw_key, - ci->ci_inode); - if (IS_ERR(dk->dk_ctfm)) { - err = PTR_ERR(dk->dk_ctfm); - dk->dk_ctfm = NULL; + err = fscrypt_prepare_key(&dk->dk_key, raw_key, ci); + if (err) goto err_free_dk; - } memcpy(dk->dk_descriptor, ci->ci_policy.v1.master_key_descriptor, FSCRYPT_KEY_DESCRIPTOR_SIZE); memcpy(dk->dk_raw, raw_key, ci->ci_mode->keysize); @@ -274,7 +272,7 @@ static int setup_v1_file_key_direct(struct fscrypt_info *ci, if (IS_ERR(dk)) return PTR_ERR(dk); ci->ci_direct_key = dk; - ci->ci_ctfm = dk->dk_ctfm; + ci->ci_key = dk->dk_key; return 0; } diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index 9d547bace7f2..18509ea3d7c7 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -362,16 +362,11 @@ static int io_submit_init_bio(struct ext4_io_submit *io, struct buffer_head *bh) { struct bio *bio; - int err; bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES); if (!bio) return -ENOMEM; - err = fscrypt_set_bio_crypt_ctx_bh(bio, bh, GFP_NOIO); - if (err) { - bio_put(bio); - return err; - } + fscrypt_set_bio_crypt_ctx_bh(bio, bh, GFP_NOIO); wbc_init_bio(io->io_wbc, bio); bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); bio_set_dev(bio, bh->b_bdev); diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c index 19b5009b811d..eb9c630cdbb7 100644 --- a/fs/ext4/readpage.c +++ b/fs/ext4/readpage.c @@ -405,12 +405,8 @@ int ext4_mpage_readpages(struct address_space *mapping, min_t(int, nr_pages, BIO_MAX_PAGES)); if (!bio) goto set_error_page; - if (fscrypt_set_bio_crypt_ctx(bio, inode, next_block, - GFP_KERNEL) != 0) { - bio_put(bio); - bio = NULL; - goto set_error_page; - } + fscrypt_set_bio_crypt_ctx(bio, inode, next_block, + GFP_KERNEL); ctx = get_bio_post_read_ctx(inode, bio, page->index); if (IS_ERR(ctx)) { bio_put(bio); diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 953ea27db372..e68f9858750d 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -317,7 +317,7 @@ static struct bio *__bio_alloc(struct f2fs_io_info *fio, int npages) return bio; } -static int f2fs_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode, +static void f2fs_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode, pgoff_t first_idx, const struct f2fs_io_info *fio, gfp_t gfp_mask) @@ -326,10 +326,8 @@ static int f2fs_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode, * The f2fs garbage collector sets ->encrypted_page when it wants to * read/write raw data without encryption. */ - if (fio && fio->encrypted_page) - return 0; - - return fscrypt_set_bio_crypt_ctx(bio, inode, first_idx, gfp_mask); + if (!fio || !fio->encrypted_page) + fscrypt_set_bio_crypt_ctx(bio, inode, first_idx, gfp_mask); } static bool f2fs_crypt_mergeable_bio(struct bio *bio, const struct inode *inode, @@ -543,7 +541,6 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio) struct bio *bio; struct page *page = fio->encrypted_page ? fio->encrypted_page : fio->page; - int err; if (!f2fs_is_valid_blkaddr(fio->sbi, fio->new_blkaddr, fio->is_por ? META_POR : (__is_meta_io(fio) ? @@ -556,12 +553,8 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio) /* Allocate a new bio */ bio = __bio_alloc(fio, 1); - err = f2fs_set_bio_crypt_ctx(bio, fio->page->mapping->host, - fio->page->index, fio, GFP_NOIO); - if (err) { - bio_put(bio); - return err; - } + f2fs_set_bio_crypt_ctx(bio, fio->page->mapping->host, + fio->page->index, fio, GFP_NOIO); if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) { bio_put(bio); @@ -763,7 +756,7 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio) bio = __bio_alloc(fio, BIO_MAX_PAGES); f2fs_set_bio_crypt_ctx(bio, fio->page->mapping->host, fio->page->index, fio, - GFP_NOIO | __GFP_NOFAIL); + GFP_NOIO); bio_set_op_attrs(bio, fio->op, fio->op_flags); add_bio_entry(fio->sbi, bio, page, fio->temp); @@ -833,7 +826,7 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio) io->bio = __bio_alloc(fio, BIO_MAX_PAGES); f2fs_set_bio_crypt_ctx(io->bio, fio->page->mapping->host, fio->page->index, fio, - GFP_NOIO | __GFP_NOFAIL); + GFP_NOIO); io->fio = *fio; } @@ -873,17 +866,12 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr, struct bio *bio; struct bio_post_read_ctx *ctx; unsigned int post_read_steps = 0; - int err; bio = f2fs_bio_alloc(sbi, min_t(int, nr_pages, BIO_MAX_PAGES), false); if (!bio) return ERR_PTR(-ENOMEM); - err = f2fs_set_bio_crypt_ctx(bio, inode, first_idx, NULL, GFP_NOFS); - if (err) { - bio_put(bio); - return ERR_PTR(err); - } + f2fs_set_bio_crypt_ctx(bio, inode, first_idx, NULL, GFP_NOFS); f2fs_target_device(sbi, blkaddr, bio); bio->bi_end_io = f2fs_read_end_io; diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 28f63ee8aa8b..aade24d425ea 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2355,6 +2355,25 @@ static bool f2fs_inline_crypt_enabled(struct super_block *sb) return F2FS_OPTION(F2FS_SB(sb)).inlinecrypt; } +static int f2fs_get_num_devices(struct super_block *sb) +{ + struct f2fs_sb_info *sbi = F2FS_SB(sb); + + if (f2fs_is_multi_device(sbi)) + return sbi->s_ndevs; + return 1; +} + +static void f2fs_get_devices(struct super_block *sb, + struct request_queue **devs) +{ + struct f2fs_sb_info *sbi = F2FS_SB(sb); + int i; + + for (i = 0; i < sbi->s_ndevs; i++) + devs[i] = bdev_get_queue(FDEV(i).bdev); +} + static const struct fscrypt_operations f2fs_cryptops = { .key_prefix = "f2fs:", .get_context = f2fs_get_context, @@ -2365,6 +2384,8 @@ static const struct fscrypt_operations f2fs_cryptops = { .has_stable_inodes = f2fs_has_stable_inodes, .get_ino_and_lblk_bits = f2fs_get_ino_and_lblk_bits, .inline_crypt_enabled = f2fs_inline_crypt_enabled, + .get_num_devices = f2fs_get_num_devices, + .get_devices = f2fs_get_devices, }; #endif diff --git a/include/linux/bio-crypt-ctx.h b/include/linux/bio-crypt-ctx.h index 7c389f310bab..4535df0a6349 100644 --- a/include/linux/bio-crypt-ctx.h +++ b/include/linux/bio-crypt-ctx.h @@ -6,221 +6,188 @@ #define __LINUX_BIO_CRYPT_CTX_H enum blk_crypto_mode_num { - BLK_ENCRYPTION_MODE_INVALID = 0, - BLK_ENCRYPTION_MODE_AES_256_XTS = 1, + BLK_ENCRYPTION_MODE_INVALID, + BLK_ENCRYPTION_MODE_AES_256_XTS, + BLK_ENCRYPTION_MODE_AES_128_CBC_ESSIV, + BLK_ENCRYPTION_MODE_ADIANTUM, + BLK_ENCRYPTION_MODE_MAX, }; #ifdef CONFIG_BLOCK #include #ifdef CONFIG_BLK_INLINE_ENCRYPTION -struct bio_crypt_ctx { - int keyslot; - const u8 *raw_key; + +#define BLK_CRYPTO_MAX_KEY_SIZE 64 + +/** + * struct blk_crypto_key - an inline encryption key + * @crypto_mode: encryption algorithm this key is for + * @data_unit_size: the data unit size for all encryption/decryptions with this + * key. This is the size in bytes of each individual plaintext and + * ciphertext. This is always a power of 2. It might be e.g. the + * filesystem block size or the disk sector size. + * @data_unit_size_bits: log2 of data_unit_size + * @size: size of this key in bytes (determined by @crypto_mode) + * @hash: hash of this key, for keyslot manager use only + * @raw: the raw bytes of this key. Only the first @size bytes are used. + * + * A blk_crypto_key is immutable once created, and many bios can reference it at + * the same time. It must not be freed until all bios using it have completed. + */ +struct blk_crypto_key { enum blk_crypto_mode_num crypto_mode; - u64 data_unit_num; + unsigned int data_unit_size; unsigned int data_unit_size_bits; + unsigned int size; + unsigned int hash; + u8 raw[BLK_CRYPTO_MAX_KEY_SIZE]; +}; + +#define BLK_CRYPTO_MAX_IV_SIZE 32 +#define BLK_CRYPTO_DUN_ARRAY_SIZE (BLK_CRYPTO_MAX_IV_SIZE/sizeof(u64)) + +/** + * struct bio_crypt_ctx - an inline encryption context + * @bc_key: the key, algorithm, and data unit size to use + * @bc_keyslot: the keyslot that has been assigned for this key in @bc_ksm, + * or -1 if no keyslot has been assigned yet. + * @bc_dun: the data unit number (starting IV) to use + * @bc_ksm: the keyslot manager into which the key has been programmed with + * @bc_keyslot, or NULL if this key hasn't yet been programmed. + * + * A bio_crypt_ctx specifies that the contents of the bio will be encrypted (for + * write requests) or decrypted (for read requests) inline by the storage device + * or controller, or by the crypto API fallback. + */ +struct bio_crypt_ctx { + const struct blk_crypto_key *bc_key; + int bc_keyslot; + + /* Data unit number */ + u64 bc_dun[BLK_CRYPTO_DUN_ARRAY_SIZE]; /* * The keyslot manager where the key has been programmed * with keyslot. */ - struct keyslot_manager *processing_ksm; - - /* - * Copy of the bvec_iter when this bio was submitted. - * We only want to en/decrypt the part of the bio - * as described by the bvec_iter upon submission because - * bio might be split before being resubmitted - */ - struct bvec_iter crypt_iter; - u64 sw_data_unit_num; + struct keyslot_manager *bc_ksm; }; -extern int bio_crypt_clone(struct bio *dst, struct bio *src, - gfp_t gfp_mask); +int bio_crypt_ctx_init(void); + +struct bio_crypt_ctx *bio_crypt_alloc_ctx(gfp_t gfp_mask); + +void bio_crypt_free_ctx(struct bio *bio); static inline bool bio_has_crypt_ctx(struct bio *bio) { return bio->bi_crypt_context; } -static inline void bio_crypt_advance(struct bio *bio, unsigned int bytes) +void bio_crypt_clone(struct bio *dst, struct bio *src, gfp_t gfp_mask); + +static inline void bio_crypt_set_ctx(struct bio *bio, + const struct blk_crypto_key *key, + u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE], + gfp_t gfp_mask) { - if (bio_has_crypt_ctx(bio)) { - bio->bi_crypt_context->data_unit_num += - bytes >> bio->bi_crypt_context->data_unit_size_bits; + struct bio_crypt_ctx *bc = bio_crypt_alloc_ctx(gfp_mask); + + bc->bc_key = key; + memcpy(bc->bc_dun, dun, sizeof(bc->bc_dun)); + bc->bc_ksm = NULL; + bc->bc_keyslot = -1; + + bio->bi_crypt_context = bc; +} + +void bio_crypt_ctx_release_keyslot(struct bio_crypt_ctx *bc); + +int bio_crypt_ctx_acquire_keyslot(struct bio_crypt_ctx *bc, + struct keyslot_manager *ksm); + +struct request; +bool bio_crypt_should_process(struct request *rq); + +static inline bool bio_crypt_dun_is_contiguous(const struct bio_crypt_ctx *bc, + unsigned int bytes, + u64 next_dun[BLK_CRYPTO_DUN_ARRAY_SIZE]) +{ + int i = 0; + unsigned int inc = bytes >> bc->bc_key->data_unit_size_bits; + + while (inc && i < BLK_CRYPTO_DUN_ARRAY_SIZE) { + if (bc->bc_dun[i] + inc != next_dun[i]) + return false; + inc = ((bc->bc_dun[i] + inc) < inc); + i++; + } + + return true; +} + + +static inline void bio_crypt_dun_increment(u64 dun[BLK_CRYPTO_DUN_ARRAY_SIZE], + unsigned int inc) +{ + int i = 0; + + while (inc && i < BLK_CRYPTO_DUN_ARRAY_SIZE) { + dun[i] += inc; + inc = (dun[i] < inc); + i++; } } -extern bool bio_crypt_swhandled(struct bio *bio); - -static inline bool bio_crypt_has_keyslot(struct bio *bio) +static inline void bio_crypt_advance(struct bio *bio, unsigned int bytes) { - return bio->bi_crypt_context->keyslot >= 0; + struct bio_crypt_ctx *bc = bio->bi_crypt_context; + + if (!bc) + return; + + bio_crypt_dun_increment(bc->bc_dun, + bytes >> bc->bc_key->data_unit_size_bits); } -extern int bio_crypt_ctx_init(void); +bool bio_crypt_ctx_compatible(struct bio *b_1, struct bio *b_2); -extern struct bio_crypt_ctx *bio_crypt_alloc_ctx(gfp_t gfp_mask); - -extern void bio_crypt_free_ctx(struct bio *bio); - -static inline int bio_crypt_set_ctx(struct bio *bio, - const u8 *raw_key, - enum blk_crypto_mode_num crypto_mode, - u64 dun, - unsigned int dun_bits, - gfp_t gfp_mask) -{ - struct bio_crypt_ctx *crypt_ctx; - - crypt_ctx = bio_crypt_alloc_ctx(gfp_mask); - if (!crypt_ctx) - return -ENOMEM; - - crypt_ctx->raw_key = raw_key; - crypt_ctx->data_unit_num = dun; - crypt_ctx->data_unit_size_bits = dun_bits; - crypt_ctx->crypto_mode = crypto_mode; - crypt_ctx->processing_ksm = NULL; - crypt_ctx->keyslot = -1; - bio->bi_crypt_context = crypt_ctx; - - return 0; -} - -static inline void bio_set_data_unit_num(struct bio *bio, u64 dun) -{ - bio->bi_crypt_context->data_unit_num = dun; -} - -static inline int bio_crypt_get_keyslot(struct bio *bio) -{ - return bio->bi_crypt_context->keyslot; -} - -static inline void bio_crypt_set_keyslot(struct bio *bio, - unsigned int keyslot, - struct keyslot_manager *ksm) -{ - bio->bi_crypt_context->keyslot = keyslot; - bio->bi_crypt_context->processing_ksm = ksm; -} - -extern void bio_crypt_ctx_release_keyslot(struct bio *bio); - -extern int bio_crypt_ctx_acquire_keyslot(struct bio *bio, - struct keyslot_manager *ksm); - -static inline const u8 *bio_crypt_raw_key(struct bio *bio) -{ - return bio->bi_crypt_context->raw_key; -} - -static inline enum blk_crypto_mode_num bio_crypto_mode(struct bio *bio) -{ - return bio->bi_crypt_context->crypto_mode; -} - -static inline u64 bio_crypt_data_unit_num(struct bio *bio) -{ - return bio->bi_crypt_context->data_unit_num; -} - -static inline u64 bio_crypt_sw_data_unit_num(struct bio *bio) -{ - return bio->bi_crypt_context->sw_data_unit_num; -} - -extern bool bio_crypt_should_process(struct bio *bio, struct request_queue *q); - -extern bool bio_crypt_ctx_compatible(struct bio *b_1, struct bio *b_2); - -extern bool bio_crypt_ctx_back_mergeable(struct bio *b_1, - unsigned int b1_sectors, - struct bio *b_2); +bool bio_crypt_ctx_mergeable(struct bio *b_1, unsigned int b1_bytes, + struct bio *b_2); #else /* CONFIG_BLK_INLINE_ENCRYPTION */ -struct keyslot_manager; - static inline int bio_crypt_ctx_init(void) { return 0; } -static inline int bio_crypt_clone(struct bio *dst, struct bio *src, - gfp_t gfp_mask) -{ - return 0; -} - -static inline void bio_crypt_advance(struct bio *bio, - unsigned int bytes) { } - static inline bool bio_has_crypt_ctx(struct bio *bio) { return false; } +static inline void bio_crypt_clone(struct bio *dst, struct bio *src, + gfp_t gfp_mask) { } + static inline void bio_crypt_free_ctx(struct bio *bio) { } -static inline void bio_crypt_set_ctx(struct bio *bio, - u8 *raw_key, - enum blk_crypto_mode_num crypto_mode, - u64 dun, - unsigned int dun_bits, - gfp_t gfp_mask) { } - -static inline bool bio_crypt_swhandled(struct bio *bio) -{ - return false; -} - -static inline void bio_set_data_unit_num(struct bio *bio, u64 dun) { } - -static inline bool bio_crypt_has_keyslot(struct bio *bio) -{ - return false; -} - -static inline void bio_crypt_set_keyslot(struct bio *bio, - unsigned int keyslot, - struct keyslot_manager *ksm) { } - -static inline int bio_crypt_get_keyslot(struct bio *bio) -{ - return -1; -} - -static inline u8 *bio_crypt_raw_key(struct bio *bio) -{ - return NULL; -} - -static inline u64 bio_crypt_data_unit_num(struct bio *bio) -{ - return 0; -} - -static inline bool bio_crypt_should_process(struct bio *bio, - struct request_queue *q) -{ - return false; -} +static inline void bio_crypt_advance(struct bio *bio, unsigned int bytes) { } static inline bool bio_crypt_ctx_compatible(struct bio *b_1, struct bio *b_2) { return true; } -static inline bool bio_crypt_ctx_back_mergeable(struct bio *b_1, - unsigned int b1_sectors, - struct bio *b_2) +static inline bool bio_crypt_ctx_mergeable(struct bio *b_1, + unsigned int b1_bytes, + struct bio *b_2) { return true; } #endif /* CONFIG_BLK_INLINE_ENCRYPTION */ + #endif /* CONFIG_BLOCK */ + #endif /* __LINUX_BIO_CRYPT_CTX_H */ diff --git a/include/linux/blk-crypto.h b/include/linux/blk-crypto.h index 2a07401244a6..07d32e33f0bb 100644 --- a/include/linux/blk-crypto.h +++ b/include/linux/blk-crypto.h @@ -6,32 +6,23 @@ #ifndef __LINUX_BLK_CRYPTO_H #define __LINUX_BLK_CRYPTO_H -#include #include #ifdef CONFIG_BLK_INLINE_ENCRYPTION -int blk_crypto_init(void); - int blk_crypto_submit_bio(struct bio **bio_ptr); bool blk_crypto_endio(struct bio *bio); -int blk_crypto_start_using_mode(enum blk_crypto_mode_num mode_num, - unsigned int data_unit_size, - struct request_queue *q); +int blk_crypto_init_key(struct blk_crypto_key *blk_key, const u8 *raw_key, + enum blk_crypto_mode_num crypto_mode, + unsigned int data_unit_size); -int blk_crypto_evict_key(struct request_queue *q, const u8 *key, - enum blk_crypto_mode_num mode, - unsigned int data_unit_size); +int blk_crypto_evict_key(struct request_queue *q, + const struct blk_crypto_key *key); #else /* CONFIG_BLK_INLINE_ENCRYPTION */ -static inline int blk_crypto_init(void) -{ - return 0; -} - static inline int blk_crypto_submit_bio(struct bio **bio_ptr) { return 0; @@ -42,21 +33,31 @@ static inline bool blk_crypto_endio(struct bio *bio) return true; } +#endif /* CONFIG_BLK_INLINE_ENCRYPTION */ + +#ifdef CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK + +int blk_crypto_start_using_mode(enum blk_crypto_mode_num mode_num, + unsigned int data_unit_size, + struct request_queue *q); + +int blk_crypto_fallback_init(void); + +#else /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */ + static inline int blk_crypto_start_using_mode(enum blk_crypto_mode_num mode_num, unsigned int data_unit_size, struct request_queue *q) { - return -EOPNOTSUPP; + return 0; } -static inline int blk_crypto_evict_key(struct request_queue *q, const u8 *key, - enum blk_crypto_mode_num mode, - unsigned int data_unit_size) +static inline int blk_crypto_fallback_init(void) { return 0; } -#endif /* CONFIG_BLK_INLINE_ENCRYPTION */ +#endif /* CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK */ #endif /* __LINUX_BLK_CRYPTO_H */ diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h index 6febaa570160..841dcbec26b5 100644 --- a/include/linux/fscrypt.h +++ b/include/linux/fscrypt.h @@ -65,6 +65,9 @@ struct fscrypt_operations { void (*get_ino_and_lblk_bits)(struct super_block *sb, int *ino_bits_ret, int *lblk_bits_ret); bool (*inline_crypt_enabled)(struct super_block *sb); + int (*get_num_devices)(struct super_block *sb); + void (*get_devices)(struct super_block *sb, + struct request_queue **devs); }; static inline bool fscrypt_has_encryption_key(const struct inode *inode) @@ -539,12 +542,13 @@ extern bool fscrypt_inode_uses_inline_crypto(const struct inode *inode); extern bool fscrypt_inode_uses_fs_layer_crypto(const struct inode *inode); -extern int fscrypt_set_bio_crypt_ctx(struct bio *bio, const struct inode *inode, - u64 first_lblk, gfp_t gfp_mask); +extern void fscrypt_set_bio_crypt_ctx(struct bio *bio, + const struct inode *inode, + u64 first_lblk, gfp_t gfp_mask); -extern int fscrypt_set_bio_crypt_ctx_bh(struct bio *bio, - const struct buffer_head *first_bh, - gfp_t gfp_mask); +extern void fscrypt_set_bio_crypt_ctx_bh(struct bio *bio, + const struct buffer_head *first_bh, + gfp_t gfp_mask); extern bool fscrypt_mergeable_bio(struct bio *bio, const struct inode *inode, u64 next_lblk); @@ -563,20 +567,14 @@ static inline bool fscrypt_inode_uses_fs_layer_crypto(const struct inode *inode) return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode); } -static inline int fscrypt_set_bio_crypt_ctx(struct bio *bio, - const struct inode *inode, - u64 first_lblk, gfp_t gfp_mask) -{ - return 0; -} +static inline void fscrypt_set_bio_crypt_ctx(struct bio *bio, + const struct inode *inode, + u64 first_lblk, gfp_t gfp_mask) { } -static inline int fscrypt_set_bio_crypt_ctx_bh( - struct bio *bio, - const struct buffer_head *first_bh, - gfp_t gfp_mask) -{ - return 0; -} +static inline void fscrypt_set_bio_crypt_ctx_bh( + struct bio *bio, + const struct buffer_head *first_bh, + gfp_t gfp_mask) { } static inline bool fscrypt_mergeable_bio(struct bio *bio, const struct inode *inode, diff --git a/include/linux/keyslot-manager.h b/include/linux/keyslot-manager.h index 0777ade7907c..fbc423fe5cd5 100644 --- a/include/linux/keyslot-manager.h +++ b/include/linux/keyslot-manager.h @@ -3,96 +3,58 @@ * Copyright 2019 Google LLC */ -#include - -#ifdef CONFIG_BLOCK - #ifndef __LINUX_KEYSLOT_MANAGER_H #define __LINUX_KEYSLOT_MANAGER_H +#include + +struct keyslot_manager; + /** * struct keyslot_mgmt_ll_ops - functions to manage keyslots in hardware - * @keyslot_program: Program the specified key and algorithm into the - * specified slot in the inline encryption hardware. + * @keyslot_program: Program the specified key into the specified slot in the + * inline encryption hardware. * @keyslot_evict: Evict key from the specified keyslot in the hardware. - * The key, crypto_mode and data_unit_size are also passed - * down so that e.g. dm layers can evict keys from - * the devices that they map over. + * The key is provided so that e.g. dm layers can evict + * keys from the devices that they map over. * Returns 0 on success, -errno otherwise. - * @crypto_mode_supported: Check whether a crypto_mode and data_unit_size - * combo is supported. - * @keyslot_find: Returns the slot number that matches the key, - * or -ENOKEY if no match found, or -errno on - * error. * * This structure should be provided by storage device drivers when they set up * a keyslot manager - this structure holds the function ptrs that the keyslot * manager will use to manipulate keyslots in the hardware. */ struct keyslot_mgmt_ll_ops { - int (*keyslot_program)(void *ll_priv_data, const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size, + int (*keyslot_program)(struct keyslot_manager *ksm, + const struct blk_crypto_key *key, unsigned int slot); - int (*keyslot_evict)(void *ll_priv_data, const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size, + int (*keyslot_evict)(struct keyslot_manager *ksm, + const struct blk_crypto_key *key, unsigned int slot); - bool (*crypto_mode_supported)(void *ll_priv_data, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size); - int (*keyslot_find)(void *ll_priv_data, const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size); }; -#ifdef CONFIG_BLK_INLINE_ENCRYPTION -struct keyslot_manager; +struct keyslot_manager *keyslot_manager_create(unsigned int num_slots, + const struct keyslot_mgmt_ll_ops *ksm_ops, + const unsigned int crypto_mode_supported[BLK_ENCRYPTION_MODE_MAX], + void *ll_priv_data); -extern struct keyslot_manager *keyslot_manager_create(unsigned int num_slots, - const struct keyslot_mgmt_ll_ops *ksm_ops, - void *ll_priv_data); +int keyslot_manager_get_slot_for_key(struct keyslot_manager *ksm, + const struct blk_crypto_key *key); -extern int -keyslot_manager_get_slot_for_key(struct keyslot_manager *ksm, - const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size); +void keyslot_manager_get_slot(struct keyslot_manager *ksm, unsigned int slot); -extern void keyslot_manager_get_slot(struct keyslot_manager *ksm, - unsigned int slot); +void keyslot_manager_put_slot(struct keyslot_manager *ksm, unsigned int slot); -extern void keyslot_manager_put_slot(struct keyslot_manager *ksm, - unsigned int slot); +bool keyslot_manager_crypto_mode_supported(struct keyslot_manager *ksm, + enum blk_crypto_mode_num crypto_mode, + unsigned int data_unit_size); -extern bool -keyslot_manager_crypto_mode_supported(struct keyslot_manager *ksm, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size); +int keyslot_manager_evict_key(struct keyslot_manager *ksm, + const struct blk_crypto_key *key); -extern bool -keyslot_manager_rq_crypto_mode_supported(struct request_queue *q, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size); +void keyslot_manager_reprogram_all_keys(struct keyslot_manager *ksm); -extern int keyslot_manager_evict_key(struct keyslot_manager *ksm, - const u8 *key, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size); +void *keyslot_manager_private(struct keyslot_manager *ksm); -extern void keyslot_manager_destroy(struct keyslot_manager *ksm); - -#else /* CONFIG_BLK_INLINE_ENCRYPTION */ - -static inline bool -keyslot_manager_rq_crypto_mode_supported(struct request_queue *q, - enum blk_crypto_mode_num crypto_mode, - unsigned int data_unit_size) -{ - return false; -} -#endif /* CONFIG_BLK_INLINE_ENCRYPTION */ +void keyslot_manager_destroy(struct keyslot_manager *ksm); #endif /* __LINUX_KEYSLOT_MANAGER_H */ - -#endif /* CONFIG_BLOCK */