1. 25 1月, 2018 21 次提交
  2. 23 1月, 2018 3 次提交
  3. 20 1月, 2018 1 次提交
    • A
      proc: fix coredump vs read /proc/*/stat race · 8bb2ee19
      Alexey Dobriyan 提交于
      do_task_stat() accesses IP and SP of a task without bumping reference
      count of a stack (which became an entity with independent lifetime at
      some point).
      
      Steps to reproduce:
      
          #include <stdio.h>
          #include <sys/types.h>
          #include <sys/stat.h>
          #include <fcntl.h>
          #include <sys/time.h>
          #include <sys/resource.h>
          #include <unistd.h>
          #include <sys/wait.h>
      
          int main(void)
          {
          	setrlimit(RLIMIT_CORE, &(struct rlimit){});
      
          	while (1) {
          		char buf[64];
          		char buf2[4096];
          		pid_t pid;
          		int fd;
      
          		pid = fork();
          		if (pid == 0) {
          			*(volatile int *)0 = 0;
          		}
      
          		snprintf(buf, sizeof(buf), "/proc/%u/stat", pid);
          		fd = open(buf, O_RDONLY);
          		read(fd, buf2, sizeof(buf2));
          		close(fd);
      
          		waitpid(pid, NULL, 0);
          	}
          	return 0;
          }
      
          BUG: unable to handle kernel paging request at 0000000000003fd8
          IP: do_task_stat+0x8b4/0xaf0
          PGD 800000003d73e067 P4D 800000003d73e067 PUD 3d558067 PMD 0
          Oops: 0000 [#1] PREEMPT SMP PTI
          CPU: 0 PID: 1417 Comm: a.out Not tainted 4.15.0-rc8-dirty #2
          Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1.fc27 04/01/2014
          RIP: 0010:do_task_stat+0x8b4/0xaf0
          Call Trace:
           proc_single_show+0x43/0x70
           seq_read+0xe6/0x3b0
           __vfs_read+0x1e/0x120
           vfs_read+0x84/0x110
           SyS_read+0x3d/0xa0
           entry_SYSCALL_64_fastpath+0x13/0x6c
          RIP: 0033:0x7f4d7928cba0
          RSP: 002b:00007ffddb245158 EFLAGS: 00000246
          Code: 03 b7 a0 01 00 00 4c 8b 4c 24 70 4c 8b 44 24 78 4c 89 74 24 18 e9 91 f9 ff ff f6 45 4d 02 0f 84 fd f7 ff ff 48 8b 45 40 48 89 ef <48> 8b 80 d8 3f 00 00 48 89 44 24 20 e8 9b 97 eb ff 48 89 44 24
          RIP: do_task_stat+0x8b4/0xaf0 RSP: ffffc90000607cc8
          CR2: 0000000000003fd8
      
      John Ogness said: for my tests I added an else case to verify that the
      race is hit and correctly mitigated.
      
      Link: http://lkml.kernel.org/r/20180116175054.GA11513@avx2Signed-off-by: NAlexey Dobriyan <adobriyan@gmail.com>
      Reported-by: N"Kohli, Gaurav" <gkohli@codeaurora.org>
      Tested-by: NJohn Ogness <john.ogness@linutronix.de>
      Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8bb2ee19
  4. 05 1月, 2018 1 次提交
  5. 04 1月, 2018 1 次提交
  6. 03 1月, 2018 5 次提交
  7. 02 1月, 2018 3 次提交
  8. 22 12月, 2017 5 次提交
    • D
      xfs: only skip rmap owner checks for unknown-owner rmap removal · 68c58e9b
      Darrick J. Wong 提交于
      For rmap removal, refactor the rmap owner checks into a separate
      function, then skip the checks if we are performing an unknown-owner
      removal.
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      68c58e9b
    • D
      xfs: always honor OWN_UNKNOWN rmap removal requests · 33df3a9c
      Darrick J. Wong 提交于
      Calling xfs_rmap_free with an unknown owner is supposed to remove any
      rmaps covering that range regardless of owner.  This is used by the EFI
      recovery code to say "we're freeing this, it mustn't be owned by
      anything anymore", but for whatever reason xfs_free_ag_extent filters
      them out.
      
      Therefore, remove the filter and make xfs_rmap_unmap actually treat it
      as a wildcard owner -- free anything that's already there, and if
      there's no owner at all then that's fine too.
      
      There are two existing callers of bmap_add_free that take care the rmap
      deferred ops themselves and use OWN_UNKNOWN to skip the EFI-based rmap
      cleanup; convert these to use OWN_NULL (via helpers), and now we really
      require that an RUI (if any) gets added to the defer ops before any EFI.
      
      Lastly, now that xfs_free_extent filters out OWN_NULL rmap free requests,
      growfs will have to consult directly with the rmap to ensure that there
      aren't any rmaps in the grown region.
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      33df3a9c
    • D
      xfs: queue deferred rmap ops for cow staging extent alloc/free in the right order · 0525e952
      Darrick J. Wong 提交于
      Under the deferred rmap operation scheme, there's a certain order in
      which the rmap deferred ops have to be queued to maintain integrity
      during log replay.  For alloc/map operations that order is cui -> rui;
      for free/unmap operations that order is cui -> rui -> efi.  However, the
      initial refcount code got the ordering wrong in the free side of things
      because it queued refcount free op and an EFI and the refcount free op
      queued a rmap free op, resulting in the order cui -> efi -> rui.
      
      If we fail before the efd finishes, the efi recovery will try to do a
      wildcard rmap removal and the subsequent rui will fail to find the rmap
      and blow up.  This didn't ever happen due to other screws up in handling
      unknown owner rmap removals, but those other screw ups broke recovery in
      other ways, so fix the ordering to follow the intended rules.
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      0525e952
    • D
      xfs: set cowblocks tag for direct cow writes too · 86d692bf
      Darrick J. Wong 提交于
      If a user performs a direct CoW write, we end up loading the CoW fork
      with preallocated extents.  Therefore, we must set the cowblocks tag so
      that they can be cleared out if we run low on space.
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      86d692bf
    • D
      xfs: remove leftover CoW reservations when remounting ro · 10ddf64e
      Darrick J. Wong 提交于
      When we're remounting the filesystem readonly, remove all CoW
      preallocations prior to going ro.  If the fs goes down after the ro
      remount, we never clean up the staging extents, which means xfs_check
      will trip over them on a subsequent run.  Practically speaking, the next
      mount will clean them up too, so this is unlikely to be seen.  Since we
      shut down the cowblocks cleaner on remount-ro, we also have to make sure
      we start it back up if/when we remount-rw.
      
      Found by adding clonerange to fsstress and running xfs/017.
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      10ddf64e