Linux s390 Architecture development
 help / color / mirror / Atom feed
* [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT
@ 2026-11-12 10:26 Stefan Haberland
  2026-11-12 10:26 ` [PATCH 1/4] s390/dasd: Fix typo 'immediatly' -> 'immediately' Stefan Haberland
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Stefan Haberland @ 2026-11-12 10:26 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger

Hi Jens,

please apply the following DASD fixes.

 - Re-initialize the RCD buffer magic "V1.0" before every start of the
   request to fix a condition where z/VM omitted the UIT and the paths
   were wrongly reported as leading to different devices.
 - Two fixes for the BIODASDCHECKFMT ioctl, both reported by Sashiko:
   a wrong free plus a refcount leak in the dasd_eckd_build_check_tcw()
   error path, and an info leak caused by trusting the userspace-supplied
   result field.
 - A typo fix in a function name, dasd_sleep_on_immediatly(). It is a
   prerequisite for the RCD patch.


Thanks,
Stefan

Stefan Haberland (4):
  s390/dasd: Fix typo 'immediatly' -> 'immediately'
  s390/dasd: Re-initialize RCD buffer with "V1.0" before every start
  s390/dasd: Fix wrong free and refcount leak in build_check_tcw error
    path
  s390/dasd: Don't trust userspace-supplied result field in format check

 drivers/s390/block/dasd.c       |  5 ++-
 drivers/s390/block/dasd_alias.c |  2 +-
 drivers/s390/block/dasd_eckd.c  | 69 +++++++++++++--------------------
 drivers/s390/block/dasd_int.h   | 17 +++++++-
 drivers/s390/block/dasd_ioctl.c |  4 +-
 5 files changed, 50 insertions(+), 47 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/4] s390/dasd: Fix typo 'immediatly' -> 'immediately'
  2026-11-12 10:26 [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT Stefan Haberland
@ 2026-11-12 10:26 ` Stefan Haberland
  2026-11-12 10:30   ` sashiko-bot
  2026-11-12 10:26 ` [PATCH 2/4] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start Stefan Haberland
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Stefan Haberland @ 2026-11-12 10:26 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger

Fix typo in function name dasd_sleep_on_immediatly().

Suggested-by: Heiko Carstens <hca@linux.ibm.com>
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
 drivers/s390/block/dasd.c       |  4 ++--
 drivers/s390/block/dasd_alias.c |  2 +-
 drivers/s390/block/dasd_eckd.c  | 14 +++++++-------
 drivers/s390/block/dasd_int.h   |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 2ffe404b890f..d74ef737ae26 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -2576,7 +2576,7 @@ static inline int _dasd_term_running_cqr(struct dasd_device *device)
 	return rc;
 }
 
-int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
+int dasd_sleep_on_immediately(struct dasd_ccw_req *cqr)
 {
 	struct dasd_device *device;
 	int rc;
@@ -2628,7 +2628,7 @@ int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
 
 	return rc;
 }
-EXPORT_SYMBOL(dasd_sleep_on_immediatly);
+EXPORT_SYMBOL(dasd_sleep_on_immediately);
 
 /*
  * Cancels a request that was started with dasd_sleep_on_req.
diff --git a/drivers/s390/block/dasd_alias.c b/drivers/s390/block/dasd_alias.c
index 8d6c16d35c22..1ffcfcfe4565 100644
--- a/drivers/s390/block/dasd_alias.c
+++ b/drivers/s390/block/dasd_alias.c
@@ -750,7 +750,7 @@ static int reset_summary_unit_check(struct alias_lcu *lcu,
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
 
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	return rc;
 }
 
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 9d1b11020b4e..53f823a9310e 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -922,7 +922,7 @@ static int dasd_eckd_read_conf_immediately(struct dasd_device *device,
 	set_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags);
 	cqr->retries = 5;
 	cqr->callback = read_conf_cb;
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	return rc;
 }
 
@@ -6008,7 +6008,7 @@ __context_unsafe(/* Conditional locking */)
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
 
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	if (!rc)
 		clear_bit(DASD_FLAG_IS_RESERVED, &device->flags);
 
