System encryption fails with "The parameter is incorrect" (File::Write) on NVMe disks with AlignmentMask = 0xF (unaligned raw I/O buffer)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- c
- Lĩnh vực
- operating-systems, security
Hướng nghiên cứu
Start with src/Common/BootEncryption.cpp and trace BootEncryption::Install() through InstallVolumeHeader() into the File::Write and File::Read fallback described in the issue. Check how the device I/O buffers are aligned, then reproduce the system encryption pretest on a device reporting AlignmentMask = 0xF. Done means the pretest writes the header and proceeds to reboot without error or rolling back EFI files.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Expected behavior
Clicking Yes on the prompt to restart for the System Encryption Pretest installs the boot loader and volume header, then restarts.
Observed behavior
Immediately after clicking Yes, before any reboot:
The parameter is incorrect.
Source: VeraCrypt::File::Write:1024
VeraCrypt then rolls back the EFI loader files. The same error also occurred with 1.26.30 (at line 1043, same statement) before that release was pulled.
Root cause
The disk reports AlignmentMask = 0xF (IOCTL_STORAGE_QUERY_PROPERTY, StorageAdapterProperty), so Windows requires raw disk I/O buffers to be 16-byte aligned and rejects others with ERROR_INVALID_PARAMETER (87). Most systems report 0x3, which hides the problem.
Code path (1.26.29, src/Common/BootEncryption.cpp):
-
BootEncryption::Install() calls InstallVolumeHeader(), which writes the 512-byte header at TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET.
-
That WriteFile fails with error 87. Because size % 4096 != 0, the 4K read-modify-write fallback in File::Write runs.
-
The fallback reads into File::ReadBuffer, which is not 16-byte aligned, so it fails the same way and throws at line 1024:
throw_sys_if (!ReadFile (Handle, ReadBuffer, 4096, &bytesRead, NULL) || (bytesRead != 4096));
On x64, ReadBuffer sits at offset 76 in the File class: vptr (8) + three bools (padded to 16) + FilePointerPosition (8) + Handle (8) + IsDevice
(padded to 40) + wstring Path (32) + LastError (4) = 76. That is 4-byte aligned but never 16-byte aligned. The same fallback code is still present
in master.
Suggested fix
- Minimal: align the member, e.g.
alignas(4096) BYTE ReadBuffer[4096];, so the existing fallback can succeed. - Complete: copy through an aligned bounce buffer (VirtualAlloc or _aligned_malloc, aligned to at least the sector size) in File::Read and
File::Write for all device I/O, since writes whose size is a multiple of 4096 from an unaligned caller buffer skip the fallback. - Optional: log the device AlignmentMask to make reports easier to diagnose.
Since most test hardware reports 0x3, a debug assertion that device I/O buffers are 16-byte aligned would catch these cases on any machine.
Ruled out
- Not Intel RST/VMD: controller is Microsoft Standard NVM Express Controller (stornvme).
- BitLocker fully decrypted, no third-party security software, EFI partition has 484 MB free.
- Not the Windows native NVMe stack (#1640): on the second affected Dell (KIOXIA, below), the disk is in the DiskDrive class, not NvmeDisk.
Related
- Forum thread with the original analysis and two more affected machines (Lenovo X1 Carbon Gen 14 / Samsung NVMe, ASUS Vivobook Go 15 / Micron UFS): https://sourceforge.net/p/veracrypt/discussion/technical/thread/a136c4a1b8/
- A second Dell Pro 5 14 (P514260) with a KIOXIA EG7 512GB NVMe SSD (firmware 12400102, PCIe 4.0 x4) also reports AlignmentMask = 0xF, so
this is not specific to one SSD vendor on this model. VeraCrypt has not been run on it, but BestCrypt Volume Encryption failed on it reading
sector 0. A vendor test build with alignment changes got past that point, which supports buffer alignment as the cause.
Steps to reproduce
- System > Encrypt System Partition/Drive (single boot, encrypt Windows partition)
- Complete the wizard up to the pretest restart prompt
- Click Yes
- The error appears before any reboot
Screenshots
None. The error text is quoted above.
Your Environment
Please tell us more about your environment
VeraCrypt version: 1.26.29
Operating system and version: Windows 11
System type: 64-bit
Hardware:
- Dell Pro 5 14 (P514260), UEFI, GPT
- SSD: SanDisk PC SN5100S 512GB (Dell OEM), firmware 35012203
- Sector size: logical 512, physical 4096
- Controller: Standard NVM Express Controller (stornvme)
- AlignmentMask: 0xF
I can test a build on the second Dell (KIOXIA) if that helps.
- Ngôn ngữ chính
- C
- Star
- 11.7k
- Fork
- 1.4k
- Merge trung bình
- 1 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 28
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của veracrypt/VeraCrypt
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 32/100
veracrypt/VeraCrypt#1995 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
veracrypt/VeraCrypt#1993 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Cache password no longer worksĐang mởbug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
veracrypt/VeraCrypt#1991 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của veracrypt/VeraCrypt
Issue tương tự
-
Signed/unsigned mix in the EOCD backward scan rejects valid archives with a 65535-byte commentĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug game: 01008BA02525A000 ios
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area/ysql kind/bug priority/medium status/awaiting-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
yugabyte/yugabyte-db#37523 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
ly05010419/MacNativeGames#2079 ·
Maintainer thường phản hồi trong vòng 1 ngày