Skip to content
  1. Apr 13, 2023
    • Hans de Goede's avatar
      platform/x86: int3472: Split into 2 drivers · 7798cd69
      Hans de Goede authored
      [ Upstream commit a2f9fbc2
      
       ]
      
      The intel_skl_int3472.ko module contains 2 separate drivers,
      the int3472_discrete platform driver and the int3472_tps68470
      I2C-driver.
      
      These 2 drivers contain very little shared code, only
      skl_int3472_get_acpi_buffer() and skl_int3472_fill_cldb() are
      shared.
      
      Split the module into 2 drivers, linking the little shared code
      directly into both.
      
      This will allow us to add soft-module dependencies for the
      tps68470 clk, gpio and regulator drivers to the new
      intel_skl_int3472_tps68470.ko to help with probe ordering issues
      without causing these modules to get loaded on boards which only
      use the int3472_discrete platform driver.
      
      While at it also rename the .c and .h files to remove the
      cumbersome intel_skl_int3472_ prefix.
      
      Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20211203102857.44539-8-hdegoede@redhat.com
      Stable-dep-of: cf5ac2d4
      
       ("platform/x86: int3472/discrete: Ensure the clk/power enable pins are in output mode")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7798cd69
    • Mustafa Ismail's avatar
      RDMA/irdma: Do not request 2-level PBLEs for CQ alloc · 5cc70e78
      Mustafa Ismail authored
      [ Upstream commit 8f7e2daa ]
      
      When allocating PBLE's for a large CQ, it is possible
      that a 2-level PBLE is returned which would cause the
      CQ allocation to fail since 1-level is assumed and checked for.
      Fix this by requesting a level one PBLE only.
      
      Fixes: b48c24c2
      
       ("RDMA/irdma: Implement device supported verb APIs")
      Signed-off-by: default avatarMustafa Ismail <mustafa.ismail@intel.com>
      Signed-off-by: default avatarShiraz Saleem <shiraz.saleem@intel.com>
      Link: https://lore.kernel.org/r/20221115011701.1379-4-shiraz.saleem@intel.com
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5cc70e78
    • Brian Foster's avatar
      NFSD: pass range end to vfs_fsync_range() instead of count · c22ac849
      Brian Foster authored
      [ Upstream commit 79a1d88a ]
      
      _nfsd_copy_file_range() calls vfs_fsync_range() with an offset and
      count (bytes written), but the former wants the start and end bytes
      of the range to sync. Fix it up.
      
      Fixes: eac0b17a
      
       ("NFSD add vfs_fsync after async copy is done")
      Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
      Tested-by: default avatarDai Ngo <dai.ngo@oracle.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c22ac849
    • Chuck Lever's avatar
      NFSD: Fix sparse warning · 34a14759
      Chuck Lever authored
      [ Upstream commit c2f1c4bd
      
       ]
      
      /home/cel/src/linux/linux/fs/nfsd/nfs4proc.c:1539:24: warning: incorrect type in assignment (different base types)
      /home/cel/src/linux/linux/fs/nfsd/nfs4proc.c:1539:24:    expected restricted __be32 [usertype] status
      /home/cel/src/linux/linux/fs/nfsd/nfs4proc.c:1539:24:    got int
      
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Stable-dep-of: 79a1d88a
      
       ("NFSD: pass range end to vfs_fsync_range() instead of count")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      34a14759
    • Li Zetao's avatar
      ocfs2: fix memory leak in ocfs2_mount_volume() · 8059e200
      Li Zetao authored
      [ Upstream commit ce2fcf15 ]
      
      There is a memory leak reported by kmemleak:
      
        unreferenced object 0xffff88810cc65e60 (size 32):
          comm "mount.ocfs2", pid 23753, jiffies 4302528942 (age 34735.105s)
          hex dump (first 32 bytes):
            10 00 00 00 00 00 00 00 00 01 01 01 01 01 01 01  ................
            01 01 01 01 01 01 01 01 00 00 00 00 00 00 00 00  ................
          backtrace:
            [<ffffffff8170f73d>] __kmalloc+0x4d/0x150
            [<ffffffffa0ac3f51>] ocfs2_compute_replay_slots+0x121/0x330 [ocfs2]
            [<ffffffffa0b65165>] ocfs2_check_volume+0x485/0x900 [ocfs2]
            [<ffffffffa0b68129>] ocfs2_mount_volume.isra.0+0x1e9/0x650 [ocfs2]
            [<ffffffffa0b7160b>] ocfs2_fill_super+0xe0b/0x1740 [ocfs2]
            [<ffffffff818e1fe2>] mount_bdev+0x312/0x400
            [<ffffffff819a086d>] legacy_get_tree+0xed/0x1d0
            [<ffffffff818de82d>] vfs_get_tree+0x7d/0x230
            [<ffffffff81957f92>] path_mount+0xd62/0x1760
            [<ffffffff81958a5a>] do_mount+0xca/0xe0
            [<ffffffff81958d3c>] __x64_sys_mount+0x12c/0x1a0
            [<ffffffff82f26f15>] do_syscall_64+0x35/0x80
            [<ffffffff8300006a>] entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      This call stack is related to two problems.  Firstly, the ocfs2 super uses
      "replay_map" to trace online/offline slots, in order to recover offline
      slots during recovery and mount.  But when ocfs2_truncate_log_init()
      returns an error in ocfs2_mount_volume(), the memory of "replay_map" will
      not be freed in error handling path.  Secondly, the memory of "replay_map"
      will not be freed if d_make_root() returns an error in ocfs2_fill_super().
      But the memory of "replay_map" will be freed normally when completing
      recovery and mount in ocfs2_complete_mount_recovery().
      
      Fix the first problem by adding error handling path to free "replay_map"
      when ocfs2_truncate_log_init() fails.  And fix the second problem by
      calling ocfs2_free_replay_slots(osb) in the error handling path
      "out_dismount".  In addition, since ocfs2_free_replay_slots() is static,
      it is necessary to remove its static attribute and declare it in header
      file.
      
      Link: https://lkml.kernel.org/r/20221109074627.2303950-1-lizetao1@huawei.com
      Fixes: 9140db04
      
       ("ocfs2: recover orphans in offline slots during recovery and mount")
      Signed-off-by: default avatarLi Zetao <lizetao1@huawei.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Jun Piao <piaojun@huawei.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8059e200
    • Heming Zhao via Ocfs2-devel's avatar
      ocfs2: rewrite error handling of ocfs2_fill_super · b613d8dc
      Heming Zhao via Ocfs2-devel authored
      [ Upstream commit f1e75d12
      
       ]
      
      Current ocfs2_fill_super() uses one goto label "read_super_error" to
      handle all error cases.  And with previous serial patches, the error
      handling should fork more branches to handle different error cases.  This
      patch rewrite the error handling of ocfs2_fill_super.
      
      Link: https://lkml.kernel.org/r/20220424130952.2436-6-heming.zhao@suse.com
      Signed-off-by: default avatarHeming Zhao <heming.zhao@suse.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Stable-dep-of: ce2fcf15
      
       ("ocfs2: fix memory leak in ocfs2_mount_volume()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b613d8dc
    • Heming Zhao via Ocfs2-devel's avatar
      ocfs2: ocfs2_mount_volume does cleanup job before return error · 05abe9c0
      Heming Zhao via Ocfs2-devel authored
      [ Upstream commit 0737e01d
      
       ]
      
      After this patch, when error, ocfs2_fill_super doesn't take care to
      release resources which are allocated in ocfs2_mount_volume.
      
      Link: https://lkml.kernel.org/r/20220424130952.2436-5-heming.zhao@suse.com
      Signed-off-by: default avatarHeming Zhao <heming.zhao@suse.com>
      Reviewed-by: default avatarJoseph Qi <joseph.qi@linux.alibaba.com>
      Cc: Changwei Ge <gechangwei@live.cn>
      Cc: Gang He <ghe@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Jun Piao <piaojun@huawei.com>
      Cc: Junxiao Bi <junxiao.bi@oracle.com>
      Cc: Mark Fasheh <mark@fasheh.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Stable-dep-of: ce2fcf15
      
       ("ocfs2: fix memory leak in ocfs2_mount_volume()")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      05abe9c0
  2. Apr 05, 2023
    • Greg Kroah-Hartman's avatar
    • Jan Beulich's avatar
      x86/PVH: avoid 32-bit build warning when obtaining VGA console info · 06a948b8
      Jan Beulich authored
      commit aadbd07f upstream.
      
      In the commit referenced below I failed to pay attention to this code
      also being buildable as 32-bit. Adjust the type of "ret" - there's no
      real need for it to be wider than 32 bits.
      
      Fixes: 934ef33e
      
       ("x86/PVH: obtain VGA console info in Dom0")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarJan Beulich <jbeulich@suse.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      
      Link: https://lore.kernel.org/r/2d2193ff-670b-0a27-e12d-2c5c4c121c79@suse.com
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      06a948b8
    • Matthieu Baerts's avatar
      hsr: ratelimit only when errors are printed · 3abdf6d7
      Matthieu Baerts authored
      commit 1b0120e4 upstream.
      
      Recently, when automatically merging -net and net-next in MPTCP devel
      tree, our CI reported [1] a conflict in hsr, the same as the one
      reported by Stephen in netdev [2].
      
      When looking at the conflict, I noticed it is in fact the v1 [3] that
      has been applied in -net and the v2 [4] in net-next. Maybe the v1 was
      applied by accident.
      
      As mentioned by Jakub Kicinski [5], the new condition makes more sense
      before the net_ratelimit(), not to update net_ratelimit's state which is
      unnecessary if we're not going to print either way.
      
      Here, this modification applies the v2 but in -net.
      
      Link: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/4423171069 [1]
      Link: https://lore.kernel.org/netdev/20230315100914.53fc1760@canb.auug.org.au/ [2]
      Link: https://lore.kernel.org/netdev/20230307133229.127442-1-koverskeid@gmail.com/ [3]
      Link: https://lore.kernel.org/netdev/20230309092302.179586-1-koverskeid@gmail.com/ [4]
      Link: https://lore.kernel.org/netdev/20230308232001.2fb62013@kernel.org/ [5]
      Fixes: 28e8cabe
      
       ("net: hsr: Don't log netdev_err message on unknown prp dst node")
      Signed-off-by: default avatarMatthieu Baerts <matthieu.baerts@tessares.net>
      Reviewed-by: default avatarSteen Hegelund <Steen.Hegelund@microchip.com>
      Link: https://lore.kernel.org/r/20230315-net-20230315-hsr_framereg-ratelimit-v1-1-61d2ef176d11@tessares.net
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3abdf6d7
    • Andrii Nakryiko's avatar
      libbpf: Fix btf_dump's packed struct determination · fcc09ef8
      Andrii Nakryiko authored
      [ Upstream commit 4fb877aa ]
      
      Fix bug in btf_dump's logic of determining if a given struct type is
      packed or not. The notion of "natural alignment" is not needed and is
      even harmful in this case, so drop it altogether. The biggest difference
      in btf_is_struct_packed() compared to its original implementation is
      that we don't really use btf__align_of() to determine overall alignment
      of a struct type (because it could be 1 for both packed and non-packed
      struct, depending on specifci field definitions), and just use field's
      actual alignment to calculate whether any field is requiring packing or
      struct's size overall necessitates packing.
      
      Add two simple test cases that demonstrate the difference this change
      would make.
      
      Fixes: ea2ce1ba
      
       ("libbpf: Fix BTF-to-C converter's padding logic")
      Reported-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Link: https://lore.kernel.org/bpf/20221215183605.4149488-1-andrii@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fcc09ef8
    • Andrii Nakryiko's avatar
      selftests/bpf: Add few corner cases to test padding handling of btf_dump · 74059587
      Andrii Nakryiko authored
      [ Upstream commit b148c8b9
      
       ]
      
      Add few hand-crafted cases and few randomized cases found using script
      from [0] that tests btf_dump's padding logic.
      
        [0] https://lore.kernel.org/bpf/85f83c333f5355c8ac026f835b18d15060725fcb.camel@ericsson.com/
      
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20221212211505.558851-7-andrii@kernel.org
      Stable-dep-of: 4fb877aa
      
       ("libbpf: Fix btf_dump's packed struct determination")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      74059587
    • Andrii Nakryiko's avatar
      libbpf: Fix BTF-to-C converter's padding logic · c74ae867
      Andrii Nakryiko authored
      [ Upstream commit ea2ce1ba
      
       ]
      
      Turns out that btf_dump API doesn't handle a bunch of tricky corner
      cases, as reported by Per, and further discovered using his testing
      Python script ([0]).
      
      This patch revamps btf_dump's padding logic significantly, making it
      more correct and also avoiding unnecessary explicit padding, where
      compiler would pad naturally. This overall topic turned out to be very
      tricky and subtle, there are lots of subtle corner cases. The comments
      in the code tries to give some clues, but comments themselves are
      supposed to be paired with good understanding of C alignment and padding
      rules. Plus some experimentation to figure out subtle things like
      whether `long :0;` means that struct is now forced to be long-aligned
      (no, it's not, turns out).
      
      Anyways, Per's script, while not completely correct in some known
      situations, doesn't show any obvious cases where this logic breaks, so
      this is a nice improvement over the previous state of this logic.
      
      Some selftests had to be adjusted to accommodate better use of natural
      alignment rules, eliminating some unnecessary padding, or changing it to
      `type: 0;` alignment markers.
      
      Note also that for when we are in between bitfields, we emit explicit
      bit size, while otherwise we use `: 0`, this feels much more natural in
      practice.
      
      Next patch will add few more test cases, found through randomized Per's
      script.
      
        [0] https://lore.kernel.org/bpf/85f83c333f5355c8ac026f835b18d15060725fcb.camel@ericsson.com/
      
      Reported-by: default avatarPer Sundström XP <per.xp.sundstrom@ericsson.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20221212211505.558851-6-andrii@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c74ae867
    • Eduard Zingerman's avatar
      selftests/bpf: Test btf dump for struct with padding only fields · 17a61d1e
      Eduard Zingerman authored
      [ Upstream commit d503f117
      
       ]
      
      Structures with zero regular fields but some padding constitute a
      special case in btf_dump.c:btf_dump_emit_struct_def with regards to
      newline before closing '}'.
      
      Signed-off-by: default avatarEduard Zingerman <eddyz87@gmail.com>
      Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20221001104425.415768-2-eddyz87@gmail.com
      Stable-dep-of: ea2ce1ba
      
       ("libbpf: Fix BTF-to-C converter's padding logic")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      17a61d1e
    • Damien Le Moal's avatar
      zonefs: Fix error message in zonefs_file_dio_append() · 6777291c
      Damien Le Moal authored
      commit 88b17008 upstream.
      
      Since the expected write location in a sequential file is always at the
      end of the file (append write), when an invalid write append location is
      detected in zonefs_file_dio_append(), print the invalid written location
      instead of the expected write location.
      
      Fixes: a608da3b
      
       ("zonefs: Detect append writes at invalid locations")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6777291c
    • Sean Christopherson's avatar
      KVM: x86: Purge "highest ISR" cache when updating APICv state · 71ab5c1d
      Sean Christopherson authored
      commit 97a71c44 upstream.
      
      Purge the "highest ISR" cache when updating APICv state on a vCPU.  The
      cache must not be used when APICv is active as hardware may emulate EOIs
      (and other operations) without exiting to KVM.
      
      This fixes a bug where KVM will effectively block IRQs in perpetuity due
      to the "highest ISR" never getting reset if APICv is activated on a vCPU
      while an IRQ is in-service.  Hardware emulates the EOI and KVM never gets
      a chance to update its cache.
      
      Fixes: b26a695a
      
       ("kvm: lapic: Introduce APICv update helper function")
      Cc: stable@vger.kernel.org
      Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Cc: Maxim Levitsky <mlevitsk@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Message-Id: <20230106011306.85230-3-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarAlejandro Jimenez <alejandro.j.jimenez@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71ab5c1d
    • Sean Christopherson's avatar
      KVM: x86: Inject #GP on x2APIC WRMSR that sets reserved bits 63:32 · 61e0863d
      Sean Christopherson authored
      commit ab52be1b
      
       upstream.
      
      Reject attempts to set bits 63:32 for 32-bit x2APIC registers, i.e. all
      x2APIC registers except ICR.  Per Intel's SDM:
      
        Non-zero writes (by WRMSR instruction) to reserved bits to these
        registers will raise a general protection fault exception
      
      Opportunistically fix a typo in a nearby comment.
      
      Reported-by: default avatarMarc Orr <marcorr@google.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Link: https://lore.kernel.org/r/20230107011025.565472-3-seanjc@google.com
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Signed-off-by: default avatarAlejandro Jimenez <alejandro.j.jimenez@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      61e0863d
    • Sean Christopherson's avatar
      KVM: VMX: Move preemption timer <=> hrtimer dance to common x86 · 4483dc41
      Sean Christopherson authored
      commit 98c25ead
      
       upstream.
      
      Handle the switch to/from the hypervisor/software timer when a vCPU is
      blocking in common x86 instead of in VMX.  Even though VMX is the only
      user of a hypervisor timer, the logic and all functions involved are
      generic x86 (unless future CPUs do something completely different and
      implement a hypervisor timer that runs regardless of mode).
      
      Handling the switch in common x86 will allow for the elimination of the
      pre/post_blocks hooks, and also lets KVM switch back to the hypervisor
      timer if and only if it was in use (without additional params).  Add a
      comment explaining why the switch cannot be deferred to kvm_sched_out()
      or kvm_vcpu_block().
      
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20211208015236.1616697-8-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      [ta: Fix conflicts in vmx_pre_block and vmx_post_block as per Paolo's
      suggestion. Add Reported-by and Link tags.]
      Reported-by: default avatar <syzbot+b6a74be92b5063a0f1ff@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?id=489beb3d76ef14cc6cd18125782dc6f86051a605
      Tested-by: default avatarTudor Ambarus <tudor.ambarus@linaro.org>
      Signed-off-by: default avatarTudor Ambarus <tudor.ambarus@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4483dc41
    • Heiko Carstens's avatar
      s390/uaccess: add missing earlyclobber annotations to __clear_user() · a58d4e66
      Heiko Carstens authored
      commit 89aba4c2 upstream.
      
      Add missing earlyclobber annotation to size, to, and tmp2 operands of the
      __clear_user() inline assembly since they are modified or written to before
      the last usage of all input operands. This can lead to incorrect register
      allocation for the inline assembly.
      
      Fixes: 6c2a9e6d
      
       ("[S390] Use alternative user-copy operations for new hardware.")
      Reported-by: default avatarMark Rutland <mark.rutland@arm.com>
      Link: https://lore.kernel.org/all/20230321122514.17438898
      
      -3-mark.rutland@arm.com/
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarGerald Schaefer <gerald.schaefer@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a58d4e66
    • Marc Zyngier's avatar
      KVM: arm64: Disable interrupts while walking userspace PTs · 1dfccde6
      Marc Zyngier authored
      commit e86fc1a3
      
       upstream.
      
      We walk the userspace PTs to discover what mapping size was
      used there. However, this can race against the userspace tables
      being freed, and we end-up in the weeds.
      
      Thankfully, the mm code is being generous and will IPI us when
      doing so. So let's implement our part of the bargain and disable
      interrupts around the walk. This ensures that nothing terrible
      happens during that time.
      
      We still need to handle the removal of the page tables before
      the walk. For that, allow get_user_mapping_size() to return an
      error, and make sure this error can be propagated all the way
      to the the exit handler.
      
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20230316174546.3777507-2-maz@kernel.org
      Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1dfccde6
    • Fangzhi Zuo's avatar
      drm/amd/display: Add DSC Support for Synaptics Cascaded MST Hub · 25e74e72
      Fangzhi Zuo authored
      commit f4f3b7de
      
       upstream.
      
      Traditional synaptics hub has one MST branch device without virtual dpcd.
      Synaptics cascaded hub has two chained MST branch devices. DSC decoding
      is performed via root MST branch device, instead of the second MST branch
      device.
      
      Reviewed-by: default avatarHersen Wu <hersenxs.wu@amd.com>
      Acked-by: default avatarQingqing Zhuo <qingqing.zhuo@amd.com>
      Signed-off-by: default avatarFangzhi Zuo <Jerry.Zuo@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      25e74e72
    • Lucas Stach's avatar
      drm/etnaviv: fix reference leak when mmaping imported buffer · 3bfedfdb
      Lucas Stach authored
      commit 963b2e8c
      
       upstream.
      
      drm_gem_prime_mmap() takes a reference on the GEM object, but before that
      drm_gem_mmap_obj() already takes a reference, which will be leaked as only
      one reference is dropped when the mapping is closed. Drop the extra
      reference when dma_buf_mmap() succeeds.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Reviewed-by: default avatarChristian Gmeiner <christian.gmeiner@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3bfedfdb
    • Douglas Raillard's avatar
      rcu: Fix rcu_torture_read ftrace event · fd1f4861
      Douglas Raillard authored
      commit d18a0415
      
       upstream.
      
      Fix the rcutorturename field so that its size is correctly reported in
      the text format embedded in trace.dat files. As it stands, it is
      reported as being of size 1:
      
          field:char rcutorturename[8];   offset:8;       size:1; signed:0;
      
      Signed-off-by: default avatarDouglas Raillard <douglas.raillard@arm.com>
      Reviewed-by: default avatarMukesh Ojha <quic_mojha@quicinc.com>
      Cc: stable@vger.kernel.org
      Fixes: 04ae87a5
      
       ("ftrace: Rework event_create_dir()")
      Reviewed-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      [ boqun: Add "Cc" and "Fixes" tags per Steven ]
      Signed-off-by: default avatarBoqun Feng <boqun.feng@gmail.com>
      Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fd1f4861
    • Max Filippov's avatar
      xtensa: fix KASAN report for show_stack · 9097ba15
      Max Filippov authored
      commit 1d3b7a78
      
       upstream.
      
      show_stack dumps raw stack contents which may trigger an unnecessary
      KASAN report. Fix it by copying stack contents to a temporary buffer
      with __memcpy and then printing that buffer instead of passing stack
      pointer directly to the print_hex_dump.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9097ba15
    • huangwenhui's avatar
      ALSA: hda/realtek: Add quirk for Lenovo ZhaoYang CF4620Z · 8861429f
      huangwenhui authored
      commit 52aad393
      
       upstream.
      
      Fix headset microphone detection on Lenovo ZhaoYang CF4620Z.
      
      [ adjusted to be applicable to the latest tree -- tiwai ]
      
      Signed-off-by: default avatarhuangwenhui <huangwenhuia@uniontech.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20230328074644.30142-1-huangwenhuia@uniontech.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8861429f
    • Tim Crawford's avatar
      ALSA: hda/realtek: Add quirks for some Clevo laptops · 77ab3e5f
      Tim Crawford authored
      commit b7a58228
      
       upstream.
      
      Add the audio quirk for some of Clevo's latest RPL laptops:
      
      - NP50RNJS (ALC256)
      - NP70SNE (ALC256)
      - PD50SNE (ALC1220)
      - PE60RNE (ALC1220)
      
      Co-authored-by: default avatarJeremy Soller <jeremy@system76.com>
      Signed-off-by: default avatarTim Crawford <tcrawford@system76.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20230317141825.11807-1-tcrawford@system76.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      77ab3e5f
    • Takashi Iwai's avatar
      ALSA: usb-audio: Fix regression on detection of Roland VS-100 · f775413f
      Takashi Iwai authored
      commit fa4e7a6f upstream.
      
      It's been reported that the recent kernel can't probe the PCM devices
      on Roland VS-100 properly, and it turned out to be a regression by the
      recent addition of the bit shift range check for the format bits.
      In the old code, we just did bit-shift and it resulted in zero, which
      is then corrected to the standard PCM format, while the new code
      explicitly returns an error in such a case.
      
      For addressing the regression, relax the check and fallback to the
      standard PCM type (with the info output).
      
      Fixes: 43d5ca88
      
       ("ALSA: usb-audio: Fix potential out-of-bounds shift")
      Cc: <stable@vger.kernel.org>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=217084
      Link: https://lore.kernel.org/r/20230324075005.19403-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f775413f
    • Takashi Iwai's avatar
      ALSA: hda/conexant: Partial revert of a quirk for Lenovo · b39d42ed
      Takashi Iwai authored
      commit b871cb97 upstream.
      
      The recent commit f83bb259 ("ALSA: hda/conexant: Add quirk for
      LENOVO 20149 Notebook model") introduced a quirk for the device with
      17aa:3977, but this caused a regression on another model (Lenovo
      Ideadpad U31) with the very same PCI SSID.  And, through skimming over
      the net, it seems that this PCI SSID is used for multiple different
      models, so it's no good idea to apply the quirk with the SSID.
      
      Although we may take a different ID check (e.g. the codec SSID instead
      of the PCI SSID), unfortunately, the original patch author couldn't
      identify the hardware details any longer as the machine was returned,
      and we can't develop the further proper fix.
      
      In this patch, instead, we partially revert the change so that the
      quirk won't be applied as default for addressing the regression.
      Meanwhile, the quirk function itself is kept, and it's now made to be
      applicable via the explicit model=lenovo-20149 option.
      
      Fixes: f83bb259
      
       ("ALSA: hda/conexant: Add quirk for LENOVO 20149 Notebook model")
      Reported-by: default avatarJetro Jormalainen <jje-lxkl@jetro.fi>
      Link: https://lore.kernel.org/r/20230308215009.4d3e58a6@mopti
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20230320140954.31154-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b39d42ed
    • Trond Myklebust's avatar
      NFSv4: Fix hangs when recovering open state after a server reboot · 305a171c
      Trond Myklebust authored
      commit 6165a16a upstream.
      
      When we're using a cached open stateid or a delegation in order to avoid
      sending a CLAIM_PREVIOUS open RPC call to the server, we don't have a
      new open stateid to present to update_open_stateid().
      Instead rely on nfs4_try_open_cached(), just as if we were doing a
      normal open.
      
      Fixes: d2bfda2e
      
       ("NFSv4: don't reprocess cached open CLAIM_PREVIOUS")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      305a171c
    • Jens Axboe's avatar
      powerpc: Don't try to copy PPR for task with NULL pt_regs · 7624973b
      Jens Axboe authored
      commit fd727618 upstream.
      
      powerpc sets up PF_KTHREAD and PF_IO_WORKER with a NULL pt_regs, which
      from my (arguably very short) checking is not commonly done for other
      archs. This is fine, except when PF_IO_WORKER's have been created and
      the task does something that causes a coredump to be generated. Then we
      get this crash:
      
        Kernel attempted to read user page (160) - exploit attempt? (uid: 1000)
        BUG: Kernel NULL pointer dereference on read at 0x00000160
        Faulting instruction address: 0xc0000000000c3a60
        Oops: Kernel access of bad area, sig: 11 [#1]
        LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=32 NUMA pSeries
        Modules linked in: bochs drm_vram_helper drm_kms_helper xts binfmt_misc ecb ctr syscopyarea sysfillrect cbc sysimgblt drm_ttm_helper aes_generic ttm sg libaes evdev joydev virtio_balloon vmx_crypto gf128mul drm dm_mod fuse loop configfs drm_panel_orientation_quirks ip_tables x_tables autofs4 hid_generic usbhid hid xhci_pci xhci_hcd usbcore usb_common sd_mod
        CPU: 1 PID: 1982 Comm: ppc-crash Not tainted 6.3.0-rc2+ #88
        Hardware name: IBM pSeries (emulated by qemu) POWER9 (raw) 0x4e1202 0xf000005 of:SLOF,HEAD hv:linux,kvm pSeries
        NIP:  c0000000000c3a60 LR: c000000000039944 CTR: c0000000000398e0
        REGS: c0000000041833b0 TRAP: 0300   Not tainted  (6.3.0-rc2+)
        MSR:  800000000280b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>  CR: 88082828  XER: 200400f8
        ...
        NIP memcpy_power7+0x200/0x7d0
        LR  ppr_get+0x64/0xb0
        Call Trace:
          ppr_get+0x40/0xb0 (unreliable)
          __regset_get+0x180/0x1f0
          regset_get_alloc+0x64/0x90
          elf_core_dump+0xb98/0x1b60
          do_coredump+0x1c34/0x24a0
          get_signal+0x71c/0x1410
          do_notify_resume+0x140/0x6f0
          interrupt_exit_user_prepare_main+0x29c/0x320
          interrupt_exit_user_prepare+0x6c/0xa0
          interrupt_return_srr_user+0x8/0x138
      
      Because ppr_get() is trying to copy from a PF_IO_WORKER with a NULL
      pt_regs.
      
      Check for a valid pt_regs in both ppc_get/ppr_set, and return an error
      if not set. The actual error value doesn't seem to be important here, so
      just pick -EINVAL.
      
      Fixes: fa439810
      
       ("powerpc/ptrace: Enable support for NT_PPPC_TAR, NT_PPC_PPR, NT_PPC_DSCR")
      Cc: stable@vger.kernel.org # v4.8+
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      [mpe: Trim oops in change log, add Fixes & Cc stable]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/d9f63344-fe7c-56ae-b420-4a1a04a2ae4c@kernel.dk
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7624973b
    • Johan Hovold's avatar
      pinctrl: at91-pio4: fix domain name assignment · 3a951011
      Johan Hovold authored
      commit 7bb97e36 upstream.
      
      Since commit d59f6617 ("genirq: Allow fwnode to carry name
      information only") an IRQ domain is always given a name during
      allocation (e.g. used for the debugfs entry).
      
      Drop the no longer valid name assignment, which would lead to an attempt
      to free a string constant when removing the domain on late probe
      failures (e.g. probe deferral).
      
      Fixes: d59f6617
      
       ("genirq: Allow fwnode to carry name information only")
      Cc: stable@vger.kernel.org	# 4.13
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
      Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com> # on SAMA7G5
      Link: https://lore.kernel.org/r/20230224130828.27985-1-johan+linaro@kernel.org
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3a951011
    • Kornel Dulęba's avatar
      pinctrl: amd: Disable and mask interrupts on resume · 6c1bc7b5
      Kornel Dulęba authored
      commit b26cd932 upstream.
      
      This fixes a similar problem to the one observed in:
      commit 4e5a04be ("pinctrl: amd: disable and mask interrupts on probe").
      
      On some systems, during suspend/resume cycle firmware leaves
      an interrupt enabled on a pin that is not used by the kernel.
      This confuses the AMD pinctrl driver and causes spurious interrupts.
      
      The driver already has logic to detect if a pin is used by the kernel.
      Leverage it to re-initialize interrupt fields of a pin only if it's not
      used by us.
      
      Cc: stable@vger.kernel.org
      Fixes: dbad75dd
      
       ("pinctrl: add AMD GPIO driver support.")
      Signed-off-by: default avatarKornel Dulęba <korneld@chromium.org>
      Link: https://lore.kernel.org/r/20230320093259.845178-1-korneld@chromium.org
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6c1bc7b5
    • Josua Mayer's avatar
      net: phy: dp83869: fix default value for tx-/rx-internal-delay · 45ed4e51
      Josua Mayer authored
      commit 82e2c39f upstream.
      
      dp83869 internally uses a look-up table for mapping supported delays in
      nanoseconds to register values.
      When specific delays are defined in device-tree, phy_get_internal_delay
      does the lookup automatically returning an index.
      
      The default case wrongly assigns the nanoseconds value from the lookup
      table, resulting in numeric value 2000 applied to delay configuration
      register, rather than the expected index values 0-7 (7 for 2000).
      Ultimately this issue broke RX for 1Gbps links.
      
      Fix default delay configuration by assigning the intended index value
      directly.
      
      Cc: stable@vger.kernel.org
      Fixes: 736b25af
      
       ("net: dp83869: Add RGMII internal delay configuration")
      Co-developed-by: default avatarYazan Shhady <yazan.shhady@solid-run.com>
      Signed-off-by: default avatarYazan Shhady <yazan.shhady@solid-run.com>
      Signed-off-by: default avatarJosua Mayer <josua@solid-run.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/20230323102536.31988-1-josua@solid-run.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45ed4e51
    • Juergen Gross's avatar
      xen/netback: don't do grant copy across page boundary · 0f75ef13
      Juergen Gross authored
      commit 05310f31 upstream.
      
      Fix xenvif_get_requests() not to do grant copy operations across local
      page boundaries. This requires to double the maximum number of copy
      operations per queue, as each copy could now be split into 2.
      
      Make sure that struct xenvif_tx_cb doesn't grow too large.
      
      Cc: stable@vger.kernel.org
      Fixes: ad7f402a
      
       ("xen/netback: Ensure protocol headers don't fall in the non-linear area")
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarPaul Durrant <paul@xen.org>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0f75ef13
    • Oleksij Rempel's avatar
      can: j1939: prevent deadlock by moving j1939_sk_errqueue() · 8a581b71
      Oleksij Rempel authored
      commit d1366b28
      
       upstream.
      
      This commit addresses a deadlock situation that can occur in certain
      scenarios, such as when running data TP/ETP transfer and subscribing to
      the error queue while receiving a net down event. The deadlock involves
      locks in the following order:
      
      3
        j1939_session_list_lock ->  active_session_list_lock
        j1939_session_activate
        ...
        j1939_sk_queue_activate_next -> sk_session_queue_lock
        ...
        j1939_xtp_rx_eoma_one
      
      2
        j1939_sk_queue_drop_all  ->  sk_session_queue_lock
        ...
        j1939_sk_netdev_event_netdown -> j1939_socks_lock
        j1939_netdev_notify
      
      1
        j1939_sk_errqueue -> j1939_socks_lock
        __j1939_session_cancel -> active_session_list_lock
        j1939_tp_rxtimer
      
             CPU0                    CPU1
             ----                    ----
        lock(&priv->active_session_list_lock);
                                     lock(&jsk->sk_session_queue_lock);
                                     lock(&priv->active_session_list_lock);
        lock(&priv->j1939_socks_lock);
      
      The solution implemented in this commit is to move the
      j1939_sk_errqueue() call out of the active_session_list_lock context,
      thus preventing the deadlock situation.
      
      Reported-by: default avatar <syzbot+ee1cd780f69483a8616b@syzkaller.appspotmail.com>
      Fixes: 5b9272e9
      
       ("can: j1939: extend UAPI to notify about RX status")
      Co-developed-by: default avatarHillf Danton <hdanton@sina.com>
      Signed-off-by: default avatarHillf Danton <hdanton@sina.com>
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Link: https://lore.kernel.org/all/20230324130141.2132787-1-o.rempel@pengutronix.de
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a581b71
    • Damien Le Moal's avatar
      zonefs: Always invalidate last cached page on append write · a3373a68
      Damien Le Moal authored
      commit c1976bd8
      
       upstream.
      
      When a direct append write is executed, the append offset may correspond
      to the last page of a sequential file inode which might have been cached
      already by buffered reads, page faults with mmap-read or non-direct
      readahead. To ensure that the on-disk and cached data is consistant for
      such last cached page, make sure to always invalidate it in
      zonefs_file_dio_append(). If the invalidation fails, return -EBUSY to
      userspace to differentiate from IO errors.
      
      This invalidation will always be a no-op when the FS block size (device
      zone write granularity) is equal to the page size (e.g. 4K).
      
      Reported-by: default avatarHans Holmberg <Hans.Holmberg@wdc.com>
      Fixes: 02ef12a6
      
       ("zonefs: use REQ_OP_ZONE_APPEND for sync DIO")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Tested-by: default avatarHans Holmberg <hans.holmberg@wdc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a3373a68
    • Anand Jain's avatar
      btrfs: scan device in non-exclusive mode · c1310fc7
      Anand Jain authored
      commit 50d281fc
      
       upstream.
      
      This fixes mkfs/mount/check failures due to race with systemd-udevd
      scan.
      
      During the device scan initiated by systemd-udevd, other user space
      EXCL operations such as mkfs, mount, or check may get blocked and result
      in a "Device or resource busy" error. This is because the device
      scan process opens the device with the EXCL flag in the kernel.
      
      Two reports were received:
      
       - btrfs/179 test case, where the fsck command failed with the -EBUSY
         error
      
       - LTP pwritev03 test case, where mkfs.vfs failed with
         the -EBUSY error, when mkfs.vfs tried to overwrite old btrfs filesystem
         on the device.
      
      In both cases, fsck and mkfs (respectively) were racing with a
      systemd-udevd device scan, and systemd-udevd won, resulting in the
      -EBUSY error for fsck and mkfs.
      
      Reproducing the problem has been difficult because there is a very
      small window during which these userspace threads can race to
      acquire the exclusive device open. Even on the system where the problem
      was observed, the problem occurrences were anywhere between 10 to 400
      iterations and chances of reproducing decreases with debug printk()s.
      
      However, an exclusive device open is unnecessary for the scan process,
      as there are no write operations on the device during scan. Furthermore,
      during the mount process, the superblock is re-read in the below
      function call chain:
      
        btrfs_mount_root
         btrfs_open_devices
          open_fs_devices
           btrfs_open_one_device
             btrfs_get_bdev_and_sb
      
      So, to fix this issue, removes the FMODE_EXCL flag from the scan
      operation, and add a comment.
      
      The case where mkfs may still write to the device and a scan is running,
      the btrfs signature is not written at that time so scan will not
      recognize such device.
      
      Reported-by: default avatarSherry Yang <sherry.yang@oracle.com>
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Link: https://lore.kernel.org/oe-lkp/202303170839.fdf23068-oliver.sang@intel.com
      CC: stable@vger.kernel.org # 5.4+
      Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c1310fc7
    • Filipe Manana's avatar
      btrfs: fix race between quota disable and quota assign ioctls · c976f923
      Filipe Manana authored
      commit 2f1a6be1
      
       upstream.
      
      The quota assign ioctl can currently run in parallel with a quota disable
      ioctl call. The assign ioctl uses the quota root, while the disable ioctl
      frees that root, and therefore we can have a use-after-free triggered in
      the assign ioctl, leading to a trace like the following when KASAN is
      enabled:
      
        [672.723][T736] BUG: KASAN: slab-use-after-free in btrfs_search_slot+0x2962/0x2db0
        [672.723][T736] Read of size 8 at addr ffff888022ec0208 by task btrfs_search_sl/27736
        [672.724][T736]
        [672.725][T736] CPU: 1 PID: 27736 Comm: btrfs_search_sl Not tainted 6.3.0-rc3 #37
        [672.723][T736] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
        [672.727][T736] Call Trace:
        [672.728][T736]  <TASK>
        [672.728][T736]  dump_stack_lvl+0xd9/0x150
        [672.725][T736]  print_report+0xc1/0x5e0
        [672.720][T736]  ? __virt_addr_valid+0x61/0x2e0
        [672.727][T736]  ? __phys_addr+0xc9/0x150
        [672.725][T736]  ? btrfs_search_slot+0x2962/0x2db0
        [672.722][T736]  kasan_report+0xc0/0xf0
        [672.729][T736]  ? btrfs_search_slot+0x2962/0x2db0
        [672.724][T736]  btrfs_search_slot+0x2962/0x2db0
        [672.723][T736]  ? fs_reclaim_acquire+0xba/0x160
        [672.722][T736]  ? split_leaf+0x13d0/0x13d0
        [672.726][T736]  ? rcu_is_watching+0x12/0xb0
        [672.723][T736]  ? kmem_cache_alloc+0x338/0x3c0
        [672.722][T736]  update_qgroup_status_item+0xf7/0x320
        [672.724][T736]  ? add_qgroup_rb+0x3d0/0x3d0
        [672.739][T736]  ? do_raw_spin_lock+0x12d/0x2b0
        [672.730][T736]  ? spin_bug+0x1d0/0x1d0
        [672.737][T736]  btrfs_run_qgroups+0x5de/0x840
        [672.730][T736]  ? btrfs_qgroup_rescan_worker+0xa70/0xa70
        [672.738][T736]  ? __del_qgroup_relation+0x4ba/0xe00
        [672.738][T736]  btrfs_ioctl+0x3d58/0x5d80
        [672.735][T736]  ? tomoyo_path_number_perm+0x16a/0x550
        [672.737][T736]  ? tomoyo_execute_permission+0x4a0/0x4a0
        [672.731][T736]  ? btrfs_ioctl_get_supported_features+0x50/0x50
        [672.737][T736]  ? __sanitizer_cov_trace_switch+0x54/0x90
        [672.734][T736]  ? do_vfs_ioctl+0x132/0x1660
        [672.730][T736]  ? vfs_fileattr_set+0xc40/0xc40
        [672.730][T736]  ? _raw_spin_unlock_irq+0x2e/0x50
        [672.732][T736]  ? sigprocmask+0xf2/0x340
        [672.737][T736]  ? __fget_files+0x26a/0x480
        [672.732][T736]  ? bpf_lsm_file_ioctl+0x9/0x10
        [672.738][T736]  ? btrfs_ioctl_get_supported_features+0x50/0x50
        [672.736][T736]  __x64_sys_ioctl+0x198/0x210
        [672.736][T736]  do_syscall_64+0x39/0xb0
        [672.731][T736]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
        [672.739][T736] RIP: 0033:0x4556ad
        [672.742][T736]  </TASK>
        [672.743][T736]
        [672.748][T736] Allocated by task 27677:
        [672.743][T736]  kasan_save_stack+0x22/0x40
        [672.741][T736]  kasan_set_track+0x25/0x30
        [672.741][T736]  __kasan_kmalloc+0xa4/0xb0
        [672.749][T736]  btrfs_alloc_root+0x48/0x90
        [672.746][T736]  btrfs_create_tree+0x146/0xa20
        [672.744][T736]  btrfs_quota_enable+0x461/0x1d20
        [672.743][T736]  btrfs_ioctl+0x4a1c/0x5d80
        [672.747][T736]  __x64_sys_ioctl+0x198/0x210
        [672.749][T736]  do_syscall_64+0x39/0xb0
        [672.744][T736]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
        [672.756][T736]
        [672.757][T736] Freed by task 27677:
        [672.759][T736]  kasan_save_stack+0x22/0x40
        [672.759][T736]  kasan_set_track+0x25/0x30
        [672.756][T736]  kasan_save_free_info+0x2e/0x50
        [672.751][T736]  ____kasan_slab_free+0x162/0x1c0
        [672.758][T736]  slab_free_freelist_hook+0x89/0x1c0
        [672.752][T736]  __kmem_cache_free+0xaf/0x2e0
        [672.752][T736]  btrfs_put_root+0x1ff/0x2b0
        [672.759][T736]  btrfs_quota_disable+0x80a/0xbc0
        [672.752][T736]  btrfs_ioctl+0x3e5f/0x5d80
        [672.756][T736]  __x64_sys_ioctl+0x198/0x210
        [672.753][T736]  do_syscall_64+0x39/0xb0
        [672.765][T736]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
        [672.769][T736]
        [672.768][T736] The buggy address belongs to the object at ffff888022ec0000
        [672.768][T736]  which belongs to the cache kmalloc-4k of size 4096
        [672.769][T736] The buggy address is located 520 bytes inside of
        [672.769][T736]  freed 4096-byte region [ffff888022ec0000, ffff888022ec1000)
        [672.760][T736]
        [672.764][T736] The buggy address belongs to the physical page:
        [672.761][T736] page:ffffea00008bb000 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x22ec0
        [672.766][T736] head:ffffea00008bb000 order:3 entire_mapcount:0 nr_pages_mapped:0 pincount:0
        [672.779][T736] flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
        [672.770][T736] raw: 00fff00000010200 ffff888012842140 ffffea000054ba00 dead000000000002
        [672.770][T736] raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
        [672.771][T736] page dumped because: kasan: bad access detected
        [672.778][T736] page_owner tracks the page as allocated
        [672.777][T736] page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd2040(__GFP_IO|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 88
        [672.779][T736]  get_page_from_freelist+0x119c/0x2d50
        [672.779][T736]  __alloc_pages+0x1cb/0x4a0
        [672.776][T736]  alloc_pages+0x1aa/0x270
        [672.773][T736]  allocate_slab+0x260/0x390
        [672.771][T736]  ___slab_alloc+0xa9a/0x13e0
        [672.778][T736]  __slab_alloc.constprop.0+0x56/0xb0
        [672.771][T736]  __kmem_cache_alloc_node+0x136/0x320
        [672.789][T736]  __kmalloc+0x4e/0x1a0
        [672.783][T736]  tomoyo_realpath_from_path+0xc3/0x600
        [672.781][T736]  tomoyo_path_perm+0x22f/0x420
        [672.782][T736]  tomoyo_path_unlink+0x92/0xd0
        [672.780][T736]  security_path_unlink+0xdb/0x150
        [672.788][T736]  do_unlinkat+0x377/0x680
        [672.788][T736]  __x64_sys_unlink+0xca/0x110
        [672.789][T736]  do_syscall_64+0x39/0xb0
        [672.783][T736]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
        [672.784][T736] page last free stack trace:
        [672.787][T736]  free_pcp_prepare+0x4e5/0x920
        [672.787][T736]  free_unref_page+0x1d/0x4e0
        [672.784][T736]  __unfreeze_partials+0x17c/0x1a0
        [672.797][T736]  qlist_free_all+0x6a/0x180
        [672.796][T736]  kasan_quarantine_reduce+0x189/0x1d0
        [672.797][T736]  __kasan_slab_alloc+0x64/0x90
        [672.793][T736]  kmem_cache_alloc+0x17c/0x3c0
        [672.799][T736]  getname_flags.part.0+0x50/0x4e0
        [672.799][T736]  getname_flags+0x9e/0xe0
        [672.792][T736]  vfs_fstatat+0x77/0xb0
        [672.791][T736]  __do_sys_newlstat+0x84/0x100
        [672.798][T736]  do_syscall_64+0x39/0xb0
        [672.796][T736]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
        [672.790][T736]
        [672.791][T736] Memory state around the buggy address:
        [672.799][T736]  ffff888022ec0100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        [672.805][T736]  ffff888022ec0180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        [672.802][T736] >ffff888022ec0200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        [672.809][T736]                       ^
        [672.809][T736]  ffff888022ec0280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
        [672.809][T736]  ffff888022ec0300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      
      Fix this by having the qgroup assign ioctl take the qgroup ioctl mutex
      before calling btrfs_run_qgroups(), which is what all qgroup ioctls should
      call.
      
      Reported-by: default avatarbutt3rflyh4ck <butterflyhuangxx@gmail.com>
      Link: https://lore.kernel.org/linux-btrfs/CAFcO6XN3VD8ogmHwqRk4kbiwtpUSNySu2VAxN8waEPciCHJvMA@mail.gmail.com/
      CC: stable@vger.kernel.org # 5.10+
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c976f923
    • Hans de Goede's avatar
      Input: goodix - add Lenovo Yoga Book X90F to nine_bytes_report DMI table · 1484852c
      Hans de Goede authored
      commit 8a0432ba
      
       upstream.
      
      The Android Lenovo Yoga Book X90F / X90L uses the same goodix touchscreen
      with 9 bytes touch reports for its touch keyboard as the already supported
      Windows Lenovo Yoga Book X91F/L, add a DMI match for this to
      the nine_bytes_report DMI table.
      
      When the quirk for the X91F/L was initially added it was written to
      also apply to the X90F/L but this does not work because the Android
      version of the Yoga Book uses completely different DMI strings.
      Also adjust the X91F/L quirk to reflect that it only applies to
      the X91F/L models.
      
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarBastien Nocera <hadess@hadess.net>
      Link: https://lore.kernel.org/r/20230315134442.71787-1-hdegoede@redhat.com
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1484852c
    • David Disseldorp's avatar
      cifs: fix DFS traversal oops without CONFIG_CIFS_DFS_UPCALL · b6430518
      David Disseldorp authored
      commit 179a88a8
      
       upstream.
      
      When compiled with CONFIG_CIFS_DFS_UPCALL disabled, cifs_dfs_d_automount
      is NULL. cifs.ko logic for mapping CIFS_FATTR_DFS_REFERRAL attributes to
      S_AUTOMOUNT and corresponding dentry flags is retained regardless of
      CONFIG_CIFS_DFS_UPCALL, leading to a NULL pointer dereference in
      VFS follow_automount() when traversing a DFS referral link:
        BUG: kernel NULL pointer dereference, address: 0000000000000000
        ...
        Call Trace:
         <TASK>
         __traverse_mounts+0xb5/0x220
         ? cifs_revalidate_mapping+0x65/0xc0 [cifs]
         step_into+0x195/0x610
         ? lookup_fast+0xe2/0xf0
         path_lookupat+0x64/0x140
         filename_lookup+0xc2/0x140
         ? __create_object+0x299/0x380
         ? kmem_cache_alloc+0x119/0x220
         ? user_path_at_empty+0x31/0x50
         user_path_at_empty+0x31/0x50
         __x64_sys_chdir+0x2a/0xd0
         ? exit_to_user_mode_prepare+0xca/0x100
         do_syscall_64+0x42/0x90
         entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      This fix adds an inline cifs_dfs_d_automount() {return -EREMOTE} handler
      when CONFIG_CIFS_DFS_UPCALL is disabled. An alternative would be to
      avoid flagging S_AUTOMOUNT, etc. without CONFIG_CIFS_DFS_UPCALL. This
      approach was chosen as it provides more control over the error path.
      
      Signed-off-by: default avatarDavid Disseldorp <ddiss@suse.de>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b6430518