Skip to contentSkip to conversation

s390/dasd: fix kernel panic with statistics

PATCH Applied Stefan Haberland 2 participants 5 messages Oct 25, 2023 – Nov 20, 2023

Subsystems (3)
lore
Share & tools
lore

Stefan Haberland

author maintainer
#0 lore raw

cover s390/dasd: fix kernel panic with statistics

Hi Jens,

please apply the following patch for the upcomming merge window that fixes a kernel panic that can be triggered by using dasd statistics. Also there is a typo fix for a comment.

Thanks.

Jan Höppner (1):
s390/dasd: protect device queue against concurrent access

Muhammad Muzammil (1):
s390/dasd: resolve spelling mistake

 drivers/s390/block/dasd.c     | 24 +++++++++++++-----------
 drivers/s390/block/dasd_int.h |  2 +-
 2 files changed, 14 insertions(+), 12 deletions(-)
Signature · 1 line
2.39.2
author maintainer
#1 lore raw

PATCH 1/2 s390/dasd: resolve spelling mistake

From: Muhammad Muzammil <[email protected]>

resolve typing mistake from pimary to primary

---
 drivers/s390/block/dasd_int.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/block/dasd_int.h +1 -1
index 8a4dbe9d7741..acdaba55b041 100644
@@ -283,7 +283,7 @@ struct dasd_pprc_dev_info {
 	__u8 secondary;		/* 7       Secondary device address */
 	__u16 pprc_id;		/* 8-9     Peer-to-Peer Remote Copy ID */
 	__u8 reserved2[12];	/* 10-21   reserved */
-	__u16 prim_cu_ssid;	/* 22-23   Pimary Control Unit SSID */
+	__u16 prim_cu_ssid;	/* 22-23   Primary Control Unit SSID */
 	__u8 reserved3[12];	/* 24-35   reserved */
 	__u16 sec_cu_ssid;	/* 36-37   Secondary Control Unit SSID */
 	__u8 reserved4[90];	/* 38-127  reserved */
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH 2/2 s390/dasd: protect device queue against concurrent access

In reply to Stefan Haberland

From: Jan Höppner <[email protected]>

In dasd_profile_start() the amount of requests on the device queue are counted. The access to the device queue is unprotected against concurrent access. With a lot of parallel I/O, especially with alias devices enabled, the device queue can change while dasd_profile_start() is accessing the queue. In the worst case this leads to a kernel panic due to incorrect pointer accesses.

Fix this by taking the device lock before accessing the queue and counting the requests. Additionally the check for a valid profile data pointer can be done earlier to avoid unnecessary locking in a hot path.

Fixes 4fa52aa7a82f ("[S390] dasd: add enhanced DASD statistics interface")
---
 drivers/s390/block/dasd.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/s390/block/dasd.c +13 -11
index 215597f73be4..5b11ee923457 100644
@@ -674,18 +674,20 @@ static void dasd_profile_start(struct dasd_block *block,
 	 * we count each request only once.
 	 */
 	device = cqr->startdev;
-	if (device->profile.data) {
-		counter = 1; /* request is not yet queued on the start device */
-		list_for_each(l, &device->ccw_queue)
-			if (++counter >= 31)
-				break;
-	}
+	if (!device->profile.data)
+		return;
+
+	spin_lock(get_ccwdev_lock(device->cdev));
+	counter = 1; /* request is not yet queued on the start device */
+	list_for_each(l, &device->ccw_queue)
+		if (++counter >= 31)
+			break;
+	spin_unlock(get_ccwdev_lock(device->cdev));
+
 	spin_lock(&device->profile.lock);
-	if (device->profile.data) {
-		device->profile.data->dasd_io_nr_req[counter]++;
-		if (rq_data_dir(req) == READ)
-			device->profile.data->dasd_read_nr_req[counter]++;
-	}
+	device->profile.data->dasd_io_nr_req[counter]++;
+	if (rq_data_dir(req) == READ)
+		device->profile.data->dasd_read_nr_req[counter]++;
 	spin_unlock(&device->profile.lock);
 }
 
Signature · 1 line
2.39.2
author maintainer
#3 lore raw
In reply to Stefan Haberland

Am 25.10.23 um 15:24 schrieb Stefan Haberland:

Quoted 11 lines

Hi Jens,

please apply the following patch for the upcomming merge window that fixes a kernel panic that can be triggered by using dasd statistics. Also there is a typo fix for a comment.

Thanks.

Jan Höppner (1):
s390/dasd: protect device queue against concurrent access

Quoted 7 lines

Muhammad Muzammil (1):
s390/dasd: resolve spelling mistake

  drivers/s390/block/dasd.c     | 24 +++++++++++++-----------
  drivers/s390/block/dasd_int.h |  2 +-
  2 files changed, 14 insertions(+), 12 deletions(-)

Hi Jens,

polite ping.

maintainer Applied
#4 lore raw
In reply to Stefan Haberland
Quoted 10 lines · Stefan Haberland

please apply the following patch for the upcomming merge window that fixes a kernel panic that can be triggered by using dasd statistics. Also there is a typo fix for a comment.

Thanks.

Jan Höppner (1):
s390/dasd: protect device queue against concurrent access

[...]

Applied, thanks!

[1/2] s390/dasd: resolve spelling mistake

      commit: 5029c5e4f20d8d6b41cefbde4b3eeadaec4662c6
[2/2] s390/dasd: protect device queue against concurrent access
      commit: db46cd1e0426f52999d50fa72cfa97fa39952885

Best regards,

Signature · 1 line
Jens Axboe