From: Demi Marie Obenour <demiobenour@gmail.com>
To: Dominique Martinet <asmadeus@codewreck.org>,
Eric Biggers <ebiggers@kernel.org>
Cc: Harald Freudenberger <freude@linux.ibm.com>,
acme@kernel.org, adrian.hunter@intel.com,
alexander.shishkin@linux.intel.com, ardb@kernel.org,
axboe@kernel.dk, corbet@lwn.net, davem@davemloft.net,
edumazet@google.com, herbert@gondor.apana.org.au,
horms@kernel.org, io-uring@vger.kernel.org, irogers@google.com,
james.clark@linaro.org, jolsa@kernel.org, kuba@kernel.org,
kuniyu@google.com, linux-crypto@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, mark.rutland@arm.com,
mingo@redhat.com, namhyung@kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com, peterz@infradead.org,
skhan@linuxfoundation.org, willemb@google.com,
linux-s390@vger.kernel.org
Subject: Re: [PATCH 2/3] AF_ALG: Drop support for off-CPU cryptography
Date: Fri, 24 Jul 2026 16:35:13 -0400 [thread overview]
Message-ID: <0ccda05f-077c-4661-b852-e6bf9bf40be3@gmail.com> (raw)
In-Reply-To: <amOTjPW__CNZui3_@codewreck.org>
[-- Attachment #1.1: Type: text/plain, Size: 3824 bytes --]
On 7/24/26 12:32, Dominique Martinet wrote:
> Eric Biggers wrote on Fri, Jul 24, 2026 at 09:00:34AM -0700:
>> On Sat, Jul 25, 2026 at 12:35:55AM +0900, Dominique Martinet wrote:
>>> The tool source is available here:
>>> https://github.com/nxp-imx/crypto_af_alg
>>> (which now fails with:
>>> bind(3, {sa_family=AF_ALG, salg_type="skcipher", salg_feat=0, salg_mask=0, salg_name="tk(cbc(aes))"}, 88) = -1 ENOENT (No such file or directory)
>>> )
>>>
>>>
>>> I don't particularily care for the API used as long as we can keep using
>>> the hardware key, but as far as I can see there's no alternative API --
>>> what's the path forward?
>>
>> There's no "tk(cbc(aes))" algorithm in the upstream kernel. So, it's
>> not possible that this ever worked with upstream. Given that, there's
>> no regression in upstream for this program, and it wouldn't be
>> appropriate to consider a sysctl knob in upstream at this time.
>
> Bleh, you are correct, it's an NXP patch in
> drivers/crypto/caam/caamalg.c that they've been carrying in their
> tree(s) since 2018[1] and has apparently never been upstreamed...
> [1] https://github.com/nxp-imx/linux-imx/commit/6868c9e49c1854028fb46022daac3b1b10ca2c70
>
> Sorry for not having checked, I was hoping for better.
> (I should be used to it by now...)
>
>
> Regardless of the specific algorithm, most recent SoCs flaunt some
> "secure element" or similiar hardware-backed keys (so one wouldn't be
> able to decrypt $whatever without running on the specific board it was
> intended for); I'm sure _some_ of them are upstream?
> (Never used it so not sure if they are reachable from af_alg, but for
> example drivers/crypto/ccree/cc_cipher.c talks about hardware key...)
>
> There's not much I can do about the vendor's kernel I'm stuck with, but
> that doesn't make having encryption material not accessible to userspace
> useless as a concept;
> forgetting about the sysctl for now, what are the alternatives API this
> kind of implementations could be based on?
>
> I guess I should start looking at how tpm backed encryption works,
> some other day, it's getting late here...
I actually had this thought myself, though with a different
use-case: preventing long-term keys (like TLS and SSH keys and
cookie signing/encryption keys) from being accidentally leaked.
I came up with a much simpler API than AF_ALG:
1. Generate a file descriptor and a wrapping key. The wrapping key
is used to encrypt data that will be imported.
2. Import an encrypted secret key. The key contains both the secret
key and the algorithm it will be used with.
3. Optionally, attach a restriction policy that requires data to
be signed to start with a certain prefix. This provides domain
separation in contexts where the same key is used for multiple
purposes.
4. Pass the file descriptor to another process via SCM_RIGHTS.
5. The receiving process can use ioctls to perform secret-key
operations, such as ML-KEM, ML-DSA, XChaCha20-Poly1305, and
XAES-256-GCM.
6. When the file descriptor is closed, the secret key is securely
deleted.
Compared to AF_ALG, the kernel attack surface is very small. It's not
quite a "hello world" character device driver, but compared to many
of the other drivers in the kernel, it is tiny. Furthermore, the
whole thing should be able to be written in safe Rust.
To keep the attack surface minimal, this would only use library
functions, so there would be no support for hardware-wrapped keys.
I don't plan to work on this myself, but I think it's of potential
value in the future. For asymmetric algorithms, the overhead of a
system call should be fairly small compared to the operation itself.
--
Sincerely,
Demi Marie Obenour (she/her/hers)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-07-24 20:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-23 19:43 [PATCH 0/3] AF_ALG: Remove support for AIO and old-style drivers Demi Marie Obenour via B4 Relay
2026-05-23 19:43 ` [PATCH 1/3] net: Remove support for AIO on sockets Demi Marie Obenour via B4 Relay
2026-05-25 8:03 ` Christoph Hellwig
2026-05-26 15:58 ` Jens Axboe
2026-05-27 8:13 ` Christoph Hellwig
2026-05-28 16:56 ` Jens Axboe
2026-05-29 13:59 ` Christoph Hellwig
2026-05-27 1:40 ` Jakub Kicinski
2026-05-23 19:43 ` [PATCH 2/3] AF_ALG: Drop support for off-CPU cryptography Demi Marie Obenour via B4 Relay
2026-06-03 13:33 ` Harald Freudenberger
2026-07-24 15:35 ` Dominique Martinet
2026-07-24 16:00 ` Eric Biggers
2026-07-24 16:32 ` Dominique Martinet
2026-07-24 18:09 ` Eric Biggers
2026-07-24 20:35 ` Demi Marie Obenour [this message]
2026-05-23 19:43 ` [PATCH 3/3] AF_ALG: Document that it is *always* slower Demi Marie Obenour via B4 Relay
2026-05-29 6:09 ` [PATCH 0/3] AF_ALG: Remove support for AIO and old-style drivers Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ccda05f-077c-4661-b852-e6bf9bf40be3@gmail.com \
--to=demiobenour@gmail.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ardb@kernel.org \
--cc=asmadeus@codewreck.org \
--cc=axboe@kernel.dk \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=ebiggers@kernel.org \
--cc=edumazet@google.com \
--cc=freude@linux.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=horms@kernel.org \
--cc=io-uring@vger.kernel.org \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=peterz@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=willemb@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox