public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] coredump: Retry writes where appropriate
@ 2009-05-31  5:33 Paul Smith
  2009-05-31 10:18 ` Alan Cox
  0 siblings, 1 reply; 36+ messages in thread
From: Paul Smith @ 2009-05-31  5:33 UTC (permalink / raw)
  To: linux-kernel
  Cc: stable, Andrew Morton, Andi Kleen, Oleg Nesterov, Roland McGrath

coredump: Retry writes where appropriate

Core dump write operations (especially to a pipe) can be incomplete due
to signal reception or possibly recoverable partial writes.

Previously any incomplete write in the ELF core dumper caused the core
dump to stop, giving short cores in these cases.  Modify the core dumper
to retry the write where appropriate.

Signed-off-by: Paul Smith <paul@mad-scientist.net>
Cc: stable@kernel.org

---

 fs/binfmt_elf.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 40381df..26b03cc 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1119,7 +1119,24 @@ out:
  */
 static int dump_write(struct file *file, const void *addr, int nr)
 {
-	return file->f_op->write(file, addr, nr, &file->f_pos) == nr;
+	const char *p = addr;
+	while (1) {
+		int r = file->f_op->write(file, p, nr, &file->f_pos);
+
+		if (likely(r == nr))
+			return 1;
+
+		if (r == -ERESTARTSYS || r == -EAGAIN || r == -EINTR)
+			/* Ignore signals during coredump. */
+			clear_thread_flag(TIF_SIGPENDING);
+		else if (r > 0) {
+			/* Partial write: try again with the rest. */
+			p += r;
+			nr -= r;
+		} else
+			/* Lose! */
+			return 0;
+	}
 }
 
 static int dump_seek(struct file *file, loff_t off)


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

end of thread, other threads:[~2009-07-07 19:41 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-31  5:33 [PATCH] coredump: Retry writes where appropriate Paul Smith
2009-05-31 10:18 ` Alan Cox
2009-05-31 14:03   ` Olivier Galibert
2009-05-31 16:31     ` Alan Cox
2009-05-31 16:49       ` Olivier Galibert
2009-05-31 17:46       ` Paul Smith
2009-05-31 16:56     ` Paul Smith
2009-06-01 16:12   ` Oleg Nesterov
2009-06-01 16:41     ` Alan Cox
2009-06-01 17:11       ` Oleg Nesterov
2009-06-01 17:46         ` Alan Cox
2009-06-01 18:23           ` Oleg Nesterov
2009-06-01 20:38             ` Roland McGrath
2009-06-01 22:32               ` Oleg Nesterov
2009-06-01 23:02                 ` Roland McGrath
2009-06-02  0:08                   ` Oleg Nesterov
2009-06-03  7:09                     ` Roland McGrath
2009-06-04  3:15                       ` Oleg Nesterov
2009-06-04 17:14                         ` Roland McGrath
2009-06-23 17:31                           ` Paul Smith
2009-06-23 19:37                             ` Oleg Nesterov
2009-07-07 19:37                               ` Oleg Nesterov
2009-06-02  8:21                 ` Alan Cox
2009-06-02 15:29                   ` Oleg Nesterov
2009-06-03  7:15                     ` Roland McGrath
2009-06-03 14:05               ` Paul Smith
2009-06-01 17:36     ` Paul Smith
2009-06-01 17:49       ` Alan Cox
2009-06-01 18:39         ` Paul Smith
2009-06-01 19:02           ` Alan Cox
2009-06-01 19:09             ` Andi Kleen
2009-06-01 19:06               ` Alan Cox
2009-06-01 19:14                 ` Andi Kleen
2009-06-01 19:51             ` Paul Smith
2009-06-01 20:20               ` Oleg Nesterov
2009-06-01 21:34               ` Alan Cox

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