ceph: validate fscrypt auth blob length
PATCH 1/1 ceph: validate fscrypt auth blob length
ceph_crypt_get_context() trusts cfa_blob_len after checking only that the inode-owned fscrypt_auth allocation contains the fixed header and one byte. An MDS can therefore place a larger inner length in a shorter outer object, causing memcpy() to read beyond the allocation when a caller requests the encryption nonce.
Require the complete blob to fit in the inode-owned allocation before using the inner length.
On the tested baseline, the malformed reply produced the same KASAN slab-out-of-bounds read twice. An ordinary UID obtained sixteen wire-absent SLUB redzone bytes in two non-KASAN production-path runs. The input was rejected twice after this change, while a complete context still worked.
--- fs/ceph/crypto.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ceph/crypto.c +3 -0
@@ -30,6 +30,9 @@ static int ceph_crypt_get_context(struct inode *inode, void *ctx, size_t len)return -ENOBUFS ; ctxlen =le32_to_cpu (cfa->cfa_blob_len); +if (ctxlen > ci->fscrypt_auth_len - + offsetof(struct ceph_fscrypt_auth , cfa_blob)) +return -ENOBUFS ;if (len < ctxlen)return -ERANGE ;
Signature · 1 line
2.43.0
Hi Sung,
Thanks for the patch.
Signature · 1 line
Alex Markuze