[PATCH 2/3] libcamera: shared_mem_object: Prevent memfd from shrinking or growing
Milan Zamazal
mzamazal at redhat.com
Wed Jul 31 09:24:29 CEST 2024
Hi Laurent,
thank you for the patch.
Laurent Pinchart <laurent.pinchart at ideasonboard.com> writes:
> 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.
Makes sense to me.
Reviewed-by: Milan Zamazal <mzamazal at redhat.com>
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> src/libcamera/shared_mem_object.cpp | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/libcamera/shared_mem_object.cpp b/src/libcamera/shared_mem_object.cpp
> index 022645e71a35..d4c7991ad16a 100644
> --- a/src/libcamera/shared_mem_object.cpp
> +++ b/src/libcamera/shared_mem_object.cpp
> @@ -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;
More information about the libcamera-devel
mailing list