mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 15:29:45 +03:00
libcamera: shared_mem_object: Prevent memfd from shrinking or growing
The memfd underlying the SharedMem object must not shrink, or memory corruption will happen. Prevent this by setting the shrink seal on the file. As there's no valid use case for growing the memory either, set the grow seal as well. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Tested-by: Milan Zamazal <mzamazal@redhat.com> Tested-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
93d9751945
commit
efc7a85bc0
1 changed files with 2 additions and 1 deletions
|
@ -58,7 +58,8 @@ SharedMem::SharedMem() = default;
|
|||
*/
|
||||
SharedMem::SharedMem(const std::string &name, std::size_t size)
|
||||
{
|
||||
UniqueFD memfd = MemFd::create(name.c_str(), size);
|
||||
UniqueFD memfd = MemFd::create(name.c_str(), size, MemFd::Seal::Shrink |
|
||||
MemFd::Seal::Grow);
|
||||
if (!memfd.isValid())
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue