Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-24117

Mongo binaries ELF stack has become executable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Fixed
    • Affects Version/s: 3.2.5, 3.2.6
    • Fix Version/s: 3.2.7, 3.3.6
    • Component/s: Build
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Backport Completed:
    • Steps To Reproduce:
      Hide

      Always since 3.2.5

      This affect also builds from https://www.mongodb.com/download-center#community

      Tested for RHEL 7 64-bit and Amazon 64-bit.

      Show
      Always since 3.2.5 This affect also builds from https://www.mongodb.com/download-center#community Tested for RHEL 7 64-bit and Amazon 64-bit.
    • Sprint:
      Platforms 14 (05/13/16)

      Description

      mongod, mongoperf and mongosniff has executable GNU_STACK. This is a real error. It means the program has an executable stack. This leaves the program vulnerable to buffer overflows.

      $ execstack path/to/binary

      • path/to/binary

      A - indicates the secure non-executability.

      If that shows an X or ? next to a file name, then the stack will be executable, i.e. insecure, i.e. bad. Furthermore, ? indicates a binary built with no marking at all, which is almost certainly a build error of some kind.

      You can check it by execstack program.

      [mskalick@unused-4-188 tmp]$ execstack bin/*
      - bin/bsondump
      - bin/mongo
      X bin/mongod
      - bin/mongodump
      - bin/mongoexport
      - bin/mongofiles
      - bin/mongoimport
      - bin/mongooplog
      X bin/mongoperf
      - bin/mongorestore
      - bin/mongos
      - bin/mongostat
      - bin/mongotop
      

      (I was trying to build MongoDB myself and mongosniff is also affected)

      Binaries from 3.2.4 are not affected. So this was introduced in 3.2.5.

      More info https://wiki.gentoo.org/wiki/Hardened/GNU_stack_quickstart

        Issue Links

          Activity

          Hide
          acm Andrew Morrow added a comment -

          Hi Marek Skalický - Thanks for reporting this. We are already aware of the issue, which we agree is serious, and we are working on a fix.

          Show
          acm Andrew Morrow added a comment - Hi Marek Skalický - Thanks for reporting this. We are already aware of the issue, which we agree is serious, and we are working on a fix.
          Hide
          mskalick Marek Skalický added a comment -

          Will mongod work correctly with gcc --noexecstack compile flag?

          Show
          mskalick Marek Skalický added a comment - Will mongod work correctly with gcc --noexecstack compile flag?
          Hide
          acm Andrew Morrow added a comment -

          Yes, building with -Wl,-z,noexecstack added into LINKFLAGS should work fine:

          scons LINKFLAGS="-Wl,-z,noexecstack" ...
          

          If you could confirm that in your environment that would be helpful, as the fix we are introducing is similar.

          Show
          acm Andrew Morrow added a comment - Yes, building with -Wl,-z,noexecstack added into LINKFLAGS should work fine: scons LINKFLAGS="-Wl,-z,noexecstack" ... If you could confirm that in your environment that would be helpful, as the fix we are introducing is similar.
          Hide
          mskalick Marek Skalický added a comment - - edited

          I am building MongoDB 3.2.6 for RHEL7 x86_64 and unittests and core jstests are working. I will inform you if other JS testsuites don't pass.

          Show
          mskalick Marek Skalický added a comment - - edited I am building MongoDB 3.2.6 for RHEL7 x86_64 and unittests and core jstests are working. I will inform you if other JS testsuites don't pass.
          Hide
          xgen-internal-githook Githook User added a comment -

          Author:

          {u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}

          Message: SERVER-24117 Force the stack to always be non-executable

          Also, warn if the stack would have been executable if we hadn't forced
          it not to be, so we can find and correct broken assmbley source files.
          Branch: master
          https://github.com/mongodb/mongo/commit/23c5d7e44c5447769a46e6d4e10ae6237e8de5fd

          Show
          xgen-internal-githook Githook User added a comment - Author: {u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'} Message: SERVER-24117 Force the stack to always be non-executable Also, warn if the stack would have been executable if we hadn't forced it not to be, so we can find and correct broken assmbley source files. Branch: master https://github.com/mongodb/mongo/commit/23c5d7e44c5447769a46e6d4e10ae6237e8de5fd
          Hide
          acm Andrew Morrow added a comment -

          Marek Skalický - I've just pushed a commit to master to address this. Assuming it works as expected we will backport it to 3.2. If you have an opportunity to test it in your environment by building the master branch, that would be valuable information.

          Show
          acm Andrew Morrow added a comment - Marek Skalický - I've just pushed a commit to master to address this. Assuming it works as expected we will backport it to 3.2. If you have an opportunity to test it in your environment by building the master branch, that would be valuable information.
          Hide
          xgen-internal-githook Githook User added a comment -

          Author:

          {u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'}

          Message: SERVER-24117 Force the stack to always be non-executable

          Also, warn if the stack would have been executable if we hadn't forced
          it not to be, so we can find and correct broken assmbley source files.

          (cherry picked from commit 23c5d7e44c5447769a46e6d4e10ae6237e8de5fd)
          Branch: v3.2
          https://github.com/mongodb/mongo/commit/61965e5792b29e3aaa04421e848731f1f2457766

          Show
          xgen-internal-githook Githook User added a comment - Author: {u'username': u'acmorrow', u'name': u'Andrew Morrow', u'email': u'acm@mongodb.com'} Message: SERVER-24117 Force the stack to always be non-executable Also, warn if the stack would have been executable if we hadn't forced it not to be, so we can find and correct broken assmbley source files. (cherry picked from commit 23c5d7e44c5447769a46e6d4e10ae6237e8de5fd) Branch: v3.2 https://github.com/mongodb/mongo/commit/61965e5792b29e3aaa04421e848731f1f2457766

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                  Agile