All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Niklas Cassel <cassel@kernel.org>,
	Zhao Gongyi <zhaogongyi@bytedance.com>
Cc: linux-ide@vger.kernel.org
Subject: Re: [PATCH] ata: libata-scsi: reject non-PIO protocols for READ/WRITE MULTIPLE
Date: Wed, 11 Nov 2026 17:52:11 +0900	[thread overview]
Message-ID: <425aaec6-89bf-4150-ab87-360cc30dc72a@kernel.org> (raw)
In-Reply-To: <avLYvtmnedp5FXSX@ryzen>

On 2026/11/10 17:41, Niklas Cassel wrote:
> There is nothing in SAT specs that requires us to validate the protocol field.
> When using normal (non-passthrough commands), the protocol field is initialized
> by the regular SCSI to ATA translation done by libata.
> 
> For passthrough commands, it comes from the user.
> 
> Not only does it come from the user, it requires CAP_SYS_RAWIO:
> 
> scsi_cmd_allowed() {
>         if (capable(CAP_SYS_RAWIO))
>                 return true;
>     ...
> 
> 
> (ATA_12 / ATA_16 / ATA_32 will all return false, so not allowed for a regular
> user.)
> 
> And... even if the user sends a command with a protocol that is not as per
> ACS spec, the command should time out and EH should reset the device.
> 
> 
> So... If the user sends a passthrough command with the wrong protocol...
> Well, that is on the user, no?
> (It also requires CAP_SYS_RAWIO)
> 
> 
> If we were to add protocol checks all passthrough commands, then we should
> not only check READ/WRITE MULTIPLE, we should check other commands like
> WRITE SECTORS (30h) and IDENTIFY DEVICE (ECh) too.
> 
> But, I don't think we want that. Damien, thoughts?

Unless we are talking about a command that libata-scsi emulates, passthrough
commands should not be parsed. We do not want that. So unless the bad SG_IO
command can crash the kernel, we should do nothing if the user sends a bad
command and it fails. We can let the drive fail it, even if that leads to drive
resets etc. As Niklas pointed out, SG_IO is priviledged, so it is not like any
user can create a DOS with bad SG_IO commands.

Also, the use case for this is a little silly in my opinion... Who wants to send
a PIO multi-sector IO using a modern command like ATA 32? libata supports that
if that is all that the drive can do. If the drive can do DMA and/or NCQ, then
better commands will be used without relaying on a PIO passthrough command.


-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2026-11-11  8:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 14:04 [PATCH] ata: libata-scsi: reject non-PIO protocols for READ/WRITE MULTIPLE Zhao Gongyi
2026-11-10  8:41 ` Niklas Cassel
2026-11-11  8:52   ` Damien Le Moal [this message]
2026-11-11 10:12     ` Zhao Gongyi

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=425aaec6-89bf-4150-ab87-360cc30dc72a@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=cassel@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=zhaogongyi@bytedance.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.