* [PATCH 1/3] scsi: st: Fix array overflow in st_setup()
2025-03-11 11:25 [PATCH 0/3] scsi: st: Small fixes Kai Mäkisara
@ 2025-03-11 11:25 ` Kai Mäkisara
2025-03-11 11:25 ` [PATCH 2/3] scsi: st: ERASE does not change tape location Kai Mäkisara
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Kai Mäkisara @ 2025-03-11 11:25 UTC (permalink / raw)
To: linux-scsi
Cc: martin.petersen, James.Bottomley, jmeneghi, Kai Mäkisara,
Chenyuan Yang
Change the array size to follow parms size instead of a fixed value.
Reported-by: Chenyuan Yang <chenyuan0y@gmail.com>
Closes: https://lore.kernel.org/linux-scsi/CALGdzuoubbra4xKOJcsyThdk5Y1BrAmZs==wbqjbkAgmKS39Aw@mail.gmail.com/
Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
---
drivers/scsi/st.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 85867120c8a9..0d020cb1ffcd 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4157,7 +4157,7 @@ static void validate_options(void)
*/
static int __init st_setup(char *str)
{
- int i, len, ints[5];
+ int i, len, ints[ARRAY_SIZE(parms)+1];
char *stp;
stp = get_options(str, ARRAY_SIZE(ints), ints);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/3] scsi: st: ERASE does not change tape location
2025-03-11 11:25 [PATCH 0/3] scsi: st: Small fixes Kai Mäkisara
2025-03-11 11:25 ` [PATCH 1/3] scsi: st: Fix array overflow in st_setup() Kai Mäkisara
@ 2025-03-11 11:25 ` Kai Mäkisara
2025-03-11 11:25 ` [PATCH 3/3] scsi: st: Tighten the page format heuristics with MODE SELECT Kai Mäkisara
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Kai Mäkisara @ 2025-03-11 11:25 UTC (permalink / raw)
To: linux-scsi; +Cc: martin.petersen, James.Bottomley, jmeneghi, Kai Mäkisara
The SCSI ERASE command erases from the current position onwards.
Don't clear the position variables.
Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
---
drivers/scsi/st.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 0d020cb1ffcd..55809f8a62d3 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -2915,7 +2915,6 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
timeout = STp->long_timeout * 8;
DEBC_printk(STp, "Erasing tape.\n");
- fileno = blkno = at_sm = 0;
break;
case MTSETBLK: /* Set block length */
case MTSETDENSITY: /* Set tape density */
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/3] scsi: st: Tighten the page format heuristics with MODE SELECT
2025-03-11 11:25 [PATCH 0/3] scsi: st: Small fixes Kai Mäkisara
2025-03-11 11:25 ` [PATCH 1/3] scsi: st: Fix array overflow in st_setup() Kai Mäkisara
2025-03-11 11:25 ` [PATCH 2/3] scsi: st: ERASE does not change tape location Kai Mäkisara
@ 2025-03-11 11:25 ` Kai Mäkisara
2025-04-26 20:54 ` Lee Duncan
2025-03-18 1:43 ` [PATCH 0/3] scsi: st: Small fixes Martin K. Petersen
2025-03-21 0:36 ` Martin K. Petersen
4 siblings, 1 reply; 7+ messages in thread
From: Kai Mäkisara @ 2025-03-11 11:25 UTC (permalink / raw)
To: linux-scsi; +Cc: martin.petersen, James.Bottomley, jmeneghi, Kai Mäkisara
In the days when SCSI-2 was emerging, some drives did claim SCSI-2
but did not correctly implement it. The st driver first tries MODE
SELECT with the page format bit set to set the block descriptor.
If not successful, the non-page format is tried.
The test only tests the sense code and this triggers also from
illegal parameter in the parameter list. The test is limited to
"old" devices and made more strict to remove false alarms.
Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
---
drivers/scsi/st.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index 55809f8a62d3..c33c0f2045b7 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3104,7 +3104,9 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
cmd_in == MTSETDRVBUFFER ||
cmd_in == SET_DENS_AND_BLK) {
if (cmdstatp->sense_hdr.sense_key == ILLEGAL_REQUEST &&
- !(STp->use_pf & PF_TESTED)) {
+ cmdstatp->sense_hdr.asc == 0x24 &&
+ (STp->device)->scsi_level <= SCSI_2 &&
+ !(STp->use_pf & PF_TESTED)) {
/* Try the other possible state of Page Format if not
already tried */
STp->use_pf = (STp->use_pf ^ USE_PF) | PF_TESTED;
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 3/3] scsi: st: Tighten the page format heuristics with MODE SELECT
2025-03-11 11:25 ` [PATCH 3/3] scsi: st: Tighten the page format heuristics with MODE SELECT Kai Mäkisara
@ 2025-04-26 20:54 ` Lee Duncan
0 siblings, 0 replies; 7+ messages in thread
From: Lee Duncan @ 2025-04-26 20:54 UTC (permalink / raw)
To: Kai Mäkisara; +Cc: linux-scsi, martin.petersen, James.Bottomley, jmeneghi
On Tue, Mar 11, 2025 at 4:26 AM Kai Mäkisara <Kai.Makisara@kolumbus.fi> wrote:
>
> In the days when SCSI-2 was emerging, some drives did claim SCSI-2
> but did not correctly implement it. The st driver first tries MODE
> SELECT with the page format bit set to set the block descriptor.
> If not successful, the non-page format is tried.
>
> The test only tests the sense code and this triggers also from
> illegal parameter in the parameter list. The test is limited to
> "old" devices and made more strict to remove false alarms.
>
> Signed-off-by: Kai Mäkisara <Kai.Makisara@kolumbus.fi>
> ---
> drivers/scsi/st.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> index 55809f8a62d3..c33c0f2045b7 100644
> --- a/drivers/scsi/st.c
> +++ b/drivers/scsi/st.c
> @@ -3104,7 +3104,9 @@ static int st_int_ioctl(struct scsi_tape *STp, unsigned int cmd_in, unsigned lon
> cmd_in == MTSETDRVBUFFER ||
> cmd_in == SET_DENS_AND_BLK) {
> if (cmdstatp->sense_hdr.sense_key == ILLEGAL_REQUEST &&
> - !(STp->use_pf & PF_TESTED)) {
> + cmdstatp->sense_hdr.asc == 0x24 &&
> + (STp->device)->scsi_level <= SCSI_2 &&
> + !(STp->use_pf & PF_TESTED)) {
> /* Try the other possible state of Page Format if not
> already tried */
> STp->use_pf = (STp->use_pf ^ USE_PF) | PF_TESTED;
> --
> 2.43.0
>
>
Reviewed-by: Lee Duncan <lduncan@suse.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/3] scsi: st: Small fixes
2025-03-11 11:25 [PATCH 0/3] scsi: st: Small fixes Kai Mäkisara
` (2 preceding siblings ...)
2025-03-11 11:25 ` [PATCH 3/3] scsi: st: Tighten the page format heuristics with MODE SELECT Kai Mäkisara
@ 2025-03-18 1:43 ` Martin K. Petersen
2025-03-21 0:36 ` Martin K. Petersen
4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2025-03-18 1:43 UTC (permalink / raw)
To: Kai Mäkisara; +Cc: linux-scsi, martin.petersen, James.Bottomley, jmeneghi
Kai,
> Fix some small things in the st driver.
Applied to 6.15/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH 0/3] scsi: st: Small fixes
2025-03-11 11:25 [PATCH 0/3] scsi: st: Small fixes Kai Mäkisara
` (3 preceding siblings ...)
2025-03-18 1:43 ` [PATCH 0/3] scsi: st: Small fixes Martin K. Petersen
@ 2025-03-21 0:36 ` Martin K. Petersen
4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2025-03-21 0:36 UTC (permalink / raw)
To: linux-scsi, Kai Mäkisara
Cc: Martin K . Petersen, James.Bottomley, jmeneghi
On Tue, 11 Mar 2025 13:25:13 +0200, Kai Mäkisara wrote:
> Fix some small things in the st driver.
>
> Applies to 6.15/scsi-staging
>
> Kai Mäkisara (3):
> scsi: st: Fix array overflow in st_setup()
> scsi: st: ERASE does not change tape location
> scsi: st: Tighten the page format heuristics with MODE SELECT
>
> [...]
Applied to 6.15/scsi-queue, thanks!
[1/3] scsi: st: Fix array overflow in st_setup()
https://git.kernel.org/mkp/scsi/c/a018d1cf990d
[2/3] scsi: st: ERASE does not change tape location
https://git.kernel.org/mkp/scsi/c/ad77cebf97bd
[3/3] scsi: st: Tighten the page format heuristics with MODE SELECT
https://git.kernel.org/mkp/scsi/c/8db816c6f176
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 7+ messages in thread