From: Greg KH <gregkh@linuxfoundation.org>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: linux-kernel@vger.kernel.org, Kay Sievers <kay@vrfy.org>,
Ming Lei <ming.lei@canonical.com>
Subject: Re: [PATCH] driver core: add uid and gid to devtmpfs
Date: Thu, 11 Apr 2013 09:43:56 -0700 [thread overview]
Message-ID: <20130411164356.GA23838@kroah.com> (raw)
In-Reply-To: <20130411155606.GA14042@kroah.com>
On Thu, Apr 11, 2013 at 08:56:06AM -0700, Greg KH wrote:
> Again, thanks for the review, I'll go enable namespaces in my test
> kernel and fix up the fallout.
Here's the fixup patch, Eric, does it look correct to you?
thanks,
greg k-h
diff --git a/block/genhd.c b/block/genhd.c
index dfcec43..20625ee 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1112,7 +1112,7 @@ struct class block_class = {
};
static char *block_devnode(struct device *dev, umode_t *mode,
- uid_t *uid, gid_t *gid)
+ kuid_t *uid, kgid_t *gid)
{
struct gendisk *disk = dev_to_disk(dev);
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 8a428b5..f88d9e2 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;
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index abd4eee..7413d06 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -42,8 +42,8 @@ static struct req {
int err;
const char *name;
umode_t mode; /* 0 => delete */
- uid_t uid;
- gid_t gid;
+ kuid_t uid;
+ kgid_t gid;
struct device *dev;
} *requests;
@@ -88,8 +88,8 @@ int devtmpfs_create_node(struct device *dev)
return 0;
req.mode = 0;
- req.uid = 0;
- req.gid = 0;
+ req.uid = GLOBAL_ROOT_UID;
+ req.gid = GLOBAL_ROOT_GID;
req.name = device_get_devnode(dev, &req.mode, &req.uid, &req.gid, &tmp);
if (!req.name)
return -ENOMEM;
@@ -192,8 +192,8 @@ static int create_path(const char *nodepath)
return err;
}
-static int handle_create(const char *nodename, umode_t mode, uid_t uid,
- gid_t gid, struct device *dev)
+static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
+ kgid_t gid, struct device *dev)
{
struct dentry *dentry;
struct path path;
@@ -212,8 +212,8 @@ static int handle_create(const char *nodename, umode_t mode, uid_t uid,
struct iattr newattrs;
newattrs.ia_mode = mode;
- newattrs.ia_uid = KUIDT_INIT(uid);
- newattrs.ia_gid = KGIDT_INIT(gid);
+ newattrs.ia_uid = uid;
+ newattrs.ia_gid = gid;
newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;
mutex_lock(&dentry->d_inode->i_mutex);
notify_change(dentry, &newattrs);
@@ -364,7 +364,7 @@ int devtmpfs_mount(const char *mntdir)
static DECLARE_COMPLETION(setup_done);
-static int handle(const char *name, umode_t mode, uid_t uid, gid_t gid,
+static int handle(const char *name, umode_t mode, kuid_t uid, kgid_t gid,
struct device *dev)
{
if (mode)
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 1700283..e092b41 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -318,7 +318,7 @@ static const struct dev_pm_ops usb_device_pm_ops = {
static char *usb_devnode(struct device *dev,
- umode_t *mode, uid_t *uid, gid_t *gid)
+ umode_t *mode, kuid_t *uid, kgid_t *gid)
{
struct usb_device *usb_dev;
diff --git a/include/linux/device.h b/include/linux/device.h
index 851b85c..88615cc 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -467,7 +467,7 @@ struct device_type {
const struct attribute_group **groups;
int (*uevent)(struct device *dev, struct kobj_uevent_env *env);
char *(*devnode)(struct device *dev, umode_t *mode,
- uid_t *uid, gid_t *gid);
+ kuid_t *uid, kgid_t *gid);
void (*release)(struct device *dev);
const struct dev_pm_ops *pm;
@@ -845,7 +845,7 @@ extern int device_rename(struct device *dev, const char *new_name);
extern int device_move(struct device *dev, struct device *new_parent,
enum dpm_order dpm_order);
extern 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);
extern void *dev_get_drvdata(const struct device *dev);
extern int dev_set_drvdata(struct device *dev, void *data);
next prev parent reply other threads:[~2013-04-11 16:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-06 16:56 Greg KH
2013-04-06 17:09 ` Al Viro
2013-04-06 17:26 ` Greg KH
2013-04-06 17:45 ` Al Viro
2013-04-06 17:58 ` Greg KH
2013-04-07 16:38 ` Kay Sievers
2013-04-08 18:14 ` Rob Landley
2013-04-08 18:25 ` Greg KH
2013-04-09 15:11 ` Rob Landley
2013-04-11 16:08 ` Greg KH
2013-04-10 9:12 ` Ming Lei
2013-04-10 15:56 ` Greg KH
2013-04-10 16:07 ` Ming Lei
2013-04-11 4:10 ` Eric W. Biederman
2013-04-11 15:56 ` Greg KH
2013-04-11 15:57 ` Greg KH
2013-04-11 16:31 ` Eric W. Biederman
2013-04-11 16:43 ` Greg KH [this message]
2013-04-11 16:50 ` Eric W. Biederman
2013-04-11 16:19 ` Greg KH
2013-04-11 16:41 ` Eric W. Biederman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130411164356.GA23838@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=ebiederm@xmission.com \
--cc=kay@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@canonical.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome