diff --git a/xbmc/platform/posix/utils/SharedMemory.cpp b/xbmc/platform/posix/utils/SharedMemory.cpp index 6c1318e936e0f..c01fef3eb16eb 100644 --- a/xbmc/platform/posix/utils/SharedMemory.cpp +++ b/xbmc/platform/posix/utils/SharedMemory.cpp @@ -15,6 +15,9 @@ #if defined(HAVE_LINUX_MEMFD) #include #include +#ifndef MFD_NOEXEC_SEAL +#define MFD_NOEXEC_SEAL 0x0008U +#endif #endif #include @@ -63,7 +66,7 @@ CFileHandle CSharedMemory::OpenMemfd() #if defined(SYS_memfd_create) && defined(HAVE_LINUX_MEMFD) // This is specific to Linux >= 3.17, but preferred over shm_create if available // because it is race-free - int fd = syscall(SYS_memfd_create, "kodi", MFD_CLOEXEC); + int fd = syscall(SYS_memfd_create, "kodi", MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_NOEXEC_SEAL); if (fd < 0) { throw std::system_error(errno, std::generic_category(), "memfd_create"); @@ -115,4 +118,4 @@ CFileHandle CSharedMemory::OpenShm() unlink(tmpFilename.c_str()); return fd; -} \ No newline at end of file +} diff --git a/xbmc/utils/UDMABufferObject.cpp b/xbmc/utils/UDMABufferObject.cpp index 2b8336bcea9c8..e67b6b2154d94 100644 --- a/xbmc/utils/UDMABufferObject.cpp +++ b/xbmc/utils/UDMABufferObject.cpp @@ -20,6 +20,10 @@ #include "PlatformDefs.h" +#ifndef MFD_NOEXEC_SEAL +#define MFD_NOEXEC_SEAL 0x0008U +#endif + namespace { @@ -95,7 +99,7 @@ bool CUDMABufferObject::CreateBufferObject(uint64_t size) // Must be rounded to the system page size m_size = RoundUp(size, PAGESIZE); - m_memfd = memfd_create("kodi", MFD_CLOEXEC | MFD_ALLOW_SEALING); + m_memfd = memfd_create("kodi", MFD_CLOEXEC | MFD_ALLOW_SEALING | MFD_NOEXEC_SEAL); if (m_memfd < 0) { CLog::Log(LOGERROR, "CUDMABufferObject::{} - memfd_create failed: {}", __FUNCTION__,