1. 23 7月, 2022 1 次提交
    • L
      mmu_gather: fix the CONFIG_MMU_GATHER_NO_RANGE case · 7fb5e508
      Linus Torvalds 提交于
      Sudip reports that alpha doesn't build properly, with errors like
      
        include/asm-generic/tlb.h:401:1: error: redefinition of 'tlb_update_vma_flags'
          401 | tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma)
              | ^~~~~~~~~~~~~~~~~~~~
        include/asm-generic/tlb.h:372:1: note: previous definition of 'tlb_update_vma_flags' with type 'void(struct mmu_gather *, struct vm_area_struct *)'
          372 | tlb_update_vma_flags(struct mmu_gather *tlb, struct vm_area_struct *vma) { }
      
      the cause being that We have this odd situation where some architectures
      were never converted to the newer TLB flushing interfaces that have a
      range for the flush.  Instead people left them alone, and we have them
      select the MMU_GATHER_NO_RANGE config option to make the tlb header
      files account for this.
      
      Peter Zijlstra cleaned some of these nasty header file games up in
      commits
      
        1e9fdf21 ("mmu_gather: Remove per arch tlb_{start,end}_vma()")
        18ba064e ("mmu_gather: Let there be one tlb_{start,end}_vma() implementation")
      
      but tlb_update_vma_flags() was left alone, and then commit b67fbebd
      ("mmu_gather: Force tlb-flush VM_PFNMAP vmas") ended up removing only
      _one_ of the two stale duplicate dummy inline functions.
      
      This removes the other stale one.
      
      Somebody braver than me should try to remove MMU_GATHER_NO_RANGE
      entirely, but it requires fixing up the oddball architectures that use
      it: alpha, m68k, microblaze, nios2 and openrisc.
      
      The fixups should be fairly straightforward ("fix the build errors it
      exposes by adding the appropriate range arguments"), but the reason this
      wasn't done in the first place is that so few people end up working on
      those architectures.  But it could be done one architecture at a time,
      hint, hint.
      Reported-by: NSudip Mukherjee (Codethink) <sudipm.mukherjee@gmail.com>
      Fixes: b67fbebd ("mmu_gather: Force tlb-flush VM_PFNMAP vmas")
      Link: https://lore.kernel.org/all/YtpXh0QHWwaEWVAY@debian/
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Nick Piggin <npiggin@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      7fb5e508
  2. 22 7月, 2022 8 次提交
  3. 21 7月, 2022 2 次提交
    • L
      watchqueue: make sure to serialize 'wqueue->defunct' properly · 353f7988
      Linus Torvalds 提交于
      When the pipe is closed, we mark the associated watchqueue defunct by
      calling watch_queue_clear().  However, while that is protected by the
      watchqueue lock, new watchqueue entries aren't actually added under that
      lock at all: they use the pipe->rd_wait.lock instead, and looking up
      that pipe happens without any locking.
      
      The watchqueue code uses the RCU read-side section to make sure that the
      wqueue entry itself hasn't disappeared, but that does not protect the
      pipe_info in any way.
      
      So make sure to actually hold the wqueue lock when posting watch events,
      properly serializing against the pipe being torn down.
      Reported-by: NNoam Rathaus <noamr@ssd-disclosure.com>
      Cc: Greg KH <gregkh@linuxfoundation.org>
      Cc: David Howells <dhowells@redhat.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      353f7988
    • E
      lockdown: Fix kexec lockdown bypass with ima policy · 543ce63b
      Eric Snowberg 提交于
      The lockdown LSM is primarily used in conjunction with UEFI Secure Boot.
      This LSM may also be used on machines without UEFI.  It can also be
      enabled when UEFI Secure Boot is disabled.  One of lockdown's features
      is to prevent kexec from loading untrusted kernels.  Lockdown can be
      enabled through a bootparam or after the kernel has booted through
      securityfs.
      
      If IMA appraisal is used with the "ima_appraise=log" boot param,
      lockdown can be defeated with kexec on any machine when Secure Boot is
      disabled or unavailable.  IMA prevents setting "ima_appraise=log" from
      the boot param when Secure Boot is enabled, but this does not cover
      cases where lockdown is used without Secure Boot.
      
      To defeat lockdown, boot without Secure Boot and add ima_appraise=log to
      the kernel command line; then:
      
        $ echo "integrity" > /sys/kernel/security/lockdown
        $ echo "appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig" > \
          /sys/kernel/security/ima/policy
        $ kexec -ls unsigned-kernel
      
      Add a call to verify ima appraisal is set to "enforce" whenever lockdown
      is enabled.  This fixes CVE-2022-21505.
      
      Cc: stable@vger.kernel.org
      Fixes: 29d3c1c8 ("kexec: Allow kexec_file() with appropriate IMA policy when locked down")
      Signed-off-by: NEric Snowberg <eric.snowberg@oracle.com>
      Acked-by: NMimi Zohar <zohar@linux.ibm.com>
      Reviewed-by: NJohn Haxby <john.haxby@oracle.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      543ce63b
  4. 20 7月, 2022 26 次提交
  5. 19 7月, 2022 3 次提交
    • P
      Merge branch 'amt-fix-validation-and-synchronization-bugs' · b3fcfc4f
      Paolo Abeni 提交于
      Taehee Yoo says:
      
      ====================
      amt: fix validation and synchronization bugs
      
      There are some synchronization issues in the amt module.
      Especially, an amt gateway doesn't well synchronize its own variables
      and status(amt->status).
      It tries to use a workqueue for handles in a single thread.
      A global lock is also good, but it would occur complex locking complex.
      
      In this patchset, only the gateway uses workqueue.
      The reason why only gateway interface uses workqueue is that gateway
      should manage its own states and variables a little bit statefully.
      But relay doesn't need to manage tunnels statefully, stateless is okay.
      So, relay side message handlers are okay to be called concurrently.
      But it doesn't mean that no lock is needed.
      
      Only amt multicast data message type will not be processed by the work
      queue because It contains actual multicast data.
      So, it should be processed immediately.
      
      When any amt gateway events are triggered(sending discovery message by
      delayed_work, sending request message by delayed_work and receiving
      messages), it stores event and skb into the event queue(amt->events[16]).
      Then, workqueue processes these events one by one.
      
      The first patch is to use the work queue.
      
      The second patch is to remove unnecessary lock due to a previous patch.
      
      The third patch is to use READ_ONCE() in the amt module.
      Even if the amt module uses a single thread, some variables (ready4,
      ready6, amt->status) can be accessed concurrently.
      
      The fourth patch is to add missing nonce generation logic when it sends a
      new request message.
      
      The fifth patch is to drop unexpected advertisement messages.
      advertisement message should be received only after the gateway sends
      a discovery message first.
      So, the gateway should drop advertisement messages if it has never
      sent a discovery message and it also should drop duplicate advertisement
      messages.
      Using nonce is good to distinguish whether a received message is an
      expected message or not.
      
      The sixth patch is to drop unexpected query messages.
      This is the same behavior as the fourth patch.
      Query messages should be received only after the gateway sends a request
      message first.
      The nonce variable is used to distinguish whether it is a reply to a
      previous request message or not.
      amt->ready4 and amt->ready6 are used to distinguish duplicate messages.
      
      The seventh patch is to drop unexpected multicast data.
      AMT gateway should not receive multicast data message type before
      establish between gateway and relay.
      In order to drop unexpected multicast data messages, it checks amt->status.
      
      The last patch is to fix a locking problem on the relay side.
      amt->nr_tunnels variable is protected by amt->lock.
      But amt_request_handler() doesn't protect this variable.
      
      v2:
       - Use local_bh_disable() instead of rcu_read_lock_bh() in
         amt_membership_query_handler.
       - Fix using uninitialized variables.
       - Fix unexpectedly start the event_wq after stopping.
       - Fix possible deadlock in amt_event_work().
       - Add a limit variable in amt_event_work() to prevent infinite working.
       - Rename amt_queue_events() to amt_queue_event().
      ====================
      
      Link: https://lore.kernel.org/r/20220717160910.19156-1-ap420073@gmail.comSigned-off-by: NPaolo Abeni <pabeni@redhat.com>
      b3fcfc4f
    • T
      amt: do not use amt->nr_tunnels outside of lock · 98991848
      Taehee Yoo 提交于
      amt->nr_tunnels is protected by amt->lock.
      But, amt_request_handler() has been using this variable without the
      amt->lock.
      So, it expands context of amt->lock in the amt_request_handler() to
      protect amt->nr_tunnels variable.
      
      Fixes: cbc21dc1 ("amt: add data plane of amt interface")
      Signed-off-by: NTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      98991848
    • T
      amt: drop unexpected multicast data · e882827d
      Taehee Yoo 提交于
      AMT gateway interface should not receive unexpected multicast data.
      Multicast data message type should be received after sending an update
      message, which means all establishment between gateway and relay is
      finished.
      So, amt_multicast_data_handler() checks amt->status.
      
      Fixes: cbc21dc1 ("amt: add data plane of amt interface")
      Signed-off-by: NTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: NPaolo Abeni <pabeni@redhat.com>
      e882827d