diff options
author | Brian Behlendorf <[email protected]> | 2015-09-28 09:08:11 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2015-09-28 09:18:29 -0700 |
commit | 2ebe396046c99ea191a51f24658273fd860b88c4 (patch) | |
tree | 5f7f079911cfb58942c2d694b76c8aeeeabe98c4 /module | |
parent | f17d005bcc9b7edeb15b10bf947379a504b2d9f7 (diff) |
Fix PAX Patch/Grsec SLAB_USERCOPY panic
Support grsecurity/PaX kernel configurations where
CONFIG_PAX_USERCOPY_SLABS are enabled. When this kernel option
is enabled slabs which are used to copy between user and kernel
space must be created with SLAB_USERCOPY.
Stock Linux kernels do not have a SLAB_USERCOPY definition so
this causes no change in behavior for non-PAX-enabled kernels.
Verified-by: Wuffleton <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Issue #2977
Issue #3796
Diffstat (limited to 'module')
-rw-r--r-- | module/spl/spl-kmem-cache.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/module/spl/spl-kmem-cache.c b/module/spl/spl-kmem-cache.c index a83c9f3ae..a7f9ca3a5 100644 --- a/module/spl/spl-kmem-cache.c +++ b/module/spl/spl-kmem-cache.c @@ -986,13 +986,23 @@ spl_kmem_cache_create(char *name, size_t size, size_t align, if (rc) goto out; } else { + unsigned long slabflags = 0; + if (size > (SPL_MAX_KMEM_ORDER_NR_PAGES * PAGE_SIZE)) { rc = EINVAL; goto out; } +#if defined(SLAB_USERCOPY) + /* + * Required for PAX-enabled kernels if the slab is to be + * used for coping between user and kernel space. + */ + slabflags |= SLAB_USERCOPY; +#endif + skc->skc_linux_cache = kmem_cache_create( - skc->skc_name, size, align, 0, NULL); + skc->skc_name, size, align, slabflags, NULL); if (skc->skc_linux_cache == NULL) { rc = ENOMEM; goto out; |