From nobody Sun Sep 28 00:35:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1561082143; cv=none; d=zoho.com; s=zohoarc; b=m6CYz8LToYThZL1IgeYcQ6EqA2NZnA5IB5/zpEvIJ7D6Ler48o9QLwDmpXZDIj6kIir3W4p5Yp9khKPycPhisR5IJ/pX7/CTA/GW+XtRCILQQWvYqpallig6+vk+TuueSdVTcb+Pt9jbtkRW5UwiRLOC53fFlbZhZk4Inl0aHOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561082143; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=a3VGuwnoGM9LiZBZHhLPfux9Kyat183XzMS8uuGHjKk=; b=NFNxtCCdre4h2MMeedecStnqdLcMJwK5ewEVTmRNKPgcJd4zZLwq4UgyzKjE89mHPgjJCk9mXNOYywOhUcPegelVYjhBk56FB/rLCE3TGkWu8amfdlmN//N0LGGkOlTjGEqSer1ULVb8isNUBGZU3AxR93XK1JNfiD/GFW/fATc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1561082143097454.8722458742907; Thu, 20 Jun 2019 18:55:43 -0700 (PDT) Received: from localhost ([::1]:54070 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he8mC-00062G-1Z for importer@patchew.org; Thu, 20 Jun 2019 21:55:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41115) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1he8a3-0006bI-W4 for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:43:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1he8a2-0006b1-7B for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:43:07 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]:51758) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1he8Zz-0006Pc-Sm for qemu-devel@nongnu.org; Thu, 20 Jun 2019 21:43:05 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 207so4810400wma.1 for ; Thu, 20 Jun 2019 18:42:57 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d1sm1123125wru.41.2019.06.20.18.42.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Jun 2019 18:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a3VGuwnoGM9LiZBZHhLPfux9Kyat183XzMS8uuGHjKk=; b=AeYOPHxi8fq9FXqQUBTvliOB04XlMVLB/x+r/TsI1u6gUoNUYC4Gw5hnXgXVrnhsuZ W2Sx4PMlN+RtDWyKh5G9SUyX/np6w2UjO3FWgulU5PSQSKjCuWyNYnwsUMLgyxlJpVB3 Xrj4L18uTqECbIzpQEl9feekjpo91S8BzfF+gBGI0SSuMXwFjsbE6Es+2Vjjvmea5ANL gKYMy/q59ueQiiFZ0F1IZOR3GSzeyeVvTdpa8RRtlrAZzhZd+2XfMqmdm28PdiliUGIb u1u1YwN5nIWy9M776y/007M+gXbYAfK3KA6grVYggYkzaS5wq7SRVqGB4+NquFw2Am22 xO7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=a3VGuwnoGM9LiZBZHhLPfux9Kyat183XzMS8uuGHjKk=; b=Ad3C7W4V93RKBOdGrVmWznngf0oOHnkT5ZN6dNVkRo+7V9V+RrItJWM8t3vG1qYYlt nCPhFtcxogIl64cw0uu8qy7hr9+UGsBVJeiN+D+Tq59jDGl2JUmQ1fOweCCAEeYXUE9o I/PSC6G/xRduh0Uv0mOkI6GVyrpxH6WYoTPFQ3rw4YFD1FUhyryb0tW3s7vvN1P2+0sS OalaWce0BcmQsp5QKQbpW7FKpXcO2SBVa+SBCn9/MbUTeLby9R8UZZjwTknGGD5N5bZA jwUezfVxjCjfDre6IDNftIVHXj/AFQiRAsbHxcDBVuGpM12OcDC1tu9cYpU8eiRMBUob mDCw== X-Gm-Message-State: APjAAAUm/4jnnz1O0tvyD7lDq1fiEyHdd0rxo9EDWrScxwH7ckRuI2bE vD96UQjCqfxBSenOd5+A9NIZ3C/d X-Google-Smtp-Source: APXvYqxNeBYzhhmIQ+GM6rRBgXcBm7+EfdxziZXDakqoQshueOoT7i+FdGi8kWJ0OIPSFX9EIL6Qhw== X-Received: by 2002:a1c:f314:: with SMTP id q20mr1401715wmq.74.1561081376683; Thu, 20 Jun 2019 18:42:56 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Fri, 21 Jun 2019 03:42:29 +0200 Message-Id: <1561081350-3723-25-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1561081350-3723-1-git-send-email-pbonzini@redhat.com> References: <1561081350-3723-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32b Subject: [Qemu-devel] [PULL 24/25] util/main-loop: Fix incorrect assertion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lidong Chen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Lidong Chen The check for poll_fds in g_assert() was incorrect. The correct assertion should check "n_poll_fds + w->num <=3D ARRAY_SIZE(poll_fds)" because the subsequent for-loop is doing access to poll_fds[n_poll_fds + i] where i is in [0, w->num). This could happen with a very high number of file descriptors and/or wait objects. Signed-off-by: Lidong Chen Suggested-by: Peter Maydell Suggested-by: Liam Merwick Reviewed-by: Liran Alon Reviewed-by: Darren Kenny Reviewed-by: Li Qiang Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: Signed-off-by: Paolo Bonzini --- util/main-loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/main-loop.c b/util/main-loop.c index e1e349c..a9f4e8d 100644 --- a/util/main-loop.c +++ b/util/main-loop.c @@ -422,7 +422,7 @@ static int os_host_main_loop_wait(int64_t timeout) g_main_context_prepare(context, &max_priority); n_poll_fds =3D g_main_context_query(context, max_priority, &poll_timeo= ut, poll_fds, ARRAY_SIZE(poll_fds)); - g_assert(n_poll_fds <=3D ARRAY_SIZE(poll_fds)); + g_assert(n_poll_fds + w->num <=3D ARRAY_SIZE(poll_fds)); =20 for (i =3D 0; i < w->num; i++) { poll_fds[n_poll_fds + i].fd =3D (DWORD_PTR)w->events[i]; --=20 1.8.3.1