From nobody Tue Nov 11 05:00:21 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=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1560972251; cv=none; d=zoho.com; s=zohoarc; b=NS3wUIItHTgrofuzSmkN9RuGZyZ8r3wqddUu5AfQaFIqmK7BLd7VIt9nbgw3ci8ioziEUFjnCr2eM6H9Qm458AuxxXxos8M5iilhAc+85yp8kE2s5V8MJj/Uj92jI2TgAFyi7FoqveSX+Yf/3oBBsJ9Ou3cMrHYXnjiUWqiUguo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560972251; 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=QknbrYuF3Bo6TG2bhZWZDEqPcshb02IIFyj9IzSp1WE/q47jC4wkET/3JbsiiyBgfpZidpgmXomlu99xogWJU9yaD0KyixyWoOIHKsiMOTsQ2mHwStUYZ5gvDX+PdJJDkPQ+XKFWWbFrZbYX5xPZOhP1sLbH0FMWd/nd2SBh2HE= 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 1560972251835833.6117105837365; Wed, 19 Jun 2019 12:24:11 -0700 (PDT) Received: from localhost ([::1]:41282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdgBm-00026l-S4 for importer@patchew.org; Wed, 19 Jun 2019 15:24:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47387) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdg4j-0005eg-97 for qemu-devel@nongnu.org; Wed, 19 Jun 2019 15:16:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdg4e-0007sk-Sn for qemu-devel@nongnu.org; Wed, 19 Jun 2019 15:16:50 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:47064) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hdg4b-0007Yc-NE for qemu-devel@nongnu.org; Wed, 19 Jun 2019 15:16:47 -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 x5JJ8ZxT074719; Wed, 19 Jun 2019 19:16:30 GMT Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2t7809d8rn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Jun 2019 19:16:30 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x5JJFEoa094497; Wed, 19 Jun 2019 19:16:29 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3030.oracle.com with ESMTP id 2t7rdwtkvn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Jun 2019 19:16:29 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x5JJGSkQ008841; Wed, 19 Jun 2019 19:16:28 GMT Received: from ca-virt2-2.us.oracle.com (/10.211.11.112) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 19 Jun 2019 12:16:27 -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=J03w48Zkdx31N+VWxi3Ik1ek7fpOXznc946KeabxUzjy97jkH6MtNJKa60uJUS7YgcMz QtOVlg4MEfY/YcU++S3I0rA6pUjafAy2EXy1ijpqM0sbX80burpFehtxjXLsX1oieMtd cSn7rKbxDPkgHKM9Yuq0eJj+2uUt7QiEBF5LI9jqpzQg26r5ZLdeVBkLCZYSlOTHuTje HcLkGMaIKEngrfWM7YuhjH6oeHb48wYw6dy3n0bqtb85ZvlBaBobCdEmw1Jg4CILNOBy uJAZnB8E1LlFaA2PnRlO6cMnUgRyjdVGSVi8rJ9Mf1J1xWNxWe2MXlA8hyDuNyhGRn29 nA== From: Lidong Chen To: qemu-devel@nongnu.org Date: Wed, 19 Jun 2019 15:14:46 -0400 Message-Id: <6b19cb7359a10a6bedc3ea0fce22fed3ef93c102.1560806687.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=9293 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-1906190157 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9293 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-1906190157 Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by userp2120.oracle.com id x5JJ8ZxT074719 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 v3 1/2] sd: Fix out-of-bounds assertions 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: peter.maydell@linaro.org, berrange@redhat.com, liq3ea@gmail.com, f4bug@amsat.org, armbru@redhat.com, lidong.chen@oracle.com, darren.kenny@oracle.com, liran.alon@oracle.com, marcandre.lureau@gmail.com, amarkovic@wavecomp.com, pbonzini@redhat.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