From patchwork Tue Jul 22 15:26:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 34102 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D7A2820540 for ; Tue, 22 Jul 2014 15:27:28 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id tr6sf71227141ieb.10 for ; Tue, 22 Jul 2014 08:27:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list; bh=W+xPRurISIqKZL5ldR2U6E8yuETT0/NNHJDk50OZLwc=; b=g08FI+4Okwqu0j5N0t7snImN0po0X6JHdX+ZbsrOKHb98j/f7GnHEolEi/Ffcx1ojC v1FbrjX0YfqHjP92yx2/XwagwU2YdQHurfr6q7b72IwwbAKXcYaZ6ahbqbzQ5kFrATIU Mb6kLNP8AJGtaKqKBsFxlrudEO3VtKvPfgeM4v2f7S4UmCRzvipcrLV7yOpXL+btSbhR ZRiE4ZXp7SMqs/LsbrHfp4EMYd/mG1eWb9oe82XBZ+WLOHkspZyTAuHZXza1rH6VEcvp GJmkwEIT8inzBtgmZoYySj9mJQ6Qs+O1s7Ff35Scu5PNkdDlNm8h+7Cs2Q8S9gf28OT2 BiFA== X-Gm-Message-State: ALoCoQmQvIIAHRLJWamP15gQxQYNx2u7Gar5sV+qRN+mOqHi21spSwD9Lor+ehFLjyFaR6Mjuk5v X-Received: by 10.50.73.5 with SMTP id h5mr5483952igv.2.1406042848377; Tue, 22 Jul 2014 08:27:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.50.25.137 with SMTP id c9ls2334906igg.7.canary; Tue, 22 Jul 2014 08:27:28 -0700 (PDT) X-Received: by 10.66.141.165 with SMTP id rp5mr19229289pab.90.1406042848210; Tue, 22 Jul 2014 08:27:28 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id ut6si1294130veb.11.2014.07.22.08.27.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Jul 2014 08:27:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ij19so14977300vcb.25 for ; Tue, 22 Jul 2014 08:27:28 -0700 (PDT) X-Received: by 10.52.248.146 with SMTP id ym18mr35035827vdc.8.1406042847354; Tue, 22 Jul 2014 08:27:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp205179vcb; Tue, 22 Jul 2014 08:27:27 -0700 (PDT) X-Received: by 10.224.34.73 with SMTP id k9mr57064131qad.11.1406042846846; Tue, 22 Jul 2014 08:27:26 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b30si1278404qgf.107.2014.07.22.08.27.26 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 22 Jul 2014 08:27:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:39807 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9byQ-00020D-Fb for patch@linaro.org; Tue, 22 Jul 2014 11:27:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57663) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9bxu-0001iq-JD for qemu-devel@nongnu.org; Tue, 22 Jul 2014 11:27:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X9bxn-0003ly-4P for qemu-devel@nongnu.org; Tue, 22 Jul 2014 11:26:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25183) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X9bxm-0003lo-Sm; Tue, 22 Jul 2014 11:26:47 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s6MFQjc8011036 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 22 Jul 2014 11:26:45 -0400 Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s6MFQhWj030021; Tue, 22 Jul 2014 11:26:43 -0400 From: Laszlo Ersek To: lersek@redhat.com, amit.shah@redhat.com, dgilbert@redhat.com, kraxel@redhat.com, qemu-devel@nongnu.org, qemu-stable@nongnu.org Date: Tue, 22 Jul 2014 17:26:41 +0200 Message-Id: <1406042801-28212-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.1 for-stable] vmstate_xhci_event: fix unterminated field list X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lersek@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 "vmstate_xhci_event" was introduced in commit 37352df3 ("xhci: add live migration support"), and first released in v1.6.0. The field list in this VMSD is not terminated with the VMSTATE_END_OF_LIST() macro. During normal use (ie. migration), the issue is practically invisible, because the "vmstate_xhci_event" object (with the unterminated field list) is only ever referenced -- via "vmstate_xhci_intr" -- if xhci_er_full() returns true, for the "ev_buffer" test. Since that field_exists() check (apparently) almost always returns false, we almost never traverse "vmstate_xhci_event" during migration, which hides the bug. However, Amit's vmstate checker forces recursion into this VMSD as well, and the lack of VMSTATE_END_OF_LIST() breaks the field list terminator check (field->name != NULL) in dump_vmstate_vmsd(). The result is undefined behavior, which in my case translates to infinite recursion (because the loop happens to overflow into "vmstate_xhci_intr", which then links back to "vmstate_xhci_event"). Add the missing terminator. Signed-off-by: Laszlo Ersek Reviewed-by: Amit Shah Reviewed-by: Paolo Bonzini --- hw/usb/hcd-xhci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 7f2af89..58c4b11 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -3737,6 +3737,7 @@ static const VMStateDescription vmstate_xhci_event = { VMSTATE_UINT32(flags, XHCIEvent), VMSTATE_UINT8(slotid, XHCIEvent), VMSTATE_UINT8(epid, XHCIEvent), + VMSTATE_END_OF_LIST() } };