From nobody Sun Apr 28 19:53:25 2024 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=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1559762255; cv=none; d=zoho.com; s=zohoarc; b=kUA7tpPC6xYjdXklQP7Fdf9a9YTbrM50y3dyWcvJbAYmI4muCGa47BXWYyAf7pI5BhQp+wi8zw8Lcj2SvUVp4qrRVtvBC78ASBlVUdfFNCMPfHoNT/h1NLU96TmHCikLH0L6gpn4FjuQknb+a0Hr9uSY3q+d2EVR9ssMF7mD3GM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559762255; 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=2/PYOiPCgaOgjxYZW+UlfdVG3rLhfOA3V7+431AJlUA=; b=YfYadTnI1bOrNPlgDvLY6Btih70Y9d1Bpw7n7l3p7YItUwim1cjMSIfkkOeAE2yogdRO5uFLv8M4J0P11hWKy7rGl+td98NDN9lJNm+ChQwOCTzHaP7gMOi/Ho9w+rpvUMdn6aTp+6KU2SC6YJOg1MTOv/xZY3eh9FS/HJIXNhw= 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1559762255432931.9073485030021; Wed, 5 Jun 2019 12:17:35 -0700 (PDT) Received: from localhost ([127.0.0.1]:48637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYbPX-0002FU-NY for importer@patchew.org; Wed, 05 Jun 2019 15:17:23 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYbNv-0001TD-RX for qemu-devel@nongnu.org; Wed, 05 Jun 2019 15:15:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYbNs-0004KC-K6 for qemu-devel@nongnu.org; Wed, 05 Jun 2019 15:15:41 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:56538) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYbNs-0004IP-Bi for qemu-devel@nongnu.org; Wed, 05 Jun 2019 15:15:40 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x55JEun4039844; Wed, 5 Jun 2019 19:15:34 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2suj0qmgat-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jun 2019 19:15:34 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x55JEeGa005960; Wed, 5 Jun 2019 19:15:34 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2swnhac6ar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jun 2019 19:15:34 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x55JFWvK017421; Wed, 5 Jun 2019 19:15:32 GMT Received: from ca-virt2-2.us.oracle.com (/10.211.11.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 05 Jun 2019 12:15:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=NkXgzSdPzOVUZDNJyEcRjrNqZpjA81OtuuhO4YYVHbc=; b=YGG6teis/KCvQyw8gTpF3l1Z2bktSGhQ2yP1hnQKH51B8hJxgysp1v3MtLbQl6L4g5BC jcFXZM5Zrrb3OeT9UBp5VqAOu1rEIkhKy3vZeApmIrO6lIzqSd+Yo5rEu+b1WpuVyXU5 91LUodkxB7XWBqA3OPrC6J4O3oXMZ0vRHHMNVj6VMqCabZT3IzlL343OqWpIkkcagzz8 ZYjyRJqjaF9jBX3n/LTypY/QWuvU83Le4Bait68xERoiLufn8h+9FUld2iXlp1a8Itvl Oo1UMX8IxdDmT8CNMvFH4R+97L3xFm27KbLQ1E3YPvndp9znNdP1SMGFT4boVmNAtgkx dQ== From: Lidong Chen To: qemu-devel@nongnu.org Date: Wed, 5 Jun 2019 15:15:20 -0400 Message-Id: <6b19cb7359a10a6bedc3ea0fce22fed3ef93c102.1559761541.git.lidong.chen@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9279 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906050120 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9279 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906050120 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id x55JEun4039844 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [Qemu-devel PATCH v2 1/2] sd: Fix out-of-bounds assertions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, berrange@redhat.com, liran.alon@oracle.com, liq3ea@gmail.com, armbru@redhat.com, lidong.chen@oracle.com, darren.kenny@oracle.com, marcandre.lureau@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Due to an off-by-one error, the assert statements allow an out-of-bound array access. Signed-off-by: Lidong Chen Reviewed-by: Liam Merwick Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Li Qiang Reviewed-by: Darren Kenny --- hw/sd/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index aaab15f..818f86c 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -144,7 +144,7 @@ static const char *sd_state_name(enum SDCardStates stat= e) if (state =3D=3D sd_inactive_state) { return "inactive"; } - assert(state <=3D ARRAY_SIZE(state_name)); + assert(state < ARRAY_SIZE(state_name)); return state_name[state]; } =20 @@ -165,7 +165,7 @@ static const char *sd_response_name(sd_rsp_type_t rsp) if (rsp =3D=3D sd_r1b) { rsp =3D sd_r1; } - assert(rsp <=3D ARRAY_SIZE(response_name)); + assert(rsp < ARRAY_SIZE(response_name)); return response_name[rsp]; } =20 --=20 1.8.3.1 From nobody Sun Apr 28 19:53:25 2024 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=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1559762338; cv=none; d=zoho.com; s=zohoarc; b=X7eOTNuNNJfpt16t1x0Y9c9C9Cnr6LckS3U1qdznzRXkI4aDh1aKqC3ojZpTuPxoCIt+1PjX1Kgj3EtxWcUe6olMdQ6MIgOkHC/baOiRWqkq1nY2QK1p/fxHnw30+7NSdSaN3vV8rxDAzEuB1lpsW9YEDm8R8Py0GxpwRPDWMyc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559762338; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=pMM3g/lXlfzIAdICK/bAJKcbHnAJyHws6Dubb/vNs+s=; b=DWkslupAyzptQ8BuOjcA/d0XQwnI8lkcMBDytpSbORAn6mqwNKBOx1khrpRvxblVQLzLdHJzWWHj6biqkovo64fmWIqEXZm2qWCPUIjnG98Bs27DAT7Z+V1sXUA6avj1xZD/O3VWyYYL+AUp46o7GyU+dVC+oE4wMKpYvzM++Bo= 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 155976233849513.968921236627807; Wed, 5 Jun 2019 12:18:58 -0700 (PDT) Received: from localhost ([127.0.0.1]:48645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYbR1-00039Q-Go for importer@patchew.org; Wed, 05 Jun 2019 15:18:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYbQ3-0002oy-Uw for qemu-devel@nongnu.org; Wed, 05 Jun 2019 15:17:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYbQ0-0008E1-10 for qemu-devel@nongnu.org; Wed, 05 Jun 2019 15:17:53 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:58494) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYbPx-0007ky-RV for qemu-devel@nongnu.org; Wed, 05 Jun 2019 15:17:50 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x55JEPMw038858; Wed, 5 Jun 2019 19:17:35 GMT Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2suj0qmgnu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jun 2019 19:17:35 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x55JDsdF125400; Wed, 5 Jun 2019 19:15:34 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2swngj27qn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jun 2019 19:15:34 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x55JFXlJ017424; Wed, 5 Jun 2019 19:15:33 GMT Received: from ca-virt2-2.us.oracle.com (/10.211.11.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 05 Jun 2019 12:15:32 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references; s=corp-2018-07-02; bh=pMM3g/lXlfzIAdICK/bAJKcbHnAJyHws6Dubb/vNs+s=; b=5M0zlJXRltPdHG3x4j55/4CD4PcW6wm9Dovqw0XxNBtCGdmB/lvxwYdqVCNM3FcstU8i G9NrP9LYN433Lj2PQ9jD/kHdGlFRes5UjeqNHxDHU3j2r7r6910UD6V5mHsMBmupE1Fm wfRTKIVBb+RiCXK+p0vLRR28fftiYg9XfFtyj7MSEw4u8m2oN25yhu0DAooI0m9fV6WW ltSn9X81Q2NED6PAqs5Y5pSTGIXVimmarKJmvs6S5hnGaSgqAxQDPcuQDYsG2qAXCYKx vTwvdwVuOvcfERa7SainbhiD09xLWC7o8gggfiZ+FtTwK0P/MAfhyJzamx3Pr4s+EeUL +g== From: Lidong Chen To: qemu-devel@nongnu.org Date: Wed, 5 Jun 2019 15:15:21 -0400 Message-Id: <00742cd052c0b66e8da0b6b684cd460d6a051175.1559761541.git.lidong.chen@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9279 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906050120 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9279 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1906050120 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [Qemu-devel PATCH v2 2/2] util/main-loop: Fix incorrect assertion X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, berrange@redhat.com, liran.alon@oracle.com, liq3ea@gmail.com, armbru@redhat.com, lidong.chen@oracle.com, darren.kenny@oracle.com, marcandre.lureau@gmail.com, amarkovic@wavecomp.com, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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). 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 --- 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