Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux 5.17.12 #144

Closed
wants to merge 781 commits into from
Closed

Linux 5.17.12 #144

wants to merge 781 commits into from
This pull request is big! We’re only showing the most recent 250 commits.

Commits on May 25, 2022

  1. rtc: mc146818-lib: Fix the AltCentury for AMD platforms

    [ Upstream commit 3ae8fd4 ]
    
    Setting the century forward has been failing on AMD platforms.
    There was a previous attempt at fixing this for family 0x17 as part of
    commit 7ad295d ("rtc: Fix the AltCentury value on AMD/Hygon
    platform") but this was later reverted due to some problems reported
    that appeared to stem from an FW bug on a family 0x17 desktop system.
    
    The same comments mentioned in the previous commit continue to apply
    to the newer platforms as well.
    
    ```
    MC146818 driver use function mc146818_set_time() to set register
    RTC_FREQ_SELECT(RTC_REG_A)'s bit4-bit6 field which means divider stage
    reset value on Intel platform to 0x7.
    
    While AMD/Hygon RTC_REG_A(0Ah)'s bit4 is defined as DV0 [Reference]:
    DV0 = 0 selects Bank 0, DV0 = 1 selects Bank 1. Bit5-bit6 is defined
    as reserved.
    
    DV0 is set to 1, it will select Bank 1, which will disable AltCentury
    register(0x32) access. As UEFI pass acpi_gbl_FADT.century 0x32
    (AltCentury), the CMOS write will be failed on code:
    CMOS_WRITE(century, acpi_gbl_FADT.century).
    
    Correct RTC_REG_A bank select bit(DV0) to 0 on AMD/Hygon CPUs, it will
    enable AltCentury(0x32) register writing and finally setup century as
    expected.
    ```
    
    However in closer examination the change previously submitted was also
    modifying bits 5 & 6 which are declared reserved in the AMD documentation.
    So instead modify just the DV0 bank selection bit.
    
    Being cognizant that there was a failure reported before, split the code
    change out to a static function that can also be used for exclusions if
    any regressions such as Mikhail's pop up again.
    
    Cc: Jinke Fan <fanjinke@hygon.cn>
    Cc: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com>
    Link: https://lore.kernel.org/all/CABXGCsMLob0DC25JS8wwAYydnDoHBSoMh2_YLPfqm3TTvDE-Zw@mail.gmail.com/
    Link: https://www.amd.com/system/files/TechDocs/51192_Bolton_FCH_RRG.pdf
    Signed-off-by: Raul E Rangel <rrangel@chromium.org>
    Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
    Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
    Link: https://lore.kernel.org/r/20220111225750.1699-1-mario.limonciello@amd.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    superm1 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    a4d4f3e View commit details
    Browse the repository at this point in the history
  2. fs: fix an infinite loop in iomap_fiemap

    [ Upstream commit 49df342 ]
    
    when get fiemap starting from MAX_LFS_FILESIZE, (maxbytes - *len) < start
    will always true , then *len set zero. because of start offset is beyond
    file size, for erofs filesystem it will always return iomap.length with
    zero,iomap iterate will enter infinite loop. it is necessary cover this
    corner case to avoid this situation.
    
    ------------[ cut here ]------------
    WARNING: CPU: 7 PID: 905 at fs/iomap/iter.c:35 iomap_iter+0x97f/0xc70
    Modules linked in: xfs erofs
    CPU: 7 PID: 905 Comm: iomap Tainted: G        W         5.17.0-rc8 #27
    Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
    RIP: 0010:iomap_iter+0x97f/0xc70
    Code: 85 a1 fc ff ff e8 71 be 9c ff 0f 1f 44 00 00 e9 92 fc ff ff e8 62 be 9c ff 0f 0b b8 fb ff ff ff e9 fc f8 ff ff e8 51 be 9c ff <0f> 0b e9 2b fc ff ff e8 45 be 9c ff 0f 0b e9 e1 fb ff ff e8 39 be
    RSP: 0018:ffff888060a37ab0 EFLAGS: 00010293
    RAX: 0000000000000000 RBX: ffff888060a37bb0 RCX: 0000000000000000
    RDX: ffff88807e19a900 RSI: ffffffff81a7da7f RDI: ffff888060a37be0
    RBP: 7fffffffffffffff R08: 0000000000000000 R09: ffff888060a37c20
    R10: ffff888060a37c67 R11: ffffed100c146f8c R12: 7fffffffffffffff
    R13: 0000000000000000 R14: ffff888060a37bd8 R15: ffff888060a37c20
    FS:  00007fd3cca01540(0000) GS:ffff888108780000(0000) knlGS:0000000000000000
    CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
    CR2: 0000000020010820 CR3: 0000000054b92000 CR4: 00000000000006e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
    Call Trace:
     <TASK>
     iomap_fiemap+0x1c9/0x2f0
     erofs_fiemap+0x64/0x90 [erofs]
     do_vfs_ioctl+0x40d/0x12e0
     __x64_sys_ioctl+0xaa/0x1c0
     do_syscall_64+0x35/0x80
     entry_SYSCALL_64_after_hwframe+0x44/0xae
     </TASK>
    ---[ end trace 0000000000000000 ]---
    watchdog: BUG: soft lockup - CPU#7 stuck for 26s! [iomap:905]
    
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Guo Xuenan <guoxuenan@huawei.com>
    Reviewed-by: Christoph Hellwig <hch@lst.de>
    [djwong: fix some typos]
    Reviewed-by: Darrick J. Wong <djwong@kernel.org>
    Signed-off-by: Darrick J. Wong <djwong@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    JonathanSmithGuo authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    694d94b View commit details
    Browse the repository at this point in the history
  3. MIPS: lantiq: check the return value of kzalloc()

    [ Upstream commit 3412320 ]
    
    kzalloc() is a memory allocation function which can return NULL when
    some internal memory errors happen. So it is better to check the
    return value of it to prevent potential wrong memory access or
    memory leak.
    
    Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
    Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    x2018 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    3d123a3 View commit details
    Browse the repository at this point in the history
  4. drbd: remove usage of list iterator variable after loop

    [ Upstream commit 901aeda ]
    
    In preparation to limit the scope of a list iterator to the list
    traversal loop, use a dedicated pointer to iterate through the list [1].
    
    Since that variable should not be used past the loop iteration, a
    separate variable is used to 'remember the current location within the
    loop'.
    
    To either continue iterating from that position or skip the iteration
    (if the previous iteration was complete) list_prepare_entry() is used.
    
    Link: https://lore.kernel.org/all/CAHk-=wgRr_D8CB-D9Kg-c=EHreAsk5SqXPwr9Y7k9sA6cWXJ6w@mail.gmail.com/ [1]
    Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
    Link: https://lore.kernel.org/r/20220331220349.885126-1-jakobkoschel@gmail.com
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Jakob-Koschel authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    eb3c8d6 View commit details
    Browse the repository at this point in the history
  5. platform/chrome: cros_ec_debugfs: detach log reader wq from devm

    [ Upstream commit 0e8eb5e ]
    
    Debugfs console_log uses devm memory (e.g. debug_info in
    cros_ec_console_log_poll()).  However, lifecycles of device and debugfs
    are independent.  An use-after-free issue is observed if userland
    program operates the debugfs after the memory has been freed.
    
    The call trace:
     do_raw_spin_lock
     _raw_spin_lock_irqsave
     remove_wait_queue
     ep_unregister_pollwait
     ep_remove
     do_epoll_ctl
    
    A Python example to reproduce the issue:
    ... import select
    ... p = select.epoll()
    ... f = open('/sys/kernel/debug/cros_scp/console_log')
    ... p.register(f, select.POLLIN)
    ... p.poll(1)
    [(4, 1)]                    # 4=fd, 1=select.POLLIN
    
    [ shutdown cros_scp at the point ]
    
    ... p.poll(1)
    [(4, 16)]                   # 4=fd, 16=select.POLLHUP
    ... p.unregister(f)
    
    An use-after-free issue raises here.  It called epoll_ctl with
    EPOLL_CTL_DEL which in turn to use the workqueue in the devm (i.e.
    log_wq).
    
    Detaches log reader's workqueue from devm to make sure it is persistent
    even if the device has been removed.
    
    Signed-off-by: Tzung-Bi Shih <tzungbi@google.com>
    Reviewed-by: Guenter Roeck <groeck@google.com>
    Link: https://lore.kernel.org/r/20220209051130.386175-1-tzungbi@google.com
    Signed-off-by: Benson Leung <bleung@chromium.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Tzung-Bi Shih authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    675f8a7 View commit details
    Browse the repository at this point in the history
  6. ARM: 9191/1: arm/stacktrace, kasan: Silence KASAN warnings in unwind_…

    …frame()
    
    [ Upstream commit 9be4c88 ]
    
    The following KASAN warning is detected by QEMU.
    
    ==================================================================
    BUG: KASAN: stack-out-of-bounds in unwind_frame+0x508/0x870
    Read of size 4 at addr c36bba90 by task cat/163
    
    CPU: 1 PID: 163 Comm: cat Not tainted 5.10.0-rc1 #40
    Hardware name: ARM-Versatile Express
    [<c0113fac>] (unwind_backtrace) from [<c010e71c>] (show_stack+0x10/0x14)
    [<c010e71c>] (show_stack) from [<c0b805b4>] (dump_stack+0x98/0xb0)
    [<c0b805b4>] (dump_stack) from [<c0b7d658>] (print_address_description.constprop.0+0x58/0x4bc)
    [<c0b7d658>] (print_address_description.constprop.0) from [<c031435c>] (kasan_report+0x154/0x170)
    [<c031435c>] (kasan_report) from [<c0113c44>] (unwind_frame+0x508/0x870)
    [<c0113c44>] (unwind_frame) from [<c010e298>] (__save_stack_trace+0x110/0x134)
    [<c010e298>] (__save_stack_trace) from [<c01ce0d8>] (stack_trace_save+0x8c/0xb4)
    [<c01ce0d8>] (stack_trace_save) from [<c0313520>] (kasan_set_track+0x38/0x60)
    [<c0313520>] (kasan_set_track) from [<c0314cb8>] (kasan_set_free_info+0x20/0x2c)
    [<c0314cb8>] (kasan_set_free_info) from [<c0313474>] (__kasan_slab_free+0xec/0x120)
    [<c0313474>] (__kasan_slab_free) from [<c0311e20>] (kmem_cache_free+0x7c/0x334)
    [<c0311e20>] (kmem_cache_free) from [<c01c35dc>] (rcu_core+0x390/0xccc)
    [<c01c35dc>] (rcu_core) from [<c01013a8>] (__do_softirq+0x180/0x518)
    [<c01013a8>] (__do_softirq) from [<c0135214>] (irq_exit+0x9c/0xe0)
    [<c0135214>] (irq_exit) from [<c01a40e4>] (__handle_domain_irq+0xb0/0x110)
    [<c01a40e4>] (__handle_domain_irq) from [<c0691248>] (gic_handle_irq+0xa0/0xb8)
    [<c0691248>] (gic_handle_irq) from [<c0100b0c>] (__irq_svc+0x6c/0x94)
    Exception stack(0xc36bb928 to 0xc36bb970)
    b920:                   c36bb9c0 00000000 c0126919 c0101228 c36bb9c0 b76d7730
    b940: c36b8000 c36bb9a0 c3335b00 c01ce0d8 00000003 c36bba3c c36bb940 c36bb978
    b960: c010e298 c011373c 60000013 ffffffff
    [<c0100b0c>] (__irq_svc) from [<c011373c>] (unwind_frame+0x0/0x870)
    [<c011373c>] (unwind_frame) from [<00000000>] (0x0)
    
    The buggy address belongs to the page:
    page:(ptrval) refcount:0 mapcount:0 mapping:00000000 index:0x0 pfn:0x636bb
    flags: 0x0()
    raw: 00000000 00000000 ef867764 00000000 00000000 00000000 ffffffff 00000000
    page dumped because: kasan: bad access detected
    
    addr c36bba90 is located in stack of task cat/163 at offset 48 in frame:
     stack_trace_save+0x0/0xb4
    
    this frame has 1 object:
     [32, 48) 'trace'
    
    Memory state around the buggy address:
     c36bb980: f1 f1 f1 f1 00 04 f2 f2 00 00 f3 f3 00 00 00 00
     c36bba00: 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1 f1
    >c36bba80: 00 00 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00
                     ^
     c36bbb00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
     c36bbb80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    ==================================================================
    
    There is a same issue on x86 and has been resolved by the commit f7d27c3
    ("x86/mm, kasan: Silence KASAN warnings in get_wchan()").
    The solution could be applied to arm architecture too.
    
    Signed-off-by: Lin Yujun <linyujun809@huawei.com>
    Reported-by: He Ying <heying24@huawei.com>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    linyujun authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    a18a392 View commit details
    Browse the repository at this point in the history
  7. nilfs2: fix lockdep warnings in page operations for btree nodes

    [ Upstream commit e897be1 ]
    
    Patch series "nilfs2 lockdep warning fixes".
    
    The first two are to resolve the lockdep warning issue, and the last one
    is the accompanying cleanup and low priority.
    
    Based on your comment, this series solves the issue by separating inode
    object as needed.  Since I was worried about the impact of the object
    composition changes, I tested the series carefully not to cause
    regressions especially for delicate functions such like disk space
    reclamation and snapshots.
    
    This patch (of 3):
    
    If CONFIG_LOCKDEP is enabled, nilfs2 hits lockdep warnings at
    inode_to_wb() during page/folio operations for btree nodes:
    
      WARNING: CPU: 0 PID: 6575 at include/linux/backing-dev.h:269 inode_to_wb include/linux/backing-dev.h:269 [inline]
      WARNING: CPU: 0 PID: 6575 at include/linux/backing-dev.h:269 folio_account_dirtied mm/page-writeback.c:2460 [inline]
      WARNING: CPU: 0 PID: 6575 at include/linux/backing-dev.h:269 __folio_mark_dirty+0xa7c/0xe30 mm/page-writeback.c:2509
      Modules linked in:
      ...
      RIP: 0010:inode_to_wb include/linux/backing-dev.h:269 [inline]
      RIP: 0010:folio_account_dirtied mm/page-writeback.c:2460 [inline]
      RIP: 0010:__folio_mark_dirty+0xa7c/0xe30 mm/page-writeback.c:2509
      ...
      Call Trace:
        __set_page_dirty include/linux/pagemap.h:834 [inline]
        mark_buffer_dirty+0x4e6/0x650 fs/buffer.c:1145
        nilfs_btree_propagate_p fs/nilfs2/btree.c:1889 [inline]
        nilfs_btree_propagate+0x4ae/0xea0 fs/nilfs2/btree.c:2085
        nilfs_bmap_propagate+0x73/0x170 fs/nilfs2/bmap.c:337
        nilfs_collect_dat_data+0x45/0xd0 fs/nilfs2/segment.c:625
        nilfs_segctor_apply_buffers+0x14a/0x470 fs/nilfs2/segment.c:1009
        nilfs_segctor_scan_file+0x47a/0x700 fs/nilfs2/segment.c:1048
        nilfs_segctor_collect_blocks fs/nilfs2/segment.c:1224 [inline]
        nilfs_segctor_collect fs/nilfs2/segment.c:1494 [inline]
        nilfs_segctor_do_construct+0x14f3/0x6c60 fs/nilfs2/segment.c:2036
        nilfs_segctor_construct+0x7a7/0xb30 fs/nilfs2/segment.c:2372
        nilfs_segctor_thread_construct fs/nilfs2/segment.c:2480 [inline]
        nilfs_segctor_thread+0x3c3/0xf90 fs/nilfs2/segment.c:2563
        kthread+0x405/0x4f0 kernel/kthread.c:327
        ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
    
    This is because nilfs2 uses two page caches for each inode and
    inode->i_mapping never points to one of them, the btree node cache.
    
    This causes inode_to_wb(inode) to refer to a different page cache than
    the caller page/folio operations such like __folio_start_writeback(),
    __folio_end_writeback(), or __folio_mark_dirty() acquired the lock.
    
    This patch resolves the issue by allocating and using an additional
    inode to hold the page cache of btree nodes.  The inode is attached
    one-to-one to the traditional nilfs2 inode if it requires a block
    mapping with b-tree.  This setup change is in memory only and does not
    affect the disk format.
    
    Link: https://lkml.kernel.org/r/1647867427-30498-1-git-send-email-konishi.ryusuke@gmail.com
    Link: https://lkml.kernel.org/r/1647867427-30498-2-git-send-email-konishi.ryusuke@gmail.com
    Link: https://lore.kernel.org/r/YXrYvIo8YRnAOJCj@casper.infradead.org
    Link: https://lore.kernel.org/r/9a20b33d-b38f-b4a2-4742-c1eb5b8e4d6c@redhat.com
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
    Reported-by: syzbot+0d5b462a6f07447991b3@syzkaller.appspotmail.com
    Reported-by: syzbot+34ef28bb2aeb28724aa0@syzkaller.appspotmail.com
    Reported-by: Hao Sun <sunhao.th@gmail.com>
    Reported-by: David Hildenbrand <david@redhat.com>
    Tested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    konis authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    1829b24 View commit details
    Browse the repository at this point in the history
  8. nilfs2: fix lockdep warnings during disk space reclamation

    [ Upstream commit 6e21193 ]
    
    During disk space reclamation, nilfs2 still emits the following lockdep
    warning due to page/folio operations on shadowed page caches that nilfs2
    uses to get a snapshot of DAT file in memory:
    
      WARNING: CPU: 0 PID: 2643 at include/linux/backing-dev.h:272 __folio_mark_dirty+0x645/0x670
      ...
      RIP: 0010:__folio_mark_dirty+0x645/0x670
      ...
      Call Trace:
        filemap_dirty_folio+0x74/0xd0
        __set_page_dirty_nobuffers+0x85/0xb0
        nilfs_copy_dirty_pages+0x288/0x510 [nilfs2]
        nilfs_mdt_save_to_shadow_map+0x50/0xe0 [nilfs2]
        nilfs_clean_segments+0xee/0x5d0 [nilfs2]
        nilfs_ioctl_clean_segments.isra.19+0xb08/0xf40 [nilfs2]
        nilfs_ioctl+0xc52/0xfb0 [nilfs2]
        __x64_sys_ioctl+0x11d/0x170
    
    This fixes the remaining warning by using inode objects to hold those
    page caches.
    
    Link: https://lkml.kernel.org/r/1647867427-30498-3-git-send-email-konishi.ryusuke@gmail.com
    Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
    Tested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
    Cc: Matthew Wilcox <willy@infradead.org>
    Cc: David Hildenbrand <david@redhat.com>
    Cc: Hao Sun <sunhao.th@gmail.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    konis authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    8092090 View commit details
    Browse the repository at this point in the history
  9. ALSA: usb-audio: Restore Rane SL-1 quirk

    commit 5c62383 upstream.
    
    At cleaning up and moving the device rename from the quirk table to
    its own table, we removed the entry for Rane SL-1 as we thought it's
    only for renaming.  It turned out, however, that the quirk is required
    for matching with the device that declares itself as no standard
    audio but only as vendor-specific.
    
    Restore the quirk entry for Rane SL-1 to fix the regression.
    
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215887
    Fixes: 5436f59 ("ALSA: usb-audio: Move device rename and profile quirks to an internal table")
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220516103112.12950-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    tiwai authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    c1d1675 View commit details
    Browse the repository at this point in the history
  10. ALSA: wavefront: Proper check of get_user() error

    commit a34ae6c upstream.
    
    The antient ISA wavefront driver reads its sample patch data (uploaded
    over an ioctl) via __get_user() with no good reason; likely just for
    some performance optimizations in the past.  Let's change this to the
    standard get_user() and the error check for handling the fault case
    properly.
    
    Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/20220510103626.16635-1-tiwai@suse.de
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    tiwai authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    16ffc72 View commit details
    Browse the repository at this point in the history
  11. ALSA: hda/realtek: Add quirk for TongFang devices with pop noise

    commit 8b3b239 upstream.
    
    When audio stops playing there is an audible "pop"-noise when using
    headphones on the TongFang GMxMRxx, GKxNRxx, GMxZGxx, GMxTGxx and GMxAGxx.
    
    This quirk fixes this mostly.
    
    Signed-off-by: Werner Sembach <wse@tuxedocomputers.com>
    Cc: stable@vger.kernel.org
    Link: https://lore.kernel.org/r/20220512180956.281804-1-wse@tuxedocomputers.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    tuxedo-wse authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    3572025 View commit details
    Browse the repository at this point in the history
  12. perf: Fix sys_perf_event_open() race against self

    commit 3ac6487 upstream.
    
    Norbert reported that it's possible to race sys_perf_event_open() such
    that the looser ends up in another context from the group leader,
    triggering many WARNs.
    
    The move_group case checks for races against itself, but the
    !move_group case doesn't, seemingly relying on the previous
    group_leader->ctx == ctx check. However, that check is racy due to not
    holding any locks at that time.
    
    Therefore, re-check the result after acquiring locks and bailing
    if they no longer match.
    
    Additionally, clarify the not_move_group case from the
    move_group-vs-move_group race.
    
    Fixes: f63a8da ("perf: Fix event->ctx locking")
    Reported-by: Norbert Slusarek <nslusarek@gmx.net>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Peter Zijlstra authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    22fb297 View commit details
    Browse the repository at this point in the history
  13. selinux: fix bad cleanup on error in hashtab_duplicate()

    commit 6254bd3 upstream.
    
    The code attempts to free the 'new' pointer using kmem_cache_free(),
    which is wrong because this function isn't responsible of freeing it.
    Instead, the function should free new->htable and clear the contents of
    *new (to prevent double-free).
    
    Cc: stable@vger.kernel.org
    Fixes: c7c556f ("selinux: refactor changing booleans")
    Reported-by: Wander Lairson Costa <wander@redhat.com>
    Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    WOnder93 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    ec9fd8d View commit details
    Browse the repository at this point in the history
  14. audit,io_uring,io-wq: call __audit_uring_exit for dummy contexts

    commit 69e9cd6 upstream.
    
    Not calling the function for dummy contexts will cause the context to
    not be reset. During the next syscall, this will cause an error in
    __audit_syscall_entry:
    
    	WARN_ON(context->context != AUDIT_CTX_UNUSED);
    	WARN_ON(context->name_count);
    	if (context->context != AUDIT_CTX_UNUSED || context->name_count) {
    		audit_panic("unrecoverable error in audit_syscall_entry()");
    		return;
    	}
    
    These problematic dummy contexts are created via the following call
    chain:
    
           exit_to_user_mode_prepare
        -> arch_do_signal_or_restart
        -> get_signal
        -> task_work_run
        -> tctx_task_work
        -> io_req_task_submit
        -> io_issue_sqe
        -> audit_uring_entry
    
    Cc: stable@vger.kernel.org
    Fixes: 5bd2182 ("audit,io_uring,io-wq: add some basic audit support to io_uring")
    Signed-off-by: Julian Orth <ju.orth@gmail.com>
    [PM: subject line tweaks]
    Signed-off-by: Paul Moore <paul@paul-moore.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    mahkoh authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    80a1f35 View commit details
    Browse the repository at this point in the history
  15. Fix double fget() in vhost_net_set_backend()

    commit fb4554c upstream.
    
    Descriptor table is a shared resource; two fget() on the same descriptor
    may return different struct file references.  get_tap_ptr_ring() is
    called after we'd found (and pinned) the socket we'll be using and it
    tries to find the private tun/tap data structures associated with it.
    Redoing the lookup by the same file descriptor we'd used to get the
    socket is racy - we need to same struct file.
    
    Thanks to Jason for spotting a braino in the original variant of patch -
    I'd missed the use of fd == -1 for disabling backend, and in that case
    we can end up with sock == NULL and sock != oldsock.
    
    Cc: stable@kernel.org
    Acked-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Jason Wang <jasowang@redhat.com>
    Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Al Viro authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    d759015 View commit details
    Browse the repository at this point in the history
  16. PCI/PM: Avoid putting Elo i2 PCIe Ports in D3cold

    commit 92597f9 upstream.
    
    If a Root Port on Elo i2 is put into D3cold and then back into D0, the
    downstream device becomes permanently inaccessible, so add a bridge D3 DMI
    quirk for that system.
    
    This was exposed by 14858dc ("PCI: Use pci_update_current_state() in
    pci_enable_device_flags()"), but before that commit the Root Port in
    question had never been put into D3cold for real due to a mismatch between
    its power state retrieved from the PCI_PM_CTRL register (which was
    accessible even though the platform firmware indicated that the port was in
    D3cold) and the state of an ACPI power resource involved in its power
    management.
    
    BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=215715
    Link: https://lore.kernel.org/r/11980172.O9o76ZdvQC@kreacher
    Reported-by: Stefan Gottwald <gottwald@igel.com>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Cc: stable@vger.kernel.org	# v5.15+
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    rafaeljw authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    6bec1b3 View commit details
    Browse the repository at this point in the history
  17. Revert "can: m_can: pci: use custom bit timings for Elkhart Lake"

    commit 14ea4a4 upstream.
    
    This reverts commit 0e8ffdf.
    
    Commit 0e8ffdf ("can: m_can: pci: use custom bit timings for
    Elkhart Lake") broke the test case using bitrate switching.
    
    | ip link set can0 up type can bitrate 500000 dbitrate 4000000 fd on
    | ip link set can1 up type can bitrate 500000 dbitrate 4000000 fd on
    | candump can0 &
    | cangen can1 -I 0x800 -L 64 -e -fb \
    |     -D 11223344deadbeef55667788feedf00daabbccdd44332211 -n 1 -v -v
    
    Above commit does everything correctly according to the datasheet.
    However datasheet wasn't correct.
    
    I got confirmation from hardware engineers that the actual CAN
    hardware on Intel Elkhart Lake is based on M_CAN version v3.2.0.
    Datasheet was mirroring values from an another specification which was
    based on earlier M_CAN version leading to wrong bit timings.
    
    Therefore revert the commit and switch back to common bit timings.
    
    Fixes: ea4c178 ("can: m_can: pci: use custom bit timings for Elkhart Lake")
    Link: https://lore.kernel.org/all/20220512124144.536850-1-jarkko.nikula@linux.intel.com
    Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
    Reported-by: Chee Hou Ong <chee.houx.ong@intel.com>
    Reported-by: Aman Kumar <aman.kumar@intel.com>
    Reported-by: Pallavi Kumari <kumari.pallavi@intel.com>
    Cc: <stable@vger.kernel.org> # v5.16+
    Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    jhnikula authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    ca5e91e View commit details
    Browse the repository at this point in the history
  18. KVM: arm64: vgic-v3: Consistently populate ID_AA64PFR0_EL1.GIC

    commit 5163373 upstream.
    
    When adding support for the slightly wonky Apple M1, we had to
    populate ID_AA64PFR0_EL1.GIC==1 to present something to the guest,
    as the HW itself doesn't advertise the feature.
    
    However, we gated this on the in-kernel irqchip being created.
    This causes some trouble for QEMU, which snapshots the state of
    the registers before creating a virtual GIC, and then tries to
    restore these registers once the GIC has been created.  Obviously,
    between the two stages, ID_AA64PFR0_EL1.GIC has changed value,
    and the write fails.
    
    The fix is to actually emulate the HW, and always populate the
    field if the HW is capable of it.
    
    Fixes: 562e530 ("KVM: arm64: Force ID_AA64PFR0_EL1.GIC=1 when exposing a virtual GICv3")
    Cc: stable@vger.kernel.org
    Signed-off-by: Marc Zyngier <maz@kernel.org>
    Reported-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Oliver Upton <oupton@google.com>
    Link: https://lore.kernel.org/r/20220503211424.3375263-1-maz@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Marc Zyngier authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    7672e47 View commit details
    Browse the repository at this point in the history
  19. KVM: x86/mmu: Update number of zapped pages even if page list is stable

    commit b28cb0c upstream.
    
    When zapping obsolete pages, update the running count of zapped pages
    regardless of whether or not the list has become unstable due to zapping
    a shadow page with its own child shadow pages.  If the VM is backed by
    mostly 4kb pages, KVM can zap an absurd number of SPTEs without bumping
    the batch count and thus without yielding.  In the worst case scenario,
    this can cause a soft lokcup.
    
     watchdog: BUG: soft lockup - CPU#12 stuck for 22s! [dirty_log_perf_:13020]
       RIP: 0010:workingset_activation+0x19/0x130
       mark_page_accessed+0x266/0x2e0
       kvm_set_pfn_accessed+0x31/0x40
       mmu_spte_clear_track_bits+0x136/0x1c0
       drop_spte+0x1a/0xc0
       mmu_page_zap_pte+0xef/0x120
       __kvm_mmu_prepare_zap_page+0x205/0x5e0
       kvm_mmu_zap_all_fast+0xd7/0x190
       kvm_mmu_invalidate_zap_pages_in_memslot+0xe/0x10
       kvm_page_track_flush_slot+0x5c/0x80
       kvm_arch_flush_shadow_memslot+0xe/0x10
       kvm_set_memslot+0x1a8/0x5d0
       __kvm_set_memory_region+0x337/0x590
       kvm_vm_ioctl+0xb08/0x1040
    
    Fixes: fbb158c ("KVM: x86/mmu: Revert "Revert "KVM: MMU: zap pages in batch""")
    Reported-by: David Matlack <dmatlack@google.com>
    Reviewed-by: Ben Gardon <bgardon@google.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Message-Id: <20220511145122.3133334-1-seanjc@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    sean-jc authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    c477e01 View commit details
    Browse the repository at this point in the history
  20. KVM: Free new dirty bitmap if creating a new memslot fails

    commit c87661f upstream.
    
    Fix a goof in kvm_prepare_memory_region() where KVM fails to free the
    new memslot's dirty bitmap during a CREATE action if
    kvm_arch_prepare_memory_region() fails.  The logic is supposed to detect
    if the bitmap was allocated and thus needs to be freed, versus if the
    bitmap was inherited from the old memslot and thus needs to be kept.  If
    there is no old memslot, then obviously the bitmap can't have been
    inherited
    
    The bug was exposed by commit 86931ff ("KVM: x86/mmu: Do not create
    SPTEs for GFNs that exceed host.MAXPHYADDR"), which made it trivally easy
    for syzkaller to trigger failure during kvm_arch_prepare_memory_region(),
    but the bug can be hit other ways too, e.g. due to -ENOMEM when
    allocating x86's memslot metadata.
    
    The backtrace from kmemleak:
    
      __vmalloc_node_range+0xb40/0xbd0 mm/vmalloc.c:3195
      __vmalloc_node mm/vmalloc.c:3232 [inline]
      __vmalloc+0x49/0x50 mm/vmalloc.c:3246
      __vmalloc_array mm/util.c:671 [inline]
      __vcalloc+0x49/0x70 mm/util.c:694
      kvm_alloc_dirty_bitmap virt/kvm/kvm_main.c:1319
      kvm_prepare_memory_region virt/kvm/kvm_main.c:1551
      kvm_set_memslot+0x1bd/0x690 virt/kvm/kvm_main.c:1782
      __kvm_set_memory_region+0x689/0x750 virt/kvm/kvm_main.c:1949
      kvm_set_memory_region virt/kvm/kvm_main.c:1962
      kvm_vm_ioctl_set_memory_region virt/kvm/kvm_main.c:1974
      kvm_vm_ioctl+0x377/0x13a0 virt/kvm/kvm_main.c:4528
      vfs_ioctl fs/ioctl.c:51
      __do_sys_ioctl fs/ioctl.c:870
      __se_sys_ioctl fs/ioctl.c:856
      __x64_sys_ioctl+0xfc/0x140 fs/ioctl.c:856
      do_syscall_x64 arch/x86/entry/common.c:50
      do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
      entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    And the relevant sequence of KVM events:
    
      ioctl(3, KVM_CREATE_VM, 0)              = 4
      ioctl(4, KVM_SET_USER_MEMORY_REGION, {slot=0,
                                            flags=KVM_MEM_LOG_DIRTY_PAGES,
                                            guest_phys_addr=0x10000000000000,
                                            memory_size=4096,
                                            userspace_addr=0x20fe8000}
           ) = -1 EINVAL (Invalid argument)
    
    Fixes: 244893f ("KVM: Dynamically allocate "new" memslots from the get-go")
    Cc: stable@vger.kernel.org
    Reported-by: syzbot+8606b8a9cc97a63f1c87@syzkaller.appspotmail.com
    Signed-off-by: Sean Christopherson <seanjc@google.com>
    Message-Id: <20220518003842.1341782-1-seanjc@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    sean-jc authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    ca0232d View commit details
    Browse the repository at this point in the history
  21. arm64: paravirt: Use RCU read locks to guard stolen_time

    commit 19bef63 upstream.
    
    During hotplug, the stolen time data structure is unmapped and memset.
    There is a possibility of the timer IRQ being triggered before memset
    and stolen time is getting updated as part of this timer IRQ handler. This
    causes the below crash in timer handler -
    
      [ 3457.473139][    C5] Unable to handle kernel paging request at virtual address ffffffc03df05148
      ...
      [ 3458.154398][    C5] Call trace:
      [ 3458.157648][    C5]  para_steal_clock+0x30/0x50
      [ 3458.162319][    C5]  irqtime_account_process_tick+0x30/0x194
      [ 3458.168148][    C5]  account_process_tick+0x3c/0x280
      [ 3458.173274][    C5]  update_process_times+0x5c/0xf4
      [ 3458.178311][    C5]  tick_sched_timer+0x180/0x384
      [ 3458.183164][    C5]  __run_hrtimer+0x160/0x57c
      [ 3458.187744][    C5]  hrtimer_interrupt+0x258/0x684
      [ 3458.192698][    C5]  arch_timer_handler_virt+0x5c/0xa0
      [ 3458.198002][    C5]  handle_percpu_devid_irq+0xdc/0x414
      [ 3458.203385][    C5]  handle_domain_irq+0xa8/0x168
      [ 3458.208241][    C5]  gic_handle_irq.34493+0x54/0x244
      [ 3458.213359][    C5]  call_on_irq_stack+0x40/0x70
      [ 3458.218125][    C5]  do_interrupt_handler+0x60/0x9c
      [ 3458.223156][    C5]  el1_interrupt+0x34/0x64
      [ 3458.227560][    C5]  el1h_64_irq_handler+0x1c/0x2c
      [ 3458.232503][    C5]  el1h_64_irq+0x7c/0x80
      [ 3458.236736][    C5]  free_vmap_area_noflush+0x108/0x39c
      [ 3458.242126][    C5]  remove_vm_area+0xbc/0x118
      [ 3458.246714][    C5]  vm_remove_mappings+0x48/0x2a4
      [ 3458.251656][    C5]  __vunmap+0x154/0x278
      [ 3458.255796][    C5]  stolen_time_cpu_down_prepare+0xc0/0xd8
      [ 3458.261542][    C5]  cpuhp_invoke_callback+0x248/0xc34
      [ 3458.266842][    C5]  cpuhp_thread_fun+0x1c4/0x248
      [ 3458.271696][    C5]  smpboot_thread_fn+0x1b0/0x400
      [ 3458.276638][    C5]  kthread+0x17c/0x1e0
      [ 3458.280691][    C5]  ret_from_fork+0x10/0x20
    
    As a fix, introduce rcu lock to update stolen time structure.
    
    Fixes: 75df529 ("arm64: paravirt: Initialize steal time when cpu is online")
    Cc: stable@vger.kernel.org
    Suggested-by: Will Deacon <will@kernel.org>
    Signed-off-by: Prakruthi Deepak Heragu <quic_pheragu@quicinc.com>
    Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
    Reviewed-by: Srivatsa S. Bhat (VMware) <srivatsa@csail.mit.edu>
    Link: https://lore.kernel.org/r/20220513174654.362169-1-quic_eberman@quicinc.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    quic-pheragu authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    c325879 View commit details
    Browse the repository at this point in the history
  22. arm64: mte: Ensure the cleared tags are visible before setting the PTE

    commit 1d0cb4c upstream.
    
    As an optimisation, only pages mapped with PROT_MTE in user space have
    the MTE tags zeroed. This is done lazily at the set_pte_at() time via
    mte_sync_tags(). However, this function is missing a barrier and another
    CPU may see the PTE updated before the zeroed tags are visible. Add an
    smp_wmb() barrier if the mapping is Normal Tagged.
    
    Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
    Fixes: 34bfeea ("arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE")
    Cc: <stable@vger.kernel.org> # 5.10.x
    Reported-by: Vladimir Murzin <vladimir.murzin@arm.com>
    Cc: Will Deacon <will@kernel.org>
    Reviewed-by: Steven Price <steven.price@arm.com>
    Tested-by: Vladimir Murzin <vladimir.murzin@arm.com>
    Link: https://lore.kernel.org/r/20220517093532.127095-1-catalin.marinas@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ctmarinas authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    404c714 View commit details
    Browse the repository at this point in the history
  23. crypto: qcom-rng - fix infinite loop on requests not multiple of WORD_SZ

    commit 1628739 upstream.
    
    The commit referenced in the Fixes tag removed the 'break' from the else
    branch in qcom_rng_read(), causing an infinite loop whenever 'max' is
    not a multiple of WORD_SZ. This can be reproduced e.g. by running:
    
        kcapi-rng -b 67 >/dev/null
    
    There are many ways to fix this without adding back the 'break', but
    they all seem more awkward than simply adding it back, so do just that.
    
    Tested on a machine with Qualcomm Amberwing processor.
    
    Fixes: a680b18 ("crypto: qcom-rng - ensure buffer for generate is completely filled")
    Cc: stable@vger.kernel.org
    Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
    Reviewed-by: Brian Masney <bmasney@redhat.com>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    WOnder93 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    05d4d17 View commit details
    Browse the repository at this point in the history
  24. mmc: core: Fix busy polling for MMC_SEND_OP_COND again

    commit e949dee upstream.
    
    It turned out that polling period for MMC_SEND_OP_COND, that currently is
    set to 1ms, still isn't sufficient. In particular a Micron eMMC on a
    Beaglebone platform, is reported to sometimes fail to initialize.
    
    Additional test, shows that extending the period to 4ms is working fine, so
    let's make that change.
    
    Reported-by: Jean Rene Dawin <jdawin@math.uni-bielefeld.de>
    Tested-by: Jean Rene Dawin <jdawin@math.uni-bielefeld.de>
    Fixes: 1760fdb (mmc: core: Restore (almost) the busy polling for MMC_SEND_OP_COND")
    Fixes: 76bfc7c ("mmc: core: adjust polling interval for CMD1")
    Cc: stable@vger.kernel.org
    Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
    Link: https://lore.kernel.org/r/20220517101046.27512-1-ulf.hansson@linaro.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    storulf authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    c90cb44 View commit details
    Browse the repository at this point in the history
  25. libceph: fix potential use-after-free on linger ping and resends

    commit 75dbb68 upstream.
    
    request_reinit() is not only ugly as the comment rightfully suggests,
    but also unsafe.  Even though it is called with osdc->lock held for
    write in all cases, resetting the OSD request refcount can still race
    with handle_reply() and result in use-after-free.  Taking linger ping
    as an example:
    
        handle_timeout thread                     handle_reply thread
    
                                                  down_read(&osdc->lock)
                                                  req = lookup_request(...)
                                                  ...
                                                  finish_request(req)  # unregisters
                                                  up_read(&osdc->lock)
                                                  __complete_request(req)
                                                    linger_ping_cb(req)
    
          # req->r_kref == 2 because handle_reply still holds its ref
    
        down_write(&osdc->lock)
        send_linger_ping(lreq)
          req = lreq->ping_req  # same req
          # cancel_linger_request is NOT
          # called - handle_reply already
          # unregistered
          request_reinit(req)
            WARN_ON(req->r_kref != 1)  # fires
            request_init(req)
              kref_init(req->r_kref)
    
                       # req->r_kref == 1 after kref_init
    
                                                  ceph_osdc_put_request(req)
                                                    kref_put(req->r_kref)
    
                # req->r_kref == 0 after kref_put, req is freed
    
            <further req initialization/use> !!!
    
    This happens because send_linger_ping() always (re)uses the same OSD
    request for watch ping requests, relying on cancel_linger_request() to
    unregister it from the OSD client and rip its messages out from the
    messenger.  send_linger() does the same for watch/notify registration
    and watch reconnect requests.  Unfortunately cancel_request() doesn't
    guarantee that after it returns the OSD client would be completely done
    with the OSD request -- a ref could still be held and the callback (if
    specified) could still be invoked too.
    
    The original motivation for request_reinit() was inability to deal with
    allocation failures in send_linger() and send_linger_ping().  Switching
    to using osdc->req_mempool (currently only used by CephFS) respects that
    and allows us to get rid of request_reinit().
    
    Cc: stable@vger.kernel.org
    Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
    Reviewed-by: Xiubo Li <xiubli@redhat.com>
    Acked-by: Jeff Layton <jlayton@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    idryomov authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    ce2e1de View commit details
    Browse the repository at this point in the history
  26. drm/amd: Don't reset dGPUs if the system is going to s2idle

    commit 7123d39 upstream.
    
    An A+A configuration on ASUS ROG Strix G513QY proves that the ASIC
    reset for handling aborted suspend can't work with s2idle.
    
    This functionality was introduced in commit daf8de0 ("drm/amdgpu:
    always reset the asic in suspend (v2)").  A few other commits have
    gone on top of the ASIC reset, but this still doesn't work on the A+A
    configuration in s2idle.
    
    Avoid doing the reset on dGPUs specifically when using s2idle.
    
    Fixes: daf8de0 ("drm/amdgpu: always reset the asic in suspend (v2)")
    Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2008
    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    superm1 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    9a08465 View commit details
    Browse the repository at this point in the history
  27. drm/i915/dmc: Add MMIO range restrictions

    commit 54395a3 upstream.
    
    Bspec has added some steps that check forDMC MMIO range before
    programming them
    
    v2: Fix for CI
    v3: move register defines to .h (Anusha)
    - Check MMIO restrictions per pipe
    - Add MMIO restricton for v1 dmc header as well (Lucas)
    v4: s/_PICK/_PICK_EVEN and use it only for Pipe DMC scenario.
    - clean up sanity check logic.(Lucas)
    - Add MMIO range for RKL as well.(Anusha)
    v5: Use DISPLAY_VER instead of per platform check (Lucas)
    
    BSpec: 49193
    
    Cc: stable@vger.kernel.org
    Cc: Lucas De Marchi <lucas.demarchi@intel.com>
    Signed-off-by: Anusha Srivatsa <anusha.srivatsa@intel.com>
    Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
    Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220511000847.1068302-1-anusha.srivatsa@intel.com
    (cherry picked from commit 21c4719)
    Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    anushasr authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    fb4ba08 View commit details
    Browse the repository at this point in the history
  28. drm/dp/mst: fix a possible memory leak in fetch_monitor_name()

    commit 6e03b13 upstream.
    
    drm_dp_mst_get_edid call kmemdup to create mst_edid. So mst_edid need to be
    freed after use.
    
    Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
    Reviewed-by: Lyude Paul <lyude@redhat.com>
    Signed-off-by: Lyude Paul <lyude@redhat.com>
    Cc: stable@vger.kernel.org
    Link: https://patchwork.freedesktop.org/patch/msgid/20220516032042.13166-1-hbh25y@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    HBh25Y authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    f8beb58 View commit details
    Browse the repository at this point in the history
  29. dma-buf: fix use of DMA_BUF_SET_NAME_{A,B} in userspace

    commit 7c3e9fc upstream.
    
    The typedefs u32 and u64 are not available in userspace. Thus user get
    an error he try to use DMA_BUF_SET_NAME_A or DMA_BUF_SET_NAME_B:
    
        $ gcc -Wall   -c -MMD -c -o ioctls_list.o ioctls_list.c
        In file included from /usr/include/x86_64-linux-gnu/asm/ioctl.h:1,
                         from /usr/include/linux/ioctl.h:5,
                         from /usr/include/asm-generic/ioctls.h:5,
                         from ioctls_list.c:11:
        ioctls_list.c:463:29: error: ‘u32’ undeclared here (not in a function)
          463 |     { "DMA_BUF_SET_NAME_A", DMA_BUF_SET_NAME_A, -1, -1 }, // linux/dma-buf.h
              |                             ^~~~~~~~~~~~~~~~~~
        ioctls_list.c:464:29: error: ‘u64’ undeclared here (not in a function)
          464 |     { "DMA_BUF_SET_NAME_B", DMA_BUF_SET_NAME_B, -1, -1 }, // linux/dma-buf.h
              |                             ^~~~~~~~~~~~~~~~~~
    
    The issue was initially reported here[1].
    
    [1]: jerome-pouiller/ioctl#14
    
    Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Fixes: a5bff92 ("dma-buf: Fix SET_NAME ioctl uapi")
    CC: stable@vger.kernel.org
    Link: https://patchwork.freedesktop.org/patch/msgid/20220517072708.245265-1-Jerome.Pouiller@silabs.com
    Signed-off-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    jerome-pouiller authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    2d0e5b6 View commit details
    Browse the repository at this point in the history
  30. dma-buf: ensure unique directory name for dmabuf stats

    commit 370704e upstream.
    
    The dmabuf file uses get_next_ino()(through dma_buf_getfile() ->
    alloc_anon_inode()) to get an inode number and uses the same as a
    directory name under /sys/kernel/dmabuf/buffers/<ino>. This directory is
    used to collect the dmabuf stats and it is created through
    dma_buf_stats_setup(). At current, failure to create this directory
    entry can make the dma_buf_export() to fail.
    
    Now, as the get_next_ino() can definitely give a repetitive inode no
    causing the directory entry creation to fail with -EEXIST. This is a
    problem on the systems where dmabuf stats functionality is enabled on
    the production builds can make the dma_buf_export(), though the dmabuf
    memory is allocated successfully, to fail just because it couldn't
    create stats entry.
    
    This issue we are able to see on the snapdragon system within 13 days
    where there already exists a directory with inode no "122602" so
    dma_buf_stats_setup() failed with -EEXIST as it is trying to create
    the same directory entry.
    
    To make the dentry name as unique, use the dmabuf fs specific inode
    which is based on the simple atomic variable increment. There is tmpfs
    subsystem too which relies on its own inode generation rather than
    relying on the get_next_ino() for the same reason of avoiding the
    duplicate inodes[1].
    
    [1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/patch/?id=e809d5f0b5c912fe981dce738f3283b2010665f0
    
    Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com>
    Cc: <stable@vger.kernel.org> # 5.15.x+
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Christian König <christian.koenig@amd.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/1652441296-1986-1-git-send-email-quic_charante@quicinc.com
    Signed-off-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Charan Teja Kalla authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    b1d99d4 View commit details
    Browse the repository at this point in the history
  31. arm64: dts: qcom: sm8250: don't enable rx/tx macro by default

    [ Upstream commit 18019eb ]
    
    Enabling rxmacro and txmacro nodes by defaults makes Qualcomm RB5 to
    crash and reboot while probing audio devices. Disable these device tree
    nodes by default and enabled them only when necessary (for the
    SM8250-MTP board).
    
    Fixes: 24f52ef ("arm64: dts: qcom: sm8250: Add nodes for tx and rx macros with soundwire masters")
    Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
    Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
    Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
    Link: https://lore.kernel.org/r/20220401185814.519653-1-dmitry.baryshkov@linaro.org
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    lumag authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    29a7a77 View commit details
    Browse the repository at this point in the history
  32. ARM: dts: aspeed-g6: remove FWQSPID group in pinctrl dtsi

    [ Upstream commit efddaa3 ]
    
    FWSPIDQ2 and FWSPIDQ3 are not part of FWSPI18 interface so remove
    FWQSPID group in pinctrl dtsi. These pins must be used with the
    FWSPI pins that are dedicated for boot SPI interface which provides
    same 3.3v logic level.
    
    Fixes: 2f6edb6 ("ARM: dts: aspeed: Fix AST2600 quad spi group")
    Signed-off-by: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
    Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
    Link: https://lore.kernel.org/r/20220329173932.2588289-2-quic_jaehyoo@quicinc.com
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    jaehyoo authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    7926d35 View commit details
    Browse the repository at this point in the history
  33. pinctrl: pinctrl-aspeed-g6: remove FWQSPID group in pinctrl

    [ Upstream commit 3eef2f4 ]
    
    FWSPIDQ2 and FWSPIDQ3 are not part of FWSPI18 interface so remove
    FWQSPID group in pinctrl. These pins must be used with the FWSPI
    pins that are dedicated for boot SPI interface which provides
    same 3.3v logic level.
    
    Fixes: 2eda1cd ("pinctrl: aspeed: Add AST2600 pinmux support")
    Signed-off-by: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
    Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
    Link: https://lore.kernel.org/r/20220329173932.2588289-3-quic_jaehyoo@quicinc.com
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    jaehyoo authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    34fdbc8 View commit details
    Browse the repository at this point in the history
  34. ARM: dts: aspeed-g6: fix SPI1/SPI2 quad pin group

    [ Upstream commit 890362d ]
    
    Fix incorrect function mappings in pinctrl_qspi1_default and
    pinctrl_qspi2_default since their function should be SPI1 and
    SPI2 respectively.
    
    Fixes: f510f04 ("ARM: dts: aspeed: Add AST2600 pinmux nodes")
    Signed-off-by: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
    Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
    Link: https://lore.kernel.org/r/20220329173932.2588289-8-quic_jaehyoo@quicinc.com
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    jaehyoo authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    a569568 View commit details
    Browse the repository at this point in the history
  35. ARM: dts: aspeed: Add video engine to g6

    [ Upstream commit 32e62d1 ]
    
    This node was accidentally removed by commit 645afe7 ("ARM: dts:
    aspeed: ast2600: Update XDMA engine node").
    
    Fixes: 645afe7 ("ARM: dts: aspeed: ast2600: Update XDMA engine node")
    Signed-off-by: Howard Chiu <howard_chiu@aspeedtech.com>
    Link: https://lore.kernel.org/r/SG2PR06MB2315C57600A0132FEF40F21EE61E9@SG2PR06MB2315.apcprd06.prod.outlook.com
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Howard Chiu authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    f81af67 View commit details
    Browse the repository at this point in the history
  36. pinctrl: ocelot: Fix for lan966x alt mode

    [ Upstream commit d3683ee ]
    
    For lan966x, the GPIO 35 has the wrong function for alternate mode 2.
    The mode is not none but is PTP sync.
    
    Fixes: 531d6ab ("pinctrl: ocelot: Extend support for lan966x")
    Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
    Reviewed-by: Kavyasree Kotagiri <kavyasree.kotagiri@microchip.com>
    Link: https://lore.kernel.org/r/20220413192918.3777234-1-horatiu.vultur@microchip.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    HoratiuVultur authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    df0dda7 View commit details
    Browse the repository at this point in the history
  37. pinctrl: mediatek: mt8365: fix IES control pins

    [ Upstream commit f680058 ]
    
    IES26 (BIT 16 of IES1_CFG_ADDR) controls the following pads:
    
    - PAD_I2S_DATA_IN (GPIO114)
    - PAD_I2S_LRCK (GPIO115)
    - PAD_I2S_BCK (GPIO116)
    
    The pinctrl table is wrong since it lists pins 114 to 112.
    
    Update the table with the correct values.
    
    Fixes: e94d8b6 ("pinctrl: mediatek: add support for mt8365 SoC")
    Reported-by: Youngmin Han <Youngmin.Han@geappliances.com>
    Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
    Link: https://lore.kernel.org/r/20220426125714.298907-1-mkorpershoek@baylibre.com
    Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    makohoek authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    0fe351f View commit details
    Browse the repository at this point in the history
  38. ALSA: hda - fix unused Realtek function when PM is not enabled

    [ Upstream commit c3d9ca9 ]
    
    When CONFIG_PM is not enabled, alc_shutup() is not needed,
    so move it inside the #ifdef CONFIG_PM guard.
    Also drop some contiguous #endif / #ifdef CONFIG_PM for simplicity.
    
    Fixes this build warning:
    sound/pci/hda/patch_realtek.c:886:20: warning: unused function 'alc_shutup'
    
    Fixes: 08c189f ("ALSA: hda - Use generic parser codes for Realtek driver")
    Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
    Reported-by: kernel test robot <lkp@intel.com>
    Link: https://lore.kernel.org/r/20220430193318.29024-1-rdunlap@infradead.org
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    rddunlap authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    ff0091f View commit details
    Browse the repository at this point in the history
  39. net: ipa: certain dropped packets aren't accounted for

    [ Upstream commit 30b338f ]
    
    If an RX endpoint receives packets containing status headers, and a
    packet in the buffer is not dropped, ipa_endpoint_skb_copy() is
    responsible for wrapping the packet data in an SKB and forwarding it
    to ipa_modem_skb_rx() for further processing.
    
    If ipa_endpoint_skb_copy() gets a null pointer from build_skb(), it
    just returns early.  But in the process it doesn't record that as a
    dropped packet in the network device statistics.
    
    Instead, call ipa_modem_skb_rx() whether or not the SKB pointer is
    NULL; that function ensures the statistics are properly updated.
    
    Fixes: 1b65bbc ("net: ipa: skip SKB copy if no netdev")
    Signed-off-by: Alex Elder <elder@linaro.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Alex Elder authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    051d03b View commit details
    Browse the repository at this point in the history
  40. net: ipa: record proper RX transaction count

    [ Upstream commit d8290cb ]
    
    Each time we are notified that some number of transactions on an RX
    channel has completed, we record the number of bytes that have been
    transferred since the previous notification.  We also track the
    number of transactions completed, but that is not currently being
    calculated correctly; we're currently counting the number of such
    notifications, but each notification can represent many transaction
    completions.  Fix this.
    
    Fixes: 650d160 ("soc: qcom: ipa: the generic software interface")
    Signed-off-by: Alex Elder <elder@linaro.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Alex Elder authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    59b0004 View commit details
    Browse the repository at this point in the history
  41. block/mq-deadline: Set the fifo_time member also if inserting at head

    [ Upstream commit 725f22a ]
    
    Before commit 322cff7 the fifo_time member of requests on a dispatch
    list was not used. Commit 322cff7 introduces code that reads the
    fifo_time member of requests on dispatch lists. Hence this patch that sets
    the fifo_time member when adding a request to a dispatch list.
    
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: Ming Lei <ming.lei@redhat.com>
    Cc: Damien Le Moal <damien.lemoal@opensource.wdc.com>
    Fixes: 322cff7 ("block/mq-deadline: Prioritize high-priority requests")
    Signed-off-by: Bart Van Assche <bvanassche@acm.org>
    Link: https://lore.kernel.org/r/20220513171307.32564-1-bvanassche@acm.org
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    bvanassche authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    684e76f View commit details
    Browse the repository at this point in the history
  42. mptcp: fix subflow accounting on close

    [ Upstream commit 95d6865 ]
    
    If the PM closes a fully established MPJ subflow or the subflow
    creation errors out in it's early stage the subflows counter is
    not bumped accordingly.
    
    This change adds the missing accounting, additionally taking care
    of updating accordingly the 'accept_subflow' flag.
    
    Fixes: a88c9e4 ("mptcp: do not block subflows creation on errors")
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Paolo Abeni authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    ece3fb2 View commit details
    Browse the repository at this point in the history
  43. net: macb: Increment rx bd head after allocating skb and buffer

    [ Upstream commit 9500acc ]
    
    In gem_rx_refill rx_prepared_head is incremented at the beginning of
    the while loop preparing the skb and data buffers. If the skb or data
    buffer allocation fails, this BD will be unusable BDs until the head
    loops back to the same BD (and obviously buffer allocation succeeds).
    In the unlikely event that there's a string of allocation failures,
    there will be an equal number of unusable BDs and an inconsistent RX
    BD chain. Hence increment the head at the end of the while loop to be
    clean.
    
    Fixes: 4df9513 ("net/macb: change RX path for GEM")
    Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
    Signed-off-by: Michal Simek <michal.simek@xilinx.com>
    Signed-off-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com>
    Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Link: https://lore.kernel.org/r/20220512171900.32593-1-harini.katakam@xilinx.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    harini-katakam authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    e8e38d1 View commit details
    Browse the repository at this point in the history
  44. i915/guc/reset: Make __guc_reset_context aware of guilty engines

    [ Upstream commit 89e96d8 ]
    
    There are 2 ways an engine can get reset in i915 and the method of reset
    affects how KMD labels a context as guilty/innocent.
    
    (1) GuC initiated engine-reset: GuC resets a hung engine and notifies
    KMD. The context that hung on the engine is marked guilty and all other
    contexts are innocent. The innocent contexts are resubmitted.
    
    (2) GT based reset: When an engine heartbeat fails to tick, KMD
    initiates a gt/chip reset. All active contexts are marked as guilty and
    discarded.
    
    In order to correctly mark the contexts as guilty/innocent, pass a mask
    of engines that were reset to __guc_reset_context.
    
    Fixes: eb5e7da ("drm/i915/guc: Reset implementation for new GuC interface")
    Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
    Reviewed-by: Alan Previn <alan.previn.teres.alexis@intel.com>
    Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220426003045.3929439-1-umesh.nerlige.ramappa@intel.com
    (cherry picked from commit 303760a)
    Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    unerlige authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    7ab9881 View commit details
    Browse the repository at this point in the history
  45. xfrm: rework default policy structure

    [ Upstream commit b58b1f5 ]
    
    This is a follow up of commit f8d858e ("xfrm: make user policy API
    complete"). The goal is to align userland API to the internal structures.
    
    Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
    Reviewed-by:  Antony Antony <antony.antony@secunet.com>
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    NicolasDichtel authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    1242dd7 View commit details
    Browse the repository at this point in the history
  46. xfrm: fix "disable_policy" flag use when arriving from different devices

    [ Upstream commit e6175a2 ]
    
    In IPv4 setting the "disable_policy" flag on a device means no policy
    should be enforced for traffic originating from the device. This was
    implemented by seting the DST_NOPOLICY flag in the dst based on the
    originating device.
    
    However, dsts are cached in nexthops regardless of the originating
    devices, in which case, the DST_NOPOLICY flag value may be incorrect.
    
    Consider the following setup:
    
                         +------------------------------+
                         | ROUTER                       |
      +-------------+    | +-----------------+          |
      | ipsec src   |----|-|ipsec0           |          |
      +-------------+    | |disable_policy=0 |   +----+ |
                         | +-----------------+   |eth1|-|-----
      +-------------+    | +-----------------+   +----+ |
      | noipsec src |----|-|eth0             |          |
      +-------------+    | |disable_policy=1 |          |
                         | +-----------------+          |
                         +------------------------------+
    
    Where ROUTER has a default route towards eth1.
    
    dst entries for traffic arriving from eth0 would have DST_NOPOLICY
    and would be cached and therefore can be reused by traffic originating
    from ipsec0, skipping policy check.
    
    Fix by setting a IPSKB_NOPOLICY flag in IPCB and observing it instead
    of the DST in IN/FWD IPv4 policy checks.
    
    Fixes: 1da177e ("Linux-2.6.12-rc2")
    Reported-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>
    Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ebirger authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    bfc4354 View commit details
    Browse the repository at this point in the history
  47. net/sched: act_pedit: sanitize shift argument before usage

    [ Upstream commit 4d42d54 ]
    
    syzbot was able to trigger an Out-of-Bound on the pedit action:
    
    UBSAN: shift-out-of-bounds in net/sched/act_pedit.c:238:43
    shift exponent 1400735974 is too large for 32-bit type 'unsigned int'
    CPU: 0 PID: 3606 Comm: syz-executor151 Not tainted 5.18.0-rc5-syzkaller-00165-g810c2f0a3f86 #0
    Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
    Call Trace:
     <TASK>
     __dump_stack lib/dump_stack.c:88 [inline]
     dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
     ubsan_epilogue+0xb/0x50 lib/ubsan.c:151
     __ubsan_handle_shift_out_of_bounds.cold+0xb1/0x187 lib/ubsan.c:322
     tcf_pedit_init.cold+0x1a/0x1f net/sched/act_pedit.c:238
     tcf_action_init_1+0x414/0x690 net/sched/act_api.c:1367
     tcf_action_init+0x530/0x8d0 net/sched/act_api.c:1432
     tcf_action_add+0xf9/0x480 net/sched/act_api.c:1956
     tc_ctl_action+0x346/0x470 net/sched/act_api.c:2015
     rtnetlink_rcv_msg+0x413/0xb80 net/core/rtnetlink.c:5993
     netlink_rcv_skb+0x153/0x420 net/netlink/af_netlink.c:2502
     netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
     netlink_unicast+0x543/0x7f0 net/netlink/af_netlink.c:1345
     netlink_sendmsg+0x904/0xe00 net/netlink/af_netlink.c:1921
     sock_sendmsg_nosec net/socket.c:705 [inline]
     sock_sendmsg+0xcf/0x120 net/socket.c:725
     ____sys_sendmsg+0x6e2/0x800 net/socket.c:2413
     ___sys_sendmsg+0xf3/0x170 net/socket.c:2467
     __sys_sendmsg+0xe5/0x1b0 net/socket.c:2496
     do_syscall_x64 arch/x86/entry/common.c:50 [inline]
     do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
     entry_SYSCALL_64_after_hwframe+0x44/0xae
    RIP: 0033:0x7fe36e9e1b59
    Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
    RSP: 002b:00007ffef796fe88 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
    RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fe36e9e1b59
    RDX: 0000000000000000 RSI: 0000000020000300 RDI: 0000000000000003
    RBP: 00007fe36e9a5d00 R08: 0000000000000000 R09: 0000000000000000
    R10: 0000000000000000 R11: 0000000000000246 R12: 00007fe36e9a5d90
    R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
     </TASK>
    
    The 'shift' field is not validated, and any value above 31 will
    trigger out-of-bounds. The issue predates the git history, but
    syzbot was able to trigger it only after the commit mentioned in
    the fixes tag, and this change only applies on top of such commit.
    
    Address the issue bounding the 'shift' value to the maximum allowed
    by the relevant operator.
    
    Reported-and-tested-by: syzbot+8ed8fc4c57e9dcf23ca6@syzkaller.appspotmail.com
    Fixes: 8b79647 ("net/sched: act_pedit: really ensure the skb is writable")
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Paolo Abeni authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    de9e451 View commit details
    Browse the repository at this point in the history
  48. netfilter: flowtable: fix excessive hw offload attempts after failure

    [ Upstream commit 396ef64 ]
    
    If a flow cannot be offloaded, the code currently repeatedly tries again as
    quickly as possible, which can significantly increase system load.
    Fix this by limiting flow timeout update and hardware offload retry to once
    per second.
    
    Fixes: c07531c ("netfilter: flowtable: Remove redundant hw refresh bit")
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    nbd168 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    d32782c View commit details
    Browse the repository at this point in the history
  49. netfilter: nft_flow_offload: skip dst neigh lookup for ppp devices

    [ Upstream commit 45ca3e6 ]
    
    The dst entry does not contain a valid hardware address, so skip the lookup
    in order to avoid running into errors here.
    The proper hardware address is filled in from nft_dev_path_info
    
    Fixes: 72efd58 ("netfilter: flowtable: add pppoe support")
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    nbd168 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    64e7b7f View commit details
    Browse the repository at this point in the history
  50. net: fix dev_fill_forward_path with pppoe + bridge

    [ Upstream commit cf2df74 ]
    
    When calling dev_fill_forward_path on a pppoe device, the provided destination
    address is invalid. In order for the bridge fdb lookup to succeed, the pppoe
    code needs to update ctx->daddr to the correct value.
    Fix this by storing the address inside struct net_device_path_ctx
    
    Fixes: f6efc67 ("net: ppp: resolve forwarding path for bridge pppoe devices")
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    nbd168 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    4f988f4 View commit details
    Browse the repository at this point in the history
  51. netfilter: nft_flow_offload: fix offload with pppoe + vlan

    [ Upstream commit 2456074 ]
    
    When running a combination of PPPoE on top of a VLAN, we need to set
    info->outdev to the PPPoE device, otherwise PPPoE encap is skipped
    during software offload.
    
    Fixes: 72efd58 ("netfilter: flowtable: add pppoe support")
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    nbd168 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    fe5e322 View commit details
    Browse the repository at this point in the history
  52. ptp: ocp: have adjtime handle negative delta_ns correctly

    [ Upstream commit da2172a ]
    
    delta_ns is a s64, but it was being passed ptp_ocp_adjtime_coarse
    as an u64.  Also, it turns out that timespec64_add_ns() only handles
    positive values, so perform the math with set_normalized_timespec().
    
    Fixes: 90f8f4c ("ptp: ocp: Add ptp_ocp_adjtime_coarse for large adjustments")
    Suggested-by: Vadim Fedorenko <vfedorenko@novek.ru>
    Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
    Acked-by: Vadim Fedorenko <vfedorenko@novek.ru>
    Link: https://lore.kernel.org/r/20220513225231.1412-1-jonathan.lemon@gmail.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    jlemon authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    b7429f8 View commit details
    Browse the repository at this point in the history
  53. Revert "PCI: aardvark: Rewrite IRQ code to chained IRQ handler"

    [ Upstream commit a3b69dd ]
    
    This reverts commit 1571d67.
    
    This commit broke support for setting interrupt affinity. It looks like
    that it is related to the chained IRQ handler. Revert this commit until
    issue with setting interrupt affinity is fixed.
    
    Fixes: 1571d67 ("PCI: aardvark: Rewrite IRQ code to chained IRQ handler")
    Link: https://lore.kernel.org/r/20220515125815.30157-1-pali@kernel.org
    Signed-off-by: Pali Rohár <pali@kernel.org>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    pali authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    9e2b163 View commit details
    Browse the repository at this point in the history
  54. net: lan966x: Fix assignment of the MAC address

    [ Upstream commit af8ca6e ]
    
    The following two scenarios were failing for lan966x.
    1. If the port had the address X and then trying to assign the same
       address, then the HW was just removing this address because first it
       tries to learn new address and then delete the old one. As they are
       the same the HW remove it.
    2. If the port eth0 was assigned the same address as one of the other
       ports eth1 then when assigning back the address to eth0 then the HW
       was deleting the address of eth1.
    
    The case 1. is fixed by checking if the port has already the same
    address while case 2. is fixed by checking if the address is used by any
    other port.
    
    Fixes: e18aba8 ("net: lan966x: add mactable support")
    Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
    Link: https://lore.kernel.org/r/20220513180030.3076793-1-horatiu.vultur@microchip.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    HoratiuVultur authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    fb1d861 View commit details
    Browse the repository at this point in the history
  55. net: systemport: Fix an error handling path in bcm_sysport_probe()

    [ Upstream commit ef6b1cd ]
    
    if devm_clk_get_optional() fails, we still need to go through the error
    handling path.
    
    Add the missing goto.
    
    Fixes: 6328a12 ("net: systemport: Manage Wake-on-LAN clock")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Acked-by: Florian Fainelli <f.fainelli@gmail.com>
    Link: https://lore.kernel.org/r/99d70634a81c229885ae9e4ee69b2035749f7edc.1652634040.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    tititiou36 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    c281eee View commit details
    Browse the repository at this point in the history
  56. net: vmxnet3: fix possible use-after-free bugs in vmxnet3_rq_alloc_rx…

    …_buf()
    
    [ Upstream commit 9e7fef9 ]
    
    In vmxnet3_rq_alloc_rx_buf(), when dma_map_single() fails, rbi->skb is
    freed immediately. Similarly, in another branch, when dma_map_page() fails,
    rbi->page is also freed. In the two cases, vmxnet3_rq_alloc_rx_buf()
    returns an error to its callers vmxnet3_rq_init() -> vmxnet3_rq_init_all()
    -> vmxnet3_activate_dev(). Then vmxnet3_activate_dev() calls
    vmxnet3_rq_cleanup_all() in error handling code, and rbi->skb or rbi->page
    are freed again in vmxnet3_rq_cleanup_all(), causing use-after-free bugs.
    
    To fix these possible bugs, rbi->skb and rbi->page should be cleared after
    they are freed.
    
    The error log in our fault-injection testing is shown as follows:
    
    [   14.319016] BUG: KASAN: use-after-free in consume_skb+0x2f/0x150
    ...
    [   14.321586] Call Trace:
    ...
    [   14.325357]  consume_skb+0x2f/0x150
    [   14.325671]  vmxnet3_rq_cleanup_all+0x33a/0x4e0 [vmxnet3]
    [   14.326150]  vmxnet3_activate_dev+0xb9d/0x2ca0 [vmxnet3]
    [   14.326616]  vmxnet3_open+0x387/0x470 [vmxnet3]
    ...
    [   14.361675] Allocated by task 351:
    ...
    [   14.362688]  __netdev_alloc_skb+0x1b3/0x6f0
    [   14.362960]  vmxnet3_rq_alloc_rx_buf+0x1b0/0x8d0 [vmxnet3]
    [   14.363317]  vmxnet3_activate_dev+0x3e3/0x2ca0 [vmxnet3]
    [   14.363661]  vmxnet3_open+0x387/0x470 [vmxnet3]
    ...
    [   14.367309]
    [   14.367412] Freed by task 351:
    ...
    [   14.368932]  __dev_kfree_skb_any+0xd2/0xe0
    [   14.369193]  vmxnet3_rq_alloc_rx_buf+0x71e/0x8d0 [vmxnet3]
    [   14.369544]  vmxnet3_activate_dev+0x3e3/0x2ca0 [vmxnet3]
    [   14.369883]  vmxnet3_open+0x387/0x470 [vmxnet3]
    [   14.370174]  __dev_open+0x28a/0x420
    [   14.370399]  __dev_change_flags+0x192/0x590
    [   14.370667]  dev_change_flags+0x7a/0x180
    [   14.370919]  do_setlink+0xb28/0x3570
    [   14.371150]  rtnl_newlink+0x1160/0x1740
    [   14.371399]  rtnetlink_rcv_msg+0x5bf/0xa50
    [   14.371661]  netlink_rcv_skb+0x1cd/0x3e0
    [   14.371913]  netlink_unicast+0x5dc/0x840
    [   14.372169]  netlink_sendmsg+0x856/0xc40
    [   14.372420]  ____sys_sendmsg+0x8a7/0x8d0
    [   14.372673]  __sys_sendmsg+0x1c2/0x270
    [   14.372914]  do_syscall_64+0x41/0x90
    [   14.373145]  entry_SYSCALL_64_after_hwframe+0x44/0xae
    ...
    
    Fixes: 5738a09 ("vmxnet3: fix checks for dma mapping errors")
    Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
    Signed-off-by: Zixuan Fu <r33s3n6@gmail.com>
    Link: https://lore.kernel.org/r/20220514050656.2636588-1-r33s3n6@gmail.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    r33s3n6 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    54f87f3 View commit details
    Browse the repository at this point in the history
  57. net: vmxnet3: fix possible NULL pointer dereference in vmxnet3_rq_cle…

    …anup()
    
    [ Upstream commit edf410c ]
    
    In vmxnet3_rq_create(), when dma_alloc_coherent() fails,
    vmxnet3_rq_destroy() is called. It sets rq->rx_ring[i].base to NULL. Then
    vmxnet3_rq_create() returns an error to its callers mxnet3_rq_create_all()
    -> vmxnet3_change_mtu(). Then vmxnet3_change_mtu() calls
    vmxnet3_force_close() -> dev_close() in error handling code. And the driver
    calls vmxnet3_close() -> vmxnet3_quiesce_dev() -> vmxnet3_rq_cleanup_all()
    -> vmxnet3_rq_cleanup(). In vmxnet3_rq_cleanup(),
    rq->rx_ring[ring_idx].base is accessed, but this variable is NULL, causing
    a NULL pointer dereference.
    
    To fix this possible bug, an if statement is added to check whether
    rq->rx_ring[0].base is NULL in vmxnet3_rq_cleanup() and exit early if so.
    
    The error log in our fault-injection testing is shown as follows:
    
    [   65.220135] BUG: kernel NULL pointer dereference, address: 0000000000000008
    ...
    [   65.222633] RIP: 0010:vmxnet3_rq_cleanup_all+0x396/0x4e0 [vmxnet3]
    ...
    [   65.227977] Call Trace:
    ...
    [   65.228262]  vmxnet3_quiesce_dev+0x80f/0x8a0 [vmxnet3]
    [   65.228580]  vmxnet3_close+0x2c4/0x3f0 [vmxnet3]
    [   65.228866]  __dev_close_many+0x288/0x350
    [   65.229607]  dev_close_many+0xa4/0x480
    [   65.231124]  dev_close+0x138/0x230
    [   65.231933]  vmxnet3_force_close+0x1f0/0x240 [vmxnet3]
    [   65.232248]  vmxnet3_change_mtu+0x75d/0x920 [vmxnet3]
    ...
    
    Fixes: d1a890f ("net: VMware virtual Ethernet NIC driver: vmxnet3")
    Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
    Signed-off-by: Zixuan Fu <r33s3n6@gmail.com>
    Link: https://lore.kernel.org/r/20220514050711.2636709-1-r33s3n6@gmail.com
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    r33s3n6 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    8d20af6 View commit details
    Browse the repository at this point in the history
  58. arm64: kexec: load from kimage prior to clobbering

    [ Upstream commit eb3d8ea ]
    
    In arm64_relocate_new_kernel() we load some fields out of the kimage
    structure after relocation has occurred. As the kimage structure isn't
    allocated to be relocation-safe, it may be clobbered during relocation,
    and we may load junk values out of the structure.
    
    Due to this, kexec may fail when the kimage allocation happens to fall
    within a PA range that an object will be relocated to. This has been
    observed to occur for regular kexec on a QEMU TCG 'virt' machine with
    2GiB of RAM, where the PA range of the new kernel image overlaps the
    kimage structure.
    
    Avoid this by ensuring we load all values from the kimage structure
    prior to relocation.
    
    I've tested this atop v5.16 and v5.18-rc6.
    
    Fixes: 878fdbd ("arm64: kexec: pass kimage as the only argument to relocation function")
    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: James Morse <james.morse@arm.com>
    Cc: Pasha Tatashin <pasha.tatashin@soleen.com>
    Cc: Will Deacon <will@kernel.org>
    Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
    Link: https://lore.kernel.org/r/20220516160735.731404-1-mark.rutland@arm.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Mark Rutland authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    3f09159 View commit details
    Browse the repository at this point in the history
  59. ice: fix crash when writing timestamp on RX rings

    [ Upstream commit 4503cc7 ]
    
    Do not allow to write timestamps on RX rings if PF is being configured.
    When PF is being configured RX rings can be freed or rebuilt. If at the
    same time timestamps are updated, the kernel will crash by dereferencing
    null RX ring pointer.
    
    PID: 1449   TASK: ff187d28ed658040  CPU: 34  COMMAND: "ice-ptp-0000:51"
     #0 [ff1966a94a713bb0] machine_kexec at ffffffff9d05a0be
     #1 [ff1966a94a713c08] __crash_kexec at ffffffff9d192e9d
     #2 [ff1966a94a713cd0] crash_kexec at ffffffff9d1941bd
     #3 [ff1966a94a713ce8] oops_end at ffffffff9d01bd54
     #4 [ff1966a94a713d08] no_context at ffffffff9d06bda4
     #5 [ff1966a94a713d60] __bad_area_nosemaphore at ffffffff9d06c10c
     #6 [ff1966a94a713da8] do_page_fault at ffffffff9d06cae4
     #7 [ff1966a94a713de0] page_fault at ffffffff9da0107e
        [exception RIP: ice_ptp_update_cached_phctime+91]
        RIP: ffffffffc076db8b  RSP: ff1966a94a713e98  RFLAGS: 00010246
        RAX: 16e3db9c6b7ccae4  RBX: ff187d269dd3c180  RCX: ff187d269cd4d018
        RDX: 0000000000000000  RSI: 0000000000000000  RDI: 0000000000000000
        RBP: ff187d269cfcc644   R8: ff187d339b9641b0   R9: 0000000000000000
        R10: 0000000000000002  R11: 0000000000000000  R12: ff187d269cfcc648
        R13: ffffffff9f128784  R14: ffffffff9d101b70  R15: ff187d269cfcc640
        ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
     #8 [ff1966a94a713ea0] ice_ptp_periodic_work at ffffffffc076dbef [ice]
     #9 [ff1966a94a713ee0] kthread_worker_fn at ffffffff9d101c1b
     #10 [ff1966a94a713f10] kthread at ffffffff9d101b4d
     #11 [ff1966a94a713f50] ret_from_fork at ffffffff9da0023f
    
    Fixes: 77a7811 ("ice: enable receive hardware timestamping")
    Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
    Reviewed-by: Michal Schmidt <mschmidt@redhat.com>
    Tested-by: Dave Cain <dcain@redhat.com>
    Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    kubalewski authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    e835098 View commit details
    Browse the repository at this point in the history
  60. ice: fix possible under reporting of ethtool Tx and Rx statistics

    [ Upstream commit 31b6298 ]
    
    The hardware statistics counters are not cleared during resets so the
    drivers first access is to initialize the baseline and then subsequent
    reads are for reporting the counters. The statistics counters are read
    during the watchdog subtask when the interface is up. If the baseline
    is not initialized before the interface is up, then there can be a brief
    window in which some traffic can be transmitted/received before the
    initial baseline reading takes place.
    
    Directly initialize ethtool statistics in driver open so the baseline will
    be initialized when the interface is up, and any dropped packets
    incremented before the interface is up won't be reported.
    
    Fixes: 28dc1b8 ("ice: ignore dropped packets during init")
    Signed-off-by: Paul Greenwalt <paul.greenwalt@intel.com>
    Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    pgreenwa authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    e495276 View commit details
    Browse the repository at this point in the history
  61. ice: Fix interrupt moderation settings getting cleared

    [ Upstream commit bf13502 ]
    
    Adaptive-rx and Adaptive-tx are interrupt moderation settings
    that can be enabled/disabled using ethtool:
    ethtool -C ethX adaptive-rx on/off adaptive-tx on/off
    
    Unfortunately those settings are getting cleared after
    changing number of queues, or in ethtool world 'channels':
    ethtool -L ethX rx 1 tx 1
    
    Clearing was happening due to introduction of bit fields
    in ice_ring_container struct. This way only itr_setting
    bits were rebuilt during ice_vsi_rebuild_set_coalesce().
    
    Introduce an anonymous struct of bitfields and create a
    union to refer to them as a single variable.
    This way variable can be easily saved and restored.
    
    Fixes: 61dc79c ("ice: Restore interrupt throttle settings after VSI rebuild")
    Signed-off-by: Michal Wilczynski <michal.wilczynski@intel.com>
    Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    mwilczy authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    57adef8 View commit details
    Browse the repository at this point in the history
  62. clk: at91: generated: consider range when calculating best rate

    [ Upstream commit d0031e6 ]
    
    clk_generated_best_diff() helps in finding the parent and the divisor to
    compute a rate closest to the required one. However, it doesn't take into
    account the request's range for the new rate. Make sure the new rate
    is within the required range.
    
    Fixes: 8a8f4bf ("clk: at91: clk-generated: create function to find best_diff")
    Signed-off-by: Codrin Ciubotariu <codrin.ciubotariu@microchip.com>
    Link: https://lore.kernel.org/r/20220413071318.244912-1-codrin.ciubotariu@microchip.com
    Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
    Signed-off-by: Stephen Boyd <sboyd@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    codrin989 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    9644d40 View commit details
    Browse the repository at this point in the history
  63. net/qla3xxx: Fix a test in ql_reset_work()

    [ Upstream commit 5361448 ]
    
    test_bit() tests if one bit is set or not.
    Here the logic seems to check of bit QL_RESET_PER_SCSI (i.e. 4) OR bit
    QL_RESET_START (i.e. 3) is set.
    
    In fact, it checks if bit 7 (4 | 3 = 7) is set, that is to say
    QL_ADAPTER_UP.
    
    This looks harmless, because this bit is likely be set, and when the
    ql_reset_work() delayed work is scheduled in ql3xxx_isr() (the only place
    that schedule this work), QL_RESET_START or QL_RESET_PER_SCSI is set.
    
    This has been spotted by smatch.
    
    Fixes: 5a4faa8 ("[PATCH] qla3xxx NIC driver")
    Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
    Link: https://lore.kernel.org/r/80e73e33f390001d9c0140ffa9baddf6466a41a2.1652637337.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    tititiou36 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    18a39a7 View commit details
    Browse the repository at this point in the history
  64. NFC: nci: fix sleep in atomic context bugs caused by nci_skb_alloc

    [ Upstream commit 23dd458 ]
    
    There are sleep in atomic context bugs when the request to secure
    element of st-nci is timeout. The root cause is that nci_skb_alloc
    with GFP_KERNEL parameter is called in st_nci_se_wt_timeout which is
    a timer handler. The call paths that could trigger bugs are shown below:
    
        (interrupt context 1)
    st_nci_se_wt_timeout
      nci_hci_send_event
        nci_hci_send_data
          nci_skb_alloc(..., GFP_KERNEL) //may sleep
    
       (interrupt context 2)
    st_nci_se_wt_timeout
      nci_hci_send_event
        nci_hci_send_data
          nci_send_data
            nci_queue_tx_data_frags
              nci_skb_alloc(..., GFP_KERNEL) //may sleep
    
    This patch changes allocation mode of nci_skb_alloc from GFP_KERNEL to
    GFP_ATOMIC in order to prevent atomic context sleeping. The GFP_ATOMIC
    flag makes memory allocation operation could be used in atomic context.
    
    Fixes: ed06aee ("nfc: st-nci: Rename st21nfcb to st-nci")
    Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
    Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
    Link: https://lore.kernel.org/r/20220517012530.75714-1-duoming@zju.edu.cn
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    stonezdm authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    1181818 View commit details
    Browse the repository at this point in the history
  65. net/mlx5: DR, Fix missing flow_source when creating multi-destination…

    … FW table
    
    [ Upstream commit 2c5fc6c ]
    
    In order to support multiple destination FTEs with SW steering
    FW table is created with single FTE with multiple actions and
    SW steering rule forward to it. When creating this table, flow
    source isn't set according to the original FTE.
    
    Fix this by passing the original FTE flow source to the created
    FW table.
    
    Fixes: 34583be ("net/mlx5: DR, Create multi-destination table for SW-steering use")
    Signed-off-by: Maor Dickman <maord@nvidia.com>
    Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    dickmanmaor authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    6cb0d86 View commit details
    Browse the repository at this point in the history
  66. net/mlx5: Initialize flow steering during driver probe

    [ Upstream commit b338869 ]
    
    Currently, software objects of flow steering are created and destroyed
    during reload flow. In case a device is unloaded, the following error
    is printed during grace period:
    
     mlx5_core 0000:00:0b.0: mlx5_fw_fatal_reporter_err_work:690:(pid 95):
        Driver is in error state. Unloading
    
    As a solution to fix use-after-free bugs, where we try to access
    these objects, when reading the value of flow_steering_mode devlink
    param[1], let's split flow steering creation and destruction into two
    routines:
        * init and cleanup: memory, cache, and pools allocation/free.
        * create and destroy: namespaces initialization and cleanup.
    
    While at it, re-order the cleanup function to mirror the init function.
    
    [1]
    Kasan trace:
    
    [  385.119849 ] BUG: KASAN: use-after-free in mlx5_devlink_fs_mode_get+0x3b/0xa0
    [  385.119849 ] Read of size 4 at addr ffff888104b79308 by task bash/291
    [  385.119849 ]
    [  385.119849 ] CPU: 1 PID: 291 Comm: bash Not tainted 5.17.0-rc1+ #2
    [  385.119849 ] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-2.fc32 04/01/2014
    [  385.119849 ] Call Trace:
    [  385.119849 ]  <TASK>
    [  385.119849 ]  dump_stack_lvl+0x6e/0x91
    [  385.119849 ]  print_address_description.constprop.0+0x1f/0x160
    [  385.119849 ]  ? mlx5_devlink_fs_mode_get+0x3b/0xa0
    [  385.119849 ]  ? mlx5_devlink_fs_mode_get+0x3b/0xa0
    [  385.119849 ]  kasan_report.cold+0x83/0xdf
    [  385.119849 ]  ? devlink_param_notify+0x20/0x190
    [  385.119849 ]  ? mlx5_devlink_fs_mode_get+0x3b/0xa0
    [  385.119849 ]  mlx5_devlink_fs_mode_get+0x3b/0xa0
    [  385.119849 ]  devlink_nl_param_fill+0x18a/0xa50
    [  385.119849 ]  ? _raw_spin_lock_irqsave+0x8d/0xe0
    [  385.119849 ]  ? devlink_flash_update_timeout_notify+0xf0/0xf0
    [  385.119849 ]  ? __wake_up_common+0x4b/0x1e0
    [  385.119849 ]  ? preempt_count_sub+0x14/0xc0
    [  385.119849 ]  ? _raw_spin_unlock_irqrestore+0x28/0x40
    [  385.119849 ]  ? __wake_up_common_lock+0xe3/0x140
    [  385.119849 ]  ? __wake_up_common+0x1e0/0x1e0
    [  385.119849 ]  ? __sanitizer_cov_trace_const_cmp8+0x27/0x80
    [  385.119849 ]  ? __rcu_read_unlock+0x48/0x70
    [  385.119849 ]  ? kasan_unpoison+0x23/0x50
    [  385.119849 ]  ? __kasan_slab_alloc+0x2c/0x80
    [  385.119849 ]  ? memset+0x20/0x40
    [  385.119849 ]  ? __sanitizer_cov_trace_const_cmp4+0x25/0x80
    [  385.119849 ]  devlink_param_notify+0xce/0x190
    [  385.119849 ]  devlink_unregister+0x92/0x2b0
    [  385.119849 ]  remove_one+0x41/0x140
    [  385.119849 ]  pci_device_remove+0x68/0x140
    [  385.119849 ]  ? pcibios_free_irq+0x10/0x10
    [  385.119849 ]  __device_release_driver+0x294/0x3f0
    [  385.119849 ]  device_driver_detach+0x82/0x130
    [  385.119849 ]  unbind_store+0x193/0x1b0
    [  385.119849 ]  ? subsys_interface_unregister+0x270/0x270
    [  385.119849 ]  drv_attr_store+0x4e/0x70
    [  385.119849 ]  ? drv_attr_show+0x60/0x60
    [  385.119849 ]  sysfs_kf_write+0xa7/0xc0
    [  385.119849 ]  kernfs_fop_write_iter+0x23a/0x2f0
    [  385.119849 ]  ? sysfs_kf_bin_read+0x160/0x160
    [  385.119849 ]  new_sync_write+0x311/0x430
    [  385.119849 ]  ? new_sync_read+0x480/0x480
    [  385.119849 ]  ? _raw_spin_lock+0x87/0xe0
    [  385.119849 ]  ? __sanitizer_cov_trace_cmp4+0x25/0x80
    [  385.119849 ]  ? security_file_permission+0x94/0xa0
    [  385.119849 ]  vfs_write+0x4c7/0x590
    [  385.119849 ]  ksys_write+0xf6/0x1e0
    [  385.119849 ]  ? __x64_sys_read+0x50/0x50
    [  385.119849 ]  ? fpregs_assert_state_consistent+0x99/0xa0
    [  385.119849 ]  do_syscall_64+0x3d/0x90
    [  385.119849 ]  entry_SYSCALL_64_after_hwframe+0x44/0xae
    [  385.119849 ] RIP: 0033:0x7fc36ef38504
    [  385.119849 ] Code: 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b3 0f 1f
    80 00 00 00 00 48 8d 05 f9 61 0d 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f
    05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 41 54 49 89 d4 55 48 89 f5 53
    [  385.119849 ] RSP: 002b:00007ffde0ff3d08 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
    [  385.119849 ] RAX: ffffffffffffffda RBX: 000000000000000c RCX: 00007fc36ef38504
    [  385.119849 ] RDX: 000000000000000c RSI: 00007fc370521040 RDI: 0000000000000001
    [  385.119849 ] RBP: 00007fc370521040 R08: 00007fc36f00b8c0 R09: 00007fc36ee4b740
    [  385.119849 ] R10: 0000000000000000 R11: 0000000000000246 R12: 00007fc36f00a760
    [  385.119849 ] R13: 000000000000000c R14: 00007fc36f005760 R15: 000000000000000c
    [  385.119849 ]  </TASK>
    [  385.119849 ]
    [  385.119849 ] Allocated by task 65:
    [  385.119849 ]  kasan_save_stack+0x1e/0x40
    [  385.119849 ]  __kasan_kmalloc+0x81/0xa0
    [  385.119849 ]  mlx5_init_fs+0x11b/0x1160
    [  385.119849 ]  mlx5_load+0x13c/0x220
    [  385.119849 ]  mlx5_load_one+0xda/0x160
    [  385.119849 ]  mlx5_recover_device+0xb8/0x100
    [  385.119849 ]  mlx5_health_try_recover+0x2f9/0x3a1
    [  385.119849 ]  devlink_health_reporter_recover+0x75/0x100
    [  385.119849 ]  devlink_health_report+0x26c/0x4b0
    [  385.275909 ]  mlx5_fw_fatal_reporter_err_work+0x11e/0x1b0
    [  385.275909 ]  process_one_work+0x520/0x970
    [  385.275909 ]  worker_thread+0x378/0x950
    [  385.275909 ]  kthread+0x1bb/0x200
    [  385.275909 ]  ret_from_fork+0x1f/0x30
    [  385.275909 ]
    [  385.275909 ] Freed by task 65:
    [  385.275909 ]  kasan_save_stack+0x1e/0x40
    [  385.275909 ]  kasan_set_track+0x21/0x30
    [  385.275909 ]  kasan_set_free_info+0x20/0x30
    [  385.275909 ]  __kasan_slab_free+0xfc/0x140
    [  385.275909 ]  kfree+0xa5/0x3b0
    [  385.275909 ]  mlx5_unload+0x2e/0xb0
    [  385.275909 ]  mlx5_unload_one+0x86/0xb0
    [  385.275909 ]  mlx5_fw_fatal_reporter_err_work.cold+0xca/0xcf
    [  385.275909 ]  process_one_work+0x520/0x970
    [  385.275909 ]  worker_thread+0x378/0x950
    [  385.275909 ]  kthread+0x1bb/0x200
    [  385.275909 ]  ret_from_fork+0x1f/0x30
    [  385.275909 ]
    [  385.275909 ] The buggy address belongs to the object at ffff888104b79300
    [  385.275909 ]  which belongs to the cache kmalloc-128 of size 128
    [  385.275909 ] The buggy address is located 8 bytes inside of
    [  385.275909 ]  128-byte region [ffff888104b79300, ffff888104b79380)
    [  385.275909 ] The buggy address belongs to the page:
    [  385.275909 ] page:00000000de44dd39 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x104b78
    [  385.275909 ] head:00000000de44dd39 order:1 compound_mapcount:0
    [  385.275909 ] flags: 0x8000000000010200(slab|head|zone=2)
    [  385.275909 ] raw: 8000000000010200 0000000000000000 dead000000000122 ffff8881000428c0
    [  385.275909 ] raw: 0000000000000000 0000000080200020 00000001ffffffff 0000000000000000
    [  385.275909 ] page dumped because: kasan: bad access detected
    [  385.275909 ]
    [  385.275909 ] Memory state around the buggy address:
    [  385.275909 ]  ffff888104b79200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc fc
    [  385.275909 ]  ffff888104b79280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
    [  385.275909 ] >ffff888104b79300: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    [  385.275909 ]                       ^
    [  385.275909 ]  ffff888104b79380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
    [  385.275909 ]  ffff888104b79400: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
    [  385.275909 ]]
    
    Fixes: e890acd ("net/mlx5: Add devlink flow_steering_mode parameter")
    Signed-off-by: Shay Drory <shayd@nvidia.com>
    Reviewed-by: Mark Bloch <mbloch@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    shayshyi authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    5fa45f0 View commit details
    Browse the repository at this point in the history
  67. net/mlx5: DR, Ignore modify TTL on RX if device doesn't support it

    [ Upstream commit 785d7ed ]
    
    When modifying TTL, packet's csum has to be recalculated.
    Due to HW issue in ConnectX-5, csum recalculation for modify
    TTL on RX is supported through a work-around that is specifically
    enabled by configuration.
    If the work-around isn't enabled, rather than adding an unsupported
    action the modify TTL action on RX should be ignored.
    Ignoring modify TTL action might result in zero actions, so in such
    cases we will not convert the match STE to modify STE, as it is done
    by FW in DMFS.
    
    This patch fixes an issue where modify TTL action was ignored both
    on RX and TX instead of only on RX.
    
    Fixes: 4ff725e ("net/mlx5: DR, Ignore modify TTL if device doesn't support it")
    Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
    Reviewed-by: Alex Vesker <valex@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    kliteyn authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    68417b2 View commit details
    Browse the repository at this point in the history
  68. net/mlx5e: Block rx-gro-hw feature in switchdev mode

    [ Upstream commit 15a5078 ]
    
    When the driver is in switchdev mode and rx-gro-hw is set, the RQ needs
    special CQE handling. Till then, block setting of rx-gro-hw feature in
    switchdev mode, to avoid failure while setting the feature due to
    failure while opening the RQ.
    
    Fixes: f97d5c2 ("net/mlx5e: Add handle SHAMPO cqe support")
    Signed-off-by: Aya Levin <ayal@nvidia.com>
    Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ayalevin authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    eb82d4a View commit details
    Browse the repository at this point in the history
  69. net/mlx5e: Properly block LRO when XDP is enabled

    [ Upstream commit cf6e34c ]
    
    LRO is incompatible and mutually exclusive with XDP. However, the needed
    checks are only made when enabling XDP. If LRO is enabled when XDP is
    already active, the command will succeed, and XDP will be skipped in the
    data path, although still enabled.
    
    This commit fixes the bug by checking the XDP status in
    mlx5e_fix_features and disabling LRO if XDP is enabled.
    
    Fixes: 8699415 ("net/mlx5e: XDP fast RX drop bpf programs support")
    Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
    Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    nvmmax authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    26a2857 View commit details
    Browse the repository at this point in the history
  70. net/mlx5e: Properly block HW GRO when XDP is enabled

    [ Upstream commit b0617e7 ]
    
    HW GRO is incompatible and mutually exclusive with XDP and XSK. However,
    the needed checks are only made when enabling XDP. If HW GRO is enabled
    when XDP is already active, the command will succeed, and XDP will be
    skipped in the data path, although still enabled.
    
    This commit fixes the bug by checking the XDP and XSK status in
    mlx5e_fix_features and disabling HW GRO if XDP is enabled.
    
    Fixes: 83439f3 ("net/mlx5e: Add HW-GRO offload")
    Signed-off-by: Maxim Mikityanskiy <maximmi@nvidia.com>
    Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    nvmmax authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    d5f797d View commit details
    Browse the repository at this point in the history
  71. net/mlx5e: Remove HW-GRO from reported features

    [ Upstream commit 6bbd723 ]
    
    We got reports of certain HW-GRO flows causing kernel call traces, which
    might be related to firmware. To be on the safe side, disable the
    feature for now and re-enable it once a driver/firmware fix is found.
    
    Fixes: 83439f3 ("net/mlx5e: Add HW-GRO offload")
    Signed-off-by: Gal Pressman <gal@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    gal-pressman authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    aeac4b6 View commit details
    Browse the repository at this point in the history
  72. net/mlx5: Drain fw_reset when removing device

    [ Upstream commit 16d42d3 ]
    
    In case fw sync reset is called in parallel to device removal, device
    might stuck in the following deadlock:
             CPU 0                        CPU 1
             -----                        -----
                                      remove_one
                                       uninit_one (locks intf_state_mutex)
    mlx5_sync_reset_now_event()
    work in fw_reset->wq.
     mlx5_enter_error_state()
      mutex_lock (intf_state_mutex)
                                       cleanup_once
                                        fw_reset_cleanup()
                                         destroy_workqueue(fw_reset->wq)
    
    Drain the fw_reset WQ, and make sure no new work is being queued, before
    entering uninit_one().
    The Drain is done before devlink_unregister() since fw_reset, in some
    flows, is using devlink API devlink_remote_reload_actions_performed().
    
    Fixes: 38b9f90 ("net/mlx5: Handle sync reset request event")
    Signed-off-by: Shay Drory <shayd@nvidia.com>
    Reviewed-by: Moshe Shemesh <moshe@nvidia.com>
    Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    shayshyi authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    4f86b7f View commit details
    Browse the repository at this point in the history
  73. net: af_key: add check for pfkey_broadcast in function pfkey_process

    [ Upstream commit 4dc2a5a ]
    
    If skb_clone() returns null pointer, pfkey_broadcast() will
    return error.
    Therefore, it should be better to check the return value of
    pfkey_broadcast() and return error if fails.
    
    Fixes: 1da177e ("Linux-2.6.12-rc2")
    Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
    Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    JiangJias authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    853c351 View commit details
    Browse the repository at this point in the history
  74. ARM: 9196/1: spectre-bhb: enable for Cortex-A15

    [ Upstream commit 0dc14aa ]
    
    The Spectre-BHB mitigations were inadvertently left disabled for
    Cortex-A15, due to the fact that cpu_v7_bugs_init() is not called in
    that case. So fix that.
    
    Fixes: b9baf5c ("ARM: Spectre-BHB workaround")
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ardbiesheuvel authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    6db9764 View commit details
    Browse the repository at this point in the history
  75. ARM: 9197/1: spectre-bhb: fix loop8 sequence for Thumb2

    [ Upstream commit 3cfb301 ]
    
    In Thumb2, 'b . + 4' produces a branch instruction that uses a narrow
    encoding, and so it does not jump to the following instruction as
    expected. So use W(b) instead.
    
    Fixes: 6c7cb60 ("ARM: fix Thumb2 regression with Spectre BHB")
    Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ardbiesheuvel authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    dbe6b6a View commit details
    Browse the repository at this point in the history
  76. lockdown: also lock down previous kgdb use

    commit eadb2f4 upstream.
    
    KGDB and KDB allow read and write access to kernel memory, and thus
    should be restricted during lockdown.  An attacker with access to a
    serial port (for example, via a hypervisor console, which some cloud
    vendors provide over the network) could trigger the debugger so it is
    important that the debugger respect the lockdown mode when/if it is
    triggered.
    
    Fix this by integrating lockdown into kdb's existing permissions
    mechanism.  Unfortunately kgdb does not have any permissions mechanism
    (although it certainly could be added later) so, for now, kgdb is simply
    and brutally disabled by immediately exiting the gdb stub without taking
    any action.
    
    For lockdowns established early in the boot (e.g. the normal case) then
    this should be fine but on systems where kgdb has set breakpoints before
    the lockdown is enacted than "bad things" will happen.
    
    CVE: CVE-2022-21499
    Co-developed-by: Stephen Brennan <stephen.s.brennan@oracle.com>
    Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
    Reviewed-by: Douglas Anderson <dianders@chromium.org>
    Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    daniel-thompson authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    281d356 View commit details
    Browse the repository at this point in the history
  77. mptcp: fix checksum byte order

    [ Upstream commit ba2c89e ]
    
    The MPTCP code typecasts the checksum value to u16 and
    then converts it to big endian while storing the value into
    the MPTCP option.
    
    As a result, the wire encoding for little endian host is
    wrong, and that causes interoperabilty interoperability
    issues with other implementation or host with different endianness.
    
    Address the issue writing in the packet the unmodified __sum16 value.
    
    MPTCP checksum is disabled by default, interoperating with systems
    with bad mptcp-level csum encoding should cause fallback to TCP.
    
    Closes: multipath-tcp/mptcp_net-next#275
    Fixes: c5b39e2 ("mptcp: send out checksum for DSS")
    Fixes: 390b95a ("mptcp: receive checksum for DSS")
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Paolo Abeni authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    d2b6745 View commit details
    Browse the repository at this point in the history
  78. igb: skip phy status check where unavailable

    [ Upstream commit 942d2ad ]
    
    igb_read_phy_reg() will silently return, leaving phy_data untouched, if
    hw->ops.read_reg isn't set. Depending on the uninitialized value of
    phy_data, this led to the phy status check either succeeding immediately
    or looping continuously for 2 seconds before emitting a noisy err-level
    timeout. This message went out to the console even though there was no
    actual problem.
    
    Instead, first check if there is read_reg function pointer. If not,
    proceed without trying to check the phy status register.
    
    Fixes: b72f3f7 ("igb: When GbE link up, wait for Remote receiver status condition")
    Signed-off-by: Kevin Mitchell <kevmitch@arista.com>
    Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
    Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    arkevmitch authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    05e19b3 View commit details
    Browse the repository at this point in the history
  79. netfilter: flowtable: fix TCP flow teardown

    [ Upstream commit e5eaac2 ]
    
    This patch addresses three possible problems:
    
    1. ct gc may race to undo the timeout adjustment of the packet path, leaving
       the conntrack entry in place with the internal offload timeout (one day).
    
    2. ct gc removes the ct because the IPS_OFFLOAD_BIT is not set and the CLOSE
       timeout is reached before the flow offload del.
    
    3. tcp ct is always set to ESTABLISHED with a very long timeout
       in flow offload teardown/delete even though the state might be already
       CLOSED. Also as a remark we cannot assume that the FIN or RST packet
       is hitting flow table teardown as the packet might get bumped to the
       slow path in nftables.
    
    This patch resets IPS_OFFLOAD_BIT from flow_offload_teardown(), so
    conntrack handles the tcp rst/fin packet which triggers the CLOSE/FIN
    state transition.
    
    Moreover, teturn the connection's ownership to conntrack upon teardown
    by clearing the offload flag and fixing the established timeout value.
    The flow table GC thread will asynchonrnously free the flow table and
    hardware offload entries.
    
    Before this patch, the IPS_OFFLOAD_BIT remained set for expired flows on
    which is also misleading since the flow is back to classic conntrack
    path.
    
    If nf_ct_delete() removes the entry from the conntrack table, then it
    calls nf_ct_put() which decrements the refcnt. This is not a problem
    because the flowtable holds a reference to the conntrack object from
    flow_offload_alloc() path which is released via flow_offload_free().
    
    This patch also updates nft_flow_offload to skip packets in SYN_RECV
    state. Since we might miss or bump packets to slow path, we do not know
    what will happen there while we are still in SYN_RECV, this patch
    postpones offload up to the next packet which also aligns to the
    existing behaviour in tc-ct.
    
    flow_offload_teardown() does not reset the existing tcp state from
    flow_offload_fixup_tcp() to ESTABLISHED anymore, packets bump to slow
    path might have already update the state to CLOSE/FIN.
    
    Joint work with Oz and Sven.
    
    Fixes: 1e5b247 ("netfilter: nf_flow_table: teardown flow timeout race")
    Signed-off-by: Oz Shlomo <ozsh@nvidia.com>
    Signed-off-by: Sven Auhagen <sven.auhagen@voleatech.de>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ummakynes authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    7e38e79 View commit details
    Browse the repository at this point in the history
  80. netfilter: flowtable: pass flowtable to nf_flow_table_iterate()

    [ Upstream commit 217cff3 ]
    
    The flowtable object is already passed as argument to
    nf_flow_table_iterate(), do use not data pointer to pass flowtable.
    
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ummakynes authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    ae3edbd View commit details
    Browse the repository at this point in the history
  81. netfilter: flowtable: move dst_check to packet path

    [ Upstream commit 2738d9d ]
    
    Fixes sporadic IPv6 packet loss when flow offloading is enabled.
    
    IPv6 route GC and flowtable GC are not synchronized.
    When dst_cache becomes stale and a packet passes through the flow before
    the flowtable GC teardowns it, the packet can be dropped.
    So, it is necessary to check dst every time in packet path.
    
    Fixes: 227e1e4 ("netfilter: nf_flowtable: skip device lookup from interface index")
    Signed-off-by: Ritaro Takenaka <ritarot634@gmail.com>
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    tarori authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    8e0d716 View commit details
    Browse the repository at this point in the history
  82. vdpa/mlx5: Use consistent RQT size

    [ Upstream commit acde392 ]
    
    The current code evaluates RQT size based on the configured number of
    virtqueues. This can raise an issue in the following scenario:
    
    Assume MQ was negotiated.
    1. mlx5_vdpa_set_map() gets called.
    2. handle_ctrl_mq() is called setting cur_num_vqs to some value, lower
       than the configured max VQs.
    3. A second set_map gets called, but now a smaller number of VQs is used
       to evaluate the size of the RQT.
    4. handle_ctrl_mq() is called with a value larger than what the RQT can
       hold. This will emit errors and the driver state is compromised.
    
    To fix this, we use a new field in struct mlx5_vdpa_net to hold the
    required number of entries in the RQT. This value is evaluated in
    mlx5_vdpa_set_driver_features() where we have the negotiated features
    all set up.
    
    In addition to that, we take into consideration the max capability of RQT
    entries early when the device is added so we don't need to take consider
    it when creating the RQT.
    
    Last, we remove the use of mlx5_vdpa_max_qps() which just returns the
    max_vas / 2 and make the code clearer.
    
    Fixes: 5289373 ("vdpa/mlx5: Add multiqueue support")
    Acked-by: Jason Wang <jasowang@redhat.com>
    Signed-off-by: Eli Cohen <elic@nvidia.com>
    Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    elic307i authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    cc43c56 View commit details
    Browse the repository at this point in the history
  83. net: bridge: Clear offload_fwd_mark when passing frame up bridge inte…

    …rface.
    
    [ Upstream commit fbb3abd ]
    
    It is possible to stack bridges on top of each other. Consider the
    following which makes use of an Ethernet switch:
    
           br1
         /    \
        /      \
       /        \
     br0.11    wlan0
       |
       br0
     /  |  \
    p1  p2  p3
    
    br0 is offloaded to the switch. Above br0 is a vlan interface, for
    vlan 11. This vlan interface is then a slave of br1. br1 also has a
    wireless interface as a slave. This setup trunks wireless lan traffic
    over the copper network inside a VLAN.
    
    A frame received on p1 which is passed up to the bridge has the
    skb->offload_fwd_mark flag set to true, indicating that the switch has
    dealt with forwarding the frame out ports p2 and p3 as needed. This
    flag instructs the software bridge it does not need to pass the frame
    back down again. However, the flag is not getting reset when the frame
    is passed upwards. As a result br1 sees the flag, wrongly interprets
    it, and fails to forward the frame to wlan0.
    
    When passing a frame upwards, clear the flag. This is the Rx
    equivalent of br_switchdev_frame_unmark() in br_dev_xmit().
    
    Fixes: f1c2edd ("bridge: switchdev: Use an helper to clear forward mark")
    Signed-off-by: Andrew Lunn <andrew@lunn.ch>
    Reviewed-by: Ido Schimmel <idosch@nvidia.com>
    Tested-by: Ido Schimmel <idosch@nvidia.com>
    Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
    Link: https://lore.kernel.org/r/20220518005840.771575-1-andrew@lunn.ch
    Signed-off-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    lunn authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    38ad5d9 View commit details
    Browse the repository at this point in the history
  84. riscv: dts: sifive: fu540-c000: align dma node name with dtschema

    [ Upstream commit b174101 ]
    
    Fixes dtbs_check warnings like:
    
      dma@3000000: $nodename:0: 'dma@3000000' does not match '^dma-controller(@.*)?$'
    
    Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
    Link: https://lore.kernel.org/r/20220407193856.18223-1-krzysztof.kozlowski@linaro.org
    Fixes: c5ab54e ("riscv: dts: add support for PDMA device of HiFive Unleashed Rev A00")
    Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    krzk authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    dcd042c View commit details
    Browse the repository at this point in the history
  85. scsi: ufs: core: Fix referencing invalid rsp field

    [ Upstream commit d5d92b6 ]
    
    Fix referencing sense data when it is invalid. When the length of the data
    segment is 0, there is no valid information in the rsp field, so
    ufshpb_rsp_upiu() is returned without additional operation.
    
    Link: https://lore.kernel.org/r/252651381.41652940482659.JavaMail.epsvc@epcpadp4
    Fixes: 4b5f490 ("scsi: ufs: ufshpb: L2P map management for HPB read")
    Acked-by: Avri Altman <avri.altman@wdc.com>
    Signed-off-by: Daejun Park <daejun7.park@samsung.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Daejun Park authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    7f9c8ed View commit details
    Browse the repository at this point in the history
  86. kvm: x86/pmu: Fix the compare function used by the pmu event filter

    [ Upstream commit 4ac19ea ]
    
    When returning from the compare function the u64 is truncated to an
    int.  This results in a loss of the high nybble[1] in the event select
    and its sign if that nybble is in use.  Switch from using a result that
    can end up being truncated to a result that can only be: 1, 0, -1.
    
    [1] bits 35:32 in the event select register and bits 11:8 in the event
        select.
    
    Fixes: 7ff775a ("KVM: x86/pmu: Use binary search to check filtered events")
    Signed-off-by: Aaron Lewis <aaronlewis@google.com>
    Reviewed-by: Sean Christopherson <seanjc@google.com>
    Message-Id: <20220517051238.2566934-1-aaronlewis@google.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    suomilewis authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    3b41960 View commit details
    Browse the repository at this point in the history
  87. perf build: Fix check for btf__load_from_kernel_by_id() in libbpf

    [ Upstream commit 0ae065a ]
    
    Avi Kivity reported a problem where the __weak
    btf__load_from_kernel_by_id() in tools/perf/util/bpf-event.c was being
    used and it called btf__get_from_id() in tools/lib/bpf/btf.c that in
    turn called back to btf__load_from_kernel_by_id(), resulting in an
    endless loop.
    
    Fix this by adding a feature test to check if
    btf__load_from_kernel_by_id() is available when building perf with
    LIBBPF_DYNAMIC=1, and if not then provide the fallback to the old
    btf__get_from_id(), that doesn't call back to btf__load_from_kernel_by_id()
    since at that time it didn't exist at all.
    
    Tested on Fedora 35 where we have libbpf-devel 0.4.0 with LIBBPF_DYNAMIC
    where we don't have btf__load_from_kernel_by_id() and thus its feature
    test fail, not defining HAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID:
    
      $ cat /tmp/build/perf-urgent/feature/test-libbpf-btf__load_from_kernel_by_id.make.output
      test-libbpf-btf__load_from_kernel_by_id.c: In function ‘main’:
      test-libbpf-btf__load_from_kernel_by_id.c:6:16: error: implicit declaration of function ‘btf__load_from_kernel_by_id’ [-Werror=implicit-function-declaration]
          6 |         return btf__load_from_kernel_by_id(20151128, NULL);
            |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      cc1: all warnings being treated as errors
      $
    
      $ nm /tmp/build/perf-urgent/perf | grep btf__load_from_kernel_by_id
      00000000005ba180 T btf__load_from_kernel_by_id
      $
    
      $ objdump --disassemble=btf__load_from_kernel_by_id -S /tmp/build/perf-urgent/perf
    
      /tmp/build/perf-urgent/perf:     file format elf64-x86-64
      <SNIP>
      00000000005ba180 <btf__load_from_kernel_by_id>:
      #include "record.h"
      #include "util/synthetic-events.h"
    
      #ifndef HAVE_LIBBPF_BTF__LOAD_FROM_KERNEL_BY_ID
      struct btf *btf__load_from_kernel_by_id(__u32 id)
      {
        5ba180:	55                   	push   %rbp
        5ba181:	48 89 e5             	mov    %rsp,%rbp
        5ba184:	48 83 ec 10          	sub    $0x10,%rsp
        5ba188:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
        5ba18f:	00 00
        5ba191:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
        5ba195:	31 c0                	xor    %eax,%eax
             struct btf *btf;
      #pragma GCC diagnostic push
      #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
             int err = btf__get_from_id(id, &btf);
        5ba197:	48 8d 75 f0          	lea    -0x10(%rbp),%rsi
        5ba19b:	e8 a0 57 e5 ff       	call   40f940 <btf__get_from_id@plt>
        5ba1a0:	89 c2                	mov    %eax,%edx
      #pragma GCC diagnostic pop
    
             return err ? ERR_PTR(err) : btf;
        5ba1a2:	48 98                	cltq
        5ba1a4:	85 d2                	test   %edx,%edx
        5ba1a6:	48 0f 44 45 f0       	cmove  -0x10(%rbp),%rax
      }
      <SNIP>
    
    Fixes: 218e7b7 ("perf bpf: Provide a weak btf__load_from_kernel_by_id() for older libbpf versions")
    Reported-by: Avi Kivity <avi@scylladb.com>
    Link: https://lore.kernel.org/linux-perf-users/f0add43b-3de5-20c5-22c4-70aff4af959f@scylladb.com
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Link: https://lore.kernel.org/linux-perf-users/YobjjFOblY4Xvwo7@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    acmel authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    e8c7bfd View commit details
    Browse the repository at this point in the history
  88. perf stat: Fix and validate CPU map inputs in synthetic PERF_RECORD_S…

    …TAT events
    
    [ Upstream commit 92d579e ]
    
    Stat events can come from disk and so need a degree of validation. They
    contain a CPU which needs looking up via CPU map to access a counter.
    
    Add the CPU to index translation, alongside validity checking.
    
    Discussion thread:
    
      https://lore.kernel.org/linux-perf-users/CAP-5=fWQR=sCuiSMktvUtcbOLidEpUJLCybVF6=BRvORcDOq+g@mail.gmail.com/
    
    Fixes: 7ac0089 ("perf evsel: Pass cpu not cpu map index to synthesize")
    Reported-by: Michael Petlan <mpetlan@redhat.com>
    Suggested-by: Michael Petlan <mpetlan@redhat.com>
    Signed-off-by: Ian Rogers <irogers@google.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Alexei Starovoitov <ast@kernel.org>
    Cc: Andrii Nakryiko <andrii@kernel.org>
    Cc: Daniel Borkmann <daniel@iogearbox.net>
    Cc: Dave Marchevsky <davemarchevsky@fb.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: James Clark <james.clark@arm.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: John Fastabend <john.fastabend@gmail.com>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: KP Singh <kpsingh@kernel.org>
    Cc: Lv Ruyi <lv.ruyi@zte.com.cn>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Martin KaFai Lau <kafai@fb.com>
    Cc: Michael Petlan <mpetlan@redhat.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: netdev@vger.kernel.org
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Quentin Monnet <quentin@isovalent.com>
    Cc: Song Liu <songliubraving@fb.com>
    Cc: Stephane Eranian <eranian@google.com>
    Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
    Cc: Yonghong Song <yhs@fb.com>
    Link: http://lore.kernel.org/lkml/20220519032005.1273691-2-irogers@google.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    captain5050 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    be8d2b8 View commit details
    Browse the repository at this point in the history
  89. gpio: gpio-vf610: do not touch other bits when set the target bit

    [ Upstream commit 9bf3ac4 ]
    
    For gpio controller contain register PDDR, when set one target bit,
    current logic will clear all other bits, this is wrong. Use operator
    '|=' to fix it.
    
    Fixes: 659d8a6 ("gpio: vf610: add imx7ulp support")
    Reviewed-by: Peng Fan <peng.fan@nxp.com>
    Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
    Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Haibo Chen authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    26d4f24 View commit details
    Browse the repository at this point in the history
  90. gpio: mvebu/pwm: Refuse requests with inverted polarity

    [ Upstream commit 3ecb101 ]
    
    The driver doesn't take struct pwm_state::polarity into account when
    configuring the hardware, so refuse requests for inverted polarity.
    
    Fixes: 757642f ("gpio: mvebu: Add limited PWM support")
    Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
    Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Uwe Kleine-König authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    bbefa89 View commit details
    Browse the repository at this point in the history
  91. perf test: Fix "all PMU test" to skip hv_24x7/hv_gpci tests on powerpc

    [ Upstream commit 451ed80 ]
    
    "perf all PMU test" picks the input events from "perf list --raw-dump
    pmu" list and runs "perf stat -e" for each of the event in the list. In
    case of powerpc, the PowerVM environment supports events from hv_24x7
    and hv_gpci PMU which is of example format like below:
    
    - hv_24x7/CPM_ADJUNCT_INST,domain=?,core=?/
    - hv_gpci/event,partition_id=?/
    
    The value for "?" needs to be filled in depending on system and
    respective event. CPM_ADJUNCT_INST needs have core value and domain
    value. hv_gpci event needs partition_id.  Similarly, there are other
    events for hv_24x7 and hv_gpci having "?" in event format. Hence skip
    these events on powerpc platform since values like partition_id, domain
    is specific to system and event.
    
    Fixes: 3d5ac9e ("perf test: Workload test of all PMUs")
    Signed-off-by: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
    Acked-by: Ian Rogers <irogers@google.com>
    Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kajol Jain <kjain@linux.ibm.com>
    Cc: linuxppc-dev@lists.ozlabs.org
    Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Nageswara R Sastry <rnsastry@linux.ibm.com>
    Link: https://lore.kernel.org/r/20220520101236.17249-1-atrajeev@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    athira-rajeev authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    48671ff View commit details
    Browse the repository at this point in the history
  92. perf regs x86: Fix arch__intr_reg_mask() for the hybrid platform

    [ Upstream commit 01b28e4 ]
    
    The X86 specific arch__intr_reg_mask() is to check whether the kernel
    and hardware can collect XMM registers. But it doesn't work on some
    hybrid platform.
    
    Without the patch on ADL-N:
    
      $ perf record -I?
      available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10
      R11 R12 R13 R14 R15
    
    The config of the test event doesn't contain the PMU information. The
    kernel may fail to initialize it on the correct hybrid PMU and return
    the wrong non-supported information.
    
    Add the PMU information into the config for the hybrid platform. The
    same register set is supported among different hybrid PMUs. Checking
    the first available one is good enough.
    
    With the patch on ADL-N:
    
      $ perf record -I?
      available registers: AX BX CX DX SI DI BP SP IP FLAGS CS SS R8 R9 R10
      R11 R12 R13 R14 R15 XMM0 XMM1 XMM2 XMM3 XMM4 XMM5 XMM6 XMM7 XMM8 XMM9
      XMM10 XMM11 XMM12 XMM13 XMM14 XMM15
    
    Fixes: 6466ec1 ("perf regs x86: Add X86 specific arch__intr_reg_mask()")
    Reported-by: Ammy Yi <ammy.yi@intel.com>
    Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
    Acked-by: Ian Rogers <irogers@google.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
    Link: https://lore.kernel.org/r/20220518145125.1494156-1-kan.liang@linux.intel.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Kan Liang authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    4298b4b View commit details
    Browse the repository at this point in the history
  93. perf bench numa: Address compiler error on s390

    [ Upstream commit f8ac1c4 ]
    
    The compilation on s390 results in this error:
    
      # make DEBUG=y bench/numa.o
      ...
      bench/numa.c: In function ‘__bench_numa’:
      bench/numa.c:1749:81: error: ‘%d’ directive output may be truncated
                  writing between 1 and 11 bytes into a region of size between
                  10 and 20 [-Werror=format-truncation=]
      1749 |        snprintf(tname, sizeof(tname), "process%d:thread%d", p, t);
                                                                   ^~
      ...
      bench/numa.c:1749:64: note: directive argument in the range
                     [-2147483647, 2147483646]
      ...
      #
    
    The maximum length of the %d replacement is 11 characters because of the
    negative sign.  Therefore extend the array by two more characters.
    
    Output after:
    
      # make  DEBUG=y bench/numa.o > /dev/null 2>&1; ll bench/numa.o
      -rw-r--r-- 1 root root 418320 May 19 09:11 bench/numa.o
      #
    
    Fixes: 3aff8ba ("perf bench numa: Avoid possible truncation when using snprintf()")
    Suggested-by: Namhyung Kim <namhyung@gmail.com>
    Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
    Cc: Heiko Carstens <hca@linux.ibm.com>
    Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
    Cc: Sven Schnelle <svens@linux.ibm.com>
    Cc: Vasily Gorbik <gor@linux.ibm.com>
    Link: https://lore.kernel.org/r/20220520081158.2990006-1-tmricht@linux.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Thomas Richter authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    8873fdc View commit details
    Browse the repository at this point in the history
  94. perf test bpf: Skip test if clang is not present

    [ Upstream commit 8994e97 ]
    
    Perf BPF filter test fails in environment where "clang" is not
    installed.
    
    Test failure logs:
    
    <<>>
     42: BPF filter                    :
     42.1: Basic BPF filtering         : Skip
     42.2: BPF pinning                 : FAILED!
     42.3: BPF prologue generation     : FAILED!
    <<>>
    
    Enabling verbose option provided debug logs which says clang/llvm needs
    to be installed. Snippet of verbose logs:
    
    <<>>
     42.2: BPF pinning                  :
     --- start ---
    test child forked, pid 61423
    ERROR:	unable to find clang.
    Hint:	Try to install latest clang/llvm to support BPF.
            Check your $PATH
    
    <<logs_here>>
    
    Failed to compile test case: 'Basic BPF llvm compile'
    Unable to get BPF object, fix kbuild first
    test child finished with -1
     ---- end ----
    BPF filter subtest 2: FAILED!
    <<>>
    
    Here subtests, "BPF pinning" and "BPF prologue generation" failed and
    logs shows clang/llvm is needed. After installing clang, testcase
    passes.
    
    Reason on why subtest failure happens though logs has proper debug
    information:
    
    Main function __test__bpf calls test_llvm__fetch_bpf_obj by
    passing 4th argument as true ( 4th arguments maps to parameter
    "force" in test_llvm__fetch_bpf_obj ). But this will cause
    test_llvm__fetch_bpf_obj to skip the check for clang/llvm.
    
    Snippet of code part which checks for clang based on
    parameter "force" in test_llvm__fetch_bpf_obj:
    
    <<>>
    if (!force && (!llvm_param.user_set_param &&
    <<>>
    
    Since force is set to "false", test won't get skipped and fails to
    compile test case. The BPF code compilation needs clang, So pass the
    fourth argument as "false" and also skip the test if reason for return
    is "TEST_SKIP"
    
    After the patch:
    
    <<>>
     42: BPF filter                    :
     42.1: Basic BPF filtering         : Skip
     42.2: BPF pinning                 : Skip
     42.3: BPF prologue generation     : Skip
    <<>>
    
    Fixes: ba1fae4 ("perf test: Add 'perf test BPF'")
    Reviewed-by: Kajol Jain <kjain@linux.ibm.com>
    Signed-off-by: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
    Acked-by: Ian Rogers <irogers@google.com>
    Cc: Disha Goel <disgoel@linux.vnet.ibm.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: linuxppc-dev@lists.ozlabs.org
    Cc: Madhavan Srinivasan <maddy@linux.vnet.ibm.com>
    Cc: Michael Ellerman <mpe@ellerman.id.au>
    Cc: Nageswara R Sastry <rnsastry@linux.ibm.com>
    Cc: Wang Nan <wangnan0@huawei.com>
    Link: https://lore.kernel.org/r/20220511115438.84032-1-atrajeev@linux.vnet.ibm.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    athira-rajeev authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    f419382 View commit details
    Browse the repository at this point in the history
  95. scsi: scsi_dh_alua: Properly handle the ALUA transitioning state

    [ Upstream commit 6056a92 ]
    
    The handling of the ALUA transitioning state is currently broken. When a
    target goes into this state, it is expected that the target is allowed to
    stay in this state for the implicit transition timeout without a path
    failure. The handler has this logic, but it gets skipped currently.
    
    When the target transitions, there is in-flight I/O from the initiator. The
    first of these responses from the target will be a unit attention letting
    the initiator know that the ALUA state has changed.  The remaining
    in-flight I/Os, before the initiator finds out that the portal state has
    changed, will return not ready, ALUA state is transitioning. The portal
    state will change to SCSI_ACCESS_STATE_TRANSITIONING. This will lead to all
    new I/O immediately failing the path unexpectedly. The path failure happens
    in less than a second instead of the expected successes until the
    transition timer is exceeded.
    
    Allow I/Os to continue while the path is in the ALUA transitioning
    state. The handler already takes care of a target that stays in the
    transitioning state for too long by changing the state to ALUA state
    standby once the transition timeout is exceeded at which point the path
    will fail.
    
    Link: https://lore.kernel.org/r/CAHZQxy+4sTPz9+pY3=7VJH+CLUJsDct81KtnR2be8ycN5mhqTg@mail.gmail.com
    Reviewed-by: Hannes Reinecke <hare@suse.de>
    Acked-by: Krishna Kant <krishna.kant@purestorage.com>
    Acked-by: Seamus Connor <sconnor@purestorage.com>
    Signed-off-by: Brian Bunker <brian@purestorage.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    brianatpurestorage authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    e483f5b View commit details
    Browse the repository at this point in the history
  96. scsi: qla2xxx: Fix missed DMA unmap for aborted commands

    [ Upstream commit 26f9ce5 ]
    
    Aborting commands that have already been sent to the firmware can
    cause BUG in qlt_free_cmd(): BUG_ON(cmd->sg_mapped)
    
    For instance:
    
     - Command passes rdx_to_xfer state, maps sgl, sends to the firmware
    
     - Reset occurs, qla2xxx performs ISP error recovery, aborts the command
    
     - Target stack calls qlt_abort_cmd() and then qlt_free_cmd()
    
     - BUG_ON(cmd->sg_mapped) in qlt_free_cmd() occurs because sgl was not
       unmapped
    
    Thus, unmap sgl in qlt_abort_cmd() for commands with the aborted flag set.
    
    Link: https://lore.kernel.org/r/AS8PR10MB4952D545F84B6B1DFD39EC1E9DEE9@AS8PR10MB4952.EURPRD10.PROD.OUTLOOK.COM
    Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com>
    Signed-off-by: Gleb Chesnokov <Chesnokov.G@raidix.com>
    Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    lnocturno authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    c3d7a2b View commit details
    Browse the repository at this point in the history
  97. mac80211: fix rx reordering with non explicit / psmp ack policy

    [ Upstream commit 5e469ed ]
    
    When the QoS ack policy was set to non explicit / psmp ack, frames are treated
    as not being part of a BA session, which causes extra latency on reordering.
    Fix this by only bypassing reordering for packets with no-ack policy
    
    Signed-off-by: Felix Fietkau <nbd@nbd.name>
    Link: https://lore.kernel.org/r/20220420105038.36443-1-nbd@nbd.name
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    nbd168 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    9af5345 View commit details
    Browse the repository at this point in the history
  98. nl80211: validate S1G channel width

    [ Upstream commit 5d087aa ]
    
    Validate the S1G channel width input by user to ensure it matches
    that of the requested channel
    
    Signed-off-by: Kieran Frewen <kieran.frewen@morsemicro.com>
    Signed-off-by: Bassem Dawood <bassem@morsemicro.com>
    Link: https://lore.kernel.org/r/20220420041321.3788789-2-kieran.frewen@morsemicro.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Kieran Frewen authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    a1a2097 View commit details
    Browse the repository at this point in the history
  99. cfg80211: retrieve S1G operating channel number

    [ Upstream commit e847ffe ]
    
    When retrieving the S1G channel number from IEs, we should retrieve
    the operating channel instead of the primary channel. The S1G operation
    element specifies the main channel of operation as the oper channel,
    unlike for HT and HE which specify their main channel of operation as
    the primary channel.
    
    Signed-off-by: Kieran Frewen <kieran.frewen@morsemicro.com>
    Signed-off-by: Bassem Dawood <bassem@morsemicro.com>
    Link: https://lore.kernel.org/r/20220420041321.3788789-1-kieran.frewen@morsemicro.com
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Kieran Frewen authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    45e7d6d View commit details
    Browse the repository at this point in the history
  100. selftests: add ping test with ping_group_range tuned

    [ Upstream commit e71b7f1 ]
    
    The 'ping' utility is able to manage two kind of sockets (raw or icmp),
    depending on the sysctl ping_group_range. By default, ping_group_range is
    set to '1 0', which forces ping to use an ip raw socket.
    
    Let's replay the ping tests by allowing 'ping' to use the ip icmp socket.
    After the previous patch, ipv4 tests results are the same with both kinds
    of socket. For ipv6, there are a lot a new failures (the previous patch
    fixes only two cases).
    
    Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
    Reviewed-by: David Ahern <dsahern@kernel.org>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    NicolasDichtel authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    98a9984 View commit details
    Browse the repository at this point in the history
  101. Revert "fbdev: Make fb_release() return -ENODEV if fbdev was unregist…

    …ered"
    
    [ Upstream commit 135332f ]
    
    This reverts commit aafa025. That commit
    attempted to fix a NULL pointer dereference, caused by the struct fb_info
    associated with a framebuffer device to not longer be valid when the file
    descriptor was closed.
    
    The issue was exposed by commit 27599aa ("fbdev: Hot-unplug firmware
    fb devices on forced removal"), which added a new path that goes through
    the struct device removal instead of directly unregistering the fb.
    
    Most fbdev drivers have issues with the fb_info lifetime, because call to
    framebuffer_release() from their driver's .remove callback, rather than
    doing from fbops.fb_destroy callback. This meant that due to this switch,
    the fb_info was now destroyed too early, while references still existed,
    while before it was simply leaked.
    
    The patch we're reverting here reinstated that leak, hence "fixed" the
    regression. But the proper solution is to fix the drivers to not release
    the fb_info too soon.
    
    Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
    Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220504115917.758787-1-javierm@redhat.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    martinezjavier authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    388c23c View commit details
    Browse the repository at this point in the history
  102. fbdev: Prevent possible use-after-free in fb_release()

    [ Upstream commit 89bfd40 ]
    
    Most fbdev drivers have issues with the fb_info lifetime, because call to
    framebuffer_release() from their driver's .remove callback, rather than
    doing from fbops.fb_destroy callback.
    
    Doing that will destroy the fb_info too early, while references to it may
    still exist, leading to a use-after-free error.
    
    To prevent this, check the fb_info reference counter when attempting to
    kfree the data structure in framebuffer_release(). That will leak it but
    at least will prevent the mentioned error.
    
    Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
    Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
    Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
    Link: https://patchwork.freedesktop.org/patch/msgid/20220505220413.365977-1-javierm@redhat.com
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    danvet authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    5678aac View commit details
    Browse the repository at this point in the history
  103. platform/x86: thinkpad_acpi: Convert btusb DMI list to quirks

    [ Upstream commit c25d7f3 ]
    
    DMI matching in thinkpad_acpi happens local to a function meaning
    quirks can only match that function.
    
    Future changes to thinkpad_acpi may need to quirk other code, so
    change this to use a quirk infrastructure.
    
    Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
    Tested-by: Mark Pearson <markpearson@lenvo.com>
    Link: https://lore.kernel.org/r/20220429030501.1909-2-mario.limonciello@amd.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    superm1 authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    770e04d View commit details
    Browse the repository at this point in the history
  104. platform/x86: thinkpad_acpi: Correct dual fan probe

    [ Upstream commit aa2fef6 ]
    
    There was an issue with the dual fan probe whereby the probe was
    failing as it assuming that second_fan support was not available.
    
    Corrected the logic so the probe works correctly. Cleaned up so
    quirks only used if 2nd fan not detected.
    
    Tested on X1 Carbon 10 (2 fans), X1 Carbon 9 (2 fans) and T490 (1 fan)
    
    Signed-off-by: Mark Pearson <markpearson@lenovo.com>
    Link: https://lore.kernel.org/r/20220502191200.63470-1-markpearson@lenovo.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    mrhpearson authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    8404c27 View commit details
    Browse the repository at this point in the history
  105. platform/x86/intel: Fix 'rmmod pmt_telemetry' panic

    [ Upstream commit 2cdfa0c ]
    
    'rmmod pmt_telemetry' panics with:
    
     BUG: kernel NULL pointer dereference, address: 0000000000000040
     #PF: supervisor read access in kernel mode
     #PF: error_code(0x0000) - not-present page
     PGD 0 P4D 0
     Oops: 0000 [#1] PREEMPT SMP NOPTI
     CPU: 4 PID: 1697 Comm: rmmod Tainted: G S      W        --------  ---  5.18.0-rc4 #3
     Hardware name: Intel Corporation Alder Lake Client Platform/AlderLake-P DDR5 RVP, BIOS ADLPFWI1.R00.3056.B00.2201310233 01/31/2022
     RIP: 0010:device_del+0x1b/0x3d0
     Code: e8 1a d9 e9 ff e9 58 ff ff ff 48 8b 08 eb dc 0f 1f 44 00 00 41 56 41 55 41 54 55 48 8d af 80 00 00 00 53 48 89 fb 48 83 ec 18 <4c> 8b 67 40 48 89 ef 65 48 8b 04 25 28 00 00 00 48 89 44 24 10 31
     RSP: 0018:ffffb520415cfd60 EFLAGS: 00010286
     RAX: 0000000000000070 RBX: 0000000000000000 RCX: 0000000000000000
     RDX: 0000000000000001 RSI: 0000000000000000 RDI: 0000000000000000
     RBP: 0000000000000080 R08: ffffffffffffffff R09: ffffb520415cfd78
     R10: 0000000000000002 R11: ffffb520415cfd78 R12: 0000000000000000
     R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
     FS:  00007f7e198e5740(0000) GS:ffff905c9f700000(0000) knlGS:0000000000000000
     CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
     CR2: 0000000000000040 CR3: 000000010782a005 CR4: 0000000000770ee0
     PKRU: 55555554
     Call Trace:
      <TASK>
      ? __xa_erase+0x53/0xb0
      device_unregister+0x13/0x50
      intel_pmt_dev_destroy+0x34/0x60 [pmt_class]
      pmt_telem_remove+0x40/0x50 [pmt_telemetry]
      auxiliary_bus_remove+0x18/0x30
      device_release_driver_internal+0xc1/0x150
      driver_detach+0x44/0x90
      bus_remove_driver+0x74/0xd0
      auxiliary_driver_unregister+0x12/0x20
      pmt_telem_exit+0xc/0xe4a [pmt_telemetry]
      __x64_sys_delete_module+0x13a/0x250
      ? syscall_trace_enter.isra.19+0x11e/0x1a0
      do_syscall_64+0x58/0x80
      ? syscall_exit_to_user_mode+0x12/0x30
      ? do_syscall_64+0x67/0x80
      ? syscall_exit_to_user_mode+0x12/0x30
      ? do_syscall_64+0x67/0x80
      ? syscall_exit_to_user_mode+0x12/0x30
      ? do_syscall_64+0x67/0x80
      ? exc_page_fault+0x64/0x140
      entry_SYSCALL_64_after_hwframe+0x44/0xae
     RIP: 0033:0x7f7e1803a05b
     Code: 73 01 c3 48 8b 0d 2d 4e 38 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d fd 4d 38 00 f7 d8 64 89 01 48
    
    The probe function, pmt_telem_probe(), adds an entry for devices even if
    they have not been initialized.  This results in the array of initialized
    devices containing both initialized and uninitialized entries.  This
    causes a panic in the remove function, pmt_telem_remove() which expects
    the array to only contain initialized entries.
    
    Only use an entry when a device is initialized.
    
    Cc: "David E. Box" <david.e.box@linux.intel.com>
    Cc: Hans de Goede <hdegoede@redhat.com>
    Cc: Mark Gross <markgross@kernel.org>
    Cc: platform-driver-x86@vger.kernel.org
    Signed-off-by: David Arcari <darcari@redhat.com>
    Signed-off-by: Prarit Bhargava <prarit@redhat.com>
    Reviewed-by: David E. Box <david.e.box@linux.intel.com>
    Link: https://lore.kernel.org/r/20220429122322.2550003-1-prarit@redhat.com
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    prarit authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    ea1b9ab View commit details
    Browse the repository at this point in the history
  106. platform/surface: gpe: Add support for Surface Pro 8

    [ Upstream commit ed13d4a ]
    
    The new Surface Pro 8 uses GPEs for lid events as well. Add an entry for
    that so that the lid can be used to wake the device. Note that this is a
    device with a keyboard type-cover, where this acts as the "lid".
    
    Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
    Link: https://lore.kernel.org/r/20220429180049.1282447-1-luzmaximilian@gmail.com
    Signed-off-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    qzed authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    54e7a2e View commit details
    Browse the repository at this point in the history
  107. drm/amd/display: undo clearing of z10 related function pointers

    [ Upstream commit 9b9bd3f ]
    
    [Why]
    Z10 and S0i3 have some shared path. Previous code clean up ,
    incorrectly removed these pointers, which breaks s0i3 restore
    
    [How]
    Do not clear the function pointers based on Z10 disable.
    
    Reviewed-by: Nicholas Kazlauskas <Nicholas.Kazlauskas@amd.com>
    Acked-by: Pavle Kotarac <Pavle.Kotarac@amd.com>
    Signed-off-by: Eric Yang <Eric.Yang2@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Eric Yang authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    f9801dd View commit details
    Browse the repository at this point in the history
  108. net: fix wrong network header length

    [ Upstream commit cf3ab8d ]
    
    When clatd starts with ebpf offloaing, and NETIF_F_GRO_FRAGLIST is enable,
    several skbs are gathered in skb_shinfo(skb)->frag_list. The first skb's
    ipv6 header will be changed to ipv4 after bpf_skb_proto_6_to_4,
    network_header\transport_header\mac_header have been updated as ipv4 acts,
    but other skbs in frag_list didnot update anything, just ipv6 packets.
    
    udp_queue_rcv_skb will call skb_segment_list to traverse other skbs in
    frag_list and make sure right udp payload is delivered to user space.
    Unfortunately, other skbs in frag_list who are still ipv6 packets are
    updated like the first skb and will have wrong transport header length.
    
    e.g.before bpf_skb_proto_6_to_4,the first skb and other skbs in frag_list
    has the same network_header(24)& transport_header(64), after
    bpf_skb_proto_6_to_4, ipv6 protocol has been changed to ipv4, the first
    skb's network_header is 44,transport_header is 64, other skbs in frag_list
    didnot change.After skb_segment_list, the other skbs in frag_list has
    different network_header(24) and transport_header(44), so there will be 20
    bytes different from original,that is difference between ipv6 header and
    ipv4 header. Just change transport_header to be the same with original.
    
    Actually, there are two solutions to fix it, one is traversing all skbs
    and changing every skb header in bpf_skb_proto_6_to_4, the other is
    modifying frag_list skb's header in skb_segment_list. Considering
    efficiency, adopt the second one--- when the first skb and other skbs in
    frag_list has different network_header length, restore them to make sure
    right udp payload is delivered to user space.
    
    Signed-off-by: Lina Wang <lina.wang@mediatek.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    pigfavor authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    9feada5 View commit details
    Browse the repository at this point in the history
  109. nl80211: fix locking in nl80211_set_tx_bitrate_mask()

    [ Upstream commit f971e18 ]
    
    This accesses the wdev's chandef etc., so cannot safely
    be used without holding the lock.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Link: https://lore.kernel.org/r/20220506102136.06b7205419e6.I2a87c05fbd8bc5e565e84d190d4cfd2e92695a90@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    jmberg-intel authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    6778bd6 View commit details
    Browse the repository at this point in the history
  110. ethernet: tulip: fix missing pci_disable_device() on error in tulip_i…

    …nit_one()
    
    [ Upstream commit 51ca86b ]
    
    Fix the missing pci_disable_device() before return
    from tulip_init_one() in the error handling case.
    
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20220506094250.3630615-1-yangyingliang@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Yang Yingliang authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    cad5b82 View commit details
    Browse the repository at this point in the history
  111. net: stmmac: fix missing pci_disable_device() on error in stmmac_pci_…

    …probe()
    
    [ Upstream commit 0807ce0 ]
    
    Switch to using pcim_enable_device() to avoid missing pci_disable_device().
    
    Reported-by: Hulk Robot <hulkci@huawei.com>
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Link: https://lore.kernel.org/r/20220510031316.1780409-1-yangyingliang@huawei.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Yang Yingliang authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    25f8ee1 View commit details
    Browse the repository at this point in the history
  112. net: atlantic: fix "frag[0] not initialized"

    [ Upstream commit 62e0ae0 ]
    
    In aq_ring_rx_clean(), if buff->is_eop is not set AND
    buff->len < AQ_CFG_RX_HDR_SIZE, then hdr_len remains equal to
    buff->len and skb_add_rx_frag(xxx, *0*, ...) is not called.
    
    The loop following this code starts calling skb_add_rx_frag() starting
    with i=1 and thus frag[0] is never initialized. Since i is initialized
    to zero at the top of the primary loop, we can just reference and
    post-increment i instead of hardcoding the 0 when calling
    skb_add_rx_frag() the first time.
    
    Reported-by: Aashay Shringarpure <aashay@google.com>
    Reported-by: Yi Chou <yich@google.com>
    Reported-by: Shervin Oloumi <enlightened@google.com>
    Signed-off-by: Grant Grundler <grundler@chromium.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    grundlerchromium authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    ba527f5 View commit details
    Browse the repository at this point in the history
  113. net: atlantic: reduce scope of is_rsc_complete

    [ Upstream commit 79784d7 ]
    
    Don't defer handling the err case outside the loop. That's pointless.
    
    And since is_rsc_complete is only used inside this loop, declare
    it inside the loop to reduce it's scope.
    
    Signed-off-by: Grant Grundler <grundler@chromium.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    grundlerchromium authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    5a5c3cd View commit details
    Browse the repository at this point in the history
  114. net: atlantic: add check for MAX_SKB_FRAGS

    [ Upstream commit 6aecbba ]
    
    Enforce that the CPU can not get stuck in an infinite loop.
    
    Reported-by: Aashay Shringarpure <aashay@google.com>
    Reported-by: Yi Chou <yich@google.com>
    Reported-by: Shervin Oloumi <enlightened@google.com>
    Signed-off-by: Grant Grundler <grundler@chromium.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    grundlerchromium authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    dd4fb02 View commit details
    Browse the repository at this point in the history
  115. net: atlantic: verify hw_head_ lies within TX buffer ring

    [ Upstream commit 2120b7f ]
    
    Bounds check hw_head index provided by NIC to verify it lies
    within the TX buffer ring.
    
    Reported-by: Aashay Shringarpure <aashay@google.com>
    Reported-by: Yi Chou <yich@google.com>
    Reported-by: Shervin Oloumi <enlightened@google.com>
    Signed-off-by: Grant Grundler <grundler@chromium.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    grundlerchromium authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    b270794 View commit details
    Browse the repository at this point in the history
  116. arm64: Enable repeat tlbi workaround on KRYO4XX gold CPUs

    [ Upstream commit 51f559d ]
    
    Add KRYO4XX gold/big cores to the list of CPUs that need the
    repeat TLBI workaround. Apply this to the affected
    KRYO4XX cores (rcpe to rfpe).
    
    The variant and revision bits are implementation defined and are
    different from the their Cortex CPU counterparts on which they are
    based on, i.e., (r0p0 to r3p0) is equivalent to (rcpe to rfpe).
    
    Signed-off-by: Shreyas K K <quic_shrekk@quicinc.com>
    Reviewed-by: Sai Prakash Ranjan <quic_saipraka@quicinc.com>
    Link: https://lore.kernel.org/r/20220512110134.12179-1-quic_shrekk@quicinc.com
    Signed-off-by: Will Deacon <will@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Shreyas K K authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    752a3ba View commit details
    Browse the repository at this point in the history
  117. Input: ili210x - fix reset timing

    commit e4920d4 upstream.
    
    According to Ilitek "231x & ILI251x Programming Guide" Version: 2.30
    "2.1. Power Sequence", "T4 Chip Reset and discharge time" is minimum
    10ms and "T2 Chip initial time" is maximum 150ms. Adjust the reset
    timings such that T4 is 12ms and T2 is 160ms to fit those figures.
    
    This prevents sporadic touch controller start up failures when some
    systems with at least ILI251x controller boot, without this patch
    the systems sometimes fail to communicate with the touch controller.
    
    Fixes: 201f3c8 ("Input: ili210x - add reset GPIO support")
    Signed-off-by: Marek Vasut <marex@denx.de>
    Link: https://lore.kernel.org/r/20220518204901.93534-1-marex@denx.de
    Cc: stable@vger.kernel.org
    Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Marek Vasut authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    1ab9adc View commit details
    Browse the repository at this point in the history
  118. dt-bindings: pinctrl: aspeed-g6: remove FWQSPID group

    commit a29c96a upstream.
    
    FWQSPID is not a group of FWSPID so remove it.
    
    Fixes: 7488838 ("dt-bindings: pinctrl: aspeed: Document AST2600 pinmux")
    Signed-off-by: Jae Hyun Yoo <quic_jaehyoo@quicinc.com>
    Acked-by: Rob Herring <robh@kernel.org>
    Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
    Link: https://lore.kernel.org/r/20220329173932.2588289-4-quic_jaehyoo@quicinc.com
    Signed-off-by: Joel Stanley <joel@jms.id.au>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    jaehyoo authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    268f52a View commit details
    Browse the repository at this point in the history
  119. i2c: mt7621: fix missing clk_disable_unprepare() on error in mtk_i2c_…

    …probe()
    
    [ Upstream commit a2537c9 ]
    
    Fix the missing clk_disable_unprepare() before return
    from mtk_i2c_probe() in the error handling case.
    
    Fixes: d04913e ("i2c: mt7621: Add MediaTek MT7621/7628/7688 I2C driver")
    Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
    Reviewed-by: Stefan Roese <sr@denx.de>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    Yang Yingliang authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    b1427a9 View commit details
    Browse the repository at this point in the history
  120. afs: Fix afs_getattr() to refetch file status if callback break occurred

    [ Upstream commit 2aeb8c8 ]
    
    If a callback break occurs (change notification), afs_getattr() needs to
    issue an FS.FetchStatus RPC operation to update the status of the file
    being examined by the stat-family of system calls.
    
    Fix afs_getattr() to do this if AFS_VNODE_CB_PROMISED has been cleared
    on a vnode by a callback break.  Skip this if AT_STATX_DONT_SYNC is set.
    
    This can be tested by appending to a file on one AFS client and then
    using "stat -L" to examine its length on a machine running kafs.  This
    can also be watched through tracing on the kafs machine.  The callback
    break is seen:
    
         kworker/1:1-46      [001] .....   978.910812: afs_cb_call: c=0000005f YFSCB.CallBack
         kworker/1:1-46      [001] ...1.   978.910829: afs_cb_break: 100058:23b4c:242d2c2 b=2 s=1 break-cb
         kworker/1:1-46      [001] .....   978.911062: afs_call_done:    c=0000005f ret=0 ab=0 [0000000082994ead]
    
    And then the stat command generated no traffic if unpatched, but with
    this change a call to fetch the status can be observed:
    
                stat-4471    [000] .....   986.744122: afs_make_fs_call: c=000000ab 100058:023b4c:242d2c2 YFS.FetchStatus
                stat-4471    [000] .....   986.745578: afs_call_done:    c=000000ab ret=0 ab=0 [0000000087fc8c84]
    
    Fixes: 08e0e7c ("[AF_RXRPC]: Make the in-kernel AFS filesystem use AF_RXRPC.")
    Reported-by: Markus Suvanto <markus.suvanto@gmail.com>
    Signed-off-by: David Howells <dhowells@redhat.com>
    cc: Marc Dionne <marc.dionne@auristor.com>
    cc: linux-afs@lists.infradead.org
    Tested-by: Markus Suvanto <markus.suvanto@gmail.com>
    Tested-by: kafs-testing+fedora34_64checkkafs-build-496@auristor.com
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=216010
    Link: https://lore.kernel.org/r/165308359800.162686.14122417881564420962.stgit@warthog.procyon.org.uk/ # v1
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    dhowells authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    9e655a8 View commit details
    Browse the repository at this point in the history
  121. Linux 5.17.10

    Link: https://lore.kernel.org/r/20220523165830.581652127@linuxfoundation.org
    Tested-by: Florian Fainelli <f.fainelli@gmail.com>
    Tested-by: Shuah Khan <skhan@linuxfoundation.org>
    Tested-by: Zan Aziz <zanaziz313@gmail.com>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Fenil Jain<fkjainco@gmail.com>
    Tested-by: Ron Economos <re@w6rz.net>
    Tested-by: Fox Chen <foxhlchen@gmail.com>
    Tested-by: Justin M. Forbes <jforbes@fedoraproject.org>
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Khalid Masum <khalid.masum.92@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    6c468bb View commit details
    Browse the repository at this point in the history
  122. mptcp: Do TCP fallback on early DSS checksum failure

    commit ae66fb2 upstream.
    
    RFC 8684 section 3.7 describes several opportunities for a MPTCP
    connection to "fall back" to regular TCP early in the connection
    process, before it has been confirmed that MPTCP options can be
    successfully propagated on all SYN, SYN/ACK, and data packets. If a peer
    acknowledges the first received data packet with a regular TCP header
    (no MPTCP options), fallback is allowed.
    
    If the recipient of that first data packet finds a MPTCP DSS checksum
    error, this provides an opportunity to fail gracefully with a TCP
    fallback rather than resetting the connection (as might happen if a
    checksum failure were detected later).
    
    This commit modifies the checksum failure code to attempt fallback on
    the initial subflow of a MPTCP connection, only if it's a failure in the
    first data mapping. In cases where the peer initiates the connection,
    requests checksums, is the first to send data, and the peer is sending
    incorrect checksums (see
    multipath-tcp/mptcp_net-next#275), this allows
    the connection to proceed as TCP rather than reset.
    
    Fixes: dd8bcd1 ("mptcp: validate the data checksum")
    Acked-by: Paolo Abeni <pabeni@redhat.com>
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    [mathew.j.martineau: backport: Resolved bitfield conflict in protocol.h]
    Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    mjmartineau authored and gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    2973647 View commit details
    Browse the repository at this point in the history
  123. Linux 5.17.11

    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    gregkh committed May 25, 2022
    Configuration menu
    Copy the full SHA
    e960d73 View commit details
    Browse the repository at this point in the history

Commits on May 30, 2022

  1. HID: amd_sfh: Add support for sensor discovery

    commit b5d7f43 upstream.
    
    Sensor discovery status fails in case of broken sensors or
    platform not supported. Hence disable driver on failure
    of sensor discovery.
    
    Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
    Signed-off-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>
    Signed-off-by: Jiri Kosina <jkosina@suse.cz>
    Cc: Mario Limonciello <Mario.Limonciello@amd.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Basavaraj Natikar authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    0650aa5 View commit details
    Browse the repository at this point in the history
  2. KVM: x86/mmu: fix NULL pointer dereference on guest INVPCID

    commit 9f46c18 upstream.
    
    With shadow paging enabled, the INVPCID instruction results in a call
    to kvm_mmu_invpcid_gva.  If INVPCID is executed with CR0.PG=0, the
    invlpg callback is not set and the result is a NULL pointer dereference.
    Fix it trivially by checking for mmu->invlpg before every call.
    
    There are other possibilities:
    
    - check for CR0.PG, because KVM (like all Intel processors after P5)
      flushes guest TLB on CR0.PG changes so that INVPCID/INVLPG are a
      nop with paging disabled
    
    - check for EFER.LMA, because KVM syncs and flushes when switching
      MMU contexts outside of 64-bit mode
    
    All of these are tricky, go for the simple solution.  This is CVE-2022-1789.
    
    Reported-by: Yongkang Jia <kangel@zju.edu.cn>
    Cc: stable@vger.kernel.org
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    [fix conflict due to missing b9e5603]
    Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    bonzini authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    19a6679 View commit details
    Browse the repository at this point in the history
  3. random: use computational hash for entropy extraction

    commit 6e8ec25 upstream.
    
    The current 4096-bit LFSR used for entropy collection had a few
    desirable attributes for the context in which it was created. For
    example, the state was huge, which meant that /dev/random would be able
    to output quite a bit of accumulated entropy before blocking. It was
    also, in its time, quite fast at accumulating entropy byte-by-byte,
    which matters given the varying contexts in which mix_pool_bytes() is
    called. And its diffusion was relatively high, which meant that changes
    would ripple across several words of state rather quickly.
    
    However, it also suffers from a few security vulnerabilities. In
    particular, inputs learned by an attacker can be undone, but moreover,
    if the state of the pool leaks, its contents can be controlled and
    entirely zeroed out. I've demonstrated this attack with this SMT2
    script, <https://xn--4db.cc/5o9xO8pb>, which Boolector/CaDiCal solves in
    a matter of seconds on a single core of my laptop, resulting in little
    proof of concept C demonstrators such as <https://xn--4db.cc/jCkvvIaH/c>.
    
    For basically all recent formal models of RNGs, these attacks represent
    a significant cryptographic flaw. But how does this manifest
    practically? If an attacker has access to the system to such a degree
    that he can learn the internal state of the RNG, arguably there are
    other lower hanging vulnerabilities -- side-channel, infoleak, or
    otherwise -- that might have higher priority. On the other hand, seed
    files are frequently used on systems that have a hard time generating
    much entropy on their own, and these seed files, being files, often leak
    or are duplicated and distributed accidentally, or are even seeded over
    the Internet intentionally, where their contents might be recorded or
    tampered with. Seen this way, an otherwise quasi-implausible
    vulnerability is a bit more practical than initially thought.
    
    Another aspect of the current mix_pool_bytes() function is that, while
    its performance was arguably competitive for the time in which it was
    created, it's no longer considered so. This patch improves performance
    significantly: on a high-end CPU, an i7-11850H, it improves performance
    of mix_pool_bytes() by 225%, and on a low-end CPU, a Cortex-A7, it
    improves performance by 103%.
    
    This commit replaces the LFSR of mix_pool_bytes() with a straight-
    forward cryptographic hash function, BLAKE2s, which is already in use
    for pool extraction. Universal hashing with a secret seed was considered
    too, something along the lines of <https://eprint.iacr.org/2013/338>,
    but the requirement for a secret seed makes for a chicken & egg problem.
    Instead we go with a formally proven scheme using a computational hash
    function, described in sections 5.1, 6.4, and B.1.8 of
    <https://eprint.iacr.org/2019/198>.
    
    BLAKE2s outputs 256 bits, which should give us an appropriate amount of
    min-entropy accumulation, and a wide enough margin of collision
    resistance against active attacks. mix_pool_bytes() becomes a simple
    call to blake2s_update(), for accumulation, while the extraction step
    becomes a blake2s_final() to generate a seed, with which we can then do
    a HKDF-like or BLAKE2X-like expansion, the first part of which we fold
    back as an init key for subsequent blake2s_update()s, and the rest we
    produce to the caller. This then is provided to our CRNG like usual. In
    that expansion step, we make opportunistic use of 32 bytes of RDRAND
    output, just as before. We also always reseed the crng with 32 bytes,
    unconditionally, or not at all, rather than sometimes with 16 as before,
    as we don't win anything by limiting beyond the 16 byte threshold.
    
    Going for a hash function as an entropy collector is a conservative,
    proven approach. The result of all this is a much simpler and much less
    bespoke construction than what's there now, which not only plugs a
    vulnerability but also improves performance considerably.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    efba5eb View commit details
    Browse the repository at this point in the history
  4. random: simplify entropy debiting

    commit 9c07f57 upstream.
    
    Our pool is 256 bits, and we only ever use all of it or don't use it at
    all, which is decided by whether or not it has at least 128 bits in it.
    So we can drastically simplify the accounting and cmpxchg loop to do
    exactly this.  While we're at it, we move the minimum bit size into a
    constant so it can be shared between the two places where it matters.
    
    The reason we want any of this is for the case in which an attacker has
    compromised the current state, and then bruteforces small amounts of
    entropy added to it. By demanding a particular minimum amount of entropy
    be present before reseeding, we make that bruteforcing difficult.
    
    Note that this rationale no longer includes anything about /dev/random
    blocking at the right moment, since /dev/random no longer blocks (except
    for at ~boot), but rather uses the crng. In a former life, /dev/random
    was different and therefore required a more nuanced account(), but this
    is no longer.
    
    Behaviorally, nothing changes here. This is just a simplification of
    the code.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    2d6c74b View commit details
    Browse the repository at this point in the history
  5. random: use linear min-entropy accumulation crediting

    commit c570449 upstream.
    
    30e37ec ("random: account for entropy loss due to overwrites")
    assumed that adding new entropy to the LFSR pool probabilistically
    cancelled out old entropy there, so entropy was credited asymptotically,
    approximating Shannon entropy of independent sources (rather than a
    stronger min-entropy notion) using 1/8th fractional bits and replacing
    a constant 2-2/√𝑒 term (~0.786938) with 3/4 (0.75) to slightly
    underestimate it. This wasn't superb, but it was perhaps better than
    nothing, so that's what was done. Which entropy specifically was being
    cancelled out and how much precisely each time is hard to tell, though
    as I showed with the attack code in my previous commit, a motivated
    adversary with sufficient information can actually cancel out
    everything.
    
    Since we're no longer using an LFSR for entropy accumulation, this
    probabilistic cancellation is no longer relevant. Rather, we're now
    using a computational hash function as the accumulator and we've
    switched to working in the random oracle model, from which we can now
    revisit the question of min-entropy accumulation, which is done in
    detail in <https://eprint.iacr.org/2019/198>.
    
    Consider a long input bit string that is built by concatenating various
    smaller independent input bit strings. Each one of these inputs has a
    designated min-entropy, which is what we're passing to
    credit_entropy_bits(h). When we pass the concatenation of these to a
    random oracle, it means that an adversary trying to receive back the
    same reply as us would need to become certain about each part of the
    concatenated bit string we passed in, which means becoming certain about
    all of those h values. That means we can estimate the accumulation by
    simply adding up the h values in calls to credit_entropy_bits(h);
    there's no probabilistic cancellation at play like there was said to be
    for the LFSR. Incidentally, this is also what other entropy accumulators
    based on computational hash functions do as well.
    
    So this commit replaces credit_entropy_bits(h) with essentially `total =
    min(POOL_BITS, total + h)`, done with a cmpxchg loop as before.
    
    What if we're wrong and the above is nonsense? It's not, but let's
    assume we don't want the actual _behavior_ of the code to change much.
    Currently that behavior is not extracting from the input pool until it
    has 128 bits of entropy in it. With the old algorithm, we'd hit that
    magic 128 number after roughly 256 calls to credit_entropy_bits(1). So,
    we can retain more or less the old behavior by waiting to extract from
    the input pool until it hits 256 bits of entropy using the new code. For
    people concerned about this change, it means that there's not that much
    practical behavioral change. And for folks actually trying to model
    the behavior rigorously, it means that we have an even higher margin
    against attacks.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    bd7d220 View commit details
    Browse the repository at this point in the history
  6. random: always wake up entropy writers after extraction

    commit 489c7fc upstream.
    
    Now that POOL_BITS == POOL_MIN_BITS, we must unconditionally wake up
    entropy writers after every extraction. Therefore there's no point of
    write_wakeup_threshold, so we can move it to the dustbin of unused
    compatibility sysctls. While we're at it, we can fix a small comparison
    where we were waking up after <= min rather than < min.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Suggested-by: Eric Biggers <ebiggers@kernel.org>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    7404140 View commit details
    Browse the repository at this point in the history
  7. random: make credit_entropy_bits() always safe

    commit a49c010 upstream.
    
    This is called from various hwgenerator drivers, so rather than having
    one "safe" version for userspace and one "unsafe" version for the
    kernel, just make everything safe; the checks are cheap and sensible to
    have anyway.
    
    Reported-by: Sultan Alsawaf <sultan@kerneltoast.com>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    4fa0d8e View commit details
    Browse the repository at this point in the history
  8. random: remove use_input_pool parameter from crng_reseed()

    commit 5d58ea3 upstream.
    
    The primary_crng is always reseeded from the input_pool, while the NUMA
    crngs are always reseeded from the primary_crng.  Remove the redundant
    'use_input_pool' parameter from crng_reseed() and just directly check
    whether the crng is the primary_crng.
    
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    ebiggers authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    a53df44 View commit details
    Browse the repository at this point in the history
  9. random: remove batched entropy locking

    commit 77760fd upstream.
    
    Rather than use spinlocks to protect batched entropy, we can instead
    disable interrupts locally, since we're dealing with per-cpu data, and
    manage resets with a basic generation counter. At the same time, we
    can't quite do this on PREEMPT_RT, where we still want spinlocks-as-
    mutexes semantics. So we use a local_lock_t, which provides the right
    behavior for each. Because this is a per-cpu lock, that generation
    counter is still doing the necessary CPU-to-CPU communication.
    
    This should improve performance a bit. It will also fix the linked splat
    that Jonathan received with a PROVE_RAW_LOCK_NESTING=y.
    
    Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Suggested-by: Andy Lutomirski <luto@kernel.org>
    Reported-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
    Tested-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
    Link: https://lore.kernel.org/lkml/YfMa0QgsjCVdRAvJ@latitude/
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    048d57f View commit details
    Browse the repository at this point in the history
  10. random: fix locking in crng_fast_load()

    commit 7c2fe2b upstream.
    
    crng_init is protected by primary_crng->lock, so keep holding that lock
    when incrementing crng_init from 0 to 1 in crng_fast_load(). The call to
    pr_notice() can wait until the lock is released; this code path cannot
    be reached twice, as crng_fast_load() aborts early if crng_init > 0.
    
    Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Dominik Brodowski authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    ba20054 View commit details
    Browse the repository at this point in the history
  11. random: use RDSEED instead of RDRAND in entropy extraction

    commit 28f425e upstream.
    
    When /dev/random was directly connected with entropy extraction, without
    any expansion stage, extract_buf() was called for every 10 bytes of data
    read from /dev/random. For that reason, RDRAND was used rather than
    RDSEED. At the same time, crng_reseed() was still only called every 5
    minutes, so there RDSEED made sense.
    
    Those olden days were also a time when the entropy collector did not use
    a cryptographic hash function, which meant most bets were off in terms
    of real preimage resistance. For that reason too it didn't matter
    _that_ much whether RDSEED was mixed in before or after entropy
    extraction; both choices were sort of bad.
    
    But now we have a cryptographic hash function at work, and with that we
    get real preimage resistance. We also now only call extract_entropy()
    every 5 minutes, rather than every 10 bytes. This allows us to do two
    important things.
    
    First, we can switch to using RDSEED in extract_entropy(), as Dominik
    suggested. Second, we can ensure that RDSEED input always goes into the
    cryptographic hash function with other things before being used
    directly. This eliminates a category of attacks in which the CPU knows
    the current state of the crng and knows that we're going to xor RDSEED
    into it, and so it computes a malicious RDSEED. By going through our
    hash function, it would require the CPU to compute a preimage on the
    fly, which isn't going to happen.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Suggested-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    bd6f26c View commit details
    Browse the repository at this point in the history
  12. random: get rid of secondary crngs

    commit a9412d5 upstream.
    
    As the comment said, this is indeed a "hack". Since it was introduced,
    it's been a constant state machine nightmare, with lots of subtle early
    boot issues and a wildly complex set of machinery to keep everything in
    sync. Rather than continuing to play whack-a-mole with this approach,
    this commit simply removes it entirely. This commit is preparation for
    "random: use simpler fast key erasure flow on per-cpu keys" in this
    series, which introduces a simpler (and faster) mechanism to accomplish
    the same thing.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    e5af930 View commit details
    Browse the repository at this point in the history
  13. random: inline leaves of rand_initialize()

    commit 8566417 upstream.
    
    This is a preparatory commit for the following one. We simply inline the
    various functions that rand_initialize() calls that have no other
    callers. The compiler was doing this anyway before. Doing this will
    allow us to reorganize this after. We can then move the trust_cpu and
    parse_trust_cpu definitions a bit closer to where they're actually used,
    which makes the code easier to read.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    18ae4b5 View commit details
    Browse the repository at this point in the history
  14. random: ensure early RDSEED goes through mixer on init

    commit a02cf3d upstream.
    
    Continuing the reasoning of "random: use RDSEED instead of RDRAND in
    entropy extraction" from this series, at init time we also don't want to
    be xoring RDSEED directly into the crng. Instead it's safer to put it
    into our entropy collector and then re-extract it, so that it goes
    through a hash function with preimage resistance. As a matter of hygiene,
    we also order these now so that the RDSEED byte are hashed in first,
    followed by the bytes that are likely more predictable (e.g. utsname()).
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    6057a5d View commit details
    Browse the repository at this point in the history
  15. random: do not xor RDRAND when writing into /dev/random

    commit 91c2afc upstream.
    
    Continuing the reasoning of "random: ensure early RDSEED goes through
    mixer on init", we don't want RDRAND interacting with anything without
    going through the mixer function, as a backdoored CPU could presumably
    cancel out data during an xor, which it'd have a harder time doing when
    being forced through a cryptographic hash function. There's actually no
    need at all to be calling RDRAND in write_pool(), because before we
    extract from the pool, we always do so with 32 bytes of RDSEED hashed in
    at that stage. Xoring at this stage is needless and introduces a minor
    liability.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    badc140 View commit details
    Browse the repository at this point in the history
  16. random: absorb fast pool into input pool after fast load

    commit c30c575 upstream.
    
    During crng_init == 0, we never credit entropy in add_interrupt_
    randomness(), but instead dump it directly into the primary_crng. That's
    fine, except for the fact that we then wind up throwing away that
    entropy later when we switch to extracting from the input pool and
    xoring into (and later in this series overwriting) the primary_crng key.
    The two other early init sites -- add_hwgenerator_randomness()'s use
    crng_fast_load() and add_device_ randomness()'s use of crng_slow_load()
    -- always additionally give their inputs to the input pool. But not
    add_interrupt_randomness().
    
    This commit fixes that shortcoming by calling mix_pool_bytes() after
    crng_fast_load() in add_interrupt_randomness(). That's partially
    verboten on PREEMPT_RT, where it implies taking spinlock_t from an IRQ
    handler. But this also only happens during early boot and then never
    again after that. Plus it's a trylock so it has the same considerations
    as calling crng_fast_load(), which we're already using.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Suggested-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    8643bf4 View commit details
    Browse the repository at this point in the history
  17. random: use simpler fast key erasure flow on per-cpu keys

    commit 186873c upstream.
    
    Rather than the clunky NUMA full ChaCha state system we had prior, this
    commit is closer to the original "fast key erasure RNG" proposal from
    <https://blog.cr.yp.to/20170723-random.html>, by simply treating ChaCha
    keys on a per-cpu basis.
    
    All entropy is extracted to a base crng key of 32 bytes. This base crng
    has a birthdate and a generation counter. When we go to take bytes from
    the crng, we first check if the birthdate is too old; if it is, we
    reseed per usual. Then we start working on a per-cpu crng.
    
    This per-cpu crng makes sure that it has the same generation counter as
    the base crng. If it doesn't, it does fast key erasure with the base
    crng key and uses the output as its new per-cpu key, and then updates
    its local generation counter. Then, using this per-cpu state, we do
    ordinary fast key erasure. Half of this first block is used to overwrite
    the per-cpu crng key for the next call -- this is the fast key erasure
    RNG idea -- and the other half, along with the ChaCha state, is returned
    to the caller. If the caller desires more than this remaining half, it
    can generate more ChaCha blocks, unlocked, using the now detached ChaCha
    state that was just returned. Crypto-wise, this is more or less what we
    were doing before, but this simply makes it more explicit and ensures
    that we always have backtrack protection by not playing games with a
    shared block counter.
    
    The flow looks like this:
    
    ──extract()──► base_crng.key ◄──memcpy()───┐
                       │                       │
                       └──chacha()──────┬─► new_base_key
                                        └─► crngs[n].key ◄──memcpy()───┐
                                                  │                    │
                                                  └──chacha()───┬─► new_key
                                                                └─► random_bytes
                                                                          │
                                                                          └────►
    
    There are a few hairy details around early init. Just as was done
    before, prior to having gathered enough entropy, crng_fast_load() and
    crng_slow_load() dump bytes directly into the base crng, and when we go
    to take bytes from the crng, in that case, we're doing fast key erasure
    with the base crng rather than the fast unlocked per-cpu crngs. This is
    fine as that's only the state of affairs during very early boot; once
    the crng initializes we never use these paths again.
    
    In the process of all this, the APIs into the crng become a bit simpler:
    we have get_random_bytes(buf, len) and get_random_bytes_user(buf, len),
    which both do what you'd expect. All of the details of fast key erasure
    and per-cpu selection happen only in a very short critical section of
    crng_make_state(), which selects the right per-cpu key, does the fast
    key erasure, and returns a local state to the caller's stack. So, we no
    longer have a need for a separate backtrack function, as this happens
    all at once here. The API then allows us to extend backtrack protection
    to batched entropy without really having to do much at all.
    
    The result is a bit simpler than before and has fewer foot guns. The
    init time state machine also gets a lot simpler as we don't need to wait
    for workqueues to come online and do deferred work. And the multi-core
    performance should be increased significantly, by virtue of having hardly
    any locking on the fast path.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Reviewed-by: Jann Horn <jannh@google.com>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    2aca3e6 View commit details
    Browse the repository at this point in the history
  18. random: use hash function for crng_slow_load()

    commit 66e4c2b upstream.
    
    Since we have a hash function that's really fast, and the goal of
    crng_slow_load() is reportedly to "touch all of the crng's state", we
    can just hash the old state together with the new state and call it a
    day. This way we dont need to reason about another LFSR or worry about
    various attacks there. This code is only ever used at early boot and
    then never again.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    5e2ecef View commit details
    Browse the repository at this point in the history
  19. random: make more consistent use of integer types

    commit 04ec96b upstream.
    
    We've been using a flurry of int, unsigned int, size_t, and ssize_t.
    Let's unify all of this into size_t where it makes sense, as it does in
    most places, and leave ssize_t for return values with possible errors.
    
    In addition, keeping with the convention of other functions in this
    file, functions that are dealing with raw bytes now take void *
    consistently instead of a mix of that and u8 *, because much of the time
    we're actually passing some other structure that is then interpreted as
    bytes by the function.
    
    We also take the opportunity to fix the outdated and incorrect comment
    in get_random_bytes_arch().
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Jann Horn <jannh@google.com>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    d1d80e9 View commit details
    Browse the repository at this point in the history
  20. random: remove outdated INT_MAX >> 6 check in urandom_read()

    commit 434537a upstream.
    
    In 79a8468 ("random: check for increase of entropy_count because of
    signed conversion"), a number of checks were added around what values
    were passed to account(), because account() was doing fancy fixed point
    fractional arithmetic, and a user had some ability to pass large values
    directly into it. One of things in that commit was limiting those values
    to INT_MAX >> 6. The first >> 3 was for bytes to bits, and the next >> 3
    was for bits to 1/8 fractional bits.
    
    However, for several years now, urandom reads no longer touch entropy
    accounting, and so this check serves no purpose. The current flow is:
    
    urandom_read_nowarn()-->get_random_bytes_user()-->chacha20_block()
    
    Of course, we don't want that size_t to be truncated when adding it into
    the ssize_t. But we arrive at urandom_read_nowarn() in the first place
    either via ordinary fops, which limits reads to MAX_RW_COUNT, or via
    getrandom() which limits reads to INT_MAX.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Jann Horn <jannh@google.com>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    3272ad7 View commit details
    Browse the repository at this point in the history
  21. random: zero buffer after reading entropy from userspace

    commit 7b5164f upstream.
    
    This buffer may contain entropic data that shouldn't stick around longer
    than needed, so zero out the temporary buffer at the end of write_pool().
    
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Jann Horn <jannh@google.com>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    06460c4 View commit details
    Browse the repository at this point in the history
  22. random: fix locking for crng_init in crng_reseed()

    commit 7191c62 upstream.
    
    crng_init is protected by primary_crng->lock. Therefore, we need
    to hold this lock when increasing crng_init to 2. As we shouldn't
    hold this lock for too long, only hold it for those parts which
    require protection.
    
    Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Dominik Brodowski authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    432b6e6 View commit details
    Browse the repository at this point in the history
  23. random: tie batched entropy generation to base_crng generation

    commit 0791e8b upstream.
    
    Now that we have an explicit base_crng generation counter, we don't need
    a separate one for batched entropy. Rather, we can just move the
    generation forward every time we change crng_init state or update the
    base_crng key.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    d52d9b7 View commit details
    Browse the repository at this point in the history
  24. random: remove ifdef'd out interrupt bench

    commit 95e6060 upstream.
    
    With tools like kbench9000 giving more finegrained responses, and this
    basically never having been used ever since it was initially added,
    let's just get rid of this. There *is* still work to be done on the
    interrupt handler, but this really isn't the way it's being developed.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    5dde7c4 View commit details
    Browse the repository at this point in the history
  25. random: remove unused tracepoints

    commit 14c1746 upstream.
    
    These explicit tracepoints aren't really used and show sign of aging.
    It's work to keep these up to date, and before I attempted to keep them
    up to date, they weren't up to date, which indicates that they're not
    really used. These days there are better ways of introspecting anyway.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    a66146a View commit details
    Browse the repository at this point in the history
  26. random: add proper SPDX header

    commit a07fdae upstream.
    
    Convert the current license into the SPDX notation of "(GPL-2.0 OR
    BSD-3-Clause)". This infers GPL-2.0 from the text "ALTERNATIVELY, this
    product may be distributed under the terms of the GNU General Public
    License, in which case the provisions of the GPL are required INSTEAD OF
    the above restrictions" and it infers BSD-3-Clause from the verbatim
    BSD 3 clause license in the file.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    5753c65 View commit details
    Browse the repository at this point in the history
  27. random: deobfuscate irq u32/u64 contributions

    commit b2f408f upstream.
    
    In the irq handler, we fill out 16 bytes differently on 32-bit and
    64-bit platforms, and for 32-bit vs 64-bit cycle counters, which doesn't
    always correspond with the bitness of the platform. Whether or not you
    like this strangeness, it is a matter of fact.  But it might not be a
    fact you well realized until now, because the code that loaded the irq
    info into 4 32-bit words was quite confusing.  Instead, this commit
    makes everything explicit by having separate (compile-time) branches for
    32-bit and 64-bit types.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    8a5bdef View commit details
    Browse the repository at this point in the history
  28. random: introduce drain_entropy() helper to declutter crng_reseed()

    commit 246c03d upstream.
    
    In preparation for separating responsibilities, break out the entropy
    count management part of crng_reseed() into its own function.
    
    No functional changes.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    fc8ce09 View commit details
    Browse the repository at this point in the history
  29. random: remove useless header comment

    commit 6071a6c upstream.
    
    This really adds nothing at all useful.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    26db5c0 View commit details
    Browse the repository at this point in the history
  30. random: remove whitespace and reorder includes

    commit 87e7d5a upstream.
    
    This is purely cosmetic. Future work involves figuring out which of
    these headers we need and which we don't.
    
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    93f764a View commit details
    Browse the repository at this point in the history
  31. random: group initialization wait functions

    commit 5f1bb11 upstream.
    
    This pulls all of the readiness waiting-focused functions into the first
    labeled section.
    
    No functional changes.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    799d1e8 View commit details
    Browse the repository at this point in the history
  32. random: group crng functions

    commit 3655adc upstream.
    
    This pulls all of the crng-focused functions into the second labeled
    section.
    
    No functional changes.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    53418d3 View commit details
    Browse the repository at this point in the history
  33. random: group entropy extraction functions

    commit a5ed7cb upstream.
    
    This pulls all of the entropy extraction-focused functions into the
    third labeled section.
    
    No functional changes.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    7c0cd71 View commit details
    Browse the repository at this point in the history
  34. random: group entropy collection functions

    commit 92c653c upstream.
    
    This pulls all of the entropy collection-focused functions into the
    fourth labeled section.
    
    No functional changes.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    b94106c View commit details
    Browse the repository at this point in the history
  35. random: group userspace read/write functions

    commit a6adf8e upstream.
    
    This pulls all of the userspace read/write-focused functions into the
    fifth labeled section.
    
    No functional changes.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    04c5d0c View commit details
    Browse the repository at this point in the history
  36. random: group sysctl functions

    commit 0deff3c upstream.
    
    This pulls all of the sysctl-focused functions into the sixth labeled
    section.
    
    No functional changes.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    118b78b View commit details
    Browse the repository at this point in the history
  37. random: rewrite header introductory comment

    commit 5f75d9f upstream.
    
    Now that we've re-documented the various sections, we can remove the
    outdated text here and replace it with a high-level overview.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    8bbe2f4 View commit details
    Browse the repository at this point in the history
  38. random: defer fast pool mixing to worker

    commit 58340f8 upstream.
    
    On PREEMPT_RT, it's problematic to take spinlocks from hard irq
    handlers. We can fix this by deferring to a workqueue the dumping of
    the fast pool into the input pool.
    
    We accomplish this with some careful rules on fast_pool->count:
    
      - When it's incremented to >= 64, we schedule the work.
      - If the top bit is set, we never schedule the work, even if >= 64.
      - The worker is responsible for setting it back to 0 when it's done.
    
    There are two small issues around using workqueues for this purpose that
    we work around.
    
    The first issue is that mix_interrupt_randomness() might be migrated to
    another CPU during CPU hotplug. This issue is rectified by checking that
    it hasn't been migrated (after disabling irqs). If it has been migrated,
    then we set the count to zero, so that when the CPU comes online again,
    it can requeue the work. As part of this, we switch to using an
    atomic_t, so that the increment in the irq handler doesn't wipe out the
    zeroing if the CPU comes back online while this worker is running.
    
    The second issue is that, though relatively minor in effect, we probably
    want to make sure we get a consistent view of the pool onto the stack,
    in case it's interrupted by an irq while reading. To do this, we don't
    reenable irqs until after the copy. There are only 18 instructions
    between the cli and sti, so this is a pretty tiny window.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
    Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Reviewed-by: Sultan Alsawaf <sultan@kerneltoast.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    a4217ab View commit details
    Browse the repository at this point in the history
  39. random: do not take pool spinlock at boot

    commit afba0b8 upstream.
    
    Since rand_initialize() is run while interrupts are still off and
    nothing else is running, we don't need to repeatedly take and release
    the pool spinlock, especially in the RDSEED loop.
    
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    89148b5 View commit details
    Browse the repository at this point in the history
  40. random: unify early init crng load accounting

    commit da792c6 upstream.
    
    crng_fast_load() and crng_slow_load() have different semantics:
    
    - crng_fast_load() xors and accounts with crng_init_cnt.
    - crng_slow_load() hashes and doesn't account.
    
    However add_hwgenerator_randomness() can afford to hash (it's called
    from a kthread), and it should account. Additionally, ones that can
    afford to hash don't need to take a trylock but can take a normal lock.
    So, we combine these into one function, crng_pre_init_inject(), which
    allows us to control these in a uniform way. This will make it simpler
    later to simplify this all down when the time comes for that.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    993d28d View commit details
    Browse the repository at this point in the history
  41. random: check for crng_init == 0 in add_device_randomness()

    commit 1daf2f3 upstream.
    
    This has no real functional change, as crng_pre_init_inject() (and
    before that, crng_slow_init()) always checks for == 0, not >= 2. So
    correct the outer unlocked change to reflect that. Before this used
    crng_ready(), which was not correct.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    0014e4f View commit details
    Browse the repository at this point in the history
  42. random: pull add_hwgenerator_randomness() declaration into random.h

    commit b777c38 upstream.
    
    add_hwgenerator_randomness() is a function implemented and documented
    inside of random.c. It is the way that hardware RNGs push data into it.
    Therefore, it should be declared in random.h. Otherwise sparse complains
    with:
    
    random.c:1137:6: warning: symbol 'add_hwgenerator_randomness' was not declared. Should it be static?
    
    The alternative would be to include hw_random.h into random.c, but that
    wouldn't really be good for anything except slowing down compile time.
    
    Cc: Matt Mackall <mpm@selenic.com>
    Cc: Theodore Ts'o <tytso@mit.edu>
    Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    101d38d View commit details
    Browse the repository at this point in the history
  43. random: clear fast pool, crng, and batches in cpuhp bring up

    commit 3191dd5 upstream.
    
    For the irq randomness fast pool, rather than having to use expensive
    atomics, which were visibly the most expensive thing in the entire irq
    handler, simply take care of the extreme edge case of resetting count to
    zero in the cpuhp online handler, just after workqueues have been
    reenabled. This simplifies the code a bit and lets us use vanilla
    variables rather than atomics, and performance should be improved.
    
    As well, very early on when the CPU comes up, while interrupts are still
    disabled, we clear out the per-cpu crng and its batches, so that it
    always starts with fresh randomness.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Sultan Alsawaf <sultan@kerneltoast.com>
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    dc64f36 View commit details
    Browse the repository at this point in the history
  44. random: round-robin registers as ulong, not u32

    commit da3951e upstream.
    
    When the interrupt handler does not have a valid cycle counter, it calls
    get_reg() to read a register from the irq stack, in round-robin.
    Currently it does this assuming that registers are 32-bit. This is
    _probably_ the case, and probably all platforms without cycle counters
    are in fact 32-bit platforms. But maybe not, and either way, it's not
    quite correct. This commit fixes that to deal with `unsigned long`
    rather than `u32`.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    83b4dbb View commit details
    Browse the repository at this point in the history
  45. random: only wake up writers after zap if threshold was passed

    commit a3f9e89 upstream.
    
    The only time that we need to wake up /dev/random writers on
    RNDCLEARPOOL/RNDZAPPOOL is when we're changing from a value that is
    greater than or equal to POOL_MIN_BITS to zero, because if we're
    changing from below POOL_MIN_BITS to zero, the writers are already
    unblocked.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    14b565a View commit details
    Browse the repository at this point in the history
  46. random: cleanup UUID handling

    commit 64276a9 upstream.
    
    Rather than hard coding various lengths, we can use the right constants.
    Strings should be `char *` while buffers should be `u8 *`. Rather than
    have a nonsensical and unused maxlength, just remove it. Finally, use
    snprintf instead of sprintf, just out of good hygiene.
    
    As well, remove the old comment about returning a binary UUID via the
    binary sysctl syscall. That syscall was removed from the kernel in 5.5,
    and actually, the "uuid_strategy" function and related infrastructure
    for even serving it via the binary sysctl syscall was removed with
    894d249 ("sysctl drivers: Remove dead binary sysctl support") back
    in 2.6.33.
    
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    e75a5b2 View commit details
    Browse the repository at this point in the history
  47. random: unify cycles_t and jiffies usage and types

    commit abded93 upstream.
    
    random_get_entropy() returns a cycles_t, not an unsigned long, which is
    sometimes 64 bits on various 32-bit platforms, including x86.
    Conversely, jiffies is always unsigned long. This commit fixes things to
    use cycles_t for fields that use random_get_entropy(), named "cycles",
    and unsigned long for fields that use jiffies, named "now". It's also
    good to mix in a cycles_t and a jiffies in the same way for both
    add_device_randomness and add_timer_randomness, rather than using xor in
    one case. Finally, we unify the order of these volatile reads, always
    reading the more precise cycles counter, and then jiffies, so that the
    cycle counter is as close to the event as possible.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    4dec7f2 View commit details
    Browse the repository at this point in the history
  48. random: do crng pre-init loading in worker rather than irq

    commit c2a7de4 upstream.
    
    Taking spinlocks from IRQ context is generally problematic for
    PREEMPT_RT. That is, in part, why we take trylocks instead. However, a
    spin_try_lock() is also problematic since another spin_lock() invocation
    can potentially PI-boost the wrong task, as the spin_try_lock() is
    invoked from an IRQ-context, so the task on CPU (random task or idle) is
    not the actual owner.
    
    Additionally, by deferring the crng pre-init loading to the worker, we
    can use the cryptographic hash function rather than xor, which is
    perhaps a meaningful difference when considering this data has only been
    through the relatively weak fast_mix() function.
    
    The biggest downside of this approach is that the pre-init loading is
    now deferred until later, which means things that need random numbers
    after interrupts are enabled, but before workqueues are running -- or
    before this particular worker manages to run -- are going to get into
    trouble. Hopefully in the real world, this window is rather small,
    especially since this code won't run until 64 interrupts had occurred.
    
    Cc: Sultan Alsawaf <sultan@kerneltoast.com>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Eric Biggers <ebiggers@kernel.org>
    Cc: Theodore Ts'o <tytso@mit.edu>
    Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    a12d3e7 View commit details
    Browse the repository at this point in the history
  49. random: give sysctl_random_min_urandom_seed a more sensible value

    commit d0efdf3 upstream.
    
    This isn't used by anything or anywhere, but we can't delete it due to
    compatibility. So at least give it the correct value of what it's
    supposed to be instead of a garbage one.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    eca9204 View commit details
    Browse the repository at this point in the history
  50. random: don't let 644 read-only sysctls be written to

    commit 77553cf upstream.
    
    We leave around these old sysctls for compatibility, and we keep them
    "writable" for compatibility, but even after writing, we should keep
    reporting the same value. This is consistent with how userspaces tend to
    use sysctl_random_write_wakeup_bits, writing to it, and then later
    reading from it and using the value.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    bdfa599 View commit details
    Browse the repository at this point in the history
  51. random: replace custom notifier chain with standard one

    commit 5acd354 upstream.
    
    We previously rolled our own randomness readiness notifier, which only
    has two users in the whole kernel. Replace this with a more standard
    atomic notifier block that serves the same purpose with less code. Also
    unexport the symbols, because no modules use it, only unconditional
    builtins. The only drawback is that it's possible for a notification
    handler returning the "stop" code to prevent further processing, but
    given that there are only two users, and that we're unexporting this
    anyway, that doesn't seem like a significant drawback for the
    simplification we receive here.
    
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    367c559 View commit details
    Browse the repository at this point in the history
  52. random: use SipHash as interrupt entropy accumulator

    commit f5eab0e upstream.
    
    The current fast_mix() function is a piece of classic mailing list
    crypto, where it just sort of sprung up by an anonymous author without a
    lot of real analysis of what precisely it was accomplishing. As an ARX
    permutation alone, there are some easily searchable differential trails
    in it, and as a means of preventing malicious interrupts, it completely
    fails, since it xors new data into the entire state every time. It can't
    really be analyzed as a random permutation, because it clearly isn't,
    and it can't be analyzed as an interesting linear algebraic structure
    either, because it's also not that. There really is very little one can
    say about it in terms of entropy accumulation. It might diffuse bits,
    some of the time, maybe, we hope, I guess. But for the most part, it
    fails to accomplish anything concrete.
    
    As a reminder, the simple goal of add_interrupt_randomness() is to
    simply accumulate entropy until ~64 interrupts have elapsed, and then
    dump it into the main input pool, which uses a cryptographic hash.
    
    It would be nice to have something cryptographically strong in the
    interrupt handler itself, in case a malicious interrupt compromises a
    per-cpu fast pool within the 64 interrupts / 1 second window, and then
    inside of that same window somehow can control its return address and
    cycle counter, even if that's a bit far fetched. However, with a very
    CPU-limited budget, actually doing that remains an active research
    project (and perhaps there'll be something useful for Linux to come out
    of it). And while the abundance of caution would be nice, this isn't
    *currently* the security model, and we don't yet have a fast enough
    solution to make it our security model. Plus there's not exactly a
    pressing need to do that. (And for the avoidance of doubt, the actual
    cluster of 64 accumulated interrupts still gets dumped into our
    cryptographically secure input pool.)
    
    So, for now we are going to stick with the existing interrupt security
    model, which assumes that each cluster of 64 interrupt data samples is
    mostly non-malicious and not colluding with an infoleaker. With this as
    our goal, we have a few more choices, simply aiming to accumulate
    entropy, while discarding the least amount of it.
    
    We know from <https://eprint.iacr.org/2019/198> that random oracles,
    instantiated as computational hash functions, make good entropy
    accumulators and extractors, which is the justification for using
    BLAKE2s in the main input pool. As mentioned, we don't have that luxury
    here, but we also don't have the same security model requirements,
    because we're assuming that there aren't malicious inputs. A
    pseudorandom function instance can approximately behave like a random
    oracle, provided that the key is uniformly random. But since we're not
    concerned with malicious inputs, we can pick a fixed key, which is not
    secret, knowing that "nature" won't interact with a sufficiently chosen
    fixed key by accident. So we pick a PRF with a fixed initial key, and
    accumulate into it continuously, dumping the result every 64 interrupts
    into our cryptographically secure input pool.
    
    For this, we make use of SipHash-1-x on 64-bit and HalfSipHash-1-x on
    32-bit, which are already in use in the kernel's hsiphash family of
    functions and achieve the same performance as the function they replace.
    It would be nice to do two rounds, but we don't exactly have the CPU
    budget handy for that, and one round alone is already sufficient.
    
    As mentioned, we start with a fixed initial key (zeros is fine), and
    allow SipHash's symmetry breaking constants to turn that into a useful
    starting point. Also, since we're dumping the result (or half of it on
    64-bit so as to tax our hash function the same amount on all platforms)
    into the cryptographically secure input pool, there's no point in
    finalizing SipHash's output, since it'll wind up being finalized by
    something much stronger. This means that all we need to do is use the
    ordinary round function word-by-word, as normal SipHash does.
    Simplified, the flow is as follows:
    
    Initialize:
    
        siphash_state_t state;
        siphash_init(&state, key={0, 0, 0, 0});
    
    Update (accumulate) on interrupt:
    
        siphash_update(&state, interrupt_data_and_timing);
    
    Dump into input pool after 64 interrupts:
    
        blake2s_update(&input_pool, &state, sizeof(state) / 2);
    
    The result of all of this is that the security model is unchanged from
    before -- we assume non-malicious inputs -- yet we now implement that
    model with a stronger argument. I would like to emphasize, again, that
    the purpose of this commit is to improve the existing design, by making
    it analyzable, without changing any fundamental assumptions. There may
    well be value down the road in changing up the existing design, using
    something cryptographically strong, or simply using a ring buffer of
    samples rather than having a fast_mix() at all, or changing which and
    how much data we collect each interrupt so that we can use something
    linear, or a variety of other ideas. This commit does not invalidate the
    potential for those in the future.
    
    For example, in the future, if we're able to characterize the data we're
    collecting on each interrupt, we may be able to inch toward information
    theoretic accumulators. <https://eprint.iacr.org/2021/523> shows that `s
    = ror32(s, 7) ^ x` and `s = ror64(s, 19) ^ x` make very good
    accumulators for 2-monotone distributions, which would apply to
    timestamp counters, like random_get_entropy() or jiffies, but would not
    apply to our current combination of the two values, or to the various
    function addresses and register values we mix in. Alternatively,
    <https://eprint.iacr.org/2021/1002> shows that max-period linear
    functions with no non-trivial invariant subspace make good extractors,
    used in the form `s = f(s) ^ x`. However, this only works if the input
    data is both identical and independent, and obviously a collection of
    address values and counters fails; so it goes with theoretical papers.
    Future directions here may involve trying to characterize more precisely
    what we actually need to collect in the interrupt handler, and building
    something specific around that.
    
    However, as mentioned, the morass of data we're gathering at the
    interrupt handler presently defies characterization, and so we use
    SipHash for now, which works well and performs well.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Reviewed-by: Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    db9b977 View commit details
    Browse the repository at this point in the history
  53. random: make consistent usage of crng_ready()

    commit a96cfe2 upstream.
    
    Rather than sometimes checking `crng_init < 2`, we should always use the
    crng_ready() macro, so that should we change anything later, it's
    consistent. Additionally, that macro already has a likely() around it,
    which means we don't need to open code our own likely() and unlikely()
    annotations.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    0d19aee View commit details
    Browse the repository at this point in the history
  54. random: reseed more often immediately after booting

    commit 7a7ff64 upstream.
    
    In order to chip away at the "premature first" problem, we augment our
    existing entropy accounting with more frequent reseedings at boot.
    
    The idea is that at boot, we're getting entropy from various places, and
    we're not very sure which of early boot entropy is good and which isn't.
    Even when we're crediting the entropy, we're still not totally certain
    that it's any good. Since boot is the one time (aside from a compromise)
    that we have zero entropy, it's important that we shepherd entropy into
    the crng fairly often.
    
    At the same time, we don't want a "premature next" problem, whereby an
    attacker can brute force individual bits of added entropy. In lieu of
    going full-on Fortuna (for now), we can pick a simpler strategy of just
    reseeding more often during the first 5 minutes after boot. This is
    still bounded by the 256-bit entropy credit requirement, so we'll skip a
    reseeding if we haven't reached that, but in case entropy /is/ coming
    in, this ensures that it makes its way into the crng rather rapidly
    during these early stages.
    
    Ordinarily we reseed if the previous reseeding is 300 seconds old. This
    commit changes things so that for the first 600 seconds of boot time, we
    reseed if the previous reseeding is uptime / 2 seconds old. That means
    that we'll reseed at the very least double the uptime of the previous
    reseeding.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    ff1ca4a View commit details
    Browse the repository at this point in the history
  55. random: check for signal and try earlier when generating entropy

    commit 3e504d2 upstream.
    
    Rather than waiting a full second in an interruptable waiter before
    trying to generate entropy, try to generate entropy first and wait
    second. While waiting one second might give an extra second for getting
    entropy from elsewhere, we're already pretty late in the init process
    here, and whatever else is generating entropy will still continue to
    contribute. This has implications on signal handling: we call
    try_to_generate_entropy() from wait_for_random_bytes(), and
    wait_for_random_bytes() always uses wait_event_interruptible_timeout()
    when waiting, since it's called by userspace code in restartable
    contexts, where signals can pend. Since try_to_generate_entropy() now
    runs first, if a signal is pending, it's necessary for
    try_to_generate_entropy() to check for signals, since it won't hit the
    wait until after try_to_generate_entropy() has returned. And even before
    this change, when entering a busy loop in try_to_generate_entropy(), we
    should have been checking to see if any signals are pending, so that a
    process doesn't get stuck in that loop longer than expected.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    ded7b5c View commit details
    Browse the repository at this point in the history
  56. random: skip fast_init if hwrng provides large chunk of entropy

    commit af704c8 upstream.
    
    At boot time, EFI calls add_bootloader_randomness(), which in turn calls
    add_hwgenerator_randomness(). Currently add_hwgenerator_randomness()
    feeds the first 64 bytes of randomness to the "fast init"
    non-crypto-grade phase. But if add_hwgenerator_randomness() gets called
    with more than POOL_MIN_BITS of entropy, there's no point in passing it
    off to the "fast init" stage, since that's enough entropy to bootstrap
    the real RNG. The "fast init" stage is just there to provide _something_
    in the case where we don't have enough entropy to properly bootstrap the
    RNG. But if we do have enough entropy to bootstrap the RNG, the current
    logic doesn't serve a purpose. So, in the case where we're passed
    greater than or equal to POOL_MIN_BITS of entropy, this commit makes us
    skip the "fast init" phase.
    
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    d82e9ea View commit details
    Browse the repository at this point in the history
  57. random: treat bootloader trust toggle the same way as cpu trust toggle

    commit d97c68d upstream.
    
    If CONFIG_RANDOM_TRUST_CPU is set, the RNG initializes using RDRAND.
    But, the user can disable (or enable) this behavior by setting
    `random.trust_cpu=0/1` on the kernel command line. This allows system
    builders to do reasonable things while avoiding howls from tinfoil
    hatters. (Or vice versa.)
    
    CONFIG_RANDOM_TRUST_BOOTLOADER is basically the same thing, but regards
    the seed passed via EFI or device tree, which might come from RDRAND or
    a TPM or somewhere else. In order to allow distros to more easily enable
    this while avoiding those same howls (or vice versa), this commit adds
    the corresponding `random.trust_bootloader=0/1` toggle.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Graham Christensen <graham@grahamc.com>
    Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Link: NixOS/nixpkgs#165355
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    9b1d7b3 View commit details
    Browse the repository at this point in the history
  58. random: re-add removed comment about get_random_{u32,u64} reseeding

    commit dd7aa36 upstream.
    
    The comment about get_random_{u32,u64}() not invoking reseeding got
    added in an unrelated commit, that then was recently reverted by
    0313bc2 ("Revert "random: block in /dev/urandom""). So this adds
    that little comment snippet back, and improves the wording a bit too.
    
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    a1baaef View commit details
    Browse the repository at this point in the history
  59. random: mix build-time latent entropy into pool at init

    commit 1754abb upstream.
    
    Prior, the "input_pool_data" array needed no real initialization, and so
    it was easy to mark it with __latent_entropy to populate it during
    compile-time. In switching to using a hash function, this required us to
    specifically initialize it to some specific state, which means we
    dropped the __latent_entropy attribute. An unfortunate side effect was
    this meant the pool was no longer seeded using compile-time random data.
    In order to bring this back, we declare an array in rand_initialize()
    with __latent_entropy and call mix_pool_bytes() on that at init, which
    accomplishes the same thing as before. We make this __initconst, so that
    it doesn't take up space at runtime after init.
    
    Fixes: 6e8ec25 ("random: use computational hash for entropy extraction")
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Reviewed-by: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    24abaf3 View commit details
    Browse the repository at this point in the history
  60. random: do not split fast init input in add_hwgenerator_randomness()

    commit 527a986 upstream.
    
    add_hwgenerator_randomness() tries to only use the required amount of input
    for fast init, but credits all the entropy, rather than a fraction of
    it. Since it's hard to determine how much entropy is left over out of a
    non-unformly random sample, either give it all to fast init or credit
    it, but don't attempt to do both. In the process, we can clean up the
    injection code to no longer need to return a value.
    
    Signed-off-by: Jan Varho <jan.varho@gmail.com>
    [Jason: expanded commit message]
    Fixes: 73c7733 ("random: do not throw away excess input to crng_fast_load")
    Cc: stable@vger.kernel.org # 5.17+, requires af704c8
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    jvarho authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    da31d0d View commit details
    Browse the repository at this point in the history
  61. random: do not allow user to keep crng key around on stack

    commit aba120c upstream.
    
    The fast key erasure RNG design relies on the key that's used to be used
    and then discarded. We do this, making judicious use of
    memzero_explicit().  However, reads to /dev/urandom and calls to
    getrandom() involve a copy_to_user(), and userspace can use FUSE or
    userfaultfd, or make a massive call, dynamically remap memory addresses
    as it goes, and set the process priority to idle, in order to keep a
    kernel stack alive indefinitely. By probing
    /proc/sys/kernel/random/entropy_avail to learn when the crng key is
    refreshed, a malicious userspace could mount this attack every 5 minutes
    thereafter, breaking the crng's forward secrecy.
    
    In order to fix this, we just overwrite the stack's key with the first
    32 bytes of the "free" fast key erasure output. If we're returning <= 32
    bytes to the user, then we can still return those bytes directly, so
    that short reads don't become slower. And for long reads, the difference
    is hopefully lost in the amortization, so it doesn't change much, with
    that amortization helping variously for medium reads.
    
    We don't need to do this for get_random_bytes() and the various
    kernel-space callers, and later, if we ever switch to always batching,
    this won't be necessary either, so there's no need to change the API of
    these functions.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Jann Horn <jannh@google.com>
    Fixes: c92e040 ("random: add backtracking protection to the CRNG")
    Fixes: 186873c ("random: use simpler fast key erasure flow on per-cpu keys")
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    b8567f7 View commit details
    Browse the repository at this point in the history
  62. random: check for signal_pending() outside of need_resched() check

    commit 1448769 upstream.
    
    signal_pending() checks TIF_NOTIFY_SIGNAL and TIF_SIGPENDING, which
    signal that the task should bail out of the syscall when possible. This
    is a separate concept from need_resched(), which checks
    TIF_NEED_RESCHED, signaling that the task should preempt.
    
    In particular, with the current code, the signal_pending() bailout
    probably won't work reliably.
    
    Change this to look like other functions that read lots of data, such as
    read_zero().
    
    Fixes: 1da177e ("Linux-2.6.12-rc2")
    Signed-off-by: Jann Horn <jannh@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    thejh authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    90fc9bf View commit details
    Browse the repository at this point in the history
  63. random: check for signals every PAGE_SIZE chunk of /dev/[u]random

    commit e3c1c4f upstream.
    
    In 1448769 ("random: check for signal_pending() outside of
    need_resched() check"), Jann pointed out that we previously were only
    checking the TIF_NOTIFY_SIGNAL and TIF_SIGPENDING flags if the process
    had TIF_NEED_RESCHED set, which meant in practice, super long reads to
    /dev/[u]random would delay signal handling by a long time. I tried this
    using the below program, and indeed I wasn't able to interrupt a
    /dev/urandom read until after several megabytes had been read. The bug
    he fixed has always been there, and so code that reads from /dev/urandom
    without checking the return value of read() has mostly worked for a long
    time, for most sizes, not just for <= 256.
    
    Maybe it makes sense to keep that code working. The reason it was so
    small prior, ignoring the fact that it didn't work anyway, was likely
    because /dev/random used to block, and that could happen for pretty
    large lengths of time while entropy was gathered. But now, it's just a
    chacha20 call, which is extremely fast and is just operating on pure
    data, without having to wait for some external event. In that sense,
    /dev/[u]random is a lot more like /dev/zero.
    
    Taking a page out of /dev/zero's read_zero() function, it always returns
    at least one chunk, and then checks for signals after each chunk. Chunk
    sizes there are of length PAGE_SIZE. Let's just copy the same thing for
    /dev/[u]random, and check for signals and cond_resched() for every
    PAGE_SIZE amount of data. This makes the behavior more consistent with
    expectations, and should mitigate the impact of Jann's fix for the
    age-old signal check bug.
    
    ---- test program ----
    
      #include <unistd.h>
      #include <signal.h>
      #include <stdio.h>
      #include <sys/random.h>
    
      static unsigned char x[~0U];
    
      static void handle(int) { }
    
      int main(int argc, char *argv[])
      {
        pid_t pid = getpid(), child;
        signal(SIGUSR1, handle);
        if (!(child = fork())) {
          for (;;)
            kill(pid, SIGUSR1);
        }
        pause();
        printf("interrupted after reading %zd bytes\n", getrandom(x, sizeof(x), 0));
        kill(child, SIGTERM);
        return 0;
      }
    
    Cc: Jann Horn <jannh@google.com>
    Cc: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    6ce4add View commit details
    Browse the repository at this point in the history
  64. random: allow partial reads if later user copies fail

    commit 5209aed upstream.
    
    Rather than failing entirely if a copy_to_user() fails at some point,
    instead we should return a partial read for the amount that succeeded
    prior, unless none succeeded at all, in which case we return -EFAULT as
    before.
    
    This makes it consistent with other reader interfaces. For example, the
    following snippet for /dev/zero outputs "4" followed by "1":
    
      int fd;
      void *x = mmap(NULL, 4096, PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
      assert(x != MAP_FAILED);
      fd = open("/dev/zero", O_RDONLY);
      assert(fd >= 0);
      printf("%zd\n", read(fd, x, 4));
      printf("%zd\n", read(fd, x + 4095, 4));
      close(fd);
    
    This brings that same standard behavior to the various RNG reader
    interfaces.
    
    While we're at it, we can streamline the loop logic a little bit.
    
    Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Jann Horn <jannh@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    96260d6 View commit details
    Browse the repository at this point in the history
  65. random: make random_get_entropy() return an unsigned long

    commit b0c3e79 upstream.
    
    Some implementations were returning type `unsigned long`, while others
    that fell back to get_cycles() were implicitly returning a `cycles_t` or
    an untyped constant int literal. That makes for weird and confusing
    code, and basically all code in the kernel already handled it like it
    was an `unsigned long`. I recently tried to handle it as the largest
    type it could be, a `cycles_t`, but doing so doesn't really help with
    much.
    
    Instead let's just make random_get_entropy() return an unsigned long all
    the time. This also matches the commonly used `arch_get_random_long()`
    function, so now RDRAND and RDTSC return the same sized integer, which
    means one can fallback to the other more gracefully.
    
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Cc: Theodore Ts'o <tytso@mit.edu>
    Acked-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    284ca0b View commit details
    Browse the repository at this point in the history
  66. random: document crng_fast_key_erasure() destination possibility

    commit 8717627 upstream.
    
    This reverts 35a33ff ("random: use memmove instead of memcpy for
    remaining 32 bytes"), which was made on a totally bogus basis. The thing
    it was worried about overlapping came from the stack, not from one of
    its arguments, as Eric pointed out.
    
    But the fact that this confusion even happened draws attention to the
    fact that it's a bit non-obvious that the random_data parameter can
    alias chacha_state, and in fact should do so when the caller can't rely
    on the stack being cleared in a timely manner. So this commit documents
    that.
    
    Reported-by: Eric Biggers <ebiggers@kernel.org>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    dcc76aa View commit details
    Browse the repository at this point in the history
  67. random: fix sysctl documentation nits

    commit 069c4ea upstream.
    
    A semicolon was missing, and the almost-alphabetical-but-not ordering
    was confusing, so regroup these by category instead.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    80f5814 View commit details
    Browse the repository at this point in the history
  68. init: call time_init() before rand_initialize()

    commit fe222a6 upstream.
    
    Currently time_init() is called after rand_initialize(), but
    rand_initialize() makes use of the timer on various platforms, and
    sometimes this timer needs to be initialized by time_init() first. In
    order for random_get_entropy() to not return zero during early boot when
    it's potentially used as an entropy source, reverse the order of these
    two calls. The block doing random initialization was right before
    time_init() before, so changing the order shouldn't have any complicated
    effects.
    
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Reviewed-by: Stafford Horne <shorne@gmail.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    12ea854 View commit details
    Browse the repository at this point in the history
  69. ia64: define get_cycles macro for arch-override

    commit 57c0900 upstream.
    
    Itanium defines a get_cycles() function, but it does not do the usual
    `#define get_cycles get_cycles` dance, making it impossible for generic
    code to see if an arch-specific function was defined. While the
    get_cycles() ifdef is not currently used, the following timekeeping
    patch in this series will depend on the macro existing (or not existing)
    when defining random_get_entropy().
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    01f814b View commit details
    Browse the repository at this point in the history
  70. s390: define get_cycles macro for arch-override

    commit 2e3df52 upstream.
    
    S390x defines a get_cycles() function, but it does not do the usual
    `#define get_cycles get_cycles` dance, making it impossible for generic
    code to see if an arch-specific function was defined. While the
    get_cycles() ifdef is not currently used, the following timekeeping
    patch in this series will depend on the macro existing (or not existing)
    when defining random_get_entropy().
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Vasily Gorbik <gor@linux.ibm.com>
    Cc: Alexander Gordeev <agordeev@linux.ibm.com>
    Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
    Cc: Sven Schnelle <svens@linux.ibm.com>
    Acked-by: Heiko Carstens <hca@linux.ibm.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    3129038 View commit details
    Browse the repository at this point in the history
  71. parisc: define get_cycles macro for arch-override

    commit 8865bbe upstream.
    
    PA-RISC defines a get_cycles() function, but it does not do the usual
    `#define get_cycles get_cycles` dance, making it impossible for generic
    code to see if an arch-specific function was defined. While the
    get_cycles() ifdef is not currently used, the following timekeeping
    patch in this series will depend on the macro existing (or not existing)
    when defining random_get_entropy().
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Helge Deller <deller@gmx.de>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    4b40eda View commit details
    Browse the repository at this point in the history
  72. alpha: define get_cycles macro for arch-override

    commit 1097710 upstream.
    
    Alpha defines a get_cycles() function, but it does not do the usual
    `#define get_cycles get_cycles` dance, making it impossible for generic
    code to see if an arch-specific function was defined. While the
    get_cycles() ifdef is not currently used, the following timekeeping
    patch in this series will depend on the macro existing (or not existing)
    when defining random_get_entropy().
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Richard Henderson <rth@twiddle.net>
    Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
    Acked-by: Matt Turner <mattst88@gmail.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    af739f0 View commit details
    Browse the repository at this point in the history
  73. powerpc: define get_cycles macro for arch-override

    commit 4088358 upstream.
    
    PowerPC defines a get_cycles() function, but it does not do the usual
    `#define get_cycles get_cycles` dance, making it impossible for generic
    code to see if an arch-specific function was defined. While the
    get_cycles() ifdef is not currently used, the following timekeeping
    patch in this series will depend on the macro existing (or not existing)
    when defining random_get_entropy().
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Benjamin Herrenschmidt <benh@ozlabs.org>
    Cc: Paul Mackerras <paulus@samba.org>
    Acked-by: Michael Ellerman <mpe@ellerman.id.au>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    d2e082d View commit details
    Browse the repository at this point in the history
  74. timekeeping: Add raw clock fallback for random_get_entropy()

    commit 1366992 upstream.
    
    The addition of random_get_entropy_fallback() provides access to
    whichever time source has the highest frequency, which is useful for
    gathering entropy on platforms without available cycle counters. It's
    not necessarily as good as being able to quickly access a cycle counter
    that the CPU has, but it's still something, even when it falls back to
    being jiffies-based.
    
    In the event that a given arch does not define get_cycles(), falling
    back to the get_cycles() default implementation that returns 0 is really
    not the best we can do. Instead, at least calling
    random_get_entropy_fallback() would be preferable, because that always
    needs to return _something_, even falling back to jiffies eventually.
    It's not as though random_get_entropy_fallback() is super high precision
    or guaranteed to be entropic, but basically anything that's not zero all
    the time is better than returning zero all the time.
    
    Finally, since random_get_entropy_fallback() is used during extremely
    early boot when randomizing freelists in mm_init(), it can be called
    before timekeeping has been initialized. In that case there really is
    nothing we can do; jiffies hasn't even started ticking yet. So just give
    up and return 0.
    
    Suggested-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    9aaae71 View commit details
    Browse the repository at this point in the history
  75. m68k: use fallback for random_get_entropy() instead of zero

    commit 0f392c9 upstream.
    
    In the event that random_get_entropy() can't access a cycle counter or
    similar, falling back to returning 0 is really not the best we can do.
    Instead, at least calling random_get_entropy_fallback() would be
    preferable, because that always needs to return _something_, even
    falling back to jiffies eventually. It's not as though
    random_get_entropy_fallback() is super high precision or guaranteed to
    be entropic, but basically anything that's not zero all the time is
    better than returning zero all the time.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    ff52f69 View commit details
    Browse the repository at this point in the history
  76. riscv: use fallback for random_get_entropy() instead of zero

    commit 6d01238 upstream.
    
    In the event that random_get_entropy() can't access a cycle counter or
    similar, falling back to returning 0 is really not the best we can do.
    Instead, at least calling random_get_entropy_fallback() would be
    preferable, because that always needs to return _something_, even
    falling back to jiffies eventually. It's not as though
    random_get_entropy_fallback() is super high precision or guaranteed to
    be entropic, but basically anything that's not zero all the time is
    better than returning zero all the time.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Paul Walmsley <paul.walmsley@sifive.com>
    Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
    Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    715066a View commit details
    Browse the repository at this point in the history
  77. mips: use fallback for random_get_entropy() instead of just c0 random

    commit 1c99c6a upstream.
    
    For situations in which we don't have a c0 counter register available,
    we've been falling back to reading the c0 "random" register, which is
    usually bounded by the amount of TLB entries and changes every other
    cycle or so. This means it wraps extremely often. We can do better by
    combining this fast-changing counter with a potentially slower-changing
    counter from random_get_entropy_fallback() in the more significant bits.
    This commit combines the two, taking into account that the changing bits
    are in a different bit position depending on the CPU model. In addition,
    we previously were falling back to 0 for ancient CPUs that Linux does
    not support anyway; remove that dead path entirely.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Tested-by: Maciej W. Rozycki <macro@orcam.me.uk>
    Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    131a92a View commit details
    Browse the repository at this point in the history
  78. arm: use fallback for random_get_entropy() instead of zero

    commit ff8a8f5 upstream.
    
    In the event that random_get_entropy() can't access a cycle counter or
    similar, falling back to returning 0 is really not the best we can do.
    Instead, at least calling random_get_entropy_fallback() would be
    preferable, because that always needs to return _something_, even
    falling back to jiffies eventually. It's not as though
    random_get_entropy_fallback() is super high precision or guaranteed to
    be entropic, but basically anything that's not zero all the time is
    better than returning zero all the time.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    357f8b2 View commit details
    Browse the repository at this point in the history
  79. nios2: use fallback for random_get_entropy() instead of zero

    commit c04e727 upstream.
    
    In the event that random_get_entropy() can't access a cycle counter or
    similar, falling back to returning 0 is really not the best we can do.
    Instead, at least calling random_get_entropy_fallback() would be
    preferable, because that always needs to return _something_, even
    falling back to jiffies eventually. It's not as though
    random_get_entropy_fallback() is super high precision or guaranteed to
    be entropic, but basically anything that's not zero all the time is
    better than returning zero all the time.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Dinh Nguyen <dinguyen@kernel.org>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    71cc2c0 View commit details
    Browse the repository at this point in the history
  80. x86/tsc: Use fallback for random_get_entropy() instead of zero

    commit 3bd4abc upstream.
    
    In the event that random_get_entropy() can't access a cycle counter or
    similar, falling back to returning 0 is suboptimal. Instead, fallback
    to calling random_get_entropy_fallback(), which isn't extremely high
    precision or guaranteed to be entropic, but is certainly better than
    returning zero all the time.
    
    If CONFIG_X86_TSC=n, then it's possible for the kernel to run on systems
    without RDTSC, such as 486 and certain 586, so the fallback code is only
    required for that case.
    
    As well, fix up both the new function and the get_cycles() function from
    which it was derived to use cpu_feature_enabled() rather than
    boot_cpu_has(), and use !IS_ENABLED() instead of #ifndef.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: x86@kernel.org
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    9771084 View commit details
    Browse the repository at this point in the history
  81. um: use fallback for random_get_entropy() instead of zero

    commit 9f13fb0 upstream.
    
    In the event that random_get_entropy() can't access a cycle counter or
    similar, falling back to returning 0 is really not the best we can do.
    Instead, at least calling random_get_entropy_fallback() would be
    preferable, because that always needs to return _something_, even
    falling back to jiffies eventually. It's not as though
    random_get_entropy_fallback() is super high precision or guaranteed to
    be entropic, but basically anything that's not zero all the time is
    better than returning zero all the time.
    
    This is accomplished by just including the asm-generic code like on
    other architectures, which means we can get rid of the empty stub
    function here.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Richard Weinberger <richard@nod.at>
    Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
    Acked-by: Johannes Berg <johannes@sipsolutions.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    36b6fc9 View commit details
    Browse the repository at this point in the history
  82. sparc: use fallback for random_get_entropy() instead of zero

    commit ac9756c upstream.
    
    In the event that random_get_entropy() can't access a cycle counter or
    similar, falling back to returning 0 is really not the best we can do.
    Instead, at least calling random_get_entropy_fallback() would be
    preferable, because that always needs to return _something_, even
    falling back to jiffies eventually. It's not as though
    random_get_entropy_fallback() is super high precision or guaranteed to
    be entropic, but basically anything that's not zero all the time is
    better than returning zero all the time.
    
    This is accomplished by just including the asm-generic code like on
    other architectures, which means we can get rid of the empty stub
    function here.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: David S. Miller <davem@davemloft.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    1cdbac2 View commit details
    Browse the repository at this point in the history
  83. xtensa: use fallback for random_get_entropy() instead of zero

    commit e10e2f5 upstream.
    
    In the event that random_get_entropy() can't access a cycle counter or
    similar, falling back to returning 0 is really not the best we can do.
    Instead, at least calling random_get_entropy_fallback() would be
    preferable, because that always needs to return _something_, even
    falling back to jiffies eventually. It's not as though
    random_get_entropy_fallback() is super high precision or guaranteed to
    be entropic, but basically anything that's not zero all the time is
    better than returning zero all the time.
    
    This is accomplished by just including the asm-generic code like on
    other architectures, which means we can get rid of the empty stub
    function here.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Acked-by: Max Filippov <jcmvbkbc@gmail.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    227221a View commit details
    Browse the repository at this point in the history
  84. random: insist on random_get_entropy() existing in order to simplify

    commit 4b758ed upstream.
    
    All platforms are now guaranteed to provide some value for
    random_get_entropy(). In case some bug leads to this not being so, we
    print a warning, because that indicates that something is really very
    wrong (and likely other things are impacted too). This should never be
    hit, but it's a good and cheap way of finding out if something ever is
    problematic.
    
    Since we now have viable fallback code for random_get_entropy() on all
    platforms, which is, in the worst case, not worse than jiffies, we can
    count on getting the best possible value out of it. That means there's
    no longer a use for using jiffies as entropy input. It also means we no
    longer have a reason for doing the round-robin register flow in the IRQ
    handler, which was always of fairly dubious value.
    
    Instead we can greatly simplify the IRQ handler inputs and also unify
    the construction between 64-bits and 32-bits. We now collect the cycle
    counter and the return address, since those are the two things that
    matter. Because the return address and the irq number are likely
    related, to the extent we mix in the irq number, we can just xor it into
    the top unchanging bytes of the return address, rather than the bottom
    changing bytes of the cycle counter as before. Then, we can do a fixed 2
    rounds of SipHash/HSipHash. Finally, we use the same construction of
    hashing only half of the [H]SipHash state on 32-bit and 64-bit. We're
    not actually discarding any entropy, since that entropy is carried
    through until the next time. And more importantly, it lets us do the
    same sponge-like construction everywhere.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    c7a9336 View commit details
    Browse the repository at this point in the history
  85. random: do not use batches when !crng_ready()

    commit cbe89e5 upstream.
    
    It's too hard to keep the batches synchronized, and pointless anyway,
    since in !crng_ready(), we're updating the base_crng key really often,
    where batching only hurts. So instead, if the crng isn't ready, just
    call into get_random_bytes(). At this stage nothing is performance
    critical anyhow.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    6521446 View commit details
    Browse the repository at this point in the history
  86. random: use first 128 bits of input as fast init

    commit 5c3b747 upstream.
    
    Before, the first 64 bytes of input, regardless of how entropic it was,
    would be used to mutate the crng base key directly, and none of those
    bytes would be credited as having entropy. Then 256 bits of credited
    input would be accumulated, and only then would the rng transition from
    the earlier "fast init" phase into being actually initialized.
    
    The thinking was that by mixing and matching fast init and real init, an
    attacker who compromised the fast init state, considered easy to do
    given how little entropy might be in those first 64 bytes, would then be
    able to bruteforce bits from the actual initialization. By keeping these
    separate, bruteforcing became impossible.
    
    However, by not crediting potentially creditable bits from those first 64
    bytes of input, we delay initialization, and actually make the problem
    worse, because it means the user is drawing worse random numbers for a
    longer period of time.
    
    Instead, we can take the first 128 bits as fast init, and allow them to
    be credited, and then hold off on the next 128 bits until they've
    accumulated. This is still a wide enough margin to prevent bruteforcing
    the rng state, while still initializing much faster.
    
    Then, rather than trying to piecemeal inject into the base crng key at
    various points, instead just extract from the pool when we need it, for
    the crng_init==0 phase. Performance may even be better for the various
    inputs here, since there are likely more calls to mix_pool_bytes() then
    there are to get_random_bytes() during this phase of system execution.
    
    Since the preinit injection code is gone, bootloader randomness can then
    do something significantly more straight forward, removing the weird
    system_wq hack in hwgenerator randomness.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    427346f View commit details
    Browse the repository at this point in the history
  87. random: do not pretend to handle premature next security model

    commit e85c0fc upstream.
    
    Per the thread linked below, "premature next" is not considered to be a
    realistic threat model, and leads to more serious security problems.
    
    "Premature next" is the scenario in which:
    
    - Attacker compromises the current state of a fully initialized RNG via
      some kind of infoleak.
    - New bits of entropy are added directly to the key used to generate the
      /dev/urandom stream, without any buffering or pooling.
    - Attacker then, somehow having read access to /dev/urandom, samples RNG
      output and brute forces the individual new bits that were added.
    - Result: the RNG never "recovers" from the initial compromise, a
      so-called violation of what academics term "post-compromise security".
    
    The usual solutions to this involve some form of delaying when entropy
    gets mixed into the crng. With Fortuna, this involves multiple input
    buckets. With what the Linux RNG was trying to do prior, this involves
    entropy estimation.
    
    However, by delaying when entropy gets mixed in, it also means that RNG
    compromises are extremely dangerous during the window of time before
    the RNG has gathered enough entropy, during which time nonces may become
    predictable (or repeated), ephemeral keys may not be secret, and so
    forth. Moreover, it's unclear how realistic "premature next" is from an
    attack perspective, if these attacks even make sense in practice.
    
    Put together -- and discussed in more detail in the thread below --
    these constitute grounds for just doing away with the current code that
    pretends to handle premature next. I say "pretends" because it wasn't
    doing an especially great job at it either; should we change our mind
    about this direction, we would probably implement Fortuna to "fix" the
    "problem", in which case, removing the pretend solution still makes
    sense.
    
    This also reduces the crng reseed period from 5 minutes down to 1
    minute. The rationale from the thread might lead us toward reducing that
    even further in the future (or even eliminating it), but that remains a
    topic of a future commit.
    
    At a high level, this patch changes semantics from:
    
        Before: Seed for the first time after 256 "bits" of estimated
        entropy have been accumulated since the system booted. Thereafter,
        reseed once every five minutes, but only if 256 new "bits" have been
        accumulated since the last reseeding.
    
        After: Seed for the first time after 256 "bits" of estimated entropy
        have been accumulated since the system booted. Thereafter, reseed
        once every minute.
    
    Most of this patch is renaming and removing: POOL_MIN_BITS becomes
    POOL_INIT_BITS, credit_entropy_bits() becomes credit_init_bits(),
    crng_reseed() loses its "force" parameter since it's now always true,
    the drain_entropy() function no longer has any use so it's removed,
    entropy estimation is skipped if we've already init'd, the various
    notifiers for "low on entropy" are now only active prior to init, and
    finally, some documentation comments are cleaned up here and there.
    
    Link: https://lore.kernel.org/lkml/YmlMGx6+uigkGiZ0@zx2c4.com/
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Nadia Heninger <nadiah@cs.ucsd.edu>
    Cc: Tom Ristenpart <ristenpart@cornell.edu>
    Reviewed-by: Eric Biggers <ebiggers@google.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    c3b0492 View commit details
    Browse the repository at this point in the history
  88. random: order timer entropy functions below interrupt functions

    commit a4b5c26 upstream.
    
    There are no code changes here; this is just a reordering of functions,
    so that in subsequent commits, the timer entropy functions can call into
    the interrupt ones.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    1705dc1 View commit details
    Browse the repository at this point in the history
  89. random: do not use input pool from hard IRQs

    commit e3e33fc upstream.
    
    Years ago, a separate fast pool was added for interrupts, so that the
    cost associated with taking the input pool spinlocks and mixing into it
    would be avoided in places where latency is critical. However, one
    oversight was that add_input_randomness() and add_disk_randomness()
    still sometimes are called directly from the interrupt handler, rather
    than being deferred to a thread. This means that some unlucky interrupts
    will be caught doing a blake2s_compress() call and potentially spinning
    on input_pool.lock, which can also be taken by unprivileged users by
    writing into /dev/urandom.
    
    In order to fix this, add_timer_randomness() now checks whether it is
    being called from a hard IRQ and if so, just mixes into the per-cpu IRQ
    fast pool using fast_mix(), which is much faster and can be done
    lock-free. A nice consequence of this, as well, is that it means hard
    IRQ context FPU support is likely no longer useful.
    
    The entropy estimation algorithm used by add_timer_randomness() is also
    somewhat different than the one used for add_interrupt_randomness(). The
    former looks at deltas of deltas of deltas, while the latter just waits
    for 64 interrupts for one bit or for one second since the last bit. In
    order to bridge these, and since add_interrupt_randomness() runs after
    an add_timer_randomness() that's called from hard IRQ, we add to the
    fast pool credit the related amount, and then subtract one to account
    for add_interrupt_randomness()'s contribution.
    
    A downside of this, however, is that the num argument is potentially
    attacker controlled, which puts a bit more pressure on the fast_mix()
    sponge to do more than it's really intended to do. As a mitigating
    factor, the first 96 bits of input aren't attacker controlled (a cycle
    counter followed by zeros), which means it's essentially two rounds of
    siphash rather than one, which is somewhat better. It's also not that
    much different from add_interrupt_randomness()'s use of the irq stack
    instruction pointer register.
    
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Filipe Manana <fdmanana@suse.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Borislav Petkov <bp@alien8.de>
    Cc: Theodore Ts'o <tytso@mit.edu>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    de2ba59 View commit details
    Browse the repository at this point in the history
  90. random: help compiler out with fast_mix() by using simpler arguments

    commit 791332b upstream.
    
    Now that fast_mix() has more than one caller, gcc no longer inlines it.
    That's fine. But it also doesn't handle the compound literal argument we
    pass it very efficiently, nor does it handle the loop as well as it
    could. So just expand the code to spell out this function so that it
    generates the same code as it did before. Performance-wise, this now
    behaves as it did before the last commit. The difference in actual code
    size on x86 is 45 bytes, which is less than a cache line.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    c5ff607 View commit details
    Browse the repository at this point in the history
  91. siphash: use one source of truth for siphash permutations

    commit e73aaae upstream.
    
    The SipHash family of permutations is currently used in three places:
    
    - siphash.c itself, used in the ordinary way it was intended.
    - random32.c, in a construction from an anonymous contributor.
    - random.c, as part of its fast_mix function.
    
    Each one of these places reinvents the wheel with the same C code, same
    rotation constants, and same symmetry-breaking constants.
    
    This commit tidies things up a bit by placing macros for the
    permutations and constants into siphash.h, where each of the three .c
    users can access them. It also leaves a note dissuading more users of
    them from emerging.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    9ebf07a View commit details
    Browse the repository at this point in the history
  92. random: use symbolic constants for crng_init states

    commit e3d2c5e upstream.
    
    crng_init represents a state machine, with three states, and various
    rules for transitions. For the longest time, we've been managing these
    with "0", "1", and "2", and expecting people to figure it out. To make
    the code more obvious, replace these with proper enum values
    representing the transition, and then redocument what each of these
    states mean.
    
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Cc: Joe Perches <joe@perches.com>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    4f8ab1c View commit details
    Browse the repository at this point in the history
  93. random: avoid initializing twice in credit race

    commit fed7ef0 upstream.
    
    Since all changes of crng_init now go through credit_init_bits(), we can
    fix a long standing race in which two concurrent callers of
    credit_init_bits() have the new bit count >= some threshold, but are
    doing so with crng_init as a lower threshold, checked outside of a lock,
    resulting in crng_reseed() or similar being called twice.
    
    In order to fix this, we can use the original cmpxchg value of the bit
    count, and only change crng_init when the bit count transitions from
    below a threshold to meeting the threshold.
    
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    8fe9ac5 View commit details
    Browse the repository at this point in the history
  94. random: move initialization out of reseeding hot path

    commit 68c9c8b upstream.
    
    Initialization happens once -- by way of credit_init_bits() -- and then
    it never happens again. Therefore, it doesn't need to be in
    crng_reseed(), which is a hot path that is called multiple times. It
    also doesn't make sense to have there, as initialization activity is
    better associated with initialization routines.
    
    After the prior commit, crng_reseed() now won't be called by multiple
    concurrent callers, which means that we can safely move the
    "finialize_init" logic into crng_init_bits() unconditionally.
    
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    e6b205d View commit details
    Browse the repository at this point in the history
  95. random: remove ratelimiting for in-kernel unseeded randomness

    commit cc1e127 upstream.
    
    The CONFIG_WARN_ALL_UNSEEDED_RANDOM debug option controls whether the
    kernel warns about all unseeded randomness or just the first instance.
    There's some complicated rate limiting and comparison to the previous
    caller, such that even with CONFIG_WARN_ALL_UNSEEDED_RANDOM enabled,
    developers still don't see all the messages or even an accurate count of
    how many were missed. This is the result of basically parallel
    mechanisms aimed at accomplishing more or less the same thing, added at
    different points in random.c history, which sort of compete with the
    first-instance-only limiting we have now.
    
    It turns out, however, that nobody cares about the first unseeded
    randomness instance of in-kernel users. The same first user has been
    there for ages now, and nobody is doing anything about it. It isn't even
    clear that anybody _can_ do anything about it. Most places that can do
    something about it have switched over to using get_random_bytes_wait()
    or wait_for_random_bytes(), which is the right thing to do, but there is
    still much code that needs randomness sometimes during init, and as a
    geeneral rule, if you're not using one of the _wait functions or the
    readiness notifier callback, you're bound to be doing it wrong just
    based on that fact alone.
    
    So warning about this same first user that can't easily change is simply
    not an effective mechanism for anything at all. Users can't do anything
    about it, as the Kconfig text points out -- the problem isn't in
    userspace code -- and kernel developers don't or more often can't react
    to it.
    
    Instead, show the warning for all instances when CONFIG_WARN_ALL_UNSEEDED_RANDOM
    is set, so that developers can debug things need be, or if it isn't set,
    don't show a warning at all.
    
    At the same time, CONFIG_WARN_ALL_UNSEEDED_RANDOM now implies setting
    random.ratelimit_disable=1 on by default, since if you care about one
    you probably care about the other too. And we can clean up usage around
    the related urandom_warning ratelimiter as well (whose behavior isn't
    changing), so that it properly counts missed messages after the 10
    message threshold is reached.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    b4b11eb View commit details
    Browse the repository at this point in the history
  96. random: use proper jiffies comparison macro

    commit 8a5b8a4 upstream.
    
    This expands to exactly the same code that it replaces, but makes things
    consistent by using the same macro for jiffy comparisons throughout.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    e78d195 View commit details
    Browse the repository at this point in the history
  97. random: handle latent entropy and command line from random_init()

    commit 2f14062 upstream.
    
    Currently, start_kernel() adds latent entropy and the command line to
    the entropy bool *after* the RNG has been initialized, deferring when
    it's actually used by things like stack canaries until the next time
    the pool is seeded. This surely is not intended.
    
    Rather than splitting up which entropy gets added where and when between
    start_kernel() and random_init(), just do everything in random_init(),
    which should eliminate these kinds of bugs in the future.
    
    While we're at it, rename the awkwardly titled "rand_initialize()" to
    the more standard "random_init()" nomenclature.
    
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    e136fbd View commit details
    Browse the repository at this point in the history
  98. random: credit architectural init the exact amount

    commit 12e45a2 upstream.
    
    RDRAND and RDSEED can fail sometimes, which is fine. We currently
    initialize the RNG with 512 bits of RDRAND/RDSEED. We only need 256 bits
    of those to succeed in order to initialize the RNG. Instead of the
    current "all or nothing" approach, actually credit these contributions
    the amount that is actually contributed.
    
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    d3fc4f4 View commit details
    Browse the repository at this point in the history
  99. random: use static branch for crng_ready()

    commit f5bda35 upstream.
    
    Since crng_ready() is only false briefly during initialization and then
    forever after becomes true, we don't need to evaluate it after, making
    it a prime candidate for a static branch.
    
    One complication, however, is that it changes state in a particular call
    to credit_init_bits(), which might be made from atomic context, which
    means we must kick off a workqueue to change the static key. Further
    complicating things, credit_init_bits() may be called sufficiently early
    on in system initialization such that system_wq is NULL.
    
    Fortunately, there exists the nice function execute_in_process_context(),
    which will immediately execute the function if !in_interrupt(), and
    otherwise defer it to a workqueue. During early init, before workqueues
    are available, in_interrupt() is always false, because interrupts
    haven't even been enabled yet, which means the function in that case
    executes immediately. Later on, after workqueues are available,
    in_interrupt() might be true, but in that case, the work is queued in
    system_wq and all goes well.
    
    Cc: Theodore Ts'o <tytso@mit.edu>
    Cc: Sultan Alsawaf <sultan@kerneltoast.com>
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    80ec4c6 View commit details
    Browse the repository at this point in the history
  100. random: remove extern from functions in header

    commit 7782cfe upstream.
    
    Accoriding to the kernel style guide, having `extern` on functions in
    headers is old school and deprecated, and doesn't add anything. So remove
    them from random.h, and tidy up the file a little bit too.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    245b1ae View commit details
    Browse the repository at this point in the history
  101. random: use proper return types on get_random_{int,long}_wait()

    commit 7c3a8a1 upstream.
    
    Before these were returning signed values, but the API is intended to be
    used with unsigned values.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    65d3f67 View commit details
    Browse the repository at this point in the history
  102. random: make consistent use of buf and len

    commit a194026 upstream.
    
    The current code was a mix of "nbytes", "count", "size", "buffer", "in",
    and so forth. Instead, let's clean this up by naming input parameters
    "buf" (or "ubuf") and "len", so that you always understand that you're
    reading this variety of function argument.
    
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    e35c23c View commit details
    Browse the repository at this point in the history
  103. random: move initialization functions out of hot pages

    commit 560181c upstream.
    
    Much of random.c is devoted to initializing the rng and accounting for
    when a sufficient amount of entropy has been added. In a perfect world,
    this would all happen during init, and so we could mark these functions
    as __init. But in reality, this isn't the case: sometimes the rng only
    finishes initializing some seconds after system init is finished.
    
    For this reason, at the moment, a whole host of functions that are only
    used relatively close to system init and then never again are intermixed
    with functions that are used in hot code all the time. This creates more
    cache misses than necessary.
    
    In order to pack the hot code closer together, this commit moves the
    initialization functions that can't be marked as __init into
    .text.unlikely by way of the __cold attribute.
    
    Of particular note is moving credit_init_bits() into a macro wrapper
    that inlines the crng_ready() static branch check. This avoids a
    function call to a nop+ret, and most notably prevents extra entropy
    arithmetic from being computed in mix_interrupt_randomness().
    
    Reviewed-by: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    41f0774 View commit details
    Browse the repository at this point in the history
  104. random: move randomize_page() into mm where it belongs

    commit 5ad7dd8 upstream.
    
    randomize_page is an mm function. It is documented like one. It contains
    the history of one. It has the naming convention of one. It looks
    just like another very similar function in mm, randomize_stack_top().
    And it has always been maintained and updated by mm people. There is no
    need for it to be in random.c. In the "which shape does not look like
    the other ones" test, pointing to randomize_page() is correct.
    
    So move randomize_page() into mm/util.c, right next to the similar
    randomize_stack_top() function.
    
    This commit contains no actual code changes.
    
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    817191b View commit details
    Browse the repository at this point in the history
  105. random: unify batched entropy implementations

    commit 3092adc upstream.
    
    There are currently two separate batched entropy implementations, for
    u32 and u64, with nearly identical code, with the goal of avoiding
    unaligned memory accesses and letting the buffers be used more
    efficiently. Having to maintain these two functions independently is a
    bit of a hassle though, considering that they always need to be kept in
    sync.
    
    This commit factors them out into a type-generic macro, so that the
    expansion produces the same code as before, such that diffing the
    assembly shows no differences. This will also make it easier in the
    future to add u16 and u8 batches.
    
    This was initially tested using an always_inline function and letting
    gcc constant fold the type size in, but the code gen was less efficient,
    and in general it was more verbose and harder to follow. So this patch
    goes with the boring macro solution, similar to what's already done for
    the _wait functions in random.h.
    
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    fb7d06d View commit details
    Browse the repository at this point in the history
  106. random: convert to using fops->read_iter()

    commit 1b388e7 upstream.
    
    This is a pre-requisite to wiring up splice() again for the random
    and urandom drivers. It also allows us to remove the INT_MAX check in
    getrandom(), because import_single_range() applies capping internally.
    
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    [Jason: rewrote get_random_bytes_user() to simplify and also incorporate
     additional suggestions from Al.]
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    axboe authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    afc002f View commit details
    Browse the repository at this point in the history
  107. random: convert to using fops->write_iter()

    commit 22b0a22 upstream.
    
    Now that the read side has been converted to fix a regression with
    splice, convert the write side as well to have some symmetry in the
    interface used (and help deprecate ->write()).
    
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    [Jason: cleaned up random_ioctl a bit, require full writes in
     RNDADDENTROPY since it's crediting entropy, simplify control flow of
     write_pool(), and incorporate suggestions from Al.]
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    axboe authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    27bf1c9 View commit details
    Browse the repository at this point in the history
  108. random: wire up fops->splice_{read,write}_iter()

    commit 79025e7 upstream.
    
    Now that random/urandom is using {read,write}_iter, we can wire it up to
    using the generic splice handlers.
    
    Fixes: 36e2c74 ("fs: don't allow splice read/write without explicit ops")
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    [Jason: added the splice_write path. Note that sendfile() and such still
     does not work for read, though it does for write, because of a file
     type restriction in splice_direct_to_actor(), which I'll address
     separately.]
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    axboe authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    de63c5e View commit details
    Browse the repository at this point in the history
  109. random: check for signals after page of pool writes

    commit 1ce6c8d upstream.
    
    get_random_bytes_user() checks for signals after producing a PAGE_SIZE
    worth of output, just like /dev/zero does. write_pool() is doing
    basically the same work (actually, slightly more expensive), and so
    should stop to check for signals in the same way. Let's also name it
    write_pool_user() to match get_random_bytes_user(), so this won't be
    misused in the future.
    
    Before this patch, massive writes to /dev/urandom would tie up the
    process for an extremely long time and make it unterminatable. After, it
    can be successfully interrupted. The following test program can be used
    to see this works as intended:
    
      #include <unistd.h>
      #include <fcntl.h>
      #include <signal.h>
      #include <stdio.h>
    
      static unsigned char x[~0U];
    
      static void handle(int) { }
    
      int main(int argc, char *argv[])
      {
        pid_t pid = getpid(), child;
        int fd;
        signal(SIGUSR1, handle);
        if (!(child = fork())) {
          for (;;)
            kill(pid, SIGUSR1);
        }
        fd = open("/dev/urandom", O_WRONLY);
        pause();
        printf("interrupted after writing %zd bytes\n", write(fd, x, sizeof(x)));
        close(fd);
        kill(child, SIGTERM);
        return 0;
      }
    
    Result before: "interrupted after writing 2147479552 bytes"
    Result after: "interrupted after writing 4096 bytes"
    
    Cc: Dominik Brodowski <linux@dominikbrodowski.net>
    Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    zx2c4 authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    3879d3f View commit details
    Browse the repository at this point in the history
  110. ACPI: sysfs: Fix BERT error region memory mapping

    commit 1bbc217 upstream.
    
    Currently the sysfs interface maps the BERT error region as "memory"
    (through acpi_os_map_memory()) in order to copy the error records into
    memory buffers through memory operations (eg memory_read_from_buffer()).
    
    The OS system cannot detect whether the BERT error region is part of
    system RAM or it is "device memory" (eg BMC memory) and therefore it
    cannot detect which memory attributes the bus to memory support (and
    corresponding kernel mapping, unless firmware provides the required
    information).
    
    The acpi_os_map_memory() arch backend implementation determines the
    mapping attributes. On arm64, if the BERT error region is not present in
    the EFI memory map, the error region is mapped as device-nGnRnE; this
    triggers alignment faults since memcpy unaligned accesses are not
    allowed in device-nGnRnE regions.
    
    The ACPI sysfs code cannot therefore map by default the BERT error
    region with memory semantics but should use a safer default.
    
    Change the sysfs code to map the BERT error region as MMIO (through
    acpi_os_map_iomem()) and use the memcpy_fromio() interface to read the
    error region into the kernel buffer.
    
    Link: https://lore.kernel.org/linux-arm-kernel/31ffe8fc-f5ee-2858-26c5-0fd8bdd68702@arm.com
    Link: https://lore.kernel.org/linux-acpi/CAJZ5v0g+OVbhuUUDrLUCfX_mVqY_e8ubgLTU98=jfjTeb4t+Pw@mail.gmail.com
    Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Tested-by: Veronika Kabatova <vkabatov@redhat.com>
    Tested-by: Aristeu Rozanski <aris@redhat.com>
    Acked-by: Ard Biesheuvel <ardb@kernel.org>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Cc: dann frazier <dann.frazier@canonical.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Lorenzo Pieralisi authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    567ae03 View commit details
    Browse the repository at this point in the history
  111. ALSA: ctxfi: Add SB046x PCI ID

    commit 1b073eb upstream.
    
    Adds the PCI ID for X-Fi cards sold under the Platnum and XtremeMusic names
    
    Before: snd_ctxfi 0000:05:05.0: chip 20K1 model Unknown (1102:0021) is found
    After: snd_ctxfi 0000:05:05.0: chip 20K1 model SB046x (1102:0021) is found
    
    [ This is only about defining the model name string, and the rest is
      handled just like before, as a default unknown device.
      Edward confirmed that the stuff has been working fine -- tiwai ]
    
    Signed-off-by: Edward Matijevic <motolav@gmail.com>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/cae7d1a4-8bd9-7dfe-7427-db7e766f7272@gmail.com
    Signed-off-by: Takashi Iwai <tiwai@suse.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    motolav authored and gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    d3bbcba View commit details
    Browse the repository at this point in the history
  112. Linux 5.17.12

    Link: https://lore.kernel.org/r/20220527084819.133490171@linuxfoundation.org
    Tested-by: Guenter Roeck <linux@roeck-us.net>
    Tested-by: Justin M. Forbes <jforbes@fedoraproject.org>
    Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
    Tested-by: Ron Economos <re@w6rz.net>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    gregkh committed May 30, 2022
    Configuration menu
    Copy the full SHA
    39555c4 View commit details
    Browse the repository at this point in the history
  113. base packaging

    Kernel Builder (sita) committed May 30, 2022
    Configuration menu
    Copy the full SHA
    d3ec022 View commit details
    Browse the repository at this point in the history
  114. UBUNTU: SAUCE: kbuild: add -fcf-protection=none when using retpoline …

    …flags
    
    BugLink: [Replace -fcf-protection=none patch with new version]
    
    The gcc -fcf-protection=branch option is not compatible with
    -mindirect-branch=thunk-extern. The latter is used when
    CONFIG_RETPOLINE is selected, and this will fail to build with
    a gcc which has -fcf-protection=branch enabled by default. Adding
    -fcf-protection=none when building with retpoline support to
    prevents such build failures.
    
    Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
    Seth Forshee authored and Kernel Builder (sita) committed May 30, 2022
    Configuration menu
    Copy the full SHA
    63a046d View commit details
    Browse the repository at this point in the history
  115. UBUNTU: SAUCE: add vmlinux.strip to BOOT_TARGETS1 on powerpc

    Signed-off-by: Andy Whitcroft <apw@canonical.com>
    Andy Whitcroft authored and Kernel Builder (sita) committed May 30, 2022
    Configuration menu
    Copy the full SHA
    b9de0d8 View commit details
    Browse the repository at this point in the history
  116. UBUNTU: SAUCE: tools/hv/lsvmbus -- add manual page

    BugLink: http://bugs.launchpad.net/bugs/1585311
    
    Signed-off-by: Andy Whitcroft <apw@canonical.com>
    Acked-by: Tim Gardner <tim.gardner@canonical.com>
    Acked-by: Brad Figg <brad.figg@canonical.com>
    Signed-off-by: Kamal Mostafa <kamal@canonical.com>
    Andy Whitcroft authored and Kernel Builder (sita) committed May 30, 2022
    Configuration menu
    Copy the full SHA
    ccc01bf View commit details
    Browse the repository at this point in the history
  117. debian changelog

    Kernel Builder (sita) committed May 30, 2022
    Configuration menu
    Copy the full SHA
    d1be8f9 View commit details
    Browse the repository at this point in the history

Commits on Jun 3, 2022

  1. System76 Linux

    jackpot51 committed Jun 3, 2022
    Configuration menu
    Copy the full SHA
    19337ff View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    30c519b View commit details
    Browse the repository at this point in the history
  3. ALSA: hda/realtek - Reapply pin fixup for oryp5

    The pin fixup is required to detect headset microphones on the oryp5.
    
    Fixes: 80690a2 ("ALSA: hda/realtek - Add quirk for Tuxedo XC 1509")
    Signed-off-by: Tim Crawford <tcrawford@system76.com>
    crawfxrd authored and jackpot51 committed Jun 3, 2022
    Configuration menu
    Copy the full SHA
    b710b89 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    bff408e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    9dd5300 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a298ce8 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    5625b26 View commit details
    Browse the repository at this point in the history
  8. Adds an ALSA mapping for Gigabyte Pro WiFi Rev 2.1

    This patch was written by Takashi Iwai, I am just
    commiting it into the pop-os kernel before this
    is upstreamed
    13r0ck authored and jackpot51 committed Jun 3, 2022
    Configuration menu
    Copy the full SHA
    d5feea6 View commit details
    Browse the repository at this point in the history
  9. DROP ON REBASE: 5.17.12-76051712.202205300835 based on 5.17.12-051712…

    ….202205300835
    
    Signed-off-by: Jeremy Soller <jackpot51@gmail.com>
    jackpot51 committed Jun 3, 2022
    Configuration menu
    Copy the full SHA
    0af4cbc View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    3235706 View commit details
    Browse the repository at this point in the history