Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1876087pxb; Mon, 13 Sep 2021 07:22:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvtrM0DuouefGuYiRe/ugcG2I/AayHuHBzH7cuwQLW3aKnwrB4USRw4AdwaQ4Oh7ABMqq4 X-Received: by 2002:a02:2b01:: with SMTP id h1mr10209374jaa.133.1631542927468; Mon, 13 Sep 2021 07:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631542927; cv=none; d=google.com; s=arc-20160816; b=eNa6opUQNdc2Ai2Rv0lykWetKM5OKfArDcUiJf5d/sAHd91mT4GcREH/F+D5ksbF7u 2ZZwZQVhL4RLDa68O3u84TA1GZFckR2vmI0x9WL5oaNlttavB1mP/inci8HDA9RR1pMW 22o13Vrnqo5QF13CjJ/FgCS4P1akSSBrL0c3OQ62hw63M4hGM4wZri4ct/+qGpuumUK2 Sy7zxHfOVtX5rf3YPJFJ7aqjpzrEnA27O9g1fxnFvC4nvL8DAVPNoc9kpAb/mWGSxiNQ XcULt1al2zbSxV+CL/+XKk5XCzmk6SOCR/81JpMSStmztxURdGkFrYU1SdtwRrZH3K2M +wrQ== 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=wpv38698XLU84upCt3l5OS+NeZO/YpfJPmdtoORzcdw=; b=nTP4PFMv5FmNXO2dibY4Uozdzskbq0GNdJ2RzYSLgDtRGBxjBitnb+IVCzO8IB0Ink IBzew7vrWEJld4QSDvFo28CTiwcwmN+26GA0NogKUsS4LkYzPE2CO0OiT6/F1bToTKuI oc1QKpIYK8d67tJEZHqaeQ+N4vt77bsDaB62PRVLCBL4b0zvvT/dRrSJ3lZPFWchpsin vm0YZ1KN9N7w87jZbrjkFj13On4B5/LhnAYltYgF0cTBnI9guQznPiPoH5fjJQH5Zac6 PpnCDLAcpigB2wqQriGhaCoMaZ/FFpUp5I+jk0/R3qck6ZKCikEG5vKs1uoPrnHlS+ha 5qYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="aSi/i23c"; 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 a3si6696275ioc.79.2021.09.13.07.21.54; Mon, 13 Sep 2021 07:22:07 -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="aSi/i23c"; 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 S1344289AbhIMOVJ (ORCPT + 99 others); Mon, 13 Sep 2021 10:21:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:40122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343617AbhIMORM (ORCPT ); Mon, 13 Sep 2021 10:17:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 03BD161505; Mon, 13 Sep 2021 13:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540698; bh=BKAMv4qCwoIHZLJss/UEAte4OVck1eTxLt8vzO6ndA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aSi/i23c6BXMQdihftrNFFjBdMLcesL59Wu5oF3fbg4mmO9u+0DOH1URRJo/6AUql OaUphVNmxiggAg/62y5plDiUFjA3H74aMKp+ORigM8fh4uZhFW08SXSbImCtCmouv1 qZCbS4afgiyZp0FDVOvbOYzKVtjIbycAscQLSzBM= 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.13 298/300] RDMA/mlx5: Fix number of allocated XLT entries Date: Mon, 13 Sep 2021 15:15:59 +0200 Message-Id: <20210913131119.433584265@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@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 @@ -1022,7 +1022,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)