From nobody Sat Feb 7 13:41:26 2026 Received: from out-176.mta0.migadu.com (out-176.mta0.migadu.com [91.218.175.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8641E18EA8 for ; Tue, 20 Aug 2024 02:09:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724119785; cv=none; b=UGtR3q0+HPMqVUGPVyZqS6GobMwtYAYJWi8DhbR+RaZlfWRGMSnjnSSVd4cKdCDA5uQDz+OjbaMHHNK4ToiPl/sF+vDjE9ofNFZlHZtBqhrUUtjPyGIfs9z805MYkD3TeegTZI7w56YVsVeNyXRP+IslWZugDuQx0hiIP2z3i5c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724119785; c=relaxed/simple; bh=/EjAw6SIVbjoOM3Noy5NGS9+qSm2/geVxGsqc0klNT4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=n//E8wEGnFpCYPhcOLB3buUD4HNbHkgLOGeE6CP+oEkDPIDUpZBC0U+ya3NqOcVdOCHhfGyDycsig6jaPZ3nEnu1AitaeG+7/V0bUf6ug6Zzaq5FsUZ+85pndCoQriAzO3Oh2MHjpn+uJLayQqT8Mjr+FEKJP11925t5Eq9Cjk0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ShD10Ec+; arc=none smtp.client-ip=91.218.175.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ShD10Ec+" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724119779; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=lvCHbg1JhDMdtUgSS3TvV3oBKMTLNMrmVInLTh4dCkg=; b=ShD10Ec+yUTBClaSyIVHIBERwSk2xQPy+ud7CticAcRNylf2MaVsDtp0sRN8+vVMIU3nN7 gHJ5Keqr8KCGDAbHqpz+iZEUnTmQKMrL/1KJJ4zJQqU5vzFUvNO7RbilCIzeNKnMaV1qAk LoxZsDojeUr4Cy8RN4jsdYNOMaSQm6g= From: Jeff Xie To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, xiehuan09@gmail.com, Jeff Xie Subject: [PATCH] genirq: procfs: Make smp_affinity read-only for interrupts marked with IRQD_AFFINITY_MANAGED flag Date: Tue, 20 Aug 2024 10:09:04 +0800 Message-Id: <20240820020904.2514189-1-jeff.xie@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Currently, due to the interrupt subsystem introduced this commit 9c2555835b= b3 ("genirq: Introduce IRQD_AFFINITY_MANAGED flag"), an error is reported when= a system administrator modifies the smp_affinity for the virtio_blk driver. For example: jeff-labs:/proc/irq/26 # echo 2 > ./smp_affinity -bash: echo: write error: Input/output error However, checking the permissions of smp_affinity/smp_affinity_list shows t= hat they are set to rw. System administrators are strongly complaining about th= is issue. jeff-labs:/proc/irq/26 # ls -l total 0 -r--r--r-- 1 root root 0 Aug 20 01:32 affinity_hint -r--r--r-- 1 root root 0 Aug 20 01:32 effective_affinity -r--r--r-- 1 root root 0 Aug 20 01:32 effective_affinity_list -r--r--r-- 1 root root 0 Aug 20 01:32 node -rw-r--r-- 1 root root 0 Aug 20 01:32 smp_affinity -rw-r--r-- 1 root root 0 Aug 20 01:32 smp_affinity_list -r--r--r-- 1 root root 0 Aug 20 01:32 spurious dr-xr-xr-x 2 root root 0 Aug 20 01:32 virtio3-req.0 Therefore, the permissions of smp_affinity/smp_affinity_list should be chan= ged to read-only. Signed-off-by: Jeff Xie --- kernel/irq/proc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c index 8cccdf40725a..4a7d572b7a8c 100644 --- a/kernel/irq/proc.c +++ b/kernel/irq/proc.c @@ -363,7 +363,11 @@ void register_irq_proc(unsigned int irq, struct irq_de= sc *desc) =20 #ifdef CONFIG_SMP /* create /proc/irq//smp_affinity */ - proc_create_data("smp_affinity", 0644, desc->dir, + if (unlikely(irqd_affinity_is_managed(&desc->irq_data))) + proc_create_data("smp_affinity", 0444, desc->dir, + &irq_affinity_proc_ops, irqp); + else + proc_create_data("smp_affinity", 0644, desc->dir, &irq_affinity_proc_ops, irqp); =20 /* create /proc/irq//affinity_hint */ @@ -371,7 +375,11 @@ void register_irq_proc(unsigned int irq, struct irq_de= sc *desc) irq_affinity_hint_proc_show, irqp); =20 /* create /proc/irq//smp_affinity_list */ - proc_create_data("smp_affinity_list", 0644, desc->dir, + if (unlikely(irqd_affinity_is_managed(&desc->irq_data))) + proc_create_data("smp_affinity_list", 0444, desc->dir, + &irq_affinity_list_proc_ops, irqp); + else + proc_create_data("smp_affinity_list", 0644, desc->dir, &irq_affinity_list_proc_ops, irqp); =20 proc_create_single_data("node", 0444, desc->dir, irq_node_proc_show, -- 2.34.1