Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp880301pxk; Thu, 17 Sep 2020 20:11:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQs/VSTLrbZcyRAMoV9SSsAtsi1P9np0HsYMOzCMRhFVLYBkC1Zmvy/Ge4o9EntIU4cUa9 X-Received: by 2002:a05:6402:8:: with SMTP id d8mr34750595edu.15.1600398676971; Thu, 17 Sep 2020 20:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398676; cv=none; d=google.com; s=arc-20160816; b=ZwbymwckxyvyriZMfO90hOOaKm1EYGeTccx14y+ijweIF6PgcsrTREH0kwOraGOi11 QhvDJyLzMZVCBaIJj89Ou9eo5Ai1Dz4hvbH1UPXfQe6PBSH74aMkylUPrWIxiz3yh1b9 rK+XlFgVR3xopovCzUQbeI23IA/iVCFBnUhOBHVnv6FkDRD6y1hAQs2rBCvhejgoFm3N ndJDn8TJXV7LFlvs7GiK0Ivll6+SUzACYEyPRCpPGL51PqZO0g5JFsZrzHKzXEUZYXAW Qw19Jr/bT5XcziCi53PW8GRs7J9QYyfNsUV5RFoQZV9Te9nfEDwFhdbCHsHHFbVkL/lO Ra8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6tSVVSnE83+ZN+0qiElEB83/cSJb19ddo9GduoY6SBM=; b=zVlSgjUGe1B7h+VZvGk3PN1P1uBbnh2nERnqAQDjSkYlmw9h5vYZqCXpVD1RRsqjen WB+ONNOzGzYedfqhb+dsxKvvVlgkTUyEyXOfsDH79iWg7LEJi02ZY4e6AuLE0GqAtdrX 5lu3y33NRGv0bskJLdXI9V8johS4N400p0WsTPoe2nKMFCQwPen5F4rHDaKDOtz/Ra90 KiSn7u7mMMf+gx5hgpWghQ1432R0ooR5QFreEgUvGJZQ6dsyl7fNRQMSiSplUJQ9N9is L1hVME0x0bxVl8WFbGd11wap1JBwZXDEBHhr0PrgZHmjcOq7PyU8I1+73/vK277GJ6iE AsGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dc1ygC6S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qx8si1308418ejb.175.2020.09.17.20.10.53; Thu, 17 Sep 2020 20:11:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Dc1ygC6S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728308AbgIRDGm (ORCPT + 99 others); Thu, 17 Sep 2020 23:06:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:50880 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727193AbgIRCEB (ORCPT ); Thu, 17 Sep 2020 22:04:01 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0525B2376F; Fri, 18 Sep 2020 02:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394633; bh=icekX+96jvpFDg2LzTwHzZf/G/6xaKhAV6pnlfsCQZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dc1ygC6SG/RpwhGMUVEAPz3gp7vbt3GGxiTkt73zGgJHR+tXB0P88glDx7QmxWzmc TYGZ2JcnmOTz1FhkJyfoFeFWkwz7OF5pjbMF5fFE1BkibT5Rwtb9XnQbkPez1iipu+ 9DhCF2L51iY4pq0cnnQYPjd20p3HSBKvF5xCq5+A= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Bart Van Assche , Leon Romanovsky , Jason Gunthorpe , Sasha Levin , linux-rdma@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 133/330] RDMA/rxe: Fix configuration of atomic queue pair attributes Date: Thu, 17 Sep 2020 21:57:53 -0400 Message-Id: <20200918020110.2063155-133-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bart Van Assche [ Upstream commit fb3063d31995cc4cf1d47a406bb61d6fb1b1d58d ] From the comment above the definition of the roundup_pow_of_two() macro: The result is undefined when n == 0. Hence only pass positive values to roundup_pow_of_two(). This patch fixes the following UBSAN complaint: UBSAN: Undefined behaviour in ./include/linux/log2.h:57:13 shift exponent 64 is too large for 64-bit type 'long unsigned int' Call Trace: dump_stack+0xa5/0xe6 ubsan_epilogue+0x9/0x26 __ubsan_handle_shift_out_of_bounds.cold+0x4c/0xf9 rxe_qp_from_attr.cold+0x37/0x5d [rdma_rxe] rxe_modify_qp+0x59/0x70 [rdma_rxe] _ib_modify_qp+0x5aa/0x7c0 [ib_core] ib_modify_qp+0x3b/0x50 [ib_core] cma_modify_qp_rtr+0x234/0x260 [rdma_cm] __rdma_accept+0x1a7/0x650 [rdma_cm] nvmet_rdma_cm_handler+0x1286/0x14cd [nvmet_rdma] cma_cm_event_handler+0x6b/0x330 [rdma_cm] cma_ib_req_handler+0xe60/0x22d0 [rdma_cm] cm_process_work+0x30/0x140 [ib_cm] cm_req_handler+0x11f4/0x1cd0 [ib_cm] cm_work_handler+0xb8/0x344e [ib_cm] process_one_work+0x569/0xb60 worker_thread+0x7a/0x5d0 kthread+0x1e6/0x210 ret_from_fork+0x24/0x30 Link: https://lore.kernel.org/r/20200217205714.26937-1-bvanassche@acm.org Fixes: 8700e3e7c485 ("Soft RoCE driver") Signed-off-by: Bart Van Assche Reviewed-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_qp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index e2c6d1cedf416..f85273883794b 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -592,15 +592,16 @@ int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask, int err; if (mask & IB_QP_MAX_QP_RD_ATOMIC) { - int max_rd_atomic = __roundup_pow_of_two(attr->max_rd_atomic); + int max_rd_atomic = attr->max_rd_atomic ? + roundup_pow_of_two(attr->max_rd_atomic) : 0; qp->attr.max_rd_atomic = max_rd_atomic; atomic_set(&qp->req.rd_atomic, max_rd_atomic); } if (mask & IB_QP_MAX_DEST_RD_ATOMIC) { - int max_dest_rd_atomic = - __roundup_pow_of_two(attr->max_dest_rd_atomic); + int max_dest_rd_atomic = attr->max_dest_rd_atomic ? + roundup_pow_of_two(attr->max_dest_rd_atomic) : 0; qp->attr.max_dest_rd_atomic = max_dest_rd_atomic; -- 2.25.1