)]}'
{
  "commit": "8c652f96d3852b97a49c331cd0bb02d22f3cb31b",
  "tree": "9752969f2ae7312026bb4037ecd950dafd403d9b",
  "parents": [
    "091069740304c979f957ceacec39c461d0192158"
  ],
  "author": {
    "name": "Oleg Nesterov",
    "email": "oleg@redhat.com",
    "time": "Fri Apr 24 01:01:56 2009 +0200"
  },
  "committer": {
    "name": "Linus Torvalds",
    "email": "torvalds@linux-foundation.org",
    "time": "Fri Apr 24 07:39:45 2009 -0700"
  },
  "message": "do_execve() must not clear fs-\u003ein_exec if it was set by another thread\n\nIf do_execve() fails after check_unsafe_exec(), it clears fs-\u003ein_exec\nunconditionally. This is wrong if we race with our sub-thread which\nalso does do_execve:\n\n\tTwo threads T1 and T2 and another process P, all share the same\n\t-\u003efs.\n\n\tT1 starts do_execve(BAD_FILE). It calls check_unsafe_exec(), since\n\t-\u003efs is shared, we set LSM_UNSAFE but not -\u003ein_exec.\n\n\tP exits and decrements fs-\u003eusers.\n\n\tT2 starts do_execve(), calls check_unsafe_exec(), now -\u003efs is not\n\tshared, we set fs-\u003ein_exec.\n\n\tT1 continues, open_exec(BAD_FILE) fails, we clear -\u003ein_exec and\n\treturn to the user-space.\n\n\tT1 does clone(CLONE_FS /* without CLONE_THREAD */).\n\n\tT2 continues without LSM_UNSAFE_SHARE while -\u003efs is shared with\n\tanother process.\n\nChange check_unsafe_exec() to return res \u003d 1 if we set -\u003ein_exec, and change\ndo_execve() to clear -\u003ein_exec depending on res.\n\nWhen do_execve() suceeds, it is safe to clear -\u003ein_exec unconditionally.\nIt can be set only if we don\u0027t share -\u003efs with another process, and since\nwe already killed all sub-threads either -\u003ein_exec \u003d\u003d 0 or we are the\nonly user of this -\u003efs.\n\nAlso, we do not need fs-\u003elock to clear fs-\u003ein_exec.\n\nSigned-off-by: Oleg Nesterov \u003coleg@redhat.com\u003e\nAcked-by: Roland McGrath \u003croland@redhat.com\u003e\nAcked-by: Hugh Dickins \u003chugh@veritas.com\u003e\nSigned-off-by: Linus Torvalds \u003ctorvalds@linux-foundation.org\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "379a399bf5c33cfd6eb3451f85ba57c16df02c5d",
      "old_mode": 33188,
      "old_path": "fs/compat.c",
      "new_id": "681ed81e6be03a44d4d6722441513c9b0fac621e",
      "new_mode": 33188,
      "new_path": "fs/compat.c"
    },
    {
      "type": "modify",
      "old_id": "052a961e41aad189b264c22e11cfd65a77a1ef22",
      "old_mode": 33188,
      "old_path": "fs/exec.c",
      "new_id": "a2e6989dbc3a42ae3aae845592bcd2087cc57bc6",
      "new_mode": 33188,
      "new_path": "fs/exec.c"
    }
  ]
}
