Commit Graph

4353 Commits

Author SHA1 Message Date
Ondrej Kozina
a321068e8d Add compile_commands.json file to .gitignore.
The file is used to describe project compilation independent
of build system in use.

It can also help LSP servers to improve code suggestions since
it can see how the project is configured and respect, for example,
content of config.h file.
2025-02-04 16:13:08 +01:00
Milan Broz
e257def910 Remove redundant check for dm-integrity mapping table params section.
The dm-integrity table always contains number of feature arguments
(since introduction in kernel 4.12).

Moreover, the code already dereferences params field, so the test
make no sense.

Found by CodeQL check.
2025-01-28 13:03:10 +00:00
Milan Broz
c9008528f9 tests: Remove function xx() bashism.
Posix does not use function keyword, moreover, we use it inconsistently.
2025-01-27 20:43:33 +01:00
Milan Broz
3d535dcf31 tests: Add trap for segfault and sigabrt
If bash test script uses a pattern that test that command should fail
  command && fail
(IOW fail function is called only if command exited successfully),
it can mask potential segfault, as it return non-zero exit code.

Fix it by using trap for scripts that uses this pattern.

The same applies for SIGABRT (abort() call).
2025-01-27 20:42:25 +01:00
Milan Broz
a45fb0a90d Do not include dlfcn.h if external token support is disabled.
Fixes: #925
2025-01-27 12:33:52 +00:00
Milan Broz
06c0f03c9f Add a note regarding use of #if for config.h processing. 2025-01-27 11:05:08 +00:00
Milan Broz
c6a7849090 Use #if for password quality libs defines. 2025-01-27 11:05:08 +00:00
Milan Broz
29741d91e6 Use #if in bitops.h. 2025-01-27 11:05:08 +00:00
Milan Broz
1e441bf75c Use #if for rest of defines. 2025-01-27 11:05:08 +00:00
Milan Broz
d9404821a6 Use #if for HAVE_BLKID_* defines. 2025-01-27 11:05:08 +00:00
Milan Broz
e5405f2fd8 Use #if for HAVE*_H defines. 2025-01-27 11:05:08 +00:00
Milan Broz
37d52876b9 Use #if for other ENABLE* options. 2025-01-27 11:05:08 +00:00
Milan Broz
ff81791308 Use #if for ENABLE_AF_ALG. 2025-01-27 11:05:08 +00:00
Milan Broz
c21c746eff Use #if for USE_UDEV. 2025-01-27 11:05:08 +00:00
Milan Broz
bb304f45bd Use #if for KERNEL_KEYRING. 2025-01-27 11:05:08 +00:00
Milan Broz
f64f6fb9e8 opal: Fix error table offset
The error table was partially wrong (for codes >0x0b)

Let's use exact enum codes according to TCG Core spec (5.1.5).

This also fixes CodeQL warning.
2025-01-27 11:04:25 +00:00
Milan Broz
5c795885c5 opal: update copyright 2025-01-27 11:04:25 +00:00
Milan Broz
6a8f88ea99 Fix leaks detected by Coverity. 2025-01-27 09:11:40 +00:00
Milan Broz
7ffa8ee28a Fix integer cast for sector_size.
Found by Coverity scan.
2025-01-27 09:11:40 +00:00
Milan Broz
2691514547 Print message about reaching maximal interactive passphrase to error output.
Reaching maximal keyfile size is already reported as error.

Note that interactive really means user entering password.

For all other us there is keyfile processing.

Related: #933
2025-01-26 10:10:27 +01:00
Milan Broz
36574dd114 Avoid if (not NULL) free().
This fixes some COdeQL warnings.
2025-01-16 15:54:09 +01:00
Milan Broz
8364178b38 Update copyright year. 2025-01-15 23:09:36 +01:00
Milan Broz
2a880f838a ci: Update and fix GitHub actions 2025-01-15 17:07:18 +01:00
Milan Broz
e6208a12b5 ci: Update CodeQL GitHub CI config 2025-01-15 15:06:06 +01:00
Milan Broz
b54e5ce9f0 ci: Fix GitHub CI build 2025-01-15 15:03:10 +01:00
Milan Broz
bfae421c52 bitlk: Clarify activation error message if clear key is present.
Fixes: #929
2025-01-15 13:35:29 +01:00
Milan Broz
33ebb36f71 tests: check for xxd binary in validation test 2024-12-23 22:07:09 +01:00
Gabi Falk
64fb1c1b26 tests/compat-test: Adjust test for compatibility with passwdqc
Unlike libpwquality, passwdqc does not consider 'compatkey' a strong
password and rejects 512 character long passwords.

Closes: https://gitlab.com/cryptsetup/cryptsetup/-/issues/928
Signed-off-by: Gabi Falk <gabifalk@gmx.com>
2024-12-22 16:00:00 +00:00
Milan Broz
b18cefcc71 Detect out of memory in KDF in keyslot derivation.
For OpenSSL and gcrypt we can detect that Argon2 failed on malloc,
report it to user (and return ENOMEM instead of EINVAL).
2024-12-12 22:45:21 +00:00
Milan Broz
7cabaa5d70 pbkdf: Do not allow memory cost that cannot be used in size_t
For 32bit platforms size_t is 32bit integer and unfortunately
our maximum hard limit overflows by 1.

