shmfs/shmfs_alloc. Fix POSIX violation for shmfs_truncate
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 commit is contained in:
parent
8e4b2e8a2a
commit
07ce2f717a
@ -22,7 +22,11 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/pgalloc.h>
|
#include <nuttx/pgalloc.h>
|
||||||
|
|
||||||
@ -87,6 +91,12 @@ FAR struct shmfs_object_s *shmfs_alloc_object(size_t length)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Clear the page memory (requirement for truncate) */
|
||||||
|
|
||||||
|
up_addrenv_page_wipe((uintptr_t)pages[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user