Re: A bug in read operation for /dev/zero and a proposed fix.

From: Linus Torvalds
Date: Thu Jun 04 2009 - 17:06:09 EST




On Thu, 4 Jun 2009, Linus Torvalds wrote:
>
> If we want to do this for 2.6.30, though, I very much agree with the
> notion of limiting it to just fatal signals, though.

IOW, I really think the patch should look like the following, and that
this has nothing to do with OOM-killing at all.

Linus
---
drivers/char/mem.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 8f05c38..65e12bc 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -694,6 +694,9 @@ static ssize_t read_zero(struct file * file, char __user * buf,
written += chunk - unwritten;
if (unwritten)
break;
+ /* Consider changing this to just 'signal_pending()' with lots of testing */
+ if (fatal_signal_pending(current))
+ return written ? written : -EINTR;
buf += chunk;
count -= chunk;
cond_resched();
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/