Re: [PATCH v2] genirq: procfs: Make smp_affinity read-only for interrupts that userspace can't set

Thomas Gleixner
2024-08-26T10:55:03Z

On Sun, Aug 25 2024 at 21:19, Jeff Xie wrote:
> The kernel already knows at the time of interrupt allocation that the
> affinity cannot be controlled by userspace and therefore creating the
> file with write permissions is wrong.
>
> Therefore set the file permissions to read-only for such interrupts.
>
> Signed-off-by: Jeff Xie <jeff.xie@linux.dev>
> ---
> v2:
> - Updated the description suggested by tglx
> - Corrected the return value from -EIO to -EPERM when the userspace can't set the affinity
>
> kernel/irq/proc.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
> index 8cccdf40725a..7b3a4c92d148 100644
> --- a/kernel/irq/proc.c
> +++ b/kernel/irq/proc.c
> @@ -142,7 +142,7 @@ static ssize_t write_irq_affinity(int type, struct file *file,
> int err;
>
> if (!irq_can_set_affinity_usr(irq) || no_irq_affinity)
> - return -EIO;
> + return -EPERM;

I drop this hunk as it is unrelated to $subject. That want's to be a
separate patch. Documentation/process clearly states:

Solve only one problem per patch.

Thanks,

tglx