Skip to content

Commit

Permalink
uidgid: make uid_valid and gid_valid work with !CONFIG_MULTIUSER
Browse files Browse the repository at this point in the history
{u,g}id_valid call {u,g}id_eq, which calls __k{u,g}id_val on both
arguments and compares.  With !CONFIG_MULTIUSER, __k{u,g}id_val return a
constant 0, which makes {u,g}id_valid always return false.  Change
{u,g}id_valid to compare their argument against -1 instead.  That produces
identical results in the normal CONFIG_MULTIUSER=y case, but with
!CONFIG_MULTIUSER will make {u,g}id_valid constant-fold into "return
true;" rather than "return false;".

This fixes uses of devpts without CONFIG_MULTIUSER.

Signed-off-by: Josh Triplett <[email protected]>
Reported-by: Fengguang Wu <[email protected]>,
Cc: Peter Hurley <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
joshtriplett authored and torvalds committed May 15, 2015
1 parent 499611e commit 929aa5b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/linux/uidgid.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ static inline bool gid_lte(kgid_t left, kgid_t right)

static inline bool uid_valid(kuid_t uid)
{
return !uid_eq(uid, INVALID_UID);
return __kuid_val(uid) != (uid_t) -1;
}

static inline bool gid_valid(kgid_t gid)
{
return !gid_eq(gid, INVALID_GID);
return __kgid_val(gid) != (gid_t) -1;
}

#ifdef CONFIG_USER_NS
Expand Down

0 comments on commit 929aa5b

Please sign in to comment.