From: Benjamin Marzinski <bmarzins@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Subject: [PATCH] multipath: fix libudev bug in sysfs_get_tgt_nodename
Date: Mon, 11 Jun 2012 16:32:35 -0500 [thread overview]
Message-ID: <20120611213235.GE3211@ether.msp.redhat.com> (raw)
In a recent patch, I introduced a bug into sysfs_get_tgt_nodename().
multipath must not unreference the target udevice before it copies the
tgt_nodename to another location, otherwise the value pointer will be
pointing at freed memory.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Index: multipath-tools-120518/libmultipath/discovery.c
===================================================================
--- multipath-tools-120518.orig/libmultipath/discovery.c
+++ multipath-tools-120518/libmultipath/discovery.c
@@ -215,11 +215,13 @@ sysfs_get_tgt_nodename (struct path *pp,
const char *value;
value = udev_device_get_sysattr_value(tgtdev, "node_name");
- udev_device_unref(tgtdev);
if (value) {
strncpy(node, value, NODE_NAME_SIZE);
+ udev_device_unref(tgtdev);
return 0;
}
+ else
+ udev_device_unref(tgtdev);
}
/* Check for iSCSI */
@@ -238,11 +240,13 @@ sysfs_get_tgt_nodename (struct path *pp,
const char *value;
value = udev_device_get_sysattr_value(tgtdev, "targetname");
- udev_device_unref(tgtdev);
if (value) {
strncpy(node, value, NODE_NAME_SIZE);
+ udev_device_unref(tgtdev);
return 0;
}
+ else
+ udev_device_unref(tgtdev);
}
}
return 1;
reply other threads:[~2012-06-11 21:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20120611213235.GE3211@ether.msp.redhat.com \
--to=bmarzins@redhat.com \
--cc=dm-devel@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.