~ubuntu-branches/ubuntu/saucy/lvm2/saucy

« back to all changes in this revision

Viewing changes to doc/kernel/verity.txt

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-05-30 11:02:10 UTC
  • mfrom: (3.1.28 sid)
  • Revision ID: package-import@ubuntu.com-20130530110210-q8bou4f333ruwhn0
Tags: 2.02.98-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/patches/avoid-dev-block.patch: Prefer any other device name over
    names in /dev/block/ since lvm.conf won't handle this.
  - debian/rules:
    - copy .po file to .pot file for Rosetta (Ubuntu specific).
  - debian/{dmsetup,lvm2}-udeb.install:
    - install initramfs and udev hooks in udebs (Debian bug 504341).
  - auto-start VGs as their PVs are discovered (Ubuntu specific):
    - add debian/tree/lvm2/lib/udev/rules.d/85-lvm2.rules: use watershed plus
      the sledgehammer of vgscan/vgchange to turn on VGs as they come online.
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/hooks/lvm2:
      - add 85-lvm2.rules to the list of udev rules to copy.
      - depend on udev.
    - debian/control:
      - add versioned Depend on watershed in lvm2 for udev rules.
      - add Depends on watershed-udeb in lvm2-udeb for udev rules.
      - add versioned Depend/Breaks on udev in dmsetup for udev rules.
      - add Depend on initramfs-tools in dmsetup so system is not potentially
        rendered unbootable by out-of-order dpkg configuration.
      - In libdevmapper-event1.02.1 add Breaks: dmeventd
        (<< 2.02.95-4ubuntu1) due to debian symbol rename
    - debian/rules:
      - do not install local-top scripts since Ubuntu mounts root using udev.
      - do not install init scripts for lvm2, since udev starts LVM.
      - continue to build clvm support.
    - debian/lvm2.postinst: handle missing lvm2 init script.
    - debian/tree/dmsetup/lib/udev/rules.d/60-persistent-storage-dm.rules:
      watch dm devices for changes with inotify
  - add mountroot failure hooks to help fix bad boots (Debian bug 468115):
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/init-premount/lvm2
  - remaining changes to upstream event manager packages (Debian bug 514706):
    - debian/rules:
      - enable dmeventd during configure.
    - debian/dmeventd.{8,manpages}: install dmeventd files.
  - rename debian/clvm.defaults to debian/clvm.default so it is installed
    correctly.
  - debian/control: add dmsetup-udeb to libdevmapper1.02.1-udeb recommends.
  - debian/rules: make sure dmsetup and lvm2 initramfs-tools scripts are
    executable.  When the Ubuntu-specific ones are added with a patch,
    they may lose their executable bit.
  - Add and install clvmd resource agent
  - Add dependency on libudev-dev to libdevmapper-dev so that the .pc file
    works.
  - debian/{clvmd.ra,clvm.init}:
    - create /run/lvm if it doesn't exist.
  - debian/clvm.init:
    - exit 3 if not running on status action.
  - Call dh_installman so that our dmeventd manpage actually gets installed
  - Install the missing fsadm manpage.
  - Complete libdevmapper-dev multiarch:
    - move .so symlinks and pkgconfig files to multiarched locations.
    - mark libdevmapper-dev M-A: same

* Dropped changes, applied upstream:
  - Update Micron PCIe SSD and other device-types to latest available.
  - Cherry pick from upstream, remove unsupported udev_get_dev_path() call.
  - Move thin check to global section.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dm-verity
 
2
==========
 
3
 
 
4
Device-Mapper's "verity" target provides transparent integrity checking of
 
5
block devices using a cryptographic digest provided by the kernel crypto API.
 
6
This target is read-only.
 
7
 
 
8
Construction Parameters
 
9
=======================
 
10
    <version> <dev> <hash_dev>
 
11
    <data_block_size> <hash_block_size>
 
12
    <num_data_blocks> <hash_start_block>
 
13
    <algorithm> <digest> <salt>
 
14
 
 
15
<version>
 
16
    This is the type of the on-disk hash format.
 
17
 
 
18
    0 is the original format used in the Chromium OS.
 
19
      The salt is appended when hashing, digests are stored continuously and
 
20
      the rest of the block is padded with zeros.
 
21
 
 
22
    1 is the current format that should be used for new devices.
 
23
      The salt is prepended when hashing and each digest is
 
24
      padded with zeros to the power of two.
 
25
 
 
26
<dev>
 
27
    This is the device containing data, the integrity of which needs to be
 
28
    checked.  It may be specified as a path, like /dev/sdaX, or a device number,
 
29
    <major>:<minor>.
 
30
 
 
31
<hash_dev>
 
32
    This is the device that supplies the hash tree data.  It may be
 
33
    specified similarly to the device path and may be the same device.  If the
 
34
    same device is used, the hash_start should be outside the configured
 
35
    dm-verity device.
 
36
 
 
37
<data_block_size>
 
38
    The block size on a data device in bytes.
 
39
    Each block corresponds to one digest on the hash device.
 
40
 
 
41
<hash_block_size>
 
42
    The size of a hash block in bytes.
 
43
 
 
44
<num_data_blocks>
 
45
    The number of data blocks on the data device.  Additional blocks are
 
