Skip to content
  1. Jan 14, 2023
    • Linus Torvalds's avatar
      hfs/hfsplus: avoid WARN_ON() for sanity check, use proper error handling · be01f35e
      Linus Torvalds authored
      commit cb7a95af upstream.
      
      Commit 55d1cbbb
      
       ("hfs/hfsplus: use WARN_ON for sanity check") fixed
      a build warning by turning a comment into a WARN_ON(), but it turns out
      that syzbot then complains because it can trigger said warning with a
      corrupted hfs image.
      
      The warning actually does warn about a bad situation, but we are much
      better off just handling it as the error it is.  So rather than warn
      about us doing bad things, stop doing the bad things and return -EIO.
      
      While at it, also fix a memory leak that was introduced by an earlier
      fix for a similar syzbot warning situation, and add a check for one case
      that historically wasn't handled at all (ie neither comment nor
      subsequent WARN_ON).
      
      Reported-by: default avatar <syzbot+7bb7cd3595533513a9e7@syzkaller.appspotmail.com>
      Fixes: 55d1cbbb ("hfs/hfsplus: use WARN_ON for sanity check")
      Fixes: 8d824e69 ("hfs: fix OOB Read in __hfs_brec_find")
      Link: https://lore.kernel.org/lkml/000000000000dbce4e05f170f289@google.com/
      
      
      Tested-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Viacheslav Dubeyko <slava@dubeyko.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      be01f35e
    • Arnd Bergmann's avatar
      hfs/hfsplus: use WARN_ON for sanity check · 1f881d92
      Arnd Bergmann authored
      commit 55d1cbbb upstream.
      
      gcc warns about a couple of instances in which a sanity check exists but
      the author wasn't sure how to react to it failing, which makes it look
      like a possible bug:
      
        fs/hfsplus/inode.c: In function 'hfsplus_cat_read_inode':
        fs/hfsplus/inode.c:503:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
          503 |                         /* panic? */;
              |                                     ^
        fs/hfsplus/inode.c:524:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
          524 |                         /* panic? */;
              |                                     ^
        fs/hfsplus/inode.c: In function 'hfsplus_cat_write_inode':
        fs/hfsplus/inode.c:582:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
          582 |                         /* panic? */;
              |                                     ^
        fs/hfsplus/inode.c:608:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
          608 |                         /* panic? */;
              |                                     ^
        fs/hfs/inode.c: In function 'hfs_write_inode':
        fs/hfs/inode.c:464:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
          464 |                         /* panic? */;
              |                                     ^
        fs/hfs/inode.c:485:37: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body]
          485 |                         /* panic? */;
              |                                     ^
      
      panic() is probably not the correct choice here, but a WARN_ON
      seems appropriate and avoids the compile-time warning.
      
      Link: https://lkml.kernel.org/r/20210927102149.1809384-1-arnd@kernel.org
      Link: https://lore.kernel.org/all/20210322223249.2632268-1-arnd@kernel.org/
      
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarChristian Brauner <christian.brauner@ubuntu.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jan Kara <jack@suse.cz>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f881d92
    • Muhammad Usama Anjum's avatar
      selftests: set the BUILD variable to absolute path · 434909ed
      Muhammad Usama Anjum authored
      commit 5ad51ab6
      
       upstream.
      
      The build of kselftests fails if relative path is specified through
      KBUILD_OUTPUT or O=<path> method. BUILD variable is used to determine
      the path of the output objects. When make is run from other directories
      with relative paths, the exact path of the build objects is ambiguous
      and build fails.
      
      	make[1]: Entering directory '/home/usama/repos/kernel/linux_mainline2/tools/testing/selftests/alsa'
      	gcc     mixer-test.c -L/usr/lib/x86_64-linux-gnu -lasound  -o build/kselftest/alsa/mixer-test
      	/usr/bin/ld: cannot open output file build/kselftest/alsa/mixer-test
      
      Set the BUILD variable to the absolute path of the output directory.
      Make the logic readable and easy to follow. Use spaces instead of tabs
      for indentation as if with tab indentation is considered recipe in make.
      
      Signed-off-by: default avatarMuhammad Usama Anjum <usama.anjum@collabora.com>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarTyler Hicks (Microsoft) <code@tyhicks.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      434909ed
    • Eric Biggers's avatar
      ext4: don't allow journal inode to have encrypt flag · a41d63f2
      Eric Biggers authored
      commit 105c78e1
      
       upstream.
      
      Mounting a filesystem whose journal inode has the encrypt flag causes a
      NULL dereference in fscrypt_limit_io_blocks() when the 'inlinecrypt'
      mount option is used.
      
      The problem is that when jbd2_journal_init_inode() calls bmap(), it
      eventually finds its way into ext4_iomap_begin(), which calls
      fscrypt_limit_io_blocks().  fscrypt_limit_io_blocks() requires that if
      the inode is encrypted, then its encryption key must already be set up.
      That's not the case here, since the journal inode is never "opened" like
      a normal file would be.  Hence the crash.
      
      A reproducer is:
      
          mkfs.ext4 -F /dev/vdb
          debugfs -w /dev/vdb -R "set_inode_field <8> flags 0x80808"
          mount /dev/vdb /mnt -o inlinecrypt
      
      To fix this, make ext4 consider journal inodes with the encrypt flag to
      be invalid.  (Note, maybe other flags should be rejected on the journal
      inode too.  For now, this is just the minimal fix for the above issue.)
      
      I've marked this as fixing the commit that introduced the call to
      fscrypt_limit_io_blocks(), since that's what made an actual crash start
      being possible.  But this fix could be applied to any version of ext4
      that supports the encrypt feature.
      
      Reported-by: default avatar <syzbot+ba9dac45bc76c490b7c3@syzkaller.appspotmail.com>
      Fixes: 38ea50da
      
       ("ext4: support direct I/O with fscrypt using blk-crypto")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Link: https://lore.kernel.org/r/20221102053312.189962-1-ebiggers@kernel.org
      
      
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a41d63f2
    • Zhenyu Wang's avatar
      drm/i915/gvt: fix vgpu debugfs clean in remove · af90f8b3
      Zhenyu Wang authored
      commit 704f3384
      
       upstream.
      
      Check carefully on root debugfs available when destroying vgpu,
      e.g in remove case drm minor's debugfs root might already be destroyed,
      which led to kernel oops like below.
      
      Console: switching to colour dummy device 80x25
      i915 0000:00:02.0: MDEV: Unregistering
      intel_vgpu_mdev b1338b2d-a709-4c23-b766-cc436c36cdf0: Removing from iommu group 14
      BUG: kernel NULL pointer dereference, address: 0000000000000150
      PGD 0 P4D 0
      Oops: 0000 [#1] PREEMPT SMP
      CPU: 3 PID: 1046 Comm: driverctl Not tainted 6.1.0-rc2+ #6
      Hardware name: HP HP ProDesk 600 G3 MT/829D, BIOS P02 Ver. 02.44 09/13/2022
      RIP: 0010:__lock_acquire+0x5e2/0x1f90
      Code: 87 ad 09 00 00 39 05 e1 1e cc 02 0f 82 f1 09 00 00 ba 01 00 00 00 48 83 c4 48 89 d0 5b 5d 41 5c 41 5d 41 5e 41 5f c3 45 31 ff <48> 81 3f 60 9e c2 b6 45 0f 45 f8 83 fe 01 0f 87 55 fa ff ff 89 f0
      RSP: 0018:ffff9f770274f948 EFLAGS: 00010046
      RAX: 0000000000000003 RBX: 0000000000000000 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000150
      RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000
      R10: ffff8895d1173300 R11: 0000000000000001 R12: 0000000000000000
      R13: 0000000000000150 R14: 0000000000000000 R15: 0000000000000000
      FS:  00007fc9b2ba0740(0000) GS:ffff889cdfcc0000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000150 CR3: 000000010fd93005 CR4: 00000000003706e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       lock_acquire+0xbf/0x2b0
       ? simple_recursive_removal+0xa5/0x2b0
       ? lock_release+0x13d/0x2d0
       down_write+0x2a/0xd0
       ? simple_recursive_removal+0xa5/0x2b0
       simple_recursive_removal+0xa5/0x2b0
       ? start_creating.part.0+0x110/0x110
       ? _raw_spin_unlock+0x29/0x40
       debugfs_remove+0x40/0x60
       intel_gvt_debugfs_remove_vgpu+0x15/0x30 [kvmgt]
       intel_gvt_destroy_vgpu+0x60/0x100 [kvmgt]
       intel_vgpu_release_dev+0xe/0x20 [kvmgt]
       device_release+0x30/0x80
       kobject_put+0x79/0x1b0
       device_release_driver_internal+0x1b8/0x230
       bus_remove_device+0xec/0x160
       device_del+0x189/0x400
       ? up_write+0x9c/0x1b0
       ? mdev_device_remove_common+0x60/0x60 [mdev]
       mdev_device_remove_common+0x22/0x60 [mdev]
       mdev_device_remove_cb+0x17/0x20 [mdev]
       device_for_each_child+0x56/0x80
       mdev_unregister_parent+0x5a/0x81 [mdev]
       intel_gvt_clean_device+0x2d/0xe0 [kvmgt]
       intel_gvt_driver_remove+0x2e/0xb0 [i915]
       i915_driver_remove+0xac/0x100 [i915]
       i915_pci_remove+0x1a/0x30 [i915]
       pci_device_remove+0x31/0xa0
       device_release_driver_internal+0x1b8/0x230
       unbind_store+0xd8/0x100
       kernfs_fop_write_iter+0x156/0x210
       vfs_write+0x236/0x4a0
       ksys_write+0x61/0xd0
       do_syscall_64+0x55/0x80
       ? find_held_lock+0x2b/0x80
       ? lock_release+0x13d/0x2d0
       ? up_read+0x17/0x20
       ? lock_is_held_type+0xe3/0x140
       ? asm_exc_page_fault+0x22/0x30
       ? lockdep_hardirqs_on+0x7d/0x100
       entry_SYSCALL_64_after_hwframe+0x46/0xb0
      RIP: 0033:0x7fc9b2c9e0c4
      Code: 15 71 7d 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 80 3d 3d 05 0e 00 00 74 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 c3 0f 1f 00 48 83 ec 28 48 89 54 24 18 48
      RSP: 002b:00007ffec29c81c8 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
      RAX: ffffffffffffffda RBX: 000000000000000d RCX: 00007fc9b2c9e0c4
      RDX: 000000000000000d RSI: 0000559f8b5f48a0 RDI: 0000000000000001
      RBP: 0000559f8b5f48a0 R08: 0000559f8b5f3540 R09: 00007fc9b2d76d30
      R10: 0000000000000000 R11: 0000000000000202 R12: 000000000000000d
      R13: 00007fc9b2d77780 R14: 000000000000000d R15: 00007fc9b2d72a00
       </TASK>
      Modules linked in: sunrpc intel_rapl_msr intel_rapl_common intel_pmc_core_pltdrv intel_pmc_core intel_tcc_cooling x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel ee1004 igbvf rapl vfat fat intel_cstate intel_uncore pktcdvd i2c_i801 pcspkr wmi_bmof i2c_smbus acpi_pad vfio_pci vfio_pci_core vfio_virqfd zram fuse dm_multipath kvmgt mdev vfio_iommu_type1 vfio kvm irqbypass i915 nvme e1000e igb nvme_core crct10dif_pclmul crc32_pclmul crc32c_intel polyval_clmulni polyval_generic serio_raw ghash_clmulni_intel sha512_ssse3 dca drm_buddy intel_gtt video wmi drm_display_helper ttm
      CR2: 0000000000000150
      ---[ end trace 0000000000000000 ]---
      
      Cc: Wang Zhi <zhi.a.wang@intel.com>
      Cc: He Yu <yu.he@intel.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarZhi Wang <zhi.a.wang@intel.com>
      Tested-by: default avatarYu He <yu.he@intel.com>
      Fixes: bc7b0be3
      
       ("drm/i915/gvt: Add basic debugfs infrastructure")
      Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20221219140357.769557-2-zhenyuw@linux.intel.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af90f8b3
    • Zhenyu Wang's avatar
      drm/i915/gvt: fix gvt debugfs destroy · bb7c7b2c
      Zhenyu Wang authored
      commit c4b850d1
      
       upstream.
      
      When gvt debug fs is destroyed, need to have a sane check if drm
      minor's debugfs root is still available or not, otherwise in case like
      device remove through unbinding, drm minor's debugfs directory has
      already been removed, then intel_gvt_debugfs_clean() would act upon
      dangling pointer like below oops.
      
      i915 0000:00:02.0: Direct firmware load for i915/gvt/vid_0x8086_did_0x1926_rid_0x0a.golden_hw_state failed with error -2
      i915 0000:00:02.0: MDEV: Registered
      Console: switching to colour dummy device 80x25
      i915 0000:00:02.0: MDEV: Unregistering
      BUG: kernel NULL pointer dereference, address: 00000000000000a0
      PGD 0 P4D 0
      Oops: 0002 [#1] PREEMPT SMP PTI
      CPU: 2 PID: 2486 Comm: gfx-unbind.sh Tainted: G          I        6.1.0-rc8+ #15
      Hardware name: Dell Inc. XPS 13 9350/0JXC1H, BIOS 1.13.0 02/10/2020
      RIP: 0010:down_write+0x1f/0x90
      Code: 1d ff ff 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 53 48 89 fb e8 62 c0 ff ff bf 01 00 00 00 e8 28 5e 31 ff 31 c0 ba 01 00 00 00 <f0> 48 0f b1 13 75 33 65 48 8b 04 25 c0 bd 01 00 48 89 43 08 bf 01
      RSP: 0018:ffff9eb3036ffcc8 EFLAGS: 00010246
      RAX: 0000000000000000 RBX: 00000000000000a0 RCX: ffffff8100000000
      RDX: 0000000000000001 RSI: 0000000000000064 RDI: ffffffffa48787a8
      RBP: ffff9eb3036ffd30 R08: ffffeb1fc45a0608 R09: ffffeb1fc45a05c0
      R10: 0000000000000002 R11: 0000000000000000 R12: 0000000000000000
      R13: ffff91acc33fa328 R14: ffff91acc033f080 R15: ffff91acced533e0
      FS:  00007f6947bba740(0000) GS:ffff91ae36d00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000000000000a0 CR3: 00000001133a2002 CR4: 00000000003706e0
      Call Trace:
       <TASK>
       simple_recursive_removal+0x9f/0x2a0
       ? start_creating.part.0+0x120/0x120
       ? _raw_spin_lock+0x13/0x40
       debugfs_remove+0x40/0x60
       intel_gvt_debugfs_clean+0x15/0x30 [kvmgt]
       intel_gvt_clean_device+0x49/0xe0 [kvmgt]
       intel_gvt_driver_remove+0x2f/0xb0
       i915_driver_remove+0xa4/0xf0
       i915_pci_remove+0x1a/0x30
       pci_device_remove+0x33/0xa0
       device_release_driver_internal+0x1b2/0x230
       unbind_store+0xe0/0x110
       kernfs_fop_write_iter+0x11b/0x1f0
       vfs_write+0x203/0x3d0
       ksys_write+0x63/0xe0
       do_syscall_64+0x37/0x90
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f6947cb5190
      Code: 40 00 48 8b 15 71 9c 0d 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 80 3d 51 24 0e 00 00 74 17 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 58 c3 0f 1f 80 00 00 00 00 48 83 ec 28 48 89
      RSP: 002b:00007ffcbac45a28 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
      RAX: ffffffffffffffda RBX: 000000000000000d RCX: 00007f6947cb5190
      RDX: 000000000000000d RSI: 0000555e35c866a0 RDI: 0000000000000001
      RBP: 0000555e35c866a0 R08: 0000000000000002 R09: 0000555e358cb97c
      R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000001
      R13: 000000000000000d R14: 0000000000000000 R15: 0000555e358cb8e0
       </TASK>
      Modules linked in: kvmgt
      CR2: 00000000000000a0
      ---[ end trace 0000000000000000 ]---
      
      Cc: Wang, Zhi <zhi.a.wang@intel.com>
      Cc: He, Yu <yu.he@intel.com>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarZhi Wang <zhi.a.wang@intel.com>
      Fixes: bc7b0be3
      
       ("drm/i915/gvt: Add basic debugfs infrastructure")
      Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20221219140357.769557-1-zhenyuw@linux.intel.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb7c7b2c
    • Ben Dooks's avatar
      riscv: uaccess: fix type of 0 variable on error in get_user() · bc847857
      Ben Dooks authored
      commit b9b916ae
      
       upstream.
      
      If the get_user(x, ptr) has x as a pointer, then the setting
      of (x) = 0 is going to produce the following sparse warning,
      so fix this by forcing the type of 'x' when access_ok() fails.
      
      fs/aio.c:2073:21: warning: Using plain integer as NULL pointer
      
      Signed-off-by: default avatarBen Dooks <ben-linux@fluff.org>
      Reviewed-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Link: https://lore.kernel.org/r/20221229170545.718264-1-ben-linux@fluff.org
      
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc847857
    • Paul Menzel's avatar
      fbdev: matroxfb: G200eW: Increase max memory from 1 MB to 16 MB · f64e56fb
      Paul Menzel authored
      commit f685dd7a upstream.
      
      Commit 62d89a7d ("video: fbdev: matroxfb: set maxvram of vbG200eW to
      the same as vbG200 to avoid black screen") accidently decreases the
      maximum memory size for the Matrox G200eW (102b:0532) from 8 MB to 1 MB
      by missing one zero. This caused the driver initialization to fail with
      the messages below, as the minimum required VRAM size is 2 MB:
      
           [    9.436420] matroxfb: Matrox MGA-G200eW (PCI) detected
           [    9.444502] matroxfb: cannot determine memory size
           [    9.449316] matroxfb: probe of 0000:0a:03.0 failed with error -1
      
      So, add the missing 0 to make it the intended 16 MB. Successfully tested on
      the Dell PowerEdge R910/0KYD3D, BIOS 2.10.0 08/29/2013, that the warning is
      gone.
      
      While at it, add a leading 0 to the maxdisplayable entry, so it’s aligned
      properly. The value could probably also be increased from 8 MB to 16 MB, as
      the G200 uses the same values, but I have not checked any datasheet.
      
      Note, matroxfb is obsolete and superseded by the maintained DRM driver
      mga200, which is used by default on most systems where both drivers are
      available. Therefore, on most systems it was only a cosmetic issue.
      
      Fixes: 62d89a7d ("video: fbdev: matroxfb: set maxvram of vbG200eW to the same as vbG200 to avoid black screen")
      Link: https://lore.kernel.org/linux-fbdev/972999d3-b75d-5680-fcef-6e6905c52ac5@suse.de/T/#mb6953a9995ebd18acc8552f99d6db39787aec775
      
      
      Cc: it+linux-fbdev@molgen.mpg.de
      Cc: Z. Liu <liuzx@knownsec.com>
      Cc: Rich Felker <dalias@libc.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f64e56fb
    • Jeff Layton's avatar
      nfsd: fix handling of readdir in v4root vs. mount upcall timeout · d0c46b55
      Jeff Layton authored
      commit cad85337 upstream.
      
      If v4 READDIR operation hits a mountpoint and gets back an error,
      then it will include that entry in the reply and set RDATTR_ERROR for it
      to the error.
      
      That's fine for "normal" exported filesystems, but on the v4root, we
      need to be more careful to only expose the existence of dentries that
      lead to exports.
      
      If the mountd upcall times out while checking to see whether a
      mountpoint on the v4root is exported, then we have no recourse other
      than to fail the whole operation.
      
      Cc: Steve Dickson <steved@redhat.com>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=216777
      
      
      Reported-by: default avatarJianHong Yin <yin-jianhong@163.com>
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d0c46b55
    • Rodrigo Branco's avatar
      x86/bugs: Flush IBP in ib_prctl_set() · 67e39c4f
      Rodrigo Branco authored
      commit a664ec91
      
       upstream.
      
      We missed the window between the TIF flag update and the next reschedule.
      
      Signed-off-by: default avatarRodrigo Branco <bsdaemon@google.com>
      Reviewed-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      67e39c4f
    • Yanjun Zhang's avatar
      nvme: fix multipath crash caused by flush request when blktrace is enabled · f13301a6
      Yanjun Zhang authored
      [ Upstream commit 3659fb5a
      
       ]
      
      The flush request initialized by blk_kick_flush has NULL bio,
      and it may be dealt with nvme_end_req during io completion.
      When blktrace is enabled, nvme_trace_bio_complete with multipath
      activated trying to access NULL pointer bio from flush request
      results in the following crash:
      
      [ 2517.831677] BUG: kernel NULL pointer dereference, address: 000000000000001a
      [ 2517.835213] #PF: supervisor read access in kernel mode
      [ 2517.838724] #PF: error_code(0x0000) - not-present page
      [ 2517.842222] PGD 7b2d51067 P4D 0
      [ 2517.845684] Oops: 0000 [#1] SMP NOPTI
      [ 2517.849125] CPU: 2 PID: 732 Comm: kworker/2:1H Kdump: loaded Tainted: G S                5.15.67-0.cl9.x86_64 #1
      [ 2517.852723] Hardware name: XFUSION 2288H V6/BC13MBSBC, BIOS 1.13 07/27/2022
      [ 2517.856358] Workqueue: nvme_tcp_wq nvme_tcp_io_work [nvme_tcp]
      [ 2517.859993] RIP: 0010:blk_add_trace_bio_complete+0x6/0x30
      [ 2517.863628] Code: 1f 44 00 00 48 8b 46 08 31 c9 ba 04 00 10 00 48 8b 80 50 03 00 00 48 8b 78 50 e9 e5 fe ff ff 0f 1f 44 00 00 41 54 49 89 f4 55 <0f> b6 7a 1a 48 89 d5 e8 3e 1c 2b 00 48 89 ee 4c 89 e7 5d 89 c1 ba
      [ 2517.871269] RSP: 0018:ff7f6a008d9dbcd0 EFLAGS: 00010286
      [ 2517.875081] RAX: ff3d5b4be00b1d50 RBX: 0000000002040002 RCX: ff3d5b0a270f2000
      [ 2517.878966] RDX: 0000000000000000 RSI: ff3d5b0b021fb9f8 RDI: 0000000000000000
      [ 2517.882849] RBP: ff3d5b0b96a6fa00 R08: 0000000000000001 R09: 0000000000000000
      [ 2517.886718] R10: 000000000000000c R11: 000000000000000c R12: ff3d5b0b021fb9f8
      [ 2517.890575] R13: 0000000002000000 R14: ff3d5b0b021fb1b0 R15: 0000000000000018
      [ 2517.894434] FS:  0000000000000000(0000) GS:ff3d5b42bfc80000(0000) knlGS:0000000000000000
      [ 2517.898299] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 2517.902157] CR2: 000000000000001a CR3: 00000004f023e005 CR4: 0000000000771ee0
      [ 2517.906053] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [ 2517.909930] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [ 2517.913761] PKRU: 55555554
      [ 2517.917558] Call Trace:
      [ 2517.921294]  <TASK>
      [ 2517.924982]  nvme_complete_rq+0x1c3/0x1e0 [nvme_core]
      [ 2517.928715]  nvme_tcp_recv_pdu+0x4d7/0x540 [nvme_tcp]
      [ 2517.932442]  nvme_tcp_recv_skb+0x4f/0x240 [nvme_tcp]
      [ 2517.936137]  ? nvme_tcp_recv_pdu+0x540/0x540 [nvme_tcp]
      [ 2517.939830]  tcp_read_sock+0x9c/0x260
      [ 2517.943486]  nvme_tcp_try_recv+0x65/0xa0 [nvme_tcp]
      [ 2517.947173]  nvme_tcp_io_work+0x64/0x90 [nvme_tcp]
      [ 2517.950834]  process_one_work+0x1e8/0x390
      [ 2517.954473]  worker_thread+0x53/0x3c0
      [ 2517.958069]  ? process_one_work+0x390/0x390
      [ 2517.961655]  kthread+0x10c/0x130
      [ 2517.965211]  ? set_kthread_struct+0x40/0x40
      [ 2517.968760]  ret_from_fork+0x1f/0x30
      [ 2517.972285]  </TASK>
      
      To avoid this situation, add a NULL check for req->bio before
      calling trace_block_bio_complete.
      
      Signed-off-by: default avatarYanjun Zhang <zhangyanjun@cestc.cn>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f13301a6
    • Hans de Goede's avatar
      ASoC: Intel: bytcr_rt5640: Add quirk for the Advantech MICA-071 tablet · 3f257a98
      Hans de Goede authored
      [ Upstream commit a1dec9d7
      
       ]
      
      The Advantech MICA-071 tablet deviates from the defaults for
      a non CR Bay Trail based tablet in several ways:
      
      1. It uses an analog MIC on IN3 rather then using DMIC1
      2. It only has 1 speaker
      3. It needs the OVCD current threshold to be set to 1500uA instead of
         the default 2000uA to reliable differentiate between headphones vs
         headsets
      
      Add a quirk with these settings for this tablet.
      
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Acked-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/20221213123246.11226-1-hdegoede@redhat.com
      
      
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3f257a98
    • Jan Kara's avatar
      udf: Fix extension of the last extent in the file · 6df376e2
      Jan Kara authored
      [ Upstream commit 83c7423d ]
      
      When extending the last extent in the file within the last block, we
      wrongly computed the length of the last extent. This is mostly a
      cosmetical problem since the extent does not contain any data and the
      length will be fixed up by following operations but still.
      
      Fixes: 1f3868f0
      
       ("udf: Fix extending file within last block")
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6df376e2
    • Zhengchao Shao's avatar
      caif: fix memory leak in cfctrl_linkup_request() · 84b2cc7b
      Zhengchao Shao authored
      [ Upstream commit fe69230f ]
      
      When linktype is unknown or kzalloc failed in cfctrl_linkup_request(),
      pkt is not released. Add release process to error path.
      
      Fixes: b482cd20 ("net-caif: add CAIF core protocol stack")
      Fixes: 8d545c8f
      
       ("caif: Disconnect without waiting for response")
      Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Link: https://lore.kernel.org/r/20230104065146.1153009-1-shaozhengchao@huawei.com
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      84b2cc7b
    • Dan Carpenter's avatar
      drm/i915: unpin on error in intel_vgpu_shadow_mm_pin() · e5a05837
      Dan Carpenter authored
      [ Upstream commit 3792fc50 ]
      
      Call intel_vgpu_unpin_mm() on this error path.
      
      Fixes: 41874148
      
       ("drm/i915/gvt: Adding ppgtt to GVT GEM context after shadow pdps settled.")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/Y3OQ5tgZIVxyQ/WV@kili
      
      
      Reviewed-by: default avatarZhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e5a05837
    • Szymon Heidrich's avatar
      usb: rndis_host: Secure rndis_query check against int overflow · 232ef345
      Szymon Heidrich authored
      [ Upstream commit c7dd1380 ]
      
      Variables off and len typed as uint32 in rndis_query function
      are controlled by incoming RNDIS response message thus their
      value may be manipulated. Setting off to a unexpectetly large
      value will cause the sum with len and 8 to overflow and pass
      the implemented validation step. Consequently the response
      pointer will be referring to a location past the expected
      buffer boundaries allowing information leakage e.g. via
      RNDIS_OID_802_3_PERMANENT_ADDRESS OID.
      
      Fixes: ddda0862
      
       ("USB: rndis_host, various cleanups")
      Signed-off-by: default avatarSzymon Heidrich <szymon.heidrich@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      232ef345
    • Daniil Tatianin's avatar
      drivers/net/bonding/bond_3ad: return when there's no aggregator · 2a9ee7c2
      Daniil Tatianin authored
      [ Upstream commit 9c807965 ]
      
      Otherwise we would dereference a NULL aggregator pointer when calling
      __set_agg_ports_ready on the line below.
      
      Found by Linux Verification Center (linuxtesting.org) with the SVACE
      static analysis tool.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarDaniil Tatianin <d-tatianin@yandex-team.ru>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2a9ee7c2
    • Miaoqian Lin's avatar
      perf tools: Fix resources leak in perf_data__open_dir() · bc6a0993
      Miaoqian Lin authored
      [ Upstream commit 0a6564eb ]
      
      In perf_data__open_dir(), opendir() opens the directory stream.  Add
      missing closedir() to release it after use.
      
      Fixes: eb617670
      
       ("perf data: Add perf_data__open_dir_data function")
      Reviewed-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20221229090903.1402395-1-linmq006@gmail.com
      
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bc6a0993
    • Jozsef Kadlecsik's avatar
      netfilter: ipset: Rework long task execution when adding/deleting entries · ee756980
      Jozsef Kadlecsik authored
      [ Upstream commit 5e29dc36 ]
      
      When adding/deleting large number of elements in one step in ipset, it can
      take a reasonable amount of time and can result in soft lockup errors. The
      patch 5f7b51bf ("netfilter: ipset: Limit the maximal range of
      consecutive elements to add/delete") tried to fix it by limiting the max
      elements to process at all. However it was not enough, it is still possible
      that we get hung tasks. Lowering the limit is not reasonable, so the
      approach in this patch is as follows: rely on the method used at resizing
      sets and save the state when we reach a smaller internal batch limit,
      unlock/lock and proceed from the saved state. Thus we can avoid long
      continuous tasks and at the same time removed the limit to add/delete large
      number of elements in one step.
      
      The nfnl mutex is held during the whole operation which prevents one to
      issue other ipset commands in parallel.
      
      Fixes: 5f7b51bf
      
       ("netfilter: ipset: Limit the maximal range of consecutive elements to add/delete")
      Reported-by: default avatar <syzbot+9204e7399656300bf271@syzkaller.appspotmail.com>
      Signed-off-by: default avatarJozsef Kadlecsik <kadlec@netfilter.org>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ee756980
    • Jozsef Kadlecsik's avatar
      netfilter: ipset: fix hash:net,port,net hang with /0 subnet · ba5d2790
      Jozsef Kadlecsik authored
      [ Upstream commit a31d47be ]
      
      The hash:net,port,net set type supports /0 subnets. However, the patch
      commit 5f7b51bf titled "netfilter: ipset: Limit the maximal range
      of consecutive elements to add/delete" did not take into account it and
      resulted in an endless loop. The bug is actually older but the patch
      5f7b51bf brings it out earlier.
      
      Handle /0 subnets properly in hash:net,port,net set types.
      
      Fixes: 5f7b51bf
      
       ("netfilter: ipset: Limit the maximal range of consecutive elements to add/delete")
      Reported-by: default avatarМарк Коренберг <socketpair@gmail.com>
      Signed-off-by: default avatarJozsef Kadlecsik <kadlec@netfilter.org>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ba5d2790
    • Jamal Hadi Salim's avatar
      net: sched: cbq: dont intepret cls results when asked to drop · b2c917e5
      Jamal Hadi Salim authored
      [ Upstream commit caa4b35b ]
      
      If asked to drop a packet via TC_ACT_SHOT it is unsafe to assume that
      res.class contains a valid pointer
      
      Sample splat reported by Kyle Zeng
      
      [    5.405624] 0: reclassify loop, rule prio 0, protocol 800
      [    5.406326] ==================================================================
      [    5.407240] BUG: KASAN: slab-out-of-bounds in cbq_enqueue+0x54b/0xea0
      [    5.407987] Read of size 1 at addr ffff88800e3122aa by task poc/299
      [    5.408731]
      [    5.408897] CPU: 0 PID: 299 Comm: poc Not tainted 5.10.155+ #15
      [    5.409516] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
      BIOS 1.15.0-1 04/01/2014
      [    5.410439] Call Trace:
      [    5.410764]  dump_stack+0x87/0xcd
      [    5.411153]  print_address_description+0x7a/0x6b0
      [    5.411687]  ? vprintk_func+0xb9/0xc0
      [    5.411905]  ? printk+0x76/0x96
      [    5.412110]  ? cbq_enqueue+0x54b/0xea0
      [    5.412323]  kasan_report+0x17d/0x220
      [    5.412591]  ? cbq_enqueue+0x54b/0xea0
      [    5.412803]  __asan_report_load1_noabort+0x10/0x20
      [    5.413119]  cbq_enqueue+0x54b/0xea0
      [    5.413400]  ? __kasan_check_write+0x10/0x20
      [    5.413679]  __dev_queue_xmit+0x9c0/0x1db0
      [    5.413922]  dev_queue_xmit+0xc/0x10
      [    5.414136]  ip_finish_output2+0x8bc/0xcd0
      [    5.414436]  __ip_finish_output+0x472/0x7a0
      [    5.414692]  ip_finish_output+0x5c/0x190
      [    5.414940]  ip_output+0x2d8/0x3c0
      [    5.415150]  ? ip_mc_finish_output+0x320/0x320
      [    5.415429]  __ip_queue_xmit+0x753/0x1760
      [    5.415664]  ip_queue_xmit+0x47/0x60
      [    5.415874]  __tcp_transmit_skb+0x1ef9/0x34c0
      [    5.416129]  tcp_connect+0x1f5e/0x4cb0
      [    5.416347]  tcp_v4_connect+0xc8d/0x18c0
      [    5.416577]  __inet_stream_connect+0x1ae/0xb40
      [    5.416836]  ? local_bh_enable+0x11/0x20
      [    5.417066]  ? lock_sock_nested+0x175/0x1d0
      [    5.417309]  inet_stream_connect+0x5d/0x90
      [    5.417548]  ? __inet_stream_connect+0xb40/0xb40
      [    5.417817]  __sys_connect+0x260/0x2b0
      [    5.418037]  __x64_sys_connect+0x76/0x80
      [    5.418267]  do_syscall_64+0x31/0x50
      [    5.418477]  entry_SYSCALL_64_after_hwframe+0x61/0xc6
      [    5.418770] RIP: 0033:0x473bb7
      [    5.418952] Code: 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00
      00 00 90 f3 0f 1e fa 64 8b 04 25 18 00 00 00 85 c0 75 10 b8 2a 00 00
      00 0f 05 <48> 3d 00 f0 ff ff 77 51 c3 48 83 ec 18 89 54 24 0c 48 89 34
      24 89
      [    5.420046] RSP: 002b:00007fffd20eb0f8 EFLAGS: 00000246 ORIG_RAX:
      000000000000002a
      [    5.420472] RAX: ffffffffffffffda RBX: 00007fffd20eb578 RCX: 0000000000473bb7
      [    5.420872] RDX: 0000000000000010 RSI: 00007fffd20eb110 RDI: 0000000000000007
      [    5.421271] RBP: 00007fffd20eb150 R08: 0000000000000001 R09: 0000000000000004
      [    5.421671] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
      [    5.422071] R13: 00007fffd20eb568 R14: 00000000004fc740 R15: 0000000000000002
      [    5.422471]
      [    5.422562] Allocated by task 299:
      [    5.422782]  __kasan_kmalloc+0x12d/0x160
      [    5.423007]  kasan_kmalloc+0x5/0x10
      [    5.423208]  kmem_cache_alloc_trace+0x201/0x2e0
      [    5.423492]  tcf_proto_create+0x65/0x290
      [    5.423721]  tc_new_tfilter+0x137e/0x1830
      [    5.423957]  rtnetlink_rcv_msg+0x730/0x9f0
      [    5.424197]  netlink_rcv_skb+0x166/0x300
      [    5.424428]  rtnetlink_rcv+0x11/0x20
      [    5.424639]  netlink_unicast+0x673/0x860
      [    5.424870]  netlink_sendmsg+0x6af/0x9f0
      [    5.425100]  __sys_sendto+0x58d/0x5a0
      [    5.425315]  __x64_sys_sendto+0xda/0xf0
      [    5.425539]  do_syscall_64+0x31/0x50
      [    5.425764]  entry_SYSCALL_64_after_hwframe+0x61/0xc6
      [    5.426065]
      [    5.426157] The buggy address belongs to the object at ffff88800e312200
      [    5.426157]  which belongs to the cache kmalloc-128 of size 128
      [    5.426955] The buggy address is located 42 bytes to the right of
      [    5.426955]  128-byte region [ffff88800e312200, ffff88800e312280)
      [    5.427688] The buggy address belongs to the page:
      [    5.427992] page:000000009875fabc refcount:1 mapcount:0
      mapping:0000000000000000 index:0x0 pfn:0xe312
      [    5.428562] flags: 0x100000000000200(slab)
      [    5.428812] raw: 0100000000000200 dead000000000100 dead000000000122
      ffff888007843680
      [    5.429325] raw: 0000000000000000 0000000000100010 00000001ffffffff
      ffff88800e312401
      [    5.429875] page dumped because: kasan: bad access detected
      [    5.430214] page->mem_cgroup:ffff88800e312401
      [    5.430471]
      [    5.430564] Memory state around the buggy address:
      [    5.430846]  ffff88800e312180: fc fc fc fc fc fc fc fc fc fc fc fc
      fc fc fc fc
      [    5.431267]  ffff88800e312200: 00 00 00 00 00 00 00 00 00 00 00 00
      00 00 00 fc
      [    5.431705] >ffff88800e312280: fc fc fc fc fc fc fc fc fc fc fc fc
      fc fc fc fc
      [    5.432123]                                   ^
      [    5.432391]  ffff88800e312300: 00 00 00 00 00 00 00 00 00 00 00 00
      00 00 00 fc
      [    5.432810]  ffff88800e312380: fc fc fc fc fc fc fc fc fc fc fc fc
      fc fc fc fc
      [    5.433229] ==================================================================
      [    5.433648] Disabling lock debugging due to kernel taint
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-by: default avatarKyle Zeng <zengyhkyle@gmail.com>
      Signed-off-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b2c917e5
    • Jamal Hadi Salim's avatar
      net: sched: atm: dont intepret cls results when asked to drop · 5f65f485
      Jamal Hadi Salim authored
      [ Upstream commit a2965c7b ]
      
      If asked to drop a packet via TC_ACT_SHOT it is unsafe to assume
      res.class contains a valid pointer
      Fixes: b0188d4d
      
       ("[NET_SCHED]: sch_atm: Lindent")
      
      Signed-off-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5f65f485
    • Miaoqian Lin's avatar
      gpio: sifive: Fix refcount leak in sifive_gpio_probe · f4a2ad10
      Miaoqian Lin authored
      [ Upstream commit 694175cd ]
      
      of_irq_find_parent() returns a node pointer with refcount incremented,
      We should use of_node_put() on it when not needed anymore.
      Add missing of_node_put() to avoid refcount leak.
      
      Fixes: 96868dce
      
       ("gpio/sifive: Add GPIO driver for SiFive SoCs")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f4a2ad10
    • Xiubo Li's avatar
      ceph: switch to vfs_inode_has_locks() to fix file lock bug · 7ec369e2
      Xiubo Li authored
      [ Upstream commit 461ab10e ]
      
      For the POSIX locks they are using the same owner, which is the
      thread id. And multiple POSIX locks could be merged into single one,
      so when checking whether the 'file' has locks may fail.
      
      For a file where some openers use locking and others don't is a
      really odd usage pattern though. Locks are like stoplights -- they
      only work if everyone pays attention to them.
      
      Just switch ceph_get_caps() to check whether any locks are set on
      the inode. If there are POSIX/OFD/FLOCK locks on the file at the
      time, we should set CHECK_FILELOCK, regardless of what fd was used
      to set the lock.
      
      Fixes: ff5d913d
      
       ("ceph: return -EIO if read/write against filp that lost file locks")
      Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7ec369e2
    • Jeff Layton's avatar
      filelock: new helper: vfs_inode_has_locks · 40771042
      Jeff Layton authored
      [ Upstream commit ab1ddef9
      
       ]
      
      Ceph has a need to know whether a particular inode has any locks set on
      it. It's currently tracking that by a num_locks field in its
      filp->private_data, but that's problematic as it tries to decrement this
      field when releasing locks and that can race with the file being torn
      down.
      
      Add a new vfs_inode_has_locks helper that just returns whether any locks
      are currently held on the inode.
      
      Reviewed-by: default avatarXiubo Li <xiubli@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@infradead.org>
      Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Stable-dep-of: 461ab10e
      
       ("ceph: switch to vfs_inode_has_locks() to fix file lock bug")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      40771042
    • Carlo Caione's avatar
      drm/meson: Reduce the FIFO lines held when AFBC is not used · 9f0ff5de
      Carlo Caione authored
      [ Upstream commit 3b754ed6 ]
      
      Having a bigger number of FIFO lines held after vsync is only useful to
      SoCs using AFBC to give time to the AFBC decoder to be reset, configured
      and enabled again.
      
      For SoCs not using AFBC this, on the contrary, is causing on some
      displays issues and a few pixels vertical offset in the displayed image.
      
      Conditionally increase the number of lines held after vsync only for
      SoCs using AFBC, leaving the default value for all the others.
      
      Fixes: 24e0d405
      
       ("drm/meson: hold 32 lines after vsync to give time for AFBC start")
      Signed-off-by: default avatarCarlo Caione <ccaione@baylibre.com>
      Acked-by: default avatarMartin Blumenstingl <martin.blumenstingl@googlemail.com>
      Acked-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
      [narmstrong: added fixes tag]
      Signed-off-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221216-afbc_s905x-v1-0-033bebf780d9@baylibre.com
      
      
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9f0ff5de
    • Maor Gottlieb's avatar
      RDMA/mlx5: Fix validation of max_rd_atomic caps for DC · ae2639cd
      Maor Gottlieb authored
      [ Upstream commit 8de8482f ]
      
      Currently, when modifying DC, we validate max_rd_atomic user attribute
      against the RC cap, validate against DC. RC and DC QP types have different
      device limitations.
      
      This can cause userspace created DC QPs to malfunction.
      
      Fixes: c32a4f29 ("IB/mlx5: Add support for DC Initiator QP")
      Link: https://lore.kernel.org/r/0c5aee72cea188c3bb770f4207cce7abc9b6fc74.1672231736.git.leonro@nvidia.com
      
      
      Signed-off-by: default avatarMaor Gottlieb <maorg@nvidia.com>
      Signed-off-by: default avatarLeon Romanovsky <leon@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ae2639cd
    • Miaoqian Lin's avatar
      net: phy: xgmiitorgmii: Fix refcount leak in xgmiitorgmii_probe · 106d0d33
      Miaoqian Lin authored
      [ Upstream commit d0395358 ]
      
      of_phy_find_device() return device node with refcount incremented.
      Call put_device() to relese it when not needed anymore.
      
      Fixes: ab4e6ee5
      
       ("net: phy: xgmiitorgmii: Check phy_driver ready before accessing")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      106d0d33
    • Jiguang Xiao's avatar
      net: amd-xgbe: add missed tasklet_kill · 398e14bb
      Jiguang Xiao authored
      [ Upstream commit d530ece7 ]
      
      The driver does not call tasklet_kill in several places.
      Add the calls to fix it.
      
      Fixes: 85b85c85
      
       ("amd-xgbe: Re-issue interrupt if interrupt status not cleared")
      Signed-off-by: default avatarJiguang Xiao <jiguang.xiao@windriver.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      398e14bb
    • Adham Faris's avatar
      net/mlx5e: Fix hw mtu initializing at XDP SQ allocation · e3d90ca9
      Adham Faris authored
      [ Upstream commit 1e267ab8 ]
      
      Current xdp xmit functions logic (mlx5e_xmit_xdp_frame_mpwqe or
      mlx5e_xmit_xdp_frame), validates xdp packet length by comparing it to
      hw mtu (configured at xdp sq allocation) before xmiting it. This check
      does not account for ethernet fcs length (calculated and filled by the
      nic). Hence, when we try sending packets with length > (hw-mtu -
      ethernet-fcs-size), the device port drops it and tx_errors_phy is
      incremented. Desired behavior is to catch these packets and drop them
      by the driver.
      
      Fix this behavior in XDP SQ allocation function (mlx5e_alloc_xdpsq) by
      subtracting ethernet FCS header size (4 Bytes) from current hw mtu
      value, since ethernet FCS is calculated and written to ethernet frames
      by the nic.
      
      Fixes: d8bec2b2
      
       ("net/mlx5e: Support bpf_xdp_adjust_head()")
      Signed-off-by: default avatarAdham Faris <afaris@nvidia.com>
      Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3d90ca9
    • Dragos Tatulea's avatar
      net/mlx5e: IPoIB, Don't allow CQE compression to be turned on by default · 6d655a9d
      Dragos Tatulea authored
      [ Upstream commit b12d581e ]
      
      mlx5e_build_nic_params will turn CQE compression on if the hardware
      capability is enabled and the slow_pci_heuristic condition is detected.
      As IPoIB doesn't support CQE compression, make sure to disable the
      feature in the IPoIB profile init.
      
      Please note that the feature is not exposed to the user for IPoIB
      interfaces, so it can't be subsequently turned on.
      
      Fixes: b797a684
      
       ("net/mlx5e: Enable CQE compression when PCI is slower than link")
      Signed-off-by: default avatarDragos Tatulea <dtatulea@nvidia.com>
      Reviewed-by: default avatarGal Pressman <gal@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6d655a9d
    • Shay Drory's avatar
      net/mlx5: Avoid recovery in probe flows · 670b2061
      Shay Drory authored
      [ Upstream commit 9078e843 ]
      
      Currently, recovery is done without considering whether the device is
      still in probe flow.
      This may lead to recovery before device have finished probed
      successfully. e.g.: while mlx5_init_one() is running. Recovery flow is
      using functionality that is loaded only by mlx5_init_one(), and there
      is no point in running recovery without mlx5_init_one() finished
      successfully.
      
      Fix it by waiting for probe flow to finish and checking whether the
      device is probed before trying to perform recovery.
      
      Fixes: 51d138c2
      
       ("net/mlx5: Fix health error state handling")
      Signed-off-by: default avatarShay Drory <shayd@nvidia.com>
      Reviewed-by: default avatarMoshe Shemesh <moshe@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      670b2061
    • Jiri Pirko's avatar
      net/mlx5: Add forgotten cleanup calls into mlx5_init_once() error path · 66b92b80
      Jiri Pirko authored
      [ Upstream commit 2a35b2c2 ]
      
      There are two cleanup calls missing in mlx5_init_once() error path.
      Add them making the error path flow to be the same as
      mlx5_cleanup_once().
      
      Fixes: 52ec462e ("net/mlx5: Add reserved-gids support")
      Fixes: 7c39afb3
      
       ("net/mlx5: PTP code migration to driver core section")
      Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      66b92b80
    • Stefano Garzarella's avatar
      vhost: fix range used in translate_desc() · b6c74d23
      Stefano Garzarella authored
      [ Upstream commit 98047313 ]
      
      vhost_iotlb_itree_first() requires `start` and `last` parameters
      to search for a mapping that overlaps the range.
      
      In translate_desc() we cyclically call vhost_iotlb_itree_first(),
      incrementing `addr` by the amount already translated, so rightly
      we move the `start` parameter passed to vhost_iotlb_itree_first(),
      but we should hold the `last` parameter constant.
      
      Let's fix it by saving the `last` parameter value before incrementing
      `addr` in the loop.
      
      Fixes: a9709d68
      
       ("vhost: convert pre sorted vhost memory array to interval tree")
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221109102503.18816-3-sgarzare@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b6c74d23
    • Stefano Garzarella's avatar
      vringh: fix range used in iotlb_translate() · 264fb6dc
      Stefano Garzarella authored
      [ Upstream commit f85efa9b ]
      
      vhost_iotlb_itree_first() requires `start` and `last` parameters
      to search for a mapping that overlaps the range.
      
      In iotlb_translate() we cyclically call vhost_iotlb_itree_first(),
      incrementing `addr` by the amount already translated, so rightly
      we move the `start` parameter passed to vhost_iotlb_itree_first(),
      but we should hold the `last` parameter constant.
      
      Let's fix it by saving the `last` parameter value before incrementing
      `addr` in the loop.
      
      Fixes: 9ad9c49c
      
       ("vringh: IOTLB support")
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221109102503.18816-2-sgarzare@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      264fb6dc
    • Yuan Can's avatar
      vhost/vsock: Fix error handling in vhost_vsock_init() · eabb3ceb
      Yuan Can authored
      [ Upstream commit 7a4efe18 ]
      
      A problem about modprobe vhost_vsock failed is triggered with the
      following log given:
      
      modprobe: ERROR: could not insert 'vhost_vsock': Device or resource busy
      
      The reason is that vhost_vsock_init() returns misc_register() directly
      without checking its return value, if misc_register() failed, it returns
      without calling vsock_core_unregister() on vhost_transport, resulting the
      vhost_vsock can never be installed later.
      A simple call graph is shown as below:
      
       vhost_vsock_init()
         vsock_core_register() # register vhost_transport
         misc_register()
           device_create_with_groups()
             device_create_groups_vargs()
               dev = kzalloc(...) # OOM happened
         # return without unregister vhost_transport
      
      Fix by calling vsock_core_unregister() when misc_register() returns error.
      
      Fixes: 433fc58e
      
       ("VSOCK: Introduce vhost_vsock.ko")
      Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
      Message-Id: <20221108101705.45981-1-yuancan@huawei.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eabb3ceb
    • Miaoqian Lin's avatar
      nfc: Fix potential resource leaks · e0f5c962
      Miaoqian Lin authored
      [ Upstream commit df49908f ]
      
      nfc_get_device() take reference for the device, add missing
      nfc_put_device() to release it when not need anymore.
      Also fix the style warnning by use error EOPNOTSUPP instead of
      ENOTSUPP.
      
      Fixes: 5ce3f32b ("NFC: netlink: SE API implementation")
      Fixes: 29e76924
      
       ("nfc: netlink: Add capability to reply to vendor_cmd with data")
      Signed-off-by: default avatarMiaoqian Lin <linmq006@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e0f5c962
    • Daniil Tatianin's avatar
      qlcnic: prevent ->dcb use-after-free on qlcnic_dcb_enable() failure · 513787ff
      Daniil Tatianin authored
      [ Upstream commit 13a7c896 ]
      
      adapter->dcb would get silently freed inside qlcnic_dcb_enable() in
      case qlcnic_dcb_attach() would return an error, which always happens
      under OOM conditions. This would lead to use-after-free because both
      of the existing callers invoke qlcnic_dcb_get_info() on the obtained
      pointer, which is potentially freed at that point.
      
      Propagate errors from qlcnic_dcb_enable(), and instead free the dcb
      pointer at callsite using qlcnic_dcb_free(). This also removes the now
      unused qlcnic_clear_dcb_ops() helper, which was a simple wrapper around
      kfree() also causing memory leaks for partially initialized dcb.
      
      Found by Linux Verification Center (linuxtesting.org) with the SVACE
      static analysis tool.
      
      Fixes: 3c44bba1
      
       ("qlcnic: Disable DCB operations from SR-IOV VFs")
      Reviewed-by: default avatarMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
      Signed-off-by: default avatarDaniil Tatianin <d-tatianin@yandex-team.ru>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      513787ff
    • Hawkins Jiawei's avatar
      net: sched: fix memory leak in tcindex_set_parms · b314f6c3
      Hawkins Jiawei authored
      [ Upstream commit 399ab7fe ]
      
      Syzkaller reports a memory leak as follows:
      ====================================
      BUG: memory leak
      unreferenced object 0xffff88810c287f00 (size 256):
        comm "syz-executor105", pid 3600, jiffies 4294943292 (age 12.990s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<ffffffff814cf9f0>] kmalloc_trace+0x20/0x90 mm/slab_common.c:1046
          [<ffffffff839c9e07>] kmalloc include/linux/slab.h:576 [inline]
          [<ffffffff839c9e07>] kmalloc_array include/linux/slab.h:627 [inline]
          [<ffffffff839c9e07>] kcalloc include/linux/slab.h:659 [inline]
          [<ffffffff839c9e07>] tcf_exts_init include/net/pkt_cls.h:250 [inline]
          [<ffffffff839c9e07>] tcindex_set_parms+0xa7/0xbe0 net/sched/cls_tcindex.c:342
          [<ffffffff839caa1f>] tcindex_change+0xdf/0x120 net/sched/cls_tcindex.c:553
          [<ffffffff8394db62>] tc_new_tfilter+0x4f2/0x1100 net/sched/cls_api.c:2147
          [<ffffffff8389e91c>] rtnetlink_rcv_msg+0x4dc/0x5d0 net/core/rtnetlink.c:6082
          [<ffffffff839eba67>] netlink_rcv_skb+0x87/0x1d0 net/netlink/af_netlink.c:2540
          [<ffffffff839eab87>] netlink_unicast_kernel net/netlink/af_netlink.c:1319 [inline]
          [<ffffffff839eab87>] netlink_unicast+0x397/0x4c0 net/netlink/af_netlink.c:1345
          [<ffffffff839eb046>] netlink_sendmsg+0x396/0x710 net/netlink/af_netlink.c:1921
          [<ffffffff8383e796>] sock_sendmsg_nosec net/socket.c:714 [inline]
          [<ffffffff8383e796>] sock_sendmsg+0x56/0x80 net/socket.c:734
          [<ffffffff8383eb08>] ____sys_sendmsg+0x178/0x410 net/socket.c:2482
          [<ffffffff83843678>] ___sys_sendmsg+0xa8/0x110 net/socket.c:2536
          [<ffffffff838439c5>] __sys_sendmmsg+0x105/0x330 net/socket.c:2622
          [<ffffffff83843c14>] __do_sys_sendmmsg net/socket.c:2651 [inline]
          [<ffffffff83843c14>] __se_sys_sendmmsg net/socket.c:2648 [inline]
          [<ffffffff83843c14>] __x64_sys_sendmmsg+0x24/0x30 net/socket.c:2648
          [<ffffffff84605fd5>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]
          [<ffffffff84605fd5>] do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
          [<ffffffff84800087>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
      ====================================
      
      Kernel uses tcindex_change() to change an existing
      filter properties.
      
      Yet the problem is that, during the process of changing,
      if `old_r` is retrieved from `p->perfect`, then
      kernel uses tcindex_alloc_perfect_hash() to newly
      allocate filter results, uses tcindex_filter_result_init()
      to clear the old filter result, without destroying
      its tcf_exts structure, which triggers the above memory leak.
      
      To be more specific, there are only two source for the `old_r`,
      according to the tcindex_lookup(). `old_r` is retrieved from
      `p->perfect`, or `old_r` is retrieved from `p->h`.
      
        * If `old_r` is retrieved from `p->perfect`, kernel uses
      tcindex_alloc_perfect_hash() to newly allocate the
      filter results. Then `r` is assigned with `cp->perfect + handle`,
      which is newly allocated. So condition `old_r && old_r != r` is
      true in this situation, and kernel uses tcindex_filter_result_init()
      to clear the old filter result, without destroying
      its tcf_exts structure
      
        * If `old_r` is retrieved from `p->h`, then `p->perfect` is NULL
      according to the tcindex_lookup(). Considering that `cp->h`
      is directly copied from `p->h` and `p->perfect` is NULL,
      `r` is assigned with `tcindex_lookup(cp, handle)`, whose value
      should be the same as `old_r`, so condition `old_r && old_r != r`
      is false in this situation, kernel ignores using
      tcindex_filter_result_init() to clear the old filter result.
      
      So only when `old_r` is retrieved from `p->perfect` does kernel use
      tcindex_filter_result_init() to clear the old filter result, which
      triggers the above memory leak.
      
      Considering that there already exists a tc_filter_wq workqueue
      to destroy the old tcindex_data by tcindex_partial_destroy_work()
      at the end of tcindex_set_parms(), this patch solves
      this memory leak bug by removing this old filter result
      clearing part and delegating it to the tc_filter_wq workqueue.
      
      Note that this patch doesn't introduce any other issues. If
      `old_r` is retrieved from `p->perfect`, this patch just
      delegates old filter result clearing part to the
      tc_filter_wq workqueue; If `old_r` is retrieved from `p->h`,
      kernel doesn't reach the old filter result clearing part, so
      removing this part has no effect.
      
      [Thanks to the suggestion from Jakub Kicinski, Cong Wang, Paolo Abeni
      and Dmitry Vyukov]
      
      Fixes: b9a24bb7 ("net_sched: properly handle failure case of tcf_exts_init()")
      Link: https://lore.kernel.org/all/0000000000001de5c505ebc9ec59@google.com/
      
      
      Reported-by: default avatar <syzbot+232ebdbd36706c965ebf@syzkaller.appspotmail.com>
      Tested-by: default avatar <syzbot+232ebdbd36706c965ebf@syzkaller.appspotmail.com>
      Cc: Cong Wang <cong.wang@bytedance.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Paolo Abeni <pabeni@redhat.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarHawkins Jiawei <yin31149@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b314f6c3
    • Jie Wang's avatar
      net: hns3: add interrupts re-initialization while doing VF FLR · 4226ce95
      Jie Wang authored
      [ Upstream commit 09e6b30e ]
      
      Currently keep alive message between PF and VF may be lost and the VF is
      unalive in PF. So the VF will not do reset during PF FLR reset process.
      This would make the allocated interrupt resources of VF invalid and VF
      would't receive or respond to PF any more.
      
      So this patch adds VF interrupts re-initialization during VF FLR for VF
      recovery in above cases.
      
      Fixes: 862d969a
      
       ("net: hns3: do VF's pci re-initialization while PF doing FLR")
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarHao Lan <lanhao@huawei.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4226ce95