tree-wide: use {pid,uid,gid}_is_valid() where appropriate
Also, drop UID/GID validity checks from getpeercred() as the kernel will never pass us invalid UID/GID on userns, but the overflow UID/GID instead. Add a comment about this.
This commit is contained in:
@@ -967,15 +967,13 @@ int getpeercred(int fd, struct ucred *ucred) {
|
||||
if (n != sizeof(struct ucred))
|
||||
return -EIO;
|
||||
|
||||
/* Check if the data is actually useful and not suppressed due
|
||||
* to namespacing issues */
|
||||
if (u.pid <= 0)
|
||||
return -ENODATA;
|
||||
if (u.uid == UID_INVALID)
|
||||
return -ENODATA;
|
||||
if (u.gid == GID_INVALID)
|
||||
/* Check if the data is actually useful and not suppressed due to namespacing issues */
|
||||
if (!pid_is_valid(u.pid))
|
||||
return -ENODATA;
|
||||
|
||||
/* Note that we don't check UID/GID here, as namespace translation works differently there: instead of
|
||||
* receiving in "invalid" user/group we get the overflow UID/GID. */
|
||||
|
||||
*ucred = u;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user