1. 15 Sep, 2018 2 commits
    • Greg Hackmann's avatar
      staging: android: ion: fix ION_IOC_{MAP,SHARE} use-after-free · 2c155709
      Greg Hackmann authored
      The ION_IOC_{MAP,SHARE} ioctls drop and reacquire client->lock several
      times while operating on one of the client's ion_handles.  This creates
      windows where userspace can call ION_IOC_FREE on the same client with
      the same handle, and effectively make the kernel drop its own reference.
      For example:
      
      - thread A: ION_IOC_ALLOC creates an ion_handle with refcount 1
      - thread A: starts ION_IOC_MAP and increments the refcount to 2
      - thread B: ION_IOC_FREE decrements the refcount to 1
      - thread B: ION_IOC_FREE decrements the refcount to 0 and frees the
                  handle
      - thread A: continues ION_IOC_MAP with a dangling ion_handle * to
                  freed memory
      
      Fix this by holding client->lock for the duration of
      ION_IOC_{MAP,SHARE}, preventing the concurrent ION_IOC_FREE.  Also
      remove ion_handle_get_by_id(), since there's literally no way to use it
      safely.
      
      This patch is applied on top of 4.4.y, and applies to older kernels
      too.  4.9.y was fixed separately.  Kernels 4.12 and later are
      unaffected, since all the underlying ion_handle infrastructure has been
      ripped out.
      
      Cc: stable@vger.kernel.org # v4.4-
      Signed-off-by: default avatarGreg Hackmann <ghackmann@google.com>
      Acked-by: default avatarLaura Abbott <labbott@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2c155709
    • Michal Hocko's avatar
      x86/speculation/l1tf: Fix up pte->pfn conversion for PAE · e3dea38f
      Michal Hocko authored
      commit e14d7dfb upstream.
      
      Jan has noticed that pte_pfn and co. resp. pfn_pte are incorrect for
      CONFIG_PAE because phys_addr_t is wider than unsigned long and so the
      pte_val reps. shift left would get truncated. Fix this up by using proper
      types.
      
      [Just one chunk, again, needed here.  Thanks to Ben and Guenter for
      finding and fixing this. - gregkh]
      
      Fixes: 6b28baca ("x86/speculation/l1tf: Protect PROT_NONE PTEs against speculation")
      Reported-by: default avatarJan Beulich <JBeulich@suse.com>
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e3dea38f
  2. 09 Sep, 2018 38 commits