[PATCH v2 0/1] dm-integrity: replace forgeable discard filler with a keyed sector marker
From: Shukai Ni
Date: Tue Jul 28 2026 - 10:48:13 EST
dm-integrity's discard support has a keyless bypass. When a device is
opened with --allow-discards, dm_integrity_rw_tag() treats a stored
tag consisting entirely of the constant DISCARD_FILLER (0xf6) as
sufficient proof that the corresponding block was discarded, and
skips the keyed integrity check for it. That constant is public and
needs no key to reproduce, so anyone able to write raw sectors to the
backing device can stamp an arbitrary data block with an all-0xf6 tag and
have its contents served as if they had passed HMAC verification.
The exposure is limited to dm-integrity's standalone cryptographic
authentication mode: discard is only accepted when internal_hash is
configured, so the combined dm-crypt + dm-integrity AEAD setup, where
dm-crypt supplies the tags itself, is not affected.
v1 replaced the constant filler unconditionally with a per-sector
keyed marker: HMAC_key(salt || sector). A real data tag is
HMAC_key(salt || sector || block); because its input always includes
the full block while the discard marker's never does, the two cannot
structurally collide, regardless of block content.
v2 makes the fix opt-in instead. A new "allow_discards_keyed" target
argument enables the keyed marker. Once "allow_discards_keyed" is
used, SB_FLAG_DISCARD_KEYED is set in the superblock and persists
across future activations.
Changes since v1:
- Added "allow_discards_keyed" as a new, explicit opt-in target
argument instead of always replacing the discard marker scheme.
- Added SB_FLAG_DISCARD_KEYED, a sticky superblock flag recording the
choice, following the same persistence pattern as
SB_FLAG_RECALCULATING.
- Restored the original DISCARD_FILLER-based marker as the default
behavior, so existing volumes are unaffected unless the admin
explicitly opts in.
- Documented the new option, its danger, and its formula in
dm-integrity.rst; updated the status-string grammar in dm-ima.rst.
Shukai Ni (1):
dm-integrity: replace forgeable discard filler with a keyed sector
marker
.../admin-guide/device-mapper/dm-ima.rst | 7 +-
.../device-mapper/dm-integrity.rst | 13 ++
drivers/md/dm-integrity.c | 122 +++++++++++++++---
3 files changed, 121 insertions(+), 21 deletions(-)
--
2.53.0