Skip to content
  1. Sep 05, 2022
    • Jing Leng's avatar
      kbuild: Fix include path in scripts/Makefile.modpost · 583daae6
      Jing Leng authored
      commit 23a0cb8e
      
       upstream.
      
      When building an external module, if users don't need to separate the
      compilation output and source code, they run the following command:
      "make -C $(LINUX_SRC_DIR) M=$(PWD)". At this point, "$(KBUILD_EXTMOD)"
      and "$(src)" are the same.
      
      If they need to separate them, they run "make -C $(KERNEL_SRC_DIR)
      O=$(KERNEL_OUT_DIR) M=$(OUT_DIR) src=$(PWD)". Before running the
      command, they need to copy "Kbuild" or "Makefile" to "$(OUT_DIR)" to
      prevent compilation failure.
      
      So the kernel should change the included path to avoid the copy operation.
      
      Signed-off-by: default avatarJing Leng <jleng@ambarella.com>
      [masahiro: I do not think "M=$(OUT_DIR) src=$(PWD)" is the official way,
      but this patch is a nice clean up anyway.]
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      [nsc: updated context for v4.19]
      Signed-off-by: default avatarNicolas Schier <n.schier@avm.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      583daae6
    • Pawan Gupta's avatar
      x86/bugs: Add "unknown" reporting for MMIO Stale Data · 0616411a
      Pawan Gupta authored
      commit 7df54884 upstream.
      
      Older Intel CPUs that are not in the affected processor list for MMIO
      Stale Data vulnerabilities currently report "Not affected" in sysfs,
      which may not be correct. Vulnerability status for these older CPUs is
      unknown.
      
      Add known-not-affected CPUs to the whitelist. Report "unknown"
      mitigation status for CPUs that are not in blacklist, whitelist and also
      don't enumerate MSR ARCH_CAPABILITIES bits that reflect hardware
      immunity to MMIO Stale Data vulnerabilities.
      
      Mitigation is not deployed when the status is unknown.
      
        [ bp: Massage, fixup. ]
      
      Fixes: 8d50cdf8
      
       ("x86/speculation/mmio: Add sysfs reporting for Processor MMIO Stale Data")
      Suggested-by: default avatarAndrew Cooper <andrew.cooper3@citrix.com>
      Suggested-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/a932c154772f2121794a5f2eded1a11013114711.1657846269.git.pawan.kumar.gupta@linux.intel.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0616411a
    • Gayatri Kammela's avatar
      x86/cpu: Add Tiger Lake to Intel family · 1a2429c4
      Gayatri Kammela authored
      commit 6e1c32c5
      
       upstream.
      
      Add the model numbers/CPUIDs of Tiger Lake mobile and desktop to the
      Intel family.
      
      Suggested-by: default avatarTony Luck <tony.luck@intel.com>
      Signed-off-by: default avatarGayatri Kammela <gayatri.kammela@intel.com>
      Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
      Reviewed-by: default avatarTony Luck <tony.luck@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Rahul Tanwar <rahul.tanwar@linux.intel.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: https://lkml.kernel.org/r/20190905193020.14707-2-tony.luck@intel.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarPawan Gupta <pawan.kumar.gupta@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1a2429c4
    • Gerald Schaefer's avatar
      s390/mm: do not trigger write fault when vma does not allow VM_WRITE · 210d22b7
      Gerald Schaefer authored
      commit 41ac42f1 upstream.
      
      For non-protection pXd_none() page faults in do_dat_exception(), we
      call do_exception() with access == (VM_READ | VM_WRITE | VM_EXEC).
      In do_exception(), vma->vm_flags is checked against that before
      calling handle_mm_fault().
      
      Since commit 92f842ea ("[S390] store indication fault optimization"),
      we call handle_mm_fault() with FAULT_FLAG_WRITE, when recognizing that
      it was a write access. However, the vma flags check is still only
      checking against (VM_READ | VM_WRITE | VM_EXEC), and therefore also
      calling handle_mm_fault() with FAULT_FLAG_WRITE in cases where the vma
      does not allow VM_WRITE.
      
      Fix this by changing access check in do_exception() to VM_WRITE only,
      when recognizing write access.
      
      Link: https://lkml.kernel.org/r/20220811103435.188481-3-david@redhat.com
      Fixes: 92f842ea
      
       ("[S390] store indication fault optimization")
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarGerald Schaefer <gerald.schaefer@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarGerald Schaefer <gerald.schaefer@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      210d22b7
    • Jann Horn's avatar
      mm: Force TLB flush for PFNMAP mappings before unlink_file_vma() · 390f33a9
      Jann Horn authored
      commit b67fbebd upstream.
      
      Some drivers rely on having all VMAs through which a PFN might be
      accessible listed in the rmap for correctness.
      However, on X86, it was possible for a VMA with stale TLB entries
      to not be listed in the rmap.
      
      This was fixed in mainline with
      commit b67fbebd ("mmu_gather: Force tlb-flush VM_PFNMAP vmas"),
      but that commit relies on preceding refactoring in
      commit 18ba064e ("mmu_gather: Let there be one tlb_{start,end}_vma()
      implementation") and commit 1e9fdf21
      
       ("mmu_gather: Remove per arch
      tlb_{start,end}_vma()").
      
      This patch provides equivalent protection without needing that
      refactoring, by forcing a TLB flush between removing PTEs in
      unmap_vmas() and the call to unlink_file_vma() in free_pgtables().
      
      [This is a stable-specific rewrite of the upstream commit!]
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      390f33a9
    • David Hildenbrand's avatar
      mm/hugetlb: fix hugetlb not supporting softdirty tracking · 9ac3240f
      David Hildenbrand authored
      commit f96f7a40 upstream.
      
      Patch series "mm/hugetlb: fix write-fault handling for shared mappings", v2.
      
      I observed that hugetlb does not support/expect write-faults in shared
      mappings that would have to map the R/O-mapped page writable -- and I
      found two case where we could currently get such faults and would
      erroneously map an anon page into a shared mapping.
      
      Reproducers part of the patches.
      
      I propose to backport both fixes to stable trees.  The first fix needs a
      small adjustment.
      
      
      This patch (of 2):
      
      Staring at hugetlb_wp(), one might wonder where all the logic for shared
      mappings is when stumbling over a write-protected page in a shared
      mapping.  In fact, there is none, and so far we thought we could get away
      with that because e.g., mprotect() should always do the right thing and
      map all pages directly writable.
      
      Looks like we were wrong:
      
      --------------------------------------------------------------------------
       #include <stdio.h>
       #include <stdlib.h>
       #include <string.h>
       #include <fcntl.h>
       #include <unistd.h>
       #include <errno.h>
       #include <sys/mman.h>
      
       #define HUGETLB_SIZE (2 * 1024 * 1024u)
      
       static void clear_softdirty(void)
       {
               int fd = open("/proc/self/clear_refs", O_WRONLY);
               const char *ctrl = "4";
               int ret;
      
               if (fd < 0) {
                       fprintf(stderr, "open(clear_refs) failed\n");
                       exit(1);
               }
               ret = write(fd, ctrl, strlen(ctrl));
               if (ret != strlen(ctrl)) {
                       fprintf(stderr, "write(clear_refs) failed\n");
                       exit(1);
               }
               close(fd);
       }
      
       int main(int argc, char **argv)
       {
               char *map;
               int fd;
      
               fd = open("/dev/hugepages/tmp", O_RDWR | O_CREAT);
               if (!fd) {
                       fprintf(stderr, "open() failed\n");
                       return -errno;
               }
               if (ftruncate(fd, HUGETLB_SIZE)) {
                       fprintf(stderr, "ftruncate() failed\n");
                       return -errno;
               }
      
               map = mmap(NULL, HUGETLB_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
               if (map == MAP_FAILED) {
                       fprintf(stderr, "mmap() failed\n");
                       return -errno;
               }
      
               *map = 0;
      
               if (mprotect(map, HUGETLB_SIZE, PROT_READ)) {
                       fprintf(stderr, "mmprotect() failed\n");
                       return -errno;
               }
      
               clear_softdirty();
      
               if (mprotect(map, HUGETLB_SIZE, PROT_READ|PROT_WRITE)) {
                       fprintf(stderr, "mmprotect() failed\n");
                       return -errno;
               }
      
               *map = 0;
      
               return 0;
       }
      --------------------------------------------------------------------------
      
      Above test fails with SIGBUS when there is only a single free hugetlb page.
       # echo 1 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
       # ./test
       Bus error (core dumped)
      
      And worse, with sufficient free hugetlb pages it will map an anonymous page
      into a shared mapping, for example, messing up accounting during unmap
      and breaking MAP_SHARED semantics:
       # echo 2 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
       # ./test
       # cat /proc/meminfo | grep HugePages_
       HugePages_Total:       2
       HugePages_Free:        1
       HugePages_Rsvd:    18446744073709551615
       HugePages_Surp:        0
      
      Reason in this particular case is that vma_wants_writenotify() will
      return "true", removing VM_SHARED in vma_set_page_prot() to map pages
      write-protected. Let's teach vma_wants_writenotify() that hugetlb does not
      support softdirty tracking.
      
      Link: https://lkml.kernel.org/r/20220811103435.188481-1-david@redhat.com
      Link: https://lkml.kernel.org/r/20220811103435.188481-2-david@redhat.com
      Fixes: 64e45507
      
       ("mm: softdirty: enable write notifications on VMAs after VM_SOFTDIRTY cleared")
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reviewed-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Cc: Peter Feiner <pfeiner@google.com>
      Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Cyrill Gorcunov <gorcunov@openvz.org>
      Cc: Pavel Emelyanov <xemul@parallels.com>
      Cc: Jamie Liu <jamieliu@google.com>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Muchun Song <songmuchun@bytedance.com>
      Cc: Peter Xu <peterx@redhat.com>
      Cc: <stable@vger.kernel.org>	[3.18+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ac3240f
    • Quanyang Wang's avatar
      asm-generic: sections: refactor memory_intersects · 6a0108b1
      Quanyang Wang authored
      commit 0c7d7cc2 upstream.
      
      There are two problems with the current code of memory_intersects:
      
      First, it doesn't check whether the region (begin, end) falls inside the
      region (virt, vend), that is (virt < begin && vend > end).
      
      The second problem is if vend is equal to begin, it will return true but
      this is wrong since vend (virt + size) is not the last address of the
      memory region but (virt + size -1) is.  The wrong determination will
      trigger the misreporting when the function check_for_illegal_area calls
      memory_intersects to check if the dma region intersects with stext region.
      
      The misreporting is as below (stext is at 0x80100000):
       WARNING: CPU: 0 PID: 77 at kernel/dma/debug.c:1073 check_for_illegal_area+0x130/0x168
       DMA-API: chipidea-usb2 e0002000.usb: device driver maps memory from kernel text or rodata [addr=800f0000] [len=65536]
       Modules linked in:
       CPU: 1 PID: 77 Comm: usb-storage Not tainted 5.19.0-yocto-standard #5
       Hardware name: Xilinx Zynq Platform
        unwind_backtrace from show_stack+0x18/0x1c
        show_stack from dump_stack_lvl+0x58/0x70
        dump_stack_lvl from __warn+0xb0/0x198
        __warn from warn_slowpath_fmt+0x80/0xb4
        warn_slowpath_fmt from check_for_illegal_area+0x130/0x168
        check_for_illegal_area from debug_dma_map_sg+0x94/0x368
        debug_dma_map_sg from __dma_map_sg_attrs+0x114/0x128
        __dma_map_sg_attrs from dma_map_sg_attrs+0x18/0x24
        dma_map_sg_attrs from usb_hcd_map_urb_for_dma+0x250/0x3b4
        usb_hcd_map_urb_for_dma from usb_hcd_submit_urb+0x194/0x214
        usb_hcd_submit_urb from usb_sg_wait+0xa4/0x118
        usb_sg_wait from usb_stor_bulk_transfer_sglist+0xa0/0xec
        usb_stor_bulk_transfer_sglist from usb_stor_bulk_srb+0x38/0x70
        usb_stor_bulk_srb from usb_stor_Bulk_transport+0x150/0x360
        usb_stor_Bulk_transport from usb_stor_invoke_transport+0x38/0x440
        usb_stor_invoke_transport from usb_stor_control_thread+0x1e0/0x238
        usb_stor_control_thread from kthread+0xf8/0x104
        kthread from ret_from_fork+0x14/0x2c
      
      Refactor memory_intersects to fix the two problems above.
      
      Before the 1d7db834 ("dma-debug: use memory_intersects()
      directly"), memory_intersects is called only by printk_late_init:
      
      printk_late_init -> init_section_intersects ->memory_intersects.
      
      There were few places where memory_intersects was called.
      
      When commit 1d7db834 ("dma-debug: use memory_intersects()
      directly") was merged and CONFIG_DMA_API_DEBUG is enabled, the DMA
      subsystem uses it to check for an illegal area and the calltrace above
      is triggered.
      
      [akpm@linux-foundation.org: fix nearby comment typo]
      Link: https://lkml.kernel.org/r/20220819081145.948016-1-quanyang.wang@windriver.com
      Fixes: 97955936
      
       ("asm/sections: add helpers to check for section data")
      Signed-off-by: default avatarQuanyang Wang <quanyang.wang@windriver.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Thierry Reding <treding@nvidia.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a0108b1
    • Siddh Raman Pant's avatar
      loop: Check for overflow while configuring loop · 18e28817
      Siddh Raman Pant authored
      commit c490a0b5
      
       upstream.
      
      The userspace can configure a loop using an ioctl call, wherein
      a configuration of type loop_config is passed (see lo_ioctl()'s
      case on line 1550 of drivers/block/loop.c). This proceeds to call
      loop_configure() which in turn calls loop_set_status_from_info()
      (see line 1050 of loop.c), passing &config->info which is of type
      loop_info64*. This function then sets the appropriate values, like
      the offset.
      
      loop_device has lo_offset of type loff_t (see line 52 of loop.c),
      which is typdef-chained to long long, whereas loop_info64 has
      lo_offset of type __u64 (see line 56 of include/uapi/linux/loop.h).
      
      The function directly copies offset from info to the device as
      follows (See line 980 of loop.c):
      	lo->lo_offset = info->lo_offset;
      
      This results in an overflow, which triggers a warning in iomap_iter()
      due to a call to iomap_iter_done() which has:
      	WARN_ON_ONCE(iter->iomap.offset > iter->pos);
      
      Thus, check for negative value during loop_set_status_from_info().
      
      Bug report: https://syzkaller.appspot.com/bug?id=c620fe14aac810396d3c3edc9ad73848bf69a29e
      
      Reported-and-tested-by: default avatar <syzbot+a8e049cd3abd342936b6@syzkaller.appspotmail.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
      Signed-off-by: default avatarSiddh Raman Pant <code@siddh.me>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Link: https://lore.kernel.org/r/20220823160810.181275-1-code@siddh.me
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      18e28817
    • Goldwyn Rodrigues's avatar
      btrfs: check if root is readonly while setting security xattr · d1f0467f
      Goldwyn Rodrigues authored
      commit b5111127
      
       upstream.
      
      For a filesystem which has btrfs read-only property set to true, all
      write operations including xattr should be denied. However, security
      xattr can still be changed even if btrfs ro property is true.
      
      This happens because xattr_permission() does not have any restrictions
      on security.*, system.*  and in some cases trusted.* from VFS and
      the decision is left to the underlying filesystem. See comments in
      xattr_permission() for more details.
      
      This patch checks if the root is read-only before performing the set
      xattr operation.
      
      Testcase:
      
        DEV=/dev/vdb
        MNT=/mnt
      
        mkfs.btrfs -f $DEV
        mount $DEV $MNT
        echo "file one" > $MNT/f1
      
        setfattr -n "security.one" -v 2 $MNT/f1
        btrfs property set /mnt ro true
      
        setfattr -n "security.one" -v 1 $MNT/f1
      
        umount $MNT
      
      CC: stable@vger.kernel.org # 4.9+
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarGoldwyn Rodrigues <rgoldwyn@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1f0467f
    • Jacob Keller's avatar
      ixgbe: stop resetting SYSTIME in ixgbe_ptp_start_cyclecounter · 4e465ee4
      Jacob Keller authored
      [ Upstream commit 25d7a5f5 ]
      
      The ixgbe_ptp_start_cyclecounter is intended to be called whenever the
      cyclecounter parameters need to be changed.
      
      Since commit a9763f3c
      
       ("ixgbe: Update PTP to support X550EM_x
      devices"), this function has cleared the SYSTIME registers and reset the
      TSAUXC DISABLE_SYSTIME bit.
      
      While these need to be cleared during ixgbe_ptp_reset, it is wrong to clear
      them during ixgbe_ptp_start_cyclecounter. This function may be called
      during both reset and link status change. When link changes, the SYSTIME
      counter is still operating normally, but the cyclecounter should be updated
      to account for the possibly changed parameters.
      
      Clearing SYSTIME when link changes causes the timecounter to jump because
      the cycle counter now reads zero.
      
      Extract the SYSTIME initialization out to a new function and call this
      during ixgbe_ptp_reset. This prevents the timecounter adjustment and avoids
      an unnecessary reset of the current time.
      
      This also restores the original SYSTIME clearing that occurred during
      ixgbe_ptp_reset before the commit above.
      
      Reported-by: default avatarSteve Payne <spayne@aurora.tech>
      Reported-by: default avatarIlya Evenbach <ievenbach@aurora.tech>
      Fixes: a9763f3c
      
       ("ixgbe: Update PTP to support X550EM_x devices")
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4e465ee4
    • Kuniyuki Iwashima's avatar
      net: Fix a data-race around sysctl_somaxconn. · 29e01227
      Kuniyuki Iwashima authored
      [ Upstream commit 3c9ba81d ]
      
      While reading sysctl_somaxconn, it can be changed concurrently.
      Thus, we need to add READ_ONCE() to its reader.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      29e01227
    • Kuniyuki Iwashima's avatar
      net: Fix a data-race around sysctl_net_busy_read. · add7c2af
      Kuniyuki Iwashima authored
      [ Upstream commit e59ef36f ]
      
      While reading sysctl_net_busy_read, it can be changed concurrently.
      Thus, we need to add READ_ONCE() to its reader.
      
      Fixes: 2d48d67f
      
       ("net: poll/select low latency socket support")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      add7c2af
    • Kuniyuki Iwashima's avatar
      net: Fix a data-race around sysctl_net_busy_poll. · 7a34fb98
      Kuniyuki Iwashima authored
      [ Upstream commit c42b7cdd ]
      
      While reading sysctl_net_busy_poll, it can be changed concurrently.
      Thus, we need to add READ_ONCE() to its reader.
      
      Fixes: 06021292
      
       ("net: add low latency socket poll")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7a34fb98
    • Kuniyuki Iwashima's avatar
      net: Fix a data-race around sysctl_tstamp_allow_data. · 64fca220
      Kuniyuki Iwashima authored
      [ Upstream commit d2154b0a ]
      
      While reading sysctl_tstamp_allow_data, it can be changed
      concurrently.  Thus, we need to add READ_ONCE() to its reader.
      
      Fixes: b245be1f
      
       ("net-timestamp: no-payload only sysctl")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      64fca220
    • Kuniyuki Iwashima's avatar
      ratelimit: Fix data-races in ___ratelimit(). · 509c21ea
      Kuniyuki Iwashima authored
      [ Upstream commit 6bae8ceb ]
      
      While reading rs->interval and rs->burst, they can be changed
      concurrently via sysctl (e.g. net_ratelimit_state).  Thus, we
      need to add READ_ONCE() to their readers.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      509c21ea
    • Pablo Neira Ayuso's avatar
      netfilter: nft_payload: report ERANGE for too long offset and length · 3cfdaa30
      Pablo Neira Ayuso authored
      [ Upstream commit 94254f99 ]
      
      Instead of offset and length are truncation to u8, report ERANGE.
      
      Fixes: 96518518
      
       ("netfilter: add nftables")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3cfdaa30
    • Jonathan Toppins's avatar
      bonding: 802.3ad: fix no transmission of LACPDUs · 4eec561a
      Jonathan Toppins authored
      [ Upstream commit d745b506 ]
      
      This is caused by the global variable ad_ticks_per_sec being zero as
      demonstrated by the reproducer script discussed below. This causes
      all timer values in __ad_timer_to_ticks to be zero, resulting
      in the periodic timer to never fire.
      
      To reproduce:
      Run the script in
      `tools/testing/selftests/drivers/net/bonding/bond-break-lacpdu-tx.sh` which
      puts bonding into a state where it never transmits LACPDUs.
      
      line 44: ip link add fbond type bond mode 4 miimon 200 \
                  xmit_hash_policy 1 ad_actor_sys_prio 65535 lacp_rate fast
      setting bond param: ad_actor_sys_prio
      given:
          params.ad_actor_system = 0
      call stack:
          bond_option_ad_actor_sys_prio()
          -> bond_3ad_update_ad_actor_settings()
             -> set ad.system.sys_priority = bond->params.ad_actor_sys_prio
             -> ad.system.sys_mac_addr = bond->dev->dev_addr; because
                  params.ad_actor_system == 0
      results:
           ad.system.sys_mac_addr = bond->dev->dev_addr
      
      line 48: ip link set fbond address 52:54:00:3B:7C:A6
      setting bond MAC addr
      call stack:
          bond->dev->dev_addr = new_mac
      
      line 52: ip link set fbond type bond ad_actor_sys_prio 65535
      setting bond param: ad_actor_sys_prio
      given:
          params.ad_actor_system = 0
      call stack:
          bond_option_ad_actor_sys_prio()
          -> bond_3ad_update_ad_actor_settings()
             -> set ad.system.sys_priority = bond->params.ad_actor_sys_prio
             -> ad.system.sys_mac_addr = bond->dev->dev_addr; because
                  params.ad_actor_system == 0
      results:
           ad.system.sys_mac_addr = bond->dev->dev_addr
      
      line 60: ip link set veth1-bond down master fbond
      given:
          params.ad_actor_system = 0
          params.mode = BOND_MODE_8023AD
          ad.system.sys_mac_addr == bond->dev->dev_addr
      call stack:
          bond_enslave
          -> bond_3ad_initialize(); because first slave
             -> if ad.system.sys_mac_addr != bond->dev->dev_addr
                return
      results:
           Nothing is run in bond_3ad_initialize() because dev_addr equals
           sys_mac_addr leaving the global ad_ticks_per_sec zero as it is
           never initialized anywhere else.
      
      The if check around the contents of bond_3ad_initialize() is no longer
      needed due to commit 5ee14e6d ("bonding: 3ad: apply ad_actor settings
      changes immediately") which sets ad.system.sys_mac_addr if any one of
      the bonding parameters whos set function calls
      bond_3ad_update_ad_actor_settings(). This is because if
      ad.system.sys_mac_addr is zero it will be set to the current bond mac
      address, this causes the if check to never be true.
      
      Fixes: 5ee14e6d
      
       ("bonding: 3ad: apply ad_actor settings changes immediately")
      Signed-off-by: default avatarJonathan Toppins <jtoppins@redhat.com>
      Acked-by: default avatarJay Vosburgh <jay.vosburgh@canonical.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4eec561a
    • Bernard Pidoux's avatar
      rose: check NULL rose_loopback_neigh->loopback · 76885373
      Bernard Pidoux authored
      [ Upstream commit 3c53cd65 ]
      
      Commit 3b3fd068 added NULL check for
      `rose_loopback_neigh->dev` in rose_loopback_timer() but omitted to
      check rose_loopback_neigh->loopback.
      
      It thus prevents *all* rose connect.
      
      The reason is that a special rose_neigh loopback has a NULL device.
      
      /proc/net/rose_neigh illustrates it via rose_neigh_show() function :
      [...]
      seq_printf(seq, "%05d %-9s %-4s   %3d %3d  %3s     %3s %3lu %3lu",
      	   rose_neigh->number,
      	   (rose_neigh->loopback) ? "RSLOOP-0" : ax2asc(buf, &rose_neigh->callsign),
      	   rose_neigh->dev ? rose_neigh->dev->name : "???",
      	   rose_neigh->count,
      
      /proc/net/rose_neigh displays special rose_loopback_neigh->loopback as
      callsign RSLOOP-0:
      
      addr  callsign  dev  count use mode restart  t0  tf digipeaters
      00001 RSLOOP-0  ???      1   2  DCE     yes   0   0
      
      By checking rose_loopback_neigh->loopback, rose_rx_call_request() is called
      even in case rose_loopback_neigh->dev is NULL. This repairs rose connections.
      
      Verification with rose client application FPAC:
      
      FPAC-Node v 4.1.3 (built Aug  5 2022) for LINUX (help = h)
      F6BVP-4 (Commands = ?) : u
      Users - AX.25 Level 2 sessions :
      Port   Callsign     Callsign  AX.25 state  ROSE state  NetRom status
      axudp  F6BVP-5   -> F6BVP-9   Connected    Connected   ---------
      
      Fixes: 3b3fd068
      
       ("rose: Fix Null pointer dereference in rose_send_frame()")
      Signed-off-by: default avatarBernard Pidoux <f6bvp@free.fr>
      Suggested-by: default avatarFrancois Romieu <romieu@fr.zoreil.com>
      Cc: Thomas DL9SAU Osterried <thomas@osterried.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      76885373
    • Herbert Xu's avatar
      af_key: Do not call xfrm_probe_algs in parallel · e580d320
      Herbert Xu authored
      [ Upstream commit ba953a9d
      
       ]
      
      When namespace support was added to xfrm/afkey, it caused the
      previously single-threaded call to xfrm_probe_algs to become
      multi-threaded.  This is buggy and needs to be fixed with a mutex.
      
      Reported-by: default avatarAbhishek Shah <abhishek.shah@columbia.edu>
      Fixes: 283bc9f3
      
       ("xfrm: Namespacify xfrm state/policy locks")
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e580d320
    • Xin Xiong's avatar
      xfrm: fix refcount leak in __xfrm_policy_check() · 18e6b6e2
      Xin Xiong authored
      [ Upstream commit 9c9cb23e ]
      
      The issue happens on an error path in __xfrm_policy_check(). When the
      fetching process of the object `pols[1]` fails, the function simply
      returns 0, forgetting to decrement the reference count of `pols[0]`,
      which is incremented earlier by either xfrm_sk_policy_lookup() or
      xfrm_policy_lookup(). This may result in memory leaks.
      
      Fix it by decreasing the reference count of `pols[0]` in that path.
      
      Fixes: 134b0fc5
      
       ("IPsec: propagate security module errors up from flow_cache_lookup")
      Signed-off-by: default avatarXin Xiong <xiongx18@fudan.edu.cn>
      Signed-off-by: default avatarXin Tan <tanxin.ctf@gmail.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18e6b6e2
    • Helge Deller's avatar
      parisc: Fix exception handler for fldw and fstw instructions · 555666fd
      Helge Deller authored
      commit 7ae1f550
      
       upstream.
      
      The exception handler is broken for unaligned memory acceses with fldw
      and fstw instructions, because it trashes or uses randomly some other
      floating point register than the one specified in the instruction word
      on loads and stores.
      
      The instruction "fldw 0(addr),%fr22L" (and the other fldw/fstw
      instructions) encode the target register (%fr22) in the rightmost 5 bits
      of the instruction word. The 7th rightmost bit of the instruction word
      defines if the left or right half of %fr22 should be used.
      
      While processing unaligned address accesses, the FR3() define is used to
      extract the offset into the local floating-point register set.  But the
      calculation in FR3() was buggy, so that for example instead of %fr22,
      register %fr12 [((22 * 2) & 0x1f) = 12] was used.
      
      This bug has been since forever in the parisc kernel and I wonder why it
      wasn't detected earlier. Interestingly I noticed this bug just because
      the libime debian package failed to build on *native* hardware, while it
      successfully built in qemu.
      
      This patch corrects the bitshift and masking calculation in FR3().
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      555666fd
  2. Aug 25, 2022