Page MenuHomeFreeBSD

D9233.1792523234.diff
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

D9233.1792523234.diff

Index: sys/kern/imgact_elf.c
===================================================================
--- sys/kern/imgact_elf.c
+++ sys/kern/imgact_elf.c
@@ -1202,7 +1202,14 @@
while (len > 0) {
chunk_len = MIN(len, CORE_BUF_SIZE);
- copyin(base, buf, chunk_len);
+
+ /*
+ * We can get EFAULT error here.
+ * In that case zero out the current chunk of the segment.
+ */
+ error = copyin(base, buf, chunk_len);
+ if (error != 0)
+ bzero(buf, chunk_len);
error = gzio_write(p->gzs, buf, chunk_len);
if (error != 0)
break;
@@ -1235,12 +1242,33 @@
core_output(void *base, size_t len, off_t offset, struct coredump_params *p,
void *tmpbuf)
{
+ static uint32_t zero;
+ int error;
#ifdef GZIO
if (p->gzs != NULL)
return (compress_chunk(p, base, tmpbuf, len));
#endif
- return (core_write(p, base, len, offset, UIO_USERSPACE));
+ /*
+ * EFAULT is a non-fatal error that we can get, for example,
+ * if the segment is backed by a file but extends beyond its
+ * end.
+ */
+ error = core_write(p, base, len, offset, UIO_USERSPACE);
+ if (error == EFAULT) {
+ log(LOG_WARNING, "Failed to fully fault in a core file segment "
+ "at VA %p with size 0x%zx to be written at offset 0x%jx "
+ "for process %s\n", base, len, offset, curproc->p_comm);
+
+ /*
+ * Write a small number of "real" zeroes at the end of the
+ * target region in the case this is the last segment.
+ * The intermediate space will be implicitly zero-filled.
+ */
+ error = core_write(p, &zero, sizeof(zero),
+ offset + len - sizeof(zero), UIO_SYSSPACE);
+ }
+ return (error);
}
/*

File Metadata

Mime Type
text/plain
Expires
Tue, Oct 20, 7:07 PM (10 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30568055
Default Alt Text
D9233.1792523234.diff (1 KB)

Event Timeline