From nobody Mon Jan 10 14:05:30 2022 X-Original-To: dev-commits-src-branches@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 B3AB1193D660; Mon, 10 Jan 2022 14:05:31 +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 4JXbFR24yRz3Fq9; Mon, 10 Jan 2022 14:05:31 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 1955826830; Mon, 10 Jan 2022 14:05:31 +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 20AE5V3q039979; Mon, 10 Jan 2022 14:05:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20AE5Ur4039978; Mon, 10 Jan 2022 14:05:30 GMT (envelope-from git) Date: Mon, 10 Jan 2022 14:05:30 GMT Message-Id: <202201101405.20AE5Ur4039978@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 16c60a70c99b - stable/13 - posixshm tests: Fix occasional largepage_mprotect failures List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 16c60a70c99b82e2b645c334f0cc3e89ad3c2be5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641823531; 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=114csO4URgpBwxF/373FMqYZUHtbN4UURWzHzvs4Xj0=; b=hBCy540WwYF8VWiBBXbdq3xjjtpviBl5+584vZIDiFpHFQ88iafEFmqG8ZhStDiyM5XhEK rhgx++eXVfv3/Qh6TRqO1pcW59JzJsurWJR668cENB6g2vc4uRMOpT63fCT5DcFZG8qWgK 4A0Kfgs2199+gbWwhnx7Nwz8Sj7IdNZZx/9YpUzbMlTDuVPVOjk5LWvnzFb73fNzZeDiZZ P55nEknZJ2r7/xanltxxmt+PWhu2p0/M3XI2+cQ0yDqx9dPXXfgw86OBEq9TCz24PbNN2C OUf3RnDTSo6egoZaOaRf2bL3en6aXyj36h7ATYTQkiirnHtAKAOdnRvF2vjjNQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641823531; a=rsa-sha256; cv=none; b=CoQNSewNf4XwuOSFmMCZE/JcUBPZoBkg8NjGc9YqyuXJPMtUyIASlUg+oRZ+tmqDt1nodG kZngiSeLDlMI1vbRXP5WuA2pNUrYvK+8TG0XYneXT/g2FVioIPqC34BNoGggBPOzCIzhDJ W0q10GTllbMcA35w+8y6KTroQP4qiYq4dmP6QYS/Ua4pw9dXiP9H7yS9YmP/juyr+VfQBb 8QUg5HyqgNov/XoosA1kYsL/hKeg56aLKnFPIbX0b42rjT3zqDiJaJ2FcqvmTgAKWevmVP SG2Rr/Z1EOxanbwYeStV9KGeu485ZxFsP+6AqbmX5SgHSzF5wLmyDVz1JtBlPQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=16c60a70c99b82e2b645c334f0cc3e89ad3c2be5 commit 16c60a70c99b82e2b645c334f0cc3e89ad3c2be5 Author: Mark Johnston AuthorDate: 2022-01-03 16:15:46 +0000 Commit: Mark Johnston CommitDate: 2022-01-10 14:05:12 +0000 posixshm tests: Fix occasional largepage_mprotect failures largepage_mprotect maps a superpage and later extends the mapping. This occasionally fails with ASLR disabled. To fix this, first try to reserve a sufficiently large virtual address region. Reported by: Jenkins Sponsored by: The FreeBSD Foundation (cherry picked from commit 321e586e46115c69e7e833d592703d997a4ec477) --- tests/sys/posixshm/posixshm_test.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/sys/posixshm/posixshm_test.c b/tests/sys/posixshm/posixshm_test.c index d1c1b14aef65..2f2c6eb5fc80 100644 --- a/tests/sys/posixshm/posixshm_test.c +++ b/tests/sys/posixshm/posixshm_test.c @@ -1434,9 +1434,19 @@ ATF_TC_BODY(largepage_mprotect, tc) pscnt = pagesizes(ps); for (int i = 1; i < pscnt; i++) { + /* + * Reserve a contiguous region in the address space to avoid + * spurious failures in the face of ASLR. + */ + addr = mmap(NULL, ps[i] * 2, PROT_NONE, + MAP_ANON | MAP_ALIGNED(ffsl(ps[i]) - 1), -1, 0); + ATF_REQUIRE_MSG(addr != MAP_FAILED, + "mmap(%zu bytes) failed; error=%d", ps[i], errno); + ATF_REQUIRE(munmap(addr, ps[i] * 2) == 0); + fd = shm_open_large(i, SHM_LARGEPAGE_ALLOC_DEFAULT, ps[i]); - addr = mmap(NULL, ps[i], PROT_READ | PROT_WRITE, MAP_SHARED, fd, - 0); + addr = mmap(addr, ps[i], PROT_READ | PROT_WRITE, + MAP_SHARED | MAP_FIXED, fd, 0); ATF_REQUIRE_MSG(addr != MAP_FAILED, "mmap(%zu bytes) failed; error=%d", ps[i], errno);