Hi,
just for the context (as cryptsetup maintainer), this encryption work
started as a master's thesis as an experiment, and now it is slightly
moving to real use.
On 7/30/25 12:41 PM, Ming Lei wrote:
>> I think the crypt feature would be much more complicated - we need to be
>> able to reset some options (like key) and do other operations along the
>> way. A lot of stuff is missing from my initial prototype.
>
> IMO the model isn't complicated, we can freeze queue easily before updating key.
The goal is that we can optionally replace backend for cryptsetup
(now dm-crypt) with ublk userspace encryption.
There is a lot of various settings dm-crypt currently supports.
Cryptsetup needs a crypt target to provide most of them, but others should
not use these settings. (Many settings are obscure and no longer secure,
but we need them for compatibility.)
For example, we need to implement all IV generators.
We already have this in userspace, as Kristina uses the cryptsetup backend wrapper.
But other targets definitely should not be linked to that code.
Later we would like to add support for authenticated encryption (AEAD) that has many
more parameters like treating IV (otr sector offset) as an authenticated-only data.
Also this will require per-sector metadata tags supported by ublk, not sure
it is there yet (integrity profile metadata).
That's why I think it is better to have a separate target, at least until
everything works as expected. But also we would like to avoid duplication
of the ublk daemon code.
> The IO fast path interface looks simple, just enc for write and dec after
> reading is done.
>
>> We are months away from a true functional target.
>> Also it would not make sense for all targets (right now just loop would be
>> applicable?).
>
> crypt can be one generic feature, which is controlled by command line.
> User can just enable it for the interested target.
Please, better no. I have seen so many wrongly implemented sector encryption.
This will simply invite people to repeat the same mistakes.
That said, did you consider something like stacking target
functionality (similar to device-mapper targets)?
> If you think it is only usable for loop, another way is to handle it in
> loop target directly, just like your prototype, then crypt command
> line can be added for loop only.
I do not think the loop target should be directly combined with encryption.
IMO one target should provide one function, maybe supporting chaining some
callbacks, dunno.
(I am so happy encryption was removed from the kernel loop target -- btw
we can map old cryptoloop in cryptsetup, one of the obscure compatible
settings mentioned above :-)
Thanks,
Milan