From nobody Tue May 7 08:12:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.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 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=163.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1546521452122514.4173705875132; Thu, 3 Jan 2019 05:17:32 -0800 (PST) Received: from localhost ([127.0.0.1]:53710 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gf2sM-0007ME-VP for importer@patchew.org; Thu, 03 Jan 2019 08:17:30 -0500 Received: from eggs.gnu.org ([208.118.235.92]:47219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gf2p6-0004hR-HO for qemu-devel@nongnu.org; Thu, 03 Jan 2019 08:14:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gf2p2-0004qW-KI for qemu-devel@nongnu.org; Thu, 03 Jan 2019 08:14:08 -0500 Received: from m12-14.163.com ([220.181.12.14]:43493) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gf2p1-0004oR-T2 for qemu-devel@nongnu.org; Thu, 03 Jan 2019 08:14:04 -0500 Received: from localhost.localdomain (unknown [183.134.169.2]) by smtp10 (Coremail) with SMTP id DsCowACXPIaVCi5cGHCfIA--.27596S2; Thu, 03 Jan 2019 21:13:58 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=NdsGMUpC60Qlr8sL+n 8g7kOsei1UYOJ6KpxzV6awIdA=; b=kCt3OZm/posa2NA11AXiIQC1Az6dOxFucQ PDg/xZPauVcRN8+1upyrqphup6ilxhRkn5mjgjjUV2QzsCPOkBlFJXNyXwROWqQ4 LD+/eAG4aX4iqLmOjaf8vQCm+6sjBp9jyxq7lt2/AxdEAMR1RYJdgQ0bwk9x8jSz tJkio5qgE= From: Li Qiang To: yuval.shaia@oracle.com, marcel.apfelbaum@gmail.com Date: Thu, 3 Jan 2019 05:12:51 -0800 Message-Id: <20190103131251.49271-1-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: DsCowACXPIaVCi5cGHCfIA--.27596S2 X-Coremail-Antispam: 1Uf129KBjvdXoW7Gr4UZw1ruF43XFWfCryfJFb_yoWfKrb_JF n8Ar1xWa1kZa4Syr1Yqa17Ar40gayxGFs0y3y3Cr17X3Waqa4DKFn7ArnxXrnrWFW2g345 Zr18urW3JFyxAjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUj7GYtUUUUU== X-Originating-IP: [183.134.169.2] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBoQsxbVQHDGm-OAAAsH X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 220.181.12.14 Subject: [Qemu-devel] [PATCH] hw: rdma: fix an off-by-one issue 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, Li Qiang , qemu-devel@nongnu.org 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" In rdma_rm_get_backend_gid_index(), the 'sgid_idx' is used to index the array 'dev_res->port.gid_tbl' which size is MAX_PORT_GIDS. Current the 'sgid_idx' may be MAX_PORT_GIDS thus cause an off-by-one issue. Spotted by Coverity: CID 1398594 Signed-off-by: Li Qiang Reviewed-by: Marcel Apfelbaum --- hw/rdma/rdma_rm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c index f5b1295890..1bbc5f128f 100644 --- a/hw/rdma/rdma_rm.c +++ b/hw/rdma/rdma_rm.c @@ -576,7 +576,7 @@ int rdma_rm_del_gid(RdmaDeviceResources *dev_res, RdmaB= ackendDev *backend_dev, int rdma_rm_get_backend_gid_index(RdmaDeviceResources *dev_res, RdmaBackendDev *backend_dev, int sgid_id= x) { - if (unlikely(sgid_idx < 0 || sgid_idx > MAX_PORT_GIDS)) { + if (unlikely(sgid_idx < 0 || sgid_idx >=3D MAX_PORT_GIDS)) { pr_dbg("Got invalid sgid_idx %d\n", sgid_idx); return -EINVAL; } --=20 2.17.1