From 261000a56b6382f597bcb12000f55c9ff26a1efb Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Fri, 25 May 2012 18:37:55 -0600 Subject: userns: userns: Remove UIDGID_STRICT_TYPE_CHECKS Removing UIDGID_STRICT_TYPE_CHECKS simplifies the code and always generates a compile error if the uids and kuids or gids and kgids are mixed by accident. Now that the appropriate conversions have been placed throughout the kernel there is no longer a need for a mode where we don't detect them as compile errors. Acked-by: Serge Hallyn Signed-off-by: Eric W. Biederman --- include/linux/posix_acl.h | 3 --- include/linux/projid.h | 15 --------------- include/linux/uidgid.h | 22 ---------------------- init/Kconfig | 11 ----------- 4 files changed, 51 deletions(-) diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h index 7931efe71175..f0f7746b2359 100644 --- a/include/linux/posix_acl.h +++ b/include/linux/posix_acl.h @@ -39,9 +39,6 @@ struct posix_acl_entry { union { kuid_t e_uid; kgid_t e_gid; -#ifndef CONFIG_UIDGID_STRICT_TYPE_CHECKS - unsigned int e_id; -#endif }; }; diff --git a/include/linux/projid.h b/include/linux/projid.h index 36517b95be5c..8c1f2c55226d 100644 --- a/include/linux/projid.h +++ b/include/linux/projid.h @@ -18,8 +18,6 @@ extern struct user_namespace init_user_ns; typedef __kernel_uid32_t projid_t; -#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS - typedef struct { projid_t val; } kprojid_t; @@ -31,19 +29,6 @@ static inline projid_t __kprojid_val(kprojid_t projid) #define KPROJIDT_INIT(value) (kprojid_t){ value } -#else - -typedef projid_t kprojid_t; - -static inline projid_t __kprojid_val(kprojid_t projid) -{ - return projid; -} - -#define KPROJIDT_INIT(value) ((kprojid_t) value ) - -#endif - #define INVALID_PROJID KPROJIDT_INIT(-1) #define OVERFLOW_PROJID 65534 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h index 8e522cbcef29..2d1f9b627f91 100644 --- a/include/linux/uidgid.h +++ b/include/linux/uidgid.h @@ -17,8 +17,6 @@ struct user_namespace; extern struct user_namespace init_user_ns; -#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS - typedef struct { uid_t val; } kuid_t; @@ -41,26 +39,6 @@ static inline gid_t __kgid_val(kgid_t gid) return gid.val; } -#else - -typedef uid_t kuid_t; -typedef gid_t kgid_t; - -static inline uid_t __kuid_val(kuid_t uid) -{ - return uid; -} - -static inline gid_t __kgid_val(kgid_t gid) -{ - return gid; -} - -#define KUIDT_INIT(value) ((kuid_t) value ) -#define KGIDT_INIT(value) ((kgid_t) value ) - -#endif - #define GLOBAL_ROOT_UID KUIDT_INIT(0) #define GLOBAL_ROOT_GID KGIDT_INIT(0) diff --git a/init/Kconfig b/init/Kconfig index 79383d3aa5dc..d4eb994d1757 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1110,8 +1110,6 @@ config IPC_NS config USER_NS bool "User namespace" - select UIDGID_STRICT_TYPE_CHECKS - default n help This allows containers, i.e. vservers, to use user namespaces @@ -1143,15 +1141,6 @@ config NET_NS endif # NAMESPACES -config UIDGID_STRICT_TYPE_CHECKS - bool "Require conversions between uid/gids and their internal representation" - default n - help - While the nececessary conversions are being added to all subsystems this option allows - the code to continue to build for unconverted subsystems. - - Say Y here if you want the strict type checking enabled - config SCHED_AUTOGROUP bool "Automatic process group scheduling" select EVENTFD -- cgit From f58437f1f9161847c636e4fed5569ed5b908af36 Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Tue, 21 Jan 2014 10:28:15 -0800 Subject: MIPS: VPE: Remove vpe_getuid and vpe_getgid The linux build-bot recently reported a build error in arch/mips/kernel/vpe.c tree: git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git for-linus head: 261000a56b6382f597bcb12000f55c9ff26a1efb commit: 261000a56b6382f597bcb12000f55c9ff26a1efb [4/4] userns: userns: Remove UIDGID_STRICT_TYPE_CHECKS config: make ARCH=mips maltaaprp_defconfig All error/warnings: arch/mips/kernel/vpe.c: In function 'vpe_open': >> arch/mips/kernel/vpe.c:1086:9: error: incompatible types when assigning to type 'unsigned int' from type 'kuid_t' >> arch/mips/kernel/vpe.c:1087:9: error: incompatible types when assigning to type 'unsigned int' from type 'kgid_t' vim +1086 arch/mips/kernel/vpe.c 863abad4 Jesper Juhl 2010-10-30 1080 return -ENOMEM; 863abad4 Jesper Juhl 2010-10-30 1081 } e01402b1 Ralf Baechle 2005-07-14 1082 v->plen = P_SIZE; e01402b1 Ralf Baechle 2005-07-14 1083 v->load_addr = NULL; e01402b1 Ralf Baechle 2005-07-14 1084 v->len = 0; e01402b1 Ralf Baechle 2005-07-14 1085 d76b0d9b David Howells 2008-11-14 @1086 v->uid = filp->f_cred->fsuid; d76b0d9b David Howells 2008-11-14 @1087 v->gid = filp->f_cred->fsgid; 2600990e Ralf Baechle 2006-04-05 1088 2600990e Ralf Baechle 2006-04-05 1089 v->cwd[0] = 0; 2600990e Ralf Baechle 2006-04-05 1090 ret = getcwd(v->cwd, VPE_PATH_MAX); When examining the code to see what v->uid and v->gid were used for I discovered that the only users in the kernel are vpe_getuid and vpe_getgid, and that vpe_getuid and vpe_getgid are never called. So instead of proposing a conversion to use kuid_t and kgid_t instead of unsigned int/int as I normally would let's just kill this dead code so no one has to worry about it further. Deng-Cheng Zhu said: This is a good catch. vpe_get[u|g]id was originally used by KSPD which has been removed. Cc: Ralf Baechle Cc: linux-mips@linux-mips.org Reviewed-by: Deng-Cheng Zhu Signed-off-by: "Eric W. Biederman" --- arch/mips/include/asm/vpe.h | 2 -- arch/mips/kernel/vpe.c | 28 ---------------------------- 2 files changed, 30 deletions(-) diff --git a/arch/mips/include/asm/vpe.h b/arch/mips/include/asm/vpe.h index c6e1b961537d..0880fe8809b1 100644 --- a/arch/mips/include/asm/vpe.h +++ b/arch/mips/include/asm/vpe.h @@ -30,8 +30,6 @@ struct vpe_notifications { extern int vpe_notify(int index, struct vpe_notifications *notify); extern void *vpe_get_shared(int index); -extern int vpe_getuid(int index); -extern int vpe_getgid(int index); extern char *vpe_getcwd(int index); #endif /* _ASM_VPE_H */ diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c index 59b2b3cd7885..2d5c142bad67 100644 --- a/arch/mips/kernel/vpe.c +++ b/arch/mips/kernel/vpe.c @@ -105,7 +105,6 @@ struct vpe { unsigned long len; char *pbuffer; unsigned long plen; - unsigned int uid, gid; char cwd[VPE_PATH_MAX]; unsigned long __start; @@ -1083,9 +1082,6 @@ static int vpe_open(struct inode *inode, struct file *filp) v->load_addr = NULL; v->len = 0; - v->uid = filp->f_cred->fsuid; - v->gid = filp->f_cred->fsgid; - v->cwd[0] = 0; ret = getcwd(v->cwd, VPE_PATH_MAX); if (ret < 0) @@ -1269,30 +1265,6 @@ void *vpe_get_shared(int index) EXPORT_SYMBOL(vpe_get_shared); -int vpe_getuid(int index) -{ - struct vpe *v; - - if ((v = get_vpe(index)) == NULL) - return -1; - - return v->uid; -} - -EXPORT_SYMBOL(vpe_getuid); - -int vpe_getgid(int index) -{ - struct vpe *v; - - if ((v = get_vpe(index)) == NULL) - return -1; - - return v->gid; -} - -EXPORT_SYMBOL(vpe_getgid); - int vpe_notify(int index, struct vpe_notifications *notify) { struct vpe *v; -- cgit