History

mm: remove HARDENED_USERCOPY_FALLBACK

This has served its purpose and is no longer used. All usercopy violations appear to have been handled by now, any remaining instances (or new bugs) will cause copies to be rejected. This isn't a direct revert of commit 2d891fbc3bb6 ("usercopy: Allow strict enforcement of whitelists"); since usercopy_fallback is effectively 0, the fallback handling is removed too. This also removes the usercopy_fallback module parameter on slab_common.

Stephen Kitt committed 5 years ago

Commit 53944f11 parent 755804d6 files · +0 −52Browse files

Unified · Split

6 files
  1. arch/powerpc/configs/skiroot_defconfig +0 −1
  2. include/linux/slab.h +0 −2
  3. mm/slab.c +0 −13
  4. mm/slab_common.c +0 −8
  5. mm/slub.c +0 −14
  6. security/Kconfig +0 −14
arch/powerpc/configs/skiroot_defconfig+0−1
@@ -275,7 +275,6 @@ CONFIG_NLS_UTF8=y · 274 unmodified lines
275CONFIG_ENCRYPTED_KEYS=y275CONFIG_ENCRYPTED_KEYS=y
276CONFIG_SECURITY=y276CONFIG_SECURITY=y
277CONFIG_HARDENED_USERCOPY=y277CONFIG_HARDENED_USERCOPY=y
278# CONFIG_HARDENED_USERCOPY_FALLBACK is not set
279CONFIG_HARDENED_USERCOPY_PAGESPAN=y278CONFIG_HARDENED_USERCOPY_PAGESPAN=y
280CONFIG_FORTIFY_SOURCE=y279CONFIG_FORTIFY_SOURCE=y
281CONFIG_SECURITY_LOCKDOWN_LSM=y280CONFIG_SECURITY_LOCKDOWN_LSM=y
include/linux/slab.h+0−2
@@ -142,8 +142,6 @@ struct mem_cgroup; · 141 unmodified lines
142void __init kmem_cache_init(void);142void __init kmem_cache_init(void);
143bool slab_is_available(void);143bool slab_is_available(void);
144 144
145extern bool usercopy_fallback;
146
147struct kmem_cache *kmem_cache_create(const char *name, unsigned int size,145struct kmem_cache *kmem_cache_create(const char *name, unsigned int size,
148 unsigned int align, slab_flags_t flags,146 unsigned int align, slab_flags_t flags,
149 void (*ctor)(void *));147 void (*ctor)(void *));
mm/slab.c+0−13
@@ -4204,19 +4204,6 @@ void __check_heap_object(const void *ptr, unsigned long n, struct page *page, · 4203 unmodified lines
4204 n <= cachep->useroffset - offset + cachep->usersize)4204 n <= cachep->useroffset - offset + cachep->usersize)
4205 return;4205 return;
4206 4206
4207 /*
4208 * If the copy is still within the allocated object, produce
4209 * a warning instead of rejecting the copy. This is intended
4210 * to be a temporary method to find any missing usercopy
4211 * whitelists.
4212 */
4213 if (usercopy_fallback &&
4214 offset <= cachep->object_size &&
4215 n <= cachep->object_size - offset) {
4216 usercopy_warn("SLAB object", cachep->name, to_user, offset, n);
4217 return;
4218 }
4219
4220 usercopy_abort("SLAB object", cachep->name, to_user, offset, n);4207 usercopy_abort("SLAB object", cachep->name, to_user, offset, n);
4221}4208}
4222#endif /* CONFIG_HARDENED_USERCOPY */4209#endif /* CONFIG_HARDENED_USERCOPY */
mm/slab_common.c+0−8
@@ -37,14 +37,6 @@ LIST_HEAD(slab_caches); · 36 unmodified lines
37DEFINE_MUTEX(slab_mutex);37DEFINE_MUTEX(slab_mutex);
38struct kmem_cache *kmem_cache;38struct kmem_cache *kmem_cache;
39 39
40#ifdef CONFIG_HARDENED_USERCOPY
41bool usercopy_fallback __ro_after_init =
42 IS_ENABLED(CONFIG_HARDENED_USERCOPY_FALLBACK);
43module_param(usercopy_fallback, bool, 0400);
44MODULE_PARM_DESC(usercopy_fallback,
45 "WARN instead of reject usercopy whitelist violations");
46#endif
47
48static LIST_HEAD(slab_caches_to_rcu_destroy);40static LIST_HEAD(slab_caches_to_rcu_destroy);
49static void slab_caches_to_rcu_destroy_workfn(struct work_struct *work);41static void slab_caches_to_rcu_destroy_workfn(struct work_struct *work);
50static DECLARE_WORK(slab_caches_to_rcu_destroy_work,42static DECLARE_WORK(slab_caches_to_rcu_destroy_work,
mm/slub.c+0−14
@@ -4489,7 +4489,6 @@ void __check_heap_object(const void *ptr, unsigned long n, struct page *page, · 4488 unmodified lines
4489{4489{
4490 struct kmem_cache *s;4490 struct kmem_cache *s;
4491 unsigned int offset;4491 unsigned int offset;
4492 size_t object_size;
4493 bool is_kfence = is_kfence_address(ptr);4492 bool is_kfence = is_kfence_address(ptr);
4494 4493
4495 ptr = kasan_reset_tag(ptr);4494 ptr = kasan_reset_tag(ptr);
@@ -4522,19 +4521,6 @@ void __check_heap_object(const void *ptr, unsigned long n, struct page *page, · 26 unmodified lines
4522 n <= s->useroffset - offset + s->usersize)4521 n <= s->useroffset - offset + s->usersize)
4523 return;4522 return;
4524 4523
4525 /*
4526 * If the copy is still within the allocated object, produce
4527 * a warning instead of rejecting the copy. This is intended
4528 * to be a temporary method to find any missing usercopy
4529 * whitelists.
4530 */
4531 object_size = slab_ksize(s);
4532 if (usercopy_fallback &&
4533 offset <= object_size && n <= object_size - offset) {
4534 usercopy_warn("SLUB object", s->name, to_user, offset, n);
4535 return;
4536 }
4537
4538 usercopy_abort("SLUB object", s->name, to_user, offset, n);4524 usercopy_abort("SLUB object", s->name, to_user, offset, n);
4539}4525}
4540#endif /* CONFIG_HARDENED_USERCOPY */4526#endif /* CONFIG_HARDENED_USERCOPY */
security/Kconfig+0−14
@@ -163,20 +163,6 @@ config HARDENED_USERCOPY · 162 unmodified lines
163 or are part of the kernel text. This kills entire classes163 or are part of the kernel text. This kills entire classes
164 of heap overflow exploits and similar kernel memory exposures.164 of heap overflow exploits and similar kernel memory exposures.
165 165
166config HARDENED_USERCOPY_FALLBACK
167 bool "Allow usercopy whitelist violations to fallback to object size"
168 depends on HARDENED_USERCOPY
169 default y
170 help
171 This is a temporary option that allows missing usercopy whitelists
172 to be discovered via a WARN() to the kernel log, instead of
173 rejecting the copy, falling back to non-whitelisted hardened
174 usercopy that checks the slab allocation size instead of the
175 whitelist size. This option will be removed once it seems like
176 all missing usercopy whitelists have been identified and fixed.
177 Booting with "slab_common.usercopy_fallback=Y/N" can change
178 this setting.
179
180config HARDENED_USERCOPY_PAGESPAN166config HARDENED_USERCOPY_PAGESPAN
181 bool "Refuse to copy allocations that span multiple pages"167 bool "Refuse to copy allocations that span multiple pages"
182 depends on HARDENED_USERCOPY168 depends on HARDENED_USERCOPY

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t