fs: inline_crypt: add parameter check

force_page_cache_ra did not perform parameter checking when calling
fscryptnode_uses_fs_layer_crypto, resulting in illegal memory access.

Bug:
Unable to handle kernel access to user memory outside uaccess routines at virtual address 0000000000000011
pc : __fscrypt_inode_uses_inline_crypto+0x4/0xc
lr : force_page_cache_ra+0x7c/0x128
sp : ffffffc00d593ad0
x29: ffffffc00d593ad0 x28: 00000000ffffffff x27: ffffffc00d593d40
x26: 0000000000000000 x25: 0000000000000153 x24: 0000000000000143

fscrypt_inode_uses_inline_crypto+0x4/0xc
page_cache_sync_ra+0x68/0x90
filemap_read+0x194/0xb14
generic_file_read_iter+0x44/0x134
vfs_read+0x1a8/0x27c
arm64_sys_pread64+0x84/0xc8
invoke_syscall+0x40/0x104
el0_svc_common+0xbc/0x168
do_el0_svc+0x1c/0x28
el0_svc+0x1c/0x68
el0t_64_sync_handler+0x68/0xb4
el0t_64_sync+0x164/0x168

Signed-off-by: Yifeng Zhao <yifeng.zhao@rock-chips.com>
Change-Id: I5a69580f26e578e46110782d3d20c9f1df2acd50
This commit is contained in:
Yifeng Zhao 2024-06-12 15:05:24 +08:00 committed by Tao Huang
commit 151ca068c0

View file

@ -228,6 +228,8 @@ void fscrypt_destroy_inline_crypt_key(struct super_block *sb,
bool __fscrypt_inode_uses_inline_crypto(const struct inode *inode)
{
if (!inode->i_crypt_info)
return false;
return inode->i_crypt_info->ci_inlinecrypt;
}
EXPORT_SYMBOL_GPL(__fscrypt_inode_uses_inline_crypto);