[systemd-devel] [PATCH] Use dev_port for the ID of a network device.

2014-06-30 Thread Thadeu Lima de Souza Cascardo
For network devices on the same PCI function, dev_id should not be used,
since its purpose is for IPv6 support on interfaces with the same MAC
address.

The new dev_port sysfs attribute should be used when it is found. When
it is not, using dev_id might work.

Signed-off-by: Thadeu Lima de Souza Cascardo casca...@linux.vnet.ibm.com
---
 src/udev/udev-builtin-net_id.c |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index c80c30a..6de9c98 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -186,9 +186,14 @@ static int dev_pci_slot(struct udev_device *dev, struct 
netnames *names) {
 return -ENOENT;
 
 /* kernel provided multi-device index */
-attr = udev_device_get_sysattr_value(dev, dev_id);
-if (attr)
+attr = udev_device_get_sysattr_value(dev, dev_port);
+if (attr) {
 dev_id = strtol(attr, NULL, 16);
+} else {
+attr = udev_device_get_sysattr_value(dev, dev_id);
+if (attr)
+dev_id = strtol(attr, NULL, 16);
+}
 
 /* compose a name based on the raw kernel's PCI bus, slot numbers */
 s = names-pci_path;
-- 
1.7.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Use dev_port for the ID of a network device.

2014-07-01 Thread Thadeu Lima de Souza Cascardo
On Tue, Jul 01, 2014 at 02:33:19AM +0200, Kay Sievers wrote:
 On Mon, Jun 30, 2014 at 10:36 PM, Thadeu Lima de Souza Cascardo
 casca...@linux.vnet.ibm.com wrote:
  For network devices on the same PCI function, dev_id should not be used,
  since its purpose is for IPv6 support on interfaces with the same MAC
  address.
 
  The new dev_port sysfs attribute should be used when it is found. When
  it is not, using dev_id might work.
 
 I don't see a problem switching this over, but why would we keep using
 dev_id if it is not the right thing to use?
 
 Kay
 

Because dev_port has only been introduced into Linux 3.15, and some
drivers used dev_id before Linux 3.10. It's not an ideal situation, so I
think it's important to keep some compatibility for the time being. Or
we could simply drop dev_id, and force everyone to do the right thing
and backport dev_port support and fix their drivers.

Cascardo.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] Use dev_port for the ID of a network device.

2014-07-01 Thread Thadeu Lima de Souza Cascardo
On Tue, Jul 01, 2014 at 08:45:56AM +0200, Bjørn Mork wrote:
 Thadeu Lima de Souza Cascardo casca...@linux.vnet.ibm.com writes:
 
  diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
  index c80c30a..6de9c98 100644
  --- a/src/udev/udev-builtin-net_id.c
  +++ b/src/udev/udev-builtin-net_id.c
  @@ -186,9 +186,14 @@ static int dev_pci_slot(struct udev_device *dev, 
  struct netnames *names) {
   return -ENOENT;
   
   /* kernel provided multi-device index */
  -attr = udev_device_get_sysattr_value(dev, dev_id);
  -if (attr)
  +attr = udev_device_get_sysattr_value(dev, dev_port);
  +if (attr) {
   dev_id = strtol(attr, NULL, 16);
  +} else {
  +attr = udev_device_get_sysattr_value(dev, dev_id);
  +if (attr)
  +dev_id = strtol(attr, NULL, 16);
  +}
   
   /* compose a name based on the raw kernel's PCI bus, slot numbers 
  */
   s = names-pci_path;
 
 Note that the base of the new attribute is 10, not 16:
 
 bjorn@nemi:/usr/local/src/git/linux$ git grep dev_port net/core/
 net/core/net-sysfs.c:NETDEVICE_SHOW_RO(dev_port, fmt_dec);
 net/core/net-sysfs.c:   dev_attr_dev_port.attr,
 bjorn@nemi:/usr/local/src/git/linux$ git grep dev_id net/core/
 net/core/net-sysfs.c:NETDEVICE_SHOW_RO(dev_id, fmt_hex);
 net/core/net-sysfs.c:   dev_attr_dev_id.attr,
 
 
 
 Bjørn
 

Thanks for noticing, I'll fix that.

Cascardo.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH v2] Use dev_port for the ID of a network device.

2014-07-01 Thread Thadeu Lima de Souza Cascardo
For network devices on the same PCI function, dev_id should not be used,
since its purpose is for IPv6 support on interfaces with the same MAC
address.

The new dev_port sysfs attribute should be used instead of dev_id.

Signed-off-by: Thadeu Lima de Souza Cascardo casca...@linux.vnet.ibm.com
---
 NEWS   |5 +
 src/udev/udev-builtin-net_id.c |   18 +-
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/NEWS b/NEWS
index 00727d1..f0c29d1 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,11 @@ CHANGES WITH 215:
   system-level software to get access to input devices. It
   complements what is already done for audio and video.
 
+* udev built-in net_id uses dev_port sysfs attribute, introduced
+  in linux 3.15 instead of dev_id to distinguish between ports
+  of the same PCI function. dev_id should only be used for ports
+  using the same HW address, hence the need for dev_port.
+
 CHANGES WITH 214:
 
 * As an experimental feature, udev now tries to lock the
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index c80c30a..96ac21c 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -36,9 +36,9 @@
  *   bnumber -- BCMA bus core number
  *   ccwname -- CCW bus group name
  *   oindex  -- on-board device index number
- *   sslot[ffunction][ddev_id]   -- hotplug slot index number
+ *   sslot[ffunction][ddev_port] -- hotplug slot index number
  *   xMAC-- MAC address
- *   [Pdomain]pbussslot[ffunction][ddev_id]
+ *   [Pdomain]pbussslot[ffunction][ddev_port]
  * -- PCI geographical location
  *   
[Pdomain]pbussslot[ffunction][uport][..][cconfig][iinterface]
  * -- USB port number chain
@@ -172,7 +172,7 @@ out:
 
 static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
 struct udev *udev = udev_device_get_udev(names-pcidev);
-unsigned domain, bus, slot, func, dev_id = 0;
+unsigned domain, bus, slot, func, dev_port = 0;
 size_t l;
 char *s;
 const char *attr;
@@ -186,9 +186,9 @@ static int dev_pci_slot(struct udev_device *dev, struct 
netnames *names) {
 return -ENOENT;
 
 /* kernel provided multi-device index */
-attr = udev_device_get_sysattr_value(dev, dev_id);
+attr = udev_device_get_sysattr_value(dev, dev_port);
 if (attr)
-dev_id = strtol(attr, NULL, 16);
+dev_port = strtol(attr, NULL, 10);
 
 /* compose a name based on the raw kernel's PCI bus, slot numbers */
 s = names-pci_path;
@@ -198,8 +198,8 @@ static int dev_pci_slot(struct udev_device *dev, struct 
netnames *names) {
 l = strpcpyf(s, l, p%ds%d, bus, slot);
 if (func  0 || is_pci_multifunction(names-pcidev))
 l = strpcpyf(s, l, f%d, func);
-if (dev_id  0)
-l = strpcpyf(s, l, d%d, dev_id);
+if (dev_port  0)
+l = strpcpyf(s, l, d%d, dev_port);
 if (l == 0)
 names-pci_path[0] = '\0';
 
@@ -248,8 +248,8 @@ static int dev_pci_slot(struct udev_device *dev, struct 
netnames *names) {
 l = strpcpyf(s, l, s%d, hotplug_slot);
 if (func  0 || is_pci_multifunction(names-pcidev))
 l = strpcpyf(s, l, f%d, func);
-if (dev_id  0)
-l = strpcpyf(s, l, d%d, dev_id);
+if (dev_port  0)
+l = strpcpyf(s, l, d%d, dev_port);
 if (l == 0)
 names-pci_path[0] = '\0';
 }
-- 
1.7.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] ask-password: prevent buffer overrow when reading from keyring

2019-05-13 Thread Thadeu Lima de Souza Cascardo
When we read from keyring, a temporary buffer is allocated in order to
determine the size needed for the entire data. However, when zeroing that area,
we use the data size returned by the read instead of the lesser size allocate
for the buffer.

That will cause memory corruption that causes systemd-cryptsetup to crash
either when a single large password is used or when multiple passwords have
already been pushed to the keyring.

Signed-off-by: Thadeu Lima de Souza Cascardo 
---
 src/shared/ask-password-api.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index ab0c34692f1c..6c0a36990291 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -80,7 +80,7 @@ static int retrieve_key(key_serial_t serial, char ***ret) {
 if (n < m)
 break;
 
-explicit_bzero_safe(p, n);
+explicit_bzero_safe(p, m);
 
 if (m > LONG_MAX / 2) /* overflow check */
 return -ENOMEM;
-- 
2.20.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel