change_all_shmget_calls_to_use_user-only_memory
authorLisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
Sat, 22 Dec 2012 16:32:12 +0000 (08:32 -0800)
committerLisandro Damián Nicanor Pérez Meyer <lisandro@debian.org>
Tue, 5 Feb 2013 21:52:29 +0000 (21:52 +0000)
Change-Id: I8fc753f09126651af3fb82df3049050f0b14e876
(cherry-picked from Qt 5 commit 856f209fb63ae336bfb389a12d2a75fa886dc1c5)
Reviewed-by: Richard J. Moore <rich@kde.org>
Gbp-Pq: Name change_all_shmget_calls_to_use_user-only_memory.patch

src/corelib/kernel/qsharedmemory_unix.cpp
src/corelib/kernel/qsystemsemaphore_unix.cpp
src/gui/image/qnativeimage.cpp
src/gui/image/qpixmap_x11.cpp
src/plugins/platforms/xcb/qxcbwindowsurface.cpp
src/plugins/platforms/xlib/qxlibwindowsurface.cpp
tools/qvfb/qvfbshmem.cpp

index 8348b2be6fbe7ce0cd3985ccc7e775132caf4d7d..f7e1f601b27bc218b4cdf3515ea4b64f71fb1a05 100644 (file)
@@ -238,7 +238,7 @@ bool QSharedMemoryPrivate::create(int size)
     }
 
     // create
-    if (-1 == shmget(unix_key, size, 0666 | IPC_CREAT | IPC_EXCL)) {
+    if (-1 == shmget(unix_key, size, 0600 | IPC_CREAT | IPC_EXCL)) {
         QString function = QLatin1String("QSharedMemory::create");
         switch (errno) {
         case EINVAL:
@@ -293,7 +293,7 @@ bool QSharedMemoryPrivate::attach(QSharedMemory::AccessMode mode)
 {
 #ifndef QT_POSIX_IPC
     // grab the shared memory segment id
-    int id = shmget(unix_key, 0, (mode == QSharedMemory::ReadOnly ? 0444 : 0660));
+    int id = shmget(unix_key, 0, (mode == QSharedMemory::ReadOnly ? 0400 : 0600));
     if (-1 == id) {
         setErrorString(QLatin1String("QSharedMemory::attach (shmget)"));
         return false;
@@ -381,7 +381,7 @@ bool QSharedMemoryPrivate::detach()
     size = 0;
 
     // Get the number of current attachments
-    int id = shmget(unix_key, 0, 0444);
+    int id = shmget(unix_key, 0, 0400);
     cleanHandle();
 
     struct shmid_ds shmid_ds;
index c987c83b35ea819566c5e6fe9134cc8953c1b06e..d497d85d05d3ad6258690dbf42625ba47319dd02 100644 (file)
@@ -153,10 +153,10 @@ key_t QSystemSemaphorePrivate::handle(QSystemSemaphore::AccessMode mode)
     }
 
     // Get semaphore
-    semaphore = semget(unix_key, 1, 0666 | IPC_CREAT | IPC_EXCL);
+    semaphore = semget(unix_key, 1, 0600 | IPC_CREAT | IPC_EXCL);
     if (-1 == semaphore) {
         if (errno == EEXIST)
-            semaphore = semget(unix_key, 1, 0666 | IPC_CREAT);
+            semaphore = semget(unix_key, 1, 0600 | IPC_CREAT);
         if (-1 == semaphore) {
             setErrorString(QLatin1String("QSystemSemaphore::handle"));
             cleanHandle();
index 4195f4ecd0db3aa8b1e94bb8fb32bac34a45f0b1..36096479cb227cb11b0c834fd32652ddd9057b15 100644 (file)
@@ -176,7 +176,7 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /*
 
     bool ok;
     xshminfo.shmid = shmget(IPC_PRIVATE, xshmimg->bytes_per_line * xshmimg->height,
-                            IPC_CREAT | 0777);
+                            IPC_CREAT | 0700);
     ok = xshminfo.shmid != -1;
     if (ok) {
         xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0);
index 2a72a91ec3b67a9f3fdac65f9cd09892265cc6c0..f4e6b1197904fb569277142007515a29ad017f94 100644 (file)
@@ -193,7 +193,7 @@ static bool qt_create_mitshm_buffer(const QPaintDevice* dev, int w, int h)
     bool ok;
     xshminfo.shmid = shmget(IPC_PRIVATE,
                              xshmimg->bytes_per_line * xshmimg->height,
-                             IPC_CREAT | 0777);
+                             IPC_CREAT | 0700);
     ok = xshminfo.shmid != -1;
     if (ok) {
         xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0);
index 57db4cebadcc6381b29d2571f15f968c7eb03d79..fd696994dd3fb66f3c4ba2c827b5f16977c4e26c 100644 (file)
@@ -98,7 +98,7 @@ QXcbShmImage::QXcbShmImage(QXcbScreen *screen, const QSize &size, uint depth, QI
                                           0);
 
     m_shm_info.shmid = shmget (IPC_PRIVATE,
-          m_xcb_image->stride * m_xcb_image->height, IPC_CREAT|0777);
+          m_xcb_image->stride * m_xcb_image->height, IPC_CREAT|0600);
 
     m_shm_info.shmaddr = m_xcb_image->data = (quint8 *)shmat (m_shm_info.shmid, 0, 0);
     m_shm_info.shmseg = xcb_generate_id(xcb_connection());
index 44f150c6d520fe2f614abf2d705c8c846bc85bc3..d4172c8e6cba524f1a80ef7b419730c13a0a1343 100644 (file)
@@ -99,7 +99,7 @@ void QXlibWindowSurface::resizeShmImage(int width, int height)
 
 
     image_info->shminfo.shmid = shmget (IPC_PRIVATE,
-          image->bytes_per_line * image->height, IPC_CREAT|0777);
+          image->bytes_per_line * image->height, IPC_CREAT|0700);
 
     image_info->shminfo.shmaddr = image->data = (char*)shmat (image_info->shminfo.shmid, 0, 0);
     image_info->shminfo.readOnly = False;
index c8629a254418bfa0722595cd633816b8991da626..58340fa75612f49a54ca7cd355efe388c8d1dfb6 100644 (file)
@@ -176,13 +176,13 @@ QShMemViewProtocol::QShMemViewProtocol(int displayid, const QSize &s,
     uint data_offset_value = sizeof(QVFbHeader);
 
     int dataSize = bpl * h + data_offset_value;
-    shmId = shmget(key, dataSize, IPC_CREAT | 0666);
+    shmId = shmget(key, dataSize, IPC_CREAT | 0600);
     if (shmId != -1)
        data = (unsigned char *)shmat(shmId, 0, 0);
     else {
        struct shmid_ds shm;
        shmctl(shmId, IPC_RMID, &shm);
-       shmId = shmget(key, dataSize, IPC_CREAT | 0666);
+    shmId = shmget(key, dataSize, IPC_CREAT | 0600);
        if (shmId == -1) {
             perror("QShMemViewProtocol::QShMemViewProtocol");
             qFatal("Cannot get shared memory 0x%08x", key);