1. 12 Apr, 2022 1 commit
    • Jason A. Donenfeld's avatar
      gcc-plugins: latent_entropy: use /dev/urandom · c40160f2
      Jason A. Donenfeld authored
      While the latent entropy plugin mostly doesn't derive entropy from
      get_random_const() for measuring the call graph, when __latent_entropy is
      applied to a constant, then it's initialized statically to output from
      get_random_const(). In that case, this data is derived from a 64-bit
      seed, which means a buffer of 512 bits doesn't really have that amount
      of compile-time entropy.
      
      This patch fixes that shortcoming by just buffering chunks of
      /dev/urandom output and doling it out as requested.
      
      At the same time, it's important that we don't break the use of
      -frandom-seed, for people who want the runtime benefits of the latent
      entropy plugin, while still having compile-time determinism. In that
      case, we detect whether gcc's set_random_seed() has been called by
      making a call to get_random_seed(noinit=true) in the plugin init
      function, which is called after set_random_seed() is called but before
      anything that calls get_random_seed(noinit=false), and seeing if it's
      zero or not. If it's not zero, we're in deterministic mode, and so we
      just generate numbers with a basic xorshift prng.
      
      Note that we don't detect if -frandom-seed is being used using the
      documented local_tick variable, because it's assigned via:
         local_tick = (unsigned) tv.tv_sec * 1000 + tv.tv_usec / 1000;
      which may well overflow and become -1 on its own, and so isn't
      reliable: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105171
      
      [kees: The 256 byte rnd_buf size was chosen based on average (250),
       median (64), and std deviation (575) bytes of used entropy for a
       defconfig x86_64 build]
      
      Fixes: 38addce8 ("gcc-plugins: Add latent_entropy plugin")
      Cc: stable@vger.kernel.org
      Cc: PaX Team <pageexec@freemail.hu>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20220405222815.21155-1-Jason@zx2c4.com
      c40160f2
  2. 31 Mar, 2022 2 commits
  3. 24 Mar, 2022 1 commit
  4. 10 Mar, 2022 1 commit
  5. 27 Feb, 2022 1 commit
  6. 26 Feb, 2022 2 commits
  7. 14 Feb, 2022 2 commits
    • Marco Elver's avatar
      stack: Constrain and fix stack offset randomization with Clang builds · efa90c11
      Marco Elver authored
      All supported versions of Clang perform auto-init of __builtin_alloca()
      when stack auto-init is on (CONFIG_INIT_STACK_ALL_{ZERO,PATTERN}).
      
      add_random_kstack_offset() uses __builtin_alloca() to add a stack
      offset. This means, when CONFIG_INIT_STACK_ALL_{ZERO,PATTERN} is
      enabled, add_random_kstack_offset() will auto-init that unused portion
      of the stack used to add an offset.
      
      There are several problems with this:
      
      	1. These offsets can be as large as 1023 bytes. Performing
      	   memset() on them isn't exactly cheap, and this is done on
      	   every syscall entry.
      
      	2. Architectures adding add_random_kstack_offset() to syscall
      	   entry implemented in C require them to be 'noinstr' (e.g. see
      	   x86 and s390). The potential problem here is that a call to
      	   memset may occur, which is not noinstr.
      
      A x86_64 defconfig kernel with Clang 11 and CONFIG_VMLINUX_VALIDATION shows:
      
       | vmlinux.o: warning: objtool: do_syscall_64()+0x9d: call to memset() leaves .noinstr.text section
       | vmlinux.o: warning: objtool: do_int80_syscall_32()+0xab: call to memset() leaves .noinstr.text section
       | vmlinux.o: warning: objtool: __do_fast_syscall_32()+0xe2: call to memset() leaves .noinstr.text section
       | vmlinux.o: warning: objtool: fixup_bad_iret()+0x2f: call to memset() leaves .noinstr.text section
      
      Clang 14 (unreleased) will introduce a way to skip alloca initialization
      via __builtin_alloca_uninitialized() (https://reviews.llvm.org/D115440).
      
      Constrain RANDOMIZE_KSTACK_OFFSET to only be enabled if no stack
      auto-init is enabled, the compiler is GCC, or Clang is version 14+. Use
      __builtin_alloca_uninitialized() if the compiler provides it, as is done
      by Clang 14.
      
      Link: https://lkml.kernel.org/r/YbHTKUjEejZCLyhX@elver.google.com
      Fixes: 39218ff4 ("stack: Optionally randomize kernel stack offset each syscall")
      Signed-off-by: default avatarMarco Elver <elver@google.com>
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20220131090521.1947110-2-elver@google.com
      efa90c11
    • Marco Elver's avatar
      stack: Introduce CONFIG_RANDOMIZE_KSTACK_OFFSET · 8cb37a59
      Marco Elver authored
      The randomize_kstack_offset feature is unconditionally compiled in when
      the architecture supports it.
      
      To add constraints on compiler versions, we require a dedicated Kconfig
      variable. Therefore, introduce RANDOMIZE_KSTACK_OFFSET.
      
      Furthermore, this option is now also configurable by EXPERT kernels:
      while the feature is supposed to have zero performance overhead when
      disabled, due to its use of static branches, there are few cases where
      giving a distribution the option to disable the feature entirely makes
      sense. For example, in very resource constrained environments, which
      would never enable the feature to begin with, in which case the
      additional kernel code size increase would be redundant.
      Signed-off-by: default avatarMarco Elver <elver@google.com>
      Reviewed-by: default avatarNathan Chancellor <nathan@kernel.org>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20220131090521.1947110-1-elver@google.com
      8cb37a59
  8. 06 Feb, 2022 3 commits
  9. 30 Jan, 2022 18 commits
  10. 29 Jan, 2022 9 commits
    • Thomas Gleixner's avatar
      Merge tag 'irqchip-fixes-5.17-1' of... · 243d3080
      Thomas Gleixner authored
      Merge tag 'irqchip-fixes-5.17-1' of git://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms into irq/urgent
      
      Pull irqchip fixes from Marc Zyngier:
      
        - Drop an unused private data field in the AIC driver
      
        - Various fixes to the realtek-rtl driver
      
        - Make the GICv3 ITS driver compile again in !SMP configurations
      
        - Force reset of the GICv3 ITSs at probe time to avoid issues during kexec
      
        - Yet another kfree/bitmap_free conversion
      
        - Various DT updates (Renesas, SiFive)
      
      Link: https://lore.kernel.org/r/20220128174217.517041-1-maz@kernel.org
      243d3080
    • Linus Torvalds's avatar
      Merge tag 'pci-v5.17-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci · f8c7e4ed
      Linus Torvalds authored
      Pull pci fixes from Bjorn Helgaas:
      
       - Fix compilation warnings in new mt7621 driver (Sergio Paracuellos)
      
       - Restore the sysfs "rom" file for VGA shadow ROMs, which was broken
         when converting "rom" to be a static attribute (Bjorn Helgaas)
      
      * tag 'pci-v5.17-fixes-2' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci:
        PCI/sysfs: Find shadow ROM before static attribute initialization
        PCI: mt7621: Remove unused function pcie_rmw()
        PCI: mt7621: Drop of_match_ptr() to avoid unused variable
      f8c7e4ed
    • Linus Torvalds's avatar
      Merge tag 'gpio-fixes-for-v5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux · 4cd90083
      Linus Torvalds authored
      Pull gpio fixes from Bartosz Golaszewski:
       "Two fixes for the gpio-simulator:
      
         - fix a bug with hogs not being set-up in gpio-sim when user-space
           sets the chip label to an empty string
      
         - include the gpio-sim documentation in the index"
      
      * tag 'gpio-fixes-for-v5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
        gpio: sim: add doc file to index file
        gpio: sim: check the label length when setting up device properties
      4cd90083
    • Linus Torvalds's avatar
      Merge tag 'char-misc-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc · e255759e
      Linus Torvalds authored
      Pull char/misc driver fixes from Greg KH:
       "Here are two small char/misc driver fixes for 5.17-rc2 that fix some
        reported issues. They are:
      
         - fix up a merge issue in the at25.c driver that ended up dropping
           some lines in the driver. The removed lines ended being needed, so
           this restores it and the driver works again.
      
         - counter core fix where the wrong error was being returned, NULL
           should be the correct error for when memory is gone here, like the
           kmalloc() core does.
      
        Both of these have been in linux-next this week with no reported
        issues"
      
      * tag 'char-misc-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
        counter: fix an IS_ERR() vs NULL bug
        eeprom: at25: Restore missing allocation
      e255759e
    • Linus Torvalds's avatar
      Merge tag 'tty-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty · bb37101b
      Linus Torvalds authored
      Pull tty/serial driver fixes from Greg KH:
       "Here are some small bug fixes and reverts for reported problems with
        the tty core and drivers. They include:
      
         - revert the fifo use for the 8250 console mode. It caused too many
           regressions and problems, and had a bug in it as well. This is
           being reworked and should show up in a later -rc1 release, but it's
           not ready for 5.17
      
         - rpmsg tty race fix
      
         - restore the cyclades.h uapi header file. Turns out a compiler test
           suite used it for some unknown reason. Bring it back just for the
           parts that are used by the builder test so they continue to build.
           No functionality is restored as no one actually has this hardware
           anymore, nor is it really tested.
      
         - stm32 driver fixes
      
         - n_gsm flow control fixes
      
         - pl011 driver fix
      
         - rs485 initialization fix
      
        All of these have been in linux-next this week with no reported
        problems"
      
      * tag 'tty-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty:
        kbuild: remove include/linux/cyclades.h from header file check
        serial: core: Initialize rs485 RTS polarity already on probe
        serial: pl011: Fix incorrect rs485 RTS polarity on set_mctrl
        serial: stm32: fix software flow control transfer
        serial: stm32: prevent TDR register overwrite when sending x_char
        tty: n_gsm: fix SW flow control encoding/handling
        serial: 8250: of: Fix mapped region size when using reg-offset property
        tty: rpmsg: Fix race condition releasing tty port
        tty: Partially revert the removal of the Cyclades public API
        tty: Add support for Brainboxes UC cards.
        Revert "tty: serial: Use fifo in 8250 console driver"
      bb37101b
    • Linus Torvalds's avatar
      Merge tag 'usb-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 44aa31a2
      Linus Torvalds authored
      Pull USB driver fixes from Greg KH:
       "Here are some small USB driver fixes for 5.17-rc2 that resolve a
        number of reported problems. These include:
      
         - typec driver fixes
      
         - xhci platform driver fixes for suspending
      
         - ulpi core fix
      
         - role.h build fix
      
         - new device ids
      
         - syzbot-reported bugfixes
      
         - gadget driver fixes
      
         - dwc3 driver fixes
      
         - other small fixes
      
        All of these have been in linux-next this week with no reported
        issues"
      
      * tag 'usb-5.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        usb: cdnsp: Fix segmentation fault in cdns_lost_power function
        usb: dwc2: gadget: don't try to disable ep0 in dwc2_hsotg_suspend
        usb: gadget: at91_udc: fix incorrect print type
        usb: dwc3: xilinx: Fix error handling when getting USB3 PHY
        usb: dwc3: xilinx: Skip resets and USB3 register settings for USB2.0 mode
        usb: xhci-plat: fix crash when suspend if remote wake enable
        usb: common: ulpi: Fix crash in ulpi_match()
        usb: gadget: f_sourcesink: Fix isoc transfer for USB_SPEED_SUPER_PLUS
        ucsi_ccg: Check DEV_INT bit only when starting CCG4
        USB: core: Fix hang in usb_kill_urb by adding memory barriers
        usb-storage: Add unusual-devs entry for VL817 USB-SATA bridge
        usb: typec: tcpm: Do not disconnect when receiving VSAFE0V
        usb: typec: tcpm: Do not disconnect while receiving VBUS off
        usb: typec: Don't try to register component master without components
        usb: typec: Only attempt to link USB ports if there is fwnode
        usb: typec: tcpci: don't touch CC line if it's Vconn source
        usb: roles: fix include/linux/usb/role.h compile issue
      44aa31a2
    • Linus Torvalds's avatar
      Merge tag 'block-5.17-2022-01-28' of git://git.kernel.dk/linux-block · cb323ee7
      Linus Torvalds authored
      Pull block fixes from Jens Axboe:
      
       - NVMe pull request
            - add the IGNORE_DEV_SUBNQN quirk for Intel P4500/P4600 SSDs (Wu
              Zheng)
            - remove the unneeded ret variable in nvmf_dev_show (Changcheng
              Deng)
      
       - Fix for a hang regression introduced with a patch in the merge
         window, where low queue depth devices would not always get woken
         correctly (Laibin)
      
       - Small series fixing an IO accounting issue with bio backed dm devices
         (Mike, Yu)
      
      * tag 'block-5.17-2022-01-28' of git://git.kernel.dk/linux-block:
        dm: properly fix redundant bio-based IO accounting
        dm: revert partial fix for redundant bio-based IO accounting
        block: add bio_start_io_acct_time() to control start_time
        blk-mq: Fix wrong wakeup batch configuration which will cause hang
        nvme-fabrics: remove the unneeded ret variable in nvmf_dev_show
        nvme-pci: add the IGNORE_DEV_SUBNQN quirk for Intel P4500/P4600 SSDs
        blk-mq: fix missing blk_account_io_done() in error path
        block: fix memory leak in disk_register_independent_access_ranges
      cb323ee7
    • Linus Torvalds's avatar
      Merge tag 'io_uring-5.17-2022-01-28' of git://git.kernel.dk/linux-block · 3b58e9f3
      Linus Torvalds authored
      Pull io_uring fixes from Jens Axboe:
       "Just two small fixes this time:
      
         - Fix a bug that can lead to node registration taking 1 second, when
           it should finish much quicker (Dylan)
      
         - Remove an unused argument from a function (Usama)"
      
      * tag 'io_uring-5.17-2022-01-28' of git://git.kernel.dk/linux-block:
        io_uring: remove unused argument from io_rsrc_node_alloc
        io_uring: fix bug in slow unregistering of nodes
      3b58e9f3
    • Linus Torvalds's avatar
      Merge tag 'powerpc-5.17-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux · d66c1e79
      Linus Torvalds authored
      Pull powerpc fixes from Michael Ellerman:
      
       - Fix VM debug warnings on boot triggered via __set_fixmap().
      
       - Fix a debug warning in the 64-bit Book3S PMU handling code.
      
       - Fix nested guest HFSCR handling with multiple vCPUs on Power9 or
         later.
      
       - Fix decrementer storm caused by a recent change, seen with some
         configs.
      
      Thanks to Alexey Kardashevskiy, Athira Rajeev, Christophe Leroy,
      Fabiano Rosas, Maxime Bizon, Nicholas Piggin, and Sachin Sant.
      
      * tag 'powerpc-5.17-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
        powerpc/64s/interrupt: Fix decrementer storm
        KVM: PPC: Book3S HV Nested: Fix nested HFSCR being clobbered with multiple vCPUs
        powerpc/perf: Fix power_pmu_disable to call clear_pmi_irq_pending only if PMI is pending
        powerpc/fixmap: Fix VM debug warning on unmap
      d66c1e79