From: Niklas Cassel <cassel@kernel.org>
To: Damien Le Moal <dlemoal@kernel.org>
Cc: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <mkp@kernel.org>,
stable@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: scsi_ioctl: require write access for the depopulation commands
Date: Tue, 17 Nov 2026 13:26:07 +0100 [thread overview]
Message-ID: <avxH3yik-Dmu5TmP@ryzen> (raw)
In-Reply-To: <037b2eab-65a0-439a-814b-cc653e8cc629@kernel.org>
On Mon, Nov 16, 2026 at 12:40:36PM -0800, Damien Le Moal wrote:
> On 11/16/26 10:31, Niklas Cassel wrote:
> > scsi_cmd_allowed() lets anybody who can open a SCSI device, even
> > read-only, send any SERVICE ACTION IN(16) command. Besides READ
> > CAPACITY(16) and the other read-only service actions, that opcode also
> > carries the storage element depopulation commands of SBC-4: REMOVE
> > ELEMENT AND TRUNCATE, RESTORE ELEMENTS AND REBUILD and REMOVE ELEMENT
> > AND MODIFY ZONES. These change the capacity of the device, and after
> > REMOVE ELEMENT AND TRUNCATE the contents of the user data area may have
> > no relation to what they were before.
>
> Since that is basically reformatting the drive, I thing we can say that the
> content is likely gone...
>
> > SCSI devices that support depopulation execute these commands directly,
> > and libata translates them to the equivalent ATA commands, so a user
> > with read-only access to the device node can truncate the device through
> > SG_IO, SCSI_IOCTL_SEND_COMMAND or bsg.
> >
> > Treat these service actions like FORMAT UNIT and ERASE, which also
> > destroy data, and only allow them if the device is opened for writing.
> > The other SERVICE ACTION IN(16) service actions remain allowed for
> > everybody who can open the device.
> >
> > Cc: stable@vger.kernel.org
>
> Hmmm... SAI_REMOVE_ELEMENT_AND_TRUNCATE and friends was defined with
> 2a0adbb80a2f ("scsi: define depopulation capabilities related service actions"),
> which is in 7.3 only.
>
> So maybe make that
>
> Cc: stable@vger.kernel.org #7.3
>
> ?
I will add:
Cc: <stable@vger.kernel.org> # 2a0adbb80a2f: scsi: define depopulation capabilities related service actions
to show the dependency as per Documentation/process/stable-kernel-rules.rst
because, while for SATA devices, this problem only exists since v7.3,
for SAS, this problem is much older.
REMOVE ELEMENT AND TRUNCATE was introduced in SBC-4 (r10) - released on
January 21, 2016.
REMOVE ELEMENT AND MODIFY ZONES command was introduced in ZBC-2 (r07),
around 2020.
Kind regards,
Niklas
prev parent reply other threads:[~2026-11-17 12:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 18:31 [PATCH] scsi: scsi_ioctl: require write access for the depopulation commands Niklas Cassel
2026-11-16 20:40 ` Damien Le Moal
2026-11-17 12:26 ` Niklas Cassel [this message]
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=avxH3yik-Dmu5TmP@ryzen \
--to=cassel@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=dlemoal@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
--cc=stable@vger.kernel.org \
/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.