mm/slab: remove HAVE_HARDENED_USERCOPY_ALLOCATOR
Subsystems (4)
PATCH 1/1 mm/slab: remove HAVE_HARDENED_USERCOPY_ALLOCATOR
With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef.
--- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-)
mm/Kconfig +0 -2
@@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in
@@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach).
mm/slab.h +0 -9
@@ -832,17 +832,8 @@ struct kmem_obj_info {void __kmem_obj_info (struct kmem_obj_info *kpp,void *object,struct slab *slab);#endif -#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object (const void *ptr,unsigned long n,const struct slab *slab,bool to_user); -#else -static inline -void __check_heap_object (const void *ptr,unsigned long n, -const struct slab *slab,bool to_user) -{ -} -#endif -#ifdef CONFIG_SLUB_DEBUG void skip_orig_size_check (struct kmem_cache *s,const void *object);#endif
security/Kconfig +0 -8
@@ -127,16 +127,8 @@ config LSM_MMAP_MIN_ADDR this low address space will need the permission specific to the systems running LSM. -config HAVE_HARDENED_USERCOPY_ALLOCATOR - bool - help - The heap allocator implements __check_heap_object() for - validating memory ranges against heap object sizes in - support of CONFIG_HARDENED_USERCOPY. - config HARDENED_USERCOPY bool "Harden memory copies between kernel and userspace" - depends on HAVE_HARDENED_USERCOPY_ALLOCATOR imply STRICT_DEVMEM help This option checks for obviously wrong memory regions when
Signature · 1 line
2.40.1
Quoted 38 lines · Vlastimil Babka
With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef.
Signed-off-by Vlastimil Babka <[email protected]>--- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-)mm/Kconfig +0
-2@@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in@@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach).mm/slab.h +0
-0@@ -832,17 +832,8 @@ struct kmem_obj_info {void __kmem_obj_info (struct kmem_obj_info *kpp,void *object,struct slab *slab);#endif
mm/slab.h struct kmem_obj_info { · line 844
Quoted 10 lines
mm/slab.h +0
-8-#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object (const void *ptr,unsigned long n,const struct slab *slab,bool to_user); -#else -static inline -void __check_heap_object (const void *ptr,unsigned long n, -const struct slab *slab,bool to_user) -{ -} -#endif
Hm, this is still defined in slab.c/slub.c and invoked in usercopy.c, do we not want the prototype? Perhaps replacing with #ifdef CONFIG_HARDENED_USERCOPY instead? I may be missing something here :)
Quoted 28 lines
mm/slab.h +0
-1-#ifdef CONFIG_SLUB_DEBUG void skip_orig_size_check (struct kmem_cache *s,const void *object);#endif security/Kconfig +0
-9@@ -127,16 +127,8 @@ config LSM_MMAP_MIN_ADDR this low address space will need the permission specific to the systems running LSM. -config HAVE_HARDENED_USERCOPY_ALLOCATOR - bool - help - The heap allocator implements __check_heap_object() for - validating memory ranges against heap object sizes in - support of CONFIG_HARDENED_USERCOPY. - config HARDENED_USERCOPY bool "Harden memory copies between kernel and userspace" - depends on HAVE_HARDENED_USERCOPY_ALLOCATOR imply STRICT_DEVMEM help This option checks for obviously wrong memory regions when --2.40.1
Quoted 39 lines · Lorenzo Stoakes
Quoted 38 lines · Vlastimil Babka
With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef.
Signed-off-by Vlastimil Babka <[email protected]>--- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-)mm/Kconfig +0
-2@@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in@@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach).mm/slab.h +0
-0@@ -832,17 +832,8 @@ struct kmem_obj_info {void __kmem_obj_info (struct kmem_obj_info *kpp,void *object,struct slab *slab);#endif
Quoted 13 lines
mm/slab.h struct kmem_obj_info { · line 844
Quoted 10 lines
mm/slab.h +0
-8-#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object (const void *ptr,unsigned long n,const struct slab *slab,bool to_user); -#else -static inline -void __check_heap_object (const void *ptr,unsigned long n, -const struct slab *slab,bool to_user) -{ -} -#endif Hm, this is still defined in
slab.c/slub.cand invoked inusercopy.c, do we not want the prototype?
Well I didn't delete the prototype, just the ifdef/else around, so now it's there unconditionally.
Quoted 2 lines
Perhaps replacing with #ifdef
CONFIG_HARDENED_USERCOPYinstead? I may be missing something here :)
Putting it under that #ifdef would work and match that the implementations of that function are under that same ifdef, but maybe it's unnecessary noise in the header?
Quoted 57 lines · Vlastimil Babka
Quoted 39 lines · Lorenzo Stoakes
Quoted 38 lines · Vlastimil Babka
With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef.
Signed-off-by Vlastimil Babka <[email protected]>--- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-)mm/Kconfig +0
-2@@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in@@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach).mm/slab.h +0
-0@@ -832,17 +832,8 @@ struct kmem_obj_info {void __kmem_obj_info (struct kmem_obj_info *kpp,void *object,struct slab *slab);#endif Quoted 13 lines
mm/slab.h struct kmem_obj_info { · line 844
Quoted 10 lines
mm/slab.h +0
-8-#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object (const void *ptr,unsigned long n,const struct slab *slab,bool to_user); -#else -static inline -void __check_heap_object (const void *ptr,unsigned long n, -const struct slab *slab,bool to_user) -{ -} -#endif Hm, this is still defined in
slab.c/slub.cand invoked inusercopy.c, do we not want the prototype?Well I didn't delete the prototype, just the ifdef/else around, so now it's there unconditionally.
Quoted 7 lines
Quoted 2 lines
Perhaps replacing with #ifdef
CONFIG_HARDENED_USERCOPYinstead? I may be missing something here :)Putting it under that #ifdef would work and match that the implementations of that function are under that same ifdef, but maybe it's unnecessary noise in the header?
Yeah my brain inserted extra '-'s there, sorry!
Given we only define __check_heap_object() in sl[au]b.c if CONFIG_HARDENED_USERCOPY wouldn't we need to keep the empty version around if !CONFIG_HARDENED_USERCOPY since check_heap_object() appears to be called unconditionally?
David Hildenbrand
Reviewed-byQuoted 66 lines · Lorenzo Stoakes
Quoted 57 lines · Vlastimil Babka
Quoted 39 lines · Lorenzo Stoakes
Quoted 38 lines · Vlastimil Babka
With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef.
Signed-off-by Vlastimil Babka <[email protected]>--- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-)mm/Kconfig +0
-2@@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in@@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach).mm/slab.h +0
-0@@ -832,17 +832,8 @@ struct kmem_obj_info {void __kmem_obj_info (struct kmem_obj_info *kpp,void *object,struct slab *slab);#endif Quoted 13 lines
mm/slab.h struct kmem_obj_info { · line 844
Quoted 10 lines
mm/slab.h +0
-8-#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object (const void *ptr,unsigned long n,const struct slab *slab,bool to_user); -#else -static inline -void __check_heap_object (const void *ptr,unsigned long n, -const struct slab *slab,bool to_user) -{ -} -#endif Hm, this is still defined in
slab.c/slub.cand invoked inusercopy.c, do we not want the prototype?Well I didn't delete the prototype, just the ifdef/else around, so now it's there unconditionally.
Quoted 7 lines
Quoted 2 lines
Perhaps replacing with #ifdef
CONFIG_HARDENED_USERCOPYinstead? I may be missing something here :)Putting it under that #ifdef would work and match that the implementations of that function are under that same ifdef, but maybe it's unnecessary noise in the header?
Quoted 7 lines
Yeah my brain inserted extra '-'s there, sorry!
Given we only define
__check_heap_object()in sl[au]b.c ifCONFIG_HARDENED_USERCOPYwouldn't we need to keep the empty version around if !CONFIG_HARDENED_USERCOPY sincecheck_heap_object()appears to be called unconditionally?
The file is only compiled with CONFIG_HARDENED_USERCOPY:
mm/Makefile:obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o
Signature · 3 lines
Thanks, David / dhildenb
Quoted 75 lines · David Hildenbrand
Quoted 66 lines · Lorenzo Stoakes
Quoted 57 lines · Vlastimil Babka
Quoted 39 lines · Lorenzo Stoakes
Quoted 38 lines · Vlastimil Babka
With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef.
Signed-off-by Vlastimil Babka <[email protected]>--- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-)mm/Kconfig +0
-2@@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in@@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach).mm/slab.h +0
-0@@ -832,17 +832,8 @@ struct kmem_obj_info {void __kmem_obj_info (struct kmem_obj_info *kpp,void *object,struct slab *slab);#endif Quoted 13 lines
mm/slab.h struct kmem_obj_info { · line 844
Quoted 10 lines
mm/slab.h +0
-8-#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object (const void *ptr,unsigned long n,const struct slab *slab,bool to_user); -#else -static inline -void __check_heap_object (const void *ptr,unsigned long n, -const struct slab *slab,bool to_user) -{ -} -#endif Hm, this is still defined in
slab.c/slub.cand invoked inusercopy.c, do we not want the prototype?Well I didn't delete the prototype, just the ifdef/else around, so now it's there unconditionally.
Quoted 7 lines
Quoted 2 lines
Perhaps replacing with #ifdef
CONFIG_HARDENED_USERCOPYinstead? I may be missing something here :)Putting it under that #ifdef would work and match that the implementations of that function are under that same ifdef, but maybe it's unnecessary noise in the header?
Quoted 7 lines
Yeah my brain inserted extra '-'s there, sorry!
Given we only define
__check_heap_object()in sl[au]b.c ifCONFIG_HARDENED_USERCOPYwouldn't we need to keep the empty version around if !CONFIG_HARDENED_USERCOPY sincecheck_heap_object()appears to be called unconditionally?
Quoted 4 lines
The file is only compiled with
CONFIG_HARDENED_USERCOPY:mm/Makefile:obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o
Yeah ugh at this sort of implicit thing. Anyway it'd be preferable to stick #ifdef CONFIG_HARDENED_USERCOPY around the prototype just so it's abundantly clear this function doesn't exist unless that is set.
Quoted 9 lines
Reviewed-by David Hildenbrand <[email protected]>--
Thanks,David / dhildenb
Quoted 76 lines · Lorenzo Stoakes
Quoted 75 lines · David Hildenbrand
Quoted 73 lines · Lorenzo Stoakes
Quoted 57 lines · Vlastimil Babka
Quoted 39 lines · Lorenzo Stoakes
Quoted 38 lines · Vlastimil Babka
With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef.
Signed-off-by Vlastimil Babka <[email protected]>--- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-)mm/Kconfig +0
-2@@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in@@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach).mm/slab.h +0
-0@@ -832,17 +832,8 @@ struct kmem_obj_info {void __kmem_obj_info (struct kmem_obj_info *kpp,void *object,struct slab *slab);#endif Quoted 13 lines
mm/slab.h struct kmem_obj_info { · line 844
Quoted 10 lines
mm/slab.h +0
-8-#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object (const void *ptr,unsigned long n,const struct slab *slab,bool to_user); -#else -static inline -void __check_heap_object (const void *ptr,unsigned long n, -const struct slab *slab,bool to_user) -{ -} -#endif Hm, this is still defined in
slab.c/slub.cand invoked inusercopy.c, do we not want the prototype?Well I didn't delete the prototype, just the ifdef/else around, so now it's there unconditionally.
Quoted 7 lines
Quoted 2 lines
Perhaps replacing with #ifdef
CONFIG_HARDENED_USERCOPYinstead? I may be missing something here :)Putting it under that #ifdef would work and match that the implementations of that function are under that same ifdef, but maybe it's unnecessary noise in the header?
Yeah my brain inserted extra '-'s there, sorry!
Given we only define
__check_heap_object()in sl[au]b.c ifCONFIG_HARDENED_USERCOPYwouldn't we need to keep the empty version around if !CONFIG_HARDENED_USERCOPY sincecheck_heap_object()appears to be called unconditionally?
Quoted 8 lines
Quoted 4 lines
The file is only compiled with
CONFIG_HARDENED_USERCOPY:mm/Makefile:obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o
Yeah ugh at this sort of implicit thing. Anyway it'd be preferable to stick #ifdef
CONFIG_HARDENED_USERCOPYaround the prototype just so it's abundantly clear this function doesn't exist unless that is set.
I recall that it is very common to not use ifdefs unless really required. Because less ifefs are obviously preferable ;)
Compilation+linking will fail in any case.
Signature · 3 lines
Thanks, David / dhildenb
Lorenzo Stoakes
Reviewed-byOn Tue, May 23, 2023 at 10:28:32AM +0200, David Hildenbrand wrote:
[snip]
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
The file is only compiled with
CONFIG_HARDENED_USERCOPY:mm/Makefile:obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o
Quoted 9 lines
Quoted 3 lines
Yeah ugh at this sort of implicit thing. Anyway it'd be preferable to stick #ifdef
CONFIG_HARDENED_USERCOPYaround the prototype just so it's abundantly clear this function doesn't exist unless that is set.I recall that it is very common to not use ifdefs unless really required. Because less ifefs are obviously preferable ;)
Compilation+linking will fail in any case.
I don't want to insist so hard on something that doesn't really matter, the bike shed can be blue, green or red it's fine :P
So,
Kees Cook
Reviewed-byQuoted 75 lines · David Hildenbrand
Quoted 66 lines · Lorenzo Stoakes
Quoted 57 lines · Vlastimil Babka
Quoted 39 lines · Lorenzo Stoakes
Quoted 38 lines · Vlastimil Babka
With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef.
Signed-off-by Vlastimil Babka <[email protected]>--- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-)mm/Kconfig +0
-2@@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in@@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach).mm/slab.h +0
-0@@ -832,17 +832,8 @@ struct kmem_obj_info {void __kmem_obj_info (struct kmem_obj_info *kpp,void *object,struct slab *slab);#endif Quoted 13 lines
mm/slab.h struct kmem_obj_info { · line 844
Quoted 10 lines
mm/slab.h +0
-8-#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object (const void *ptr,unsigned long n,const struct slab *slab,bool to_user); -#else -static inline -void __check_heap_object (const void *ptr,unsigned long n, -const struct slab *slab,bool to_user) -{ -} -#endif Hm, this is still defined in
slab.c/slub.cand invoked inusercopy.c, do we not want the prototype?Well I didn't delete the prototype, just the ifdef/else around, so now it's there unconditionally.
Quoted 7 lines
Quoted 2 lines
Perhaps replacing with #ifdef
CONFIG_HARDENED_USERCOPYinstead? I may be missing something here :)Putting it under that #ifdef would work and match that the implementations of that function are under that same ifdef, but maybe it's unnecessary noise in the header?
Quoted 7 lines
Yeah my brain inserted extra '-'s there, sorry!
Given we only define
__check_heap_object()in sl[au]b.c ifCONFIG_HARDENED_USERCOPYwouldn't we need to keep the empty version around if !CONFIG_HARDENED_USERCOPY sincecheck_heap_object()appears to be called unconditionally?
Quoted 3 lines
The file is only compiled with
CONFIG_HARDENED_USERCOPY:mm/Makefile:obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o
Right.
Quoted 1 line
Reviewed-by David Hildenbrand <[email protected]>
Thanks!
Signature · 1 line
Kees Cook
Quoted 80 lines · Kees Cook
Quoted 75 lines · David Hildenbrand
Quoted 66 lines · Lorenzo Stoakes
Quoted 57 lines · Vlastimil Babka
Quoted 39 lines · Lorenzo Stoakes
Quoted 38 lines · Vlastimil Babka
With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef.
Signed-off-by Vlastimil Babka <[email protected]>--- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-)mm/Kconfig +0
-2@@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in@@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach).mm/slab.h +0
-0@@ -832,17 +832,8 @@ struct kmem_obj_info {void __kmem_obj_info (struct kmem_obj_info *kpp,void *object,struct slab *slab);#endif Quoted 13 lines
mm/slab.h struct kmem_obj_info { · line 844
Quoted 10 lines
mm/slab.h +0
-8-#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object (const void *ptr,unsigned long n,const struct slab *slab,bool to_user); -#else -static inline -void __check_heap_object (const void *ptr,unsigned long n, -const struct slab *slab,bool to_user) -{ -} -#endif Hm, this is still defined in
slab.c/slub.cand invoked inusercopy.c, do we not want the prototype?Well I didn't delete the prototype, just the ifdef/else around, so now it's there unconditionally.
Quoted 7 lines
Quoted 2 lines
Perhaps replacing with #ifdef
CONFIG_HARDENED_USERCOPYinstead? I may be missing something here :)Putting it under that #ifdef would work and match that the implementations of that function are under that same ifdef, but maybe it's unnecessary noise in the header?
Quoted 7 lines
Yeah my brain inserted extra '-'s there, sorry!
Given we only define
__check_heap_object()in sl[au]b.c ifCONFIG_HARDENED_USERCOPYwouldn't we need to keep the empty version around if !CONFIG_HARDENED_USERCOPY sincecheck_heap_object()appears to be called unconditionally?Quoted 3 lines
The file is only compiled with
CONFIG_HARDENED_USERCOPY:mm/Makefile:obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o
Quoted 8 lines
Right.
Quoted 1 line
Reviewed-by David Hildenbrand <[email protected]>Thanks!
Reviewed-by Kees Cook <[email protected]>
Hyeonggon Yoo
Acked-byQuoted 84 lines · David Rientjes
Quoted 82 lines · Kees Cook
Quoted 75 lines · David Hildenbrand
Quoted 66 lines · Lorenzo Stoakes
Quoted 57 lines · Vlastimil Babka
Quoted 39 lines · Lorenzo Stoakes
Quoted 38 lines · Vlastimil Babka
With SLOB removed, both remaining allocators support hardened usercopy, so remove the config and associated #ifdef.
Signed-off-by Vlastimil Babka <[email protected]>--- mm/Kconfig | 2 -- mm/slab.h | 9 --------- security/Kconfig | 8 -------- 3 files changed, 19 deletions(-)mm/Kconfig +0
-2@@ -221,7 +221,6 @@ choice config SLAB bool "SLAB" depends on !PREEMPT_RT - select HAVE_HARDENED_USERCOPY_ALLOCATOR help The regular slab allocator that is established and known to work well in all environments. It organizes cache hot objects in@@ -229,7 +228,6 @@ config SLAB config SLUB bool "SLUB (Unqueued Allocator)" - select HAVE_HARDENED_USERCOPY_ALLOCATOR help SLUB is a slab allocator that minimizes cache line usage instead of managing queues of cached objects (SLAB approach).mm/slab.h +0
-0@@ -832,17 +832,8 @@ struct kmem_obj_info {void __kmem_obj_info (struct kmem_obj_info *kpp,void *object,struct slab *slab);#endif Quoted 13 lines
mm/slab.h struct kmem_obj_info { · line 844
Quoted 10 lines
mm/slab.h +0
-8-#ifdef CONFIG_HAVE_HARDENED_USERCOPY_ALLOCATOR void __check_heap_object (const void *ptr,unsigned long n,const struct slab *slab,bool to_user); -#else -static inline -void __check_heap_object (const void *ptr,unsigned long n, -const struct slab *slab,bool to_user) -{ -} -#endif Hm, this is still defined in
slab.c/slub.cand invoked inusercopy.c, do we not want the prototype?Well I didn't delete the prototype, just the ifdef/else around, so now it's there unconditionally.
Quoted 7 lines
Quoted 2 lines
Perhaps replacing with #ifdef
CONFIG_HARDENED_USERCOPYinstead? I may be missing something here :)Putting it under that #ifdef would work and match that the implementations of that function are under that same ifdef, but maybe it's unnecessary noise in the header?
Quoted 7 lines
Yeah my brain inserted extra '-'s there, sorry!
Given we only define
__check_heap_object()in sl[au]b.c ifCONFIG_HARDENED_USERCOPYwouldn't we need to keep the empty version around if !CONFIG_HARDENED_USERCOPY sincecheck_heap_object()appears to be called unconditionally?Quoted 3 lines
The file is only compiled with
CONFIG_HARDENED_USERCOPY:mm/Makefile:obj-$(CONFIG_HARDENED_USERCOPY) += usercopy.o
Right.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Reviewed-by David Hildenbrand <[email protected]>Thanks!
Reviewed-by Kees Cook <[email protected]>Acked-by David Rientjes <[email protected]>
looks fine to me,
Signature · 5 lines
Hyeonggon Yoo Doing kernel stuff as a hobby Undergraduate | Chungnam National University Dept. Computer Science & Engineering