Skip to content

Commit 5673a94

Browse files
committed
userns: Add a Kconfig option to enforce strict kuid and kgid type checks
Make it possible to easily switch between strong mandatory type checks and relaxed type checks so that the code can easily be tested with the type checks and then built with the strong type checks disabled so the resulting code can be used. Require strong mandatory type checks when enabling the user namespace. It is very simple to make a typo and use the wrong type allowing conversions to/from userspace values to be bypassed by accident, the strong type checks prevent this. Acked-by: Serge Hallyn <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent 7a4e740 commit 5673a94

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

include/linux/uidgid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
struct user_namespace;
1818
extern struct user_namespace init_user_ns;
1919

20-
#if defined(NOTYET)
20+
#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
2121

2222
typedef struct {
2323
uid_t val;

init/Kconfig

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,8 @@ config IPC_NS
828828
config USER_NS
829829
bool "User namespace (EXPERIMENTAL)"
830830
depends on EXPERIMENTAL
831-
default y
831+
select UIDGID_STRICT_TYPE_CHECKS
832+
default n
832833
help
833834
This allows containers, i.e. vservers, to use user namespaces
834835
to provide different user info for different servers.
@@ -852,6 +853,15 @@ config NET_NS
852853

853854
endif # NAMESPACES
854855

856+
config UIDGID_STRICT_TYPE_CHECKS
857+
bool "Require conversions between uid/gids and their internal representation"
858+
default n
859+
help
860+
While the nececessary conversions are being added to all subsystems this option allows
861+
the code to continue to build for unconverted subsystems.
862+
863+
Say Y here if you want the strict type checking enabled
864+
855865
config SCHED_AUTOGROUP
856866
bool "Automatic process group scheduling"
857867
select EVENTFD

0 commit comments

Comments
 (0)