Linux ATA/IDE development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Damien Le Moal" <dlemoal@kernel.org>
Cc: dlemoal@kernel.org, linux-ide@vger.kernel.org, cassel@kernel.org
Subject: Re: [PATCH v2 3/5] ata: libata-scsi: improve service action support in ata_scsi_report_supported_opcodes()
Date: Thu, 02 Jul 2026 06:47:10 +0000	[thread overview]
Message-ID: <20260702064710.6E8811F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260702063412.1892584-4-dlemoal@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Improper handling of the REQUESTED SERVICE ACTION field for reporting option 3 in REPORT SUPPORTED OPERATION CODES.
--

commit b3caa191a7aab568905b6cb9a00aa04fd0f6cf62
Author: Damien Le Moal <dlemoal@kernel.org>

ata: libata-scsi: improve service action support in ata_scsi_report_supported_opcodes()

This commit updates ata_scsi_report_supported_opcodes() to consider the
service action specified in the SCSI command CDB. It adds support for failing
reporting options 1 if the opcode has service actions, and matches opcodes
with their service actions for reporting option 3.

> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 4f0ae44f59dd2..86ac41a7d81ab 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -3642,32 +3642,46 @@ static const struct ata_scsi_cmd ata_supported_cmds[] = {
>  	{ SECURITY_PROTOCOL_OUT, 12,	false,	0 },
>  };
>  
> -static const struct ata_scsi_cmd *ata_scsi_get_supported_cmd(u8 op)
> +static const struct ata_scsi_cmd *ata_scsi_get_supported_cmd(u8 op, u16 sa)
>  {
>  	const struct ata_scsi_cmd *cmd;
>  	int i;
>  
>  	for (i = 0; i < ARRAY_SIZE(ata_supported_cmds); i++) {
>  		cmd = &ata_supported_cmds[i];
> -		if (cmd->op == op)
> +		if (cmd->op == op && cmd->sa == sa)

[Severity: Medium]
If the queried command does not have a service action, its cmd->sa will be 0.
If a non-zero service action was passed in through sa, this strict comparison
will fail.

Since SPC-5 states that the REQUESTED SERVICE ACTION field "shall be ignored"
when the operation code does not have service actions, could this result in
valid commands being incorrectly reported as unsupported?

>  			return cmd;
>  	}
>  
>  	return NULL;
>  }

[ ... ]

> @@ -3713,15 +3727,28 @@ static unsigned int ata_scsi_report_supported_opcodes(struct ata_device *dev,
>  {
>  	struct ata_scsi_cmd_support sup;
>  	u8 *cdb = cmd->cmnd;
> -
> -	if (cdb[2] != 1 && cdb[2] != 3) {
> +	u16 sa = 0;
> +
> +	switch (cdb[2]) {
> +	case 1:
> +		/* One command format with command support data, ignore sa. */
> +		if (ata_scsi_supported_cmd_use_sa(cdb[3])) {
> +			ata_scsi_set_invalid_field(dev, cmd, 3, 0xff);
> +			return 0;
> +		}
> +		break;
> +	case 3:
> +		/* One command format */
> +		sa = get_unaligned_be16(&cdb[4]);
> +		break;

[Severity: Medium]
If the queried command (e.g., READ_10) doesn't use service actions, does
extracting the service action unconditionally here pass a non-zero value to
ata_scsi_get_supported_cmd() if the initiator provided one?

Should sa remain 0 if ata_scsi_supported_cmd_use_sa(cdb[3]) is false?

> +	default:
>  		ata_dev_warn(dev, "invalid command format %d\n", cdb[2]);
>  		ata_scsi_set_invalid_field(dev, cmd, 2, 0xff);
>  		return 0;
>  	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260702063412.1892584-1-dlemoal@kernel.org?part=3

  parent reply	other threads:[~2026-07-02  6:47 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  6:34 [PATCH v2 0/5] Improve ata_scsi_report_supported_opcodes() Damien Le Moal
2026-07-02  6:34 ` [PATCH v2 1/5] ata: libata: rename ata_dev_is_zac() Damien Le Moal
2026-07-02  6:38   ` Hannes Reinecke
2026-07-02  7:16   ` sashiko-bot
2026-07-02  6:34 ` [PATCH v2 2/5] ata: libata-scsi: refactor ata_scsi_report_supported_opcodes() Damien Le Moal
2026-07-02  6:44   ` Hannes Reinecke
2026-07-02  7:01     ` Damien Le Moal
2026-07-02  6:53   ` sashiko-bot
2026-07-02 13:25     ` Niklas Cassel
2026-07-02 14:36       ` Niklas Cassel
2026-07-02 14:48         ` Christoph Hellwig
2026-07-02 14:53           ` Niklas Cassel
2026-07-02  6:34 ` [PATCH v2 3/5] ata: libata-scsi: improve service action support in ata_scsi_report_supported_opcodes() Damien Le Moal
2026-07-02  6:45   ` Hannes Reinecke
2026-07-02  6:47   ` sashiko-bot [this message]
2026-07-02  6:34 ` [PATCH v2 4/5] ata: libata-scsi: support reporting options 2 in REPORT SUPPORTED OPERATION CODES Damien Le Moal
2026-07-02  6:46   ` Hannes Reinecke
2026-07-02  6:52   ` sashiko-bot
2026-07-02  7:00     ` Damien Le Moal
2026-07-02 11:41       ` Niklas Cassel
2026-07-02  6:53   ` Hannes Reinecke
2026-07-02  6:34 ` [PATCH v2 5/5] ata: libata-scsi: support the all command format for reporting supported commands Damien Le Moal
2026-07-02  6:54   ` 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=20260702064710.6E8811F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=cassel@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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