* [PATCH 0/4] s390/dasd: fix out of bound access and other fixes
@ 2022-11-23 16:07 Stefan Haberland
2022-11-23 16:07 ` [PATCH 1/4] s390/dasd: Fix spelling mistake "Ivalid" -> "Invalid" Stefan Haberland
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Stefan Haberland @ 2022-11-23 16:07 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Colin Ian King
Hi Jens,
please apply the following patches that:
- fix an out of bound access
- fix a possible IO error on non-IBM storage
- fix a typo
- improve debug data for error scenarios
regards,
Stefan
Colin Ian King (1):
s390/dasd: Fix spelling mistake "Ivalid" -> "Invalid"
Stefan Haberland (3):
s390/dasd: increase printing of debug data payload
s390/dasd: fix no record found for raw_track_access
s390/dasd: fix possible buffer overflow in copy_pair_show
drivers/s390/block/dasd_devmap.c | 2 +-
drivers/s390/block/dasd_eckd.c | 43 ++++++++++++++++----------------
drivers/s390/block/dasd_ioctl.c | 2 +-
3 files changed, 23 insertions(+), 24 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] s390/dasd: Fix spelling mistake "Ivalid" -> "Invalid"
2022-11-23 16:07 [PATCH 0/4] s390/dasd: fix out of bound access and other fixes Stefan Haberland
@ 2022-11-23 16:07 ` Stefan Haberland
2022-11-23 16:07 ` [PATCH 2/4] s390/dasd: increase printing of debug data payload Stefan Haberland
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Stefan Haberland @ 2022-11-23 16:07 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Colin Ian King
From: Colin Ian King <colin.i.king@gmail.com>
There is a spelling mistake in a pr_warn message. Fix it.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Link: https://lore.kernel.org/r/20220923132103.2486724-1-colin.i.king@gmail.com
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
drivers/s390/block/dasd_ioctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index d0ddf2cc9786..9327dcdd6e5e 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -401,7 +401,7 @@ dasd_ioctl_copy_pair_swap(struct block_device *bdev, void __user *argp)
return -EFAULT;
}
if (memchr_inv(data.reserved, 0, sizeof(data.reserved))) {
- pr_warn("%s: Ivalid swap data specified.\n",
+ pr_warn("%s: Invalid swap data specified\n",
dev_name(&device->cdev->dev));
dasd_put_device(device);
return DASD_COPYPAIRSWAP_INVALID;
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] s390/dasd: increase printing of debug data payload
2022-11-23 16:07 [PATCH 0/4] s390/dasd: fix out of bound access and other fixes Stefan Haberland
2022-11-23 16:07 ` [PATCH 1/4] s390/dasd: Fix spelling mistake "Ivalid" -> "Invalid" Stefan Haberland
@ 2022-11-23 16:07 ` Stefan Haberland
2022-11-23 16:07 ` [PATCH 3/4] s390/dasd: fix no record found for raw_track_access Stefan Haberland
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Stefan Haberland @ 2022-11-23 16:07 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Colin Ian King
32 byte are to less for important data from prefix or
other commands.
Print up to 128 byte data. This is enough for the largest
CCW data we have.
Since printk can only print up to 1024 byte at once, print the
different parts of the CCW dumps separately.
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
---
drivers/s390/block/dasd_eckd.c | 37 +++++++++++++++++-----------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 662730f3b027..85bf045c2ff9 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -5500,7 +5500,7 @@ dasd_eckd_ioctl(struct dasd_block *block, unsigned int cmd, void __user *argp)
* Dump the range of CCWs into 'page' buffer
* and return number of printed chars.
*/
-static int
+static void
dasd_eckd_dump_ccw_range(struct ccw1 *from, struct ccw1 *to, char *page)
{
int len, count;
@@ -5518,16 +5518,21 @@ dasd_eckd_dump_ccw_range(struct ccw1 *from, struct ccw1 *to, char *page)
else
datap = (char *) ((addr_t) from->cda);
- /* dump data (max 32 bytes) */
- for (count = 0; count < from->count && count < 32; count++) {
- if (count % 8 == 0) len += sprintf(page + len, " ");
- if (count % 4 == 0) len += sprintf(page + len, " ");
+ /* dump data (max 128 bytes) */
+ for (count = 0; count < from->count && count < 128; count++) {
+ if (count % 32 == 0)
+ len += sprintf(page + len, "\n");
+ if (count % 8 == 0)
+ len += sprintf(page + len, " ");
+ if (count % 4 == 0)
+ len += sprintf(page + len, " ");
len += sprintf(page + len, "%02x", datap[count]);
}
len += sprintf(page + len, "\n");
from++;
}
- return len;
+ if (len > 0)
+ printk(KERN_ERR "%s", page);
}
static void
@@ -5619,37 +5624,33 @@ static void dasd_eckd_dump_sense_ccw(struct dasd_device *device,
if (req) {
/* req == NULL for unsolicited interrupts */
/* dump the Channel Program (max 140 Bytes per line) */
- /* Count CCW and print first CCWs (maximum 1024 % 140 = 7) */
+ /* Count CCW and print first CCWs (maximum 7) */
first = req->cpaddr;
for (last = first; last->flags & (CCW_FLAG_CC | CCW_FLAG_DC); last++);
to = min(first + 6, last);
- len = sprintf(page, PRINTK_HEADER
- " Related CP in req: %p\n", req);
- dasd_eckd_dump_ccw_range(first, to, page + len);
- printk(KERN_ERR "%s", page);
+ printk(KERN_ERR PRINTK_HEADER " Related CP in req: %p\n", req);
+ dasd_eckd_dump_ccw_range(first, to, page);
/* print failing CCW area (maximum 4) */
/* scsw->cda is either valid or zero */
- len = 0;
from = ++to;
fail = (struct ccw1 *)(addr_t)
irb->scsw.cmd.cpa; /* failing CCW */
if (from < fail - 2) {
from = fail - 2; /* there is a gap - print header */
- len += sprintf(page, PRINTK_HEADER "......\n");
+ printk(KERN_ERR PRINTK_HEADER "......\n");
}
to = min(fail + 1, last);
- len += dasd_eckd_dump_ccw_range(from, to, page + len);
+ dasd_eckd_dump_ccw_range(from, to, page + len);
/* print last CCWs (maximum 2) */
+ len = 0;
from = max(from, ++to);
if (from < last - 1) {
from = last - 1; /* there is a gap - print header */
- len += sprintf(page + len, PRINTK_HEADER "......\n");
+ printk(KERN_ERR PRINTK_HEADER "......\n");
}
- len += dasd_eckd_dump_ccw_range(from, last, page + len);
- if (len > 0)
- printk(KERN_ERR "%s", page);
+ dasd_eckd_dump_ccw_range(from, last, page + len);
}
free_page((unsigned long) page);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] s390/dasd: fix no record found for raw_track_access
2022-11-23 16:07 [PATCH 0/4] s390/dasd: fix out of bound access and other fixes Stefan Haberland
2022-11-23 16:07 ` [PATCH 1/4] s390/dasd: Fix spelling mistake "Ivalid" -> "Invalid" Stefan Haberland
2022-11-23 16:07 ` [PATCH 2/4] s390/dasd: increase printing of debug data payload Stefan Haberland
@ 2022-11-23 16:07 ` Stefan Haberland
2022-11-23 16:07 ` [PATCH 4/4] s390/dasd: fix possible buffer overflow in copy_pair_show Stefan Haberland
2022-11-23 17:37 ` [PATCH 0/4] s390/dasd: fix out of bound access and other fixes Jens Axboe
4 siblings, 0 replies; 6+ messages in thread
From: Stefan Haberland @ 2022-11-23 16:07 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Colin Ian King
For DASD devices in raw_track_access mode only full track images are
read and written.
For this purpose it is not necessary to do search operation in the
locate record extended function. The documentation even states that
this might fail if the searched record is not found on a track.
Currently the driver sets a value of 1 in the search field for the first
record after record zero. This is the default for disks not in
raw_track_access mode but record 1 might be missing on a completely
empty track.
There has not been any problem with this on IBM storage servers but it
might lead to errors with DASD devices on other vendors storage servers.
Fix this by setting the search field to 0. Record zero is always available
even on a completely empty track.
Fixes: e4dbb0f2b5dd ("[S390] dasd: Add support for raw ECKD access.")
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
---
drivers/s390/block/dasd_eckd.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 85bf045c2ff9..5d0b9991e91a 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -4722,7 +4722,6 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_raw(struct dasd_device *startdev,
struct dasd_device *basedev;
struct req_iterator iter;
struct dasd_ccw_req *cqr;
- unsigned int first_offs;
unsigned int trkcount;
unsigned long *idaws;
unsigned int size;
@@ -4756,7 +4755,6 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_raw(struct dasd_device *startdev,
last_trk = (blk_rq_pos(req) + blk_rq_sectors(req) - 1) /
DASD_RAW_SECTORS_PER_TRACK;
trkcount = last_trk - first_trk + 1;
- first_offs = 0;
if (rq_data_dir(req) == READ)
cmd = DASD_ECKD_CCW_READ_TRACK;
@@ -4800,13 +4798,13 @@ static struct dasd_ccw_req *dasd_eckd_build_cp_raw(struct dasd_device *startdev,
if (use_prefix) {
prefix_LRE(ccw++, data, first_trk, last_trk, cmd, basedev,
- startdev, 1, first_offs + 1, trkcount, 0, 0);
+ startdev, 1, 0, trkcount, 0, 0);
} else {
define_extent(ccw++, data, first_trk, last_trk, cmd, basedev, 0);
ccw[-1].flags |= CCW_FLAG_CC;
data += sizeof(struct DE_eckd_data);
- locate_record_ext(ccw++, data, first_trk, first_offs + 1,
+ locate_record_ext(ccw++, data, first_trk, 0,
trkcount, cmd, basedev, 0, 0);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] s390/dasd: fix possible buffer overflow in copy_pair_show
2022-11-23 16:07 [PATCH 0/4] s390/dasd: fix out of bound access and other fixes Stefan Haberland
` (2 preceding siblings ...)
2022-11-23 16:07 ` [PATCH 3/4] s390/dasd: fix no record found for raw_track_access Stefan Haberland
@ 2022-11-23 16:07 ` Stefan Haberland
2022-11-23 17:37 ` [PATCH 0/4] s390/dasd: fix out of bound access and other fixes Jens Axboe
4 siblings, 0 replies; 6+ messages in thread
From: Stefan Haberland @ 2022-11-23 16:07 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Colin Ian King
dasd_copy_relation->entry[] array might be accessed out of bounds if the
loop does not break.
Fixes: a91ff09d39f9 ("s390/dasd: add copy pair setup")
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Reviewed-by: Jan Hoeppner <hoeppner@linux.ibm.com>
---
drivers/s390/block/dasd_devmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c
index cb83f81da416..df17f0f9cb0f 100644
--- a/drivers/s390/block/dasd_devmap.c
+++ b/drivers/s390/block/dasd_devmap.c
@@ -1954,7 +1954,7 @@ dasd_copy_pair_show(struct device *dev,
break;
}
}
- if (!copy->entry[i].primary)
+ if (i == DASD_CP_ENTRIES)
goto out;
/* print all secondary */
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] s390/dasd: fix out of bound access and other fixes
2022-11-23 16:07 [PATCH 0/4] s390/dasd: fix out of bound access and other fixes Stefan Haberland
` (3 preceding siblings ...)
2022-11-23 16:07 ` [PATCH 4/4] s390/dasd: fix possible buffer overflow in copy_pair_show Stefan Haberland
@ 2022-11-23 17:37 ` Jens Axboe
4 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2022-11-23 17:37 UTC (permalink / raw)
To: Stefan Haberland
Cc: Heiko Carstens, Vasily Gorbik, Colin Ian King, linux-s390,
Jan Hoeppner, Christian Borntraeger, linux-block
On Wed, 23 Nov 2022 17:07:15 +0100, Stefan Haberland wrote:
> please apply the following patches that:
>
> - fix an out of bound access
> - fix a possible IO error on non-IBM storage
> - fix a typo
> - improve debug data for error scenarios
>
> [...]
Applied, thanks!
[1/4] s390/dasd: Fix spelling mistake "Ivalid" -> "Invalid"
commit: 4ba5f0c36cfdda68347269c02961cd90f8443ace
[2/4] s390/dasd: increase printing of debug data payload
commit: b49e648fcca7e420c4ad670a548e19f0e8531c30
[3/4] s390/dasd: fix no record found for raw_track_access
commit: 590ce6d96d6a224b470a3862c33a483d5022bfdb
[4/4] s390/dasd: fix possible buffer overflow in copy_pair_show
commit: 7e8a05b47ba7200f333eefd19979eeb4d273ceec
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-11-23 17:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-23 16:07 [PATCH 0/4] s390/dasd: fix out of bound access and other fixes Stefan Haberland
2022-11-23 16:07 ` [PATCH 1/4] s390/dasd: Fix spelling mistake "Ivalid" -> "Invalid" Stefan Haberland
2022-11-23 16:07 ` [PATCH 2/4] s390/dasd: increase printing of debug data payload Stefan Haberland
2022-11-23 16:07 ` [PATCH 3/4] s390/dasd: fix no record found for raw_track_access Stefan Haberland
2022-11-23 16:07 ` [PATCH 4/4] s390/dasd: fix possible buffer overflow in copy_pair_show Stefan Haberland
2022-11-23 17:37 ` [PATCH 0/4] s390/dasd: fix out of bound access and other fixes Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox