Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3086387rwb; Mon, 15 Aug 2022 17:47:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR7eabVpMPoabcN83xQ7NmYGx36evCbFgZEw3r6AwM2Hsj86qe5SoXmu2iM3hh36F7qiHJQj X-Received: by 2002:a05:6402:27d3:b0:43e:5490:27ca with SMTP id c19-20020a05640227d300b0043e549027camr17244659ede.307.1660610870917; Mon, 15 Aug 2022 17:47:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610870; cv=none; d=google.com; s=arc-20160816; b=D4qSxnwqswbv4ZK41BNPDixM5Kc5VutUGJIpPvll5VIUEJMHXRy0CIZ2h85s2gPMfQ BoDM7QJFlLmN0853kdgpXskFhUPB3vUhvKUbw6CNhggb6bslbclf4EZrQbi5tI4A67+r zAIJS8iBPp1DP80EpnGJwXqrRQfVkOlV/Ire9ufGFGAyDBf4N4Kz76q9YSQv4ngKKihW 4/YVRaYECFpc4rKyKavDH+9SNS8XR0k8/RNJFGWjK8hgV1VaEOX/AMcgOzn6JiryayDE lPPxbM41fgBylc1k46ZslAh7D4l1n1+2VBWMwNbBfXrC28ST8tA2yLBtv6dCuU/OOVhC bWHw== 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=trBmFjV8dfhT8/pHoGhANsDhuy0KozMpiRGu9LkIUJE=; b=bF7bpn2usqNY6gOP0+uRhmVb5jBEyl2vjMYLnL1buKOMxXGnr4UxlTCyKts0eeR01J h9dgmtWYHPxARu/t9VEv7r0+WyK9u+19ZiaakrvZSDGZszhUzPJQJU8AFxFu/bQs0UrK rZxKmp93FZ/IXudmFIUcebpmCTs11oAV4w/+TsMf5NCd5xe+J81g8fRzV5itzl3R/0Zq jOWoMns5NY6SpLq3WnnI4ESuEwJ1DmetVV4xFm7tfrCmsWUg/UWl1p6V8s2qBLU/cBk/ OeIZc2uxu2BaQ/BB4XTeAM5ORQ/ce6x+0MXbW8Wmvf1dO3Wbdm8OZrVS2Qp0L10yI+jf EvhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lmpYsKKs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dd5-20020a1709069b8500b00734e75c49fbsi8066052ejc.204.2022.08.15.17.47.25; Mon, 15 Aug 2022 17:47:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lmpYsKKs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1352914AbiHPAYU (ORCPT + 99 others); Mon, 15 Aug 2022 20:24:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357140AbiHPAW3 (ORCPT ); Mon, 15 Aug 2022 20:22:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B18917CF9C; Mon, 15 Aug 2022 13:34:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5B423B811A0; Mon, 15 Aug 2022 20:33:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A093DC433D6; Mon, 15 Aug 2022 20:33:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595615; bh=BLxZlwgA6bUXBn40afykVCkJe/OvnRwH2/iMn++bFMM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lmpYsKKsifexlCDkUjAslQpJxvJz+BMrqup+GFzuJblM2wKZtTrKvIPOpcyO0MptT Lp90kl/IUseXhf5gQOStMJ5wNwEldV/xoW3SKsq8ydH1ZX+iPWPTy7paozxLo0Y9uB xqJCnNwBWnhvFoBuhcorrOisMWxl+PKjMu8kEqh8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bartosz Sobczak , Mustafa Ismail , Shiraz Saleem , Leon Romanovsky , Sasha Levin Subject: [PATCH 5.19 0820/1157] RDMA/irdma: Fix a window for use-after-free Date: Mon, 15 Aug 2022 20:02:56 +0200 Message-Id: <20220815180512.289849388@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mustafa Ismail [ Upstream commit 8ecef7890b3aea78c8bbb501a4b5b8134367b821 ] During a destroy CQ an interrupt may cause processing of a CQE after CQ resources are freed by irdma_cq_free_rsrc(). Fix this by moving the call to irdma_cq_free_rsrc() after the irdma_sc_cleanup_ceqes(), which is called under the cq_lock. Fixes: b48c24c2d710 ("RDMA/irdma: Implement device supported verb APIs") Link: https://lore.kernel.org/r/20220705230815.265-6-shiraz.saleem@intel.com Signed-off-by: Bartosz Sobczak Signed-off-by: Mustafa Ismail Signed-off-by: Shiraz Saleem Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/hw/irdma/verbs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/hw/irdma/verbs.c b/drivers/infiniband/hw/irdma/verbs.c index 96135a228f26..227a799385d1 100644 --- a/drivers/infiniband/hw/irdma/verbs.c +++ b/drivers/infiniband/hw/irdma/verbs.c @@ -1776,11 +1776,11 @@ static int irdma_destroy_cq(struct ib_cq *ib_cq, struct ib_udata *udata) spin_unlock_irqrestore(&iwcq->lock, flags); irdma_cq_wq_destroy(iwdev->rf, cq); - irdma_cq_free_rsrc(iwdev->rf, iwcq); spin_lock_irqsave(&iwceq->ce_lock, flags); irdma_sc_cleanup_ceqes(cq, ceq); spin_unlock_irqrestore(&iwceq->ce_lock, flags); + irdma_cq_free_rsrc(iwdev->rf, iwcq); return 0; } -- 2.35.1