Skip to content

Commit b09b97a

Browse files
kmakisarazyf1116
authored andcommitted
scsi: st: Don't set pos_unknown just after device recognition
stable inclusion from stable-6.6.78 commit 7bfa83ee25a68214903dc3a6b431eb8ab0a81850 category: bugfix issue: #IC2PN8 CVE: NA Signed-off-by: zyf1116 <[email protected]> --------------------------------------- commit 98b37881b7492ae9048ad48260cc8a6ee9eb39fd upstream. Commit 9604eea ("scsi: st: Add third party poweron reset handling") in v6.6 added new code to handle the Power On/Reset Unit Attention (POR UA) sense data. This was in addition to the existing method. When this Unit Attention is received, the driver blocks attempts to read, write and some other operations because the reset may have rewinded the tape. Because of the added code, also the initial POR UA resulted in blocking operations, including those that are used to set the driver options after the device is recognized. Also, reading and writing are refused, whereas they succeeded before this commit. Add code to not set pos_unknown to block operations if the POR UA is received from the first test_ready() call after the st device has been created. This restores the behavior before v6.6. Signed-off-by: Kai Mäkisara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Fixes: 9604eea ("scsi: st: Add third party poweron reset handling") CC: [email protected] Closes: https://lore.kernel.org/linux-scsi/[email protected]/ Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: zyf1116 <[email protected]>
1 parent 36ddf29 commit b09b97a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

drivers/scsi/st.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,11 @@ static int test_ready(struct scsi_tape *STp, int do_wait)
10281028
retval = new_session ? CHKRES_NEW_SESSION : CHKRES_READY;
10291029
break;
10301030
}
1031+
if (STp->first_tur) {
1032+
/* Don't set pos_unknown right after device recognition */
1033+
STp->pos_unknown = 0;
1034+
STp->first_tur = 0;
1035+
}
10311036

10321037
if (SRpnt != NULL)
10331038
st_release_request(SRpnt);
@@ -4326,6 +4331,7 @@ static int st_probe(struct device *dev)
43264331
blk_queue_rq_timeout(tpnt->device->request_queue, ST_TIMEOUT);
43274332
tpnt->long_timeout = ST_LONG_TIMEOUT;
43284333
tpnt->try_dio = try_direct_io;
4334+
tpnt->first_tur = 1;
43294335

43304336
for (i = 0; i < ST_NBR_MODES; i++) {
43314337
STm = &(tpnt->modes[i]);

drivers/scsi/st.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ struct scsi_tape {
170170
unsigned char rew_at_close; /* rewind necessary at close */
171171
unsigned char inited;
172172
unsigned char cleaning_req; /* cleaning requested? */
173+
unsigned char first_tur; /* first TEST UNIT READY */
173174
int block_size;
174175
int min_block;
175176
int max_block;

0 commit comments

Comments
 (0)