Bug 259970 - sys.kern.coredump_phnum_test.coredump_phnum fails with ASLR on by default
Summary: sys.kern.coredump_phnum_test.coredump_phnum fails with ASLR on by default
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: tests (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-testing (Nobody)
URL:
Keywords:
Depends on:
Blocks: 259968
  Show dependency treegraph
 
Reported: 2021-11-21 16:08 UTC by Ed Maste
Modified: 2021-11-28 02:57 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2021-11-21 16:08:01 UTC
As reported by lwhsu and mw on -current,  sys.kern.coredump_phnum_test.coredump_phnum fails after ASLR was enabled by default

https://ci.freebsd.org/job/FreeBSD-main-amd64-test/19828/testReport/

Fail: regexp 65535 \(66[0-9]{3}\) not in stdout
  Number of program headers:         17
Comment 1 Ed Maste freebsd_committer freebsd_triage 2021-11-21 16:41:44 UTC
More recent run, https://ci.freebsd.org/job/FreeBSD-main-amd64-test/19867/testReport/junit/sys.kern/coredump_phnum_test/coredump_phnum/

Source reference:
tests/sys/kern/coredump_phnum_test.sh
tests/sys/kern/coredump_phnum_helper.c

Proposed fix: https://reviews.freebsd.org/D33070
Comment 2 commit-hook freebsd_committer freebsd_triage 2021-11-21 18:00:04 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=8ec4c5dae32765701ac70811455084efd1570c32

commit 8ec4c5dae32765701ac70811455084efd1570c32
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2021-11-21 17:17:20 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2021-11-21 17:57:38 +0000

    Fix coredump_phnum test with ASLR enabled by default

    coredump_phnum intends to generate a core file with many PT_LOAD
    segments.  Previously it called mmap() in a loop with alternating
    protections, relying on each mapping following the previous, to produce
    a core file with many page-sized PT_LOAD segments.  With ASLR on we no
    longer have this property of each mmap() following the previous.

    Instead, perform a single allocation, and then use mprotect() to set
    alternating pages to PROT_READ.

    PR:             259970
    Reported by:    lwhsu, mw
    Reviewed by:    kib
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D33070

 tests/sys/kern/coredump_phnum_helper.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2021-11-28 02:06:55 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=ee2e925603e42897fbabe1b24208d27bdcaae786

commit ee2e925603e42897fbabe1b24208d27bdcaae786
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2021-11-21 17:17:20 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2021-11-28 00:27:03 +0000

    Fix coredump_phnum test with ASLR enabled

    coredump_phnum intends to generate a core file with many PT_LOAD
    segments.  Previously it called mmap() in a loop with alternating
    protections, relying on each mapping following the previous, to produce
    a core file with many page-sized PT_LOAD segments.  With ASLR on we no
    longer have this property of each mmap() following the previous.

    Instead, perform a single allocation, and then use mprotect() to set
    alternating pages to PROT_READ.

    PR:             259970
    Reported by:    lwhsu, mw
    Reviewed by:    kib
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D33070

    (cherry picked from commit 8ec4c5dae32765701ac70811455084efd1570c32)

 tests/sys/kern/coredump_phnum_helper.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2021-11-28 02:57:03 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d3a7b75bbcb5171d7eda9d712437efd46bb7605b

commit d3a7b75bbcb5171d7eda9d712437efd46bb7605b
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2021-11-21 17:17:20 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2021-11-28 02:55:46 +0000

    Fix coredump_phnum test with ASLR enabled

    coredump_phnum intends to generate a core file with many PT_LOAD
    segments.  Previously it called mmap() in a loop with alternating
    protections, relying on each mapping following the previous, to produce
    a core file with many page-sized PT_LOAD segments.  With ASLR on we no
    longer have this property of each mmap() following the previous.

    Instead, perform a single allocation, and then use mprotect() to set
    alternating pages to PROT_READ.

    PR:             259970
    Reported by:    lwhsu, mw
    Reviewed by:    kib
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D33070

    (cherry picked from commit 8ec4c5dae32765701ac70811455084efd1570c32)
    (cherry picked from commit ee2e925603e42897fbabe1b24208d27bdcaae786)

 tests/sys/kern/coredump_phnum_helper.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)