Skip to contentSkip to conversation

uaccess: Introduce ucopysize.h

PATCH New Kees Cook 1 participant 1 message Feb 28, 2025

Subsystems (3)
lore
Share & tools
lore

Kees Cook

author maintainer
#0 lore raw

PATCH 1/1 uaccess: Introduce ucopysize.h

The object size sanity checking macros that uaccess.h and uio.h use have been living in thread_info.h for historical reasons. Needing to use jump labels for these checks, however, introduces a header include loop under certain conditions. The dependencies for the object checking macros are very limited, but they are used by separate header files, so introduce a new header that can be used directly by uaccess.h and uio.h. As a result, this also means thread_info.h (which is rather large) and be removed from those headers.

---
I'll carry this in the hardening tree since the usercopy hardening changes depend on it...

Cc Alexander Viro <[email protected]>
Cc "Gustavo A. R. Silva" <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc "Rafael J. Wysocki" <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Christophe Leroy <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Aleksa Sarai <[email protected]>
Cc Christian Brauner <[email protected]>
Cc Alexander Potapenko <[email protected]>
Cc Catalin Marinas <[email protected]>
---
 MAINTAINERS                 |  1 +
 include/linux/thread_info.h | 48 -------------------------------
 include/linux/uaccess.h     |  2 +-
 include/linux/ucopysize.h   | 56 +++++++++++++++++++++++++++++++++++++
 include/linux/uio.h         |  2 +-
 mm/usercopy.c               |  2 +-
 6 files changed, 60 insertions(+), 51 deletions(-)
 create mode 100644 include/linux/ucopysize.h
MAINTAINERS +1 -0
index 25c86f47353d..a1900962ced9 100644
@@ -12586,6 +12586,7 @@ F:	Documentation/ABI/testing/sysfs-kernel-warn_count
 F:	arch/*/configs/hardening.config
 F:	include/linux/overflow.h
 F:	include/linux/randomize_kstack.h
+F:	include/linux/ucopysize.h
 F:	kernel/configs/hardening.config
 F:	lib/usercopy_kunit.c
 F:	mm/usercopy.c
include/linux/thread_info.h +0 -48

54 lines not on this page · raw message

include/linux/uaccess.h +1 -1
index e9c702c1908d..7c06f4795670 100644
@@ -7,7 +7,7 @@
 #include <linux/minmax.h>
 #include <linux/nospec.h>
 #include <linux/sched.h>
-#include <linux/thread_info.h>
+#include <linux/ucopysize.h>
 
 #include <asm/uaccess.h>
 
include/linux/ucopysize.h new file +56 -0

56 lines not on this page · raw message

include/linux/uio.h +1 -1
index 8ada84e85447..49ece9e1888f 100644
@@ -6,8 +6,8 @@
 #define __LINUX_UIO_H
 
 #include <linux/kernel.h>
-#include <linux/thread_info.h>
 #include <linux/mm_types.h>
+#include <linux/ucopysize.h>
 #include <uapi/linux/uio.h>
 
 struct page;
mm/usercopy.c +1 -1
index 83c164aba6e0..16d63bd010af 100644
@@ -17,7 +17,7 @@
 #include <linux/sched.h>
 #include <linux/sched/task.h>
 #include <linux/sched/task_stack.h>
-#include <linux/thread_info.h>
+#include <linux/ucopysize.h>
 #include <linux/vmalloc.h>
 #include <linux/atomic.h>
 #include <linux/jump_label.h>
Signature · 1 line
2.34.1