From nobody Wed Jun 22 11:50:49 2022 X-Original-To: dev-commits-src-main@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 D3C35875FDF; Wed, 22 Jun 2022 11:50:49 +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 4LShXn4Rytz3GYr; Wed, 22 Jun 2022 11:50:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655898649; 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=XXWOIwa7G9H5knchIpbHHHNXGhrndGj2Wnz56EjnoM0=; b=EkU8XD6W8xPkeKJUhvp7bvF3AaYuj5pHrMj/J4Q1qbaYUwwPeVB/2AMBo+aXfvwAZJkyFi uIK/KMz24loG5/564ZmUvi3rkxuzpjpZW62IVXH7iMwXlqz9P+r9Ei+l7vPQXAlnJ/XWyq UAZf7l1oNZYKVbQzF4oys/gzz2ouXZercou7Sx29kg/wasH999w0Sv45LVv4MNlfvniPMV rBnvjVmTJmUSrhycRAYhLDfDbpVXsW5NfAzHr4jzYp2m0h8Ij7zPZJcqrb/Q3gul04sHKH +IAkUw0ai4At3wU7dJUk2lKOj26dRwm5XZu2fmzFXyXNzShZaltnIBXolgkVUA== 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 75F93256E8; Wed, 22 Jun 2022 11:50:49 +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 25MBonwg037080; Wed, 22 Jun 2022 11:50:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25MBon9P037079; Wed, 22 Jun 2022 11:50:49 GMT (envelope-from git) Date: Wed, 22 Jun 2022 11:50:49 GMT Message-Id: <202206221150.25MBon9P037079@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: ef1976ccf542 - main - linprocfs: Skip printing of the guard page in the /proc/self/maps List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: ef1976ccf5420d0912afcb49733c7a88643069da Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655898649; 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=XXWOIwa7G9H5knchIpbHHHNXGhrndGj2Wnz56EjnoM0=; b=iAYuLp5OvrIhq27VZ82EA8Bf7K7y1qK5rbQRIH7LY5j8UiaHyHhHqBPRh0+RREtHjry/0x 3Ev9Fo79pztIYblASAiVzvqkNsQlH4Bwa/DmerD9V6XWjfLcOvPWI+bD60wADmxPt+J+xJ o/1G3h24uOxaJlHe3bi4well6HefVC3nEFg87eBFYh8v5CETAy5dDP5Gz38cXAHBhEpq/S N59hVohlR4Ju4V7UN1H6pmX/x5ZBfDP4uEiRy6l9YLM2tOPXNTsntCzPZy1F0u7JLOKw+O wXECgbFzi0oscPLRpFM9siC1zMB4WKdU8zU0dNqCXlcAtepmx64RQvmoU+6kVQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655898649; a=rsa-sha256; cv=none; b=pQ2OIrEB8kUbbI+KrxMsWLIRaCzhT1R6xWVXOxK0/4q8GSMXHoHhPXgtAFQbKp3pnm9CS4 6xa6tpCuC5Q6SAKWqKjLH+V+OfD8Iuu6TXNk/mu6XQihYBX+zgKHKJi7Y+mFEFpZIHNQu9 rpH1cyIZ+NqsI+89PwqK00VE9ldGF46tJ4qdYCgZp/dALF4j4SlyIKXViV+cNFAInrf8f0 pS2M7GjPdUfCNPyMGCtopAHRRT/5rNEcTiNI97grvbRzT1srf730q7bnSiBm8Zveybk8vY KlNa/Z/dbhQWm8VSLD9KmsZUczeiz6JuGCRuuHw5+qWeAskrnD5b/VMB9qx6gg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=ef1976ccf5420d0912afcb49733c7a88643069da commit ef1976ccf5420d0912afcb49733c7a88643069da Author: Dmitry Chagin AuthorDate: 2022-06-22 11:49:40 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-22 11:49:40 +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 --- 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 62fa797ae875..93b5af04e670 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;