Skip to content

Commit 7dc4484

Browse files
peaktwilightgregkh
authored andcommitted
crypto: rsa-pkcs1pad: Don't WARN on an empty digest
KEYCTL_PKEY_VERIFY lets an unprivileged caller supply a zero-length digest (in_len == 0). keyctl_pkey_params_get_2() accepts the zero length and the request reaches pkcs1pad_verify(), where the empty digest is rejected but only after being passed through WARN_ON(!digest_size). The warning is therefore directly user-triggerable, and on kernels built with panic_on_warn=1 an unprivileged process can panic the machine -- a local denial of service. Reproduced as UID 65534 in a setuid sandbox. Keep rejecting the invalid request with -EINVAL, but do not emit a warning for the user-controlled length. Mainline does not contain this code path; commit 1e562de ("crypto: rsassa-pkcs1 - Migrate to sig_alg backend") removed pkcs1pad_verify() in v6.13-rc1. This is a minimal fix for the affected stable branches. It applies as-is to 6.1.y, 6.6.y and 6.12.y (identical pkcs1pad_verify); the 5.10.y/5.15.y form is sent as a separate patch due to the older req->dst_len spelling. Found by 0sec automated security-research tooling (https://0sec.ai). Fixes: c7381b0 ("crypto: akcipher - new verify API for public key algorithms") Cc: stable@vger.kernel.org Assisted-by: 0sec:multi-model Signed-off-by: Doruk Tan Ozturk <doruk@0sec.ai> Reviewed-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent d8d18d2 commit 7dc4484

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

crypto/rsa-pkcs1pad.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ static int pkcs1pad_verify(struct akcipher_request *req)
534534
const unsigned int digest_size = req->dst_len;
535535
int err;
536536

537-
if (WARN_ON(req->dst) || WARN_ON(!digest_size) ||
537+
if (WARN_ON(req->dst) || !digest_size ||
538538
!ctx->key_size || sig_size != ctx->key_size)
539539
return -EINVAL;
540540

0 commit comments

Comments
 (0)