svn commit: r323227 - head/lib/libproc
Mark Johnston
markj at FreeBSD.org
Wed Sep 6 16:24:35 UTC 2017
Author: markj
Date: Wed Sep 6 16:24:34 2017
New Revision: 323227
URL: https://svnweb.freebsd.org/changeset/base/323227
Log:
Avoid keeping a dangling pointer when the mappings array is resized.
Sponsored by: Dell EMC Isilon
Modified:
head/lib/libproc/_libproc.h
head/lib/libproc/proc_rtld.c
head/lib/libproc/proc_sym.c
Modified: head/lib/libproc/_libproc.h
==============================================================================
--- head/lib/libproc/_libproc.h Wed Sep 6 16:18:53 2017 (r323226)
+++ head/lib/libproc/_libproc.h Wed Sep 6 16:24:34 2017 (r323227)
@@ -72,7 +72,7 @@ struct proc_handle {
struct map_info *mappings; /* File mappings for proc. */
size_t maparrsz; /* Map array size. */
size_t nmappings; /* Number of mappings. */
- prmap_t *exec_map; /* Executable text mapping. */
+ size_t exec_map; /* Executable text mapping index. */
lwpstatus_t lwps; /* Process status. */
struct procstat *procstat; /* libprocstat handle. */
char execpath[PATH_MAX]; /* Path to program executable. */
Modified: head/lib/libproc/proc_rtld.c
==============================================================================
--- head/lib/libproc/proc_rtld.c Wed Sep 6 16:18:53 2017 (r323226)
+++ head/lib/libproc/proc_rtld.c Wed Sep 6 16:24:34 2017 (r323227)
@@ -62,7 +62,7 @@ map_iter(const rd_loadobj_t *lop, void *arg)
rdl2prmap(lop, &mapping->map);
if (strcmp(lop->rdl_path, phdl->execpath) == 0 &&
(lop->rdl_prot & RD_RDL_X) != 0)
- phdl->exec_map = &mapping->map;
+ phdl->exec_map = phdl->nmappings;
file = NULL;
if (lop->rdl_path[0] != '\0') {
Modified: head/lib/libproc/proc_sym.c
==============================================================================
--- head/lib/libproc/proc_sym.c Wed Sep 6 16:18:53 2017 (r323226)
+++ head/lib/libproc/proc_sym.c Wed Sep 6 16:24:34 2017 (r323227)
@@ -511,7 +511,8 @@ _proc_name2map(struct proc_handle *p, const char *name
return (&p->mappings[i]);
}
if (strcmp(name, "a.out") == 0)
- return (_proc_addr2map(p, p->exec_map->pr_vaddr));
+ return (_proc_addr2map(p,
+ p->mappings[p->exec_map].map.pr_vaddr));
return (NULL);
}
More information about the svn-src-head
mailing list