RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2056439 - While online reencrypt is started, test-passphrase exits with exit code 1
Summary: While online reencrypt is started, test-passphrase exits with exit code 1
Keywords:
Status: CLOSED ERRATA
Alias: None
Deadline: 2022-02-28
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: cryptsetup
Version: 9.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: beta
: 9.0
Assignee: Ondrej Kozina
QA Contact: guazhang@redhat.com
URL:
Whiteboard:
Depends On:
Blocks: 2058009
TreeView+ depends on / blocked
 
Reported: 2022-02-21 08:49 UTC by Patrick Uiterwijk
Modified: 2022-06-07 03:16 UTC (History)
6 users (show)

Fixed In Version: cryptsetup-2.4.3-4.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2058009 (view as bug list)
Environment:
Last Closed: 2022-05-17 15:48:06 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-112893 0 None None None 2022-02-21 08:58:00 UTC
Red Hat Product Errata RHBA-2022:3913 0 None None None 2022-05-17 15:48:21 UTC

Description Patrick Uiterwijk 2022-02-21 08:49:08 UTC
Description of problem:
When executing an open with --test-passphrase on a disk that has started the progress of online reencryption (but is unmounted), the test correctly identifies the passphrase is correct, but it exits with exit code 1.
This seems to have to do with the validation of the digests of the in-reencrypt volume.
This breaks clevis automatically decrypting the volume if it was unmounted in the midst of a reencrypt, because clevis only looks at the exit code of an "open --test-passhrase" to see whether the password was correct.


Version-Release number of selected component (if applicable):
cryptsetup-2.4.3-1.el9.x86_64


How reproducible:
Consistent

Steps to Reproduce:
1. truncate -s 1G testdisk
2. cryptsetup luksFormat ./testdisk --force-password
3. cryptsetup open --test-passphrase ./testdisk (exit code = 0)
4. cryptsetup reencrypt ./testdisk --init-only
5. cryptsetup open --test-passphrase ./testdisk (exit code = 1)


Actual results:
The passphrase is recognized as correct, but the process exits with exit code 1.

Expected results:
The passphrase is recognized as correct, and the process exits with exit code 0.

Additional info:

bash-5.1# cryptsetup luksDump ./testdisk
LUKS header information
Version:       	2
Epoch:         	5
Metadata area: 	16384 [bytes]
Keyslots area: 	16744448 [bytes]
UUID:          	ea47846d-c566-4911-bc7c-10682257f78e
Label:         	(no label)
Subsystem:     	(no subsystem)
Flags:       	(no flags)
Requirements:	online-reencrypt-v2 

Data segments:
  0: crypt
	offset: 16777216 [bytes]
	length: (whole device)
	cipher: aes-xts-plain64
	sector: 4096 [bytes]

  1: crypt
	offset: 16777216 [bytes]
	length: (whole device)
	cipher: aes-xts-plain64
	sector: 4096 [bytes]
	flags : backup-previous

  2: crypt
	offset: 16777216 [bytes]
	length: (whole device)
	cipher: aes-xts-plain64
	sector: 4096 [bytes]
	flags : backup-final

Keyslots:
  0: luks2
	Key:        512 bits
	Priority:   normal
	Cipher:     aes-xts-plain64
	Cipher key: 512 bits
	PBKDF:      argon2id
	Time cost:  4
	Memory:     681075
	Threads:    1
	Salt:       17 ee 9b 22 e8 bb bd 10 f1 75 4a 0c 3a a8 33 15 
	            65 5b bf a7 37 d4 69 f2 fa 65 da 61 c2 92 2e b7 
	AF stripes: 4000
	AF hash:    sha256
	Area offset:32768 [bytes]
	Area length:258048 [bytes]
	Digest ID:  0
  1: luks2 (unbound)
	Key:        512 bits
	Priority:   normal
	Cipher:     aes-xts-plain64
	Cipher key: 512 bits
	PBKDF:      argon2id
	Time cost:  4
	Memory:     681075
	Threads:    1
	Salt:       53 e2 65 25 83 5e c1 c4 08 c6 cf 32 5b ac 87 84 
	            b8 e2 99 4e 0f d9 22 7e e2 43 e2 b8 1d 37 e3 75 
	AF stripes: 4000
	AF hash:    sha256
	Area offset:290816 [bytes]
	Area length:258048 [bytes]
	Digest ID:  1
  2: reencrypt (unbound)
	Key:        8 bits
	Priority:   ignored
	Mode:       reencrypt
	Direction:  forward
	Resilience: none
	Area offset:548864 [bytes]
	Area length:16228352 [bytes]
	Digest ID:  2
