From: Damien Le Moal <dlemoal@kernel.org>
To: Jason Yan <yanaijie@huawei.com>, linux-ide@vger.kernel.org
Cc: John Garry <john.g.garry@oracle.com>,
Xingui Yang <yangxingui@huawei.com>
Subject: Re: [PATCH v2] ata: libata-scsi: Use correct device no in ata_find_dev()
Date: Wed, 24 May 2023 10:31:02 +0900 [thread overview]
Message-ID: <18bd6b4f-0c08-2ea3-c676-1803f55de9bf@kernel.org> (raw)
In-Reply-To: <cb2d18ed-2b61-6d92-96f4-4c84429ebe74@huawei.com>
On 5/23/23 21:29, Jason Yan wrote:
> On 2023/5/23 19:52, Damien Le Moal wrote:
>>> I wonder if you can change the type of devno to 'unsigned int'? At a
>>> closer look I found the user can control this value and may pass in a
>>> bogus channel or id.
>>>
>>> proc_scsi_write
>>> =>scsi_add_single_device
>>> =>ata_scsi_user_scan
>>> =>ata_find_dev
>> Reading more about scsi_add_single_device(), the comment says "Note:
>> this seems
>> to be aimed exclusively at SCSI parallel busses.". So I don't think we
>> should
>> worry about it. But then I also do not understand why libata is wired
>> to this at
>> all. Cannot have ATA device on a parallel SCSI bus...
>
> The comment is kind of obsolete. It is not limited to SCSI parallel
> busses only.
>
>>
>> On my system, I cannot get
>>
>> echo "scsi add-single-device X 0 100 0" >/proc/scsi/scsi
>>
>> to do anything and so I do not see how ata_scsi_user_scan can ever be
>> called...
>>
>
> Did you enabled CONFIG_SCSI_PROC_FS ? I started a qemu and it still works.
>
> [root@localhost ~]# cat /proc/scsi/scsi
> Attached devices:
> Host: scsi1 Channel: 00 Id: 00 Lun: 00
> Vendor: QEMU Model: QEMU DVD-ROM Rev: 2.5+
> Type: CD-ROM ANSI SCSI revision: 05
> [root@localhost ~]# lsscsi
> [1:0:0:0] cd/dvd QEMU QEMU DVD-ROM 2.5+ /dev/sr0
> [root@localhost ~]#
> [root@localhost ~]#
> [root@localhost ~]# echo "scsi remove-single-device 1 0 0 0" >
> /proc/scsi/scsi
> [ 639.747836] ata2.00: disable device
> [root@localhost ~]#
> [root@localhost ~]#
> [root@localhost ~]# echo "scsi add-single-device 1 0 0 0" > /proc/scsi/scsi
> [root@localhost ~]#
> [root@localhost ~]#
> [root@localhost ~]# lsscsi
> [1:0:0:0] cd/dvd QEMU QEMU DVD-ROM 2.5+ /dev/sr0
> [root@localhost ~]#
> [root@localhost ~]#
> [root@localhost ~]# echo "scsi add-single-device 1 0 100 0" >
> /proc/scsi/scsi
> -bash: echo: write error: Invalid argument
> [root@localhost ~]#
> [root@localhost ~]#
>
>
> For a wrong scsi nubmer "1 0 100 0", it returns an error now. If our
> patch is applied, it will return ok and will add "1 0 0 0" instead, I
> guess.
Indeed. Using ata_find_dev() in ata_scsi_user_scan() as it is is not
broken. And ata_scsi_user_scan() is also likely broken in subtle ways
for libsas due to the ata port being determined from the scsi host,
which does not seem to be how libsas manages things. Need to dig further.
>
>
> Thanks,
> Jason
--
Damien Le Moal
Western Digital Research
prev parent reply other threads:[~2023-05-24 1:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 2:32 [PATCH v2] ata: libata-scsi: Use correct device no in ata_find_dev() Damien Le Moal
2023-05-23 7:05 ` Jason Yan
2023-05-23 11:52 ` Damien Le Moal
2023-05-23 12:29 ` Jason Yan
2023-05-23 12:41 ` Jason Yan
2023-05-24 1:31 ` Damien Le Moal [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=18bd6b4f-0c08-2ea3-c676-1803f55de9bf@kernel.org \
--to=dlemoal@kernel.org \
--cc=john.g.garry@oracle.com \
--cc=linux-ide@vger.kernel.org \
--cc=yanaijie@huawei.com \
--cc=yangxingui@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox