From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7ECD5C433F5 for ; Tue, 19 Apr 2022 14:28:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243343AbiDSOa7 (ORCPT ); Tue, 19 Apr 2022 10:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348414AbiDSOax (ORCPT ); Tue, 19 Apr 2022 10:30:53 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 281582F3AB; Tue, 19 Apr 2022 07:28:10 -0700 (PDT) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KjR302wBDzfYyv; Tue, 19 Apr 2022 22:27:24 +0800 (CST) Received: from dggpemm500017.china.huawei.com (7.185.36.178) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 19 Apr 2022 22:28:08 +0800 Received: from [10.174.178.220] (10.174.178.220) by dggpemm500017.china.huawei.com (7.185.36.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 19 Apr 2022 22:28:08 +0800 Message-ID: <6301e87f-15f6-4c1f-41f5-d2f1aa4eedd7@huawei.com> Date: Tue, 19 Apr 2022 22:28:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Content-Language: en-US From: Wenchao Hao Subject: [Question] SCSI_EH: How does EH guarantee there is no UAF of scsi_cmnd if host reset failed To: Hannes Reinecke , "James E.J. Bottomley" , "Martin K. Petersen" , , "linux-kernel@vger.kernel.org" CC: Feilong Lin Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.220] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500017.china.huawei.com (7.185.36.178) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi all, I am wondered how does SCSI EH guarantee there is no UAF of scsi_cmnd if host reset failed. If host reset failed and eh_cmd_q of shost is not empty, these command in eh_cmd_q would be added to done_q in scsi_eh_offline_sdevs() and finished by scsi_eh_flush_done_q(). So these scsi_cmnd and it's related request would be freed. While since host reset failed, we can not guarantee the LLDDs has cleared all references to these commands in eh_cmd_q. Is there any possibility that the LLDDs reference to these commands? If this happened, then a using after free issue would occur. Waiting for your response.