Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp4331910pxb; Wed, 20 Apr 2022 00:22:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8g/8kAhRrInkzXIWzjVdc2q+w24McPGe+Nf0J8col9kULODbT1gslQY/9GEFiI5aXGNc7 X-Received: by 2002:a17:902:b697:b0:151:4c2e:48be with SMTP id c23-20020a170902b69700b001514c2e48bemr18961555pls.70.1650439362894; Wed, 20 Apr 2022 00:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650439362; cv=none; d=google.com; s=arc-20160816; b=I8a3XYr9xSu2pGhBmNtaghKs6Q8BikaDriHJ2DU5Kb/4gYhAc3ZNs6sCa/WzmY2/QK aODFDwbtc1EznaXF7BO2pmtFK1TO02ieZTOzvDCaZgW84BNvEtbJAm+OPW+W6boKtrFg l0UsGTncytNkiPuMfA+ydHuShCN3vV1D9GH1fnSLqz4CI3NXNVETUajyYxyv7DOM6NOA Di+h5rSZvhOVxE08yadjHf9QQOvKh3+a6wAyFeF6OMQUO/xI0T59XhsTmk7Ki8N3T4Hq O/jPMqA6Q3hk3P0jRiqrrUfnJ8S/lunV+ISlLeDFdwYSdF8odZSv6W4DR4pZANEyQu/G KlTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=P0bHge+GMMYbznLePUUnvwkPwSt8s9dbZBlPzkfEDUk=; b=aAulAKqEbiMXXNyC9DCGvKGn+jcT6AOOb0CUF2ZZziotNPVlW6bey9VD/gnUiSRKef +qZ5AAv8llUAIqgzv//DGu4Nz90rQVfo0LwGHM9gQg899LI+6mfCZOZRc1R4t0oaSXRi UyCSn4GfwKKBHtObyMkODpl/Uc382QDS6LoAq8HAOWjB6hZspcTFF6MsM73awCQt0lHZ ySDtI2mCDdJxqSkW92G9/solsoU/es8HkXX54v8I0ns9QUcYaf4tXYAlPSuMI1BDQ4MG tagmpGsdQQN5BOfyHzx6JT8JlbnedqOwxYPo7ydWRl+PVdFVFH6ZOByk6fdNrpsG7jVe Pq1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=L4yhz0oz; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k7-20020a170902c40700b00158c6131014si1740002plk.518.2022.04.20.00.22.28; Wed, 20 Apr 2022 00:22:42 -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=@suse.de header.s=susede2_rsa header.b=L4yhz0oz; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241305AbiDSPAa (ORCPT + 99 others); Tue, 19 Apr 2022 11:00:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353584AbiDSO7s (ORCPT ); Tue, 19 Apr 2022 10:59:48 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1084C3298B; Tue, 19 Apr 2022 07:56:55 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C4809210DE; Tue, 19 Apr 2022 14:56:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1650380213; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P0bHge+GMMYbznLePUUnvwkPwSt8s9dbZBlPzkfEDUk=; b=L4yhz0ozTVo9fBukVYFThXvzy5umuiahsDQqOO5KbrWfq5gsjRz0HEbii/PP1EYy0+NVHo +kzZlDy7QDMnnQpVS8wsq2/i03B6XdcScoQjCYBJwd9k4/PgGcw0nAPcZ7Z/FSgGU/KoN/ QvctlGqEdKZ8ADjIErOfAz37jFuQOO0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1650380213; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P0bHge+GMMYbznLePUUnvwkPwSt8s9dbZBlPzkfEDUk=; b=Q6GawvPbP9nlR/fBI2mZjRUJRjMR3BYbxLuA40glIlT/hfcWPkHMNm4Qlo3E6e1+4FeL8l 2gv3oO9/w4AE3XDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8E148139BE; Tue, 19 Apr 2022 14:56:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KRf5IbXNXmIhLQAAMHmgww (envelope-from ); Tue, 19 Apr 2022 14:56:53 +0000 Message-ID: Date: Tue, 19 Apr 2022 16:56:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [Question] SCSI_EH: How does EH guarantee there is no UAF of scsi_cmnd if host reset failed Content-Language: en-US To: Wenchao Hao , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org, "linux-kernel@vger.kernel.org" Cc: Feilong Lin References: <6301e87f-15f6-4c1f-41f5-d2f1aa4eedd7@huawei.com> From: Hannes Reinecke In-Reply-To: <6301e87f-15f6-4c1f-41f5-d2f1aa4eedd7@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, 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 On 4/19/22 16:28, Wenchao Hao wrote: > 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. > Yes. > 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. > If host reset has failed there are _no_ assumptions we can make about commands, and not even about the PCI device itself. So in effect, once host_reset failed the system is hosed. We _might_ be able to resurrect the system by doing PCI EEH, but not many systems nor drivers implement that. Cheers, Hannes