46
    inaccessible.  You can place hashes to the same partition as data, in this
 
47
    case hashes are placed after <num_data_blocks>.
 
48
 
 
49
<hash_start_block>
 
50
    This is the offset, in <hash_block_size>-blocks, from the start of hash_dev
 
51
    to the root block of the hash tree.
 
52
 
 
53
<algorithm>
 
54
    The cryptographic hash algorithm used for this device.  This should
 
55
    be the name of the algorithm, like "sha1".
 
56
 
 
57
<digest>
 
58
    The hexadecimal encoding of the cryptographic hash of the root hash block
 
59
    and the salt.  This hash should be trusted as there is no other authenticity
 
60
    beyond this point.
 
61
 
 
62
<salt>
 
63
    The hexadecimal encoding of the salt value.
 
64
 
 
65
Theory of operation
 
66
===================
 
67
 
 
68
dm-verity is meant to be set up as part of a verified boot path.  This
 
69
may be anything ranging from a boot using tboot or trustedgrub to just
 
70
booting from a known-good device (like a USB drive or CD).
 
71
 
 
72
When a dm-verity device is configured, it is expected that the caller
 
73
has been authenticated in some way (cryptographic signatures, etc).
 
74
After instantiation, all hashes will be verified on-demand during
 
75
disk access.  If they cannot be verified up to the root node of the
 
76
tree, the root hash, then the I/O will fail.  This should detect
 
77
tampering with any data on the device and the hash data.
 
78
 
 
79
Cryptographic hashes are used to assert the integrity of the device on a
 
80
per-block basis. This allows for a lightweight hash computation on first read
 
81
into the page cache. Block hashes are stored linearly, aligned to the nearest
 
82
block size.
 
83
 
 
84
Hash Tree
 
85
---------
 
86
 
 
87
Each node in the tree is a cryptographic hash.  If it is a leaf node, the hash
 
88
of some data block on disk is calculated. If it is an intermediary node,
 
89
the hash of a number of child nodes is calculated.
 
90
 
 
91
Each entry in the tree is a collection of neighboring nodes that fit in one
 
92
block.  The number is determined based on block_size and the size of the
 
93
selected cryptographic digest algorithm.  The hashes are linearly-ordered in
 
94
this entry and any unaligned trailing space is ignored but included when
 
95
calculating the parent node.
 
96
 
 
97
The tree looks something like:
 
98
 
 
99
alg = sha256, num_blocks = 32768, block_size = 4096
 
100
 
 
101
                                 [   root    ]
 
102
                                /    . . .    \
 
103
                     [entry_0]                 [entry_1]
 
104
                    /  . . .  \                 . . .   \
 
105
         [entry_0_0]   . . .  [entry_0_127]    . . . .  [entry_1_127]
 
106
           / ... \             /   . . .  \             /           \
 
107
     blk_0 ... blk_127  blk_16256   blk_16383      blk_32640 . . . blk_32767
 
108
 
 
109
 
 
110
On-disk format
 
111
==============
 
112
 
 
113
The verity kernel code does not read the verity metadata on-disk header.
 
114
It only reads the hash blocks which directly follow the header.
 
115
It is expected that a user-space tool will verify the integrity of the
 
116
verity header.
 
117
 
 
118
Alternatively, the header can be omitted and the dmsetup parameters can
 
119
be passed via the kernel command-line in a rooted chain of trust where
 
120
the command-line is verified.
 
121
 
 
122
Directly following the header (and with sector number padded to the next hash
 
123
block boundary) are the hash blocks which are stored a depth at a time
 
124
(starting from the root), sorted in order of increasing index.
 
125
 
 
126
The full specification of kernel parameters and on-disk metadata format
 
127
is available at the cryptsetup project's wiki page
 
128
  http://code.google.com/p/cryptsetup/wiki/DMVerity
 
129
 
 
130
Status
 
131
======
 
132
V (for Valid) is returned if every check performed so far was valid.
 
133
If any check failed, C (for Corruption) is returned.
 
134
 
 
135
Example
 
136
=======
 
137
Set up a device:
 
138
  # dmsetup create vroot --readonly --table \
 
139
    "0 2097152 verity 1 /dev/sda1 /dev/sda2 4096 4096 262144 1 sha256 "\
 
140
    "4392712ba01368efdf14b05c76f9e4df0d53664630b5d48632ed17a137f39076 "\
 
141
    "1234000000000000000000000000000000000000000000000000000000000000"
 
142
 
 
143
A command line tool veritysetup is available to compute or verify
 
144
the hash tree or activate the kernel device. This is available from
 
145
the cryptsetup upstream repository http://code.google.com/p/cryptsetup/
 
146
(as a libcryptsetup extension).
 
147
 
 
148
Create hash on the device:
 
149
  # veritysetup format /dev/sda1 /dev/sda2
 
150
  ...
 
151
  Root hash: 4392712ba01368efdf14b05c76f9e4df0d53664630b5d48632ed17a137f39076
 
152
 
 
153
Activate the device:
 
154
  # veritysetup create vroot /dev/sda1 /dev/sda2 \
 
155
    4392712ba01368efdf14b05c76f9e4df0d53664630b5d48632ed17a137f39076