[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-id: <00eb01d09f77$d4f2c930$7ed85b90$@samsung.com>
Date: Fri, 05 Jun 2015 19:10:21 +0900
From: Namjae Jeon <namjae.jeon@...sung.com>
To: 'Greg Kroah-Hartman' <gregkh@...uxfoundation.org>
Cc: 'Kay Sievers' <kay@...y.org>, linux-kernel@...r.kernel.org
Subject: [PATCH 1/3] driver: core: add uid gid to class devnode
Add support for setting uid gid to devtmpfs device nodes.
In this manner, drivers can specify desired uid gid in their
class->devnode method.
This is extension of existing method of setting uid gid by drivers
using device_type->devnode method:
3c2670e6515cf584810f417db9b00992c8b2d75a
"driver core: add uid and gid to devtmpfs"
Signed-off-by: Namjae Jeon <namjae.jeon@...sung.com>
Signed-off-by: Vivek Trivedi <t.vivek@...sung.com>
---
arch/x86/kernel/cpuid.c | 3 ++-
arch/x86/kernel/msr.c | 3 ++-
block/bsg.c | 3 ++-
drivers/base/core.c | 2 +-
drivers/block/aoe/aoechr.c | 3 ++-
drivers/block/pktcdvd.c | 3 ++-
drivers/char/mem.c | 3 ++-
drivers/char/misc.c | 3 ++-
drivers/char/raw.c | 3 ++-
drivers/char/tile-srom.c | 3 ++-
drivers/gpu/drm/drm_sysfs.c | 3 ++-
drivers/hid/usbhid/hiddev.c | 3 ++-
drivers/infiniband/core/cm.c | 3 ++-
drivers/infiniband/core/user_mad.c | 3 ++-
drivers/infiniband/core/uverbs_main.c | 3 ++-
drivers/input/input.c | 3 ++-
drivers/media/dvb-core/dvbdev.c | 3 ++-
drivers/media/pci/ddbridge/ddbridge-core.c | 3 ++-
drivers/misc/cxl/file.c | 3 ++-
drivers/s390/char/hmcdrv_dev.c | 3 ++-
drivers/tty/tty_io.c | 3 ++-
drivers/usb/class/usblp.c | 3 ++-
drivers/usb/core/file.c | 5 +++--
drivers/usb/misc/iowarrior.c | 3 ++-
drivers/usb/misc/legousbtower.c | 3 ++-
drivers/vfio/vfio.c | 3 ++-
fs/pstore/pmsg.c | 3 ++-
include/linux/device.h | 3 ++-
include/linux/usb.h | 3 ++-
sound/sound_core.c | 3 ++-
30 files changed, 60 insertions(+), 31 deletions(-)
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
index 83741a7..7153cb7 100644
--- a/arch/x86/kernel/cpuid.c
+++ b/arch/x86/kernel/cpuid.c
@@ -175,7 +175,8 @@ static struct notifier_block __refdata cpuid_class_cpu_notifier =
.notifier_call = cpuid_class_cpu_callback,
};
-static char *cpuid_devnode(struct device *dev, umode_t *mode)
+static char *cpuid_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "cpu/%u/cpuid", MINOR(dev->devt));
}
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
index 113e707..fcbd718 100644
--- a/arch/x86/kernel/msr.c
+++ b/arch/x86/kernel/msr.c
@@ -239,7 +239,8 @@ static struct notifier_block __refdata msr_class_cpu_notifier = {
.notifier_call = msr_class_cpu_callback,
};
-static char *msr_devnode(struct device *dev, umode_t *mode)
+static char *msr_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "cpu/%u/msr", MINOR(dev->devt));
}
diff --git a/block/bsg.c b/block/bsg.c
index d214e92..6eef206 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -1040,7 +1040,8 @@ EXPORT_SYMBOL_GPL(bsg_register_queue);
static struct cdev bsg_cdev;
-static char *bsg_devnode(struct device *dev, umode_t *mode)
+static char *bsg_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "bsg/%s", dev_name(dev));
}
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 21d1303..4e7546d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1294,7 +1294,7 @@ const char *device_get_devnode(struct device *dev,
/* the class may provide a specific name */
if (dev->class && dev->class->devnode)
- *tmp = dev->class->devnode(dev, mode);
+ *tmp = dev->class->devnode(dev, mode, uid, gid);
if (*tmp)
return *tmp;
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index ab41be6..a71332f 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -275,7 +275,8 @@ static const struct file_operations aoe_fops = {
.llseek = noop_llseek,
};
-static char *aoe_devnode(struct device *dev, umode_t *mode)
+static char *aoe_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "etherd/%s", dev_name(dev));
}
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
index 4c20c22..5f5c462 100644
--- a/drivers/block/pktcdvd.c
+++ b/drivers/block/pktcdvd.c
@@ -2731,7 +2731,8 @@ static const struct block_device_operations pktcdvd_ops = {
.check_events = pkt_check_events,
};
-static char *pktcdvd_devnode(struct gendisk *gd, umode_t *mode)
+static char *pktcdvd_devnode(struct gendisk *gd, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "pktcdvd/%s", gd->disk_name);
}
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 6b1721f..f16b511 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -831,7 +831,8 @@ static const struct file_operations memory_fops = {
.llseek = noop_llseek,
};
-static char *mem_devnode(struct device *dev, umode_t *mode)
+static char *mem_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
if (mode && devlist[MINOR(dev->devt)].mode)
*mode = devlist[MINOR(dev->devt)].mode;
diff --git a/drivers/char/misc.c b/drivers/char/misc.c
index fdb0f9b..9a960ab 100644
--- a/drivers/char/misc.c
+++ b/drivers/char/misc.c
@@ -267,7 +267,8 @@ int misc_deregister(struct miscdevice *misc)
EXPORT_SYMBOL(misc_register);
EXPORT_SYMBOL(misc_deregister);
-static char *misc_devnode(struct device *dev, umode_t *mode)
+static char *misc_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
struct miscdevice *c = dev_get_drvdata(dev);
diff --git a/drivers/char/raw.c b/drivers/char/raw.c
index 60316fb..d6714ee 100644
--- a/drivers/char/raw.c
+++ b/drivers/char/raw.c
@@ -305,7 +305,8 @@ static const struct file_operations raw_ctl_fops = {
static struct cdev raw_cdev;
-static char *raw_devnode(struct device *dev, umode_t *mode)
+static char *raw_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "raw/%s", dev_name(dev));
}
diff --git a/drivers/char/tile-srom.c b/drivers/char/tile-srom.c
index 69f6b4a..1b6f655 100644
--- a/drivers/char/tile-srom.c
+++ b/drivers/char/tile-srom.c
@@ -310,7 +310,8 @@ static struct attribute *srom_dev_attrs[] = {
};
ATTRIBUTE_GROUPS(srom_dev);
-static char *srom_devnode(struct device *dev, umode_t *mode)
+static char *srom_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
*mode = S_IRUGO | S_IWUSR;
return kasprintf(GFP_KERNEL, "srom/%s", dev_name(dev));
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 487ddf5..48ec1b6 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -99,7 +99,8 @@ static const struct dev_pm_ops drm_class_dev_pm_ops = {
.freeze = drm_class_freeze,
};
-static char *drm_devnode(struct device *dev, umode_t *mode)
+static char *drm_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "dri/%s", dev_name(dev));
}
diff --git a/drivers/hid/usbhid/hiddev.c b/drivers/hid/usbhid/hiddev.c
index 2f1ddca..a40204b 100644
--- a/drivers/hid/usbhid/hiddev.c
+++ b/drivers/hid/usbhid/hiddev.c
@@ -860,7 +860,8 @@ static const struct file_operations hiddev_fops = {
.llseek = noop_llseek,
};
-static char *hiddev_devnode(struct device *dev, umode_t *mode)
+static char *hiddev_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
}
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index c3be666..13621fd4 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -3691,7 +3691,8 @@ static struct kobj_type cm_port_obj_type = {
.release = cm_release_port_obj
};
-static char *cm_devnode(struct device *dev, umode_t *mode)
+static char *cm_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
if (mode)
*mode = 0666;
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index e58d701..dc34a45 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1332,7 +1332,8 @@ static void ib_umad_remove_one(struct ib_device *device)
kobject_put(&umad_dev->kobj);
}
-static char *umad_devnode(struct device *dev, umode_t *mode)
+static char *umad_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "infiniband/%s", dev_name(dev));
}
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 88cce9b..86c0311 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -968,7 +968,8 @@ static void ib_uverbs_remove_one(struct ib_device *device)
kfree(uverbs_dev);
}
-static char *uverbs_devnode(struct device *dev, umode_t *mode)
+static char *uverbs_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
if (mode)
*mode = 0666;
diff --git a/drivers/input/input.c b/drivers/input/input.c
index f315784..f4825b7 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1759,7 +1759,8 @@ static struct device_type input_dev_type = {
#endif
};
-static char *input_devnode(struct device *dev, umode_t *mode)
+static char *input_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "input/%s", dev_name(dev));
}
diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
index 13bb57f..5ec225e 100644
--- a/drivers/media/dvb-core/dvbdev.c
+++ b/drivers/media/dvb-core/dvbdev.c
@@ -584,7 +584,8 @@ static int dvb_uevent(struct device *dev, struct kobj_uevent_env *env)
return 0;
}
-static char *dvb_devnode(struct device *dev, umode_t *mode)
+static char *dvb_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
struct dvb_device *dvbdev = dev_get_drvdata(dev);
diff --git a/drivers/media/pci/ddbridge/ddbridge-core.c b/drivers/media/pci/ddbridge/ddbridge-core.c
index 9e3492e..44d9bc6 100644
--- a/drivers/media/pci/ddbridge/ddbridge-core.c
+++ b/drivers/media/pci/ddbridge/ddbridge-core.c
@@ -1476,7 +1476,8 @@ static const struct file_operations ddb_fops = {
.open = ddb_open,
};
-static char *ddb_devnode(struct device *device, umode_t *mode)
+static char *ddb_devnode(struct device *device, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
struct ddb *dev = dev_get_drvdata(device);
diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
index e3f4b69..f570d50 100644
--- a/drivers/misc/cxl/file.c
+++ b/drivers/misc/cxl/file.c
@@ -408,7 +408,8 @@ const struct file_operations afu_master_fops = {
};
-static char *cxl_devnode(struct device *dev, umode_t *mode)
+static char *cxl_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
if (CXL_DEVT_IS_CARD(dev->devt)) {
/*
diff --git a/drivers/s390/char/hmcdrv_dev.c b/drivers/s390/char/hmcdrv_dev.c
index 43cee7f..ffa582a 100644
--- a/drivers/s390/char/hmcdrv_dev.c
+++ b/drivers/s390/char/hmcdrv_dev.c
@@ -89,7 +89,8 @@ static dev_t hmcdrv_dev_no; /* device number (major/minor) */
*
* Return: recommended device file name in /dev
*/
-static char *hmcdrv_dev_name(struct device *dev, umode_t *mode)
+static char *hmcdrv_dev_name(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
char *nodename = NULL;
const char *devname = dev_name(dev); /* kernel device name */
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 57fc6ee..a47650a 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3528,7 +3528,8 @@ void __init console_init(void)
}
}
-static char *tty_devnode(struct device *dev, umode_t *mode)
+static char *tty_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
if (!mode)
return NULL;
diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c
index f38e875..d672115 100644
--- a/drivers/usb/class/usblp.c
+++ b/drivers/usb/class/usblp.c
@@ -1058,7 +1058,8 @@ static const struct file_operations usblp_fops = {
.llseek = noop_llseek,
};
-static char *usblp_devnode(struct device *dev, umode_t *mode)
+static char *usblp_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
}
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c
index ea337a7..e990b8d 100644
--- a/drivers/usb/core/file.c
+++ b/drivers/usb/core/file.c
@@ -58,14 +58,15 @@ static struct usb_class {
struct class *class;
} *usb_class;
-static char *usb_devnode(struct device *dev, umode_t *mode)
+static char *usb_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
struct usb_class_driver *drv;
drv = dev_get_drvdata(dev);
if (!drv || !drv->devnode)
return NULL;
- return drv->devnode(dev, mode);
+ return drv->devnode(dev, mode, uid, gid);
}
static int init_usb_class(void)
diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index c6bfd13..f9d6887 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -729,7 +729,8 @@ static const struct file_operations iowarrior_fops = {
.llseek = noop_llseek,
};
-static char *iowarrior_devnode(struct device *dev, umode_t *mode)
+static char *iowarrior_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
}
diff --git a/drivers/usb/misc/legousbtower.c b/drivers/usb/misc/legousbtower.c
index 7771be3..d41c1b8 100644
--- a/drivers/usb/misc/legousbtower.c
+++ b/drivers/usb/misc/legousbtower.c
@@ -253,7 +253,8 @@ static const struct file_operations tower_fops = {
.llseek = tower_llseek,
};
-static char *legousbtower_devnode(struct device *dev, umode_t *mode)
+static char *legousbtower_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
}
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index e1278fe..58e4e67 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -1519,7 +1519,8 @@ EXPORT_SYMBOL_GPL(vfio_external_check_extension);
/**
* Module/class support
*/
-static char *vfio_devnode(struct device *dev, umode_t *mode)
+static char *vfio_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
return kasprintf(GFP_KERNEL, "vfio/%s", dev_name(dev));
}
diff --git a/fs/pstore/pmsg.c b/fs/pstore/pmsg.c
index feb5dd2..2d7db92 100644
--- a/fs/pstore/pmsg.c
+++ b/fs/pstore/pmsg.c
@@ -73,7 +73,8 @@ static int pmsg_major;
#undef pr_fmt
#define pr_fmt(fmt) PMSG_NAME ": " fmt
-static char *pmsg_devnode(struct device *dev, umode_t *mode)
+static char *pmsg_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
if (mode)
*mode = 0220;
diff --git a/include/linux/device.h b/include/linux/device.h
index 5a31bf3..220c0b1 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -389,7 +389,8 @@ struct class {
struct kobject *dev_kobj;
int (*dev_uevent)(struct device *dev, struct kobj_uevent_env *env);
- char *(*devnode)(struct device *dev, umode_t *mode);
+ char *(*devnode)(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid);
void (*class_release)(struct class *class);
void (*dev_release)(struct device *dev);
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 447fe29..c396dde 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1157,7 +1157,8 @@ extern struct bus_type usb_bus_type;
*/
struct usb_class_driver {
char *name;
- char *(*devnode)(struct device *dev, umode_t *mode);
+ char *(*devnode)(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid);
const struct file_operations *fops;
int minor_base;
};
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 11e953a..9c01786 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -29,7 +29,8 @@ MODULE_DESCRIPTION("Core sound module");
MODULE_AUTHOR("Alan Cox");
MODULE_LICENSE("GPL");
-static char *sound_devnode(struct device *dev, umode_t *mode)
+static char *sound_devnode(struct device *dev, umode_t *mode,
+ kuid_t *uid, kgid_t *gid)
{
if (MAJOR(dev->devt) == SOUND_MAJOR)
return NULL;
--
1.8.5.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists