Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#17895 closed bug (fixed)

mprotect ineffective after fork

Reported by: korli Owned by: nobody
Priority: normal Milestone: R1/beta4
Component: System/Kernel Version: R1/beta3
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description (last modified by korli)

I took a few tests from libhugetlbfs, combined them in fork-mprotect-cow to check the page protection after fork. this actually succeeds on Linux and fails on Haiku.

Test output on Linux

Starting testcase "./fork-mprotect-cow", pid 15944
Mapping synchronization area..done
Mapping hugepage area...mapped at 0x7f59034f2000
Parent writes pre-fork...1234abcd
mprotect()ing to prot=0
Parent reading..SIGSEGV at 0x7f59034f2000 (sig_expected=0x7f59034f2000)
-1
Child starts..
Child reading..SIGSEGV at 0x7f59034f2000 (sig_expected=0x7f59034f2000)
-1
Child exits...
PASS

Test output on Haiku

Starting testcase "./fork-mprotect-cow", pid 585
Mapping synchronization area..done
Mapping hugepage area...mapped at 0x6e1872f000
Parent writes pre-fork...1234abcd
mprotect()ing to prot=0
Parent reading..Read back 305441741
0
Child starts..
Child reading..SIGSEGV at 0x6e1872f000 (sig_expected=0x6e1872f000)
-1
Child exits...
FAIL	Parent read succeeded on mmap(prot=0)

Attachments (3)

fork-mprotect-cow.c (5.8 KB ) - added by korli 2 years ago.
testutils.c (8.6 KB ) - added by korli 2 years ago.
hugetests.h (4.3 KB ) - added by korli 2 years ago.

Download all attachments as: .zip

Change History (9)

by korli, 2 years ago

Attachment: fork-mprotect-cow.c added

by korli, 2 years ago

Attachment: testutils.c added

by korli, 2 years ago

Attachment: hugetests.h added

comment:1 by korli, 2 years ago

Description: modified (diff)

comment:2 by korli, 2 years ago

Description: modified (diff)

comment:4 by waddlesplash, 2 years ago

Milestone: UnscheduledR1/beta4
Resolution: fixed
Status: newclosed

Fix merged in hrev56392. Should we add this testcase to the tree, perhaps?

comment:5 by korli, 2 years ago

Thanks, the testcase licensing is LGPL, I wasn't sure it can be added to the tree.

comment:6 by waddlesplash, 2 years ago

I think it's fine for testcases to be LGPL, we mostly care about things actually distributed to not be GPL.

Note: See TracTickets for help on using tickets.