Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp153433pxb; Thu, 2 Sep 2021 22:11:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwQO16V+uPpHulXXJTkW8PmArKUXIELiqsck5WRVQ/xT3wcMmJ+Ith/xb2eTlQPCaIKfLc9 X-Received: by 2002:a6b:3c16:: with SMTP id k22mr1680561iob.130.1630645909486; Thu, 02 Sep 2021 22:11:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630645909; cv=none; d=google.com; s=arc-20160816; b=EqLR49qp1vzMqfai26fXwcqNyAY55nn6Zj/tkWavm8G8c15bX2uZ9f2L5W5FjFLEsR 2fiegolWijDroagkLVkQfll/yNhXRtIa9Cm9FKsOBX61kHlNDSxY4Q/fXGQVh0Lo1ycS ocV5MMuz+CKDCtGWhMuHh4hlhJB035ANrYXJXPJVvegWVuWA46ilKwVpDHin3Jck67i4 WLp+T9x3ltd8QQbwAFVgyIQeLyUXvHM+Q5zWncCHN4PO0h6QHhPoFcNTtQVoU25548Qm vTFy3+Y/+HvH4NOaQKwdApCg9cnLXxGdAwXlMXOCykioMV/T94zU0rAmEvrB+hJKUHyi Dg0w== 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=OJvdQPrTeeSIW2aKxp3H75/EFGJNAh2MQGun3kF8gc0=; b=FcrRp4ccSiQ4V2UschyahQrQ1ZLpaNrNVcLd4Xh5hensF4IHLNvHYUUhTALyb4Yrma 0qYRifM3sfG4aYpTMhapO6mHMmovODvkEXBUq1U2HmT9JPiihNHB+2FbfvufJjbPDzUB 3Q2Ged0wy5YlkT1nC70w4eZrP3TZSqTZE4fZZko7o3gGCKF557CAbAeICVcCLKvan06u BUexnGA0wuTFrYN9OlCBUKNDVfR9Nz82ikpYaICZbRdpnTyfdWnPqJ6TrxptmZk94IYT +ybQDQVOfuYKJU+HQHdUK9tsuemGHzgcjsiFHIWbp6ZxncfbAlQL/c37R+fwtl0EWVeX WsCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=W8GXkwjG; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y28si3778611iot.48.2021.09.02.22.11.37; Thu, 02 Sep 2021 22:11:49 -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=@infradead.org header.s=casper.20170209 header.b=W8GXkwjG; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232002AbhICEkT (ORCPT + 99 others); Fri, 3 Sep 2021 00:40:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbhICEkS (ORCPT ); Fri, 3 Sep 2021 00:40:18 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DDC4C061575; Thu, 2 Sep 2021 21:39:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=OJvdQPrTeeSIW2aKxp3H75/EFGJNAh2MQGun3kF8gc0=; b=W8GXkwjGUGrcZ0YktI/byhySfl Z/jry2yBMifvlxl8QXdmc5ZxMkmCBf+Wy5K0VlaE+Y3/MCNtf7XO0YM427IX3v106SfIUKXo9axJT pSn8U7K6glCI4oxHqxGT5pmbDqy+atR2geCfAEwW956s1uu0Evh6ttbocHqN5/3mGJkfDe3qnAyCF 3tItNaKTVzk3rGFY/TtJrXCfmak8tMMv+faduqTXcbz4SmZHxgd55FIAWF1Vec6fp+0ANlwO064TV OScCOndgwmf8H39+bZ4wVbJ3yxqBuGu7d0CjbsgiU3BkL/4wzfgzO8sK6kMyQA6bUXWG9tRzgG47F cEeBGBzw==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mM0yI-0047Vt-Ps; Fri, 03 Sep 2021 04:38:47 +0000 Date: Fri, 3 Sep 2021 05:38:34 +0100 From: Christoph Hellwig To: Christian L?hle Cc: "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "martin.petersen@oracle.com" , "jejb@linux.ibm.com" , "stable@vger.kernel.org" Subject: Re: [PATCH] sd: sd_open: prevent device removal during sd_open Message-ID: References: <98bfca4cbaa24462994bcb533d365414@hyperstone.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <98bfca4cbaa24462994bcb533d365414@hyperstone.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 02, 2021 at 01:57:13PM +0000, Christian L?hle wrote: > sd and parent devices must not be removed as sd_open checks for events > > sd_need_revalidate and sd_revalidate_disk traverse the device path > to check for event changes. If during this, e.g. the scsi host is being > removed and its resources freed, this traversal crashes. > Locking with scan_mutex for just a scsi disk open may seem blunt, but there > does not seem to be a more granular option. Also opening /dev/sdX directly > happens rarely enough that this shouldn't cause any issues. Can you please root cause how the device could not be valid, as that should not happen? > > The issue occurred on an older kernel with the following trace: > stack segment: 0000 [#1] PREEMPT SMP PTI > CPU: 1 PID: 121457 Comm: python3 Not tainted 4.14.238hyLinux #1 .. preferably with a current mainline kernel as things changed a lot in this area.