From: "Christian Löhle" <CLoehle@hyperstone.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
"jejb@linux.ibm.com" <jejb@linux.ibm.com>
Subject: AW: [PATCH] sd: sd_open: prevent device removal during sd_open
Date: Fri, 3 Sep 2021 10:09:18 +0000 [thread overview]
Message-ID: <771b391322c142baa6c15db458b81e8d@hyperstone.com> (raw)
In-Reply-To: <YTGmyp0kzhVsuk5K@infradead.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
prev parent reply other threads:[~2021-09-03 10:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-02 13:57 [PATCH] sd: sd_open: prevent device removal during sd_open Christian Löhle
2021-09-02 14:23 ` Greg KH
2021-09-03 4:38 ` Christoph Hellwig
2021-09-03 10:09 ` Christian Löhle [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=771b391322c142baa6c15db458b81e8d@hyperstone.com \
--to=cloehle@hyperstone.com \
--cc=hch@infradead.org \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.