Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177763147
D58416.1795223608.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D58416.1795223608.diff
View Options
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -1585,6 +1585,8 @@
struct phdr_closure {
Elf_Phdr *phdr; /* Program header to fill in */
Elf_Off offset; /* Offset of segment in core file */
+ int numsegs; /* Maximum number of segments */
+ int nextseg; /* Next segment to fill in */
};
struct note_info {
@@ -1701,10 +1703,15 @@
}
/*
- * Allocate memory for building the header, fill it up,
- * and write it out following the notes.
+ * Allocate memory for building the header, fill it up, and write it out
+ * following the notes.
+ *
+ * Note that a process sharing our vmspace might be concurrently
+ * mutating the map, in which case we could populate fewer than
+ * seginfo.count headers. Zero the buffer to ensure that unpopulated
+ * headers are still initialized.
*/
- hdr = malloc(hdrsize, M_TEMP, M_WAITOK);
+ hdr = malloc(hdrsize, M_TEMP, M_WAITOK | M_ZERO);
error = __elfN(corehdr)(¶ms, seginfo.count, hdr, hdrsize, ¬elst,
notesz, flags);
@@ -1757,6 +1764,11 @@
struct phdr_closure *phc = (struct phdr_closure *)closure;
Elf_Phdr *phdr = phc->phdr;
+ if (phc->nextseg >= phc->numsegs) {
+ /* Only write as many headers as we have space for. */
+ return;
+ }
+
phc->offset = round_page(phc->offset);
phdr->p_type = PT_LOAD;
@@ -1769,6 +1781,8 @@
phc->offset += phdr->p_filesz;
phc->phdr++;
+
+ phc->nextseg++;
}
/*
@@ -2031,6 +2045,8 @@
/* All the writable segments from the program. */
phc.phdr = phdr;
phc.offset = round_page(hdrsize + notesz);
+ phc.numsegs = numsegs;
+ phc.nextseg = 0;
each_dumpable_segment(td, cb_put_phdr, &phc, flags);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 21, 1:13 AM (23 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41879041
Default Alt Text
D58416.1795223608.diff (1 KB)
Attached To
Mode
D58416: coredump: Don't assume that the number of ELF segments is consistent
Attached
Detach File
Event Timeline