[PATCH RFC 07/23] s390/dasd: let procfs copy in writes to /proc/dasd/statistics

From: Christian Brauner

Date: Mon Nov 02 2026 - 10:52:59 EST


Implement ->proc_write_buf() so procfs copies in what is written before
it pins the entry, and parse the command from that copy. Commands longer
than PAGE_SIZE - 1 bytes are rejected now instead of cut at 64k.

Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
---
drivers/s390/block/dasd_proc.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 86399427f01d..6c3bbb7dfe85 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -15,7 +15,6 @@
#include <linux/slab.h>
#include <linux/string.h>
#include <linux/seq_file.h>
-#include <linux/vmalloc.h>
#include <linux/proc_fs.h>

#include <asm/debug.h>
@@ -247,17 +246,15 @@ static int dasd_stats_proc_show(struct seq_file *m, void *v)
}

static ssize_t dasd_stats_proc_write(struct file *file,
- const char __user *user_buf, size_t user_len, loff_t *pos)
+ char *buffer, size_t user_len, loff_t *pos)
{
#ifdef CONFIG_DASD_PROFILE
- char *buffer, *str;
+ char *str;
int rc;

- if (user_len > 65536)
- user_len = 65536;
- buffer = dasd_get_user_string(user_buf, user_len);
- if (IS_ERR(buffer))
- return PTR_ERR(buffer);
+ /* strip linefeed */
+ if (user_len && buffer[user_len - 1] == '\n')
+ buffer[user_len - 1] = 0;

/* check for valid verbs */
str = skip_spaces(buffer);
@@ -296,13 +293,11 @@ static ssize_t dasd_stats_proc_write(struct file *file,
pr_info("The statistics have been reset\n");
} else
goto out_parse_error;
- vfree(buffer);
return user_len;
out_parse_error:
rc = -EINVAL;
pr_warn("%s is not a supported value for /proc/dasd/statistics\n", str);
out_error:
- vfree(buffer);
return rc;
#else
pr_warn("/proc/dasd/statistics: is not activated in this kernel\n");
@@ -312,7 +307,7 @@ out_error:

static const struct proc_ops dasd_stats_proc_ops = {
.proc_show = dasd_stats_proc_show,
- .proc_write = dasd_stats_proc_write,
+ .proc_write_buf = dasd_stats_proc_write,
};

/*

--
2.53.0