Skip to content

Conversation

alindima
Copy link
Contributor

Reason for This PR

#2811

Description of Changes

  • seccomp: allow mmap(MAP_PRIVATE|MAP_ANONYMOUS) on the vmm thread.

  • add regression test for it

  • fix error from commit a3f5d47. The mmap call on aarch64 should have been allowed on the api thread, but was instead added to the vmm

  • This functionality can be added in rust-vmm.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.

PR Checklist

[Author TODO: Meet these criteria.]
[Reviewer TODO: Verify that these criteria are met. Request changes if not]

  • All commits in this PR are signed (git commit -s).
  • The issue which led to this PR has a clear conclusion.
  • This PR follows the solution outlined in the related issue.
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • Any newly added unsafe code is properly documented.
  • Any API changes follow the Runbook for Firecracker API changes.
  • Any user-facing changes are mentioned in CHANGELOG.md.
  • All added/changed functionality is tested.

Signed-off-by: alindima <alindima@amazon.com>
@alindima alindima self-assigned this Dec 13, 2021
@alindima alindima added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Dec 13, 2021
@alindima alindima requested a review from a team December 13, 2021 14:57
luminitavoicu
luminitavoicu previously approved these changes Dec 14, 2021
Copy link
Contributor

@luminitavoicu luminitavoicu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Should we add a changelog entry for this as well?

Copy link
Contributor

@georgepisaltu georgepisaltu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great! Just a couple of comments.

}
]
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good catch. However, I'm worried that we had to rely on a person finding this rather than our test. Did we just not cover this in any kind of test on aarch64? Maybe we can open an issue about this, might even be a "Good First Contribution" 😄 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a regression test for this in test_api.py::test_map_private_seccomp_regression, but for some reason this mmap call must not have been triggered on ARM.
It's very likely a platform-specific implementation detail of either the Global Allocator or the rust stdlib.
I'll try to see if sending a larger payload than the current 1 mib would trigger the regression on ARM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out that the regression test in test_api.py is not failing even if I remove the mmap from the allowlist.
Looking with strace, there are no such mmap calls issued.
I think it's a bug in the test, I'm looking into it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the bug in the test, it now tests the regression 👍🏻

@alindima
Copy link
Contributor Author

Looks good to me! Should we add a changelog entry for this as well?

Personally, I don't think it's worth adding a changelog entry

"val": 34,
"comment": " libc::MAP_ANONYMOUS | libc::MAP_PRIVATE"
"val": 1,
"comment": "libc::MAP_SHARED"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the comment correct? MAP_SHARED being needed for reading the timezone?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is. I've checked with strace and in the musl implementation of localtime_r
It first checks for the TZ environment variable. If that's not available and if the /etc/localtime file is present, it opens the file and mmaps it.

During this commit: a3f5d47,
the mmap call was mistakenly added to the vmm thread, as opposed
to the API thread to which it was intended.

Also fix the regression test. There was a bug in it, which lead
to this issue being hidden.

Signed-off-by: alindima <alindima@amazon.com>
Also adds regression test.

Signed-off-by: alindima <alindima@amazon.com>
@alindima alindima merged commit 6252021 into firecracker-microvm:main Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting review Indicates that a pull request is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants