Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp263241lqf; Fri, 26 Apr 2024 06:13:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWG84KS0c0rLtKVuNHbd86v+0lAXC57axs0Je7r21B1mrV4Pekjqbfi4AuY2HM4mDewvqWr6T+ywspUACuXyG0C9iiej6W2n/vmgD2+dQ== X-Google-Smtp-Source: AGHT+IGzKleCNnV0FyMlNM60GsJU3UCF4IVFy+LgFkEtucj+dRmsTe6QhfpzX2dcRQCKnCR36ahm X-Received: by 2002:a05:6a20:5619:b0:1a7:a353:939e with SMTP id ir25-20020a056a20561900b001a7a353939emr2650469pzc.56.1714137233955; Fri, 26 Apr 2024 06:13:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714137233; cv=pass; d=google.com; s=arc-20160816; b=qTB6aP1eGDauWl0RNOireBanRVVqE4fpWo94potBx0w3BvBvilatHV+yJH73icVy5P Eb4+fkQpMLgGZrWciy7S4Ect7uizVYp0+pKuECi8zFGQVKXYEoxlibnq3fo+nVhlU2HA YuX9v4mO7/gmwxSF0G2qHoqTQ0u+2spMdI0o6snHdT2oK2EVBKfF5yieUlsGbdbT2i1a unnPJ5wHLS/WcNaHX/Mx0jC6G9gI7Jn7HqQqVAso+2Zl6zcVORVBpu0y44XqJR8L/aoB 9n340Czb8AC2Sspa9PfbMeZ/WESsGchBrUd5XwPQZZRJJ/ZQWniDFPC8HqVLGHygXWJz Hidw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :dkim-filter; bh=HfSrTbBlObJZ5QgMLDom1PtUczMN227beKLXYqpagmc=; fh=ujksmUrBEjpGhQjWbrjZMx9PDXUXbYR/j4y8MAq1x1o=; b=yONVlxT9gII+5igtCMUJQHAKpVV9cDBkVKwh/eQDxMKGPR6E75Ux2U3M1Orcht+mqK hrA6R9u/CzfgkDI19MK+VQurwA2Ac45mtv1el4pIuX8J2mmtYfJhs/nA/XQz03zcPevB +pyJBO0C1q98i5PysTvRPLJKRdZYwpEErpsXenxgsbK2b7/mp0bjHtk80lVFA8Bljuos uruCKP3Hab6y/1Dn2JOG2p164eAvdp3PSYiu0WslJvDl7AR3qD85ZhZ4SkEEmnueokZ1 3npuzhzLjtSAzLEVawLXnUBcJwtopY74LcxdiqO1OuR7HOwokgdSgXBVbRdCtahoy3C5 j8hw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=mUjKyMn7; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-160036-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 4-20020a631744000000b005cf268638f4si14623812pgx.156.2024.04.26.06.13.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 06:13:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160036-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=mUjKyMn7; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-160036-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160036-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 519152841BA for ; Fri, 26 Apr 2024 13:13:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E96C61487E1; Fri, 26 Apr 2024 13:12:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="mUjKyMn7" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8190F146D69; Fri, 26 Apr 2024 13:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714137169; cv=none; b=dc8L3JGM5HEXRyFHG3C6MSbSzXK7eF4JaH9NKKnEyckgxHLKz6v3vMIerUqetETBJr9N3X5CFQLdLtfqB6zu3SncUvx+Lx6AByCwLq/PYiLmVdOgNNBjIFcWDkVsmg6IQOZGQqe+DkYJMGI7zv+eMtBSIKMY5XJRH5/0+KZDHv0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714137169; c=relaxed/simple; bh=71RwQwi9TFTUPNDyPLmoKi09b5OBg6kwngITmrLKZ2Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=aOmLgGoV2vn4ui6UJox/ws8MkgJsJrvXTbmvCDIlHk+b0tAiqITFf7CvAixDNpvRzbyYklLECjXajlAR66n3PrLuZPnfyEvkow+brdeAuu+p3Z/sC63z9raV8G7DsJS84PQR4qVgkkeJB4h5gKOkznEOe/4exYMTX4u0RiHZfgI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=mUjKyMn7; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 39D7C210EF29; Fri, 26 Apr 2024 06:12:46 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 39D7C210EF29 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1714137166; bh=HfSrTbBlObJZ5QgMLDom1PtUczMN227beKLXYqpagmc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mUjKyMn7qOr7/Q+0ayG2nOy7nleg3db2XX5+gBFcQ7+i0kyuntO8WfMloWqgy0vtN Ad/7NFleTrYKOvmaKR/OLa3pI1P+gyXL4KsBpfpwgTR16MdV3VIr55WQ+miwQOhtQI sv698RBGFXQ18nymwLF+//vM7ol27Rs8cqLeqTjk= From: Konstantin Taranov To: kotaranov@microsoft.com, sharmaajay@microsoft.com, longli@microsoft.com, jgg@ziepe.ca, leon@kernel.org Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH rdma-next v2 4/5] RDMA/mana_ib: boundary check before installing cq callbacks Date: Fri, 26 Apr 2024 06:12:39 -0700 Message-Id: <1714137160-5222-5-git-send-email-kotaranov@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1714137160-5222-1-git-send-email-kotaranov@linux.microsoft.com> References: <1714137160-5222-1-git-send-email-kotaranov@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Konstantin Taranov Add a boundary check inside mana_ib_install_cq_cb to prevent index overflow. Fixes: 2a31c5a7e0d8 ("RDMA/mana_ib: Introduce mana_ib_install_cq_cb helper function") Signed-off-by: Konstantin Taranov Reviewed-by: Long Li --- drivers/infiniband/hw/mana/cq.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/hw/mana/cq.c b/drivers/infiniband/hw/mana/cq.c index 298e8f1..688ffe6 100644 --- a/drivers/infiniband/hw/mana/cq.c +++ b/drivers/infiniband/hw/mana/cq.c @@ -70,6 +70,8 @@ int mana_ib_install_cq_cb(struct mana_ib_dev *mdev, struct mana_ib_cq *cq) struct gdma_context *gc = mdev_to_gc(mdev); struct gdma_queue *gdma_cq; + if (cq->queue.id >= gc->max_num_cqs) + return -EINVAL; /* Create CQ table entry */ WARN_ON(gc->cq_table[cq->queue.id]); gdma_cq = kzalloc(sizeof(*gdma_cq), GFP_KERNEL); -- 2.43.0