09 Jun, 2022

40 commits

  • commit 2965c4cdf7ad9ce0796fac5e57debb9519ea721e upstream.

    In ieee80211_vif_use_reserved_context(), when we have an
    old context and the new context's replace_state is set to
    IEEE80211_CHANCTX_REPLACE_NONE, we free the old context
    in ieee80211_vif_use_reserved_reassign(). Therefore, we
    cannot check the old_ctx anymore, so we should set it to
    NULL after this point.

    However, since the new_ctx replace state is clearly not
    IEEE80211_CHANCTX_REPLACES_OTHER, we're not going to do
    anything else in this function and can just return to
    avoid accessing the freed old_ctx.

    Cc: stable@vger.kernel.org
    Fixes: 5bcae31d9cb1 ("mac80211: implement multi-vif in-place reservations")
    Signed-off-by: Johannes Berg
    Signed-off-by: Kalle Valo
    Link: https://lore.kernel.org/r/20220601091926.df419d91b165.I17a9b3894ff0b8323ce2afdb153b101124c821e5@changeid
    Signed-off-by: Greg Kroah-Hartman

    Johannes Berg
     
  • commit ead165fa1042247b033afad7be4be9b815d04ade upstream.

    Nathan reported objtool failing with the following messages:

    warning: objtool: no non-local symbols !?
    warning: objtool: gelf_update_symshndx: invalid section index

    The problem is due to commit 4abff6d48dbc ("objtool: Fix code relocs
    vs weak symbols") failing to consider the case where an object would
    have no non-local symbols.

    The problem that commit tries to address is adding a STB_LOCAL symbol
    to the symbol table in light of the ELF spec's requirement that:

    In each symbol table, all symbols with STB_LOCAL binding preced the
    weak and global symbols. As ``Sections'' above describes, a symbol
    table section's sh_info section header member holds the symbol table
    index for the first non-local symbol.

    The approach taken is to find this first non-local symbol, move that
    to the end and then re-use the freed spot to insert a new local symbol
    and increment sh_info.

    Except it never considered the case of object files without global
    symbols and got a whole bunch of details wrong -- so many in fact that
    it is a wonder it ever worked :/

    Specifically:

    - It failed to re-hash the symbol on the new index, so a subsequent
    find_symbol_by_index() would not find it at the new location and a
    query for the old location would now return a non-deterministic
    choice between the old and new symbol.

    - It failed to appreciate that the GElf wrappers are not a valid disk
    format (it works because GElf is basically Elf64 and we only
    support x86_64 atm.)

    - It failed to fully appreciate how horrible the libelf API really is
    and got the gelf_update_symshndx() call pretty much completely
    wrong; with the direct consequence that if inserting a second
    STB_LOCAL symbol would require moving the same STB_GLOBAL symbol
    again it would completely come unstuck.

    Write a new elf_update_symbol() function that wraps all the magic
    required to update or create a new symbol at a given index.

    Specifically, gelf_update_sym*() require an @ndx argument that is
    relative to the @data argument; this means you have to manually
    iterate the section data descriptor list and update @ndx.

    Fixes: 4abff6d48dbc ("objtool: Fix code relocs vs weak symbols")
    Reported-by: Nathan Chancellor
    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Borislav Petkov
    Acked-by: Josh Poimboeuf
    Tested-by: Nathan Chancellor
    Cc:
    Link: https://lkml.kernel.org/r/YoPCTEYjoPqE4ZxB@hirez.programming.kicks-ass.net
    Signed-off-by: Greg Kroah-Hartman

    Peter Zijlstra
     
  • commit 22682a07acc308ef78681572e19502ce8893c4d4 upstream.

    Commit c087c6e7b551 ("objtool: Fix type of reloc::addend") failed to
    appreciate cross building from ILP32 hosts, where 'int' == 'long' and
    the issue persists.

    As such, use s64/int64_t/Elf64_Sxword for this field and suffer the
    pain that is ISO C99 printf formats for it.

    Fixes: c087c6e7b551 ("objtool: Fix type of reloc::addend")
    Signed-off-by: Mikulas Patocka
    [peterz: reword changelog, s/long long/s64/]
    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Borislav Petkov
    Cc:
    Link: https://lkml.kernel.org/r/alpine.LRH.2.02.2205161041260.11556@file01.intranet.prod.int.rdu2.redhat.com
    Signed-off-by: Greg Kroah-Hartman

    Mikulas Patocka
     
  • commit 677a82b44ebf263d4f9a0cfbd576a6ade797a07b upstream.

    Yanming reported a kernel bug in Bugzilla kernel [1], which can be
    reproduced. The bug message is:

    The kernel message is shown below:

    kernel BUG at fs/inode.c:611!
    Call Trace:
    evict+0x282/0x4e0
    __dentry_kill+0x2b2/0x4d0
    dput+0x2dd/0x720
    do_renameat2+0x596/0x970
    __x64_sys_rename+0x78/0x90
    do_syscall_64+0x3b/0x90

    [1] https://bugzilla.kernel.org/show_bug.cgi?id=215895

    The bug is due to fuzzed inode has both inline_data and encrypted flags.
    During f2fs_evict_inode(), as the inode was deleted by rename(), it
    will cause inline data conversion due to conflicting flags. The page
    cache will be polluted and the panic will be triggered in clear_inode().

    Try fixing the bug by doing more sanity checks for inline data inode in
    sanity_check_inode().

    Cc: stable@vger.kernel.org
    Reported-by: Ming Yan
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Chao Yu
     
  • commit 958ed92922028ec67f504dcdc72bfdfd0f43936a upstream.

    This patch tries to fix permission consistency issue as all other
    mainline filesystems.

    Since the initial introduction of (posix) fallocate back at the turn of
    the century, it has been possible to use this syscall to change the
    user-visible contents of files. This can happen by extending the file
    size during a preallocation, or through any of the newer modes (punch,
    zero, collapse, insert range). Because the call can be used to change
    file contents, we should treat it like we do any other modification to a
    file -- update the mtime, and drop set[ug]id privileges/capabilities.

    The VFS function file_modified() does all this for us if pass it a
    locked inode, so let's make fallocate drop permissions correctly.

    Cc: stable@kernel.org
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Chao Yu
     
  • commit b5639bb4313b9d455fc9fc4768d23a5e4ca8cb9d upstream.

    Tryng to rename a directory that has all following properties fails with
    EINVAL and triggers the 'WARN_ON_ONCE(!fscrypt_has_encryption_key(dir))'
    in f2fs_match_ci_name():

    - The directory is casefolded
    - The directory is encrypted
    - The directory's encryption key is not yet set up
    - The parent directory is *not* encrypted

    The problem is incorrect handling of the lookup of ".." to get the
    parent reference to update. fscrypt_setup_filename() treats ".." (and
    ".") specially, as it's never encrypted. It's passed through as-is, and
    setting up the directory's key is not attempted. As the name isn't a
    no-key name, f2fs treats it as a "normal" name and attempts a casefolded
    comparison. That breaks the assumption of the WARN_ON_ONCE() in
    f2fs_match_ci_name() which assumes that for encrypted directories,
    casefolded comparisons only happen when the directory's key is set up.

    We could just remove this WARN_ON_ONCE(). However, since casefolding is
    always a no-op on "." and ".." anyway, let's instead just not casefold
    these names. This results in the standard bytewise comparison.

    Fixes: 7ad08a58bf67 ("f2fs: Handle casefolding with Encryption")
    Cc: # v5.11+
    Signed-off-by: Eric Biggers
    Reviewed-by: Gabriel Krisman Bertazi
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     
  • commit 6b8beca0edd32075a769bfe4178ca00c0dcd22a9 upstream.

    As Yanming reported in bugzilla:

    https://bugzilla.kernel.org/show_bug.cgi?id=215916

    The kernel message is shown below:

    kernel BUG at fs/f2fs/segment.c:2560!
    Call Trace:
    allocate_segment_by_default+0x228/0x440
    f2fs_allocate_data_block+0x13d1/0x31f0
    do_write_page+0x18d/0x710
    f2fs_outplace_write_data+0x151/0x250
    f2fs_do_write_data_page+0xef9/0x1980
    move_data_page+0x6af/0xbc0
    do_garbage_collect+0x312f/0x46f0
    f2fs_gc+0x6b0/0x3bc0
    f2fs_balance_fs+0x921/0x2260
    f2fs_write_single_data_page+0x16be/0x2370
    f2fs_write_cache_pages+0x428/0xd00
    f2fs_write_data_pages+0x96e/0xd50
    do_writepages+0x168/0x550
    __writeback_single_inode+0x9f/0x870
    writeback_sb_inodes+0x47d/0xb20
    __writeback_inodes_wb+0xb2/0x200
    wb_writeback+0x4bd/0x660
    wb_workfn+0x5f3/0xab0
    process_one_work+0x79f/0x13e0
    worker_thread+0x89/0xf60
    kthread+0x26a/0x300
    ret_from_fork+0x22/0x30
    RIP: 0010:new_curseg+0xe8d/0x15f0

    The root cause is: ckpt.valid_block_count is inconsistent with SIT table,
    stat info indicates filesystem has free blocks, but SIT table indicates
    filesystem has no free segment.

    So that during garbage colloection, it triggers panic when LFS allocator
    fails to find free segment.

    This patch tries to fix this issue by checking consistency in between
    ckpt.valid_block_count and block accounted from SIT.

    Cc: stable@vger.kernel.org
    Reported-by: Ming Yan
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Chao Yu
     
  • commit 6213f5d4d23c50d393a31dc8e351e63a1fd10dbe upstream.

    Let's avoid false-alarmed lockdep warning.

    [ 58.914674] [T1501146] -> #2 (&sb->s_type->i_mutex_key#20){+.+.}-{3:3}:
    [ 58.915975] [T1501146] system_server: down_write+0x7c/0xe0
    [ 58.916738] [T1501146] system_server: f2fs_quota_sync+0x60/0x1a8
    [ 58.917563] [T1501146] system_server: block_operations+0x16c/0x43c
    [ 58.918410] [T1501146] system_server: f2fs_write_checkpoint+0x114/0x318
    [ 58.919312] [T1501146] system_server: f2fs_issue_checkpoint+0x178/0x21c
    [ 58.920214] [T1501146] system_server: f2fs_sync_fs+0x48/0x6c
    [ 58.920999] [T1501146] system_server: f2fs_do_sync_file+0x334/0x738
    [ 58.921862] [T1501146] system_server: f2fs_sync_file+0x30/0x48
    [ 58.922667] [T1501146] system_server: __arm64_sys_fsync+0x84/0xf8
    [ 58.923506] [T1501146] system_server: el0_svc_common.llvm.12821150825140585682+0xd8/0x20c
    [ 58.924604] [T1501146] system_server: do_el0_svc+0x28/0xa0
    [ 58.925366] [T1501146] system_server: el0_svc+0x24/0x38
    [ 58.926094] [T1501146] system_server: el0_sync_handler+0x88/0xec
    [ 58.926920] [T1501146] system_server: el0_sync+0x1b4/0x1c0

    [ 58.927681] [T1501146] -> #1 (&sbi->cp_global_sem){+.+.}-{3:3}:
    [ 58.928889] [T1501146] system_server: down_write+0x7c/0xe0
    [ 58.929650] [T1501146] system_server: f2fs_write_checkpoint+0xbc/0x318
    [ 58.930541] [T1501146] system_server: f2fs_issue_checkpoint+0x178/0x21c
    [ 58.931443] [T1501146] system_server: f2fs_sync_fs+0x48/0x6c
    [ 58.932226] [T1501146] system_server: sync_filesystem+0xac/0x130
    [ 58.933053] [T1501146] system_server: generic_shutdown_super+0x38/0x150
    [ 58.933958] [T1501146] system_server: kill_block_super+0x24/0x58
    [ 58.934791] [T1501146] system_server: kill_f2fs_super+0xcc/0x124
    [ 58.935618] [T1501146] system_server: deactivate_locked_super+0x90/0x120
    [ 58.936529] [T1501146] system_server: deactivate_super+0x74/0xac
    [ 58.937356] [T1501146] system_server: cleanup_mnt+0x128/0x168
    [ 58.938150] [T1501146] system_server: __cleanup_mnt+0x18/0x28
    [ 58.938944] [T1501146] system_server: task_work_run+0xb8/0x14c
    [ 58.939749] [T1501146] system_server: do_notify_resume+0x114/0x1e8
    [ 58.940595] [T1501146] system_server: work_pending+0xc/0x5f0

    [ 58.941375] [T1501146] -> #0 (&sbi->gc_lock){+.+.}-{3:3}:
    [ 58.942519] [T1501146] system_server: __lock_acquire+0x1270/0x2868
    [ 58.943366] [T1501146] system_server: lock_acquire+0x114/0x294
    [ 58.944169] [T1501146] system_server: down_write+0x7c/0xe0
    [ 58.944930] [T1501146] system_server: f2fs_issue_checkpoint+0x13c/0x21c
    [ 58.945831] [T1501146] system_server: f2fs_sync_fs+0x48/0x6c
    [ 58.946614] [T1501146] system_server: f2fs_do_sync_file+0x334/0x738
    [ 58.947472] [T1501146] system_server: f2fs_ioc_commit_atomic_write+0xc8/0x14c
    [ 58.948439] [T1501146] system_server: __f2fs_ioctl+0x674/0x154c
    [ 58.949253] [T1501146] system_server: f2fs_ioctl+0x54/0x88
    [ 58.950018] [T1501146] system_server: __arm64_sys_ioctl+0xa8/0x110
    [ 58.950865] [T1501146] system_server: el0_svc_common.llvm.12821150825140585682+0xd8/0x20c
    [ 58.951965] [T1501146] system_server: do_el0_svc+0x28/0xa0
    [ 58.952727] [T1501146] system_server: el0_svc+0x24/0x38
    [ 58.953454] [T1501146] system_server: el0_sync_handler+0x88/0xec
    [ 58.954279] [T1501146] system_server: el0_sync+0x1b4/0x1c0

    Cc: stable@vger.kernel.org
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Jaegeuk Kim
     
  • commit cfd66bb715fd11fde3338d0660cffa1396adc27d upstream.

    As Yanming reported in bugzilla:

    https://bugzilla.kernel.org/show_bug.cgi?id=215914

    The root cause is: in a very small sized image, it's very easy to
    exceed threshold of foreground GC, if we calculate free space and
    dirty data based on section granularity, in corner case,
    has_not_enough_free_secs() will always return true, result in
    deadloop in f2fs_gc().

    So this patch refactors has_not_enough_free_secs() as below to fix
    this issue:
    1. calculate needed space based on block granularity, and separate
    all blocks to two parts, section part, and block part, comparing
    section part to free section, and comparing block part to free space
    in openned log.
    2. account F2FS_DIRTY_NODES, F2FS_DIRTY_IMETA and F2FS_DIRTY_DENTS
    as node block consumer;
    3. account F2FS_DIRTY_DENTS as data block consumer;

    Cc: stable@vger.kernel.org
    Reported-by: Ming Yan
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Chao Yu
     
  • commit f2db71053dc0409fae785096ad19cce4c8a95af7 upstream.

    As Yanming reported in bugzilla:

    https://bugzilla.kernel.org/show_bug.cgi?id=215904

    The kernel message is shown below:

    kernel BUG at fs/f2fs/inode.c:825!
    Call Trace:
    evict+0x282/0x4e0
    __dentry_kill+0x2b2/0x4d0
    shrink_dentry_list+0x17c/0x4f0
    shrink_dcache_parent+0x143/0x1e0
    do_one_tree+0x9/0x30
    shrink_dcache_for_umount+0x51/0x120
    generic_shutdown_super+0x5c/0x3a0
    kill_block_super+0x90/0xd0
    kill_f2fs_super+0x225/0x310
    deactivate_locked_super+0x78/0xc0
    cleanup_mnt+0x2b7/0x480
    task_work_run+0xc8/0x150
    exit_to_user_mode_prepare+0x14a/0x150
    syscall_exit_to_user_mode+0x1d/0x40
    do_syscall_64+0x48/0x90

    The root cause is: inode node and dnode node share the same nid,
    so during f2fs_evict_inode(), dnode node truncation will invalidate
    its NAT entry, so when truncating inode node, it fails due to
    invalid NAT entry, result in inode is still marked as dirty, fix
    this issue by clearing dirty for inode and setting SBI_NEED_FSCK
    flag in filesystem.

    output from dump.f2fs:
    [print_node_info: 354] Node ID [0xf:15] is inode
    i_nid[0] [0x f : 15]

    Cc: stable@vger.kernel.org
    Reported-by: Ming Yan
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Chao Yu
     
  • commit 25f8236213a91efdf708b9d77e9e51b6fc3e141c upstream.

    As Yanming reported in bugzilla:

    https://bugzilla.kernel.org/show_bug.cgi?id=215894

    I have encountered a bug in F2FS file system in kernel v5.17.

    I have uploaded the system call sequence as case.c, and a fuzzed image can
    be found in google net disk

    The kernel should enable CONFIG_KASAN=y and CONFIG_KASAN_INLINE=y. You can
    reproduce the bug by running the following commands:

    kernel BUG at fs/f2fs/segment.c:2291!
    Call Trace:
    f2fs_invalidate_blocks+0x193/0x2d0
    f2fs_fallocate+0x2593/0x4a70
    vfs_fallocate+0x2a5/0xac0
    ksys_fallocate+0x35/0x70
    __x64_sys_fallocate+0x8e/0xf0
    do_syscall_64+0x3b/0x90
    entry_SYSCALL_64_after_hwframe+0x44/0xae

    The root cause is, after image was fuzzed, block mapping info in inode
    will be inconsistent with SIT table, so in f2fs_fallocate(), it will cause
    panic when updating SIT with invalid blkaddr.

    Let's fix the issue by adding sanity check on block address before updating
    SIT table with it.

    Cc: stable@vger.kernel.org
    Reported-by: Ming Yan
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Chao Yu
     
  • commit 4d17e6fe9293d57081ffdc11e1cf313e25e8fd9e upstream.

    As Yanming reported in bugzilla:

    https://bugzilla.kernel.org/show_bug.cgi?id=215897

    I have encountered a bug in F2FS file system in kernel v5.17.

    The kernel should enable CONFIG_KASAN=y and CONFIG_KASAN_INLINE=y. You can
    reproduce the bug by running the following commands:

    The kernel message is shown below:

    kernel BUG at fs/f2fs/f2fs.h:2511!
    Call Trace:
    f2fs_remove_inode_page+0x2a2/0x830
    f2fs_evict_inode+0x9b7/0x1510
    evict+0x282/0x4e0
    do_unlinkat+0x33a/0x540
    __x64_sys_unlinkat+0x8e/0xd0
    do_syscall_64+0x3b/0x90
    entry_SYSCALL_64_after_hwframe+0x44/0xae

    The root cause is: .total_valid_block_count or .total_valid_node_count
    could fuzzed to zero, then once dec_valid_node_count() was called, it
    will cause BUG_ON(), this patch fixes to print warning info and set
    SBI_NEED_FSCK into CP instead of panic.

    Cc: stable@vger.kernel.org
    Reported-by: Ming Yan
    Signed-off-by: Chao Yu
    Signed-off-by: Jaegeuk Kim
    Signed-off-by: Greg Kroah-Hartman

    Chao Yu
     
  • [ Upstream commit 118f09eda21d392e1eeb9f8a4bee044958cccf20 ]

    Mark async operations such as RENAME, REMOVE, COMMIT MOVEABLE
    for the nfsv4.1+ sessions.

    Fixes: 85e39feead948 ("NFSv4.1 identify and mark RPC tasks that can move between transports")
    Signed-off-by: Olga Kornievskaia
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Olga Kornievskaia
     
  • [ Upstream commit da48f267f90d9dc9f930fd9a67753643657b404f ]

    Assume that sections that should not re-enter the filesystem are already
    protected with memalloc_nofs_save/restore call, so relax those GFP_NOFS
    instances which might be used by other contexts.

    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit d755ad8dc752d44545613ea04d660aed674e540d ]

    For creating fattrs with the label field already allocated for us. I
    also update nfs_free_fattr() to free the label in the end.

    Signed-off-by: Anna Schumaker
    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Anna Schumaker
     
  • [ Upstream commit d4a95a7e5a4d3b68b26f70668cf77324a11b5718 ]

    We're about to add a check in nfs_free_fattr() for whether or not the
    label is non-zero.

    Signed-off-by: Trond Myklebust
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit acde4003efc16480375543638484d8f13f2e99a3 ]

    Commit b3c9a924aab6 ("fbdev: vesafb: Cleanup fb_info in .fb_destroy rather
    than .remove") fixed a use-after-free error due the vesafb driver freeing
    the fb_info in the .remove handler instead of doing it in .fb_destroy.

    This can happen if the .fb_destroy callback is executed after the .remove
    callback, since the former tries to access a pointer freed by the latter.

    But that change didn't take into account that another possible scenario is
    that .fb_destroy is called before the .remove callback. For example, if no
    process has the fbdev chardev opened by the time the driver is removed.

    If that's the case, fb_info will be freed when unregister_framebuffer() is
    called, making the fb_info pointer accessed in vesafb_remove() after that
    to no longer be valid.

    To prevent that, move the expression containing the info->par to happen
    before the unregister_framebuffer() function call.

    Fixes: b3c9a924aab6 ("fbdev: vesafb: Cleanup fb_info in .fb_destroy rather than .remove")
    Reported-by: Pascal Ernster
    Signed-off-by: Javier Martinez Canillas
    Tested-by: Pascal Ernster
    Signed-off-by: Helge Deller
    Signed-off-by: Sasha Levin

    Javier Martinez Canillas
     
  • [ Upstream commit f4df0dbbe62ee8e4405a57b27ccd54393971c773 ]

    In the origin code, when "ExtSel" is 1, the eventcode will change to
    "eventcode |= 1 << 21”. For event “UNC_Q_RxL_CREDITS_CONSUMED_VN0.DRS",
    its "ExtSel" is "1", its eventcode will change from 0x1E to 0x20001E,
    but in fact the eventcode should
    Signed-off-by: Xing Zhengjun
    Acked-by: Ian Rogers
    Cc: Adrian Hunter
    Cc: Alexander Shishkin
    Cc: Andi Kleen
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Link: https://lore.kernel.org/r/20220525140410.1706851-1-zhengjun.xing@linux.intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Zhengjun Xing
     
  • [ Upstream commit c4040212bc97d16040712a410335f93bc94d2262 ]

    If the slang lib is not installed on the system, perf c2c tool disables TUI
    mode and roll back to use stdio mode; but the flag 'c2c.use_stdio' is
    missed to set true and thus it wrongly applies UI quirks in the function
    ui_quirks().

    This commit forces to use stdio interface if slang is not supported, and
    it can avoid to apply the UI quirks and show the correct metric header.

    Before:

    =================================================
    Shared Cache Line Distribution Pareto
    =================================================
    -------------------------------------------------------------------------------
    0 0 0 99 0 0 0 0xaaaac17d6000
    -------------------------------------------------------------------------------
    0.00% 0.00% 6.06% 0.00% 0.00% 0.00% 0x20 N/A 0 0xaaaac17c25ac 0 0 43 375 18469 2 [.] 0x00000000000025ac memstress memstress[25ac] 0
    0.00% 0.00% 93.94% 0.00% 0.00% 0.00% 0x29 N/A 0 0xaaaac17c3e88 0 0 173 180 135 2 [.] 0x0000000000003e88 memstress memstress[3e88] 0

    After:

    =================================================
    Shared Cache Line Distribution Pareto
    =================================================
    -------------------------------------------------------------------------------
    0 0 0 99 0 0 0 0xaaaac17d6000
    -------------------------------------------------------------------------------
    0.00% 0.00% 6.06% 0.00% 0.00% 0.00% 0x20 N/A 0 0xaaaac17c25ac 0 0 43 375 18469 2 [.] 0x00000000000025ac memstress memstress[25ac] 0
    0.00% 0.00% 93.94% 0.00% 0.00% 0.00% 0x29 N/A 0 0xaaaac17c3e88 0 0 173 180 135 2 [.] 0x0000000000003e88 memstress memstress[3e88] 0

    Fixes: 5a1a99cd2e4e1557 ("perf c2c report: Add main TUI browser")
    Reported-by: Joe Mario
    Signed-off-by: Leo Yan
    Cc: Alexander Shishkin
    Cc: Jiri Olsa
    Cc: Mark Rutland
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lore.kernel.org/lkml/20220526145400.611249-1-leo.yan@linaro.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Leo Yan
     
  • [ Upstream commit 73534617dfa3c4cd95fe5ffaeff5315e9ffc2de6 ]

    The btf__load_from_kernel_by_id() only takes one arg, not two.

    Committer notes:

    I tested it just with an older libbpf, one where
    btf__load_from_kernel_by_id() wasn't introduced yet.

    A test with a newer dynamic libbpf would fail because the
    btf__load_from_kernel_by_id() is there, but takes just one arg.

    Fixes: 0ae065a5d265bc5a ("perf build: Fix check for btf__load_from_kernel_by_id() in libbpf")
    Signed-off-by: Jiri Olsa
    Cc: Heiko Carstens
    Cc: Ian Rogers
    Cc: Ilya Leoshkevich
    Cc: Sumanth Korikkar
    Cc: Sven Schnelle
    Cc: Thomas Richter
    Cc: Vasily Gorbik
    Link: http://lore.kernel.org/linux-perf-users/YozLKby7ITEtchC9@krava
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Jiri Olsa
     
  • [ Upstream commit 3fe2ec59db1a7569e18594b9c0cf1f4f1afd498e ]

    We have to take care of ID_P_PM_BLOCKED when bailing out during probe.

    Fixes: 7ee24eb508d6 ("i2c: rcar: disable PM in multi-master mode")
    Signed-off-by: Kuninori Morimoto
    Signed-off-by: Wolfram Sang
    Signed-off-by: Wolfram Sang
    Signed-off-by: Sasha Levin

    Kuninori Morimoto
     
  • [ Upstream commit e5222d408de2a88e6b206c38217b48d092184553 ]

    On some platforms in rare cases (1 to 100,000 transactions),
    the i2c gets a spurious interrupt which means that we enter an interrupt
    but in the interrupt handler we don't find any status bit that points to
    the reason we got this interrupt.

    This may be a case of a rare HW issue or signal integrity issue that is
    still under investigation.

    In order to overcome this we are doing the following:
    1. Disable incoming interrupts in master mode only when slave mode is not
    enabled.
    2. Clear end of busy (EOB) after every interrupt.
    3. Clear other status bits (just in case since we found them cleared)
    4. Return correct status during the interrupt that will finish the
    transaction.

    On next xmit transaction if the bus is still busy the master will issue a
    recovery process before issuing the new transaction.

    Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
    Signed-off-by: Tali Perry
    Signed-off-by: Tyrone Ting
    Signed-off-by: Wolfram Sang
    Signed-off-by: Sasha Levin

    Tali Perry
     
  • [ Upstream commit ea9f8426d17620214ee345ffb77ee6cc196ff14f ]

    The SMBnCTL3 register is 8-bit wide and the 32-bit access was always
    incorrect, but simply didn't cause a visible error on the 32-bit machine.

    On the 64-bit machine, the kernel message reports that ESR value is
    0x96000021. Checking Arm Architecture Reference Manual Armv8 suggests that
    it's the alignment fault.

    SMBnCTL3's address is 0xE.

    Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
    Signed-off-by: Tyrone Ting
    Reviewed-by: Jonathan Neuschäfer
    Signed-off-by: Wolfram Sang
    Signed-off-by: Sasha Levin

    Tyrone Ting
     
  • [ Upstream commit 288b204492fddf28889cea6dc95a23976632c7a0 ]

    Use adap.timeout for timeout calculation instead of hard-coded
    value of 35ms.

    Fixes: 56a1485b102e ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
    Signed-off-by: Tali Perry
    Signed-off-by: Tyrone Ting
    Signed-off-by: Wolfram Sang
    Signed-off-by: Sasha Levin

    Tali Perry
     
  • [ Upstream commit 42bb5aa043382f09bef2cc33b8431be867c70f8e ]

    On some systems it can take a long time for the hardware to enable the
    GA log of the AMD IOMMU. The current wait time is only 0.1ms, but
    testing showed that it can take up to 14ms for the GA log to enter
    running state after it has been enabled.

    Sometimes the long delay happens when booting the system, sometimes
    only on resume. Adjust the timeout accordingly to not print a warning
    when hardware takes a longer than usual.

    There has already been an attempt to fix this with commit

    9b45a7738eec ("iommu/amd: Fix loop timeout issue in iommu_ga_log_enable()")

    But that commit was based on some wrong math and did not fix the issue
    in all cases.

    Cc: "D. Ziegfeld"
    Cc: Jörg-Volker Peetz
    Fixes: 8bda0cfbdc1a ("iommu/amd: Detect and initialize guest vAPIC log")
    Signed-off-by: Joerg Roedel
    Link: https://lore.kernel.org/r/20220520102214.12563-1-joro@8bytes.org
    Signed-off-by: Sasha Levin

    Joerg Roedel
     
  • [ Upstream commit da3b8ddb464bd49b6248d00ca888ad751c9e44fd ]

    The parameter to pass back to the handler function when irq has been
    requested is a struct stm32_mdma_device pointer, not a struct
    stm32_mdma_chan pointer.
    Even if chan is reinit later in the function, remove this wrong
    initialization.

    Fixes: a4ffb13c8946 ("dmaengine: Add STM32 MDMA driver")
    Signed-off-by: Amelie Delaunay
    Link: https://lore.kernel.org/r/20220504155322.121431-3-amelie.delaunay@foss.st.com
    Signed-off-by: Vinod Koul
    Signed-off-by: Sasha Levin

    Amelie Delaunay
     
  • [ Upstream commit 9d6a2d92e450926c483e45eaf426080a19219f4e ]

    GISR1 was described in a not up-to-date documentation when the stm32-mdma
    driver has been developed. This register has not been added in reference
    manual of STM32 SoC with MDMA, which have only 32 MDMA channels.
    So remove it from stm32-mdma driver.

    Fixes: a4ffb13c8946 ("dmaengine: Add STM32 MDMA driver")
    Signed-off-by: Amelie Delaunay
    Link: https://lore.kernel.org/r/20220504155322.121431-2-amelie.delaunay@foss.st.com
    Signed-off-by: Vinod Koul
    Signed-off-by: Sasha Levin

    Amelie Delaunay
     
  • [ Upstream commit b23789a59fa6f00e98a319291819f91fbba0deb8 ]

    of_parse_phandle() returns a node pointer with refcount incremented, we should
    use of_node_put() on it when not need anymore. Add missing of_node_put() to
    avoid refcount leak.

    Fixes: d10715be03bd ("video: ARM CLCD: Add DT support")
    Signed-off-by: Miaoqian Lin
    Signed-off-by: Helge Deller
    Signed-off-by: Sasha Levin

    Miaoqian Lin
     
  • [ Upstream commit c6fd3511c3397dd9cbc6dc5d105bbedb69bf4061 ]

    When we handle an error by redirtying the page, we're not corrupting the
    mapping, so we don't want the error to be recorded in the mapping.
    If the caller has specified a sync_mode of WB_SYNC_NONE, we can just
    return AOP_WRITEPAGE_ACTIVATE. However if we're dealing with
    WB_SYNC_ALL, we need to ensure that retries happen when the errors are
    non-fatal.

    Reported-by: Olga Kornievskaia
    Fixes: 8fc75bed96bb ("NFS: Fix up return value on fatal errors in nfs_page_async_flush()")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit 3764a17e31d579cf9b4bd0a69894b577e8d75702 ]

    Commit 587f03deb69b caused pnfs_update_layout() to stop returning ENOMEM
    when the memory allocation fails, and hence causes it to fall back to
    trying to do I/O through the MDS. There is no guarantee that this will
    fare any better. If we're failing the pNFS layout allocation, then we
    should just redirty the page and retry later.

    Reported-by: Olga Kornievskaia
    Fixes: 587f03deb69b ("pnfs: refactor send_layoutget")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit c5e483b77cc2edb318da152abe07e33006b975fd ]

    Since errors from nfs_pageio_complete() are already being reported
    through nfs_async_write_error(), we should not be returning them to the
    callers of do_writepages() as well. They will end up being reported
    through the generic mechanism instead.

    Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with generic one")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit d95b26650e86175e4a97698d89bc1626cd1df0c6 ]

    If we do flush cached writebacks in nfs_write_end() due to the imminent
    expiration of an RPCSEC_GSS session, then we should defer reporting any
    resulting errors until the calls to file_check_and_advance_wb_err() in
    nfs_file_write() and nfs_file_fsync().

    Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with generic one")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit e6005436f6cc9ed13288f936903f0151e5543485 ]

    Any errors reported by the write() system call need to be cleared from
    the file descriptor's error tracking. The current call to nfs_wb_all()
    causes the error to be reported, but since it doesn't call
    file_check_and_advance_wb_err(), we can end up reporting the same error
    a second time when the application calls fsync().

    Note that since Linux 4.13, the rule is that EIO may be reported for
    write(), but it must be reported by a subsequent fsync(), so let's just
    drop reporting it in write.

    The check for nfs_ctx_key_to_expire() is just a duplicate to the one
    already in nfs_write_end(), so let's drop that too.

    Reported-by: ChenXiaoSong
    Fixes: ce368536dd61 ("nfs: nfs_file_write() should check for writeback errors")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit 9641d9bc9b75f11f70646f5c6ee9f5f519a1012e ]

    If the commit to disk is interrupted, we should still first check for
    filesystem errors so that we can report them in preference to the error
    due to the signal.

    Fixes: 2197e9b06c22 ("NFS: Fix up fsync() when the server rebooted")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit cea9ba7239dcc84175041174304c6cdeae3226e5 ]

    If the attempt to flush data was interrupted due to a local signal, then
    just requeue the writes back for I/O.

    Fixes: 6fbda89b257f ("NFS: Replace custom error reporting mechanism with generic one")
    Signed-off-by: Trond Myklebust
    Signed-off-by: Anna Schumaker
    Signed-off-by: Sasha Levin

    Trond Myklebust
     
  • [ Upstream commit aab08c1aac01097815fbcf10fce7021d2396a31f ]

    If a call to alloc_chrdev_region() fails, the already allocated resources
    are leaking.

    Add the needed error handling path to fix the leak.

    Fixes: 42d279f9137a ("dmaengine: idxd: add char driver to expose submission portal to userland")
    Signed-off-by: Christophe JAILLET
    Acked-by: Dave Jiang
    Link: https://lore.kernel.org/r/1b5033dcc87b5f2a953c413f0306e883e6114542.1650521591.git.christophe.jaillet@wanadoo.fr
    Signed-off-by: Vinod Koul
    Signed-off-by: Sasha Levin

    Christophe JAILLET
     
  • [ Upstream commit 6977262c2eee111645668fe9e235ef2f5694abf7 ]

    Clang warns:

    drivers/i2c/busses/i2c-at91-master.c:707:6: warning: variable 'dma_buf' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
    if (dev->use_dma) {
    ^~~~~~~~~~~~
    drivers/i2c/busses/i2c-at91-master.c:717:27: note: uninitialized use occurs here
    i2c_put_dma_safe_msg_buf(dma_buf, m_start, !ret);
    ^~~~~~~

    Initialize dma_buf to NULL, as i2c_put_dma_safe_msg_buf() is a no-op
    when the first argument is NULL, which will work for the !dev->use_dma
    case.

    Fixes: 03fbb903c8bf ("i2c: at91: use dma safe buffers")
    Link: https://github.com/ClangBuiltLinux/linux/issues/1629
    Signed-off-by: Nathan Chancellor
    Reviewed-by: Michael Walle
    Signed-off-by: Wolfram Sang
    Signed-off-by: Sasha Levin

    Nathan Chancellor
     
  • [ Upstream commit de78657e16f41417da9332f09c2d67d100096939 ]

    When larbdev is NULL (in the case I hit, the node is incorrectly set
    iommus = ), it will cause device_link_add() fail and
    kernel crashes when we try to print dev_name(larbdev).

    Let's fail the probe if a larbdev is NULL to avoid invalid inputs from
    dts.

    It should work for normal correct setting and avoid the crash caused
    by my incorrect setting.

    Error log:
    [ 18.189042][ T301] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000050
    ...
    [ 18.344519][ T301] pstate: a0400005 (NzCv daif +PAN -UAO)
    [ 18.345213][ T301] pc : mtk_iommu_probe_device+0xf8/0x118 [mtk_iommu]
    [ 18.346050][ T301] lr : mtk_iommu_probe_device+0xd0/0x118 [mtk_iommu]
    [ 18.346884][ T301] sp : ffffffc00a5635e0
    [ 18.347392][ T301] x29: ffffffc00a5635e0 x28: ffffffd44a46c1d8
    [ 18.348156][ T301] x27: ffffff80c39a8000 x26: ffffffd44a80cc38
    [ 18.348917][ T301] x25: 0000000000000000 x24: ffffffd44a80cc38
    [ 18.349677][ T301] x23: ffffffd44e4da4c6 x22: ffffffd44a80cc38
    [ 18.350438][ T301] x21: ffffff80cecd1880 x20: 0000000000000000
    [ 18.351198][ T301] x19: ffffff80c439f010 x18: ffffffc00a50d0c0
    [ 18.351959][ T301] x17: ffffffffffffffff x16: 0000000000000004
    [ 18.352719][ T301] x15: 0000000000000004 x14: ffffffd44eb5d420
    [ 18.353480][ T301] x13: 0000000000000ad2 x12: 0000000000000003
    [ 18.354241][ T301] x11: 00000000fffffad2 x10: c0000000fffffad2
    [ 18.355003][ T301] x9 : a0d288d8d7142d00 x8 : a0d288d8d7142d00
    [ 18.355763][ T301] x7 : ffffffd44c2bc640 x6 : 0000000000000000
    [ 18.356524][ T301] x5 : 0000000000000080 x4 : 0000000000000001
    [ 18.357284][ T301] x3 : 0000000000000000 x2 : 0000000000000005
    [ 18.358045][ T301] x1 : 0000000000000000 x0 : 0000000000000000
    [ 18.360208][ T301] Hardware name: MT6873 (DT)
    [ 18.360771][ T301] Call trace:
    [ 18.361168][ T301] dump_backtrace+0xf8/0x1f0
    [ 18.361737][ T301] dump_stack_lvl+0xa8/0x11c
    [ 18.362305][ T301] dump_stack+0x1c/0x2c
    [ 18.362816][ T301] mrdump_common_die+0x184/0x40c [mrdump]
    [ 18.363575][ T301] ipanic_die+0x24/0x38 [mrdump]
    [ 18.364230][ T301] atomic_notifier_call_chain+0x128/0x2b8
    [ 18.364937][ T301] die+0x16c/0x568
    [ 18.365394][ T301] __do_kernel_fault+0x1e8/0x214
    [ 18.365402][ T301] do_page_fault+0xb8/0x678
    [ 18.366934][ T301] do_translation_fault+0x48/0x64
    [ 18.368645][ T301] do_mem_abort+0x68/0x148
    [ 18.368652][ T301] el1_abort+0x40/0x64
    [ 18.368660][ T301] el1h_64_sync_handler+0x54/0x88
    [ 18.368668][ T301] el1h_64_sync+0x68/0x6c
    [ 18.368673][ T301] mtk_iommu_probe_device+0xf8/0x118 [mtk_iommu]
    ...

    Cc: Robin Murphy
    Cc: Yong Wu
    Reported-by: kernel test robot
    Fixes: 635319a4a744 ("media: iommu/mediatek: Add device_link between the consumer and the larb devices")
    Signed-off-by: Miles Chen
    Reviewed-by: Yong Wu
    Reviewed-by: AngeloGioacchino Del Regno
    Link: https://lore.kernel.org/r/20220505132731.21628-1-miles.chen@mediatek.com
    Signed-off-by: Joerg Roedel
    Signed-off-by: Sasha Levin

    Miles Chen
     
  • [ Upstream commit abae018a03821be2b65c01ebe2bef06fd7d85a4c ]

    Calling hwmon_device_register_with_info() with NULL dev and/or chip
    information parameters is an ABI abuse and not a real conversion to
    the new API. Also, the code creates sysfs attributes _after_ creating
    the hwmon device, which is racy and unsupported to start with. On top
    of that, the removal code tries to remove the name attribute which is
    owned by the hwmon core.

    Use hwmon_device_register_with_groups() to register the hwmon device
    instead.

    In the future, the hwmon subsystem will reject calls to
    hwmon_device_register_with_info with NULL dev or chip/info parameters.
    Without this patch, the hwmon device will fail to register.

    Fixes: f59dc5119192 ("MIPS: Loongson: Fix boot warning about hwmon_device_register()")
    Cc: Zhi Li
    Signed-off-by: Guenter Roeck
    Signed-off-by: Thomas Bogendoerfer
    Signed-off-by: Sasha Levin

    Guenter Roeck
     
  • [ Upstream commit cbd23144f7662b00bcde32a938c4a4057e476d68 ]

    We currently call arm64_mm_context_put() without holding a reference to
    the mm, which can result in use-after-free. Call mmgrab()/mmdrop() to
    ensure the mm only gets freed after we unpinned the ASID.

    Fixes: 32784a9562fb ("iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind()")
    Signed-off-by: Jean-Philippe Brucker
    Tested-by: Zhangfei Gao
    Link: https://lore.kernel.org/r/20220426130444.300556-1-jean-philippe@linaro.org
    Signed-off-by: Will Deacon
    Signed-off-by: Sasha Levin

    Jean-Philippe Brucker