lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 22 May 2023 12:28:09 +0100
From:   John Garry <john.g.garry@...cle.com>
To:     Jason Yan <yanaijie@...wei.com>,
        Damien Le Moal <dlemoal@...nel.org>,
        yangxingui <yangxingui@...wei.com>, jejb@...ux.ibm.com,
        martin.petersen@...cle.com
Cc:     linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
        linuxarm@...wei.com, prime.zeng@...ilicon.com,
        kangfenglong@...wei.com
Subject: Re: [PATCH v2] ata: libata-scsi: Fix get identity data failed

On 22/05/2023 09:00, Jason Yan wrote:
> 
> OK, so the issue is that __ata_scsi_find_dev() calls ata_find_dev() with 
> devno
> == scsidev->id. This leads to devno being 0, 1, 2 and 3 for connected 
> drives

This numbering comes from sas_rphy_add():
...
if (identify->device_type == SAS_END_DEVICE &&
     (identify->target_port_protocols &
      (SAS_PROTOCOL_SSP | SAS_PROTOCOL_STP | SAS_PROTOCOL_SATA)))
	rphy->scsi_target_id = sas_host->next_target_id++;

..

	scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, lun,
SCSI_SCAN_INITIAL);
}

So libata and scsi_transport_sas just use different sdev id numbering 
schemes for host scan.

> sdd, sd1, sdf and sdg, as shown by lsscsi. However, each drive has its own
> port+link, with the link for each one having  ata_link_max_devices() == 
> 1, so
> ata_find_dev() works only for the first drive with scsidev->id == 0 and 
> fails
> for the others. A naive fix would be this:
> 
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 7bb12deab70c..e4d6f17d7ccc 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -2718,7 +2718,7 @@ static struct ata_device *__ata_scsi_find_dev(struct
> ata_port *ap,
>           if (!sata_pmp_attached(ap)) {
>                   if (unlikely(scsidev->channel || scsidev->lun))
>                           return NULL;
> -               devno = scsidev->id;
> +               devno = 0;
Would this pattern work:

ata_for_each_dev(ata_dev, link, ALL) {
	if (ata_dev->sdev == sdev)
		return ata_dev;
}

If not, I think it's ok to have devno = 0 assignment under SAS_HOST 
flag, even though it's far from ideal. Not both of these are not 
preferred, then, as I mentioned before, some per-port callback to do the 
conversion.

Thanks,
John

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