[PATCH v2] keys: fix crash on big_key read or revoke after a failed update
Guicai Ma
maguicai at kylinos.cn
Tue Nov 24 11:20:44 UTC 2026
On Tue, Nov 24, 2026 at 10:57:59AM +0800, Henry Martin wrote:
> Instantiate the new payload first and destroy the old one only on success;
> a positive key's reservation is already 16 bytes, so it cannot fail.
Looks good. Saving the old big_key_payload on the stack before calling
generic_key_instantiate() also keeps negative keys untouched if the
quota reserve fails, and the caller still frees prep via
big_key_free_preparse().
I tested this on 7.4.0-rc3 arm64 in QEMU (KASAN, lockdep,
CONFIG_BIG_KEYS=y). After creating a 4096-byte big_key and setting
root_maxbytes=1, a 1-byte KEYCTL_UPDATE fails with -EDQUOT on the
unpatched kernel and the next KEYCTL_READ hits the BUG at
fs/open.c:1145 in dentry_open(). With this patch the 1-byte update and
read succeed, as do file/buff update transitions and KEYCTL_REVOKE.
Reviewed-by: Guicai Ma <maguicai at kylinos.cn>
Tested-by: Guicai Ma <maguicai at kylinos.cn>
More information about the Linux-security-module-archive
mailing list