Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1904197pxb; Mon, 13 Sep 2021 07:53:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzscWAmzZZwARqdObeQwwt5jCYs4fVX95JdS1pYes+lwdwCouWLpqMxGtlEwPwYmiLEDkg0 X-Received: by 2002:a05:6402:2156:: with SMTP id bq22mr1143837edb.49.1631544797497; Mon, 13 Sep 2021 07:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631544797; cv=none; d=google.com; s=arc-20160816; b=MW7rYnYr1yjhqjG2yzFpvD6JEwvVQ9/CQjjBR/lN87HsqV6tQJtG6aQKtjbiti43p2 r7v8VRonk1SyDTTKfOZ+h1gjV+68EjoI1EbsODrBc19SzT2FOi2g2ouudz9qSnhfeupk yRdGNNMYy6/UNr2uchqnBDizgiVfR8HP0/EFMISebDyDNe3QTaPqb8oXl2uNmFR2xuRM jBjIgz04ms/Aj4Q+ydwZ+ew4vuLqeFR/sjVHyMPQn5aWIqNKYDyN2aA/QwoG28rNLQrw C2lIXCrx9bLsrHylpomtA7GCvr3WpGX0UqFcmxe3sdJ3eFeC6ZKiHXbXMSEoTQE1rHaQ 0eMg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LUGX9WEAIVsotEX54B78Ysbp8PrUfdmoJd+ZnCT44k0=; b=CoB3QaSToulzV0sipuu+P0VJz9sXJbMDh3raSKh40OSmHMF10zpo4PkA9U+SdZRU4M XkKy2aXfGZxgTebskkgdjqsVstCOS/9gYwBDqSkNP8vldo9U/YCIZ+N+k57oE/xAAMef vjQWSN9trvrOidyWASAe7Dts5OM1qDMdUn1mZiXI4nw1BQVrz8ZAOiJHt0pRLe4qJQSf k5kOkR7j8f1pITRg6czcxJfd2QZ9p9KhqKy7+9umHShzMxitvNl6n74wmQtBxvVJR2Cf 6ZP0jWqR6nfVXSJ6yg2vU9+9xsAs3S+bxjF6CSwPRBFNRu8FmiGnwASMEuW6vQkVfFmQ k5tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r3SaT1qC; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x43si7308854edy.609.2021.09.13.07.52.53; Mon, 13 Sep 2021 07:53:17 -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=@linuxfoundation.org header.s=korg header.b=r3SaT1qC; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347056AbhIMOv2 (ORCPT + 99 others); Mon, 13 Sep 2021 10:51:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:60772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346242AbhIMOqJ (ORCPT ); Mon, 13 Sep 2021 10:46:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 21D7D619F7; Mon, 13 Sep 2021 13:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631541522; bh=E76jz9xtCITBjMUUX/IkyAHuxytwZerqTnSflWPpseQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r3SaT1qCg1y/+Mr8jFbMNaxb5mFGEOu2WTrguZsn7Cv5tN7udp5vpcCYWtuWaJwhJ 6ob+nzJPWe8R5n5+vuTarVaF/HHlkbuZTTdkVtuqxnn/ouprAPrXBNBpQae56EKWK7 8h2riA0c1Flv+QZLXN8QE40jrGDyCmKj88R74ZBA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niklas Schnelle , Jason Gunthorpe Subject: [PATCH 5.14 330/334] RDMA/mlx5: Fix number of allocated XLT entries Date: Mon, 13 Sep 2021 15:16:24 +0200 Message-Id: <20210913131124.597356914@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131113.390368911@linuxfoundation.org> References: <20210913131113.390368911@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Niklas Schnelle commit 9660dcbe0d9186976917c94bce4e69dbd8d7a974 upstream. In commit 8010d74b9965b ("RDMA/mlx5: Split the WR setup out of mlx5_ib_update_xlt()") the allocation logic was split out of mlx5_ib_update_xlt() and the logic was changed to enable better OOM handling. Sadly this change introduced a miscalculation of the number of entries that were actually allocated when under memory pressure where it can actually become 0 which on s390 lets dma_map_single() fail. It can also lead to corruption of the free pages list when the wrong number of entries is used in the calculation of sg->length which is used as argument for free_pages(). Fix this by using the allocation size instead of misusing get_order(size). Cc: stable@vger.kernel.org Fixes: 8010d74b9965 ("RDMA/mlx5: Split the WR setup out of mlx5_ib_update_xlt()") Link: https://lore.kernel.org/r/20210908081849.7948-1-schnelle@linux.ibm.com Signed-off-by: Niklas Schnelle Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/mlx5/mr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -1024,7 +1024,7 @@ static void *mlx5_ib_alloc_xlt(size_t *n if (size > MLX5_SPARE_UMR_CHUNK) { size = MLX5_SPARE_UMR_CHUNK; - *nents = get_order(size) / ent_size; + *nents = size / ent_size; res = (void *)__get_free_pages(gfp_mask | __GFP_NOWARN, get_order(size)); if (res)