Tokens:
Digests:
  0: pbkdf2
	Hash:       sha256
	Iterations: 85111
	Salt:       de b6 4c 29 97 af 6e 4a bf a2 a6 d8 ea e9 c8 86 
	            cc 98 36 7d 36 6e 1b 3c e5 ed 93 65 68 16 c9 ee 
	Digest:     13 42 20 d0 8a f0 d8 b7 72 f5 04 2b 1f ea 03 84 
	            a8 35 16 55 94 0c 6a 61 88 fb 09 04 4c f1 ce 24 
  1: pbkdf2
	Hash:       sha256
	Iterations: 1000
	Salt:       df de 75 04 14 80 01 b6 85 fb ef 66 94 fc f2 7b 
	            46 75 b1 be 81 d0 9a 12 3d 69 18 33 ac 77 6a cb 
	Digest:     c8 02 f8 fd dd ad f3 08 4f 16 77 80 38 65 81 bb 
	            0f 1b 0a 43 82 60 73 a6 3b a4 42 64 83 35 d7 0d 
  2: pbkdf2
	Hash:       sha256
	Iterations: 1000
	Salt:       2d 41 8d e8 1a 39 91 96 6f d8 c7 ae 09 dd 3a c6 
	            de 2c 19 24 17 47 c5 65 c7 58 3c 93 05 84 7d 5e 
	Digest:     17 03 91 a3 a4 06 5c e2 07 c0 84 0f 9e 0f ee 7a 
	            ff eb fd 7f a4 0b 80 9a be dc bf 58 c7 d7 99 f3 



