mbox series

[0/1] selftest/mm/hugetlb: SIGBUS on stolen page

Message ID 20240105155419.1939484-1-leitao@debian.org (mailing list archive)
Headers show
Series selftest/mm/hugetlb: SIGBUS on stolen page | expand

Message

Breno Leitao Jan. 5, 2024, 3:54 p.m. UTC
This test case triggers a race between madvise(MADV_DONTNEED) and
mmap() in a single huge page, which got stolen (while reserved).

Once the only page is stolen, the memory previously mmaped (and
madvise(MADV_DONTNEED) got a SIGBUS when accessed.

I am not adding this test to the un_vmtests.sh scripts, since this test
fails at upstream.

Breno Leitao (1):
  selftests/mm: add a new test for madv and hugetlb mmap

 tools/testing/selftests/mm/.gitignore         |   1 +
 tools/testing/selftests/mm/Makefile           |   1 +
 .../selftests/mm/hugetlb_madv_vs_map.c        | 124 ++++++++++++++++++
 3 files changed, 126 insertions(+)
 create mode 100644 tools/testing/selftests/mm/hugetlb_madv_vs_map.c

Comments

Andrew Morton Jan. 5, 2024, 4:42 p.m. UTC | #1
On Fri,  5 Jan 2024 07:54:18 -0800 Breno Leitao <leitao@debian.org> wrote:

> This test case triggers a race between madvise(MADV_DONTNEED) and
> mmap() in a single huge page, which got stolen (while reserved).
> 
> Once the only page is stolen, the memory previously mmaped (and
> madvise(MADV_DONTNEED) got a SIGBUS when accessed.
> 
> I am not adding this test to the un_vmtests.sh scripts, since this test
> fails at upstream.

Oh.  Is a fix for this in the pipeline?  If so, I assume that once the
fix is merged, we enable this test in run_vmtests?
Breno Leitao Jan. 5, 2024, 5:40 p.m. UTC | #2
On Fri, Jan 05, 2024 at 08:42:38AM -0800, Andrew Morton wrote:
> On Fri,  5 Jan 2024 07:54:18 -0800 Breno Leitao <leitao@debian.org> wrote:
> 
> > This test case triggers a race between madvise(MADV_DONTNEED) and
> > mmap() in a single huge page, which got stolen (while reserved).
> > 
> > Once the only page is stolen, the memory previously mmaped (and
> > madvise(MADV_DONTNEED) got a SIGBUS when accessed.
> > 
> > I am not adding this test to the un_vmtests.sh scripts, since this test
> > fails at upstream.
> 
> Oh.  Is a fix for this in the pipeline?  If so, I assume that once the
> fix is merged, we enable this test in run_vmtests?

The fix is not ready yet. As soon as the fix lands, I will enable the
test in run_vmtests.
Rik van Riel Jan. 5, 2024, 7 p.m. UTC | #3
On Fri, 2024-01-05 at 08:42 -0800, Andrew Morton wrote:
> On Fri,  5 Jan 2024 07:54:18 -0800 Breno Leitao <leitao@debian.org>
> wrote:
> 
> > This test case triggers a race between madvise(MADV_DONTNEED) and
> > mmap() in a single huge page, which got stolen (while reserved).
> > 
> > Once the only page is stolen, the memory previously mmaped (and
> > madvise(MADV_DONTNEED) got a SIGBUS when accessed.
> > 
> > I am not adding this test to the un_vmtests.sh scripts, since this
> > test
> > fails at upstream.
> 
> Oh.  Is a fix for this in the pipeline?  If so, I assume that once
> the
> fix is merged, we enable this test in run_vmtests?
> 
I've got some ideas on how to fix it, and hope to get
a fix to you and Mike by next week.

I'll ask Mike if I run into any unexpected complications.