Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1104630pxa; Thu, 20 Aug 2020 02:35:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfZ9r6Ov+3zfX0uqWy63AOaLNqcX6Ar3fyQQ9WgjEDAO+0yeSBR4rjCuASsis1eX8jtigp X-Received: by 2002:a17:907:42cd:: with SMTP id nz21mr2388022ejb.395.1597916121980; Thu, 20 Aug 2020 02:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597916121; cv=none; d=google.com; s=arc-20160816; b=s0dG98CiB1MNtGOXJMIYbjkk8X3FKsJTpMA3yUgratSnqCsTkvidldpqyj+yw18mwl v4jzzLwOAVyX0OcNpf6MpuQpQce/+ivgzeO6HFaB5PfNqcPJBjVSSYNQBh4WjHmBVZWv QIuZnMYqmYYhtbbU4ePe9FKW7S8uab2sSuUp6z9QouKWaGChS/gaWXhjW6khcPpB3zrO lPRZmBAtviOfHtKfJgBVuKxRuM3+2rGYKaYDGNfVlpT3SpY7SBwWwSgbd0jWHigNROoB ATbwSsPgKDUxIBQYrnnzdXvOO7ApbcdNDAwd1vZluPZj617tO7kTDu4PWHHn+QsgMFSO /9Ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VIoyvAJGZNKCyAXG3YtEXuVAq3XKnRqtCjP8vWYDfxw=; b=aFsIZjWGZTofMRKXjjJKkf3CXsFFwSFImSoReoe+ENaUSAfmJwjuMkgCaKQDZo8sA8 yFjCWYag3sCpIPHG55s3DYxK3JkeHPWoEEwZUb9yiav3d259MjbT3VxbwQAqVJDsYTZ1 Zfqct49mOmkw4RPU9PQeKhDjwJWGBCP0IZP4Kt6YXzOA+avqj/vWbgwZ7P0TQmiBhLaS xObhAyG/2OkF4oomXLCibEL0vJPz/sFTff3DnNqqe33d46zHxAvRlj0DrkhaXj/4D079 UwPe7T2Kr0iIUTUWZvgYsR1c6uEX8VBpxyCczIg2B76CU5DurdbD8vrOVL+VS50cP8Wc FfPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jYHl9dT+; 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=fail (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 ay17si977078ejb.345.2020.08.20.02.34.58; Thu, 20 Aug 2020 02:35:21 -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=jYHl9dT+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728208AbgHTJeQ (ORCPT + 99 others); Thu, 20 Aug 2020 05:34:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:44430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728063AbgHTJcI (ORCPT ); Thu, 20 Aug 2020 05:32:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 61A04207DE; Thu, 20 Aug 2020 09:32:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915927; bh=4fzfIvN+NcbSnlAg6+7Q33xB9C/POBwhAntdAp9XSBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jYHl9dT+tbx59+MQ2N5LxVaIw1RxzbH5s9hrIrxvwn7a6g+wMtfKJLbR/7W76BSYr gVG1AYtZzctKGBTk4Zr6Yfdhsmg3kHE1+xKfslKrUqmqWclBZq8aY4MfCL8HNkazs8 GDkL/TkI80EkIXXQ5q70nRa+bcPaEzfhJIHPhyZ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Smart , "Ewan D. Milne" , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.8 183/232] scsi: lpfc: nvmet: Avoid hang / use-after-free again when destroying targetport Date: Thu, 20 Aug 2020 11:20:34 +0200 Message-Id: <20200820091621.668630975@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ewan D. Milne [ Upstream commit af6de8c60fe9433afa73cea6fcccdccd98ad3e5e ] We cannot wait on a completion object in the lpfc_nvme_targetport structure in the _destroy_targetport() code path because the NVMe/fc transport will free that structure immediately after the .targetport_delete() callback. This results in a use-after-free, and a crash if slub_debug=FZPU is enabled. An earlier fix put put the completion on the stack, but commit 2a0fb340fcc8 ("scsi: lpfc: Correct localport timeout duration error") subsequently changed the code to reference the completion through a pointer in the object rather than the local stack variable. Fix this by using the stack variable directly. Link: https://lore.kernel.org/r/20200729231011.13240-1-emilne@redhat.com Fixes: 2a0fb340fcc8 ("scsi: lpfc: Correct localport timeout duration error") Reviewed-by: James Smart Signed-off-by: Ewan D. Milne Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc_nvmet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c index 88760416a8cbd..fcd9d4c2f1ee0 100644 --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c @@ -2112,7 +2112,7 @@ lpfc_nvmet_destroy_targetport(struct lpfc_hba *phba) } tgtp->tport_unreg_cmp = &tport_unreg_cmp; nvmet_fc_unregister_targetport(phba->targetport); - if (!wait_for_completion_timeout(tgtp->tport_unreg_cmp, + if (!wait_for_completion_timeout(&tport_unreg_cmp, msecs_to_jiffies(LPFC_NVMET_WAIT_TMO))) lpfc_printf_log(phba, KERN_ERR, LOG_NVME, "6179 Unreg targetport x%px timeout " -- 2.25.1