s390/appldata: Fix error handling in appldata_generic_handler()
PATCH 1/1 s390/appldata: Fix error handling in appldata_generic_handler()
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.
--- arch/s390/appldata/appldata_base.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/s390/appldata/appldata_base.c +8 -4
@@ -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> *******************************/
Signature · 1 line
2.53.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues.
Quoted 12 lines
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 DIAG0xDCfailed. A failed start would keepops->activeas 0, so reading the sysctl later would correctly reflect this.A failed stop would falsely set
ops->activeto 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.
Quoted 6 lines
Fix this by returning
-EIOwhenappldata_diag()failed, and only setops->activeto 0 and decrement module refcount when it succeeded on stop path.Signed-off-by Gerald Schaefer <[email protected]>
Sashiko has reviewed this patch and found no issues.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 16 lines · Gerald Schaefer
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 DIAG0xDCfailed. A failed start would keepops->activeas 0, so reading the sysctl later would correctly reflect this.A failed stop would falsely set
ops->activeto 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
-EIOwhenappldata_diag()failed, and only setops->activeto 0 and decrement module refcount when it succeeded on stop path.
Quoted 5 lines
Signed-off-by Gerald Schaefer <[email protected]>--- arch/s390/appldata/appldata_base.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Applied, thanks!