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
275275 CONFIG_ENCRYPTED_KEYS=y
276276 CONFIG_SECURITY=y
277277 CONFIG_HARDENED_USERCOPY=y
278−# CONFIG_HARDENED_USERCOPY_FALLBACK is not set
279278 CONFIG_HARDENED_USERCOPY_PAGESPAN=y
280279 CONFIG_FORTIFY_SOURCE=y
281280 CONFIG_SECURITY_LOCKDOWN_LSM=y
include/linux/slab.h+0−2
@@ -142,8 +142,6 @@ struct mem_cgroup; · 141 unmodified lines
142142 void __init kmem_cache_init(void);
143143 bool slab_is_available(void);
144144
145−extern bool usercopy_fallback;
146−
147145 struct kmem_cache *kmem_cache_create(const char *name, unsigned int size,
148146 unsigned int align, slab_flags_t flags,
149147 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
42044204 n <= cachep->useroffset - offset + cachep->usersize)
42054205 return;
42064206
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−
42204207 usercopy_abort("SLAB object", cachep->name, to_user, offset, n);
42214208 }
42224209 #endif /* CONFIG_HARDENED_USERCOPY */
mm/slab_common.c+0−8
@@ -37,14 +37,6 @@ LIST_HEAD(slab_caches); · 36 unmodified lines
3737 DEFINE_MUTEX(slab_mutex);
3838 struct kmem_cache *kmem_cache;
3939
40−#ifdef CONFIG_HARDENED_USERCOPY
41−bool usercopy_fallback __ro_after_init =
42− IS_ENABLED(CONFIG_HARDENED_USERCOPY_FALLBACK);
43−module_param(usercopy_fallback, bool, 0400);
44−MODULE_PARM_DESC(usercopy_fallback,
45− "WARN instead of reject usercopy whitelist violations");
46−#endif
47−
4840 static LIST_HEAD(slab_caches_to_rcu_destroy);
4941 static void slab_caches_to_rcu_destroy_workfn(struct work_struct *work);
5042 static 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
44894489 {
44904490 struct kmem_cache *s;
44914491 unsigned int offset;
4492− size_t object_size;
44934492 bool is_kfence = is_kfence_address(ptr);
44944493
44954494 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
45224521 n <= s->useroffset - offset + s->usersize)
45234522 return;
45244523
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−
45384524 usercopy_abort("SLUB object", s->name, to_user, offset, n);
45394525 }
45404526 #endif /* CONFIG_HARDENED_USERCOPY */
security/Kconfig+0−14
@@ -163,20 +163,6 @@ config HARDENED_USERCOPY · 162 unmodified lines
163163 or are part of the kernel text. This kills entire classes
164164 of heap overflow exploits and similar kernel memory exposures.
165165
166−config 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−
180166 config HARDENED_USERCOPY_PAGESPAN
181167 bool "Refuse to copy allocations that span multiple pages"
182168 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