1. 04 Apr, 2023 6 commits
    • Jason Gunthorpe's avatar
      iommufd/selftest: Cover domain unmap with huge pages and access · 62e37c86
      Jason Gunthorpe authored
      Inspired by the syzkaller reproducer check the batch carry path with a
      simple test.
      
      Link: https://lore.kernel.org/r/4-v1-ceab6a4d7d7a+94-iommufd_syz_jgg@nvidia.comReviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      62e37c86
    • Jason Gunthorpe's avatar
      Merge branch 'iommufd/for-rc' into for-next · 692d42d4
      Jason Gunthorpe authored
      The following selftest patch requires both the bug fixes and the
      improvements of the selftest framework.
      
      * iommufd/for-rc:
        iommufd: Do not corrupt the pfn list when doing batch carry
        iommufd: Fix unpinning of pages when an access is present
        iommufd: Check for uptr overflow
        Linux 6.3-rc5
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      692d42d4
    • Tom Rix's avatar
      iommufd/selftest: Set varaiable mock_iommu_device storage-class-specifier to static · c52159b5
      Tom Rix authored
      smatch reports:
      
      drivers/iommu/iommufd/selftest.c:295:21: warning: symbol
        'mock_iommu_device' was not declared. Should it be static?
      
      This variable is only used in one file so it should be static.
      
      Fixes: 65c619ae ("iommufd/selftest: Make selftest create a more complete mock device")
      Link: https://lore.kernel.org/r/20230404002317.1912530-1-trix@redhat.comSigned-off-by: default avatarTom Rix <trix@redhat.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      c52159b5
    • Jason Gunthorpe's avatar
      iommufd: Do not corrupt the pfn list when doing batch carry · 13a0d1ae
      Jason Gunthorpe authored
      If batch->end is 0 then setting npfns[0] before computing the new value of
      pfns will fail to adjust the pfn and result in various page accounting
      corruptions. It should be ordered after.
      
      This seems to result in various kinds of page meta-data corruption related
      failures:
      
        WARNING: CPU: 1 PID: 527 at mm/gup.c:75 try_grab_folio+0x503/0x740
        Modules linked in:
        CPU: 1 PID: 527 Comm: repro Not tainted 6.3.0-rc2-eeac8ede+ #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
        RIP: 0010:try_grab_folio+0x503/0x740
        Code: e3 01 48 89 de e8 6d c1 dd ff 48 85 db 0f 84 7c fe ff ff e8 4f bf dd ff 49 8d 47 ff 48 89 45 d0 e9 73 fe ff ff e8 3d bf dd ff <0f> 0b 31 db e9 d0 fc ff ff e8 2f bf dd ff 48 8b 5d c8 31 ff 48 89
        RSP: 0018:ffffc90000f37908 EFLAGS: 00010046
        RAX: 0000000000000000 RBX: 00000000fffffc02 RCX: ffffffff81504c26
        RDX: 0000000000000000 RSI: ffff88800d030000 RDI: 0000000000000002
        RBP: ffffc90000f37948 R08: 000000000003ca24 R09: 0000000000000008
        R10: 000000000003ca00 R11: 0000000000000023 R12: ffffea000035d540
        R13: 0000000000000001 R14: 0000000000000000 R15: ffffea000035d540
        FS:  00007fecbf659740(0000) GS:ffff88807dd00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00000000200011c3 CR3: 000000000ef66006 CR4: 0000000000770ee0
        PKRU: 55555554
        Call Trace:
         <TASK>
         internal_get_user_pages_fast+0xd32/0x2200
         pin_user_pages_fast+0x65/0x90
         pfn_reader_user_pin+0x376/0x390
         pfn_reader_next+0x14a/0x7b0
         pfn_reader_first+0x140/0x1b0
         iopt_area_fill_domain+0x74/0x210
         iopt_table_add_domain+0x30e/0x6e0
         iommufd_device_selftest_attach+0x7f/0x140
         iommufd_test+0x10ff/0x16f0
         iommufd_fops_ioctl+0x206/0x330
         __x64_sys_ioctl+0x10e/0x160
         do_syscall_64+0x3b/0x90
         entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Cc: <stable@vger.kernel.org>
      Fixes: f394576e ("iommufd: PFN handling for iopt_pages")
      Link: https://lore.kernel.org/r/3-v1-ceab6a4d7d7a+94-iommufd_syz_jgg@nvidia.comReviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
      Reported-by: default avatarPengfei Xu <pengfei.xu@intel.com>
      Tested-by: default avatarPengfei Xu <pengfei.xu@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      13a0d1ae
    • Jason Gunthorpe's avatar
      iommufd: Fix unpinning of pages when an access is present · 727c28c1
      Jason Gunthorpe authored
      syzkaller found that the calculation of batch_last_index should use
      'start_index' since at input to this function the batch is either empty or
      it has already been adjusted to cross any accesses so it will start at the
      point we are unmapping from.
      
      Getting this wrong causes the unmap to run over the end of the pages
      which corrupts pages that were never mapped. In most cases this triggers
      the num pinned debugging:
      
        WARNING: CPU: 0 PID: 557 at drivers/iommu/iommufd/pages.c:294 __iopt_area_unfill_domain+0x152/0x560
        Modules linked in:
        CPU: 0 PID: 557 Comm: repro Not tainted 6.3.0-rc2-eeac8ede #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
        RIP: 0010:__iopt_area_unfill_domain+0x152/0x560
        Code: d2 0f ff 44 8b 64 24 54 48 8b 44 24 48 31 ff 44 89 e6 48 89 44 24 38 e8 fc d3 0f ff 45 85 e4 0f 85 eb 01 00 00 e8 0e d2 0f ff <0f> 0b e8 07 d2 0f ff 48 8b 44 24 38 89 5c 24 58 89 18 8b 44 24 54
        RSP: 0018:ffffc9000108baf0 EFLAGS: 00010246
        RAX: 0000000000000000 RBX: 00000000ffffffff RCX: ffffffff821e3f85
        RDX: 0000000000000000 RSI: ffff88800faf0000 RDI: 0000000000000002
        RBP: ffffc9000108bd18 R08: 000000000003ca25 R09: 0000000000000014
        R10: 000000000003ca00 R11: 0000000000000024 R12: 0000000000000004
        R13: 0000000000000801 R14: 00000000000007ff R15: 0000000000000800
        FS:  00007f3499ce1740(0000) GS:ffff88807dc00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000020000243 CR3: 00000000179c2001 CR4: 0000000000770ef0
        PKRU: 55555554
        Call Trace:
         <TASK>
         iopt_area_unfill_domain+0x32/0x40
         iopt_table_remove_domain+0x23f/0x4c0
         iommufd_device_selftest_detach+0x3a/0x90
         iommufd_selftest_destroy+0x55/0x70
         iommufd_object_destroy_user+0xce/0x130
         iommufd_destroy+0xa2/0xc0
         iommufd_fops_ioctl+0x206/0x330
         __x64_sys_ioctl+0x10e/0x160
         do_syscall_64+0x3b/0x90
         entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Also add some useful WARN_ON sanity checks.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 8d160cd4 ("iommufd: Algorithms for PFN storage")
      Link: https://lore.kernel.org/r/2-v1-ceab6a4d7d7a+94-iommufd_syz_jgg@nvidia.comReviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
      Reported-by: default avatarPengfei Xu <pengfei.xu@intel.com>
      Tested-by: default avatarPengfei Xu <pengfei.xu@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      727c28c1
    • Jason Gunthorpe's avatar
      iommufd: Check for uptr overflow · e4395701
      Jason Gunthorpe authored
      syzkaller found that setting up a map with a user VA that wraps past zero
      can trigger WARN_ONs, particularly from pin_user_pages weirdly returning 0
      due to invalid arguments.
      
      Prevent creating a pages with a uptr and size that would math overflow.
      
        WARNING: CPU: 0 PID: 518 at drivers/iommu/iommufd/pages.c:793 pfn_reader_user_pin+0x2e6/0x390
        Modules linked in:
        CPU: 0 PID: 518 Comm: repro Not tainted 6.3.0-rc2-eeac8ede+ #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
        RIP: 0010:pfn_reader_user_pin+0x2e6/0x390
        Code: b1 11 e9 25 fe ff ff e8 28 e4 0f ff 31 ff 48 89 de e8 2e e6 0f ff 48 85 db 74 0a e8 14 e4 0f ff e9 4d ff ff ff e8 0a e4 0f ff <0f> 0b bb f2 ff ff ff e9 3c ff ff ff e8 f9 e3 0f ff ba 01 00 00 00
        RSP: 0018:ffffc90000f9fa30 EFLAGS: 00010246
        RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff821e2b72
        RDX: 0000000000000000 RSI: ffff888014184680 RDI: 0000000000000002
        RBP: ffffc90000f9fa78 R08: 00000000000000ff R09: 0000000079de6f4e
        R10: ffffc90000f9f790 R11: ffff888014185418 R12: ffffc90000f9fc60
        R13: 0000000000000002 R14: ffff888007879800 R15: 0000000000000000
        FS:  00007f4227555740(0000) GS:ffff88807dc00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000020000043 CR3: 000000000e748005 CR4: 0000000000770ef0
        PKRU: 55555554
        Call Trace:
         <TASK>
         pfn_reader_next+0x14a/0x7b0
         ? interval_tree_double_span_iter_update+0x11a/0x140
         pfn_reader_first+0x140/0x1b0
         iopt_pages_rw_slow+0x71/0x280
         ? __this_cpu_preempt_check+0x20/0x30
         iopt_pages_rw_access+0x2b2/0x5b0
         iommufd_access_rw+0x19f/0x2f0
         iommufd_test+0xd11/0x16f0
         ? write_comp_data+0x2f/0x90
         iommufd_fops_ioctl+0x206/0x330
         __x64_sys_ioctl+0x10e/0x160
         ? __pfx_iommufd_fops_ioctl+0x10/0x10
         do_syscall_64+0x3b/0x90
         entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      Cc: <stable@vger.kernel.org>
      Fixes: 8d160cd4 ("iommufd: Algorithms for PFN storage")
      Link: https://lore.kernel.org/r/1-v1-ceab6a4d7d7a+94-iommufd_syz_jgg@nvidia.comReviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
      Reported-by: default avatarPengfei Xu <pengfei.xu@intel.com>
      Tested-by: default avatarPengfei Xu <pengfei.xu@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      e4395701
  2. 02 Apr, 2023 5 commits
  3. 01 Apr, 2023 5 commits
    • Linus Torvalds's avatar
      Merge tag '6.3-rc4-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6 · f7772da6
      Linus Torvalds authored
      Pull cifs client fixes from Steve French:
       "Four cifs/smb3 client (reconnect and DFS related) fixes, including two
        for stable:
      
         - DFS oops fix
      
         - DFS reconnect recursion fix
      
         - An SMB1 parallel reconnect fix
      
         - Trivial dead code removal in smb2_reconnect"
      
      * tag '6.3-rc4-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
        cifs: get rid of dead check in smb2_reconnect()
        cifs: prevent infinite recursion in CIFSGetDFSRefer()
        cifs: avoid races in parallel reconnects in smb1
        cifs: fix DFS traversal oops without CONFIG_CIFS_DFS_UPCALL
      f7772da6
    • Linus Torvalds's avatar
      Merge tag 'input-for-v6.3-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input · 00c7b5f4
      Linus Torvalds authored
      Pull input fixes from Dmitry Torokhov:
      
       - fixes to ALPS and Focaltech PS/2 drivers dealing with the breakage of
         switching to -funsigned-char
      
       - quirks to i8042 to better handle Lifebook A574/H and TUXEDO devices
      
       - a quirk to Goodix touchscreen driver to handle Yoga Book X90F
      
       - a fix for incorrectly merged patch to xpad game controller driver
      
      * tag 'input-for-v6.3-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
        Input: i8042 - add TUXEDO devices to i8042 quirk tables for partial fix
        Input: alps - fix compatibility with -funsigned-char
        Input: focaltech - use explicitly signed char type
        Input: xpad - fix incorrectly applied patch for MAP_PROFILE_BUTTON
        Input: goodix - add Lenovo Yoga Book X90F to nine_bytes_report DMI table
        Input: i8042 - add quirk for Fujitsu Lifebook A574/H
      00c7b5f4
    • Linus Torvalds's avatar
      Merge tag 'pinctrl-v6.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl · 93e2b017
      Linus Torvalds authored
      Pull pin control fixes from Linus Walleij:
       "Some pin control fixes for the v6.3 series.
      
        The most notable and urgent one is probably the AMD fix which affects
        AMD laptops, found by the Chromium people.
      
        Summary:
      
         - Fix up the Kconfig options for MediaTek MT7981
      
         - Fix the irq domain name in the AT91-PIO4 driver
      
         - Fix some alternative muxing modes in the Ocelot driver
      
         - Allocate the GPIO numbers dynamically in the STM32 driver
      
         - Disable and mask interrupts on resume in the AMD driver
      
         - Fix a typo in the Qualcomm SM8550 pin control device tree bindings"
      
      * tag 'pinctrl-v6.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
        dt-bindings: pinctrl: qcom,sm8550-lpass-lpi: allow input-enabled and bias-bus-hold
        pinctrl: amd: Disable and mask interrupts on resume
        pinctrl: stm32: use dynamic allocation of GPIO base
        pinctrl: ocelot: Fix alt mode for ocelot
        pinctrl: at91-pio4: fix domain name assignment
        pinctrl: mediatek: fix naming inconsistency
        pinctrl: mediatek: add missing options to PINCTRL_MT7981
      93e2b017
    • Linus Torvalds's avatar
      Merge tag 'kbuild-fixes-v6.3-2' of... · ce0c2375
      Linus Torvalds authored
      Merge tag 'kbuild-fixes-v6.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
      
      Pull Kbuild fixes from Masahiro Yamada:
      
       - Fix linux-headers debian package
      
       - Fix a merge_config.sh error due to a misspelled variable
      
       - Fix modversion for 32-bit build machines
      
      * tag 'kbuild-fixes-v6.3-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
        modpost: Fix processing of CRCs on 32-bit build machines
        scripts: merge_config: Fix typo in variable name.
        kbuild: deb-pkg: set version for linux-headers paths
      ce0c2375
    • Linus Torvalds's avatar
      Merge tag 'iommu-fixes-6.3-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu · 92367fdf
      Linus Torvalds authored
      Pull iommu fixes from Joerg Roedel:
      
       - Maintainer update for S390 IOMMU driver
      
       - A fix for the set_platform_dma_ops() call-back in the Exynos
         IOMMU driver
      
       - Intel VT-d fixes from Lu Baolu:
          - Fix a lockdep splat
          - Fix a supplement of the specification
          - Fix a warning in perfmon code
      
      * tag 'iommu-fixes-6.3-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
        iommu/vt-d: Fix an IOMMU perfmon warning when CPU hotplug
        iommu/vt-d: Allow zero SAGAW if second-stage not supported
        iommu/vt-d: Remove unnecessary locking in intel_irq_remapping_alloc()
        iommu/exynos: Fix set_platform_dma_ops() callback
        MAINTAINERS: Update s390-iommu driver maintainer information
      92367fdf
  4. 31 Mar, 2023 24 commits