From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 42033606C466 for ; Wed, 4 Nov 2026 19:52:25 +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: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4jKbgr053Kz3cNp; Thu, 05 Nov 2026 06:52:24 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=172.105.4.254 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1793821943; cv=none; b=C4hD9PSLn7T8kq7PbpvUJKLTqpURnMza3OPwkSoquXhmxO+29YmXFXLSxjJGqW3SSbsDNR4KkmdTgq9WP5h7UEWy6l5VPyhNB5oDayqJDAViKclikCLhp3tUec0haMhP6q7BER5pb3ilCHIZbQquTlqD1nIqOvR+Qq4Nko+qzy9ZOf4aetXHO/jO/sDBp2cHngMCfEFKjsJG+Z4BMs+Nt8DaCdOsE5xDbTH5wIQtbK1YDhsLoeT/Pt7uR5dD/EaubhKjhXwjF8GQWDngJHZ5UUmMhrh7PTsfQitNLioZuFr2sQaRuQgadXhLPbRTI1MF1j86+8Y79v4WSJZ/mkZ9pQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1793821943; c=relaxed/relaxed; bh=cbUv3n1tBnI1k6VxTZ3ZcHd/CVUe8/cnvkVP6mlO6Yc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DhJvQ/5oBwExoPo29LbSAzjzCZQRXkSj8HPIg58Eo/2C2wbt0YDpvw1kH7G3CTEXM8+ChB2FssP9+DGeZAGoB19ol7+NK3ieN/9N4agXOO30Lp1uWkGyctlofi169YiXmDFv6nsHpCQFMM3gyuYViTDV2/ydDfcJ3LksFZH3bu0By+PkX9WUFRr1G2f5JM57X7s7JzI+nVGyCH/behi+Aqzkvg+uwQfha2k5Dk5IrCLFf0ZVszP/+BpFb+AaMv9pkZx6EfR+enx67mqXPk+qknusS2helgEy0v6OBUEM8MrdsrzNY+A/ze9IxUJ6jyZ1k0g6zFYNiNbPFSkAr0IBMQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=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; dkim-atps=neutral; spf=pass (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=brauner@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.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; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=brauner@kernel.org; receiver=lists.ozlabs.org) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4jKbgq1kFkz3cNj for ; Thu, 05 Nov 2026 06:52:23 +1100 (AEDT) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 28B1760D99; Wed, 4 Nov 2026 19:52:21 +0000 (UTC) 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: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , Precedence: list 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=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 X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, 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 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