summaryrefslogtreecommitdiffstats
path: root/drivers/base/core.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-11 20:43:29 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-04-11 20:43:29 +0200
commit4e4098a3e08783cfd75f9fcdab276dc1d46931da (patch)
treed0befddb4d6f999a443ef60ae8af327bed046fd5 /drivers/base/core.c
parentdriver core: devtmpfs: fix compile failure with CONFIG_UIDGID_STRICT_TYPE_CHECKS (diff)
downloadlinux-4e4098a3e08783cfd75f9fcdab276dc1d46931da.tar.xz
linux-4e4098a3e08783cfd75f9fcdab276dc1d46931da.zip
driver core: handle user namespaces properly with the uid/gid devtmpfs change
Now that devtmpfs is caring about uid/gid, we need to use the correct internal types so users who have USER_NS enabled will have things work properly for them. Thanks to Eric for pointing this out, and the patch review. Reported-by: Eric W. Biederman <ebiederm@xmission.com> Cc: Kay Sievers <kay@vrfy.org> Cc: Ming Lei <ming.lei@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/core.c')
-rw-r--r--drivers/base/core.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 8a428b51089d..f88d9e259a32 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -283,8 +283,8 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
const char *tmp;
const char *name;
umode_t mode = 0;
- uid_t uid = 0;
- gid_t gid = 0;
+ kuid_t uid = GLOBAL_ROOT_UID;
+ kgid_t gid = GLOBAL_ROOT_GID;
add_uevent_var(env, "MAJOR=%u", MAJOR(dev->devt));
add_uevent_var(env, "MINOR=%u", MINOR(dev->devt));
@@ -293,10 +293,10 @@ static int dev_uevent(struct kset *kset, struct kobject *kobj,
add_uevent_var(env, "DEVNAME=%s", name);
if (mode)
add_uevent_var(env, "DEVMODE=%#o", mode & 0777);
- if (uid)
- add_uevent_var(env, "DEVUID=%u", uid);
- if (gid)
- add_uevent_var(env, "DEVGID=%u", gid);
+ if (!uid_eq(uid, GLOBAL_ROOT_UID))
+ add_uevent_var(env, "DEVUID=%u", from_kuid(&init_user_ns, uid));
+ if (!gid_eq(gid, GLOBAL_ROOT_GID))
+ add_uevent_var(env, "DEVGID=%u", from_kgid(&init_user_ns, gid));
kfree(tmp);
}
}
@@ -1297,7 +1297,7 @@ static struct device *next_device(struct klist_iter *i)
* freed by the caller.
*/
const char *device_get_devnode(struct device *dev,
- umode_t *mode, uid_t *uid, gid_t *gid,
+ umode_t *mode, kuid_t *uid, kgid_t *gid,
const char **tmp)
{
char *s;