1. 06 Apr, 2023 7 commits
  2. 05 Apr, 2023 8 commits
    • Daniel Vetter's avatar
      Merge tag 'drm-misc-fixes-2023-04-05' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes · 3dfa8926
      Daniel Vetter authored
      Short summary of fixes pull:
      
       * ivpu: DMA fence and suspend fixes
       * nouveau: Color-depth fixes
       * panfrost: Fix mmap error handling
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      From: Thomas Zimmermann <tzimmermann@suse.de>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230405182855.GA1551@linux-uq9g
      3dfa8926
    • Linus Torvalds's avatar
      Merge tag 'trace-v6.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace · 99ddf225
      Linus Torvalds authored
      Pull tracing fixes from Steven Rostedt:
      
       - Fix timerlat notification, as it was not triggering the notify to
         users when a new max latency was hit.
      
       - Do not trigger max latency if the tracing is off.
      
         When tracing is off, the ring buffer is not updated, it does not make
         sense to notify when there's a new max latency detected by the
         tracer, as why that latency happened is not available. The tracing
         logic still runs when the ring buffer is disabled, but it should not
         be triggering notifications.
      
       - Fix race on freeing the synthetic event "last_cmd" variable by adding
         a mutex around it.
      
       - Fix race between reader and writer of the ring buffer by adding
         memory barriers. When the writer is still on the reader page it must
         have its content visible on the buffer before it moves the commit
         index that the reader uses to know how much content is on the page.
      
       - Make get_lock_parent_ip() always inlined, as it uses _THIS_IP_ and
         _RET_IP_, which gets broken if it is not inlined.
      
       - Make __field(int, arr[5]) in a TRACE_EVENT() macro fail to build.
      
         The field formats of trace events are calculated by using
         sizeof(type) and other means by what is passed into the structure
         macros like __field(). The __field() macro is only meant for atom
         types like int, long, short, pointer, etc. It is not meant for
         arrays.
      
         The code will currently compile with arrays, but then the format
         produced will be inaccurate, and user space parsing tools will break.
      
         Two bugs have already been fixed, now add code that will make the
         kernel fail to build if another trace event includes this buggy field
         format.
      
       - Fix boot up snapshot code:
      
         Boot snapshots were triggering when not even asked for on the kernel
         command line. This was caused by two bugs:
      
          1) It would trigger a snapshot on any instance if one was created
             from the kernel command line.
      
          2) The error handling would only affect the top level instance.
             So the fact that a snapshot was done on a instance that didn't
             allocate a buffer triggered a warning written into the top level
             buffer, and worse yet, disabled the top level buffer.
      
       - Fix memory leak that was caused when an error was logged in a trace
         buffer instance, and then the buffer instance was removed.
      
         The allocated error log messages still needed to be freed.
      
      * tag 'trace-v6.3-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
        tracing: Free error logs of tracing instances
        tracing: Fix ftrace_boot_snapshot command line logic
        tracing: Have tracing_snapshot_instance_cond() write errors to the appropriate instance
        tracing: Error if a trace event has an array for a __field()
        tracing/osnoise: Fix notify new tracing_max_latency
        tracing/timerlat: Notify new max thread latency
        ftrace: Mark get_lock_parent_ip() __always_inline
        ring-buffer: Fix race while reader and writer are on the same page
        tracing/synthetic: Fix races on freeing last_cmd
      99ddf225
    • Steven Rostedt (Google)'s avatar
      tracing: Free error logs of tracing instances · 3357c6e4
      Steven Rostedt (Google) authored
      When a tracing instance is removed, the error messages that hold errors
      that occurred in the instance needs to be freed. The following reports a
      memory leak:
      
       # cd /sys/kernel/tracing
       # mkdir instances/foo
       # echo 'hist:keys=x' > instances/foo/events/sched/sched_switch/trigger
       # cat instances/foo/error_log
       [  117.404795] hist:sched:sched_switch: error: Couldn't find field
         Command: hist:keys=x
                            ^
       # rmdir instances/foo
      
      Then check for memory leaks:
      
       # echo scan > /sys/kernel/debug/kmemleak
       # cat /sys/kernel/debug/kmemleak
      unreferenced object 0xffff88810d8ec700 (size 192):
        comm "bash", pid 869, jiffies 4294950577 (age 215.752s)
        hex dump (first 32 bytes):
          60 dd 68 61 81 88 ff ff 60 dd 68 61 81 88 ff ff  `.ha....`.ha....
          a0 30 8c 83 ff ff ff ff 26 00 0a 00 00 00 00 00  .0......&.......
        backtrace:
          [<00000000dae26536>] kmalloc_trace+0x2a/0xa0
          [<00000000b2938940>] tracing_log_err+0x277/0x2e0
          [<000000004a0e1b07>] parse_atom+0x966/0xb40
          [<0000000023b24337>] parse_expr+0x5f3/0xdb0
          [<00000000594ad074>] event_hist_trigger_parse+0x27f8/0x3560
          [<00000000293a9645>] trigger_process_regex+0x135/0x1a0
          [<000000005c22b4f2>] event_trigger_write+0x87/0xf0
          [<000000002cadc509>] vfs_write+0x162/0x670
          [<0000000059c3b9be>] ksys_write+0xca/0x170
          [<00000000f1cddc00>] do_syscall_64+0x3e/0xc0
          [<00000000868ac68c>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
      unreferenced object 0xffff888170c35a00 (size 32):
        comm "bash", pid 869, jiffies 4294950577 (age 215.752s)
        hex dump (first 32 bytes):
          0a 20 20 43 6f 6d 6d 61 6e 64 3a 20 68 69 73 74  .  Command: hist
          3a 6b 65 79 73 3d 78 0a 00 00 00 00 00 00 00 00  :keys=x.........
        backtrace:
          [<000000006a747de5>] __kmalloc+0x4d/0x160
          [<000000000039df5f>] tracing_log_err+0x29b/0x2e0
          [<000000004a0e1b07>] parse_atom+0x966/0xb40
          [<0000000023b24337>] parse_expr+0x5f3/0xdb0
          [<00000000594ad074>] event_hist_trigger_parse+0x27f8/0x3560
          [<00000000293a9645>] trigger_process_regex+0x135/0x1a0
          [<000000005c22b4f2>] event_trigger_write+0x87/0xf0
          [<000000002cadc509>] vfs_write+0x162/0x670
          [<0000000059c3b9be>] ksys_write+0xca/0x170
          [<00000000f1cddc00>] do_syscall_64+0x3e/0xc0
          [<00000000868ac68c>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
      
      The problem is that the error log needs to be freed when the instance is
      removed.
      
      Link: https://lore.kernel.org/lkml/76134d9f-a5ba-6a0d-37b3-28310b4a1e91@alu.unizg.hr/
      Link: https://lore.kernel.org/linux-trace-kernel/20230404194504.5790b95f@gandalf.local.home
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Thorsten Leemhuis <regressions@leemhuis.info>
      Cc: Ulf Hansson <ulf.hansson@linaro.org>
      Cc: Eric Biggers <ebiggers@kernel.org>
      Fixes: 2f754e77 ("tracing: Have the error logs show up in the proper instances")
      Reported-by: default avatarMirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
      Tested-by: default avatarMirsad Todorovac <mirsad.todorovac@alu.unizg.hr>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      3357c6e4
    • Daniel Vetter's avatar
      Merge tag 'drm-intel-fixes-2023-04-05' of... · 1a4edef8
      Daniel Vetter authored
      Merge tag 'drm-intel-fixes-2023-04-05' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes
      
      drm/i915 fixes for v6.3-rc6:
      - Fix DP MST DSC M/N calculation to use compressed bpp
      - Fix racy use-after-free in perf ioctl
      - Fix context runtime accounting
      - Fix handling of GT reset during HuC loading
      - Fix use of unsigned vm_fault_t for error values
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      From: Jani Nikula <jani.nikula@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/87zg7mzomz.fsf@intel.com
      1a4edef8
    • Jacek Lawrynowicz's avatar
      accel/ivpu: Fix S3 system suspend when not idle · 0ec86718
      Jacek Lawrynowicz authored
      Wait for VPU to be idle in ivpu_pm_suspend_cb() before powering off
      the device, so jobs are not lost and TDRs are not triggered after
      resume.
      
      Fixes: 852be13f ("accel/ivpu: Add PM support")
      Signed-off-by: default avatarStanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
      Reviewed-by: default avatarJeffrey Hugo <quic_jhugo@quicinc.com>
      Signed-off-by: default avatarJacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230331113603.2802515-3-stanislaw.gruszka@linux.intel.com
      0ec86718
    • Karol Wachowski's avatar
      accel/ivpu: Add dma fence to command buffers only · 774e7cb5
      Karol Wachowski authored
      Currently job->done_fence is added to every BO handle within a job. If job
      handle (command buffer) is shared between multiple submits, KMD will add
      the fence in each of them. Then bo_wait_ioctl() executed on command buffer
      will exit only when all jobs containing that handle are done.
      
      This creates deadlock scenario for user mode driver in case when job handle
      is added as dependency of another job, because bo_wait_ioctl() of first job
      will wait until second job finishes, and second job can not finish before
      first one.
      
      Having fences added only to job buffer handle allows user space to execute
      bo_wait_ioctl() on the job even if it's handle is submitted with other job.
      
      Fixes: cd727221 ("accel/ivpu: Add command buffer submission logic")
      Signed-off-by: default avatarKarol Wachowski <karol.wachowski@linux.intel.com>
      Signed-off-by: default avatarStanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
      Reviewed-by: default avatarJeffrey Hugo <quic_jhugo@quicinc.com>
      Signed-off-by: default avatarJacek Lawrynowicz <jacek.lawrynowicz@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20230331113603.2802515-2-stanislaw.gruszka@linux.intel.com
      774e7cb5
    • Steven Rostedt (Google)'s avatar
      tracing: Fix ftrace_boot_snapshot command line logic · e9489164
      Steven Rostedt (Google) authored
      The kernel command line ftrace_boot_snapshot by itself is supposed to
      trigger a snapshot at the end of boot up of the main top level trace
      buffer. A ftrace_boot_snapshot=foo will do the same for an instance called
      foo that was created by trace_instance=foo,...
      
      The logic was broken where if ftrace_boot_snapshot was by itself, it would
      trigger a snapshot for all instances that had tracing enabled, regardless
      if it asked for a snapshot or not.
      
      When a snapshot is requested for a buffer, the buffer's
      tr->allocated_snapshot is set to true. Use that to know if a trace buffer
      wants a snapshot at boot up or not.
      
      Since the top level buffer is part of the ftrace_trace_arrays list,
      there's no reason to treat it differently than the other buffers. Just
      iterate the list if ftrace_boot_snapshot was specified.
      
      Link: https://lkml.kernel.org/r/20230405022341.895334039@goodmis.org
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ross Zwisler <zwisler@google.com>
      Fixes: 9c1c251d ("tracing: Allow boot instances to have snapshot buffers")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      e9489164
    • Steven Rostedt (Google)'s avatar
      tracing: Have tracing_snapshot_instance_cond() write errors to the appropriate instance · 9d52727f
      Steven Rostedt (Google) authored
      If a trace instance has a failure with its snapshot code, the error
      message is to be written to that instance's buffer. But currently, the
      message is written to the top level buffer. Worse yet, it may also disable
      the top level buffer and not the instance that had the issue.
      
      Link: https://lkml.kernel.org/r/20230405022341.688730321@goodmis.org
      
      Cc: stable@vger.kernel.org
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Ross Zwisler <zwisler@google.com>
      Fixes: 2824f503 ("tracing: Make the snapshot trigger work with instances")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      9d52727f
  3. 04 Apr, 2023 12 commits
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 76f598ba
      Linus Torvalds authored
      Pull kvm fixes from Paolo Bonzini:
       "PPC:
         - Hide KVM_CAP_IRQFD_RESAMPLE if XIVE is enabled
      
        s390:
         - Fix handling of external interrupts in protected guests
      
        x86:
         - Resample the pending state of IOAPIC interrupts when unmasking them
      
         - Fix usage of Hyper-V "enlightened TLB" on AMD
      
         - Small fixes to real mode exceptions
      
         - Suppress pending MMIO write exits if emulator detects exception
      
        Documentation:
         - Fix rST syntax"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        docs: kvm: x86: Fix broken field list
        KVM: PPC: Make KVM_CAP_IRQFD_RESAMPLE platform dependent
        KVM: s390: pv: fix external interruption loop not always detected
        KVM: nVMX: Do not report error code when synthesizing VM-Exit from Real Mode
        KVM: x86: Clear "has_error_code", not "error_code", for RM exception injection
        KVM: x86: Suppress pending MMIO write exits if emulator detects exception
        KVM: x86/ioapic: Resample the pending state of an IRQ when unmasking
        KVM: irqfd: Make resampler_list an RCU list
        KVM: SVM: Flush Hyper-V TLB when required
      76f598ba
    • Linus Torvalds's avatar
      Merge tag 'nfsd-6.3-5' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux · ceeea1b7
      Linus Torvalds authored
      Pull nfsd fixes from Chuck Lever:
      
       - Fix a crash and a resource leak in NFSv4 COMPOUND processing
      
       - Fix issues with AUTH_SYS credential handling
      
       - Try again to address an NFS/NFSD/SUNRPC build dependency regression
      
      * tag 'nfsd-6.3-5' of git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux:
        NFSD: callback request does not use correct credential for AUTH_SYS
        NFS: Remove "select RPCSEC_GSS_KRB5
        sunrpc: only free unix grouplist after RCU settles
        nfsd: call op_release, even when op_func returns an error
        NFSD: Avoid calling OPDESC() with ops->opnum == OP_ILLEGAL
      ceeea1b7
    • Takahiro Itazuri's avatar
      docs: kvm: x86: Fix broken field list · fb5015bc
      Takahiro Itazuri authored
      Add a missing ":" to fix a broken field list.
      Signed-off-by: default avatarTakahiro Itazuri <itazur@amazon.com>
      Fixes: ba7bb663 ("KVM: x86: Provide per VM capability for disabling PMU virtualization")
      Message-Id: <20230331093116.99820-1-itazur@amazon.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      fb5015bc
    • Arnd Bergmann's avatar
      asm-generic: avoid __generic_cmpxchg_local warnings · 656e9007
      Arnd Bergmann authored
      Code that passes a 32-bit constant into cmpxchg() produces a harmless
      sparse warning because of the truncation in the branch that is not taken:
      
      fs/erofs/zdata.c: note: in included file (through /home/arnd/arm-soc/arch/arm/include/asm/cmpxchg.h, /home/arnd/arm-soc/arch/arm/include/asm/atomic.h, /home/arnd/arm-soc/include/linux/atomic.h, ...):
      include/asm-generic/cmpxchg-local.h:29:33: warning: cast truncates bits from constant value (5f0ecafe becomes fe)
      include/asm-generic/cmpxchg-local.h:33:34: warning: cast truncates bits from constant value (5f0ecafe becomes cafe)
      include/asm-generic/cmpxchg-local.h:29:33: warning: cast truncates bits from constant value (5f0ecafe becomes fe)
      include/asm-generic/cmpxchg-local.h:30:42: warning: cast truncates bits from constant value (5f0edead becomes ad)
      include/asm-generic/cmpxchg-local.h:33:34: warning: cast truncates bits from constant value (5f0ecafe becomes cafe)
      include/asm-generic/cmpxchg-local.h:34:44: warning: cast truncates bits from constant value (5f0edead becomes dead)
      
      This was reported as a regression to Matt's recent __generic_cmpxchg_local
      patch, though this patch only added more warnings on top of the ones
      that were already there.
      
      Rewording the truncation to use an explicit bitmask instead of a cast
      to a smaller type avoids the warning but otherwise leaves the code
      unchanged.
      
      I had another look at why the cast is even needed for atomic_cmpxchg(),
      and as Matt describes the problem here is that atomic_t contains a
      signed 'int', but cmpxchg() takes an 'unsigned long' argument, and
      converting between the two leads to a 64-bit sign-extension of
      negative 32-bit atomics.
      
      I checked the other implementations of arch_cmpxchg() and did not find
      any others that run into the same problem as __generic_cmpxchg_local(),
      but it's easy to be on the safe side here and always convert the
      signed int into an unsigned int when calling arch_cmpxchg(), as this
      will work even when any of the arch_cmpxchg() implementations run
      into the same problem.
      
      Fixes: 62465415 ("locking/atomic: cmpxchg: Make __generic_cmpxchg_local compare against zero-extended 'old' value")
      Reviewed-by: default avatarMatt Evans <mev@rivosinc.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      656e9007
    • Vladimir Oltean's avatar
      asm-generic/io.h: suppress endianness warnings for relaxed accessors · 05d3855b
      Vladimir Oltean authored
      Copy the forced type casts from the normal MMIO accessors to suppress
      the sparse warnings that point out __raw_readl() returns a native endian
      word (just like readl()).
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      05d3855b
    • Vladimir Oltean's avatar
      asm-generic/io.h: suppress endianness warnings for readq() and writeq() · d564fa1f
      Vladimir Oltean authored
      Commit c1d55d50 ("asm-generic/io.h: Fix sparse warnings on
      big-endian architectures") missed fixing the 64-bit accessors.
      
      Arnd explains in the attached link why the casts are necessary, even if
      __raw_readq() and __raw_writeq() do not take endian-specific types.
      
      Link: https://lore.kernel.org/lkml/9105d6fc-880b-4734-857d-e3d30b87ccf6@app.fastmail.com/Suggested-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      d564fa1f
    • Dai Ngo's avatar
      NFSD: callback request does not use correct credential for AUTH_SYS · 7de82c2f
      Dai Ngo authored
      Currently callback request does not use the credential specified in
      CREATE_SESSION if the security flavor for the back channel is AUTH_SYS.
      
      Problem was discovered by pynfs 4.1 DELEG5 and DELEG7 test with error:
      DELEG5   st_delegation.testCBSecParms     : FAILURE
                 expected callback with uid, gid == 17, 19, got 0, 0
      Signed-off-by: default avatarDai Ngo <dai.ngo@oracle.com>
      Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
      Fixes: 8276c902 ("SUNRPC: remove uid and gid from struct auth_cred")
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      7de82c2f
    • Chuck Lever's avatar
      NFS: Remove "select RPCSEC_GSS_KRB5 · 8be8f170
      Chuck Lever authored
      If CONFIG_CRYPTO=n (e.g. arm/shmobile_defconfig):
      
         WARNING: unmet direct dependencies detected for RPCSEC_GSS_KRB5
           Depends on [n]: NETWORK_FILESYSTEMS [=y] && SUNRPC [=y] && CRYPTO [=n]
           Selected by [y]:
           - NFS_V4 [=y] && NETWORK_FILESYSTEMS [=y] && NFS_FS [=y]
      
      As NFSv4 can work without crypto enabled, remove the RPCSEC_GSS_KRB5
      dependency altogether.
      
      Trond says:
      > It is possible to use the NFSv4.1 client with just AUTH_SYS, and
      > in fact there are plenty of people out there using only that. The
      > fact that RFC5661 gets its knickers in a twist about RPCSEC_GSS
      > support is largely irrelevant to those people.
      >
      > The other issue is that ’select’ enforces the strict dependency
      > that if the NFS client is compiled into the kernel, then the
      > RPCSEC_GSS and kerberos code needs to be compiled in as well: they
      > cannot exist as modules.
      
      Fixes: e57d0652 ("NFS & NFSD: Update GSS dependencies")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reported-by: default avatarNiklas Söderlund <niklas.soderlund@ragnatech.se>
      Suggested-by: default avatarTrond Myklebust <trondmy@hammerspace.com>
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      8be8f170
    • Jeff Layton's avatar
      sunrpc: only free unix grouplist after RCU settles · 5085e41f
      Jeff Layton authored
      While the unix_gid object is rcu-freed, the group_info list that it
      contains is not. Ensure that we only put the group list reference once
      we are really freeing the unix_gid object.
      Reported-by: default avatarZhi Li <yieli@redhat.com>
      Link: https://bugzilla.redhat.com/show_bug.cgi?id=2183056Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
      Fixes: fd5d2f78 ("SUNRPC: Make server side AUTH_UNIX use lockless lookups")
      Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
      5085e41f
    • 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
  4. 03 Apr, 2023 13 commits