When shmfs_truncate is called, it uses shmfs_alloc_object to create the
physical backing for the shm file. However, the allocated physical
memory returned by mm_pgalloc is not cleared when CONFIG_BUILD_KERNEL is
set, which is a clear POSIX violation:
https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html
"If the file was previously shorter than length, its size is increased,
and the extended area appears as if it were zero-filled."
For FLAT and PROTECTED modes zalloc is used, so the violation affects
KERNEL mode only.
This implements the file system logic for posix shared memory:
shm_open, shm_unlink, mmap, munmap and close
For flat and protected builds the memory simply allocated from (user) heap
For kernel build the memory is allocated from page pool and mapped with MMU
This doesn't yet support protection flags or re-sizing already truncated shared
memory area.
Co-authored-by: Ville Juven <ville.juven@unikie.com>
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>