Commit Graph

84 Commits

Author SHA1 Message Date
Nim Wijetunga 01acd8d3c6
blob granule inplace encryption (#10619) 2023-07-17 10:44:11 -07:00
Josh Slocum 8ec439f023
fixing apparent source of nondeterminism in bgfiles (#10605) 2023-07-10 12:59:30 -04:00
Ata E Husain Bohra 7779c908b3
EaR: Remove usage of ENABLE_CONFIGURABLE_ENCRYPTION knob (#10570)
Description

Given Configurable encryption has been checked in and being tested via
simulation for more than a month and also to avoid penalty of accessing
KNOBS in inline commit path, patch retires the KNOB and make
ConfigurationEncryption default EaR mode for FDB.

BlobCipher still supports the old format header and encryption semantics,
will remove the dead code as a followup PR.

Testing

devRunCorrectness - 100K
2023-06-30 17:48:09 -07:00
Josh Slocum ae862e1b96 fixing code probe issues 2023-04-20 11:54:47 -07:00
Ata E Husain Bohra fe0a4df06a
EaR: Implement Key Check Value semantics (#9936)
* EaR: Implement Key Check Value semantics

Description

Key Check Value (KCV) is a checksum of cryptographic encryption key
used to validate encryption keys's integrity. FDB Encryption at-rest
relies on external KMS to supply encryption keys.

Patch proposes following major changes:
1. Implement Sha256 based KCV implementation to protect against
'baseCipher' corruption in two possible scenarios:
 a) potential corruption external to FDB
 b) potential corruption within FDB processes.
2. Scheme persists computed KCV token in block encryption header,
which then gets validated as part of header validation during
decryption.
3. FDB Encryption key derivation uses HMAC_SHA256 digest generation
scheme, which allows max 64 bytes of 'cipher buffer', patch add
required check to ensure 'baseCipher' length are within bounds.
OpenSSL HMAC underlying call ignores extra length if supplied, however,
it weakens the security guarantees, hence, disallowed.

Testing

devRunCorrectness - multiple 500K runs
Valgrind & Asan - BlobCipherUnit, RESTKMSUnit, BlobGranuleCorrectness*,
EncryptionOps, EncryptKeyProxyTest
2023-04-12 14:29:31 -07:00
Ata E Husain Bohra 3f6fcada45
EaR - Misc fixes found using end-to-end integration testing (#9806)
* EaR - Misc fixes found using end-to-end integration testing

Description

Major changes proposed includes:
1. RESTClient filtering of trailing `/`(s) characters from
input URI resource path
2. Avoid EKP exponential backup given RESTClient supports
exponential backoffs retries for all retryable errors.
3. Memory allocation optimizations:
 3.1. BaseCipher key management using Standalone semantics
 in KMSConnector interface endpoints
 3.2. Optimize memcpy while looking encryption-keys in EKP endpoints
4. Avoid delay while starting EKP, given its criticality during
cluster recovery.
5. Update BlobCipher to handle variable size BaseCipher buffer
6. Improved logging

Testing

Setup:
1. External KMS server to supply encryption keys (inhouse)
2. Create cluster with: cluster_aware & domain_aware config

* Fix EncryptionOps test

Description

Testing

* EaR - Misc fixes found using end-to-end integration testing

Description

Major changes:
1. Cleanup EKP driven exponential backup files.
2. Update EKP not to use #1.

Testing

* EaR - Misc fixes found using end-to-end integration testing

Description

Address review comments

Testing

* Fix AES 256 key length value

Description

Testing

* Address review comments

Description

Testing
2023-03-30 22:22:26 -07:00
Josh Slocum c26831ec04
adding version metadata to blob granule file pointers (#9392) 2023-02-16 17:11:11 -06:00
Josh Slocum eefc889389
Add tenant and encryption support to new bg file apis (#9315)
* Add tenant and encryption support to new bg file apis

* formatting

* fixing comment style for linter
2023-02-15 11:48:40 -06:00
Yi Wu 3d882a99c5
EaR: Refactor encryption header std::variant serializer and versioning (#9345)
Changes:
1. Make binary serializer natively support `std::variant`. Serialize size is 1 byte (the type index, i.e. `std::variant::index()`), plus the serialize size of the actual type stored in the `std::variant`. Update `BlobCipherEncryptHeaderRef` to use the `std::variant` binary serializer
3. Remove `flagsVersion` and `algoHeaderVersion` from `BlobCipherEncryptHeaderRef`. The former is replaced by `flags.index() + 1`, and the latter is moved into each of the algorithm-specific sub-headers. Each sub-header types will have nesting version-specific subtypes to handle serialization of that specific version (e.g. for `AesCtrNoAuth` it has a `AesCtrNoAuthV1` subtype).
2023-02-14 20:19:27 -08:00
Yi Wu fe18c87ac6
EaR: commit proxy fetch additional cipher keys post-resolution (#9308)
Commit proxy needs to fetch additional cipher keys post-resolution, since tenant ids for raw access requests and cross-tenant clear ranges are calculated after resolution.
2023-02-14 13:05:51 -08:00
Ata E Husain Bohra f30c5a13ac
EaR: Configurable Encryption feature support for BlobGranules (#9343)
Description

Patch update BlobGranule encryption code to support Configurable
encryption semantics

Testing

BlobGranuleCorrectness* - 100K
2023-02-09 21:13:56 -08:00
Hui Liu 6b6959d35f Split blob manifest as segments when writting 2023-02-09 11:26:19 -08:00
Marian Dvorsky dfce17f65f
Add new Blob Granule (BG) APIs for raw blob data access (#9245)
Adds a prototype of new APIs to access the Blob Granule data:

fdb_future_readbg_get_descriptions
fdb_readbg_parse_snapshot_file
fdb_readbg_parse_delta_file
fdb_result_get_bg_mutations_array

The client first calls fdb_future_readbg_get_descriptions to get a high level description of granules, reads the files and then calls fdb_readbg_parse_snapshot_file and fdb_readbg_parse_delta_file to parse the snapshot and delta files, respectively. This allows the client to get a raw access to the blob granule data, and allows the client to process them in a way they wouldn't be efficiently able to when using previous blob granule read APIs.

We expect these APIs to evolve before a release.

---------

Co-authored-by: Josh Slocum <josh.slocum@snowflake.com>
2023-01-31 15:22:04 +01:00
Xiaoge Su 2f581fc290 fixup! Reformat source 2023-01-30 17:07:57 -08:00
Xiaoge Su 84343b3b97 fixup! fix the compile error 2023-01-30 17:07:57 -08:00
Xiaoge Su 896a9decd5 Let materializeBlobGranule accept a std::vector<StringRef> instead of StringRef[]
The deltaFileData parameter was type StringRef[], this indirectly causes
issue #9206. By setting the incoming parameter type to be
std::vector<StringRef>, the issue might be fixed plus adding extra
memory safety.
2023-01-30 17:07:57 -08:00
Junhyun Shim 8e7f02e2f9
Set VLA minimum length to 1 (#9205) 2023-01-24 09:41:07 -08:00
Xiaoxi Wang 070894a597 return early if streams is empty 2022-12-15 12:56:49 -08:00
Nim Wijetunga a21f657429
Add Encryption Code Probes for BlobGranule (#8779)
* add code probes

* address pr comments

* address pr comments

* Trigger Build

* fix
2022-11-16 06:13:55 -08:00
Hui Liu 0f8e5af5cf Add micro-benchmark for blob delta serialization 2022-11-11 09:22:11 -08:00
Josh Slocum 494dd1c5ed
switch bg file data chunks to be serialized with binary writer instead of object writer (#8535) 2022-11-03 16:42:36 -05:00
Nim Wijetunga 24ce8c0fd0
Commit Proxy Encryption Code Probes (#8618)
* add commit proxy encryption code probes

* fix comment

* address pr comments

* address pr comments

* address pr comments

* address pr comments

* Trigger Build
2022-10-31 20:04:42 -07:00
Josh Slocum 2d6840ee90
fix bg stats invalid access (#8507) 2022-10-24 10:23:22 -07:00
Josh Slocum 9987da5a4f
Add blob granule benchmark to track stats by varying amount of deltas, and several simple perf improvements (#8533) 2022-10-21 17:05:51 -05:00
Josh Slocum d7b88f203c
added repeatFromFiles that supports new file format (#8502) 2022-10-21 10:29:35 -05:00
Josh Slocum 89519343a7
adding new bg read metrics to client and refactoring them into a new trace event (#8493) 2022-10-18 14:13:35 -05:00
A.J. Beamon e1fe28b78b Switch some usages of LiteralStringRef to use the _sr suffix 2022-09-30 16:04:16 -07:00
Hui Liu db3b908ce2
Merge pull request #8368 from sfc-gh-huliu/fixunittest
fix benchFromFiles unit test
2022-09-29 22:15:56 -07:00
Hui Liu dea6da142d fix unittest benchFromFiles 2022-09-29 21:00:12 -07:00
Ata E Husain Bohra 03f1d13be3
Enable encryption authentication configurability (#8312)
* Enable encryption authentication configurability

Description

 diff-1: Remove memcpy due to auth-token computation
         Address review comments

Patch proposes major changes:
1. Enable FDB to choose encryption authentication as a configurable
parameter. Fix issues choosing ENCRYPT_HEADER_AUTH_TOKEN_NONE mode.
2. Introduce AES_CMAC as supported encryption authentication scheme.

Patch allows cluster to govern: if encryption authentication needs to
enabled, if yes, then choose from two supported schemes:
1. HMAC_SHA_256
2. AES_256_CMAC

Testing

devRunCorrectness - 100K
BlobCipher unittests
EncryptionOps.toml
BlobGranuleCorrectness/BlobGranuleCorrectnessClean
2022-09-29 16:18:55 -07:00
Josh Slocum f78eb8c778
Adding bg read amp metrics (#8275) 2022-09-22 16:31:27 -07:00
Ata E Husain Bohra 52169d2b8e
Enable ZSTD compression support (#8014)
* Enable ZSTD compression filter

Description

  diff-4: Randomize Knob Compression filter selection
  diff-3: Minor refactoring
  diff-2: Limit ZSTD availability to CLANG compiler
  diff-1: Add ZSTD compression option to BlobGranule tests

Major changes includes:
1. Update FDB CMake to download, install and build Boost with
ZSTD compatibility
2. Update CompressionUtils to enable boost::iostreams::zstd
compression filter

Testing

CompressionUtilsUnit.toml
BlobGranuleCorrectness/BlobGranuleCorrectnessClean
devRunCorrectness - 100K (in-progress)
2022-09-22 14:31:49 -07:00
A.J. Beamon 4fd64630e8 Convert literal string ref instances to use _sr suffix 2022-09-19 11:35:58 -07:00
Josh Slocum 4ead9a697f cleaning tss and blob granule file code probes 2022-09-16 09:51:33 -05:00
Yi Wu d831c87d14
Add encryption metrics (#8070)
Adding the following metrics:
* BlobCipherKeyCache hit/miss
* EKP: KMS requests latencies
* For each component that using encryption, they now need to pass a UsageType enum to the encryption helper methods (GetEncryptCipherKeys/GetLatestEncryptCipherKey/encrypt/decrypt) and those methods will help to log get cipher key latency samples and encryption/decryption cpu times accordingly.
2022-09-09 18:43:09 -07:00
Josh Slocum a27ee0f18a
Fixing UBSAN issues in BlobGranuleFiles (#7987) 2022-08-25 10:25:50 +02:00
Josh Slocum cfc5ab550e
Update BlobGranules API tests (#7947)
* blob granule fixes from api tests

* Adding BlobGranuleErrors workload

* bug fixes and debugging improvements for blob granule api tests

* cleanup and refactoring of bg api tests

* better memory management for loadAndMaterialize
2022-08-23 17:47:02 -05:00
Josh Slocum 98a7ec1797
Blob Granules Cleanup (#7941)
* Cleaned up BlobGranule TODO + FIXMEs and addressed some

* popping feed at correct version

* blob worker taking over a granule will pop from where previous worker left off

* addressed fixme of blob worker not re-snapshotting from old change feed

* formatting

* more change feed popped fixes after pop updates

* Getting rid of change feed parallelism lock since it can cause deadlocks in fetching, and relying on full fetch lock

* New blob worker metric and fixing old one

* server-side popped checking still doesn't work because of pops at non-mutation versions

* format
2022-08-19 17:25:31 -07:00
Ata E Husain Bohra 03435b5133
Update BlobCipher cache to respect EKP/KMS cipherKey TTL (#7885)
Description

FDB native encryption data at-rest supports two type of cipher-keys
in-memory caching:
1. Revocable keys - with a definite expiry (future timestamp)
2. Non-revocable keys - with or without expiry timestamp and/or
refreshAt timestamp.

Patch update BlobCipherKey in-memory cache to respect EKP/KMS
supplied 'refreshAt' and 'expireAt' timestamp. GetLatestCipher
validates `cipher key freshness' as well as GetCipherKey checks
for 'cipher key liveness' before replying details to the caller.

Patch also optimizes the BlobCipher module logging by taking
following measures:
1. BLOB_CIPHER_DEBUG macro to guard spammy log messages needed
mostly for debugging failures.
2. Minimize log volume by logging cipherKey details for any new
key added to the cache, key-refreshes are not logged.
3. Categorize logs into: debug, info and warn on per-usecase basis

Testing

devRunCorrectness - 100K
EncryptOps.toml - 100K
2022-08-15 11:17:26 -07:00
Josh Slocum 62494f048c
several changes to manage blob worker memory more and to test that management (#7834) 2022-08-09 17:53:52 -05:00
Josh Slocum 4b66645d80
Granule file performance benchmark and improvements (#7742)
* added cpu microbenchmark for blob granule files

* Added edge case read benchmarks, and sorting memory deltas

* Sorted merge for granule files

* key block comparison optimization in granule files

* More performance improvements to granule file read

* fixing zlib not supported build

* fixing formatting

* Added debug macro for new debugging prints

* review comments

* more strict compression size validation assert
2022-08-02 11:36:44 -05:00
Ata E Husain Bohra ef6012c1d1
Encrypt BlobGranule delta files (#7735)
* Encrypt  BlobGranule delta files

Description

 diff-1: Address review comments

Major changes proposed by the patch are:
1. Refactor code to allow caching of 'encryption key ctx' as part of
BlobFilePointerRef. The refactoring allows snapshot and/or delta files
to store their own file encryption context.
2. Enable BlobGranule delta file encryption/decryption semantics.

Testing

BlobGranuleCorrrectness  
BlobGranuleCorrectnessClean
BlobGranuleFileUnitTestToml

Description

Testing
2022-08-01 16:34:44 -07:00
Junhyun Shim c6342a6e5b
Merge branch 'main' into features/authz 2022-07-27 20:51:32 +02:00
Junhyun Shim 5169616b16 Fix unresolved merge conflicts 2022-07-27 00:38:16 +02:00
Josh Slocum 0609aa57d1 Merge branch 'main' into improved_cf_testing 2022-07-26 16:44:13 -05:00
Josh Slocum 15e7a4b186 addressing review comments 2022-07-26 14:20:35 -05:00
Josh Slocum ea9018460a cleanup and polish 2022-07-22 15:13:32 -05:00
Josh Slocum 33053a0a7a Bug fix and cleanup 2022-07-22 14:34:38 -05:00
Josh Slocum 095a5a4868 First version of key-sorted delta files 2022-07-22 11:43:49 -05:00
Josh Slocum 80f4c059f1 Added full granule read unit test 2022-07-21 14:14:01 -05:00