[PATCH v2 1/2] KEYS: fix signature length passed to KEYCTL_PKEY_VERIFY
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Nov 18 23:24:30 UTC 2026
> From: Florian Bauckholt <florian.bauckholt at cispa.de>
>
> Commit cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
> made keyctl_pkey_params_get_2() set params->out_len to the maximum
> output size of the operation instead of the size provided by the caller.
> It does so for KEYCTL_PKEY_VERIFY as well, but verify has no output
> buffer: out_len shares a union with in2_len, the length of the
> signature.
>
> As a result keyctl_pkey_verify() ignores the signature length passed by
> the caller and always reads max_sig_size bytes from the signature
> pointer. A shorter signature is extended with whatever follows it in
> the caller's memory, or the call fails with -EFAULT if that memory is
> not readable.
>
> The x962 ECDSA template currently ignores data following a DER-encoded
> signature, which hides the problem there. A truncated RSA signature,
> however, is accepted if the bytes following it happen to match the ones
> that were cut off, as reported by Rodolfo Giometti [1].
>
> Use the length provided by the caller, which has already been checked
> against max_sig_size.
>
> Fixes: cb481e59ea6c ("KEYS: fix overflow in keyctl_pkey_params_get_2()")
> Cc: stable at vger.kernel.org
> Link: https://lore.kernel.org/all/20260919221742.3709658-1-benquike@gmail.com/
> Link: https://lore.kernel.org/all/0e20f799-e389-40d2-aaee-2f174748faae@enneenne.com/ [1]
> Reviewed-by: Jarkko Sakkinen <jarkko at kernel.org>
> Tested-by: Stefan Berger <stefanb at linux.ibm.com>
> Signed-off-by: Florian Bauckholt <florian.bauckholt at cispa.de>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-keyctl-pkey-fixes-v2-0-9e2d1c7db7ec@cispa.de?part=1
More information about the Linux-security-module-archive
mailing list