Skip to content

Commit e7dfc4c

Browse files
AlexandruCihodarualindima
authored andcommitted
[CI]: Test for mmap allow on api thread
When there is a put or patch request with a large header there will be a mmap call from api_server thread with MAP_PRIVATE flag. It was not allowed. Now we are able to send large buffers. This should be completed by checking the size of the body and returing error when the length is greater than a transhold. Signed-off-by: AlexandruCihodaru <[email protected]>
1 parent ccd994b commit e7dfc4c

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/integration_tests/functional/test_api.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
# Disable pylint C0302: Too many lines in module
66
# pylint: disable=C0302
7+
import array
8+
import itertools
79
import os
810
import platform
911
import resource
@@ -1133,3 +1135,36 @@ def test_negative_api_lifecycle(bin_cloner_path):
11331135
response = basevm.vm.patch(state='Resumed')
11341136
assert "not supported before starting the microVM" \
11351137
in response.text
1138+
1139+
1140+
def test_map_private_seccomp_regression(test_microvm_with_ssh):
1141+
"""
1142+
Seccomp mmap MAP_PRIVATE regression test.
1143+
1144+
When sending large buffer to an api endpoint there will be an attempt to
1145+
call mmap with MAP_PRIVATE|MAP_ANONYMOUS. This would result in vmm being
1146+
killed by the seccomp filter before this PR.
1147+
1148+
@type: functional
1149+
"""
1150+
test_microvm = test_microvm_with_ssh
1151+
test_microvm.spawn()
1152+
test_microvm.api_session.untime()
1153+
1154+
response = test_microvm.mmds.get()
1155+
assert test_microvm.api_session.is_status_ok(response.status_code)
1156+
assert response.json() == {}
1157+
1158+
data_store = {
1159+
'latest': {
1160+
'meta-data': {
1161+
}
1162+
}
1163+
}
1164+
1165+
slice_1mb = array.array('u', itertools.repeat('b', 1024 * 1024))
1166+
chars = array.array('u')
1167+
chars = [chars.extend(slice_1mb) for _ in range(190)]
1168+
data_store["latest"]["meta-data"]["ami-id"] = chars
1169+
response = test_microvm.mmds.put(json=data_store)
1170+
assert test_microvm.api_session.is_status_no_content(response.status_code)

0 commit comments

Comments
 (0)