All of lore.kernel.org
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Karuna Ramkumar <rkaruna@google.com>
Cc: sashiko-reviews@lists.linux.dev, cassel@kernel.org,
	linux-ide@vger.kernel.org, Igor Pylypiv <ipylypiv@google.com>,
	TJ Adams <tadamsjr@google.com>
Subject: Re: [PATCH v2] ata: libata-scsi: limit simulated SCSI command copy to response length
Date: Tue, 7 Jul 2026 10:10:02 +0900	[thread overview]
Message-ID: <49cb57c1-d7d6-4f30-b628-72c083981da6@kernel.org> (raw)
In-Reply-To: <CAD50Xqp_LBvRqhn0q93s3aVxtfFWGhf42jBePKsUonfE6V=WNw@mail.gmail.com>

On 7/7/26 08:10, Karuna Ramkumar wrote:
> Before I start working on this, I would love to hear your feedback on:
> 1. Whether you think this API update (passing `rbuf_len` down to all
> actors and helper functions) is the right approach, or if you prefer
> simpler, and more localized checks elsewhere.

I do not think it is necessary at all because rbuf is statically declared:

static u8 ata_scsi_rbuf[ATA_SCSI_RBUF_SIZE];

So the buffer address and maximum size is known to all functions using it.

> 2. What would be the best way to test all these simulated command
> paths to ensure the fix is verified appropriately?

Most functions for emulated commands generate only a very small amount of data,
far below ATA_SCSI_RBUF_SIZE. So I would suggest that we simply add checks to
the functions which may potentially exceed that. Off the top of my head, I do
not know if we have any, but we should just check.

Note that ideally, we should have each function allocate their own local buffer
to handle the translation. But this is right now a little hard to do because
these translation/emulation functions are called with the port locked, so we
would have a memory allocation for a potentially large-ish buffer under a spin
lock, which means no reclaim/no wait allocation, and thus potential for failure
which we do not have right now. A proper/ideal fix would need to drop
ata_scsi_rbuf, have some helpers for managing the internal buffer and redesign
the submission path to not have the port locked until the translation is
actually generated. That is all more work and more changes.

So as a first step, let's check the emulation function if any of them can exceed
ATA_SCSI_RBUF_SIZE in size, fail them with internal target failure.

-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2026-07-07  1:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  2:01 [PATCH v2] ata: libata-scsi: limit simulated SCSI command copy to response length Karuna Ramkumar
2026-07-02  2:14 ` sashiko-bot
2026-07-02  2:30   ` Damien Le Moal
2026-07-06 23:10     ` Karuna Ramkumar
2026-07-07  1:10       ` Damien Le Moal [this message]
2026-07-03  6:17 ` Damien Le Moal

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=49cb57c1-d7d6-4f30-b628-72c083981da6@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=cassel@kernel.org \
    --cc=ipylypiv@google.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=rkaruna@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tadamsjr@google.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.