Re: [PATCH] /dev/mem: Bail out upon SIGKILL when reading memory.

From: Linus Torvalds
Date: Sun Aug 25 2019 - 12:55:10 EST


On Sat, Aug 24, 2019 at 10:50 PM Tetsuo Handa
<penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote:
>
> @@ -142,7 +144,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
> sz = size_inside_page(p, count);
> cond_resched();
> err = -EINTR;
> - if (fatal_signal_pending(current))
> + if (signal_pending(current))
> goto failed;
>
> err = -EPERM;

So from a "likelihood of breaking" standpoint, I'd really like to make
sure that the "signal_pending()" checks come at the *end* of the loop.

That way, if somebody is doing a 4-byte read from MMIO, he'll never see -EINTR.

I'm specifically thinking of tools like user-space 'lspci' etc, which
I wouldn't be surprised could happen.

Also, just in case things break, I do agree with Ingo that this should
be split up into several patches.

Linus