Linux s390 Architecture development
 help / color / mirror / Atom feed
* [PATCH] s390/appldata: Fix error handling in appldata_generic_handler()
@ 2026-10-21 12:04 Gerald Schaefer
  2026-10-21 12:07 ` sashiko-bot
  2026-10-21 13:16 ` Heiko Carstens
  0 siblings, 2 replies; 3+ messages in thread
From: Gerald Schaefer @ 2026-10-21 12:04 UTC (permalink / raw)
  To: linux-s390
  Cc: Heiko Carstens, Alexander Gordeev, Vasily Gorbik, Sven Schnelle,
	Christian Borntraeger

appldata_generic_handler() always returns 0 after starting or stopping
monitor recording.

So "echo {0,1} > /proc/sys/appldata/{os,mem,net_sum}" returns success even
when DIAG 0xDC failed. A failed start would keep ops->active as 0, so
reading the sysctl later would correctly reflect this.

A failed stop would falsely set ops->active to 0 and decrement module
refcount. This would allow the data gathering module to be removed, and
the data buffer to be freed, while z/VM monitor service is still collecting
data from that buffer.

Fix this by returning -EIO when appldata_diag() failed, and only set
ops->active to 0 and decrement module refcount when it succeeded on stop
path.

Cc: stable@vger.kernel.org
Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
---
 arch/s390/appldata/appldata_base.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c
index 836c51da18f4..f10b2f040cc2 100644
--- a/arch/s390/appldata/appldata_base.c
+++ b/arch/s390/appldata/appldata_base.c
@@ -360,21 +360,25 @@ appldata_generic_handler(const struct ctl_table *ctl, int write,
 			pr_err("Starting the data collection for %s "
 			       "failed with rc=%d\n", ops->name, rc);
 			module_put(ops->owner);
+			rc = -EIO;
 		} else
 			ops->active = 1;
 	} else if (!active && (ops->active == 1)) {
-		ops->active = 0;
 		rc = appldata_diag(ops->record_nr, APPLDATA_STOP_REC,
 				(unsigned long) ops->data, ops->size,
 				ops->mod_lvl);
-		if (rc != 0)
+		if (rc != 0) {
 			pr_err("Stopping the data collection for %s "
 			       "failed with rc=%d\n", ops->name, rc);
-		module_put(ops->owner);
+			rc = -EIO;
+		} else {
+			ops->active = 0;
+			module_put(ops->owner);
+		}
 	}
 	mutex_unlock(&appldata_ops_mutex);
 	module_put(ops->owner);
-	return 0;
+	return rc;
 }
 
 /*************************** /proc stuff <END> *******************************/
-- 
2.53.0


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

* Re: [PATCH] s390/appldata: Fix error handling in appldata_generic_handler()
  2026-10-21 12:04 [PATCH] s390/appldata: Fix error handling in appldata_generic_handler() Gerald Schaefer
@ 2026-10-21 12:07 ` sashiko-bot
  2026-10-21 13:16 ` Heiko Carstens
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-10-21 12:07 UTC (permalink / raw)
  To: Gerald Schaefer, linux-s390
  Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Christian Borntraeger

> appldata_generic_handler() always returns 0 after starting or stopping
> monitor recording.
> 
> So "echo {0,1} > /proc/sys/appldata/{os,mem,net_sum}" returns success even
> when DIAG 0xDC failed. A failed start would keep ops->active as 0, so
> reading the sysctl later would correctly reflect this.
> 
> A failed stop would falsely set ops->active to 0 and decrement module
> refcount. This would allow the data gathering module to be removed, and
> the data buffer to be freed, while z/VM monitor service is still collecting
> data from that buffer.
> 
> Fix this by returning -EIO when appldata_diag() failed, and only set
> ops->active to 0 and decrement module refcount when it succeeded on stop
> path.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>

Sashiko has reviewed this patch and found no issues.

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


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

* Re: [PATCH] s390/appldata: Fix error handling in appldata_generic_handler()
  2026-10-21 12:04 [PATCH] s390/appldata: Fix error handling in appldata_generic_handler() Gerald Schaefer
  2026-10-21 12:07 ` sashiko-bot
@ 2026-10-21 13:16 ` Heiko Carstens
  1 sibling, 0 replies; 3+ messages in thread
From: Heiko Carstens @ 2026-10-21 13:16 UTC (permalink / raw)
  To: Gerald Schaefer
  Cc: linux-s390, Alexander Gordeev, Vasily Gorbik, Sven Schnelle,
	Christian Borntraeger

On Wed, Oct 21, 2026 at 02:04:26PM +0200, Gerald Schaefer wrote:
> appldata_generic_handler() always returns 0 after starting or stopping
> monitor recording.
> 
> So "echo {0,1} > /proc/sys/appldata/{os,mem,net_sum}" returns success even
> when DIAG 0xDC failed. A failed start would keep ops->active as 0, so
> reading the sysctl later would correctly reflect this.
> 
> A failed stop would falsely set ops->active to 0 and decrement module
> refcount. This would allow the data gathering module to be removed, and
> the data buffer to be freed, while z/VM monitor service is still collecting
> data from that buffer.
> 
> Fix this by returning -EIO when appldata_diag() failed, and only set
> ops->active to 0 and decrement module refcount when it succeeded on stop
> path.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
> ---
>  arch/s390/appldata/appldata_base.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)

Applied, thanks!

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

end of thread, other threads:[~2026-10-21 13:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 12:04 [PATCH] s390/appldata: Fix error handling in appldata_generic_handler() Gerald Schaefer
2026-10-21 12:07 ` sashiko-bot
2026-10-21 13:16 ` Heiko Carstens

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