1. 18 Jul, 2022 5 commits
    • Jason A. Donenfeld's avatar
      um: seed rng using host OS rng · 0b9ba613
      Jason A. Donenfeld authored
      UML generally does not provide access to special CPU instructions like
      RDRAND, and execution tends to be rather deterministic, with no real
      hardware interrupts, making good randomness really very hard, if not
      all together impossible. Not only is this a security eyebrow raiser, but
      it's also quite annoying when trying to do various pieces of UML-based
      automation that takes a long time to boot, if ever.
      
      Fix this by trivially calling getrandom() in the host and using that
      seed as "bootloader randomness", which initializes the rng immediately
      at UML boot.
      
      The old behavior can be restored the same way as on any other arch, by
      way of CONFIG_TRUST_BOOTLOADER_RANDOMNESS=n or
      random.trust_bootloader=0. So seen from that perspective, this just
      makes UML act like other archs, which is positive in its own right.
      
      Additionally, wire up arch_get_random_{int,long}() in the same way, so
      that reseeds can also make use of the host RNG, controllable by
      CONFIG_TRUST_CPU_RANDOMNESS and random.trust_cpu, per usual.
      
      Cc: stable@vger.kernel.org
      Acked-by: default avatarJohannes Berg <johannes@sipsolutions.net>
      Acked-By: default avatarAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      0b9ba613
    • Uros Bizjak's avatar
      random: use try_cmpxchg in _credit_init_bits · b7a68f67
      Uros Bizjak authored
      Use `!try_cmpxchg(ptr, &orig, new)` instead of `cmpxchg(ptr, orig, new)
      != orig` in _credit_init_bits. This has two benefits:
      
      - The x86 cmpxchg instruction returns success in the ZF flag, so this
        change saves a compare after cmpxchg, as well as a related move
        instruction in front of cmpxchg.
      
      - try_cmpxchg implicitly assigns the *ptr value to &orig when cmpxchg
        fails, enabling further code simplifications.
      
      This patch has no functional change.
      Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      b7a68f67
    • Jason A. Donenfeld's avatar
      timekeeping: contribute wall clock to rng on time change · b8ac29b4
      Jason A. Donenfeld authored
      The rng's random_init() function contributes the real time to the rng at
      boot time, so that events can at least start in relation to something
      particular in the real world. But this clock might not yet be set that
      point in boot, so nothing is contributed. In addition, the relation
      between minor clock changes from, say, NTP, and the cycle counter is
      potentially useful entropic data.
      
      This commit addresses this by mixing in a time stamp on calls to
      settimeofday and adjtimex. No entropy is credited in doing so, so it
      doesn't make initialization faster, but it is still useful input to
      have.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      b8ac29b4
    • Jason A. Donenfeld's avatar
      x86/rdrand: Remove "nordrand" flag in favor of "random.trust_cpu" · 049f9ae9
      Jason A. Donenfeld authored
      The decision of whether or not to trust RDRAND is controlled by the
      "random.trust_cpu" boot time parameter or the CONFIG_RANDOM_TRUST_CPU
      compile time default. The "nordrand" flag was added during the early
      days of RDRAND, when there were worries that merely using its values
      could compromise the RNG. However, these days, RDRAND values are not
      used directly but always go through the RNG's hash function, making
      "nordrand" no longer useful.
      
      Rather, the correct switch is "random.trust_cpu", which not only handles
      the relevant trust issue directly, but also is general to multiple CPU
      types, not just x86.
      
      However, x86 RDRAND does have a history of being occasionally
      problematic. Prior, when the kernel would notice something strange, it'd
      warn in dmesg and suggest enabling "nordrand". We can improve on that by
      making the test a little bit better and then taking the step of
      automatically disabling RDRAND if we detect it's problematic.
      
      Also disable RDSEED if the RDRAND test fails.
      
      Cc: x86@kernel.org
      Cc: Theodore Ts'o <tytso@mit.edu>
      Suggested-by: default avatarH. Peter Anvin <hpa@zytor.com>
      Suggested-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      049f9ae9
    • Jason A. Donenfeld's avatar
      random: remove CONFIG_ARCH_RANDOM · 9592eef7
      Jason A. Donenfeld authored
      When RDRAND was introduced, there was much discussion on whether it
      should be trusted and how the kernel should handle that. Initially, two
      mechanisms cropped up, CONFIG_ARCH_RANDOM, a compile time switch, and
      "nordrand", a boot-time switch.
      
      Later the thinking evolved. With a properly designed RNG, using RDRAND
      values alone won't harm anything, even if the outputs are malicious.
      Rather, the issue is whether those values are being *trusted* to be good
      or not. And so a new set of options were introduced as the real
      ones that people use -- CONFIG_RANDOM_TRUST_CPU and "random.trust_cpu".
      With these options, RDRAND is used, but it's not always credited. So in
      the worst case, it does nothing, and in the best case, maybe it helps.
      
      Along the way, CONFIG_ARCH_RANDOM's meaning got sort of pulled into the
      center and became something certain platforms force-select.
      
      The old options don't really help with much, and it's a bit odd to have
      special handling for these instructions when the kernel can deal fine
      with the existence or untrusted existence or broken existence or
      non-existence of that CPU capability.
      
      Simplify the situation by removing CONFIG_ARCH_RANDOM and using the
      ordinary asm-generic fallback pattern instead, keeping the two options
      that are actually used. For now it leaves "nordrand" for now, as the
      removal of that will take a different route.
      Acked-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Acked-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      9592eef7
  2. 16 Jul, 2022 2 commits
    • Jason A. Donenfeld's avatar
      random: cap jitter samples per bit to factor of HZ · 829d680e
      Jason A. Donenfeld authored
      Currently the jitter mechanism will require two timer ticks per
      iteration, and it requires N iterations per bit. This N is determined
      with a small measurement, and if it's too big, it won't waste time with
      jitter entropy because it'd take too long or not have sufficient entropy
      anyway.
      
      With the current max N of 32, there are large timeouts on systems with a
      small CONFIG_HZ. Rather than set that maximum to 32, instead choose a
      factor of CONFIG_HZ. In this case, 1/30 seems to yield sane values for
      different configurations of CONFIG_HZ.
      Reported-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
      Fixes: 78c768e6 ("random: vary jitter iterations based on cycle counter speed")
      Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Tested-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      829d680e
    • Thadeu Lima de Souza Cascardo's avatar
      efi/x86: use naked RET on mixed mode call wrapper · 51a6fa07
      Thadeu Lima de Souza Cascardo authored
      When running with return thunks enabled under 32-bit EFI, the system
      crashes with:
      
        kernel tried to execute NX-protected page - exploit attempt? (uid: 0)
        BUG: unable to handle page fault for address: 000000005bc02900
        #PF: supervisor instruction fetch in kernel mode
        #PF: error_code(0x0011) - permissions violation
        PGD 18f7063 P4D 18f7063 PUD 18ff063 PMD 190e063 PTE 800000005bc02063
        Oops: 0011 [#1] PREEMPT SMP PTI
        CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.19.0-rc6+ #166
        Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 0.0.0 02/06/2015
        RIP: 0010:0x5bc02900
        Code: Unable to access opcode bytes at RIP 0x5bc028d6.
        RSP: 0018:ffffffffb3203e10 EFLAGS: 00010046
        RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000048
        RDX: 000000000190dfac RSI: 0000000000001710 RDI: 000000007eae823b
        RBP: ffffffffb3203e70 R08: 0000000001970000 R09: ffffffffb3203e28
        R10: 747563657865206c R11: 6c6977203a696665 R12: 0000000000001710
        R13: 0000000000000030 R14: 0000000001970000 R15: 0000000000000001
        FS:  0000000000000000(0000) GS:ffff8e013ca00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0018 ES: 0018 CR0: 0000000080050033
        CR2: 000000005bc02900 CR3: 0000000001930000 CR4: 00000000000006f0
        Call Trace:
         ? efi_set_virtual_address_map+0x9c/0x175
         efi_enter_virtual_mode+0x4a6/0x53e
         start_kernel+0x67c/0x71e
         x86_64_start_reservations+0x24/0x2a
         x86_64_start_kernel+0xe9/0xf4
         secondary_startup_64_no_verify+0xe5/0xeb
      
      That's because it cannot jump to the return thunk from the 32-bit code.
      
      Using a naked RET and marking it as safe allows the system to proceed
      booting.
      
      Fixes: aa3d4803 ("x86: Use return-thunk in asm code")
      Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@canonical.com>
      Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Josh Poimboeuf <jpoimboe@kernel.org>
      Cc: <stable@vger.kernel.org>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      51a6fa07
  3. 15 Jul, 2022 11 commits
    • Linus Torvalds's avatar
      Merge tag 'riscv-for-linus-5.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux · 9b59ec8d
      Linus Torvalds authored
      Pull RISC-V fixes from Palmer Dabbelt:
      
       - A fix to avoid printing a warning when modules do not exercise any
         errata-dependent behavior and the SiFive errata are enabled.
      
       - A fix to the Microchip PFSOC to attach the L2 cache to the CPU nodes.
      
      * tag 'riscv-for-linus-5.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
        riscv: don't warn for sifive erratas in modules
        riscv: dts: microchip: hook up the mpfs' l2cache
      9b59ec8d
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · a8ebfcd3
      Linus Torvalds authored
      Pull KVM fixes from Paolo Bonzini:
       "RISC-V:
         - Fix missing PAGE_PFN_MASK
      
         - Fix SRCU deadlock caused by kvm_riscv_check_vcpu_requests()
      
        x86:
         - Fix for nested virtualization when TSC scaling is active
      
         - Estimate the size of fastcc subroutines conservatively, avoiding
           disastrous underestimation when return thunks are enabled
      
         - Avoid possible use of uninitialized fields of 'struct
           kvm_lapic_irq'
      
        Generic:
         - Mark as such the boolean values available from the statistics file
           descriptors
      
         - Clarify statistics documentation"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: emulate: do not adjust size of fastop and setcc subroutines
        KVM: x86: Fully initialize 'struct kvm_lapic_irq' in kvm_pv_kick_cpu_op()
        Documentation: kvm: clarify histogram units
        kvm: stats: tell userspace which values are boolean
        x86/kvm: fix FASTOP_SIZE when return thunks are enabled
        KVM: nVMX: Always enable TSC scaling for L2 when it was enabled for L1
        RISC-V: KVM: Fix SRCU deadlock caused by kvm_riscv_check_vcpu_requests()
        riscv: Fix missing PAGE_PFN_MASK
      a8ebfcd3
    • Linus Torvalds's avatar
      Merge tag 'ceph-for-5.19-rc7' of https://github.com/ceph/ceph-client · 1ce9d792
      Linus Torvalds authored
      Pull ceph fix from Ilya Dryomov:
       "A folio locking fixup that Xiubo and David cooperated on, marked for
        stable. Most of it is in netfs but I picked it up into ceph tree on
        agreement with David"
      
      * tag 'ceph-for-5.19-rc7' of https://github.com/ceph/ceph-client:
        netfs: do not unlock and put the folio twice
      1ce9d792
    • Linus Torvalds's avatar
      Merge tag 'spi-fix-v5.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi · 8006112d
      Linus Torvalds authored
      Pull spi fixes from Mark Brown:
       "A few driver specific fixes, none especially remarkable, plus a
        MAINTAINERS file update due to the previous maintainer for the NXP
        FSPI driver having left the company"
      
      * tag 'spi-fix-v5.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
        spi: cadence-quadspi: Remove spi_master_put() in probe failure path
        MAINTAINERS: change the NXP FSPI driver maintainer.
        spi: amd: Limit max transfer and message size
        spi: aspeed: Fix division by zero
        spi: aspeed: Add dev_dbg() to dump the spi-mem direct mapping descriptor
      8006112d
    • Linus Torvalds's avatar
      Merge tag 'soc-fixes-5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc · 1c49f281
      Linus Torvalds authored
      Pull ARM SoC fixes from Arnd Bergmann:
       "Most of the contents are bugfixes for the devicetree files:
      
         - A Qualcomm MSM8974 pin controller regression, caused by a cleanup
           patch that gets partially reverted here.
      
         - Missing properties for Broadcom BCM49xx to fix timer detection and
           SMP boot.
      
         - Fix touchscreen pinctrl for imx6ull-colibri board
      
         - Multiple fixes for Rockchip rk3399 based machines including the vdu
           clock-rate fix, otg port fix on Quartz64-A and ethernet on
           Quartz64-B
      
         - Fixes for misspelled DT contents causing minor problems on
           imx6qdl-ts7970m, orangepi-zero, sama5d2, kontron-kswitch-d10, and
           ls1028a
      
        And a couple of changes elsewhere:
      
         - Fix binding for Allwinner D1 display pipeline
      
         - Trivial code fixes to the TEE and reset controller driver
           subsystems and the rockchip platform code.
      
         - Multiple updates to the MAINTAINERS files, marking the Palm Treo
           support as orphaned, and fixing some entries for added or changed
           file names"
      
      * tag 'soc-fixes-5.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (21 commits)
        arm64: dts: broadcom: bcm4908: Fix cpu node for smp boot
        arm64: dts: broadcom: bcm4908: Fix timer node for BCM4906 SoC
        ARM: dts: sunxi: Fix SPI NOR campatible on Orange Pi Zero
        ARM: dts: at91: sama5d2: Fix typo in i2s1 node
        tee: tee_get_drvdata(): fix description of return value
        optee: Remove duplicate 'of' in two places.
        ARM: dts: kswitch-d10: use open drain mode for coma-mode pins
        ARM: dts: colibri-imx6ull: fix snvs pinmux group
        optee: smc_abi.c: fix wrong pointer passed to IS_ERR/PTR_ERR()
        MAINTAINERS: add polarfire rng, pci and clock drivers
        MAINTAINERS: mark ARM/PALM TREO SUPPORT orphan
        ARM: dts: imx6qdl-ts7970: Fix ngpio typo and count
        arm64: dts: ls1028a: Update SFP node to include clock
        dt-bindings: display: sun4i: Fix D1 pipeline count
        ARM: dts: qcom: msm8974: re-add missing pinctrl
        reset: Fix devm bulk optional exclusive control getter
        MAINTAINERS: rectify entry for SYNOPSYS AXS10x RESET CONTROLLER DRIVER
        ARM: rockchip: Add missing of_node_put() in rockchip_suspend_init()
        arm64: dts: rockchip: Assign RK3399 VDU clock rate
        arm64: dts: rockchip: Fix Quartz64-A dwc3 otg port behavior
        ...
      1c49f281
    • Linus Torvalds's avatar
      Merge tag 'platform-drivers-x86-v5.19-4' of... · 2a347a06
      Linus Torvalds authored
      Merge tag 'platform-drivers-x86-v5.19-4' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86
      
      Pull x86 platform driver fixes from Hans de Goede:
       "Highlights:
      
         - Fix brightness key events getting reported twice on some Dells.
           Regression caused by recent Panasonic hotkey fixes
      
         - Fix poweroff no longer working on some devices regression caused
           by recent poweroff handler rework
      
         - Mark new (in 5.19) Intel IFS driver as broken, because of some
           issues surrounding the userspace (sysfs) API which need to be
           cleared up
      
         - Some hardware-id / quirk additions"
      
      * tag 'platform-drivers-x86-v5.19-4' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
        ACPI: video: Fix acpi_video_handles_brightness_key_presses()
        platform/x86: intel_atomisp2_led: Also turn off the always-on camera LED on the Asus T100TAF
        platform/x86/intel/ifs: Mark as BROKEN
        platform/x86: asus-wmi: Add key mappings
        efi: Fix efi_power_off() not being run before acpi_power_off() when necessary
        platform/x86: x86-android-tablets: Fix Lenovo Yoga Tablet 2 830/1050 poweroff again
        platform/x86: gigabyte-wmi: add support for B660I AORUS PRO DDR4
        platform/x86/amd/pmc: Add new platform support
        platform/x86/amd/pmc: Add new acpi id for PMC controller
      2a347a06
    • Linus Torvalds's avatar
      Merge tag 'for-linus-5.19a-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · 339f74e3
      Linus Torvalds authored
      Pull xen fix from Juergen Gross:
       "Fix for the Xen gntdev driver causing inappropriate WARN() messages"
      
      * tag 'for-linus-5.19a-rc7-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        xen/gntdev: Ignore failure to unmap INVALID_GRANT_HANDLE
      339f74e3
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-2022-07-15' of git://anongit.freedesktop.org/drm/drm · fcd1b2b9
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "This is the regular fixes pull for this week. This has a bunch of
        amdgpu fixes, major one reverts the buddy allocator until it can be
        tested more, otherwise just small ones, then i915 has a bunch of
        fixes.
      
        The outstanding firmware regressions reported by phoronix will
        hopefully be dealt with ASAP.
      
        amdgpu:
         - revert buddy allocator support for now
         - DP MST blank screen fix for specific platforms
         - MEC firmware check fix for GC 10.3.7
         - Deep color fix for DCE
         - Fix possible divide by 0
         - Coverage blend mode fix
         - Fix cursor only commit timestamps
      
        i915:
         - Selftest fix
         - TTM fix sg_table construction
         - Error return fixes
         - Fix a performance regression related to waitboost
         - Fix GT resets"
      
      * tag 'drm-fixes-2022-07-15' of git://anongit.freedesktop.org/drm/drm:
        drm/amd/display: Ensure valid event timestamp for cursor-only commits
        drm/amd/display: correct check of coverage blend mode
        drm/amd/pm: Prevent divide by zero
        drm/amd/display: Only use depth 36 bpp linebuffers on DCN display engines.
        drm/amdkfd: correct the MEC atomic support firmware checking for GC 10.3.7
        drm/amd/display: Ignore First MST Sideband Message Return Error
        drm/i915/selftests: fix subtraction overflow bug
        drm/i915/gem: Look for waitboosting across the whole object prior to individual waits
        drm/i915/gt: Serialize TLB invalidates with GT resets
        drm/i915/gt: Serialize GRDOM access between multiple engine resets
        drm/i915/ttm: fix sg_table construction
        drm/i915/selftests: fix a couple IS_ERR() vs NULL tests
        drm/i915: Fix vm use-after-free in vma destruction
        drm/i915/guc: ADL-N should use the same GuC FW as ADL-S
        drm/i915: fix a possible refcount leak in intel_dp_add_mst_connector()
        drm/i915/gvt: IS_ERR() vs NULL bug in intel_gvt_update_reg_whitelist()
        Revert "drm/amdgpu: add drm buddy support to amdgpu"
      fcd1b2b9
    • Linus Torvalds's avatar
      Merge tag 'sysctl-fixes-5.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux · 862161e8
      Linus Torvalds authored
      Pyll sysctl fix from Luis Chamberlain:
       "Only one fix for sysctl"
      
      * tag 'sysctl-fixes-5.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux:
        mm: sysctl: fix missing numa_stat when !CONFIG_HUGETLB_PAGE
      862161e8
    • Paolo Bonzini's avatar
      KVM: emulate: do not adjust size of fastop and setcc subroutines · 79629181
      Paolo Bonzini authored
      Instead of doing complicated calculations to find the size of the subroutines
      (which are even more complicated because they need to be stringified into
      an asm statement), just hardcode to 16.
      
      It is less dense for a few combinations of IBT/SLS/retbleed, but it has
      the advantage of being really simple.
      
      Cc: stable@vger.kernel.org # 5.15.x: 84e7051c: x86/kvm: fix FASTOP_SIZE when return thunks are enabled
      Cc: stable@vger.kernel.org
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      79629181
    • Dave Airlie's avatar
      Merge tag 'amd-drm-fixes-5.19-2022-07-13' of... · 093f8d8f
      Dave Airlie authored
      Merge tag 'amd-drm-fixes-5.19-2022-07-13' of https://gitlab.freedesktop.org/agd5f/linux into drm-fixes
      
      amd-drm-fixes-5.19-2022-07-13:
      
      amdgpu:
      - DP MST blank screen fix for specific platforms
      - MEC firmware check fix for GC 10.3.7
      - Deep color fix for DCE
      - Fix possible divide by 0
      - Coverage blend mode fix
      - Fix cursor only commit timestamps
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      From: Alex Deucher <alexander.deucher@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220713172920.6037-1-alexander.deucher@amd.com
      093f8d8f
  4. 14 Jul, 2022 22 commits