You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2018/02/16 16:15:11 UTC

[1/2] mesos git commit: Fixed the type-punned pointer and strict aliasing issue.

Repository: mesos
Updated Branches:
  refs/heads/1.4.x e41742037 -> 638d24dbb


Fixed the type-punned pointer and strict aliasing issue.

Dereferencing a pointer cast from a different type of pointer
violates the so-called "strict aliasing" rule, which is undefined
behaviour and might lead to bugs when compiler optimizations are
enabled.

For more information on this topic, see
https://blog.regehr.org/archives/959
http://alas.matf.bg.ac.rs/manuals/lspe/snode=153.html

Review: https://reviews.apache.org/r/64686/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/dade7f5c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/dade7f5c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/dade7f5c

Branch: refs/heads/1.4.x
Commit: dade7f5c68b54ebe18a50c619af1bb2ad49d4bd1
Parents: e417420
Author: Alexander Rukletsov <al...@apache.org>
Authored: Fri Feb 16 17:02:16 2018 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Feb 16 17:13:45 2018 +0100

----------------------------------------------------------------------
 src/linux/ns.hpp | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/dade7f5c/src/linux/ns.hpp
----------------------------------------------------------------------
diff --git a/src/linux/ns.hpp b/src/linux/ns.hpp
index be96d5b..87d66e1 100644
--- a/src/linux/ns.hpp
+++ b/src/linux/ns.hpp
@@ -25,9 +25,11 @@
 #include <sched.h>
 #include <unistd.h>
 
+#include <sys/socket.h>
 #include <sys/syscall.h>
 #include <sys/wait.h>
 
+#include <cstring>
 #include <set>
 #include <string>
 #include <vector>
@@ -496,7 +498,11 @@ inline Try<pid_t> clone(
       return Error("Bad control data received");
     }
 
-    pid_t pid = ((struct ucred*) CMSG_DATA(CMSG_FIRSTHDR(&message)))->pid;
+    struct ucred cred;
+    std::memcpy(
+        &cred, CMSG_DATA(CMSG_FIRSTHDR(&message)), sizeof(struct ucred));
+
+    const pid_t pid = cred.pid;
 
     // Need to `waitpid` on child process to avoid a zombie. Note that
     // it's expected that the child will terminate quickly hence
@@ -554,17 +560,20 @@ inline Try<pid_t> clone(
           stack.get(),
           flags,
           [=]() {
-            struct ucred* cred = reinterpret_cast<struct ucred*>(
-                CMSG_DATA(CMSG_FIRSTHDR(&message)));
+            struct ucred cred;
+            cred.pid = ::getpid();
+            cred.uid = ::getuid();
+            cred.gid = ::getgid();
 
             // Now send back the pid and have it be translated appropriately
             // by the kernel to the enclosing pid namespace.
             //
             // NOTE: sending back the pid is best effort because we're going
             // to exit no matter what.
-            cred->pid = ::getpid();
-            cred->uid = ::getuid();
-            cred->gid = ::getgid();
+            std::memcpy(
+                CMSG_DATA(CMSG_FIRSTHDR(&message)),
+                &cred,
+                sizeof(struct ucred));
 
             if (sendmsg(sockets[1], &message, 0) == -1) {
               // Failed to send the pid back to the parent!


[2/2] mesos git commit: Added MESOS-6616 to the 1.4.2 CHANGELOG.

Posted by al...@apache.org.
Added MESOS-6616 to the 1.4.2 CHANGELOG.


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/638d24db
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/638d24db
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/638d24db

Branch: refs/heads/1.4.x
Commit: 638d24dbbf64baf42d3923d9bd55527425cfbc2a
Parents: dade7f5
Author: Alexander Rukletsov <al...@apache.org>
Authored: Fri Feb 16 17:04:07 2018 +0100
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Feb 16 17:14:46 2018 +0100

----------------------------------------------------------------------
 CHANGELOG | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/638d24db/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 583e87d..27d403c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ Release Notes - Mesos - Version 1.4.2 (WIP)
 * This is a bug fix release.
 
 ** Bug
+ * [MESOS-6616] - Error: dereferencing type-punned pointer will break strict-aliasing rules.
  * [MESOS-7504] - Parent's mount namespace cannot be determined when launching a nested container.
  * [MESOS-7975] - The command/default/docker executor can incorrectly send a TASK_FINISHED update even when the task is killed.
  * [MESOS-8125] - Agent should properly handle recovering an executor when its pid is reused.