From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793821941; b=Krhld1d/5QMC4SFD0TLPW7Wd+rJmuTHLyzQgmUgrmGnY3g3nQ9/u2EG/vCI5u99pY5aF m2ZivemS21N3UvVF97+TI8XRt7eCM5zNM2vFSyMsxYHCkeoWtZHCulJfVSPcY5G+7OXm4 eX961ANve9ZQizx8HeEzlwTublDO109g0hjNFGI8f3ZjB1Vs7LBB//zHHgG0mOMkCtPCG gDaq4fkPZXAbsC/D2+9UgXGNVMbw/znOimN3c82octETXJuOQBTnOu52cKZ2MKiw3d1Mn Fzi+CmrF6766a0Hkm6HpI2TEzYkU5hjc1zqbQRRd6/XOs1fLI/b0q7jd6Dlai28fY7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793821941; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: In-Reply-To:References:MIME-Version:Content-Type:X-Mailer: X-Developer-Signature:X-Developer-Key:Content-Transfer-Encoding; bh=cbUv3n1tBnI1k6VxTZ3ZcHd/CVUe8/cnvkVP6mlO6Yc=; b=R6zqzMdpBDK1jsRwYfffo+o4fsJZh1Yo8HpMeQrujK3BCRfxtg4tE4J0jaBQ7ZU6uUMo 4y1Xjy7ke6HLpndo9qydkvUVQ+kXQGa3QzEQ/JKnMJHzaINN31CfCBFT7XHBViFEo7Xjc txOjxgFOa64/FyqPjM+q4Ptq+k4un6YGXCFHIVUPSfPVrqSX6wa7A/mgl1UTQAqgvTKif 95e4ZjRFhn6rXXkNkpia5wb7WFuh0zAxoQG91UPnoIzpomwgJTxjliq0com00KW0tpUWF w0qncbwL2g4Rf53MXtj0vMZs77ruLBL3KhxTORkE0uQ0m306pyXQRsw8UWUMpo9mgmw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=E4RqvCC3; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33F5F609528C; Wed, 4 Nov 2026 19:52:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=E4RqvCC3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84F8E1F00919; Wed, 4 Nov 2026 19:52:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793821940; bh=cbUv3n1tBnI1k6VxTZ3ZcHd/CVUe8/cnvkVP6mlO6Yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=E4RqvCC33TjJz3vsdxt6gVY1KKu7vjxv4xFkRitk2vuws+TlWcgf7WMt9M4i+MGOG 5RqBFuiDLeSXKpam105hMVUy3rhZtAy4+MdMi+B7rIZnwUE4pEJ3q3s5wEaYNPAvME KGEwRiAVWj2XYJWhDQNc2XFGUB4R7PXjlOfMJ1Wd48dn4EheS4oMJIcqJ7f5JQYPgB TSPocNG2UWf2+B18aoxxNlwBlUst0KSwQJOkoIQQZUfrJ7zcLgoYvoDopw5KBBJBn/ 8DxYWNnsXOWVRZ4gVxW8YDBrz4dlklthAuCncsHXYWBPclGriCH6RWHTj0lVCLeuJN 1w/HFHcR3YoYQ== 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 10/30] genirq/proc: let procfs copy in the affinity masks Date: Wed, 4 Nov 2026 20:52:06 +0100 Message-ID: <20261104-work-procfs-fs-v2-10-319e0f9a8aae@kernel.org> In-Reply-To: <20261104-work-procfs-fs-v2-0-319e0f9a8aae@kernel.org> References: <20261104-work-procfs-fs-v2-0-319e0f9a8aae@kernel.org> X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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=3770; i=brauner@kernel.org; h=from:subject:message-id; bh=WZPzG5+ElQbjbcTuZJJKbql/hLS5VpybW+Y2WsbSVy8=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWS97jFTOsnPsPqVcfq0tE/cqcL/tgpv8fLebHHL7+Kde 1dYK5Ofd5SyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAExEejPDf4d249cV1q+X8Xi5 lzKEZHld3P2sJ++tcMq/aU/+3/3eHMjwvy5Y6WGkzT+rx1e/T7mY5upvvFxP0ovZMPeTMvtUxrP urAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Content-Transfer-Encoding: 8bit Implement ->proc_write_buf() for smp_affinity, smp_affinity_list and default_smp_affinity so procfs copies in what is written before it pins the entry, and parse the masks from that copy. A list of CPUs can be longer than a page on large machines, so the files take as much as memdup_user_nul() could copy in before. Anything larger fails with -EINVAL instead of -ENOMEM. Signed-off-by: Christian Brauner (Amutable) --- kernel/irq/proc.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index aa3d5544cfc1..fe683457a088 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -134,8 +135,11 @@ static inline int irq_select_affinity_usr(unsigned int irq) } #endif +/* lists of CPUs can outgrow a page, take what memdup_user_nul() took */ +#define IRQ_AFFINITY_WRITE_SIZE (KMALLOC_MAX_SIZE - 1) + static ssize_t write_irq_affinity(int type, struct file *file, - const char __user *buffer, size_t count, loff_t *pos) + char *buffer, size_t count, loff_t *pos) { unsigned int irq = (int)(long)pde_data(file_inode(file)); cpumask_var_t new_value; @@ -148,9 +152,9 @@ static ssize_t write_irq_affinity(int type, struct file *file, return -ENOMEM; if (type) - err = cpumask_parselist_user(buffer, count, new_value); + err = cpulist_parse(buffer, new_value); else - err = cpumask_parse_user(buffer, count, new_value); + err = cpumask_parse(buffer, new_value); if (err) goto free_cpumask; @@ -177,25 +181,27 @@ free_cpumask: } static ssize_t irq_affinity_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *pos) + char *buffer, size_t count, loff_t *pos) { return write_irq_affinity(0, file, buffer, count, pos); } static ssize_t irq_affinity_list_proc_write(struct file *file, - const char __user *buffer, size_t count, loff_t *pos) + char *buffer, size_t count, loff_t *pos) { return write_irq_affinity(1, file, buffer, count, pos); } static const struct proc_ops irq_affinity_proc_ops = { .proc_show = irq_affinity_proc_show, - .proc_write = irq_affinity_proc_write, + .proc_write_buf = irq_affinity_proc_write, + .proc_write_size = IRQ_AFFINITY_WRITE_SIZE, }; static const struct proc_ops irq_affinity_list_proc_ops = { .proc_show = irq_affinity_list_proc_show, - .proc_write = irq_affinity_list_proc_write, + .proc_write_buf = irq_affinity_list_proc_write, + .proc_write_size = IRQ_AFFINITY_WRITE_SIZE, }; #ifdef CONFIG_GENERIC_IRQ_EFFECTIVE_AFF_MASK @@ -217,7 +223,7 @@ static int default_affinity_show(struct seq_file *m, void *v) } static ssize_t default_affinity_write(struct file *file, - const char __user *buffer, size_t count, loff_t *ppos) + char *buffer, size_t count, loff_t *ppos) { cpumask_var_t new_value; int err; @@ -225,7 +231,7 @@ static ssize_t default_affinity_write(struct file *file, if (!zalloc_cpumask_var(&new_value, GFP_KERNEL)) return -ENOMEM; - err = cpumask_parse_user(buffer, count, new_value); + err = cpumask_parse(buffer, new_value); if (err) goto out; @@ -249,7 +255,8 @@ out: static const struct proc_ops default_affinity_proc_ops = { .proc_show = default_affinity_show, - .proc_write = default_affinity_write, + .proc_write_buf = default_affinity_write, + .proc_write_size = IRQ_AFFINITY_WRITE_SIZE, }; static int irq_node_proc_show(struct seq_file *m, void *v) -- 2.53.0