From: Eric Biggers <ebiggers@kernel.org>
To: Demi Marie Obenour <demiobenour@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>,
linux-crypto@vger.kernel.org,
Herbert Xu <herbert@gondor.apana.org.au>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
linux-bluetooth@vger.kernel.org, iwd@lists.linux.dev,
linux-hardening@vger.kernel.org, Milan Broz <gmazyland@gmail.com>
Subject: Re: [PATCH] crypto: af_alg - Add af_alg_restrict sysctl, defaulting to 1
Date: Sun, 28 Jun 2026 11:54:04 -0700 [thread overview]
Message-ID: <20260628185404.GA2292@quark> (raw)
In-Reply-To: <c7cb79ce-48f9-4433-ab4f-88b4c4df996c@gmail.com>
On Tue, Jun 23, 2026 at 10:09:27PM -0400, Demi Marie Obenour wrote:
> On 6/23/26 15:27, Eric Biggers wrote:
> > On Tue, Jun 23, 2026 at 12:12:24PM -0700, Andy Lutomirski wrote:
> >> On Mon, Jun 22, 2026 at 4:49 PM Eric Biggers <ebiggers@kernel.org> wrote:
> >>>
> >>> AF_ALG is a frequent source of vulnerabilities and a maintenance
> >>> nightmare. It exposes far more functionality to userspace than ever
> >>> should have been exposed, especially to unprivileged processes. Recent
> >>> exploits have targeted kernel internal implementation details like
> >>> "authencesn" that have zero use case for userspace access.
> >>>
> >>> Fortunately, AF_ALG is rarely used in practice, as userspace crypto
> >>> libraries exist. And when it is used, only some functionality is known
> >>> to be used, and many users are known to hold capabilities already.
> >>> iwd for example requires CAP_NET_ADMIN and has a known algorithm list
> >>> (https://lore.kernel.org/linux-crypto/bcbbef00-5881-421b-8892-7be6c04b832d@gmail.com/).
> >>>
> >>> Thus, let's restrict the set of allowed algorithms by default, depending
> >>> on the capabilities held.
> >>>
> >>> Add a sysctl /proc/sys/crypto/af_alg_restrict with meaning:
> >>>
> >>> 0: unrestricted
> >>> 1: limited functionality
> >>> 2: completely disabled
> >>>
> >>> Set the default value to 1, which enables an algorithm allowlist for
> >>> unprivileged processes and a slightly longer allowlist for privileged
> >>> processes.
> >>
> >> In our brave new world of containers, this is a bit awkward. The
> >> admin is sort of asking two separate questions:
> >>
> >> 1. Is the actual running distro and its privileged components capable
> >> of working without AF_ALG or with only the parts marked as being
> >> unprivileged?
> >>
> >> 2. Is the system running contains that need the unprivileged parts?
> >> (Which is maybe just sha1 for ip? I really don't know.)
> >>
> >> Should there maybe be two separate options so that all options are
> >> available? Or maybe something between 2 and 3 that means "limited
> >> functionality and privileged modes are completely disabled"?
> >
> > If we want to offer more settings we could. I could see this getting
> > quite complex pretty quickly once everyone weighs in, though. There's
> > quite a bit of value in keeping things simple, even if the offered
> > settings won't be optimal for every case.
> >
> > - Eric
>
> What about exposing both allowlists to userspace and making them
> configurable?
>
> I'm mostly concerned about systems running code (possibly
> closed-source) that uses algorithms that nobody here knows about.
> It would be better to allow a single algorithm than to turn off all
> restrictions.
> --
> Sincerely,
> Demi Marie Obenour (she/her/hers)
I think the following is what you're asking for:
sysctl crypto.algif_aead_priv_allowlist='ccm(aes)'
sysctl crypto.algif_aead_unpriv_allowlist=''
sysctl crypto.algif_hash_priv_allowlist='cmac(aes),hmac(md5),hmac(sha1),hmac(sha256),hmac(sha384),hmac(sha512),md4,md5,sha224,sha256,sha384,sha512'
sysctl crypto.algif_hash_unpriv_allowlist='sha1'
sysctl crypto.algif_skcipher_priv_allowlist='cbc(aes),cbc(des),cbc(des3_ede),ctr(aes),ecb(aes),ecb(des)'
sysctl crypto.algif_skcipher_unpriv_allowlist='adiantum(xchacha12,aes),adiantum(xchacha20,aes),hctr2(aes),xts(aes)'
sysctl crypto.algif_rng_priv_allowlist=''
sysctl crypto.algif_rng_unpriv_allowlist=''
We could do that if it's what people want. Just keep in mind that it
would be much more complex than the single tristate sysctl. And in
practice the number of people who are knowledgeable enough to create
these lists is quite small; we've seen similar things with other "Crypto
API" configuration knobs that seem to never be touched in practice.
Any thoughts?
- Eric
next prev parent reply other threads:[~2026-06-28 18:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 23:48 [PATCH] crypto: af_alg - Add af_alg_restrict sysctl, defaulting to 1 Eric Biggers
2026-06-23 8:42 ` Bastien Nocera
2026-06-23 16:54 ` Eric Biggers
2026-06-23 15:04 ` Luiz Augusto von Dentz
2026-06-23 16:52 ` Eric Biggers
2026-06-23 17:29 ` Demi Marie Obenour
2026-06-23 17:45 ` Eric Biggers
2026-06-23 18:05 ` Eric Biggers
2026-06-23 18:51 ` Luiz Augusto von Dentz
2026-06-23 17:24 ` Demi Marie Obenour
2026-06-23 17:58 ` Eric Biggers
2026-06-23 19:12 ` Andy Lutomirski
2026-06-23 19:27 ` Eric Biggers
2026-06-24 2:09 ` Demi Marie Obenour
2026-06-28 18:54 ` Eric Biggers [this message]
2026-06-23 19:24 ` Kees Cook
2026-06-23 19:49 ` Eric Biggers
2026-06-23 21:28 ` Rosen Penev
2026-06-23 21:47 ` Eric Biggers
2026-06-23 22:06 ` Rosen Penev
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=20260628185404.GA2292@quark \
--to=ebiggers@kernel.org \
--cc=demiobenour@gmail.com \
--cc=gmazyland@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=iwd@lists.linux.dev \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
/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