Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

[LibOS,PAL] MAP_SHARED flag is not propagated to PAL #2146

Open
dimakuv opened this issue Feb 8, 2021 · 6 comments · May be fixed by #2147
Open

[LibOS,PAL] MAP_SHARED flag is not propagated to PAL #2146

dimakuv opened this issue Feb 8, 2021 · 6 comments · May be fixed by #2147
Assignees

Comments

@dimakuv
Copy link

dimakuv commented Feb 8, 2021

Description of the problem

During shim_do_mmap(), there could be a combination mmap(..., MAP_SHARED, ...) which is not possible on Linux-SGX PAL. However, the Linux-SGX PAL layer ignores this flag (which is transformed into !PAL_PROT_WRITECOPY via LINUX_PROT_TO_PAL()).

It seems that the simple fix is to check that prot doesn't contain PAL_PROT_WRITECOPY inside Linux-SGX's _DkVirtualMemoryAlloc() and fail with some PAL error.

It looks like the same situation happens in Linux PAL: the mapping is created as MAP_PRIVATE (never MAP_SHARED) always.

@dimakuv
Copy link
Author

dimakuv commented Feb 8, 2021

@mkow You touched that part of code (with all those transformations between flags), could you give your opinion on this issue?

@mkow
Copy link
Member

mkow commented Feb 8, 2021

Seems that PAL API doesn't even have a notion of shared memory? And I don't think it should, this concept is (I think) not compatible with the rest of this API.
So, should we just error out on MAP_SHARED in LibOS?

@mkow mkow self-assigned this Feb 8, 2021
@boryspoplawski
Copy link
Contributor

It does: PAL_PROT_WRITECOPY means CoW (translates to MAP_PRIVATE on Linux), lack of it means shared memory (MAP_SHARED). The convention might be questionable, but the feature is supported atm.

@mkow
Copy link
Member

mkow commented Feb 8, 2021

Huh, really? All mappings in PAL API are shared, unless marked as CoW? That doesn't make sense...

@boryspoplawski
Copy link
Contributor

boryspoplawski commented Feb 8, 2021

That's what the current code does ¯\_(ツ)_/¯

@boryspoplawski
Copy link
Contributor

After validating PAL_PROT_WRITECOPY does not work, even on Linux-Pal.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants