Browse Source

userns: Handle -1 in k[ug]id_has_mapping when !CONFIG_USER_NS

Refuse to admit any user namespace has a mapping of the INVALID_UID
and the INVALID_GID when !CONFIG_USER_NS.

Acked-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Eric W. Biederman 9 years ago
parent
commit
37b11804ed
1 changed files with 2 additions and 2 deletions
  1. 2 2
      include/linux/uidgid.h

+ 2 - 2
include/linux/uidgid.h

@@ -177,12 +177,12 @@ static inline gid_t from_kgid_munged(struct user_namespace *to, kgid_t kgid)
 
 
 static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid)
 static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid)
 {
 {
-	return true;
+	return uid_valid(uid);
 }
 }
 
 
 static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
 static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
 {
 {
-	return true;
+	return gid_valid(gid);
 }
 }
 
 
 #endif /* CONFIG_USER_NS */
 #endif /* CONFIG_USER_NS */