drivers/net: Make rtskb pool cache being an usercopy source
PATCH v2 1/1 drivers/net: Make rtskb pool cache being an usercopy source
When kernel enable CONFIG_HARDENED_USERCOPY option, since not marking rtskb_slab_pool cache is usercopy type, will trigger the following calltrace.
[ 594.413602] invalid opcode: 0000 1 PREEMPT SMP PTI IRQ_PIPELINE [ 594.413603] CPU: 2 PID: 492 Comm: rtcfg Tainted: [ 594.413603] IRQ stage: Linux [ 594.413604] RIP: 0010:usercopy_abort+0x77/0x79 [ 594.413610] Call Trace: [ 594.413610] __check_heap_object+0xa6/0xc0 [ 594.413611] __check_object_size+0x136/0x150 [ 594.413611] copy_stage_1_data+0x48/0x70 [rtcfg] [ 594.413612] rtnet_rtpc_dispatch_call+0x151/0x320 [rtnet] [ 594.413612] ? cleanup_cmd_del+0x70/0x70 [rtcfg] [ 594.413612] ? wait_woken+0x70/0x70 [ 594.413613] rtcfg_ioctl+0xa0/0x250 [rtcfg] [ 594.413613] rtnet_ioctl+0xdf/0x170 [rtnet] [ 594.413613] __x64_sys_ioctl+0x83/0xb0 [ 594.413613] do_syscall_64+0x39/0x50 [ 594.413614] entry_SYSCALL_64_after_hwframe+0x44/0xa9
This commit make rtskb_slab_pool cache being an usercopy source.
Signed-off-by Zqiang <[email protected]>
---
v1->v2:
Adjust code indentation.
kernel/drivers/net/stack/rtskb.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/drivers/net/stack/rtskb.c +4 -3
@@ -497,10 +497,11 @@ EXPORT_SYMBOL_GPL(rtskb_clone);int rtskb_pools_init (void ) { - rtskb_slab_pool =kmem_cache_create ("rtskb_slab_pool" , -ALIGN_RTSKB_STRUCT_LEN + + rtskb_slab_pool =kmem_cache_create_usercopy ("rtskb_slab_pool" , +ALIGN_RTSKB_STRUCT_LEN +SKB_DATA_ALIGN (RTSKB_SIZE ), -0 ,SLAB_HWCACHE_ALIGN ,NULL ); +0 ,SLAB_HWCACHE_ALIGN , +0 ,SKB_DATA_ALIGN (RTSKB_SIZE ),NULL );if (rtskb_slab_pool ==NULL )return -ENOMEM ;
Signature · 1 line
2.25.1