aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linprocfs/linprocfs.c
diff options
context:
space:
mode:
authorDmitry Chagin <dchagin@FreeBSD.org>2022-06-22 11:49:40 +0000
committerDmitry Chagin <dchagin@FreeBSD.org>2022-07-06 11:02:15 +0000
commitb1d0fe755bb11be36d97885dbab0ac66aabb5877 (patch)
treef262c68ba73c19d087a4d48d288abea15819d413 /sys/compat/linprocfs/linprocfs.c
parent5bdeed846dc02d1dc2e845e209bd3bcb6cb8cbf5 (diff)
linprocfs: Skip printing of the guard page in the /proc/self/maps
To calculate the base (lowest addressable) address of the stack of the initial thread glibc parses /proc/self/maps. In fact, the base address is calculated as 'to' value of stack entry of the /proc/self/maps - stack size limit (if the stack grows down). The base address should fit in between preceding entry and stack entry of the /proc/self/maps. In FreeBSD, since 19bd0d9 (Implement address space guards), we actually have two mappings for the stack region. The first one is the no-access mapping for the region the stack can grow into (guard page), and the second - initial stack region with size sgrowsiz. The first mapping confuses Glibc, in the end which is improperly calculate stack size and the base address. PR: 253337 Reviewed by: kib Differential revision: https://reviews.freebsd.org/D35537 MFC after: 2 week (cherry picked from commit ef1976ccf5420d0912afcb49733c7a88643069da)
Diffstat (limited to 'sys/compat/linprocfs/linprocfs.c')
-rw-r--r--sys/compat/linprocfs/linprocfs.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index 6cf25350d9e8..714c4ee4a84c 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -1307,7 +1307,13 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
VM_MAP_ENTRY_FOREACH(entry, map) {
name = "";
freename = NULL;
- if (entry->eflags & MAP_ENTRY_IS_SUB_MAP)
+ /*
+ * Skip printing of the guard page of the stack region, as
+ * it confuses glibc pthread_getattr_np() method, where both
+ * the base address and size of the stack of the initial thread
+ * are calculated.
+ */
+ if ((entry->eflags & (MAP_ENTRY_IS_SUB_MAP | MAP_ENTRY_GUARD)) != 0)
continue;
e_prot = entry->protection;
e_start = entry->start;