Skip to content
  1. Sep 15, 2022
    • Ville Syrjälä's avatar
      drm/i915: Implement WaEdpLinkRateDataReload · de572ede
      Ville Syrjälä authored
      commit 672d6ca7 upstream.
      
      A lot of modern laptops use the Parade PS8461E MUX for eDP
      switching. The MUX can operate in jitter cleaning mode or
      redriver mode, the first one resulting in higher link
      quality. The jitter cleaning mode needs to know the link
      rate used and the MUX achieves this by snooping the
      LINK_BW_SET, LINK_RATE_SELECT and SUPPORTED_LINK_RATES
      DPCD accesses.
      
      When the MUX is powered down (seems this can happen whenever
      the display is turned off) it loses track of the snooped
      link rates so when we do the LINK_RATE_SELECT write it no
      longer knowns which link rate we're selecting, and thus it
      falls back to the lower quality redriver mode. This results
      in unstable high link rates (eg. usually 8.1Gbps link rate
      no longer works correctly).
      
      In order to avoid all that let's re-snoop SUPPORTED_LINK_RATES
      from the sink at the start of every link training.
      
      Unfortunately we don't have a way to detect the presence of
      the MUX. It looks like the set of laptops equipped with this
      MUX is fairly large and contains devices from multiple
      manufacturers. It may also still be growing with new models.
      So a quirk doesn't seem like a very easily maintainable
      option, thus we shall attempt to do this unconditionally on
      all machines that use LINK_RATE_SELECT. Hopefully this extra
      DPCD read doesn't cause issues for any unaffected machine.
      If that turns out to be the case we'll need to convert this
      into a quirk in the future.
      
      Cc: stable@vger.kernel.org
      Cc: Jason A. Donenfeld <Jason@zx2c4.com>
      Cc: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
      Cc: Jani Nikula <jani.nikula@intel.com>
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/6205
      
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220902070319.15395-1-ville.syrjala@linux.intel.com
      
      
      Tested-by: default avatarAaron Ma <aaron.ma@canonical.com>
      Tested-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
      Reviewed-by: default avatarJani Nikula <jani.nikula@intel.com>
      (cherry picked from commit 25899c59
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      de572ede
    • Bart Van Assche's avatar
      nvmet: fix a use-after-free · be01f1c9
      Bart Van Assche authored
      commit 6a02a61e upstream.
      
      Fix the following use-after-free complaint triggered by blktests nvme/004:
      
      BUG: KASAN: user-memory-access in blk_mq_complete_request_remote+0xac/0x350
      Read of size 4 at addr 0000607bd1835943 by task kworker/13:1/460
      Workqueue: nvmet-wq nvme_loop_execute_work [nvme_loop]
      Call Trace:
       show_stack+0x52/0x58
       dump_stack_lvl+0x49/0x5e
       print_report.cold+0x36/0x1e2
       kasan_report+0xb9/0xf0
       __asan_load4+0x6b/0x80
       blk_mq_complete_request_remote+0xac/0x350
       nvme_loop_queue_response+0x1df/0x275 [nvme_loop]
       __nvmet_req_complete+0x132/0x4f0 [nvmet]
       nvmet_req_complete+0x15/0x40 [nvmet]
       nvmet_execute_io_connect+0x18a/0x1f0 [nvmet]
       nvme_loop_execute_work+0x20/0x30 [nvme_loop]
       process_one_work+0x56e/0xa70
       worker_thread+0x2d1/0x640
       kthread+0x183/0x1c0
       ret_from_fork+0x1f/0x30
      
      Cc: stable@vger.kernel.org
      Fixes: a07b4970
      
       ("nvmet: add a generic NVMe target")
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be01f1c9
    • Greg Kroah-Hartman's avatar
      debugfs: add debugfs_lookup_and_remove() · 68f22c80
      Greg Kroah-Hartman authored
      commit dec9b2f1
      
       upstream.
      
      There is a very common pattern of using
      debugfs_remove(debufs_lookup(..)) which results in a dentry leak of the
      dentry that was looked up.  Instead of having to open-code the correct
      pattern of calling dput() on the dentry, create
      debugfs_lookup_and_remove() to handle this pattern automatically and
      properly without any memory leaks.
      
      Cc: stable <stable@kernel.org>
      Reported-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
      Tested-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
      Link: https://lore.kernel.org/r/YxIaQ8cSinDR881k@kroah.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      68f22c80
    • Christian A. Ehrhardt's avatar
      kprobes: Prohibit probes in gate area · ab600102
      Christian A. Ehrhardt authored
      commit 1efda38d upstream.
      
      The system call gate area counts as kernel text but trying
      to install a kprobe in this area fails with an Oops later on.
      To fix this explicitly disallow the gate area for kprobes.
      
      Found by syzkaller with the following reproducer:
      perf_event_open$cgroup(&(0x7f00000001c0)={0x6, 0x80, 0x0, 0x0, 0x0, 0x0, 0x80ffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @perf_config_ext={0x0, 0xffffffffff600000}}, 0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0x0)
      
      Sample report:
      BUG: unable to handle page fault for address: fffffbfff3ac6000
      PGD 6dfcb067 P4D 6dfcb067 PUD 6df8f067 PMD 6de4d067 PTE 0
      Oops: 0000 [#1] PREEMPT SMP KASAN NOPTI
      CPU: 0 PID: 21978 Comm: syz-executor.2 Not tainted 6.0.0-rc3-00363-g7726d4c3e60b-dirty #6
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
      RIP: 0010:__insn_get_emulate_prefix arch/x86/lib/insn.c:91 [inline]
      RIP: 0010:insn_get_emulate_prefix arch/x86/lib/insn.c:106 [inline]
      RIP: 0010:insn_get_prefixes.part.0+0xa8/0x1110 arch/x86/lib/insn.c:134
      Code: 49 be 00 00 00 00 00 fc ff df 48 8b 40 60 48 89 44 24 08 e9 81 00 00 00 e8 e5 4b 39 ff 4c 89 fa 4c 89 f9 48 c1 ea 03 83 e1 07 <42> 0f b6 14 32 38 ca 7f 08 84 d2 0f 85 06 10 00 00 48 89 d8 48 89
      RSP: 0018:ffffc900088bf860 EFLAGS: 00010246
      RAX: 0000000000040000 RBX: ffffffff9b9bebc0 RCX: 0000000000000000
      RDX: 1ffffffff3ac6000 RSI: ffffc90002d82000 RDI: ffffc900088bf9e8
      RBP: ffffffff9d630001 R08: 0000000000000000 R09: ffffc900088bf9e8
      R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001
      R13: ffffffff9d630000 R14: dffffc0000000000 R15: ffffffff9d630000
      FS:  00007f63eef63640(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: fffffbfff3ac6000 CR3: 0000000029d90005 CR4: 0000000000770ef0
      PKRU: 55555554
      Call Trace:
       <TASK>
       insn_get_prefixes arch/x86/lib/insn.c:131 [inline]
       insn_get_opcode arch/x86/lib/insn.c:272 [inline]
       insn_get_modrm+0x64a/0x7b0 arch/x86/lib/insn.c:343
       insn_get_sib+0x29a/0x330 arch/x86/lib/insn.c:421
       insn_get_displacement+0x350/0x6b0 arch/x86/lib/insn.c:464
       insn_get_immediate arch/x86/lib/insn.c:632 [inline]
       insn_get_length arch/x86/lib/insn.c:707 [inline]
       insn_decode+0x43a/0x490 arch/x86/lib/insn.c:747
       can_probe+0xfc/0x1d0 arch/x86/kernel/kprobes/core.c:282
       arch_prepare_kprobe+0x79/0x1c0 arch/x86/kernel/kprobes/core.c:739
       prepare_kprobe kernel/kprobes.c:1160 [inline]
       register_kprobe kernel/kprobes.c:1641 [inline]
       register_kprobe+0xb6e/0x1690 kernel/kprobes.c:1603
       __register_trace_kprobe kernel/trace/trace_kprobe.c:509 [inline]
       __register_trace_kprobe+0x26a/0x2d0 kernel/trace/trace_kprobe.c:477
       create_local_trace_kprobe+0x1f7/0x350 kernel/trace/trace_kprobe.c:1833
       perf_kprobe_init+0x18c/0x280 kernel/trace/trace_event_perf.c:271
       perf_kprobe_event_init+0xf8/0x1c0 kernel/events/core.c:9888
       perf_try_init_event+0x12d/0x570 kernel/events/core.c:11261
       perf_init_event kernel/events/core.c:11325 [inline]
       perf_event_alloc.part.0+0xf7f/0x36a0 kernel/events/core.c:11619
       perf_event_alloc kernel/events/core.c:12059 [inline]
       __do_sys_perf_event_open+0x4a8/0x2a00 kernel/events/core.c:12157
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f63ef7efaed
      Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007f63eef63028 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
      RAX: ffffffffffffffda RBX: 00007f63ef90ff80 RCX: 00007f63ef7efaed
      RDX: 0000000000000000 RSI: ffffffffffffffff RDI: 00000000200001c0
      RBP: 00007f63ef86019c R08: 0000000000000000 R09: 0000000000000000
      R10: ffffffffffffffff R11: 0000000000000246 R12: 0000000000000000
      R13: 0000000000000002 R14: 00007f63ef90ff80 R15: 00007f63eef43000
       </TASK>
      Modules linked in:
      CR2: fffffbfff3ac6000
      ---[ end trace 0000000000000000 ]---
      RIP: 0010:__insn_get_emulate_prefix arch/x86/lib/insn.c:91 [inline]
      RIP: 0010:insn_get_emulate_prefix arch/x86/lib/insn.c:106 [inline]
      RIP: 0010:insn_get_prefixes.part.0+0xa8/0x1110 arch/x86/lib/insn.c:134
      Code: 49 be 00 00 00 00 00 fc ff df 48 8b 40 60 48 89 44 24 08 e9 81 00 00 00 e8 e5 4b 39 ff 4c 89 fa 4c 89 f9 48 c1 ea 03 83 e1 07 <42> 0f b6 14 32 38 ca 7f 08 84 d2 0f 85 06 10 00 00 48 89 d8 48 89
      RSP: 0018:ffffc900088bf860 EFLAGS: 00010246
      RAX: 0000000000040000 RBX: ffffffff9b9bebc0 RCX: 0000000000000000
      RDX: 1ffffffff3ac6000 RSI: ffffc90002d82000 RDI: ffffc900088bf9e8
      RBP: ffffffff9d630001 R08: 0000000000000000 R09: ffffc900088bf9e8
      R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001
      R13: ffffffff9d630000 R14: dffffc0000000000 R15: ffffffff9d630000
      FS:  00007f63eef63640(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: fffffbfff3ac6000 CR3: 0000000029d90005 CR4: 0000000000770ef0
      PKRU: 55555554
      ==================================================================
      
      Link: https://lkml.kernel.org/r/20220907200917.654103-1-lk@c--e.de
      
      cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      cc: "David S. Miller" <davem@davemloft.net>
      Cc: stable@vger.kernel.org
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarChristian A. Ehrhardt <lk@c--e.de>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ab600102
    • Dongxiang Ke's avatar
      ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface() · 6123bec8
      Dongxiang Ke authored
      commit e53f47f6
      
       upstream.
      
      There may be a bad USB audio device with a USB ID of (0x04fa, 0x4201) and
      the number of it's interfaces less than 4, an out-of-bounds read bug occurs
      when parsing the interface descriptor for this device.
      
      Fix this by checking the number of interfaces.
      
      Signed-off-by: default avatarDongxiang Ke <kdx.glider@gmail.com>
      Link: https://lore.kernel.org/r/20220906024928.10951-1-kdx.glider@gmail.com
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6123bec8
    • Pattara Teerapong's avatar
      ALSA: aloop: Fix random zeros in capture data when using jiffies timer · ab730d3c
      Pattara Teerapong authored
      commit 3e48940a
      
       upstream.
      
      In loopback_jiffies_timer_pos_update(), we are getting jiffies twice.
      First time for playback, second time for capture. Jiffies can be updated
      between these two calls and if the capture jiffies is larger, extra zeros
      will be filled in the capture buffer.
      
      Change to get jiffies once and use it for both playback and capture.
      
      Signed-off-by: default avatarPattara Teerapong <pteerapong@chromium.org>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220901144036.4049060-1-pteerapong@chromium.org
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ab730d3c
    • Tasos Sahanidis's avatar
      ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc() · 39a90720
      Tasos Sahanidis authored
      commit d29f5905
      
       upstream.
      
      The voice allocator sometimes begins allocating from near the end of the
      array and then wraps around, however snd_emu10k1_pcm_channel_alloc()
      accesses the newly allocated voices as if it never wrapped around.
      
      This results in out of bounds access if the first voice has a high enough
      index so that first_voice + requested_voice_count > NUM_G (64).
      The more voices are requested, the more likely it is for this to occur.
      
      This was initially discovered using PipeWire, however it can be reproduced
      by calling aplay multiple times with 16 channels:
      aplay -r 48000 -D plughw:CARD=Live,DEV=3 -c 16 /dev/zero
      
      UBSAN: array-index-out-of-bounds in sound/pci/emu10k1/emupcm.c:127:40
      index 65 is out of range for type 'snd_emu10k1_voice [64]'
      CPU: 1 PID: 31977 Comm: aplay Tainted: G        W IOE      6.0.0-rc2-emu10k1+ #7
      Hardware name: ASUSTEK COMPUTER INC P5W DH Deluxe/P5W DH Deluxe, BIOS 3002    07/22/2010
      Call Trace:
      <TASK>
      dump_stack_lvl+0x49/0x63
      dump_stack+0x10/0x16
      ubsan_epilogue+0x9/0x3f
      __ubsan_handle_out_of_bounds.cold+0x44/0x49
      snd_emu10k1_playback_hw_params+0x3bc/0x420 [snd_emu10k1]
      snd_pcm_hw_params+0x29f/0x600 [snd_pcm]
      snd_pcm_common_ioctl+0x188/0x1410 [snd_pcm]
      ? exit_to_user_mode_prepare+0x35/0x170
      ? do_syscall_64+0x69/0x90
      ? syscall_exit_to_user_mode+0x26/0x50
      ? do_syscall_64+0x69/0x90
      ? exit_to_user_mode_prepare+0x35/0x170
      snd_pcm_ioctl+0x27/0x40 [snd_pcm]
      __x64_sys_ioctl+0x95/0xd0
      do_syscall_64+0x5c/0x90
      ? do_syscall_64+0x69/0x90
      ? do_syscall_64+0x69/0x90
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Signed-off-by: default avatarTasos Sahanidis <tasos@tasossah.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/3707dcab-320a-62ff-63c0-73fc201ef756@tasossah.com
      
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39a90720
    • Qu Huang's avatar
      drm/amdgpu: mmVM_L2_CNTL3 register not initialized correctly · dfb27648
      Qu Huang authored
      [ Upstream commit b8983d42
      
       ]
      
      The mmVM_L2_CNTL3 register is not assigned an initial value
      
      Signed-off-by: default avatarQu Huang <jinsdb@126.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dfb27648
    • Yang Yingliang's avatar
      fbdev: chipsfb: Add missing pci_disable_device() in chipsfb_pci_init() · 2078e326
      Yang Yingliang authored
      [ Upstream commit 07c55c98
      
       ]
      
      Add missing pci_disable_device() in error path in chipsfb_pci_init().
      
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2078e326
    • lily's avatar
      net/core/skbuff: Check the return value of skb_copy_bits() · 9d040a62
      lily authored
      [ Upstream commit c624c58e
      
       ]
      
      skb_copy_bits() could fail, which requires a check on the return
      value.
      
      Signed-off-by: default avatarLi Zhong <floridsleeves@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9d040a62
    • Sudeep Holla's avatar
      arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level · 43b9af72
      Sudeep Holla authored
      [ Upstream commit e75d18ce ]
      
      Though acpi_find_last_cache_level() always returned signed value and the
      document states it will return any errors caused by lack of a PPTT table,
      it never returned negative values before.
      
      Commit 0c80f9e1
      
       ("ACPI: PPTT: Leave the table mapped for the runtime usage")
      however changed it by returning -ENOENT if no PPTT was found. The value
      returned from acpi_find_last_cache_level() is then assigned to unsigned
      fw_level.
      
      It will result in the number of cache leaves calculated incorrectly as
      a huge value which will then cause the following warning from __alloc_pages
      as the order would be great than MAX_ORDER because of incorrect and huge
      cache leaves value.
      
        |  WARNING: CPU: 0 PID: 1 at mm/page_alloc.c:5407 __alloc_pages+0x74/0x314
        |  Modules linked in:
        |  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.19.0-10393-g7c2a8d3ac4c0 #73
        |  pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
        |  pc : __alloc_pages+0x74/0x314
        |  lr : alloc_pages+0xe8/0x318
        |  Call trace:
        |   __alloc_pages+0x74/0x314
        |   alloc_pages+0xe8/0x318
        |   kmalloc_order_trace+0x68/0x1dc
        |   __kmalloc+0x240/0x338
        |   detect_cache_attributes+0xe0/0x56c
        |   update_siblings_masks+0x38/0x284
        |   store_cpu_topology+0x78/0x84
        |   smp_prepare_cpus+0x48/0x134
        |   kernel_init_freeable+0xc4/0x14c
        |   kernel_init+0x2c/0x1b4
        |   ret_from_fork+0x10/0x20
      
      Fix the same by changing fw_level to be signed integer and return the
      error from init_cache_level() early in case of error.
      
      Reported-and-Tested-by: default avatarBruno Goncalves <bgoncalv@redhat.com>
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Link: https://lore.kernel.org/r/20220808084640.3165368-1-sudeep.holla@arm.com
      
      
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      43b9af72
    • Helge Deller's avatar
      parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines · 96d206d0
      Helge Deller authored
      [ Upstream commit 591d2108
      
       ]
      
      If a 32-bit kernel was compiled for PA2.0 CPUs, it won't be able to run
      on machines with PA1.x CPUs. Add a check and bail out early if a PA1.x
      machine is detected.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      96d206d0
    • Li Qiong's avatar
      parisc: ccio-dma: Handle kmalloc failure in ccio_init_resources() · 44739b5a
      Li Qiong authored
      [ Upstream commit d46c742f
      
       ]
      
      As the possible failure of the kmalloc(), it should be better
      to fix this error path, check and return '-ENOMEM' error code.
      
      Signed-off-by: default avatarLi Qiong <liqiong@nfschina.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      44739b5a
    • Zhenneng Li's avatar
      drm/radeon: add a force flush to delay work when radeon · 826b46fd
      Zhenneng Li authored
      [ Upstream commit f461950f
      
       ]
      
      Although radeon card fence and wait for gpu to finish processing current batch rings,
      there is still a corner case that radeon lockup work queue may not be fully flushed,
      and meanwhile the radeon_suspend_kms() function has called pci_set_power_state() to
      put device in D3hot state.
      Per PCI spec rev 4.0 on 5.3.1.4.1 D3hot State.
      > Configuration and Message requests are the only TLPs accepted by a Function in
      > the D3hot state. All other received Requests must be handled as Unsupported Requests,
      > and all received Completions may optionally be handled as Unexpected Completions.
      This issue will happen in following logs:
      Unable to handle kernel paging request at virtual address 00008800e0008010
      CPU 0 kworker/0:3(131): Oops 0
      pc = [<ffffffff811bea5c>]  ra = [<ffffffff81240844>]  ps = 0000 Tainted: G        W
      pc is at si_gpu_check_soft_reset+0x3c/0x240
      ra is at si_dma_is_lockup+0x34/0xd0
      v0 = 0000000000000000  t0 = fff08800e0008010  t1 = 0000000000010000
      t2 = 0000000000008010  t3 = fff00007e3c00000  t4 = fff00007e3c00258
      t5 = 000000000000ffff  t6 = 0000000000000001  t7 = fff00007ef078000
      s0 = fff00007e3c016e8  s1 = fff00007e3c00000  s2 = fff00007e3c00018
      s3 = fff00007e3c00000  s4 = fff00007fff59d80  s5 = 0000000000000000
      s6 = fff00007ef07bd98
      a0 = fff00007e3c00000  a1 = fff00007e3c016e8  a2 = 0000000000000008
      a3 = 0000000000000001  a4 = 8f5c28f5c28f5c29  a5 = ffffffff810f4338
      t8 = 0000000000000275  t9 = ffffffff809b66f8  t10 = ff6769c5d964b800
      t11= 000000000000b886  pv = ffffffff811bea20  at = 0000000000000000
      gp = ffffffff81d89690  sp = 00000000aa814126
      Disabling lock debugging due to kernel taint
      Trace:
      [<ffffffff81240844>] si_dma_is_lockup+0x34/0xd0
      [<ffffffff81119610>] radeon_fence_check_lockup+0xd0/0x290
      [<ffffffff80977010>] process_one_work+0x280/0x550
      [<ffffffff80977350>] worker_thread+0x70/0x7c0
      [<ffffffff80977410>] worker_thread+0x130/0x7c0
      [<ffffffff80982040>] kthread+0x200/0x210
      [<ffffffff809772e0>] worker_thread+0x0/0x7c0
      [<ffffffff80981f8c>] kthread+0x14c/0x210
      [<ffffffff80911658>] ret_from_kernel_thread+0x18/0x20
      [<ffffffff80981e40>] kthread+0x0/0x210
       Code: ad3e0008  43f0074a  ad7e0018  ad9e0020  8c3001e8  40230101
       <88210000> 4821ed21
      So force lockup work queue flush to fix this problem.
      
      Acked-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarZhenneng Li <lizhenneng@kylinos.cn>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      826b46fd
    • Candice Li's avatar
      drm/amdgpu: Check num_gfx_rings for gfx v9_0 rb setup. · 04102568
      Candice Li authored
      [ Upstream commit c3519383
      
       ]
      
      No need to set up rb when no gfx rings.
      
      Signed-off-by: default avatarCandice Li <candice.li@amd.com>
      Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      04102568
    • YiPeng Chai's avatar
      drm/amdgpu: Move psp_xgmi_terminate call from amdgpu_xgmi_remove_device to psp_hw_fini · c19656cd
      YiPeng Chai authored
      [ Upstream commit 9d705d77
      
       ]
      
      V1:
      The amdgpu_xgmi_remove_device function will send unload command
      to psp through psp ring to terminate xgmi, but psp ring has been
      destroyed in psp_hw_fini.
      
      V2:
      1. Change the commit title.
      2. Restore amdgpu_xgmi_remove_device to its original calling location.
         Move psp_xgmi_terminate call from amdgpu_xgmi_remove_device to
         psp_hw_fini.
      
      Signed-off-by: default avatarYiPeng Chai <YiPeng.Chai@amd.com>
      Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c19656cd
    • Jeffy Chen's avatar
      drm/gem: Fix GEM handle release errors · 67bf86ff
      Jeffy Chen authored
      [ Upstream commit ea2aa97c ]
      
      Currently we are assuming a one to one mapping between dmabuf and
      GEM handle when releasing GEM handles.
      
      But that is not always true, since we would create extra handles for the
      GEM obj in cases like gem_open() and getfb{,2}().
      
      A similar issue was reported at:
      https://lore.kernel.org/all/20211105083308.392156-1-jay.xu@rock-chips.com/
      
      
      
      Another problem is that the imported dmabuf might not always have
      gem_obj->dma_buf set, which would cause leaks in
      drm_gem_remove_prime_handles().
      
      Let's fix these for now by using handle to find the exact map to remove.
      
      Signed-off-by: default avatarJeffy Chen <jeffy.chen@rock-chips.com>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220819072834.17888-1-jeffy.chen@rock-chips.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      67bf86ff
    • Guixin Liu's avatar
      scsi: megaraid_sas: Fix double kfree() · a175aed8
      Guixin Liu authored
      [ Upstream commit 8c499e49 ]
      
      When allocating log_to_span fails, kfree(instance->ctrl_context) is called
      twice. Remove redundant call.
      
      Link: https://lore.kernel.org/r/1659424729-46502-1-git-send-email-kanie@linux.alibaba.com
      
      
      Acked-by: default avatarSumit Saxena <sumit.saxena@broadcom.com>
      Signed-off-by: default avatarGuixin Liu <kanie@linux.alibaba.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a175aed8
    • Tony Battersby's avatar
      scsi: qla2xxx: Disable ATIO interrupt coalesce for quad port ISP27XX · 004e26ef
      Tony Battersby authored
      [ Upstream commit 53661ded ]
      
      This partially reverts commit d2b292c3 ("scsi: qla2xxx: Enable ATIO
      interrupt handshake for ISP27XX")
      
      For some workloads where the host sends a batch of commands and then
      pauses, ATIO interrupt coalesce can cause some incoming ATIO entries to be
      ignored for extended periods of time, resulting in slow performance,
      timeouts, and aborted commands.
      
      Disable interrupt coalesce and re-enable the dedicated ATIO MSI-X
      interrupt.
      
      Link: https://lore.kernel.org/r/97dcf365-89ff-014d-a3e5-1404c6af511c@cybernetics.com
      
      
      Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
      Reviewed-by: default avatarNilesh Javali <njavali@marvell.com>
      Signed-off-by: default avatarTony Battersby <tonyb@cybernetics.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      004e26ef
    • Yee Lee's avatar
      Revert "mm: kmemleak: take a full lowmem check in kmemleak_*_phys()" · a14f1799
      Yee Lee authored
      This reverts commit 23c2d497.
      
      Commit 23c2d497 ("mm: kmemleak: take a full lowmem check in
      kmemleak_*_phys()") brought false leak alarms on some archs like arm64
      that does not init pfn boundary in early booting. The final solution
      lands on linux-6.0: commit 0c24e061
      
       ("mm: kmemleak: add rbtree and
      store physical address for objects allocated with PA").
      
      Revert this commit before linux-6.0. The original issue of invalid PA
      can be mitigated by additional check in devicetree.
      
      The false alarm report is as following: Kmemleak output: (Qemu/arm64)
      unreferenced object 0xffff0000c0170a00 (size 128):
        comm "swapper/0", pid 1, jiffies 4294892404 (age 126.208s)
        hex dump (first 32 bytes):
       62 61 73 65 00 00 00 00 00 00 00 00 00 00 00 00  base............
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<(____ptrval____)>] __kmalloc_track_caller+0x1b0/0x2e4
          [<(____ptrval____)>] kstrdup_const+0x8c/0xc4
          [<(____ptrval____)>] kvasprintf_const+0xbc/0xec
          [<(____ptrval____)>] kobject_set_name_vargs+0x58/0xe4
          [<(____ptrval____)>] kobject_add+0x84/0x100
          [<(____ptrval____)>] __of_attach_node_sysfs+0x78/0xec
          [<(____ptrval____)>] of_core_init+0x68/0x104
          [<(____ptrval____)>] driver_init+0x28/0x48
          [<(____ptrval____)>] do_basic_setup+0x14/0x28
          [<(____ptrval____)>] kernel_init_freeable+0x110/0x178
          [<(____ptrval____)>] kernel_init+0x20/0x1a0
          [<(____ptrval____)>] ret_from_fork+0x10/0x20
      
      This pacth is also applicable to linux-5.17.y/linux-5.18.y/linux-5.19.y
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarYee Lee <yee.lee@mediatek.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a14f1799
    • Linus Torvalds's avatar
      fs: only do a memory barrier for the first set_buffer_uptodate() · 13c8f561
      Linus Torvalds authored
      commit 2f79cdfe upstream.
      
      Commit d4252071 ("add barriers to buffer_uptodate and
      set_buffer_uptodate") added proper memory barriers to the buffer head
      BH_Uptodate bit, so that anybody who tests a buffer for being up-to-date
      will be guaranteed to actually see initialized state.
      
      However, that commit didn't _just_ add the memory barrier, it also ended
      up dropping the "was it already set" logic that the BUFFER_FNS() macro
      had.
      
      That's conceptually the right thing for a generic "this is a memory
      barrier" operation, but in the case of the buffer contents, we really
      only care about the memory barrier for the _first_ time we set the bit,
      in that the only memory ordering protection we need is to avoid anybody
      seeing uninitialized memory contents.
      
      Any other access ordering wouldn't be about the BH_Uptodate bit anyway,
      and would require some other proper lock (typically BH_Lock or the folio
      lock).  A reader that races with somebody invalidating the buffer head
      isn't an issue wrt the memory ordering, it's a serialization issue.
      
      Now, you'd think that the buffer head operations don't matter in this
      day and age (and I certainly thought so), but apparently some loads
      still end up being heavy users of buffer heads.  In particular, the
      kernel test robot reported that not having this bit access optimization
      in place caused a noticeable direct IO performance regression on ext4:
      
        fxmark.ssd_ext4_no_jnl_DWTL_54_directio.works/sec -26.5% regression
      
      although you presumably need a fast disk and a lot of cores to actually
      notice.
      
      Link: https://lore.kernel.org/all/Yw8L7HTZ%2FdE2%2Fo9C@xsang-OptiPlex-9020/
      
      
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Tested-by: default avatarFengwei Yin <fengwei.yin@intel.com>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: stable@kernel.org
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      13c8f561
    • Stanislaw Gruszka's avatar
      wifi: iwlegacy: 4965: corrected fix for potential off-by-one overflow in il4965_rs_fill_link_cmd() · 2946d2ae
      Stanislaw Gruszka authored
      commit 6d0ef724 upstream.
      
      This reverts commit a8eb8e6f as
      it can cause invalid link quality command sent to the firmware
      and address the off-by-one issue by fixing condition of while loop.
      
      Cc: stable@vger.kernel.org
      Fixes: a8eb8e6f
      
       ("wifi: iwlegacy: 4965: fix potential off-by-one overflow in il4965_rs_fill_link_cmd()")
      Signed-off-by: default avatarStanislaw Gruszka <stf_xl@wp.pl>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20220815073737.GA999388@wp.pl
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2946d2ae
    • Hyunwoo Kim's avatar
      efi: capsule-loader: Fix use-after-free in efi_capsule_write · 918d9c4a
      Hyunwoo Kim authored
      commit 9cb636b5
      
       upstream.
      
      A race condition may occur if the user calls close() on another thread
      during a write() operation on the device node of the efi capsule.
      
      This is a race condition that occurs between the efi_capsule_write() and
      efi_capsule_flush() functions of efi_capsule_fops, which ultimately
      results in UAF.
      
      So, the page freeing process is modified to be done in
      efi_capsule_release() instead of efi_capsule_flush().
      
      Cc: <stable@vger.kernel.org> # v4.9+
      Signed-off-by: default avatarHyunwoo Kim <imv4bel@gmail.com>
      Link: https://lore.kernel.org/all/20220907102920.GA88602@ubuntu/
      
      
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      918d9c4a
    • Ard Biesheuvel's avatar
      efi: libstub: Disable struct randomization · 94f0f30b
      Ard Biesheuvel authored
      commit 1a388792
      
       upstream.
      
      The EFI stub is a wrapper around the core kernel that makes it look like
      a EFI compatible PE/COFF application to the EFI firmware. EFI
      applications run on top of the EFI runtime, which is heavily based on
      so-called protocols, which are struct types consisting [mostly] of
      function pointer members that are instantiated and recorded in a
      protocol database.
      
      These structs look like the ideal randomization candidates to the
      randstruct plugin (as they only carry function pointers), but of course,
      these protocols are contracts between the firmware that exposes them,
      and the EFI applications (including our stubbed kernel) that invoke
      them. This means that struct randomization for EFI protocols is not a
      great idea, and given that the stub shares very little data with the
      core kernel that is represented as a randomizable struct, we're better
      off just disabling it completely here.
      
      Cc: <stable@vger.kernel.org> # v4.14+
      Reported-by: default avatarDaniel Marth <daniel.marth@inso.tuwien.ac.at>
      Tested-by: default avatarDaniel Marth <daniel.marth@inso.tuwien.ac.at>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      94f0f30b
    • Fedor Pchelkin's avatar
      tty: n_gsm: avoid call of sleeping functions from atomic context · eb75efde
      Fedor Pchelkin authored
      commit 902e02ea upstream.
      
      Syzkaller reports the following problem:
      
      BUG: sleeping function called from invalid context at kernel/printk/printk.c:2347
      in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 1105, name: syz-executor423
      3 locks held by syz-executor423/1105:
       #0: ffff8881468b9098 (&tty->ldisc_sem){++++}-{0:0}, at: tty_ldisc_ref_wait+0x22/0x90 drivers/tty/tty_ldisc.c:266
       #1: ffff8881468b9130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: tty_write_lock drivers/tty/tty_io.c:952 [inline]
       #1: ffff8881468b9130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: do_tty_write drivers/tty/tty_io.c:975 [inline]
       #1: ffff8881468b9130 (&tty->atomic_write_lock){+.+.}-{3:3}, at: file_tty_write.constprop.0+0x2a8/0x8e0 drivers/tty/tty_io.c:1118
       #2: ffff88801b06c398 (&gsm->tx_lock){....}-{2:2}, at: gsmld_write+0x5e/0x150 drivers/tty/n_gsm.c:2717
      irq event stamp: 3482
      hardirqs last  enabled at (3481): [<ffffffff81d13343>] __get_reqs_available+0x143/0x2f0 fs/aio.c:946
      hardirqs last disabled at (3482): [<ffffffff87d39722>] __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:108 [inline]
      hardirqs last disabled at (3482): [<ffffffff87d39722>] _raw_spin_lock_irqsave+0x52/0x60 kernel/locking/spinlock.c:159
      softirqs last  enabled at (3408): [<ffffffff87e01002>] asm_call_irq_on_stack+0x12/0x20
      softirqs last disabled at (3401): [<ffffffff87e01002>] asm_call_irq_on_stack+0x12/0x20
      Preemption disabled at:
      [<0000000000000000>] 0x0
      CPU: 2 PID: 1105 Comm: syz-executor423 Not tainted 5.10.137-syzkaller #0
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x107/0x167 lib/dump_stack.c:118
       ___might_sleep.cold+0x1e8/0x22e kernel/sched/core.c:7304
       console_lock+0x19/0x80 kernel/printk/printk.c:2347
       do_con_write+0x113/0x1de0 drivers/tty/vt/vt.c:2909
       con_write+0x22/0xc0 drivers/tty/vt/vt.c:3296
       gsmld_write+0xd0/0x150 drivers/tty/n_gsm.c:2720
       do_tty_write drivers/tty/tty_io.c:1028 [inline]
       file_tty_write.constprop.0+0x502/0x8e0 drivers/tty/tty_io.c:1118
       call_write_iter include/linux/fs.h:1903 [inline]
       aio_write+0x355/0x7b0 fs/aio.c:1580
       __io_submit_one fs/aio.c:1952 [inline]
       io_submit_one+0xf45/0x1a90 fs/aio.c:1999
       __do_sys_io_submit fs/aio.c:2058 [inline]
       __se_sys_io_submit fs/aio.c:2028 [inline]
       __x64_sys_io_submit+0x18c/0x2f0 fs/aio.c:2028
       do_syscall_64+0x33/0x40 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x61/0xc6
      
      The problem happens in the following control flow:
      
      gsmld_write(...)
      spin_lock_irqsave(&gsm->tx_lock, flags) // taken a spinlock on TX data
       con_write(...)
        do_con_write(...)
         console_lock()
          might_sleep() // -> bug
      
      As far as console_lock() might sleep it should not be called with
      spinlock held.
      
      The patch replaces tx_lock spinlock with mutex in order to avoid the
      problem.
      
      Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
      
      Fixes: 32dd59f9
      
       ("tty: n_gsm: fix race condition in gsmld_write()")
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
      Signed-off-by: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
      Link: https://lore.kernel.org/r/20220829131640.69254-3-pchelkin@ispras.ru
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eb75efde
    • Tetsuo Handa's avatar
      tty: n_gsm: initialize more members at gsm_alloc_mux() · fb6cadd2
      Tetsuo Handa authored
      commit 4bb1a53b upstream.
      
      syzbot is reporting use of uninitialized spinlock at gsmld_write() [1], for
      commit 32dd59f9 ("tty: n_gsm: fix race condition in gsmld_write()")
      allows accessing gsm->tx_lock before gsm_activate_mux() initializes it.
      
      Since object initialization should be done right after allocation in order
      to avoid accessing uninitialized memory, move initialization of
      timer/work/waitqueue/spinlock from gsmld_open()/gsm_activate_mux() to
      gsm_alloc_mux().
      
      Link: https://syzkaller.appspot.com/bug?extid=cf155def4e717db68a12 [1]
      Fixes: 32dd59f9
      
       ("tty: n_gsm: fix race condition in gsmld_write()")
      Reported-by: default avatarsyzbot <syzbot+cf155def4e717db68a12@syzkaller.appspotmail.com>
      Tested-by: default avatarsyzbot <syzbot+cf155def4e717db68a12@syzkaller.appspotmail.com>
      Cc: stable <stable@kernel.org>
      Acked-by: default avatarJiri Slaby <jirislaby@kernel.org>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Link: https://lore.kernel.org/r/2110618e-57f0-c1ce-b2ad-b6cacef3f60e@I-love.SAKURA.ne.jp
      
      
      Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fb6cadd2
    • SeongJae Park's avatar
      xen-blkfront: Cache feature_persistent value before advertisement · 186cb020
      SeongJae Park authored
      commit fe8f65b0 upstream.
      
      Xen blkfront advertises its support of the persistent grants feature
      when it first setting up and when resuming in 'talk_to_blkback()'.
      Then, blkback reads the advertised value when it connects with blkfront
      and decides if it will use the persistent grants feature or not, and
      advertises its decision to blkfront.  Blkfront reads the blkback's
      decision and it also makes the decision for the use of the feature.
      
      Commit 402c43ea ("xen-blkfront: Apply 'feature_persistent' parameter
      when connect"), however, made the blkfront's read of the parameter for
      disabling the advertisement, namely 'feature_persistent', to be done
      when it negotiate, not when advertise.  Therefore blkfront advertises
      without reading the parameter.  As the field for caching the parameter
      value is zero-initialized, it always advertises as the feature is
      disabled, so that the persistent grants feature becomes always disabled.
      
      This commit fixes the issue by making the blkfront does parmeter caching
      just before the advertisement.
      
      Fixes: 402c43ea
      
       ("xen-blkfront: Apply 'feature_persistent' parameter when connect")
      Cc: <stable@vger.kernel.org> # 5.10.x
      Reported-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Tested-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Link: https://lore.kernel.org/r/20220831165824.94815-4-sj@kernel.org
      
      
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      186cb020
    • Chuck Lever's avatar
      NFSD: Fix verifier returned in stable WRITEs · d3d88550
      Chuck Lever authored
      commit f11ad7aa upstream.
      
      RFC 8881 explains the purpose of the write verifier this way:
      
      > The final portion of the result is the field writeverf. This field
      > is the write verifier and is a cookie that the client can use to
      > determine whether a server has changed instance state (e.g., server
      > restart) between a call to WRITE and a subsequent call to either
      > WRITE or COMMIT.
      
      But then it says:
      
      > This cookie MUST be unchanged during a single instance of the
      > NFSv4.1 server and MUST be unique between instances of the NFSv4.1
      > server. If the cookie changes, then the client MUST assume that
      > any data written with an UNSTABLE4 value for committed and an old
      > writeverf in the reply has been lost and will need to be
      > recovered.
      
      RFC 1813 has similar language for NFSv3. NFSv2 does not have a write
      verifier since it doesn't implement the COMMIT procedure.
      
      Since commit 19e0663f ("nfsd: Ensure sampling of the write
      verifier is atomic with the write"), the Linux NFS server has
      returned a boot-time-based verifier for UNSTABLE WRITEs, but a zero
      verifier for FILE_SYNC and DATA_SYNC WRITEs. FILE_SYNC and DATA_SYNC
      WRITEs are not followed up with a COMMIT, so there's no need for
      clients to compare verifiers for stable writes.
      
      However, by returning a different verifier for stable and unstable
      writes, the above commit puts the Linux NFS server a step farther
      out of compliance with the first MUST above. At least one NFS client
      (FreeBSD) noticed the difference, making this a potential
      regression.
      
      [Removed down_write to fix the conflict in the cherry-pick. The
      down_write functionality was no longer needed there. Upstream commit
      555dbf1a
      
       titled nfsd: Replace use of
      rwsem with errseq_t removed those and replace it with new functionality
      that was more scalable. This commit is already backported onto 5.10 and
      so removing down_write ensures consistency with that change. Tested by
      compiling and booting successfully. - kochera]
      
      Reported-by: default avatarRick Macklem <rmacklem@uoguelph.ca>
      Link: https://lore.kernel.org/linux-nfs/YQXPR0101MB096857EEACF04A6DF1FC6D9BDD749@YQXPR0101MB0968.CANPRD01.PROD.OUTLOOK.COM/T/
      Fixes: 19e0663f
      
       ("nfsd: Ensure sampling of the write verifier is atomic with the write")
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Signed-off-by: default avatarMichael Kochera <kochera@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d3d88550
  2. Sep 08, 2022