Skip to content

Commit 03cb266

Browse files
committed
Emulate -EINVAL for MADV_GUARD_{INSTALL,REMOVE}.
Fixes #3997
1 parent 0b91a14 commit 03cb266

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

src/kernel_supplement.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ struct rr_input_mask {
281281
#ifndef MADV_COLLAPSE
282282
#define MADV_COLLAPSE 25
283283
#endif
284+
#ifndef MADV_GUARD_INSTALL
285+
#define MADV_GUARD_INSTALL 102
286+
#endif
287+
#ifndef MADV_GUARD_REMOVE
288+
#define MADV_GUARD_REMOVE 103
289+
#endif
284290

285291
#ifndef BUS_MCEERR_AR
286292
#define BUS_MCEERR_AR 4

src/record_syscall.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5245,6 +5245,10 @@ static Switchable rec_prepare_syscall_arch(RecordTask* t,
52455245
t->set_regs(r);
52465246
break;
52475247
}
5248+
case MADV_GUARD_INSTALL:
5249+
case MADV_GUARD_REMOVE:
5250+
syscall_state.emulate_result(-EINVAL);
5251+
break;
52485252
default:
52495253
syscall_state.expect_errno = EINVAL;
52505254
break;

src/test/madvise_misc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ int main(void) {
2929
DO_MADVISE(MADV_POPULATE_READ);
3030
DO_MADVISE(MADV_POPULATE_WRITE);
3131
DO_MADVISE(MADV_COLLAPSE);
32+
DO_MADVISE(MADV_GUARD_INSTALL);
33+
DO_MADVISE(MADV_GUARD_REMOVE);
3234

3335
atomic_puts("EXIT-SUCCESS");
3436

src/test/util.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,12 @@ struct open_how {
497497
#ifndef MADV_COLLAPSE
498498
#define MADV_COLLAPSE 25
499499
#endif
500+
#ifndef MADV_GUARD_INSTALL
501+
#define MADV_GUARD_INSTALL 102
502+
#endif
503+
#ifndef MADV_GUARD_REMOVE
504+
#define MADV_GUARD_REMOVE 103
505+
#endif
500506

501507
#ifndef F_OFD_GETLK
502508
#define F_OFD_GETLK 36

0 commit comments

Comments
 (0)