@@ -6064,7 +6064,7 @@ __context_unsafe(/* Conditional locking */)
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
 
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	if (!rc)
 		set_bit(DASD_FLAG_IS_RESERVED, &device->flags);
 
@@ -6119,7 +6119,7 @@ __context_unsafe(/* Conditional locking */)
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
 
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	if (!rc)
 		set_bit(DASD_FLAG_IS_RESERVED, &device->flags);
 
@@ -6183,7 +6183,7 @@ __context_unsafe(/* Conditional locking */)
 	cqr->status = DASD_CQR_FILLED;
 	cqr->lpm = usrparm.path_mask;
 
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	/* verify that I/O processing didn't modify the path mask */
 	if (!rc && usrparm.path_mask && (cqr->lpm != usrparm.path_mask))
 		rc = -EIO;
@@ -6815,7 +6815,7 @@ static int dasd_eckd_read_message_buffer(struct dasd_device *device,
 	cqr->block = NULL;
 	cqr->expires = 10 * HZ;
 	set_bit(DASD_CQR_VERIFY_PATH, &cqr->flags);
-	/* dasd_sleep_on_immediatly does not do complex error
+	/* dasd_sleep_on_immediately does not do complex error
 	 * recovery so clear erp flag and set retry counter to
 	 * do basic erp */
 	clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
@@ -6847,7 +6847,7 @@ static int dasd_eckd_read_message_buffer(struct dasd_device *device,
 
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
-	rc = dasd_sleep_on_immediatly(cqr);
+	rc = dasd_sleep_on_immediately(cqr);
 	if (rc == 0) {
 		prssdp = (struct dasd_psf_prssd_data *) cqr->data;
 		message_buf = (struct dasd_rssd_messages *)
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index ef4930432c09..26ecf9f47d2e 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -998,7 +998,7 @@ void dasd_schedule_device_bh(struct dasd_device *);
 void dasd_schedule_block_bh(struct dasd_block *);
 int  dasd_sleep_on(struct dasd_ccw_req *);
 int  dasd_sleep_on_queue(struct list_head *);
-int  dasd_sleep_on_immediatly(struct dasd_ccw_req *);
+int  dasd_sleep_on_immediately(struct dasd_ccw_req *);
 int  dasd_sleep_on_queue_interruptible(struct list_head *);
 int  dasd_sleep_on_interruptible(struct dasd_ccw_req *);
 void dasd_device_set_timer(struct dasd_device *, int);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/4] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start
  2026-11-12 10:26 [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT Stefan Haberland
  2026-11-12 10:26 ` [PATCH 1/4] s390/dasd: Fix typo 'immediatly' -> 'immediately' Stefan Haberland
@ 2026-11-12 10:26 ` Stefan Haberland
  2026-11-12 10:32   ` sashiko-bot
  2026-11-12 10:26 ` [PATCH 3/4] s390/dasd: Fix wrong free and refcount leak in build_check_tcw error path Stefan Haberland
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Stefan Haberland @ 2026-11-12 10:26 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger

Under z/VM the Read Configuration Data (RCD) buffer has to start with
EBCDIC "V1.0" to request the virtual device SNEQ that carries the
minidisk UIT. The request and the response share the same buffer:
CP evaluates the magic on the way out and the RCD data is written into
the same buffer on the way back.

The magic is only written when the request is built and again in
read_conf_cb() when the original request fails.

Several restart paths do not run that callback:
 - ERP use the same buffer and if the same error occurs again,
   the ERP restarts the existing ERP request;
   if a different error occurs, it adds another ERP request.
   Neither re-initializes the magic.
 - Terminated (timed out) ERP requests, killed requests and requests
   requeued after the last path was gone are restarted without it.
 - dasd_sleep_on_immediately() overwrites cqr->callback, so read_conf_cb()
   never ran for dasd_eckd_read_conf_immediately(), and its fastpath
   retries in dasd_int_handler() do not call a callback either.

If such a restart succeeds, z/VM omits the virtual device SNEQ, the UID
of that path is built without the UIT and the paths are reported as
"Not all channel paths lead to the same device" although they lead to
the same minidisk.

Every start of a request, whatever path led to it, goes through
dasd_start_IO(). Add an optional prepare_io function to the request
that dasd_start_IO() calls before every start of the request and of
its ERP requests, and use it to write the magic for RCD requests.

The ERP handling stays unchanged. read_conf_cb() is no longer needed
and is removed, which also gets rid of its memset() that only cleared
a single byte.

Fixes: 5915a873fcb1 ("[S390] dasd: re-initialize read_conf buffer for retries")
Cc: stable@vger.kernel.org
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
 drivers/s390/block/dasd.c      |  1 +
 drivers/s390/block/dasd_eckd.c | 52 ++++++++++++----------------------
 drivers/s390/block/dasd_int.h  | 15 ++++++++++
 3 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index d74ef737ae26..3a55c937d0d6 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -1396,6 +1396,7 @@ int dasd_start_IO(struct dasd_ccw_req *cqr)
 		cqr->status = DASD_CQR_ERROR;
 		return -EIO;
 	}
+	dasd_start_IO_prepare(cqr);
 	cqr->startclk = get_tod_clock();
 	cqr->starttime = jiffies;
 	cqr->retries--;
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index 53f823a9310e..efaf117e39f4 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -845,20 +845,29 @@ static int dasd_eckd_compare_path_uid(struct dasd_device *device,
 	return memcmp(&device_uid, &path_uid, sizeof(struct dasd_uid));
 }
 
+/*
+ * The RCD buffer has to start with EBCDIC "V1.0" to show support for
+ * virtual device SNEQ. The RCD data is written into the same buffer, so
+ * a failed attempt may already have overwritten the magic. Re-initialize
+ * it before every start, including restarts by ERP requests.
+ */
+static void dasd_eckd_rcd_prepare_io(struct dasd_ccw_req *cqr)
+{
+	struct ccw1 *ccw = cqr->cpaddr;
+	__u8 *rcd_buffer = dma32_to_virt(ccw->cda);
+
+	rcd_buffer[0] = 0xE5;
+	rcd_buffer[1] = 0xF1;
+	rcd_buffer[2] = 0x4B;
+	rcd_buffer[3] = 0xF0;
+}
+
 static void dasd_eckd_fill_rcd_cqr(struct dasd_device *device,
 				   struct dasd_ccw_req *cqr,
 				   __u8 *rcd_buffer,
 				   __u8 lpm)
 {
 	struct ccw1 *ccw;
-	/*
-	 * buffer has to start with EBCDIC "V1.0" to show
-	 * support for virtual device SNEQ
-	 */
-	rcd_buffer[0] = 0xE5;
-	rcd_buffer[1] = 0xF1;
-	rcd_buffer[2] = 0x4B;
-	rcd_buffer[3] = 0xF0;
 
 	ccw = cqr->cpaddr;
 	ccw->cmd_code = DASD_ECKD_CCW_RCD;
@@ -875,33 +884,10 @@ static void dasd_eckd_fill_rcd_cqr(struct dasd_device *device,
 	cqr->retries = 256;
 	cqr->buildclk = get_tod_clock();
 	cqr->status = DASD_CQR_FILLED;
+	cqr->prepare_io = dasd_eckd_rcd_prepare_io;
 	set_bit(DASD_CQR_VERIFY_PATH, &cqr->flags);
 }
 
-/*
- * Wakeup helper for read_conf
- * if the cqr is not done and needs some error recovery
- * the buffer has to be re-initialized with the EBCDIC "V1.0"
- * to show support for virtual device SNEQ
- */
-static void read_conf_cb(struct dasd_ccw_req *cqr, void *data)
-{
-	struct ccw1 *ccw;
-	__u8 *rcd_buffer;
-
-	if (cqr->status !=  DASD_CQR_DONE) {
-		ccw = cqr->cpaddr;
-		rcd_buffer = dma32_to_virt(ccw->cda);
-		memset(rcd_buffer, 0, sizeof(*rcd_buffer));
-
-		rcd_buffer[0] = 0xE5;
-		rcd_buffer[1] = 0xF1;
-		rcd_buffer[2] = 0x4B;
-		rcd_buffer[3] = 0xF0;
-	}
-	dasd_wakeup_cb(cqr, data);
-}
-
 static int dasd_eckd_read_conf_immediately(struct dasd_device *device,
 					   struct dasd_ccw_req *cqr,
 					   __u8 *rcd_buffer,
@@ -921,7 +907,6 @@ static int dasd_eckd_read_conf_immediately(struct dasd_device *device,
 	clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
 	set_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags);
 	cqr->retries = 5;
-	cqr->callback = read_conf_cb;
 	rc = dasd_sleep_on_immediately(cqr);
 	return rc;
 }
@@ -959,7 +944,6 @@ static int dasd_eckd_read_conf_lpm(struct dasd_device *device,
 		goto out_error;
 	}
 	dasd_eckd_fill_rcd_cqr(device, cqr, rcd_buf, lpm);
-	cqr->callback = read_conf_cb;
 	ret = dasd_sleep_on(cqr);
 	/*
 	 * on success we update the user input parms
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
index 26ecf9f47d2e..53c450036fe1 100644
--- a/drivers/s390/block/dasd_int.h
+++ b/drivers/s390/block/dasd_int.h
@@ -147,6 +147,8 @@ struct dasd_ccw_req {
 	void *data;			/* pointer to data area */
 	struct irb irb;			/* device status in case of an error */
 	struct dasd_ccw_req *refers;	/* ERP-chain queueing. */
+	/* optional prepare function called before every start_io, must not sleep */
+	void (*prepare_io)(struct dasd_ccw_req *cqr);
 	void *function; 		/* originating ERP action */
 	void *mem_chunk;
 
@@ -892,6 +894,19 @@ static inline void *dasd_get_callback_data(struct dasd_ccw_req *cqr)
 	return cqr->callback_data;
 }
 
+/*
+ * Walk down the ERP chain to the original CQR and call its
+ * prepare_io function if set.
+ */
+static inline void dasd_start_IO_prepare(struct dasd_ccw_req *cqr)
+{
+	/* ERP requests use the prepare function of the original request */
+	while (cqr->refers)
+		cqr = cqr->refers;
+	if (cqr->prepare_io)
+		cqr->prepare_io(cqr);
+}
+
 static inline bool dasd_req_conflict(struct dasd_ccw_req *cqr1,
 				     struct dasd_ccw_req *cqr2)
 {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/4] s390/dasd: Fix wrong free and refcount leak in build_check_tcw error path
  2026-11-12 10:26 [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT Stefan Haberland
  2026-11-12 10:26 ` [PATCH 1/4] s390/dasd: Fix typo 'immediatly' -> 'immediately' Stefan Haberland
  2026-11-12 10:26 ` [PATCH 2/4] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start Stefan Haberland
@ 2026-11-12 10:26 ` Stefan Haberland
  2026-11-12 10:43   ` sashiko-bot
  2026-11-12 10:26 ` [PATCH 4/4] s390/dasd: Don't trust userspace-supplied result field in format check Stefan Haberland
  2026-11-12 16:18 ` [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT Jens Axboe
  4 siblings, 1 reply; 10+ messages in thread
From: Stefan Haberland @ 2026-11-12 10:26 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger

dasd_eckd_build_check_tcw() allocates its request with
dasd_fmalloc_request(), but its out_err path frees it with
dasd_sfree_request(). The latter uses a different pool and therefor,
leading to invalid pointer arithmetic and a crash.
Use the matching dasd_ffree_request() instead.

The same error path also leaves start_priv->count incremented
without ever decrementing it again.
This leaks a permanent reference on every build failure.
Decrement it before freeing the request.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260722103704.1709668-1-sth@linux.ibm.com
Fixes: 8fd575200db5 ("s390/dasd: Add new ioctl BIODASDCHECKFMT")
Cc: stable@vger.kernel.org #4.7
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
 drivers/s390/block/dasd_eckd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
index efaf117e39f4..7e60d5b3b343 100644
--- a/drivers/s390/block/dasd_eckd.c
+++ b/drivers/s390/block/dasd_eckd.c
@@ -2764,7 +2764,8 @@ dasd_eckd_build_check_tcw(struct dasd_device *base, struct format_data_t *fdata,
 	return cqr;
 
 out_err:
-	dasd_sfree_request(cqr, startdev);
+	start_priv->count--;
+	dasd_ffree_request(cqr, startdev);
 
 	return ERR_PTR(rc);
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/4] s390/dasd: Don't trust userspace-supplied result field in format check
  2026-11-12 10:26 [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT Stefan Haberland
                   ` (2 preceding siblings ...)
  2026-11-12 10:26 ` [PATCH 3/4] s390/dasd: Fix wrong free and refcount leak in build_check_tcw error path Stefan Haberland
@ 2026-11-12 10:26 ` Stefan Haberland
  2026-11-12 10:34   ` sashiko-bot
  2026-11-12 16:18 ` [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT Jens Axboe
  4 siblings, 1 reply; 10+ messages in thread
From: Stefan Haberland @ 2026-11-12 10:26 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger

BIODASDCHECKFMT used to copy the entire format_check_t struct from
userspace, including the result/unit/rec/num_records/blksize/
key_length fields that are output fields only.
dasd_eckd_format_evaluate_tracks() relies on cdata->result being zero
to decide whether to apply an index correction (i--/pos--) after a
successful check. A caller that pre-sets result to a non-zero value
can suppress that correction, leaving pos advanced past the last valid
entry; the (partially out-of-bounds) fmt_buffer[pos] fields are then
copied back to userspace, leaking heap contents.

Only expect is an Input field; copy just that member in and zero
the rest of cdata.

Fixes: 8fd575200db5 ("s390/dasd: Add new ioctl BIODASDCHECKFMT")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260722103704.1709668-1-sth@linux.ibm.com
Cc: stable@vger.kernel.org #4.7
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
---
 drivers/s390/block/dasd_ioctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/s390/block/dasd_ioctl.c b/drivers/s390/block/dasd_ioctl.c
index e5b8b413f5ab..2f2ec2bea333 100644
--- a/drivers/s390/block/dasd_ioctl.c
+++ b/drivers/s390/block/dasd_ioctl.c
@@ -303,7 +303,9 @@ static int dasd_ioctl_check_format(struct block_device *bdev, void __user *argp)
 		goto out_err;
 	}
 
-	if (copy_from_user(&cdata, argp, sizeof(cdata))) {
+	/* copy only input fields, clear the rest */
+	memset(&cdata, 0, sizeof(cdata));
+	if (copy_from_user(&cdata.expect, argp, sizeof(cdata.expect))) {
 		rc = -EFAULT;
 		goto out_err;
 	}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/4] s390/dasd: Fix typo 'immediatly' -> 'immediately'
  2026-11-12 10:26 ` [PATCH 1/4] s390/dasd: Fix typo 'immediatly' -> 'immediately' Stefan Haberland
@ 2026-11-12 10:30   ` sashiko-bot
  0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-11-12 10:30 UTC (permalink / raw)
  To: Stefan Haberland
  Cc: linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger

> Fix typo in function name dasd_sleep_on_immediatly().
> 
> Suggested-by: Heiko Carstens <hca@linux.ibm.com>
> Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
> Signed-off-by: Stefan Haberland <sth@linux.ibm.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112102608.1057852-1-sth@linux.ibm.com?part=1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/4] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start
  2026-11-12 10:26 ` [PATCH 2/4] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start Stefan Haberland
@ 2026-11-12 10:32   ` sashiko-bot
  0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-11-12 10:32 UTC (permalink / raw)
  To: Stefan Haberland
  Cc: linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger

> Under z/VM the Read Configuration Data (RCD) buffer has to start with
> EBCDIC "V1.0" to request the virtual device SNEQ that carries the
> minidisk UIT. The request and the response share the same buffer:
> CP evaluates the magic on the way out and the RCD data is written into
> the same buffer on the way back.
> 
> The magic is only written when the request is built and again in
> read_conf_cb() when the original request fails.
> 
> Several restart paths do not run that callback:
>  - ERP use the same buffer and if the same error occurs again,
>    the ERP restarts the existing ERP request;
>    if a different error occurs, it adds another ERP request.
>    Neither re-initializes the magic.
>  - Terminated (timed out) ERP requests, killed requests and requests
> [ ... ]
> 
> Fixes: 5915a873fcb1 ("[S390] dasd: re-initialize read_conf buffer for retries")
> Cc: stable@vger.kernel.org
> Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
> Signed-off-by: Stefan Haberland <sth@linux.ibm.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112102608.1057852-1-sth@linux.ibm.com?part=2


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 4/4] s390/dasd: Don't trust userspace-supplied result field in format check
  2026-11-12 10:26 ` [PATCH 4/4] s390/dasd: Don't trust userspace-supplied result field in format check Stefan Haberland
@ 2026-11-12 10:34   ` sashiko-bot
  0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-11-12 10:34 UTC (permalink / raw)
  To: Stefan Haberland
  Cc: linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger

> BIODASDCHECKFMT used to copy the entire format_check_t struct from
> userspace, including the result/unit/rec/num_records/blksize/
> key_length fields that are output fields only.
> dasd_eckd_format_evaluate_tracks() relies on cdata->result being zero
> to decide whether to apply an index correction (i--/pos--) after a
> successful check. A caller that pre-sets result to a non-zero value
> can suppress that correction, leaving pos advanced past the last valid
> entry; the (partially out-of-bounds) fmt_buffer[pos] fields are then
> copied back to userspace, leaking heap contents.
> 
> Only expect is an Input field; copy just that member in and zero
> the rest of cdata.
> 
> Fixes: 8fd575200db5 ("s390/dasd: Add new ioctl BIODASDCHECKFMT")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260722103704.1709668-1-sth@linux.ibm.com
> Cc: stable@vger.kernel.org #4.7
> Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
> Signed-off-by: Stefan Haberland <sth@linux.ibm.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112102608.1057852-1-sth@linux.ibm.com?part=4


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/4] s390/dasd: Fix wrong free and refcount leak in build_check_tcw error path
  2026-11-12 10:26 ` [PATCH 3/4] s390/dasd: Fix wrong free and refcount leak in build_check_tcw error path Stefan Haberland
@ 2026-11-12 10:43   ` sashiko-bot
  0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-11-12 10:43 UTC (permalink / raw)
  To: Stefan Haberland
  Cc: linux-s390, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] s390/dasd: inaccurate Fixes tag and crash description in commit
  message
--

commit b485d08acd9f888238bf37617a7cb2fffa1637cc
Author: Stefan Haberland <sth@linux.ibm.com>

> s390/dasd: Fix wrong free and refcount leak in build_check_tcw error path
>
> dasd_eckd_build_check_tcw() allocates its request with
> dasd_fmalloc_request(), but its out_err path frees it with
> dasd_sfree_request(). The latter uses a different pool and therefor,
> leading to invalid pointer arithmetic and a crash.
> Use the matching dasd_ffree_request() instead.
>
> The same error path also leaves start_priv->count incremented
> without ever decrementing it again.
> This leaks a permanent reference on every build failure.
> Decrement it before freeing the request.
>
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://sashiko.dev/#/patchset/20260722103704.1709668-1-sth@linux.ibm.com
> Fixes: 8fd575200db5 ("s390/dasd: Add new ioctl BIODASDCHECKFMT")
> Cc: stable@vger.kernel.org #4.7
> Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
> Signed-off-by: Stefan Haberland <sth@linux.ibm.com>

[Severity: Low]
Are the Fixes tag, the #4.7 stable hint, and the crash description in the
commit message accurate?

Commit 8fd575200db5 ("s390/dasd: Add new ioctl BIODASDCHECKFMT") introduced
the missing start_priv->count decrement, but it paired dasd_smalloc_request()
with dasd_sfree_request().  Commit 5e2b17e712cf ("s390/dasd: Add dynamic
formatting support for ESE volumes") in v4.18 introduced
dasd_fmalloc_request() and dasd_ffree_request() and switched
dasd_eckd_build_check_tcw() to dasd_fmalloc_request(), so backporting this
patch to v4.7..v4.17 will fail to build, and this commit should also carry:

  Fixes: 5e2b17e712cf ("s390/dasd: Add dynamic formatting support for ESE volumes")

Also, since commit 9cebfced1324 ("s390/dasd: Add infrastructure for ESE
full-track write"), dasd_sfree_request() checks cqr->mem_chunk and frees
requests with a NULL mem_chunk from device->ese_chunks rather than crashing:

drivers/s390/block/dasd.c:dasd_sfree_request() {
    ...
	if (cqr->mem_chunk)
		dasd_free_chunk(&device->ccw_chunks, cqr->mem_chunk);
	else
		dasd_free_chunk(&device->ese_chunks, cqr);
    ...
}

So the invalid pointer arithmetic and crash only occur on kernels between
5e2b17e712cf ("s390/dasd: Add dynamic formatting support for ESE volumes")
and 9cebfced1324 ("s390/dasd: Add infrastructure for ESE full-track write").

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112102608.1057852-1-sth@linux.ibm.com?part=3

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT
  2026-11-12 10:26 [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT Stefan Haberland
                   ` (3 preceding siblings ...)
  2026-11-12 10:26 ` [PATCH 4/4] s390/dasd: Don't trust userspace-supplied result field in format check Stefan Haberland
@ 2026-11-12 16:18 ` Jens Axboe
  4 siblings, 0 replies; 10+ messages in thread
From: Jens Axboe @ 2026-11-12 16:18 UTC (permalink / raw)
  To: Stefan Haberland
  Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
	Vasily Gorbik, Christian Borntraeger


On Thu, 12 Nov 2026 11:26:04 +0100, Stefan Haberland wrote:
> please apply the following DASD fixes.
> 
>  - Re-initialize the RCD buffer magic "V1.0" before every start of the
>    request to fix a condition where z/VM omitted the UIT and the paths
>    were wrongly reported as leading to different devices.
>  - Two fixes for the BIODASDCHECKFMT ioctl, both reported by Sashiko:
>    a wrong free plus a refcount leak in the dasd_eckd_build_check_tcw()
>    error path, and an info leak caused by trusting the userspace-supplied
>    result field.
>  - A typo fix in a function name, dasd_sleep_on_immediatly(). It is a
>    prerequisite for the RCD patch.
> 
> [...]

Applied, thanks!

[1/4] s390/dasd: Fix typo 'immediatly' -> 'immediately'
      commit: ae6f19236b5ae4eef4df2780d51bee19add0eba8
[2/4] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start
      commit: 25cdc1f63227a1ea69a1ec823a8a860e33299169
[3/4] s390/dasd: Fix wrong free and refcount leak in build_check_tcw error path
      commit: df56f7a6c20a5eb2794c0a7391bde50ba7c8c54b
[4/4] s390/dasd: Don't trust userspace-supplied result field in format check
      commit: 7cc2dda4f7aaf596c1796184649007151ff98f8d

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-12 16:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-12 10:26 [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT Stefan Haberland
2026-11-12 10:26 ` [PATCH 1/4] s390/dasd: Fix typo 'immediatly' -> 'immediately' Stefan Haberland
2026-11-12 10:30   ` sashiko-bot
2026-11-12 10:26 ` [PATCH 2/4] s390/dasd: Re-initialize RCD buffer with "V1.0" before every start Stefan Haberland
2026-11-12 10:32   ` sashiko-bot
2026-11-12 10:26 ` [PATCH 3/4] s390/dasd: Fix wrong free and refcount leak in build_check_tcw error path Stefan Haberland
2026-11-12 10:43   ` sashiko-bot
2026-11-12 10:26 ` [PATCH 4/4] s390/dasd: Don't trust userspace-supplied result field in format check Stefan Haberland
2026-11-12 10:34   ` sashiko-bot
2026-11-12 16:18 ` [PATCH 0/4] s390/dasd: fixes for RCD retry and BIODASDCHECKFMT Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox