From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13A8B60C21BC for ; Wed, 4 Nov 2026 19:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=lPRUInfb; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nBYfqhzO DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc: To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=0F908CJPgWsUmGeEXwOdb+LqVbJ68uHDJ1pDvsTQFww=; b=lPRUInfbpq/sd4 +E/hxJ1rDqJ22kokCZqq/NBSO35OHqcP1cbzvXALTyB5K1UoH6XQdSwhHbyJrmSKfimLZc3p1ZNp5 00m8edQRSkW2QyXRoM6YRW2Crp7IWoGvM38jBJ+FuIxhVj0BfJRrphzHJgjV5VdOBZXYebWt0sasU LDz3V5kDUoBN4hfq03hosxbVdBh4AW/HG41UEdlCUghObwA8zkzWuCQNnJPGHdmohG9Zc9/rvCwDU DCUfNjjXUFeb0m1+75I9Nk31SCOSVmCu+Tk054GVKaRErczvr8o84ucKnpCq4h4X5JK6lnf9z/158 omhqxaxI7aUsakVoHGKg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOguX-00000006jYC-3OSn; Wed, 04 Nov 2026 19:44:41 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xOguW-00000006jXo-2uiL; Wed, 04 Nov 2026 19:44:40 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 1FE1F60F1A; Wed, 4 Nov 2026 19:44:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72EC61F00A17; Wed, 4 Nov 2026 19:44:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793821479; bh=0F908CJPgWsUmGeEXwOdb+LqVbJ68uHDJ1pDvsTQFww=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nBYfqhzOfWIGHsy8c53G5+e95/eOlSF+s0+PYDPiLShDcgF0zVxjVzadNTSbzeGPS Gev4jrZfOjt5GDc4cXiN0YSRT4TEvVxeJ2FuLYhPV1dedrvI3+Pu2yeGrj82/WNN7U zCQG6VqNrlF0Qr0UfEw+wC6aUxsz8RLux0n+F+FKqEtWOUz0g4EnG8ntHPfCxNd+jn UZguQOMxrmrHjsx8VQXG8JjtzywqCzawniFug93OojMezHRM7T0Hoqz+lfYQibeFF9 cZni/cwUgquBfE2XXxNA/dGO3y/WvuRn97YHSCiffyy1RTxslKI+LzMpvfOv8McSjk yCxQsEs373mbw== From: Christian Brauner To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , Jann Horn , Josef Bacik , Chris Mason , Jeff Layton , NeilBrown , Eric Dumazet , Thomas Gleixner , Al Viro , Jonathan Corbet , Christoph Hellwig , Greg Kroah-Hartman , Joel Granados , Kees Cook , Jan Kara , Jan Kara , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-s390@vger.kernel.org, linux-scsi@vger.kernel.org, linux-um@lists.infradead.org, linux-wireless@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, netdev@vger.kernel.org, ntfs3@lists.linux.dev, platform-driver-x86@vger.kernel.org, coreteam@netfilter.org, kexec@lists.infradead.org, linux-pci@vger.kernel.org, linux-sound@vger.kernel.org, netfilter-devel@vger.kernel.org, dri-devel@lists.freedesktop.org, ibm-acpi-devel@lists.sourceforge.net, jfs-discussion@lists.sourceforge.net, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-cifs@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-mm@kvack.org, linux-sh@vger.kernel.org, linux-usb@vger.kernel.org, samba-technical@lists.samba.org, sparclinux@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-doc@vger.kernel.org, linux-serial@vger.kernel.org, linux-atm-general@lists.sourceforge.net, Takashi Iwai , linux-input@vger.kernel.org, linux-raid@vger.kernel.org, linux-ext4@vger.kernel.org, linux-modules@vger.kernel.org, linux-debuggers@vger.kernel.org, "Christian Brauner (Amutable)" , Chuck Lever Subject: [PATCH RESEND v2 09/26] s390/cio: let procfs copy in writes Date: Wed, 4 Nov 2026 20:44:25 +0100 Message-ID: <20261104-work-procfs-drivers-v2-9-245e54e87116@kernel.org> In-Reply-To: <20261104-work-procfs-drivers-v2-0-245e54e87116@kernel.org> References: <20261104-work-procfs-drivers-v2-0-245e54e87116@kernel.org> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3388; i=brauner@kernel.org; h=from:subject:message-id; bh=lEA79OgzD1RbbuI3leV0mq7RtW4au2plI+2F9ffJvH8=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWS97qo1Prvbv2jWnmkmH6pDufs/6rfzTKnoEu5evTnGy 2WLm6V9RykLgxgXg6yYIotDu0m43HKeis1GmRowc1iZQIYwcHEKwERk/zIybEjl+VB/KeuDnbef yim235O4L5f4ub8sDT0fcZyRo2NjBCPDPrXc7kQ1lzbL+Yvap+65J7Y7TdL2ycNNJx9pnjvSsWU KKwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Content-Transfer-Encoding: 8bit X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" X-Spam-Status: No, score=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 Implement ->proc_write_buf() for cio_ignore and cio_settle so procfs copies in what is written before it pins the entry. cio_ignore parses the list from that copy, up to the first NUL like strncpy_from_user() handed it to it before. Writes larger than 64k still come up short, now through PROC_ENTRY_SHORT_WRITES. Writes to cio_settle larger than PAGE_SIZE - 1 bytes fail with -EINVAL now, it never looked at what was written. Signed-off-by: Christian Brauner (Amutable) --- drivers/s390/cio/blacklist.c | 33 ++++++++++----------------------- drivers/s390/cio/css.c | 4 ++-- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/drivers/s390/cio/blacklist.c b/drivers/s390/cio/blacklist.c index 4e02f78f6102..1ec7915be6b3 100644 --- a/drivers/s390/cio/blacklist.c +++ b/drivers/s390/cio/blacklist.c @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include #include @@ -355,39 +355,24 @@ cio_ignore_proc_seq_show(struct seq_file *s, void *it) } static ssize_t -cio_ignore_write(struct file *file, const char __user *user_buf, +cio_ignore_write(struct file *file, char *buf, size_t user_len, loff_t *offset) { - char *buf; - ssize_t rc, ret, i; + ssize_t ret, i; if (*offset) return -EINVAL; - if (user_len > 65536) - user_len = 65536; - buf = vzalloc(user_len + 1); /* maybe better use the stack? */ - if (buf == NULL) - return -ENOMEM; - if (strncpy_from_user (buf, user_buf, user_len) < 0) { - rc = -EFAULT; - goto out_free; - } - - i = user_len - 1; + /* the parser never saw what follows a NUL */ + i = strnlen(buf, user_len) - 1; while ((i >= 0) && (isspace(buf[i]) || (buf[i] == 0))) { buf[i] = '\0'; i--; } ret = blacklist_parse_proc_parameters(buf); if (ret) - rc = ret; - else - rc = user_len; - -out_free: - vfree (buf); - return rc; + return ret; + return user_len; } static const struct seq_operations cio_ignore_proc_seq_ops = { @@ -398,9 +383,11 @@ static const struct seq_operations cio_ignore_proc_seq_ops = { }; static const struct proc_ops cio_ignore_proc_ops = { + .proc_flags = PROC_ENTRY_SHORT_WRITES, .proc_seq_ops = &cio_ignore_proc_seq_ops, .proc_state_size = sizeof(struct ccwdev_iter), - .proc_write = cio_ignore_write, + .proc_write_buf = cio_ignore_write, + .proc_write_size = SZ_64K, }; static int diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c index 54b8b8639694..efd3df3e90ba 100644 --- a/drivers/s390/cio/css.c +++ b/drivers/s390/cio/css.c @@ -1278,7 +1278,7 @@ static int __init channel_subsystem_init_sync(void) subsys_initcall_sync(channel_subsystem_init_sync); #ifdef CONFIG_PROC_FS -static ssize_t cio_settle_write(struct file *file, const char __user *buf, +static ssize_t cio_settle_write(struct file *file, char *buf, size_t count, loff_t *ppos) { int ret; @@ -1292,7 +1292,7 @@ static ssize_t cio_settle_write(struct file *file, const char __user *buf, static const struct proc_ops cio_settle_proc_ops = { .proc_open = nonseekable_open, - .proc_write = cio_settle_write, + .proc_write_buf = cio_settle_write, }; static int __init cio_settle_init(void) -- 2.53.0