Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3140765pxb; Mon, 18 Apr 2022 17:05:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrBvAs76VmdzWhs8MBe4pj931ssZnKwWNVGlhVk+7kPWOrW2yWI9ujW2EP4o/JldJPXhuO X-Received: by 2002:a17:90a:e7ca:b0:1d1:22ce:86c3 with SMTP id kb10-20020a17090ae7ca00b001d122ce86c3mr18647874pjb.10.1650326724155; Mon, 18 Apr 2022 17:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650326724; cv=none; d=google.com; s=arc-20160816; b=qCpXNXovNDpIb9Y8MTukxBuFyU3Fk1QteDGbkQkXmfZOAmJqBEVeo2RTlC6JFksppX H/PhiMpDqJWHiq7jLYFafmu6QcO57eg8EUSzVlFYQVBeHVCYqU1dVIXKCeWhp074gvNp 1GAd1Up5mau/eZQtg/SYoZTbEfCJacf5+zUE647IHyEHjDNIvS+V2+tWFbXnq6ZMQ2h6 4FyRzMwbZWzvN/0gdikr/OFhCuXYUbrE6IxLI4ljJ2/+TRQqZoL3QfxHK3vU2bupz21L WUhrKxLFVikz1Sk9nmalGbpsmRQQdD7rbjIOzr9d7jWaEeiXLLfYmdutNvQsvAESZ2O/ kKrg== 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=VuvawG8a1tEFAXcWTEOZmn8XXA70dgm0mZ0MHEqrL78=; b=qUKc0gqxkJjjZe5Qte1T/O0DBp9rnycuFWzJj9Gcw62X9ozf55OaxQ/zAQS8tT+SUq h25OzFH3yA6yjVwcEvU0h+AtOEunmb4VeinkmyLxT4WAKhQiZEvfSo+lWYa0B/mXY2h1 7u0XyfpnfOgZNULfK4Dv5LIRRUtl7T6UGxr1Z2t2f/IYJmoKwHMn5izKBrGWIUG/4fzv KIuq48oOl8U6ke3vlwuYw6lq4xfuWodxOcbNEBOgViII+OZbzfIgS/PNg0964d5qQBy5 JiNxR7t1ao+PA/DFtErHDS/yhQwADxm/SAsUxKtOYoLBRHhDZyVS5SeLgDXXv7BGO1XJ DtCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WoZ+OlTG; 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 t35-20020a056a0013a300b0050a6c1711d7si5529525pfg.336.2022.04.18.17.05.08; Mon, 18 Apr 2022 17:05:24 -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=WoZ+OlTG; 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 S244487AbiDROAI (ORCPT + 99 others); Mon, 18 Apr 2022 10:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244117AbiDRNi4 (ORCPT ); Mon, 18 Apr 2022 09:38:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7032E28998; Mon, 18 Apr 2022 05:58:36 -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 dfw.source.kernel.org (Postfix) with ESMTPS id EA7C0612CF; Mon, 18 Apr 2022 12:58:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA47FC385A1; Mon, 18 Apr 2022 12:58:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286715; bh=AWYy8rOKJFVWVVwDVHX+muVJcjQmAIjXRPSJZ4HgY6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WoZ+OlTGB51hbSDn1b2X+TKwO9xwkdc3pSdV5Oz/kELyonKifxBm2qR/iAvUkQzW5 XosuOgLBOcweqhwJV+/44Dj0B1vgMvsV81NTqZW8/SMxOl+wkb0tVZFge4j0BEWqrE FftV0OzzaIZ+qgmuFpEKN3+Rz7O+c3CTvvYFs/lg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hannes Reinecke , Jianglei Nie , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.14 223/284] scsi: libfc: Fix use after free in fc_exch_abts_resp() Date: Mon, 18 Apr 2022 14:13:24 +0200 Message-Id: <20220418121218.052827139@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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: Jianglei Nie [ Upstream commit 271add11994ba1a334859069367e04d2be2ebdd4 ] fc_exch_release(ep) will decrease the ep's reference count. When the reference count reaches zero, it is freed. But ep is still used in the following code, which will lead to a use after free. Return after the fc_exch_release() call to avoid use after free. Link: https://lore.kernel.org/r/20220303015115.459778-1-niejianglei2021@163.com Reviewed-by: Hannes Reinecke Signed-off-by: Jianglei Nie Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/libfc/fc_exch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c index 384458d1f73c..9fa0aa235cb4 100644 --- a/drivers/scsi/libfc/fc_exch.c +++ b/drivers/scsi/libfc/fc_exch.c @@ -1709,6 +1709,7 @@ static void fc_exch_abts_resp(struct fc_exch *ep, struct fc_frame *fp) if (cancel_delayed_work_sync(&ep->timeout_work)) { FC_EXCH_DBG(ep, "Exchange timer canceled due to ABTS response\n"); fc_exch_release(ep); /* release from pending timer hold */ + return; } spin_lock_bh(&ep->ex_lock); -- 2.35.1