Commit Graph

258 Commits

Author SHA1 Message Date
Ondrej Kozina
fb114d8d20 fix memleaks in lower level dm_query_device on error path 2017-08-26 11:43:31 +02:00
Milan Broz
d891e00f63 Add kernel keyring functions for volume key.
Code is written by Ondrej Kozina.

This patch adds ability to store volume key in kernel keyring
(feature available in recent kernels) and avoid setting
key through dm-ioctl and avoiding key in table mapping.

Will be used in LUKS2.

Signed-off-by: Milan Broz <gmazyland@gmail.com>
2017-08-06 21:30:51 +02:00
Milan Broz
01598028c4 Aff info function for integrity device and print info ion status. 2017-07-31 16:48:29 +02:00
Milan Broz
cf9428fba1 Fix typo in journal integrity processing. 2017-07-31 15:42:20 +02:00
Milan Broz
b16fbde032 Add DM_UDEV_DISABLE_LIBRARY_FALLBACK to libdevmapper wrapper.
This call is required for deferred removal of device.

Morever, if the system reports that udev is running, we should not
try to "fix" problems by creating or removing nodes directly through libdevmapper.

(Non-udev case should still work.)
2017-06-27 09:12:05 +02:00
Milan Broz
2c3e0aee08 And check libdevmapper support for deferred flag as well. 2017-06-24 19:37:28 +02:00
Milan Broz
552e9c8408 Check DM support for deferred flag.
So it fails correctly on older systems.
2017-06-24 19:07:14 +02:00
Milan Broz
3efa00d59a Revert deferred flag for keyslots and temp devices.
It could cause races later, replacing with error device is enough.
2017-06-24 09:57:22 +02:00
Milan Broz
ea694a4588 Fix force removal option. 2017-06-23 15:42:46 +02:00
Milan Broz
32d5e59ab6 Implement deferred removal of device.
This can be used in some automated systems and allows device
to be removed after the last user mapping closes it.
2017-06-23 14:41:54 +02:00
Milan Broz
40a9178c7f Rework detection of DM target flags.
Because there are already 3 targets used, the current detection
based only on dm-crypt is not sufficient.

Add new definition of dm_flags that allows separate target version detect.

Note: we do not want to load targets explicitly; instead, we repeats
detection after operation that could trigger target load.

If dm_flags() call fails, then the target is not yet loaded.
2017-06-01 09:28:09 +02:00
Ondrej Mosnáček
f786ed8505 Fix strncat usage
The 'strncat' function may write up to n + 1 bytes into destination, so
the 'n' parameter must be sizeof(dest) - strlen(dest) - 1. See [1] for
a nice explanation from US CERT.

[1] https://www.us-cert.gov/bsi/articles/knowledge/coding-practices/strncpy-and-strncat
2017-05-29 12:08:21 +02:00
Milan Broz
0bb7098fd8 Add integritysetup command line tool for the dm-integrity standalone setting.
The dm-integrity target is intended to be used for authenticated
encryption through LUKS and dm-crypt.

It can be used in standalone as well; for this use case there
is a simple configuration utility called integritysetup
(similar to veritysetup to dm-verity).
2017-05-28 09:22:17 +02:00
Milan Broz
c6a0048b9b Add check for FEC support in kernel dm-verity. 2017-04-05 15:16:13 +02:00
Milan Broz
3d6a589a04 Fix dm-verity max-size parameter. 2017-04-04 14:27:52 +02:00
Milan Broz
6c8b3686b4 Add FEC info to init_by_name.
And use it in veritysetup dump.
2017-04-03 13:55:20 +02:00
Milan Broz
fc0bef732b Add FEC offset parameter for verity. 2017-04-03 12:34:50 +02:00
Milan Broz
e8eab081c5 Add code for activation wirh FEC device. 2017-04-03 10:21:37 +02:00
Milan Broz
98368c4770 Update copyright years. 2017-03-12 13:17:15 +01:00
Milan Broz
4dd703ea6c Support activation options for error handling modes in dm-verity.
This patch adds veritysetup support for these Linux kernel dm-verity options:

  --ignore-corruption - dm-verity just logs detected corruption
  --restart-on-corruption - dm-verity restarts the kernel if corruption is detected

  If the options above are not specified, default behaviour for dm-verity remains.
  Default is that I/O operation fails with I/O error if corrupted block is detected.

  --ignore-zero-blocks - Instructs dm-verity to not verify blocks that are expected
   to contain zeroes and always return zeroes directly instead.

NOTE that these options could have serious security or functional impacts,
do not use them without assessing the risks!
2016-05-04 10:07:47 +02:00
Ondrej Kozina
03d9db921b Fix hang in low level device-mapper code.
udev cookies should be set right in before the dm_task_run()
call otherwise we risk a hang while waiting for a cookie
associated with not yet executed dm task.

For example: failing to add table line (dm_task_add_target())
results in such hang.
2016-01-02 21:06:15 +01:00
Milan Broz
dc3de39eb7 Include prototype for stat(). 2015-03-23 20:38:14 +01:00
Milan Broz
d7d76e72f7 Update URLs (->gitlab.com).
The code.google is going to be abandoned.
Thank you you for all the fish.
2015-03-19 11:23:16 +01:00
Milan Broz
4f7b413638 Add low-level performance options for dmcrypt tuning.
The patch adds the two options
  --perf-same_cpu_crypt
  --perf-submit_from_crypt_cpus
that set the same named options inside dmcrypt
(available in Linux kernel 3.20 and later).
2015-02-20 16:46:34 +01:00
Milan Broz
3762c8b76e Report crypto lib version only once (and add kernel version). 2014-07-27 20:39:06 +02:00
Milan Broz
59fdf2a6bb Properly allow activation of discard even if dm_crypt module is not yet loaded.
The dm_flags() call cannot be used if dmcrypt module is not present.

Better try to activate volume with dicard flags and if it is not possible,
try to activate device without the discard flag.
2014-07-24 22:11:58 +02:00
Milan Broz
3640eaa726 Re-check flags after DM device creations. 2014-07-24 11:52:58 +02:00
Milan Broz
2250d5f71f Move safe table params wipe into function which allocates it. 2014-07-24 11:37:24 +02:00
Milan Broz
bb8dbfdf5b Update author name. 2014-06-23 21:40:12 +02:00
Milan Broz
cad0cbf0c8 Fix integer type warnings in debug log. 2014-04-13 16:41:29 +02:00
Dave Reisner
18901fd501 libdevmapper: correctly compare major and minor versions
Previously, this code could incorrectly identify a version of crypt or
dm due to the way it compared versions. For example, if a feature was
gated on crypt version 1.5, it would disable the feature for crypt
version 2.2.
2013-11-14 08:32:02 +01:00
Milan Broz
5b86cb5cc2 Enable TCW dmcrypt version check (patch should be in kernel 3.13). 2013-11-10 22:20:30 +01:00
Milan Broz
54c1f71bd3 Detect presence of TCW mode support in kernel dmcrypt. 2013-10-20 13:20:22 +02:00
Milan Broz
3f66e9fe4b Fix error path for DM UUID wrong format. 2013-10-20 13:06:16 +02:00
Milan Broz
db0f5f8d22 Add kernel version to DM debug output. 2013-06-29 11:28:33 +02:00
Milan Broz
72db6e4de2 Do not support user uuid for plain & loopaes devices.
This function was not documented.
So now crypt_get_uuid() returns only on-disk UUID.
2013-01-22 16:20:09 +01:00
Milan Broz
0946c704bf Fix status of device if path argument is used. Fix double path prefix for non-existent device path. 2012-12-30 11:48:30 +01:00
Milan Broz
29f21208a0 Change License from GPLv2 only to GPLv2+ ("or any later").
Agreed by all copyright authors.
2012-12-29 11:33:54 +01:00
Milan Broz
83f02e6682 Add copyright line for files I have written or modified. 2012-12-21 16:40:33 +01:00
Milan Broz
af2730fe2a Always zero memory in crypt_safe_alloc. 2012-08-27 16:28:00 +02:00
Milan Broz
1d5788f779 Set context for DM log for all DM backend entries.
Try to handle error if run as non-root user better.
2012-08-14 19:17:13 +02:00
Milan Broz
97224b072a Add context to DM helpers.
(To be used later.)
2012-08-14 16:25:21 +02:00
Milan Broz
65f975655c New device access backend.
Allocate loop device late (only when real block device needed).
Rework underlying device/file access functions.
Move all device (and ioctl) access to utils_device.c.

Allows using file where appropriate without allocation loop device.
2012-08-12 22:00:17 +02:00
Milan Broz
4abfd38169 Remove open device debugging feature (no longer needed). 2012-06-26 12:55:14 +02:00
Milan Broz
a9d9a2ad44 Fix hex_to_bytes and add it to common utils. 2012-06-18 17:09:48 +02:00
Milan Broz
6d2c15ea79 Avoid some clang warnings. 2012-06-10 19:55:43 +02:00
Milan Broz
4b8f91d0d9 Remove some compilation warnings. 2012-06-10 18:56:04 +02:00
Milan Broz
697c6c9324 Prepare new superblock format. 2012-06-09 22:02:06 +02:00
Milan Broz
6d07be898d Enhance status of active device. 2012-06-09 18:28:00 +02:00
Milan Broz
ade21e6c60 Support empty salt for verity, support no superblock. 2012-06-09 13:12:04 +02:00