Skip to content

Commit

Permalink
imgact_elf: consistently pass flags from coredump down to helper func…
Browse files Browse the repository at this point in the history
…tions

(cherry picked from commit 5bc3c61)
  • Loading branch information
kostikbel committed May 10, 2021
1 parent b316c01 commit 69130fd
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions sys/kern/imgact_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,12 +1471,13 @@ static void cb_put_phdr(vm_map_entry_t, void *);
static void cb_size_segment(vm_map_entry_t, void *);
static int core_write(struct coredump_params *, const void *, size_t, off_t,
enum uio_seg, size_t *);
static void each_dumpable_segment(struct thread *, segment_callback, void *);
static void each_dumpable_segment(struct thread *, segment_callback, void *,
int);
static int __elfN(corehdr)(struct coredump_params *, int, void *, size_t,
struct note_info_list *, size_t);
struct note_info_list *, size_t, int);
static void __elfN(prepare_notes)(struct thread *, struct note_info_list *,
size_t *);
static void __elfN(puthdr)(struct thread *, void *, size_t, int, size_t);
static void __elfN(puthdr)(struct thread *, void *, size_t, int, size_t, int);
static void __elfN(putnote)(struct note_info *, struct sbuf *);
static size_t register_note(struct note_info_list *, int, outfunc_t, void *);
static int sbuf_drain_core_output(void *, const char *, int);
Expand Down Expand Up @@ -1669,7 +1670,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
/* Size the program segments. */
seginfo.count = 0;
seginfo.size = 0;
each_dumpable_segment(td, cb_size_segment, &seginfo);
each_dumpable_segment(td, cb_size_segment, &seginfo, flags);

/*
* Collect info about the core file header area.
Expand Down Expand Up @@ -1722,7 +1723,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
*/
hdr = malloc(hdrsize, M_TEMP, M_WAITOK);
error = __elfN(corehdr)(&params, seginfo.count, hdr, hdrsize, &notelst,
notesz);
notesz, flags);

/* Write the contents of all of the writable segments. */
if (error == 0) {
Expand Down Expand Up @@ -1806,7 +1807,8 @@ cb_size_segment(vm_map_entry_t entry, void *closure)
* caller-supplied data.
*/
static void
each_dumpable_segment(struct thread *td, segment_callback func, void *closure)
each_dumpable_segment(struct thread *td, segment_callback func, void *closure,
int flags)
{
struct proc *p = td->td_proc;
vm_map_t map = &p->p_vmspace->vm_map;
Expand Down Expand Up @@ -1867,15 +1869,16 @@ each_dumpable_segment(struct thread *td, segment_callback func, void *closure)
*/
static int
__elfN(corehdr)(struct coredump_params *p, int numsegs, void *hdr,
size_t hdrsize, struct note_info_list *notelst, size_t notesz)
size_t hdrsize, struct note_info_list *notelst, size_t notesz,
int flags)
{
struct note_info *ninfo;
struct sbuf *sb;
int error;

/* Fill in the header. */
bzero(hdr, hdrsize);
__elfN(puthdr)(p->td, hdr, hdrsize, numsegs, notesz);
__elfN(puthdr)(p->td, hdr, hdrsize, numsegs, notesz, flags);

sb = sbuf_new(NULL, NULL, CORE_BUF_SIZE, SBUF_FIXEDLEN);
sbuf_set_drain(sb, sbuf_drain_core_output, p);
Expand Down Expand Up @@ -1953,7 +1956,7 @@ __elfN(prepare_notes)(struct thread *td, struct note_info_list *list,

static void
__elfN(puthdr)(struct thread *td, void *hdr, size_t hdrsize, int numsegs,
size_t notesz)
size_t notesz, int flags)
{
Elf_Ehdr *ehdr;
Elf_Phdr *phdr;
Expand Down Expand Up @@ -2032,7 +2035,7 @@ __elfN(puthdr)(struct thread *td, void *hdr, size_t hdrsize, int numsegs,
/* All the writable segments from the program. */
phc.phdr = phdr;
phc.offset = round_page(hdrsize + notesz);
each_dumpable_segment(td, cb_put_phdr, &phc);
each_dumpable_segment(td, cb_put_phdr, &phc, flags);
}

static size_t
Expand Down

0 comments on commit 69130fd

Please sign in to comment.