From nobody Wed Jul 06 11:04:15 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 027901D015A4; Wed, 6 Jul 2022 11:04:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LdGrc0jKGz3NN8; Wed, 6 Jul 2022 11:04:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657105456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9gLJ0S569kC2uO0+ZBNvRlTmtIJcYvZ6o3OMJ/2M6oU=; b=Jk4kKMhCsOY/Y2USf0BUFPVxDHjoSPD5uWJKm0m6IfbzQCUJkBh2xACw8CR1bImQaZFtoY 5lw5udrypdBH+ZTsFo/gOghzGaN237ZRp63NQN6g5fjqNHTTXl8MM1SMKkpu6UPnHN5haB 6ilOoTJWKHee4r2q3wiMax4MOtJ9IxsUxs1iSOEIgUzzMDw4mZk3ZOWEA9E5nEGatqs7Aa Gw51Wucf2X9XQ6fL4XEBjwfAjtUFKhEgdSZeN9HlU+nDxKfxZS8fAdlfABnCXJsivZ5gtN i06cYDjNL22znpDWeRMLzAEMalNLdK6v5vMbLpbwZah+XxSwez1Py6OGuz5lig== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8A81718F79; Wed, 6 Jul 2022 11:04:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 266B4Fxl096754; Wed, 6 Jul 2022 11:04:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 266B4FnV096753; Wed, 6 Jul 2022 11:04:15 GMT (envelope-from git) Date: Wed, 6 Jul 2022 11:04:15 GMT Message-Id: <202207061104.266B4FnV096753@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: b1d0fe755bb1 - stable/13 - linprocfs: Skip printing of the guard page in the /proc/self/maps List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b1d0fe755bb11be36d97885dbab0ac66aabb5877 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657105456; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9gLJ0S569kC2uO0+ZBNvRlTmtIJcYvZ6o3OMJ/2M6oU=; b=bowmGjbkVrrmHpXKPHnVdRd6AV8OV3HbI5MYNeiAB71l2dl8+7xpDfXBTEEENBaRhezBQb UM6rg2b2sDzd+aDuv6961tVmqtTQISw0+rWJyGiz+D49mjksuLY7DdN447xU+U92fFcrCd t0NI46gIF65Xw2FioKH7aowl3Xw9rBMgm/2byKwOGc1IzE6xvowLUT2M0IcTg+qzhH9ZpP HmbW0Ql9vyJWZzwJXw+lbzEzl63YBShG5ibQylB5O13gCGI6Z4VfglAjfd/LlO00QfHlyD shiXLckrYlhqAbfCsEPrB+KPwGNpmvcO1BkCSXJELbC1kSsm0GSUlZvRsPlU/w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657105456; a=rsa-sha256; cv=none; b=c2ASq0sLz5L+/Vu63vG9iseIiA+1AuVjuF2MYqp8B+xbXAnSqW5CtaXwE9iWXjluc9gw4o tqKorYEKzX9UNUVd5v1tBNxIDubWGaCdnkA8Ej6dBM4gqauPDuD6GrqBdLtfcTBphZblPZ Hu/Wk7QI2dMj5Qul4V6kO6WwXIfJ5IyEWJWD7CkZmeuEXAkVSxCheJBl98h7jMd0uxpe14 BTbeucJckC23RiPysdN1CZhNkNeXEGC2DGPuTU7IQubsVXZ908yMms4FN4fw1KTZIrZgv2 ZZFdLvYu/RGofS+G4rtUw3LGD091om5T513ln0gtN/4Spavfxx+vSb6l2NaqRA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=b1d0fe755bb11be36d97885dbab0ac66aabb5877 commit b1d0fe755bb11be36d97885dbab0ac66aabb5877 Author: Dmitry Chagin AuthorDate: 2022-06-22 11:49:40 +0000 Commit: Dmitry Chagin CommitDate: 2022-07-06 11:02:15 +0000 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) --- sys/compat/linprocfs/linprocfs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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;