From: Li Dongyang Date: Tue, 16 Jul 2019 07:01:01 +0000 (-0700) Subject: LU-12331 llite: create obd_device with usercopy whitelist X-Git-Tag: 2.12.3-RC1~114 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=c8cf8521f517842febbab24e0b20a4b88e615416;p=fs%2Flustre-release.git LU-12331 llite: create obd_device with usercopy whitelist Since kernel 4.16 hardened usercopy has been added, whitelist the struct obd_device to silence the warning. Bad or missing usercopy whitelist? Kernel memory exposure attempt detected from SLUB object 'll_obd_dev_cache' (offset 1256, size 40)! WARNING: CPU: 1 PID: 17534 at mm/usercopy.c:83 usercopy_warn+0x7d/0xa0 Call Trace: __check_object_size+0xfa/0x181 lmv_iocontrol+0x1146/0x1880 [lmv] ll_obd_statfs+0x356/0x860 [lustre] ll_dir_ioctl+0x1e37/0x6760 [lustre] do_vfs_ioctl+0xa4/0x630 Linux-commit: 8eb8284b412906181357c2b0110d879d5af95e52 This patch is back-ported from the following one: Lustre-commit: 7f77996b1c4ac3a874a1f9e016e8b0e3cfee6992 Lustre-change: https://review.whamcloud.com/34946 Test-Parameters: trivial Signed-off-by: Li Dongyang Change-Id: Ie863e8a5e2cebd3fd716e7ccc4e0491f83f6fabc Reviewed-on: https://review.whamcloud.com/35528 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Li Xi --- diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 862c1c7..ae99a9e 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -787,4 +788,10 @@ static inline bool bdev_integrity_enabled(struct block_device *bdev, int rw) #define xa_unlock_irq(lockp) spin_unlock_irq(lockp) #endif +#ifndef KMEM_CACHE_USERCOPY +#define kmem_cache_create_usercopy(name, size, align, flags, useroffset, \ + usersize, ctor) \ + kmem_cache_create(name, size, align, flags, ctor) +#endif + #endif /* _LUSTRE_COMPAT_H */ diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 9c71703..5a3802d 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -910,9 +910,9 @@ int obd_init_caches(void) ENTRY; LASSERT(obd_device_cachep == NULL); - obd_device_cachep = kmem_cache_create("ll_obd_dev_cache", - sizeof(struct obd_device), - 0, 0, NULL); + obd_device_cachep = kmem_cache_create_usercopy("ll_obd_dev_cache", + sizeof(struct obd_device), + 0, 0, 0, sizeof(struct obd_device), NULL); if (!obd_device_cachep) GOTO(out, rc = -ENOMEM);