All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dgilbert@interlog.com>
To: linux-scsi <linux-scsi@vger.kernel.org>,
	linux-ide@vger.kernel.org,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Hannes Reinecke <hare@suse.de>,
	Tony Asleson <tasleson@redhat.com>
Subject: libata: big endian bug in VPD page 89 (ATA Information)
Date: Sun, 13 Jun 2021 21:28:03 -0400	[thread overview]
Message-ID: <f0d1073e-b4a0-c255-41a3-ff52f1553c0f@interlog.com> (raw)

In drivers/ata/libata-scsi.c in function ata_scsiop_inq_89() there is
this line, just before the return:
        memcpy(&rbuf[60], &args->id[0], 512);

args->id[0] is the first u16 word of an array from the ATA IDENTIFY
DEVICE response while rbuf is an array of u8 that will become the
response to a SCSI INQUIRY(VPD=89h). Given the definition of VPD
page 89h:
    byte 60+0:  ATA IDENTIFY DEVICE data word 0 bits 7:0
    byte 60+1:  ATA IDENTIFY DEVICE data word 0 bits 15:8
    byte 60+2:  ATA IDENTIFY DEVICE data word 1 bits 7:0
    ........

then that memcpy is just fine and dandy on a little endian machine.
On a big endian machine, not so much.

Would this call after the memcpy fix things?
     swap_buf_le16((u16 *)(rbuf + 60), ATA_ID_WORDS);

That function (in libata-core.c) only swaps bytes in 16 bit words
on big endian machines.

Doug Gilbert

             reply	other threads:[~2021-06-14  1:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-14  1:28 Douglas Gilbert [this message]
2021-06-14  6:00 ` libata: big endian bug in VPD page 89 (ATA Information) Hannes Reinecke

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=f0d1073e-b4a0-c255-41a3-ff52f1553c0f@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=hare@suse.de \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=tasleson@redhat.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.