mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-22 05:01:27 +00:00
scst, scst_user: Add support for usercopy hardening
Avoid that with CONFIG_HARDENED_USERCOPY enabled warnings appear about kernel memory exposure attempts when using scst_user. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7601 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -4212,8 +4212,8 @@ static int __init init_scst_user(void)
|
||||
goto out;
|
||||
}
|
||||
|
||||
user_cmd_cachep = KMEM_CACHE(scst_user_cmd,
|
||||
SCST_SLAB_FLAGS|SLAB_HWCACHE_ALIGN);
|
||||
user_cmd_cachep = KMEM_CACHE_USERCOPY(scst_user_cmd,
|
||||
SCST_SLAB_FLAGS | SLAB_HWCACHE_ALIGN, user_cmd);
|
||||
if (user_cmd_cachep == NULL) {
|
||||
res = -ENOMEM;
|
||||
goto out_dev_cache;
|
||||
|
||||
@@ -2586,6 +2586,13 @@ static int __init init_scst(void)
|
||||
sizeof(struct s)); \
|
||||
(p); \
|
||||
})
|
||||
#define INIT_CACHEP_ALIGN_USERCOPY(p, s, f) ({ \
|
||||
(p) = KMEM_CACHE_USERCOPY(s, SCST_SLAB_FLAGS | \
|
||||
SLAB_HWCACHE_ALIGN, f); \
|
||||
TRACE_MEM("Slab create: %s at %p size %zd", #s, (p), \
|
||||
sizeof(struct s)); \
|
||||
(p); \
|
||||
})
|
||||
|
||||
res = -ENOMEM;
|
||||
if (!INIT_CACHEP(scst_mgmt_cachep, scst_mgmt_cmd))
|
||||
@@ -2601,7 +2608,7 @@ static int __init init_scst(void)
|
||||
}
|
||||
if (!INIT_CACHEP(scst_aen_cachep, scst_aen)) /* read-mostly */
|
||||
goto out_destroy_sense_cache;
|
||||
if (!INIT_CACHEP_ALIGN(scst_cmd_cachep, scst_cmd))
|
||||
if (!INIT_CACHEP_ALIGN_USERCOPY(scst_cmd_cachep, scst_cmd, cdb))
|
||||
goto out_destroy_aen_cache;
|
||||
/* Big enough with read-mostly head and tail */
|
||||
if (!INIT_CACHEP(scst_sess_cachep, scst_session))
|
||||
|
||||
Reference in New Issue
Block a user