Re: [PATCH v4] driver core: Fix device link device name collision
Hi, Am 2021-01-10 18:54, schrieb Saravana Kannan: The device link device's name was of the form: -- This can cause name collision as reported here [1] as device names are not globally unique. Since device names have to be unique within the bus/class, add the bus/class name as a prefix to the device names used to construct the device link device name. So the devuce link device's name will be of the form: :--: [1] - https://lore.kernel.org/lkml/20201229033440.32142-1-mich...@walle.cc/ Cc: sta...@vger.kernel.org Fixes: 287905e68dd2 ("driver core: Expose device link details in sysfs") Reported-by: Michael Walle Tested-by: Michael Walle Signed-off-by: Saravana Kannan --- Greg, any news here? -michael
Re: [PATCH v4] driver core: Fix device link device name collision
On Thu, Jan 21, 2021 at 08:01:24PM +0100, Michael Walle wrote: > Hi, > > Am 2021-01-10 18:54, schrieb Saravana Kannan: > > The device link device's name was of the form: > > -- > > > > This can cause name collision as reported here [1] as device names are > > not globally unique. Since device names have to be unique within the > > bus/class, add the bus/class name as a prefix to the device names used > > to > > construct the device link device name. > > > > So the devuce link device's name will be of the form: > > :--: > > > > [1] - > > https://lore.kernel.org/lkml/20201229033440.32142-1-mich...@walle.cc/ > > > > Cc: sta...@vger.kernel.org > > Fixes: 287905e68dd2 ("driver core: Expose device link details in sysfs") > > Reported-by: Michael Walle > > Tested-by: Michael Walle > > Signed-off-by: Saravana Kannan > > --- > > Greg, any news here? Burried in other patches... I'll go pick this up now, sorry for the delay. greg k-h
[PATCH v4] driver core: Fix device link device name collision
The device link device's name was of the form: -- This can cause name collision as reported here [1] as device names are not globally unique. Since device names have to be unique within the bus/class, add the bus/class name as a prefix to the device names used to construct the device link device name. So the devuce link device's name will be of the form: :--: [1] - https://lore.kernel.org/lkml/20201229033440.32142-1-mich...@walle.cc/ Cc: sta...@vger.kernel.org Fixes: 287905e68dd2 ("driver core: Expose device link details in sysfs") Reported-by: Michael Walle Tested-by: Michael Walle Signed-off-by: Saravana Kannan --- v1: - Fixed the collision in the device link device name. v1 -> v2: - Tried to fixed collision in the supplier: and consumer: symlinks v2 -> v3: - Fixed the truncation of the symlink names caused by v2. v3 -> v4: - Did all the above fixes for the symlink removal path. Documentation/ABI/testing/sysfs-class-devlink | 4 +-- .../ABI/testing/sysfs-devices-consumer| 5 ++-- .../ABI/testing/sysfs-devices-supplier| 5 ++-- drivers/base/core.c | 27 ++- include/linux/device.h| 12 + 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-devlink b/Documentation/ABI/testing/sysfs-class-devlink index b662f747c83e..8a21ce515f61 100644 --- a/Documentation/ABI/testing/sysfs-class-devlink +++ b/Documentation/ABI/testing/sysfs-class-devlink @@ -5,8 +5,8 @@ Description: Provide a place in sysfs for the device link objects in the kernel at any given time. The name of a device link directory, denoted as ... above, is of the form -- - where is the supplier device name and is - the consumer device name. + where is the supplier bus:device name and + is the consumer bus:device name. What: /sys/class/devlink/.../auto_remove_on Date: May 2020 diff --git a/Documentation/ABI/testing/sysfs-devices-consumer b/Documentation/ABI/testing/sysfs-devices-consumer index 1f06d74d1c3c..0809fda092e6 100644 --- a/Documentation/ABI/testing/sysfs-devices-consumer +++ b/Documentation/ABI/testing/sysfs-devices-consumer @@ -4,5 +4,6 @@ Contact:Saravana Kannan Description: The /sys/devices/.../consumer: are symlinks to device links where this device is the supplier. denotes the - name of the consumer in that device link. There can be zero or - more of these symlinks for a given device. + name of the consumer in that device link and is of the form + bus:device name. There can be zero or more of these symlinks + for a given device. diff --git a/Documentation/ABI/testing/sysfs-devices-supplier b/Documentation/ABI/testing/sysfs-devices-supplier index a919e0db5e90..207f5972e98d 100644 --- a/Documentation/ABI/testing/sysfs-devices-supplier +++ b/Documentation/ABI/testing/sysfs-devices-supplier @@ -4,5 +4,6 @@ Contact:Saravana Kannan Description: The /sys/devices/.../supplier: are symlinks to device links where this device is the consumer. denotes the - name of the supplier in that device link. There can be zero or - more of these symlinks for a given device. + name of the supplier in that device link and is of the form + bus:device name. There can be zero or more of these symlinks + for a given device. diff --git a/drivers/base/core.c b/drivers/base/core.c index 25e08e5f40bd..47a6faf1605a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -456,7 +456,9 @@ static int devlink_add_symlinks(struct device *dev, struct device *con = link->consumer; char *buf; - len = max(strlen(dev_name(sup)), strlen(dev_name(con))); + len = max(strlen(dev_bus_name(sup)) + strlen(dev_name(sup)), + strlen(dev_bus_name(con)) + strlen(dev_name(con))); + len += strlen(":"); len += strlen("supplier:") + 1; buf = kzalloc(len, GFP_KERNEL); if (!buf) @@ -470,12 +472,12 @@ static int devlink_add_symlinks(struct device *dev, if (ret) goto err_con; - snprintf(buf, len, "consumer:%s", dev_name(con)); + snprintf(buf, len, "consumer:%s:%s", dev_bus_name(con), dev_name(con)); ret = sysfs_create_link(&sup->kobj, &link->link_dev.kobj, buf); if (ret) goto err_con_dev; - snprintf(buf, len, "supplier:%s", dev_name(sup)); + snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup)); ret = sysfs_create_link(&con->kobj, &link->link_dev.kobj, buf); if (ret) goto err_sup_dev; @@ -483,7 +485,7 @@ static int devlink_add_symlinks(struct device *dev, goto out; err_sup_dev:
Re: [PATCH v4] driver core: Fix device link device name collision
On Sat, Jan 09, 2021 at 02:45:06PM -0800, Saravana Kannan wrote: > The device link device's name was of the form: > -- > > This can cause name collision as reported here [1] as device names are > not globally unique. Since device names have to be unique within the > bus/class, add the bus/class name as a prefix to the device names used to > construct the device link device name. > > So the devuce link device's name will be of the form: > :--: > > [1] - https://lore.kernel.org/lkml/20201229033440.32142-1-mich...@walle.cc/ > > Cc: sta...@vger.kernel.org > Fixes: 287905e68dd2 ("driver core: Expose device link details in sysfs") > Reported-by: Michael Walle > Signed-off-by: Saravana Kannan > --- > Documentation/ABI/testing/sysfs-class-devlink | 4 +-- > .../ABI/testing/sysfs-devices-consumer| 5 ++-- > .../ABI/testing/sysfs-devices-supplier| 5 ++-- > drivers/base/core.c | 27 ++- > include/linux/device.h| 12 + > 5 files changed, 35 insertions(+), 18 deletions(-) > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what needs to be done here to properly describe this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot
Re: [PATCH v4] driver core: Fix device link device name collision
Am 2021-01-09 23:45, schrieb Saravana Kannan: The device link device's name was of the form: -- This can cause name collision as reported here [1] as device names are not globally unique. Since device names have to be unique within the bus/class, add the bus/class name as a prefix to the device names used to construct the device link device name. So the devuce link device's name will be of the form: :--: [1] - https://lore.kernel.org/lkml/20201229033440.32142-1-mich...@walle.cc/ Cc: sta...@vger.kernel.org Fixes: 287905e68dd2 ("driver core: Expose device link details in sysfs") Reported-by: Michael Walle Signed-off-by: Saravana Kannan Tested-by: Michael Walle Thanks! -michael
[PATCH v4] driver core: Fix device link device name collision
The device link device's name was of the form: -- This can cause name collision as reported here [1] as device names are not globally unique. Since device names have to be unique within the bus/class, add the bus/class name as a prefix to the device names used to construct the device link device name. So the devuce link device's name will be of the form: :--: [1] - https://lore.kernel.org/lkml/20201229033440.32142-1-mich...@walle.cc/ Cc: sta...@vger.kernel.org Fixes: 287905e68dd2 ("driver core: Expose device link details in sysfs") Reported-by: Michael Walle Signed-off-by: Saravana Kannan --- Documentation/ABI/testing/sysfs-class-devlink | 4 +-- .../ABI/testing/sysfs-devices-consumer| 5 ++-- .../ABI/testing/sysfs-devices-supplier| 5 ++-- drivers/base/core.c | 27 ++- include/linux/device.h| 12 + 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-class-devlink b/Documentation/ABI/testing/sysfs-class-devlink index b662f747c83e..8a21ce515f61 100644 --- a/Documentation/ABI/testing/sysfs-class-devlink +++ b/Documentation/ABI/testing/sysfs-class-devlink @@ -5,8 +5,8 @@ Description: Provide a place in sysfs for the device link objects in the kernel at any given time. The name of a device link directory, denoted as ... above, is of the form -- - where is the supplier device name and is - the consumer device name. + where is the supplier bus:device name and + is the consumer bus:device name. What: /sys/class/devlink/.../auto_remove_on Date: May 2020 diff --git a/Documentation/ABI/testing/sysfs-devices-consumer b/Documentation/ABI/testing/sysfs-devices-consumer index 1f06d74d1c3c..0809fda092e6 100644 --- a/Documentation/ABI/testing/sysfs-devices-consumer +++ b/Documentation/ABI/testing/sysfs-devices-consumer @@ -4,5 +4,6 @@ Contact:Saravana Kannan Description: The /sys/devices/.../consumer: are symlinks to device links where this device is the supplier. denotes the - name of the consumer in that device link. There can be zero or - more of these symlinks for a given device. + name of the consumer in that device link and is of the form + bus:device name. There can be zero or more of these symlinks + for a given device. diff --git a/Documentation/ABI/testing/sysfs-devices-supplier b/Documentation/ABI/testing/sysfs-devices-supplier index a919e0db5e90..207f5972e98d 100644 --- a/Documentation/ABI/testing/sysfs-devices-supplier +++ b/Documentation/ABI/testing/sysfs-devices-supplier @@ -4,5 +4,6 @@ Contact:Saravana Kannan Description: The /sys/devices/.../supplier: are symlinks to device links where this device is the consumer. denotes the - name of the supplier in that device link. There can be zero or - more of these symlinks for a given device. + name of the supplier in that device link and is of the form + bus:device name. There can be zero or more of these symlinks + for a given device. diff --git a/drivers/base/core.c b/drivers/base/core.c index 25e08e5f40bd..47a6faf1605a 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -456,7 +456,9 @@ static int devlink_add_symlinks(struct device *dev, struct device *con = link->consumer; char *buf; - len = max(strlen(dev_name(sup)), strlen(dev_name(con))); + len = max(strlen(dev_bus_name(sup)) + strlen(dev_name(sup)), + strlen(dev_bus_name(con)) + strlen(dev_name(con))); + len += strlen(":"); len += strlen("supplier:") + 1; buf = kzalloc(len, GFP_KERNEL); if (!buf) @@ -470,12 +472,12 @@ static int devlink_add_symlinks(struct device *dev, if (ret) goto err_con; - snprintf(buf, len, "consumer:%s", dev_name(con)); + snprintf(buf, len, "consumer:%s:%s", dev_bus_name(con), dev_name(con)); ret = sysfs_create_link(&sup->kobj, &link->link_dev.kobj, buf); if (ret) goto err_con_dev; - snprintf(buf, len, "supplier:%s", dev_name(sup)); + snprintf(buf, len, "supplier:%s:%s", dev_bus_name(sup), dev_name(sup)); ret = sysfs_create_link(&con->kobj, &link->link_dev.kobj, buf); if (ret) goto err_sup_dev; @@ -483,7 +485,7 @@ static int devlink_add_symlinks(struct device *dev, goto out; err_sup_dev: - snprintf(buf, len, "consumer:%s", dev_name(con)); + snprintf(buf, len, "consumer:%s:%s", dev_bus_name(con), dev_name(con)); sysfs_remove_link(&sup->kobj, buf); err_con_dev: sysfs_remove_link(&link->link_dev.kobj, "consumer"); @@ -506,7 +508,9 @@ static void devlink