All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Demi Marie Obenour via B4 Relay"
	<devnull+demiobenour.gmail.com@kernel.org>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH 2/3] AF_ALG: Drop support for off-CPU cryptography
Date: Sat, 30 May 2026 00:47:19 +0000	[thread overview]
Message-ID: <20260530004719.8EFB61F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260523-af-alg-harden-v1-2-c76755c3a5c5@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] The patch breaks userspace compatibility by forcefully disabling hardware accelerators, asynchronous algorithms, and memory-allocating algorithms, and silently ignores user-provided configuration flags.
--

commit ac5d5083a6e0ac13c785899123f47cf8eacc20ee
Author: Demi Marie Obenour <demiobenour@gmail.com>

AF_ALG: Drop support for off-CPU cryptography

This commit removes support for hardware accelerators in the AF_ALG
subsystem. It forces all userspace crypto API consumers to use purely
software-based synchronous implementations by dropping features and
flags in the bind callbacks. The goal stated is to reduce overhead
and attack surface.

> diff --git a/crypto/af_alg.c b/crypto/af_alg.c
> index 8ccf7a737cd6c..cce000e8590e4 100644
> --- a/crypto/af_alg.c
> +++ b/crypto/af_alg.c
[ ... ]
> @@ -181,7 +181,7 @@ static int alg_bind(struct socket *sock, struct sockaddr_unsized *uaddr, int add
>  	if (IS_ERR(type))
>  		return PTR_ERR(type);
>  
> -	private = type->bind(sa->salg_name, sa->salg_feat, sa->salg_mask);
> +	private = type->bind(sa->salg_name);

[Severity: Critical]
Does this silently ignore user-provided configuration flags?

Looking earlier in alg_bind(), the user-supplied salg_feat and salg_mask are
still validated, which explicitly allows the hardware driver flag:

    const u32 allowed = CRYPTO_ALG_KERN_DRIVER_ONLY;
    ...
    if ((sa->salg_feat & ~allowed) || (sa->salg_mask & ~allowed))
        return -EINVAL;

If userspace explicitly requests a hardware driver, it looks like the kernel
will now silently ignore the flag and provide a software fallback instead of
returning an error.

[ ... ]
> diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h
> index 62867daca47d7..7643ba954125a 100644
> --- a/include/crypto/if_alg.h
> +++ b/include/crypto/if_alg.h
[ ... ]
> @@ -243,4 +243,16 @@ int af_alg_get_rsgl(struct sock *sk, struct msghdr *msg, int flags,
>  		    struct af_alg_async_req *areq, size_t maxsize,
>  		    size_t *outlen);
>  
> +/*
> + * Mask used to disable unsupported algorithm implementations.
> + *
> + * This is the same as FSCRYPT_CRYPTOAPI_MASK in fs/crypto/fscrypt_private.h.
> + * In additions to the motivations there, this API is exposed to userspace
> + * that might not be fully trusted.
> + */
> +#define AF_ALG_CRYPTOAPI_MASK                             \
> +	(CRYPTO_ALG_ASYNC | CRYPTO_ALG_ALLOCATES_MEMORY | \
> +	 CRYPTO_ALG_KERN_DRIVER_ONLY)

[Severity: Critical]
Does this unnecessarily break pure software algorithms that legitimately
allocate memory?

While fscrypt restricts memory allocation to prevent filesystem deadlocks,
AF_ALG is a socket API that does not have these same constraints. By
copying the fscrypt mask, this might inadvertently prevent the use of valid
software-only algorithms.

Furthermore, does forcefully removing asynchronous algorithm and hardware
accelerator support break userspace ABI? The kernel generally maintains a
strict no-regression policy for userspace compatibility.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260523-af-alg-harden-v1-0-c76755c3a5c5@gmail.com?part=2

  reply	other threads:[~2026-05-30  0:47 UTC|newest]

Thread overview: 19+ 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 ` Demi Marie Obenour
2026-05-23 19:43 ` [PATCH 1/3] net: Remove support for AIO on sockets Demi Marie Obenour via B4 Relay
2026-05-23 19:43   ` Demi Marie Obenour
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-30  0:47   ` sashiko-bot
2026-05-23 19:43 ` [PATCH 2/3] AF_ALG: Drop support for off-CPU cryptography Demi Marie Obenour via B4 Relay
2026-05-23 19:43   ` Demi Marie Obenour
2026-05-30  0:47   ` sashiko-bot [this message]
2026-06-03 13:33   ` Harald Freudenberger
2026-05-23 19:43 ` [PATCH 3/3] AF_ALG: Document that it is *always* slower Demi Marie Obenour via B4 Relay
2026-05-23 19:43   ` Demi Marie Obenour
2026-05-30  0:47   ` sashiko-bot
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=20260530004719.8EFB61F00898@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=devnull+demiobenour.gmail.com@kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.