Skip to content

Commit 6252021

Browse files
committed
seccomp: allow mmap(PRIVATE|ANON) on vmm
Also adds regression test. Signed-off-by: alindima <alindima@amazon.com>
1 parent 650d110 commit 6252021

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

resources/seccomp/aarch64-unknown-linux-musl.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,19 @@
202202
}
203203
]
204204
},
205+
{
206+
"syscall": "mmap",
207+
"comment": "Used by rust's stdlib, particularly when creating a diff snapshot of a VM with ~16 GB of memory",
208+
"args": [
209+
{
210+
"index": 3,
211+
"type": "dword",
212+
"op": "eq",
213+
"val": 34,
214+
"comment": "libc::MAP_ANONYMOUS | libc::MAP_PRIVATE"
215+
}
216+
]
217+
},
205218
{
206219
"syscall": "rt_sigaction",
207220
"comment": "rt_sigaction is used by libc::abort during a panic to install the default handler for SIGABRT",
@@ -533,7 +546,7 @@
533546
"type": "dword",
534547
"op": "eq",
535548
"val": 34,
536-
"comment": " libc::MAP_ANONYMOUS | libc::MAP_PRIVATE"
549+
"comment": "libc::MAP_ANONYMOUS | libc::MAP_PRIVATE"
537550
}
538551
]
539552
},

resources/seccomp/x86_64-unknown-linux-musl.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,19 @@
202202
}
203203
]
204204
},
205+
{
206+
"syscall": "mmap",
207+
"comment": "Used by rust's stdlib, particularly when creating a diff snapshot of a VM with ~16 GB of memory",
208+
"args": [
209+
{
210+
"index": 3,
211+
"type": "dword",
212+
"op": "eq",
213+
"val": 34,
214+
"comment": "libc::MAP_ANONYMOUS | libc::MAP_PRIVATE"
215+
}
216+
]
217+
},
205218
{
206219
"syscall": "rt_sigaction",
207220
"comment": "rt_sigaction is used by libc::abort during a panic to install the default handler for SIGABRT",
@@ -532,7 +545,7 @@
532545
"type": "dword",
533546
"op": "eq",
534547
"val": 34,
535-
"comment": " libc::MAP_ANONYMOUS | libc::MAP_PRIVATE"
548+
"comment": "libc::MAP_ANONYMOUS | libc::MAP_PRIVATE"
536549
}
537550
]
538551
},

tests/integration_tests/functional/test_snapshot_basic.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,3 +601,32 @@ def test_negative_snapshot_create(bin_cloner_path):
601601
assert not os.path.exists('memfile')
602602

603603
vm.kill()
604+
605+
606+
def test_create_large_diff_snapshot(test_microvm_with_api):
607+
"""
608+
Create large diff snapshot seccomp regression test.
609+
610+
When creating a diff snapshot of a microVM with a large memory size, an
611+
mmap(MAP_PRIVATE|MAP_ANONYMOUS) is issued. Test that the default seccomp
612+
filter allows it.
613+
614+
@type: regression
615+
@issue: https://github.com/firecracker-microvm/firecracker/discussions/2811
616+
"""
617+
vm = test_microvm_with_api
618+
vm.spawn()
619+
vm.basic_config(mem_size_mib=16*1024, track_dirty_pages=True)
620+
621+
vm.start()
622+
623+
response = vm.vm.patch(state='Paused')
624+
assert vm.api_session.is_status_no_content(response.status_code)
625+
626+
response = vm.snapshot.create(mem_file_path='memfile',
627+
snapshot_path='statefile',
628+
diff=True)
629+
630+
# If the regression was not fixed, this would have failed. The Firecracker
631+
# process would have been taken down.
632+
assert vm.api_session.is_status_no_content(response.status_code)

0 commit comments

Comments
 (0)