1. 20 Nov, 2016 34 commits
  2. 20 Oct, 2016 2 commits
    • Ben Hutchings's avatar
      Linux 3.2.83 · e0aed024
      Ben Hutchings authored
      e0aed024
    • Michal Hocko's avatar
      mm, gup: close FOLL MAP_PRIVATE race · 243f858d
      Michal Hocko authored
      commit 19be0eaf upstream.
      
      faultin_page drops FOLL_WRITE after the page fault handler did the CoW
      and then we retry follow_page_mask to get our CoWed page. This is racy,
      however because the page might have been unmapped by that time and so
      we would have to do a page fault again, this time without CoW. This
      would cause the page cache corruption for FOLL_FORCE on MAP_PRIVATE
      read only mappings with obvious consequences.
      
      This is an ancient bug that was actually already fixed once by Linus
      eleven years ago in commit 4ceb5db9 ("Fix get_user_pages() race
      for write access") but that was then undone due to problems on s390
      by commit f33ea7f4 ("fix get_user_pages bug") because s390 didn't
      have proper dirty pte tracking until abf09bed ("s390/mm: implement
      software dirty bits"). This wasn't a problem at the time as pointed out
      by Hugh Dickins because madvise relied on mmap_sem for write up until
      0a27a14a ("mm: madvise avoid exclusive mmap_sem") but since then we
      can race with madvise which can unmap the fresh COWed page or with KSM
      and corrupt the content of the shared page.
      
      This patch is based on the Linus' approach to not clear FOLL_WRITE after
      the CoW page fault (aka VM_FAULT_WRITE) but instead introduces FOLL_COW
      to note this fact. The flag is then rechecked during follow_pfn_pte to
      enforce the page fault again if we do not see the CoWed page. Linus was
      suggesting to check pte_dirty again as s390 is OK now. But that would
      make backporting to some old kernels harder. So instead let's just make
      sure that vm_normal_page sees a pure anonymous page.
      
      This would guarantee we are seeing a real CoW page. Introduce
      can_follow_write_pte which checks both pte_write and falls back to
      PageAnon on forced write faults which passed CoW already. Thanks to Hugh
      to point out that a special care has to be taken for KSM pages because
      our COWed page might have been merged with a KSM one and keep its
      PageAnon flag.
      
      Fixes: 0a27a14a ("mm: madvise avoid exclusive mmap_sem")
      Reported-by: default avatarPhil "not Paul" Oester <kernel@linuxace.com>
      Disclosed-by: default avatarAndy Lutomirski <luto@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarMichal Hocko <mhocko@suse.com>
      [bwh: Backported to 3.2:
       - Adjust filename, context, indentation
       - The 'no_page' exit path in follow_page() is different, so open-code the
         cleanup
       - Delete a now-unused label]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      243f858d
  3. 22 Aug, 2016 4 commits
    • Ben Hutchings's avatar
      Linux 3.2.82 · f098a0c6
      Ben Hutchings authored
      f098a0c6
    • Paul Moore's avatar
      audit: fix a double fetch in audit_log_single_execve_arg() · 143d0f16
      Paul Moore authored
      commit 43761473 upstream.
      
      There is a double fetch problem in audit_log_single_execve_arg()
      where we first check the execve(2) argumnets for any "bad" characters
      which would require hex encoding and then re-fetch the arguments for
      logging in the audit record[1].  Of course this leaves a window of
      opportunity for an unsavory application to munge with the data.
      
      This patch reworks things by only fetching the argument data once[2]
      into a buffer where it is scanned and logged into the audit
      records(s).  In addition to fixing the double fetch, this patch
      improves on the original code in a few other ways: better handling
      of large arguments which require encoding, stricter record length
      checking, and some performance improvements (completely unverified,
      but we got rid of some strlen() calls, that's got to be a good
      thing).
      
      As part of the development of this patch, I've also created a basic
      regression test for the audit-testsuite, the test can be tracked on
      GitHub at the following link:
      
       * https://github.com/linux-audit/audit-testsuite/issues/25
      
      [1] If you pay careful attention, there is actually a triple fetch
      problem due to a strnlen_user() call at the top of the function.
      
      [2] This is a tiny white lie, we do make a call to strnlen_user()
      prior to fetching the argument data.  I don't like it, but due to the
      way the audit record is structured we really have no choice unless we
      copy the entire argument at once (which would require a rather
      wasteful allocation).  The good news is that with this patch the
      kernel no longer relies on this strnlen_user() value for anything
      beyond recording it in the log, we also update it with a trustworthy
      value whenever possible.
      Reported-by: default avatarPengfei Wang <wpengfeinudt@gmail.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      [bwh: Backported to 3.2:
       - In audit_log_execve_info() various information is retrieved via
         the extra parameter struct audit_aux_data_execve *axi
       - Adjust context]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      143d0f16
    • Eric Dumazet's avatar
      tcp: make challenge acks less predictable · 07ab6b62
      Eric Dumazet authored
      commit 75ff39cc upstream.
      
      Yue Cao claims that current host rate limiting of challenge ACKS
      (RFC 5961) could leak enough information to allow a patient attacker
      to hijack TCP sessions. He will soon provide details in an academic
      paper.
      
      This patch increases the default limit from 100 to 1000, and adds
      some randomization so that the attacker can no longer hijack
      sessions without spending a considerable amount of probes.
      
      Based on initial analysis and patch from Linus.
      
      Note that we also have per socket rate limiting, so it is tempting
      to remove the host limit in the future.
      
      v2: randomize the count of challenge acks per second, not the period.
      
      Fixes: 282f23c6 ("tcp: implement RFC 5961 3.2")
      Reported-by: default avatarYue Cao <ycao009@ucr.edu>
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Cc: Yuchung Cheng <ycheng@google.com>
      Cc: Neal Cardwell <ncardwell@google.com>
      Acked-by: default avatarNeal Cardwell <ncardwell@google.com>
      Acked-by: default avatarYuchung Cheng <ycheng@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      [bwh: Backported to 3.2:
       - Adjust context
       - Use ACCESS_ONCE() instead of {READ,WRITE}_ONCE()
       - Open-code prandom_u32_max()]
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      07ab6b62
    • Kangjie Lu's avatar
      rds: fix an infoleak in rds_inc_info_copy · 948969a4
      Kangjie Lu authored
      commit 4116def2 upstream.
      
      The last field "flags" of object "minfo" is not initialized.
      Copying this object out may leak kernel stack data.
      Assign 0 to it to avoid leak.
      Signed-off-by: default avatarKangjie Lu <kjlu@gatech.edu>
      Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      948969a4