public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] genirq: procfs: Make smp_affinity read-only for interrupts marked with IRQD_AFFINITY_MANAGED flag
@ 2024-08-20  2:09 Jeff Xie
  2024-08-23 19:16 ` Thomas Gleixner
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Xie @ 2024-08-20  2:09 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, xiehuan09, Jeff Xie

Currently, due to the interrupt subsystem introduced this commit 9c2555835bb3
("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 that
they are set to rw. System administrators are strongly complaining about this 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 changed to read-only.

Signed-off-by: Jeff Xie <jeff.xie@linux.dev>
---
 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_desc *desc)
 
 #ifdef CONFIG_SMP
 	/* create /proc/irq/<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);
 
 	/* create /proc/irq/<irq>/affinity_hint */
@@ -371,7 +375,11 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc)
 			irq_affinity_hint_proc_show, irqp);
 
 	/* create /proc/irq/<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);
 
 	proc_create_single_data("node", 0444, desc->dir, irq_node_proc_show,
--
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-25 11:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-20  2:09 [PATCH] genirq: procfs: Make smp_affinity read-only for interrupts marked with IRQD_AFFINITY_MANAGED flag Jeff Xie
2024-08-23 19:16 ` Thomas Gleixner
2024-08-24 14:54   ` jeff.xie
2024-08-25 11:05     ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox