Cryptsetup development
 help / color / mirror / Atom feed
* luks2 + integrity + discard
@ 2026-07-20 12:16 Piergiorgio Sartor
  2026-07-20 20:28 ` Milan Broz
  0 siblings, 1 reply; 4+ messages in thread
From: Piergiorgio Sartor @ 2026-07-20 12:16 UTC (permalink / raw)
  To: cryptsetup

Hello,

I'm quite puzzled about the, apparently,
missing support of discard (or trim) in
case of encryption with integrity.

From what I understand, which might be
very wrong, both the encryption layer
and dm-integrity should support discard.

Reading the documentation does not really,
at least for me, clarify what is the
reason why it should not be possible to
have encryption + integrity + discard.

On the other hand, in case of integrity
under the raid, with lvm and luks2 on
top, it seems possible to have discard.

Can someone provide some clarification
on this?

Thanks a lot in advance,

bye,

-- 

piergiorgio

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: luks2 + integrity + discard
  2026-07-20 12:16 luks2 + integrity + discard Piergiorgio Sartor
@ 2026-07-20 20:28 ` Milan Broz
  2026-07-20 20:36   ` Piergiorgio Sartor
  0 siblings, 1 reply; 4+ messages in thread
From: Milan Broz @ 2026-07-20 20:28 UTC (permalink / raw)
  To: Piergiorgio Sartor, cryptsetup

On 7/20/26 2:16 PM, Piergiorgio Sartor wrote:
> Hello,
> 
> I'm quite puzzled about the, apparently,
> missing support of discard (or trim) in
> case of encryption with integrity.
> 
>  From what I understand, which might be
> very wrong, both the encryption layer
> and dm-integrity should support discard.
> 
> Reading the documentation does not really,
> at least for me, clarify what is the
> reason why it should not be possible to
> have encryption + integrity + discard.
> 
> On the other hand, in case of integrity
> under the raid, with lvm and luks2 on
> top, it seems possible to have discard.
> 
> Can someone provide some clarification
> on this?

Discard (TRIM) is supported for dm-integrity
standalone mode. It is also supported for dm-crypt
standalone.

It is not supported for stacked dm-crypt over dm-integrity
(In authenticated encryption mode where dm-integrity only provides
interleaved metadata sectors for dm-crypt.)
(And it never will be implemented for this case.)

Milan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: luks2 + integrity + discard
  2026-07-20 20:28 ` Milan Broz
@ 2026-07-20 20:36   ` Piergiorgio Sartor
  2026-07-20 21:03     ` Milan Broz
  0 siblings, 1 reply; 4+ messages in thread
From: Piergiorgio Sartor @ 2026-07-20 20:36 UTC (permalink / raw)
  To: Milan Broz; +Cc: Piergiorgio Sartor, cryptsetup

On Mon, Jul 20, 2026 at 10:28:27PM +0200, Milan Broz wrote:
> On 7/20/26 2:16 PM, Piergiorgio Sartor wrote:
> > Hello,
> > 
> > I'm quite puzzled about the, apparently,
> > missing support of discard (or trim) in
> > case of encryption with integrity.
> > 
> >  From what I understand, which might be
> > very wrong, both the encryption layer
> > and dm-integrity should support discard.
> > 
> > Reading the documentation does not really,
> > at least for me, clarify what is the
> > reason why it should not be possible to
> > have encryption + integrity + discard.
> > 
> > On the other hand, in case of integrity
> > under the raid, with lvm and luks2 on
> > top, it seems possible to have discard.
> > 
> > Can someone provide some clarification
> > on this?
> 
> Discard (TRIM) is supported for dm-integrity
> standalone mode. It is also supported for dm-crypt
> standalone.
> 
> It is not supported for stacked dm-crypt over dm-integrity
> (In authenticated encryption mode where dm-integrity only provides
> interleaved metadata sectors for dm-crypt.)

Thanks for the answer.

I was curious about the technical reason
for this.
Why the stacked mode should not made
possible the discard.
Is this because they're "interleaved"?
Could explain or point out to some
explanation of what is intended with
"interleaved"?

> (And it never will be implemented for this case.)

Well, is this because is too complex or
for some other reasons?
I mean, SSD are more and more common,
giving up discard seems a bit of a problem.

Thanks again,

bye,

-- 

piergiorgio

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: luks2 + integrity + discard
  2026-07-20 20:36   ` Piergiorgio Sartor
@ 2026-07-20 21:03     ` Milan Broz
  0 siblings, 0 replies; 4+ messages in thread
From: Milan Broz @ 2026-07-20 21:03 UTC (permalink / raw)
  To: Piergiorgio Sartor; +Cc: cryptsetup

On 7/20/26 10:36 PM, Piergiorgio Sartor wrote:
>> Discard (TRIM) is supported for dm-integrity
>> standalone mode. It is also supported for dm-crypt
>> standalone.
>>
>> It is not supported for stacked dm-crypt over dm-integrity
>> (In authenticated encryption mode where dm-integrity only provides
>> interleaved metadata sectors for dm-crypt.)
> 
> Thanks for the answer.
> 
> I was curious about the technical reason
> for this.
> Why the stacked mode should not made
> possible the discard.
> Is this because they're "interleaved"?
> Could explain or point out to some
> explanation of what is intended with
> "interleaved"?

That is the main reason, you basically cannot trim a continuous region
as sectors are interleaved.

The second reason security - discard in dm-integrity standalone
mode is not secure (you can trim a region to remove real data
and it will not report integrity errors).

The dm-integrity idea (as I initially planned) was to implement
temporary solution to emulate sector+metadata to allow authenticated
encryption.

Once hardware itself can provide such configuration, discard will
work natively (see inline mode).

Unfortunately, only a very few enterprise drives support it
(even if it is basically only about proper SSD firmware).

...
> I mean, SSD are more and more common,
> giving up discard seems a bit of a problem.

Then do not use authenticated encryption using dm-integrity.
Security is not for free.

Milan


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-07-20 21:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 12:16 luks2 + integrity + discard Piergiorgio Sartor
2026-07-20 20:28 ` Milan Broz
2026-07-20 20:36   ` Piergiorgio Sartor
2026-07-20 21:03     ` Milan Broz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox