Re: [syzbot] [ext4?] general protection fault in ext4_put_io_end_defer

From: Theodore Ts'o
Date: Fri Jun 30 2023 - 13:14:16 EST


On Fri, Jun 30, 2023 at 12:46:14AM -0700, Eric Biggers wrote:
> > AF_ALG has existed since 2010. My understanding that its original purpose was
> > to expose hardware crypto accelerators to userspace. Unfortunately, support for
> > exposing *any* crypto algorithm was included as well, which IMO was a mistake.

+1000....

> > There are quite a few different userspace programs that use AF_ALG purely to get
> > at the CPU-based algorithm implementations, without any sort of intention to use
> > hardware crypto accelerator. Probably because it seemed "easy". Or "better"
> > because everything in the kernel is better, right?

Do we know if any to standard crypto libraries are using AF_ALG? All
aside from whether it's a good idea for userspace programs to be using
kernel code because "everything is better in the kernel", I'm
wondering how solicitous we should be for programs who are very likely
rolling their own crypto, as opposed to using crypto library that has
been written and vetted and tested for vulnerability by experts...

> > It's controlled by the CONFIG_CRYPTO_USER_API_* options, with the hash support
> > in particular controlled by CONFIG_CRYPTO_USER_API_HASH. Though good luck
> > disabling it on most systems, as systemd depends on it...
> >
>
> Actually it turns out systemd has finally seen the light:
> https://github.com/systemd/systemd/commit/2c3794f4228162c9bfd9e10886590d9f5b1920d7

Aside from those PCI-attached crypto accelerators where you have to go
through the kernel (although my experience has been that most of the
time, the overhead for key scheduling, etc., is such that unless
you're doing bulk crypto on large chunks of data, using external
crypto hardware acclerators no longer makes sense 99.99% of the time
in the 21st century), I wonder if we should consider having the kernel
print a warning, "WARNING: [comm] is using AF_ALG; please consider
using a real crypto library instead of rolling your own crypto".

(Only half kidding.)

- Ted