bash-5.1# cryptsetup open --test-passphrase ./testdisk --debug-json
# cryptsetup 2.4.3 processing "cryptsetup open --test-passphrase ./testdisk --debug-json"
# Running command open.
# Locking memory.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
# Allocating context for crypt device ./testdisk.
# Trying to open and read device ./testdisk with direct-io.
# Initialising device-mapper backend library.
# Trying to load any crypt type from device ./testdisk.
# Crypto backend (OpenSSL 3.0.1 14 Dec 2021 [default][legacy]) initialized in cryptsetup library version 2.4.3.
# Detected kernel Linux 5.14.0-56.kpq0.el9.x86_64 x86_64.
# Loading LUKS2 header (repair disabled).
# Acquiring read lock for device ./testdisk.
# Verifying lock handle for ./testdisk.
# Device ./testdisk READ lock taken.
# Trying to read primary LUKS2 header at offset 0x0.
# Opening locked device ./testdisk
# Verifying locked device handle (regular file)
# LUKS2 header version 2 of size 16384 bytes, checksum sha256.
# Checksum:e4e4df76630d50a283700bf7629f035611e0316b3b100b6c3ac786be7d20b386 (on-disk)
# Checksum:e4e4df76630d50a283700bf7629f035611e0316b3b100b6c3ac786be7d20b386 (in-memory)
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# Trying to read secondary LUKS2 header at offset 0x4000.
# Reusing open ro fd on device ./testdisk
# LUKS2 header version 2 of size 16384 bytes, checksum sha256.
# Checksum:e9031cfbb9642105b352eccc3a2cfbb551c384133e6042db8a53fe7face16872 (on-disk)
# Checksum:e9031cfbb9642105b352eccc3a2cfbb551c384133e6042db8a53fe7face16872 (in-memory)
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# Device size 1073741824, offset 16777216.
# Device ./testdisk READ lock released.
# Only 1 active CPUs detected, PBKDF threads decreased from 4 to 1.
# Not enough physical memory detected, PBKDF max memory decreased from 1048576kB to 1007122kB.
# PBKDF argon2id, time_ms 2000 (iterations 0), max_memory_kb 1007122, parallel_threads 1.
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# Checking volume passphrase using token (any type) -1.
No usable token is available.
# Interactive passphrase entry requested.
Enter passphrase for ./testdisk: 
# Checking volume passphrase [keyslot -1] using passphrase.
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# Keyslot 0 priority 1 != 2 (required), skipped.
# Keyslot 1 priority 1 != 2 (required), skipped.
# Keyslot 2 priority 0 != 2 (required), skipped.
# Trying to open LUKS2 keyslot 0.
# Running keyslot key derivation.
# Reading keyslot area [0x8000].
# Acquiring read lock for device ./testdisk.
# Verifying lock handle for ./testdisk.
# Device ./testdisk READ lock taken.
# Reusing open ro fd on device ./testdisk
# Device ./testdisk READ lock released.
# Verifying key from keyslot 0, digest 0.
# Releasing crypt device ./testdisk context.
# Releasing device-mapper backend.
# Closing read only fd for ./testdisk.
# Unlocking memory.
Command failed with code -1 (wrong or missing parameters).
bash-5.1# cryptsetup open --test-passphrase ./testdisk --debug-json --debug
# cryptsetup 2.4.3 processing "cryptsetup open --test-passphrase ./testdisk --debug-json --debug"
# Running command open.
# Locking memory.
# Installing SIGINT/SIGTERM handler.
# Unblocking interruption on signal.
# Allocating context for crypt device ./testdisk.
# Trying to open and read device ./testdisk with direct-io.
# Initialising device-mapper backend library.
# Trying to load any crypt type from device ./testdisk.
# Crypto backend (OpenSSL 3.0.1 14 Dec 2021 [default][legacy]) initialized in cryptsetup library version 2.4.3.
# Detected kernel Linux 5.14.0-56.kpq0.el9.x86_64 x86_64.
# Loading LUKS2 header (repair disabled).
# Acquiring read lock for device ./testdisk.
# Verifying lock handle for ./testdisk.
# Device ./testdisk READ lock taken.
# Trying to read primary LUKS2 header at offset 0x0.
# Opening locked device ./testdisk
# Verifying locked device handle (regular file)
# LUKS2 header version 2 of size 16384 bytes, checksum sha256.
# Checksum:e4e4df76630d50a283700bf7629f035611e0316b3b100b6c3ac786be7d20b386 (on-disk)
# Checksum:e4e4df76630d50a283700bf7629f035611e0316b3b100b6c3ac786be7d20b386 (in-memory)
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# Trying to read secondary LUKS2 header at offset 0x4000.
# Reusing open ro fd on device ./testdisk
# LUKS2 header version 2 of size 16384 bytes, checksum sha256.
# Checksum:e9031cfbb9642105b352eccc3a2cfbb551c384133e6042db8a53fe7face16872 (on-disk)
# Checksum:e9031cfbb9642105b352eccc3a2cfbb551c384133e6042db8a53fe7face16872 (in-memory)
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# Device size 1073741824, offset 16777216.
# Device ./testdisk READ lock released.
# Only 1 active CPUs detected, PBKDF threads decreased from 4 to 1.
# Not enough physical memory detected, PBKDF max memory decreased from 1048576kB to 1007122kB.
# PBKDF argon2id, time_ms 2000 (iterations 0), max_memory_kb 1007122, parallel_threads 1.
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# Checking volume passphrase using token (any type) -1.
No usable token is available.
# Interactive passphrase entry requested.
Enter passphrase for ./testdisk: 
# Checking volume passphrase [keyslot -1] using passphrase.
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# LUKS2 requirements detected:
# online-reencrypt-v2 - known
# Keyslot 0 priority 1 != 2 (required), skipped.
# Keyslot 1 priority 1 != 2 (required), skipped.
# Keyslot 2 priority 0 != 2 (required), skipped.
# Trying to open LUKS2 keyslot 0.
# Running keyslot key derivation.
# Reading keyslot area [0x8000].
# Acquiring read lock for device ./testdisk.
# Verifying lock handle for ./testdisk.
# Device ./testdisk READ lock taken.
# Reusing open ro fd on device ./testdisk
# Device ./testdisk READ lock released.
# Verifying key from keyslot 0, digest 0.
# Releasing crypt device ./testdisk context.
# Releasing device-mapper backend.
# Closing read only fd for ./testdisk.
# Unlocking memory.
Command failed with code -1 (wrong or missing parameters).

Comment 4 guazhang@redhat.com 2022-02-23 10:39:03 UTC
Hi,

Reproduce the bug with cryptsetup-2.4.3-1.el9.x86_64.


[root@dell-r430-22 ~]# truncate -s 1G testdisk
[root@dell-r430-22 ~]# cryptsetup luksFormat ./testdisk --force-password

WARNING!
========
This will overwrite data on ./testdisk irrevocably.

Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for ./testdisk: 
Verify passphrase: 
[root@dell-r430-22 ~]# cryptsetup open --test-passphrase ./testdisk 
Enter passphrase for ./testdisk: 
[root@dell-r430-22 ~]# $?
-bash: 0: command not found
[root@dell-r430-22 ~]# cryptsetup reencrypt ./testdisk --init-only
Enter passphrase for key slot 0: 
[root@dell-r430-22 ~]# $?
-bash: 0: command not found
[root@dell-r430-22 ~]# cryptsetup open --test-passphrase ./testdisk
Enter passphrase for ./testdisk: 
[root@dell-r430-22 ~]# $?
-bash: 1: command not found
[root@dell-r430-22 ~]#

Comment 5 Ondrej Kozina 2022-02-23 12:25:20 UTC
Upstream fix: https://gitlab.com/cryptsetup/cryptsetup/-/merge_requests/289

Comment 9 guazhang@redhat.com 2022-02-24 09:43:36 UTC
Test pass with the fixed package.
cryptsetup-2.4.3-3.el9.x86_64

[root@dell-r430-22 home]# cryptsetup luksFormat ./testdisk --force-password
WARNING: Device ./testdisk already contains a 'crypto_LUKS' superblock signature.

WARNING!
========
This will overwrite data on ./testdisk irrevocably.

Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for ./testdisk: 
Verify passphrase: 
[root@dell-r430-22 home]# cryptsetup open --test-passphrase ./testdisk
Enter passphrase for ./testdisk: 
[root@dell-r430-22 home]# cryptsetup reencrypt ./testdisk --init-only
Enter passphrase for key slot 0: 
[root@dell-r430-22 home]# $?
-bash: 0: command not found
[root@dell-r430-22 home]# cryptsetup open --test-passphrase ./testdisk
Enter passphrase for ./testdisk: 
[root@dell-r430-22 home]# $?
-bash: 0: command not found
[root@dell-r430-22 home]#

Comment 10 guazhang@redhat.com 2022-02-24 10:06:24 UTC

[root@dell-r430-22 home]# cryptsetup luksFormat ./testdisk --force-password
WARNING: Device ./testdisk already contains a 'crypto_LUKS' superblock signature.

WARNING!
========
This will overwrite data on ./testdisk irrevocably.

Are you sure? (Type 'yes' in capital letters): YES
Enter passphrase for ./testdisk: 
Verify passphrase: 
[root@dell-r430-22 home]# $?
-bash: 0: command not found
[root@dell-r430-22 home]# cryptsetup open --test-passphrase ./testdisk 
Enter passphrase for ./testdisk: 
[root@dell-r430-22 home]# $?
-bash: 0: command not found
[root@dell-r430-22 home]#  cryptsetup reencrypt ./testdisk --init-only
Enter passphrase for key slot 0: 
[root@dell-r430-22 home]# $?
-bash: 0: command not found
[root@dell-r430-22 home]# cryptsetup open --test-passphrase ./testdisk
Enter passphrase for ./testdisk: 
[root@dell-r430-22 home]# $?
-bash: 0: command not found
[root@dell-r430-22 home]# rpm -qa |grep cryptsetup
cryptsetup-libs-2.4.3-4.el9.x86_64
cryptsetup-2.4.3-4.el9.x86_64
cryptsetup-devel-2.4.3-4.el9.x86_64
[root@dell-r430-22 home]#

Comment 14 errata-xmlrpc 2022-05-17 15:48:06 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: cryptsetup), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:3913


Note You need to log in before you can comment on or make changes to this bug.