Stop validation if this happens (it cannot be passed to malloc()
and similar functions anyway).

There should be no compatibility change, as such memory
is not allocatable on 32bit anyway.
Other platforms have 64bit size_t.
2024-12-12 22:45:21 +00:00
Milan Broz
b201a62987 Add a note about OPAL PSID sensitivity to manual pages. 2024-12-12 22:44:35 +00:00
Milan Broz
f8788f347e Mark all sizes in status and dump output in the correct units.
NOTE: This is possibly an incompatible change as it changes text output.

Since the support of --sector-size option, the description "sectors"
became ambiguous as it usually means 512-byte sectors (device-mapper unit).

Major confusion occurs when the sector size is 4096 bytes while units display
is in 512-bytes.

Unfortunately, there is no clear compatible way, so this patch adds
[512-byte units] marker and also additional byte size value.

All other fields that display units are changed to use the "[units]" format.

The integrity format is also unified with the common style with ':' as a separator.

Fixes: #884.
2024-12-12 15:56:00 +00:00
Milan Broz
ea39aecba3 Add integrity key tests. 2024-12-03 20:28:07 +01:00
Milan Broz
5eda5f6a38 Fix compatibility for older dmcrypt without integrity_key_size
For older kernel an default HMAC key size we must not set
integrity_key_size option.
2024-12-03 20:28:00 +01:00
Milan Broz
b5672053f5 Use real integrity key size in format operation.
For now, we used zeroed key for dm-integrity format, as there was not
data area. In future, there can be wrapped key scheme, that will require
to setup real key even in this situation.

This patch modifies the integrity format flow that the real key is used
during format.

Mostly based on code from Ingo Franzki <ifranzki@linux.ibm.com>
2024-12-03 20:27:16 +01:00
Milan Broz
491f31c4d4 Add --integrity-key-size option to cryptsetup.
This patch adds support for --integrity-key-size option that can be used
to setup non-standard HMAC integrity key size.
2024-12-03 20:25:54 +01:00
Milan Broz
7b5ac650e5 Allow specific integrity key size.
This patch add support for setting of integrity key size
for LUKS2 devices.

It adds new (optional) JSON "key_size" attribute in segment.integrity JSON object.
If not set, the code use hash length size (backward compatible).

For LUKS2, we do not allow smaller keys than 128 bits.

Mostly based on code from Ingo Franzki <ifranzki@linux.ibm.com>
2024-12-03 20:25:54 +01:00
Milan Broz
ff3e2c6a43 libdevmapper: Support dm-crypt integrity_key_size option
This patch implement support for setting specific integrity key size
option in dm-crypt, available since dm-crypt version 1.28.0.

This can be used for setting non-standard HMAC key length.

Mostly based on code from Ingo Franzki <ifranzki@linux.ibm.com>
2024-12-03 20:25:54 +01:00
Ondrej Kozina
1bea029cef Lock volume key structure in memory.
This was probably oversight in original commit
introducing support for selective memory locking
on sensitive data only.

Fixes: db65a5ceac
2024-12-03 13:33:59 +01:00
Milan Broz
ecb1326e0e CI: Disable annocheck run.
It is currently broken.
2024-11-29 10:18:45 +01:00
Milan Broz
690c22ac7b Switch isLUKS() testing order to avoid static analysis scan confusion.
There is no functional change in this patch except it avoids
strange confusion during some static tests.

The cd->type must be set in this function anyway.
2024-11-28 10:41:18 +01:00
Ondrej Kozina
9f1aee46d5 Rename 'keyring' member to 'keyring_key_type' in volume_key.
The keyring field is misleading since the
field indeed contains the type identification
id.
2024-11-27 12:24:59 +01:00
Milan Broz
82bee1c52d test: Skip trusted test if keyctl cannot load user key.
Some very old systems do not support -x option for keyctl,
skip the test in this case.
2024-11-26 12:20:00 +01:00
Milan Broz
0805cc025d test: Run keyring trusted/encrypted test in CI.
And install dependencies unconditionally.
2024-11-25 14:56:00 +01:00
Milan Broz
9d03e5987c Add trusted/encrypted keyring test (for plain format). 2024-11-25 14:55:55 +01:00
Milan Broz
768bca1df5 Support plain resize with keyring key. 2024-11-25 14:55:51 +01:00
Milan Broz
4b7920975c Support trusted & encrypted keyring for plain device. 2024-11-25 14:55:47 +01:00
Milan Broz
42e85571df Move keyring utilities to separate file. 2024-11-25 14:55:43 +01:00
Milan Broz
ae4b4ff4d7 Unlink only volume keys that were previously stored in keyring.
This is only preparation for an extension later, however, the volume
keys should not be unloaded unconditionally from keyring.

Note that all other places dropping keys already check that keys
were uploaded through key ID setting.
(And for suspend unconditional unlink make sense too.)
2024-11-25 13:20:36 +01:00
Milan Broz
9575dadc8b Store keyring type in volume key.
The key_decripion always contains only a key name,
keyring then contains type of keyring as defned un keyring utils.

For now, only LOGON type is used in commands, it will be extended later.
2024-11-25 13:19:42 +01:00