From 50d607a3363ef3835f75e8b76d602397dd258918 Mon Sep 17 00:00:00 2001 From: Chesnokov Gleb Date: Wed, 15 Dec 2021 17:33:41 +0300 Subject: [PATCH] isert-scst: Enable copying to user space from isert_cmnd_cache This patch fixes warning with call trace that occurs during copy_to_user() from isert_read(): usercopy: Kernel memory exposure attempt detected from SLUB object 'sgv-clust-64K' (offset 200, size 48)! ------------[ cut here ]------------ kernel BUG at mm/usercopy.c:99! ... RIP: 0010:usercopy_abort+0x7b/0x7d Call Trace: __check_heap_object+0xdf/0x110 __check_object_size.part.0+0x128/0x150 __check_object_size+0x1c/0x20 isert_read+0x10b/0x380 [isert_scst] ? security_file_permission+0x96/0x160 vfs_read+0x9f/0x190 ksys_read+0x67/0xe0 __x64_sys_read+0x19/0x20 do_syscall_64+0x61/0xb0 ? __x64_sys_sendto+0x24/0x30 ? do_syscall_64+0x6e/0xb0 ? exit_to_user_mode_prepare+0x37/0xb0 ? syscall_exit_to_user_mode+0x27/0x50 ? do_syscall_64+0x6e/0xb0 ? asm_exc_page_fault+0x8/0x30 entry_SYSCALL_64_after_hwframe+0x44/0xae Signed-off-by: Morozov Ilia --- iscsi-scst/kernel/isert-scst/iser_global.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/iscsi-scst/kernel/isert-scst/iser_global.c b/iscsi-scst/kernel/isert-scst/iser_global.c index 96783c913..f7f7f5400 100644 --- a/iscsi-scst/kernel/isert-scst/iser_global.c +++ b/iscsi-scst/kernel/isert-scst/iser_global.c @@ -144,8 +144,9 @@ int isert_global_init(void) return -ENOMEM; } - isert_cmnd_cache = KMEM_CACHE(isert_cmnd, - SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN); + isert_cmnd_cache = KMEM_CACHE_USERCOPY(isert_cmnd, + SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN, + iscsi); if (!isert_cmnd_cache) { destroy_workqueue(isert_glob.conn_wq); PRINT_ERROR("Failed to alloc iser command cache");