Skip to contentSkip to conversation

Allow hmac(sha512) for unpriviledged users

PATCH In review Justin M. Forbes 3 participants 6 messages Oct 3 – Oct 8 Crypto API

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow hmac(sha512) for unpriviledged users

By default users cannot run sha512hmac with the current set up. This is problematic because our kernel builds call this for FIPS compliance. Rather than have anyone turn off af_alg_restrict all together, let's allow a common use case.

---
 crypto/algif_hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
crypto/algif_hash.c +1 -1
index 6e8b5fb82a7f..0d3ec5760de6 100644
@@ -23,7 +23,7 @@ static const struct af_alg_allowlist_entry hash_allowlist[] = {
 	{ "hmac(sha224)" }, /* iwd */
 	{ "hmac(sha256)" }, /* iwd */
 	{ "hmac(sha384)" }, /* iwd */
-	{ "hmac(sha512)" }, /* iwd, sha512hmac */
+	{ "hmac(sha512)", AF_ALG_UNPRIVILEGED }, /* iwd, sha512hmac */
 	{ "md4" }, /* iwd */
 	{ "md5" }, /* iwd */
 	{ "sha1", AF_ALG_UNPRIVILEGED }, /* iwd, iproute2 < 7.0 */
Signature · 1 line
2.55.0
#1 lore raw
Quoted 6 lines · Justin M. Forbes

By default users cannot run sha512hmac with the current set up. This is problematic because our kernel builds call this for FIPS compliance. Rather than have anyone turn off af_alg_restrict all together, let's allow a common use case.

The fips hook in dracut was taken into account already, and it runs as root. So this patch shouldn't be needed. Can you clarify why you think it is needed?

- Eric

#2 lore raw
Quoted 6 lines · Eric Biggers
Quoted 5 lines · Justin M. Forbes

By default users cannot run sha512hmac with the current set up. This is problematic because our kernel builds call this for FIPS compliance. Rather than have anyone turn off af_alg_restrict all together, let's allow a common use case.

Quoted 7 lines
Quoted 1 line

The fips hook in dracut was taken into account already, and it runs as root. So this patch shouldn't be needed. Can you clarify why you think it is needed?

- Eric

Specifically for the case of Fedora and all Red Hat kernels, we call sha512hmac to sign the kernel, and a couple of UKI images that are created during the kernel build. Users on Fedora 45 and newer are now unable to build the kernel from spec without turning off af_alg_restrict all together, while any user can build a kernel on Fedora 44 or older.

Justin

#3 lore raw
Quoted 13 lines · Justin Forbes
Quoted 12 lines · Eric Biggers
Quoted 6 lines · Justin M. Forbes

By default users cannot run sha512hmac with the current set up. This is problematic because our kernel builds call this for FIPS compliance. Rather than have anyone turn off af_alg_restrict all together, let's allow a common use case.

The fips hook in dracut was taken into account already, and it runs as root. So this patch shouldn't be needed. Can you clarify why you think it is needed?

Quoted 7 lines
Quoted 1 line

- Eric

Specifically for the case of Fedora and all Red Hat kernels, we call sha512hmac to sign the kernel, and a couple of UKI images that are created during the kernel build. Users on Fedora 45 and newer are now unable to build the kernel from spec without turning off af_alg_restrict all together, while any user can build a kernel on Fedora 44 or older.

I see, it's in redhat/kernel.spec.template in the Fedora kernel source tree which is used when packaging the kernel into an RPM package. Please make that super clear in your commit message, because it wasn't clear you were talking about something different from the use in dracut.

I guess the actual diff is fine then, since something like this that's being used should continue to be allowed.

Of course, this is yet another gratuitous use of AF_ALG, as I've explained previously
(https://lore.kernel.org/r/20260504173952.GA2291@sol/). Depending AF_ALG to build the kernel (vs. just using OpenSSL for example) is even more misguided than using it in the integrity check itself, as at least there are FIPS boundary considerations for the integrity check itself, but those are irrelevant for the build tools.

So even though this will keep being allowed for now, please work to get this fixed to not need AF_ALG. Note also that Fedora 45 explicitly deprecates AF_ALG (https://lwn.net/Articles/1088489/) on top of the already-documented upstream deprecation.

- Eric

#4 lore raw
Quoted 38 lines · Eric Biggers
Quoted 13 lines · Justin Forbes
Quoted 12 lines · Eric Biggers
Quoted 6 lines · Justin M. Forbes

By default users cannot run sha512hmac with the current set up. This is problematic because our kernel builds call this for FIPS compliance. Rather than have anyone turn off af_alg_restrict all together, let's allow a common use case.

The fips hook in dracut was taken into account already, and it runs as root. So this patch shouldn't be needed. Can you clarify why you think it is needed?

Quoted 7 lines
Quoted 1 line

- Eric

Specifically for the case of Fedora and all Red Hat kernels, we call sha512hmac to sign the kernel, and a couple of UKI images that are created during the kernel build. Users on Fedora 45 and newer are now unable to build the kernel from spec without turning off af_alg_restrict all together, while any user can build a kernel on Fedora 44 or older.

I see, it's in redhat/kernel.spec.template in the Fedora kernel source tree which is used when packaging the kernel into an RPM package. Please make that super clear in your commit message, because it wasn't clear you were talking about something different from the use in dracut.

I guess the actual diff is fine then, since something like this that's being used should continue to be allowed.

Of course, this is yet another gratuitous use of AF_ALG, as I've explained previously
(https://lore.kernel.org/r/20260504173952.GA2291@sol/). Depending AF_ALG to build the kernel (vs. just using OpenSSL for example) is even more misguided than using it in the integrity check itself, as at least there are FIPS boundary considerations for the integrity check itself, but those are irrelevant for the build tools.

Quoted 6 lines

So even though this will keep being allowed for now, please work to get this fixed to not need AF_ALG. Note also that Fedora 45 explicitly deprecates AF_ALG (https://lwn.net/Articles/1088489/) on top of the already-documented upstream deprecation.

- Eric

Understood. I am one of the people behind that change. Basically it means we backported all of this into 7.2 to make sure that Fedora 45 ships with it by default. The hope is that we can get this all worked out to the point that we can turn off AF_ALG all together by Fedora 46. But this piece in particular caught me by surprise, and this will give us time to get it fixed properly.

Thanks,
Justin

maintainer
#5 lore raw
In reply to Justin M. Forbes
Quoted 9 lines · Justin M. Forbes

By default users cannot run sha512hmac with the current set up. This is problematic because our kernel builds call this for FIPS compliance. Rather than have anyone turn off af_alg_restrict all together, let's allow a common use case.

---
 crypto/algif_hash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt