diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2021-12-30 00:34:52 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2021-12-30 00:42:39 +0100 |
commit | f63c2ec13c5f74e5211409ae2c3367a2171adb83 (patch) | |
tree | d7d7899b5e078d1bc14c0c3e4ce0092d1a76e9d1 | |
parent | fac35ab08abc26d05e4b737d716f77ac794798d2 (diff) | |
download | VeraCrypt-f63c2ec13c5f74e5211409ae2c3367a2171adb83.tar.gz VeraCrypt-f63c2ec13c5f74e5211409ae2c3367a2171adb83.zip |
Windows driver: Set maximum values for encryption queue parameters. Add IOCTL code to read used values from user space maximum value for EncryptionFragmentSize is 2048 maximum value for EncryptionIoRequestCount is 8192 maximum value for EncryptionItemCount is (EncryptionIoRequestCount/2)
-rw-r--r-- | src/Common/Apidrvr.h | 9 | ||||
-rw-r--r-- | src/Driver/EncryptedIoQueue.h | 1 | ||||
-rw-r--r-- | src/Driver/Ntdriver.c | 20 |
3 files changed, 27 insertions, 3 deletions
diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h index 368d4a72..36946e6c 100644 --- a/src/Common/Apidrvr.h +++ b/src/Common/Apidrvr.h @@ -127,6 +127,8 @@ #define VC_IOCTL_IS_RAM_ENCRYPTION_ENABLED TC_IOCTL (42) +#define VC_IOCTL_ENCRYPTION_QUEUE_PARAMS TC_IOCTL (43) + // Legacy IOCTLs used before version 5.0 #define TC_IOCTL_LEGACY_GET_DRIVER_VERSION 466968 #define TC_IOCTL_LEGACY_GET_MOUNTED_VOLUMES 466948 @@ -390,6 +392,13 @@ typedef struct BOOL HwEncryptionEnabled; } GetSystemDriveDumpConfigRequest; +typedef struct +{ + int EncryptionIoRequestCount; + int EncryptionItemCount; + int EncryptionFragmentSize; +} EncryptionQueueParameters; + #pragma pack (pop) #define DRIVER_STR WIDE diff --git a/src/Driver/EncryptedIoQueue.h b/src/Driver/EncryptedIoQueue.h index d9bef42b..c4b6f269 100644 --- a/src/Driver/EncryptedIoQueue.h +++ b/src/Driver/EncryptedIoQueue.h @@ -24,6 +24,7 @@ #define TC_ENC_IO_QUEUE_PREALLOCATED_ITEM_COUNT 8 #define TC_ENC_IO_QUEUE_PREALLOCATED_IO_REQUEST_COUNT 16 +#define TC_ENC_IO_QUEUE_PREALLOCATED_IO_REQUEST_MAX_COUNT 8192 typedef struct EncryptedIoQueueBufferStruct diff --git a/src/Driver/Ntdriver.c b/src/Driver/Ntdriver.c index 3c7b50dc..6f068a8f 100644 --- a/src/Driver/Ntdriver.c +++ b/src/Driver/Ntdriver.c @@ -2886,6 +2886,18 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex } break; + case VC_IOCTL_ENCRYPTION_QUEUE_PARAMS: + if (ValidateIOBufferSize (Irp, sizeof (EncryptionQueueParameters), ValidateOutput)) + { + EncryptionQueueParameters* pParams = (EncryptionQueueParameters*) Irp->AssociatedIrp.SystemBuffer; + pParams->EncryptionFragmentSize = EncryptionFragmentSize; + pParams->EncryptionIoRequestCount = EncryptionIoRequestCount; + pParams->EncryptionItemCount = EncryptionItemCount; + Irp->IoStatus.Information = sizeof (EncryptionQueueParameters); + Irp->IoStatus.Status = STATUS_SUCCESS; + } + break; + default: return TCCompleteIrp (Irp, STATUS_INVALID_DEVICE_REQUEST, 0); } @@ -3296,6 +3308,7 @@ LPWSTR TCTranslateCode (ULONG ulCode) TC_CASE_RET_NAME (VC_IOCTL_GET_DRIVE_GEOMETRY_EX); TC_CASE_RET_NAME (VC_IOCTL_EMERGENCY_CLEAR_ALL_KEYS); TC_CASE_RET_NAME (VC_IOCTL_IS_RAM_ENCRYPTION_ENABLED); + TC_CASE_RET_NAME (VC_IOCTL_ENCRYPTION_QUEUE_PARAMS); TC_CASE_RET_NAME (IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS); @@ -4826,13 +4839,14 @@ NTSTATUS ReadRegistryConfigFlags (BOOL driverEntry) { if (EncryptionIoRequestCount < TC_ENC_IO_QUEUE_PREALLOCATED_IO_REQUEST_COUNT) EncryptionIoRequestCount = TC_ENC_IO_QUEUE_PREALLOCATED_IO_REQUEST_COUNT; + else if (EncryptionIoRequestCount > TC_ENC_IO_QUEUE_PREALLOCATED_IO_REQUEST_MAX_COUNT) + EncryptionIoRequestCount = TC_ENC_IO_QUEUE_PREALLOCATED_IO_REQUEST_MAX_COUNT; - if (EncryptionItemCount == 0) + if ((EncryptionItemCount == 0) || (EncryptionItemCount > (EncryptionIoRequestCount / 2))) EncryptionItemCount = EncryptionIoRequestCount / 2; - else if (EncryptionItemCount >= EncryptionIoRequestCount) - EncryptionItemCount = EncryptionIoRequestCount - 1; /* EncryptionFragmentSize value in registry is expressed in KiB */ + /* Maximum allowed value for EncryptionFragmentSize is 2048 KiB */ EncryptionFragmentSize *= 1024; if (EncryptionFragmentSize == 0) EncryptionFragmentSize = TC_ENC_IO_QUEUE_MAX_FRAGMENT_SIZE; |