Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp4310550pxb; Tue, 19 Apr 2022 23:44:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuDofE27DWd/bj3kfIqhr/I1vUx7UeGQ5HsybDkPHu3bfBj9PoxisledvYZlKAIPHZvW5T X-Received: by 2002:a05:6a00:1146:b0:4c9:ede0:725a with SMTP id b6-20020a056a00114600b004c9ede0725amr21967370pfm.35.1650437070571; Tue, 19 Apr 2022 23:44:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650437070; cv=none; d=google.com; s=arc-20160816; b=NzlZWP5jrxhyU/89mdTL353mIPvDPKEAP3m0LFTb2UcYJxEWWlOFLJvyslg1N68d0b rdRcA8i9zarNwN/3Ax80wTv3uvt4gRVz/LOC4XaKQmDMPvUxVyQ2d14A+Sz8S9gLcgT8 rv7HxeBXwgktl2hC1JQfCoY1kiNxp4SAASn8Z2fa/ImoCJcaASNS/yJfK2HKUgH1jOjg Mfn0+BNUwaO+04+YoXgEfL0hYRqDUwtK8UuIEY739zQQznQ64nlBZvHaVPBuaFKmaJXg Gfl8JN/H2OcUBHaqk3Mks2ahInmMsBnNx4uVovoVOHcUdFft9QKamQIp1DINjOBAxtqE FOOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject:from :content-language:user-agent:mime-version:date:message-id; bh=ZXxBIkXWIukLHyeIBJTVqZ9PuqSB2s3d3TyNKqV2iX0=; b=eHjisL6Q+6T5BgJ7VeOZMR9NIWkg55CNNcLoMP2BsKXGyfjnlSMRlpa2efO9rRw2Yp zUVJauRjA/I84py4GdpiBRpM21K7rA9X9uxVhXTSRykpX9/ttx5X8SqladN+AgCU9KWM rs6Xn2/uHUnsmxU6YehUS9TEFHZwXyTube3kH6G7Aptxc0TeJo5uDZKG4DTeI5acTcLk qmmCaVfNWbJIinf61PfwlkajH+3kNoFi8ldtNrfZZZsGvNAobQnYb+WkTFjApwSaP3N0 vvY91rjbTwZvf0wRlCKEHeIBG5uC/+z3wjaEImaGoKniqhnqOU1vp00RlSDJapxVyz+M Hp4w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gz7-20020a17090b0ec700b001bd14e01fbesi4093813pjb.172.2022.04.19.23.44.15; Tue, 19 Apr 2022 23:44:30 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351709AbiDSOa5 (ORCPT + 99 others); Tue, 19 Apr 2022 10:30:57 -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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 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.