1. 01 8月, 2021 1 次提交
    • M
      iscsi_ibft: fix crash due to KASLR physical memory remapping · 342f43af
      Maurizio Lombardi 提交于
      Starting with commit a799c2bd
      ("x86/setup: Consolidate early memory reservations")
      memory reservations have been moved earlier during the boot process,
      before the execution of the Kernel Address Space Layout Randomization code.
      
      setup_arch() calls the iscsi_ibft's find_ibft_region() function
      to find and reserve the memory dedicated to the iBFT and this function
      also saves a virtual pointer to the iBFT table for later use.
      
      The problem is that if KALSR is active, the physical memory gets
      remapped somewhere else in the virtual address space and the pointer is
      no longer valid, this will cause a kernel panic when the iscsi driver tries
      to dereference it.
      
       iBFT detected.
       BUG: unable to handle page fault for address: ffff888000099fd8
       #PF: supervisor read access in kernel mode
       #PF: error_code(0x0000) - not-present page
       PGD 0 P4D 0
       Oops: 0000 [#1] SMP PTI
      
      ..snip..
      
       Call Trace:
        ? ibft_create_kobject+0x1d2/0x1d2 [iscsi_ibft]
        do_one_initcall+0x44/0x1d0
        ? kmem_cache_alloc_trace+0x119/0x220
        do_init_module+0x5c/0x270
        __do_sys_init_module+0x12e/0x1b0
        do_syscall_64+0x40/0x80
        entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Fix this bug by saving the address of the physical location
      of the ibft; later the driver will use isa_bus_to_virt() to get
      the correct virtual address.
      
      N.B. On each reboot KASLR randomizes the virtual addresses so
      assuming phys_to_virt before KASLR does its deed is incorrect.
      
      Simplify the code by renaming find_ibft_region()
      to reserve_ibft_region() and remove all the wrappers.
      Signed-off-by: NMaurizio Lombardi <mlombard@redhat.com>
      Reviewed-by: NMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: NKonrad Rzeszutek Wilk <konrad@kernel.org>
      342f43af
  2. 28 6月, 2021 2 次提交
    • L
      Linux 5.13 · 62fb9874
      Linus Torvalds 提交于
      62fb9874
    • L
      Revert "signal: Allow tasks to cache one sigqueue struct" · b4b27b9e
      Linus Torvalds 提交于
      This reverts commits 4bad58eb (and
      399f8dd9, which tried to fix it).
      
      I do not believe these are correct, and I'm about to release 5.13, so am
      reverting them out of an abundance of caution.
      
      The locking is odd, and appears broken.
      
      On the allocation side (in __sigqueue_alloc()), the locking is somewhat
      straightforward: it depends on sighand->siglock.  Since one caller
      doesn't hold that lock, it further then tests 'sigqueue_flags' to avoid
      the case with no locks held.
      
      On the freeing side (in sigqueue_cache_or_free()), there is no locking
      at all, and the logic instead depends on 'current' being a single
      thread, and not able to race with itself.
      
      To make things more exciting, there's also the data race between freeing
      a signal and allocating one, which is handled by using WRITE_ONCE() and
      READ_ONCE(), and being mutually exclusive wrt the initial state (ie
      freeing will only free if the old state was NULL, while allocating will
      obviously only use the value if it was non-NULL, so only one or the
      other will actually act on the value).
      
      However, while the free->alloc paths do seem mutually exclusive thanks
      to just the data value dependency, it's not clear what the memory
      ordering constraints are on it.  Could writes from the previous
      allocation possibly be delayed and seen by the new allocation later,
      causing logical inconsistencies?
      
      So it's all very exciting and unusual.
      
      And in particular, it seems that the freeing side is incorrect in
      depending on "current" being single-threaded.  Yes, 'current' is a
      single thread, but in the presense of asynchronous events even a single
      thread can have data races.
      
      And such asynchronous events can and do happen, with interrupts causing
      signals to be flushed and thus free'd (for example - sending a
      SIGCONT/SIGSTOP can happen from interrupt context, and can flush
      previously queued process control signals).
      
      So regardless of all the other questions about the memory ordering and
      locking for this new cached allocation, the sigqueue_cache_or_free()
      assumptions seem to be fundamentally incorrect.
      
      It may be that people will show me the errors of my ways, and tell me
      why this is all safe after all.  We can reinstate it if so.  But my
      current belief is that the WRITE_ONCE() that sets the cached entry needs
      to be a smp_store_release(), and the READ_ONCE() that finds a cached
      entry needs to be a smp_load_acquire() to handle memory ordering
      correctly.
      
      And the sequence in sigqueue_cache_or_free() would need to either use a
      lock or at least be interrupt-safe some way (perhaps by using something
      like the percpu 'cmpxchg': it doesn't need to be SMP-safe, but like the
      percpu operations it needs to be interrupt-safe).
      
      Fixes: 399f8dd9 ("signal: Prevent sigqueue caching after task got released")
      Fixes: 4bad58eb ("signal: Allow tasks to cache one sigqueue struct")
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b4b27b9e
  3. 27 6月, 2021 1 次提交
    • L
      Merge tag 's390-5.13-5' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux · 625acffd
      Linus Torvalds 提交于
      Pull s390 fixes from Vasily Gorbik:
      
       - Fix a couple of late pt_regs flags handling findings of conversion to
         generic entry.
      
       - Fix potential register clobbering in stack switch helper.
      
       - Fix thread/group masks for offline cpus.
      
       - Fix cleanup of mdev resources when remove callback is invoked in
         vfio-ap code.
      
      * tag 's390-5.13-5' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
        s390/stack: fix possible register corruption with stack switch helper
        s390/topology: clear thread/group maps for offline cpus
        s390/vfio-ap: clean up mdev resources when remove callback invoked
        s390: clear pt_regs::flags on irq entry
        s390: fix system call restart with multiple signals
      625acffd
  4. 26 6月, 2021 13 次提交
  5. 25 6月, 2021 23 次提交