Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp435793pxb; Fri, 3 Sep 2021 05:41:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyKmlGid7NNNa+7/ePCG3h/ZSFeyo6kHyMRhmOoUFwCOvSVoZIkNz+iatd5TBgdWA+TPrA X-Received: by 2002:a05:6e02:510:: with SMTP id d16mr2493790ils.13.1630672911753; Fri, 03 Sep 2021 05:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630672911; cv=none; d=google.com; s=arc-20160816; b=ugdWZvVM+sSi7qFWpyAWC1j9dBXTbPW5m/UQT/UpIm/4Xx21odjYuuBmbvRqdP4QJG y4r3u8vj87CNCawho8VBEsaXxY88mbKt9E+5YEX1bbG7AH5+5mGF+LoUAqFXZRphVd/u foITVjYefk0HrLmQXAS8NHBoDPlkpTIj681PDYUCoy9ANnpiIk825seIl23BMk4Tli8v TCgWgfI+TeMPZL06mUyPYvIGXlbdvu+SD5CqzNavw+mkay9hdstyRvGIQvzNGZM2ChOV p+dXMF3Ri2JvfX28QgzvhalBaz6VhW6ie5ATLE+1DIXB3AEDsDIKf2o03iUa10SzWpFb 1w4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=xt3Mc7YU3IySC66H1egC/uoSN5KkbQhVsibde1MLnxA=; b=FlXIV9Y/kDNyQoQW9vkklxnWKpveFYqXRpAz1kDvrcLteDQ8fLiz9R3wtSJ1kc/vi7 zGGFWDB5A9Q2d1GL9hKicrxaGr0r8OvOgCwyihJiSbsNg+N7oPadr/s7Vo36fpbgf4H2 G3IODvJrs2ovzawVHhDrVgrOZt/fTAXPxM/z81mG0eaILV6+sW2LEsffUa71s89FdU4B 45g3hC2tWypQ7iGhxEnuaZ9J8OgSiwjTACnftv3NObpzwk58LzgpXRuujEQqUdYjd908 qGARQDbc9+U0a6Vk4K2QZnKcEGn9bvl1mPqNSZLTbiQiC1Ju+h3cfTbVJipxz5yQ9qkY k/DQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hyperstone.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 132si4968456jaf.20.2021.09.03.05.41.39; Fri, 03 Sep 2021 05:41:51 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hyperstone.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349035AbhICKKV convert rfc822-to-8bit (ORCPT + 99 others); Fri, 3 Sep 2021 06:10:21 -0400 Received: from mail3.swissbit.com ([176.95.1.57]:34742 "EHLO mail3.swissbit.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348987AbhICKKU (ORCPT ); Fri, 3 Sep 2021 06:10:20 -0400 Received: from mail3.swissbit.com (localhost [127.0.0.1]) by DDEI (Postfix) with ESMTP id 8EA27462120; Fri, 3 Sep 2021 12:09:19 +0200 (CEST) Received: from mail3.swissbit.com (localhost [127.0.0.1]) by DDEI (Postfix) with ESMTP id 7E0A446211D; Fri, 3 Sep 2021 12:09:19 +0200 (CEST) X-TM-AS-ERS: 10.149.2.84-127.5.254.253 X-TM-AS-SMTP: 1.0 ZXguc3dpc3NiaXQuY29t Y2xvZWhsZUBoeXBlcnN0b25lLmNvbQ== X-DDEI-TLS-USAGE: Used Received: from ex.swissbit.com (SBDEEX02.sbitdom.lan [10.149.2.84]) by mail3.swissbit.com (Postfix) with ESMTPS; Fri, 3 Sep 2021 12:09:19 +0200 (CEST) Received: from sbdeex02.sbitdom.lan (10.149.2.84) by sbdeex02.sbitdom.lan (10.149.2.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Fri, 3 Sep 2021 12:09:19 +0200 Received: from sbdeex02.sbitdom.lan ([fe80::e0eb:ade8:2d90:1f74]) by sbdeex02.sbitdom.lan ([fe80::e0eb:ade8:2d90:1f74%8]) with mapi id 15.02.0792.015; Fri, 3 Sep 2021 12:09:19 +0200 From: =?iso-8859-1?Q?Christian_L=F6hle?= To: Christoph Hellwig CC: "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "martin.petersen@oracle.com" , "jejb@linux.ibm.com" Subject: AW: [PATCH] sd: sd_open: prevent device removal during sd_open Thread-Topic: [PATCH] sd: sd_open: prevent device removal during sd_open Thread-Index: AQHXoAHu4he04cmBqECW8DEEUakoBauRmZAAgAB7+j8= Date: Fri, 3 Sep 2021 10:09:18 +0000 Message-ID: <771b391322c142baa6c15db458b81e8d@hyperstone.com> References: <98bfca4cbaa24462994bcb533d365414@hyperstone.com>, In-Reply-To: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.154.1.4] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-TMASE-Version: DDEI-5.1-8.6.1018-26384.007 X-TMASE-Result: 10--5.980700-10.000000 X-TMASE-MatchedRID: TMsvcu6/L5dbRbA/K/rHzPZvT2zYoYOwMDmYaN/e0lZgDDNFig+GrOVJ pKzRFX/CiqKFBc8lvzajhXQGpGiFkXrSP9RtGZYo0wmR34xRQc/5qGeseGYAlIsYz77JTJ+IUAr JnwHoG3R+keJMZ3NCNpBi242iWIRSePs/Cx1DJd15zXLXCu83xRfJTYLG2XFvK+euk6MYlDZvIa Mtw0Pio4psmNGAE/yp1y6ttzFWrvdMi6dAAjypotMfKJ+BrWfHTJDl9FKHbrkrhioeAJKilQ6UK 9Ft+LyUNFHfw012zdN/JgN7Aw6tALVQu1GNZ+sisjvNV98mpPM03E8a2eQGboPHZ0sZfvcz0cm+ 1kT6rGJlSUEmQtntakEkNtY/j9YoftwZ3X11IV0= X-TMASE-SNAP-Result: 1.821001.0001-0-1-12:0,22:0,33:0,34:0-0 X-TMASE-INERTIA: 0-0;;;; X-TMASE-XGENCLOUD: e8dfb5c0-1be9-4ce3-b84b-f46cbe580018-0-0-200-0 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 device is being removed physically, the driver e.g. uas calls scsi_remove_host while user-space opens the /dev/sdX. >> >> 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. I will, but might take a while to get a setup to reproduce the issue. (The setup where this occurred actually powerfails the usb device repreatedly.)= Hyperstone GmbH | Line-Eid-Strasse 3 | 78467 Konstanz Managing Directors: Dr. Jan Peter Berns. Commercial register of local courts: Freiburg HRB381782