diff options
author | Vlad Zahorodnii <vlad.zahorodnii@kde.org> | 2022-11-17 15:25:37 +0200 |
---|---|---|
committer | Vlad Zahorodnii <vlad.zahorodnii@kde.org> | 2022-11-18 11:13:25 +0200 |
commit | 0c1cbb376e0cf878e3a91ab4917fe784a3b4c547 (patch) | |
tree | d4b4b365479354a3b52309ce9611c9f6bd68a197 /src | |
parent | 349bce0feaa7aa64081a6e2ef3c8611236d26975 (diff) | |
download | qtwayland-0c1cbb376e0cf878e3a91ab4917fe784a3b4c547.tar.gz |
Client: Add F_SEAL_SHRINK seal to shm backing file
This lets libwayland-server avoid installing a SIGBUS handler when it
wants to mmap() the backing file and access the contents of shared
memory client buffers.
Change-Id: Id0b17f729799535d73e8700c5a99c32fd88a068a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/qwaylandshmbackingstore.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp index a8e59637..2e0c2491 100644 --- a/src/client/qwaylandshmbackingstore.cpp +++ b/src/client/qwaylandshmbackingstore.cpp @@ -16,6 +16,7 @@ #include <QtWaylandClient/private/wayland-wayland-client-protocol.h> +#include <fcntl.h> #include <unistd.h> #include <sys/mman.h> @@ -25,6 +26,9 @@ # ifndef MFD_CLOEXEC # define MFD_CLOEXEC 0x0001U # endif +# ifndef MFD_ALLOW_SEALING +# define MFD_ALLOW_SEALING 0x0002U +# endif #endif QT_BEGIN_NAMESPACE @@ -39,7 +43,9 @@ QWaylandShmBuffer::QWaylandShmBuffer(QWaylandDisplay *display, int fd = -1; #ifdef SYS_memfd_create - fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC); + fd = syscall(SYS_memfd_create, "wayland-shm", MFD_CLOEXEC | MFD_ALLOW_SEALING); + if (fd >= 0) + fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL); #endif QScopedPointer<QFile> filePointer; |