]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Fix stack smashing in virNetDevGetFamilyId
authorLaine Stump <laine@laine.org>
Thu, 21 Sep 2017 17:57:30 +0000 (13:57 -0400)
committerJiri Denemark <jdenemar@redhat.com>
Fri, 22 Sep 2017 07:17:59 +0000 (09:17 +0200)
After commit 8708ca01c0d libvirtd consistently aborts with "stack
 smashing detected" when nodedev driver is initialized.

This is caused by nlmsg_parse() being told that its array of nlattr*
has CTRL_CMD_MAX (10) entries, when in fact it is declared to have
CTRL_ATTR_MAX (8) entries. Since all the entries are initialized to
NULL, the result is that nlmsg_parse is overwriting 2*(sizof(nlattr*))
bytes outside the array.

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/util/virnetdev.c

index 41a659732be8d505c7afe226a22d9f68e288c59b..5060d051dc3bef64ecf44eb69726f62e2f6e2f02 100644 (file)
@@ -3183,7 +3183,7 @@ virNetDevGetFamilyId(const char *family_name)
     if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, 0, NETLINK_GENERIC, 0) < 0)
         goto cleanup;
 
-    if (nlmsg_parse(resp, sizeof(struct nlmsghdr), tb, CTRL_CMD_MAX, NULL) < 0) {
+    if (nlmsg_parse(resp, sizeof(struct nlmsghdr), tb, CTRL_ATTR_MAX, NULL) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                        _("malformed netlink response message"));
         goto cleanup;