Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6651275iob; Wed, 11 May 2022 02:17:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfvACG4bjRV1nwNvLgdk96T4nc0VKRlxxCAx7Mpw+w/uvkeSA1OR4fio9Hh24U/g/RmjFn X-Received: by 2002:a63:e549:0:b0:3c6:d87:d3ef with SMTP id z9-20020a63e549000000b003c60d87d3efmr20275242pgj.111.1652260661406; Wed, 11 May 2022 02:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652260661; cv=none; d=google.com; s=arc-20160816; b=ov1nfY6AuTX0WPhxb+jXHk4RZncNooH5Bw0LwQKuD61WwYSiIRqlgPQ0TV9IPtA1se fHTM9CCy4u+oyE+4LbKXcVQz+auKDl1dvYHRYPCgacAUe/Nhs3SEIEh3rsc3drZE30O6 lpsIrGPe8PpujYZ5+ZZPaGVQ0jlZaGyiLOqr3s5RvpTNmqUzefWZRYUM0JSf++JxvBcO 02JLFfs8eRzIoq86LAFWr2FNFbje4MubDKeI6u5tWQ/XzhUHVPMg8MC+XNeJSMWX2T0H 5N+OZ2n5yKGDdepj7fi0Zc3mCpss83Qi0uYzTQ9wAshYEcpWhha+V8lG5curtaKr3oRK J6ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=v6LTVQjeDFrw6vdK4w8luloTEFL+fsitDmR6W5fFJig=; b=xt6qhJxpHUjbcfKwycex/Z5BMAHfPlRD7mqJgA2C/idAaekvtlLorsdpiMzg4uCxc3 jvVpYyib4rO8LZdz69Q7uNbjvC7rFK3Sfb6uRHGXBw+NQJ5lMrcVenelYrSJkVMvouhh A+TXI8VFYsZdqUrEkDNOJ144MRT9/9WnJ5xaIFAqaTnG5SDpkn7YKdpHwoXKYzuPJDBL zNf1pyIuKo9C70WHk6RCXpmLoUAgMuX0ORp4cPNXF2719WKyGI44pmij1IxWGBK9ucH7 QZzUHwiW3NXU3rZTsDp9LgGcfcuYVPNk8E9vH+vwTDC5LHQVq9foS4oCejWyMh8yS27f keMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=IZ8CZmlP; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mt13-20020a17090b230d00b001dd177af7fcsi5030029pjb.182.2022.05.11.02.17.26; Wed, 11 May 2022 02:17:41 -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=@infradead.org header.s=bombadil.20210309 header.b=IZ8CZmlP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243828AbiEKIdQ (ORCPT + 99 others); Wed, 11 May 2022 04:33:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243779AbiEKIbw (ORCPT ); Wed, 11 May 2022 04:31:52 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D14273190F; Wed, 11 May 2022 01:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=v6LTVQjeDFrw6vdK4w8luloTEFL+fsitDmR6W5fFJig=; b=IZ8CZmlPJlqOJneX1ygZtZH9XC 3O4wLrlBJTUiSsQ7Wn4piNtq66RatOWmjhgxOKeLdSi/UU/ygJU2swRImRifc+taFT25hqRbjQX4Z oWxPzaMZOEUW6AYTlQ5v+wNTWmgeUfQvPh6nyxty8+fhr7S5FCw7n5qtRCWwtHpWC1mXbm/HwSjld ODjjNirmL4WaUSW+odUmMSpD2S3wa+stlWW94jiP+O6lgW0ixEbsQ8p2YgPFaCPIwwNSVSpmgkqV1 ox4chKK7R/t5IycO3qu+lPIw1m+Opdn73RKY2cRGTuOMnM4qOIMqFuGnMMdE8ruXVY/iJdsxH+/kb 9ytKpZlQ==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nohku-005xEt-Te; Wed, 11 May 2022 08:31:36 +0000 Date: Wed, 11 May 2022 01:31:36 -0700 From: Christoph Hellwig To: John Garry Cc: Krzysztof Kozlowski , Christoph Hellwig , "Ewan D. Milne" , "James E.J. Bottomley" , "Martin K. Petersen" , Alim Akhtar , Avri Altman , Doug Gilbert , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, james.smart@broadcom.com Subject: Re: [PATCH 1/4] scsi: core: constify pointer to scsi_host_template Message-ID: References: <24bfb681-faec-3567-3089-9cd5ee182710@linaro.org> <1bb53912-c5c3-7690-e82f-cf356ca87404@huawei.com> <6f28acde-2177-0bc7-b06d-c704153489c0@linaro.org> <4510c5dc-3d7d-fc5f-cb80-34da7dbaaa8e@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Mon, May 09, 2022 at 03:50:33PM +0100, John Garry wrote: > If you check scsi_device_dev_release(), we try to do a 'get' - if it fails, > then we nullify hostt->module. I think that is important as then we call > execute_in_process_context(), whose worker does the 'put'. However, the > 'put' will get upset if the refcnt was 0, which it would be if the earlier > 'get' fails - hence the nullify is to avoid that possibility. So whatever > you do needs to handle that. Details are in f2b85040 Yikes, that code is completely and utterly buggy and does not account for all the cases why try_module_get can fail. I think we always have a reference here and could use __module_get, but what we have is certainly unsafe and a good reason why the host template should be constifyed.