An error occurred fetching the project authors.
  1. 27 Jan, 2023 1 commit
    • Jason Wang's avatar
      vhost-scsi: unbreak any layout for response · 6dd88fd5
      Jason Wang authored
      Al Viro said:
      
      """
      Since "vhost/scsi: fix reuse of &vq->iov[out] in response"
      we have this:
                      cmd->tvc_resp_iov = vq->iov[vc.out];
                      cmd->tvc_in_iovs = vc.in;
      combined with
                      iov_iter_init(&iov_iter, ITER_DEST, &cmd->tvc_resp_iov,
                                    cmd->tvc_in_iovs, sizeof(v_rsp));
      in vhost_scsi_complete_cmd_work().  We used to have ->tvc_resp_iov
      _pointing_ to vq->iov[vc.out]; back then iov_iter_init() asked to
      set an iovec-backed iov_iter over the tail of vq->iov[], with
      length being the amount of iovecs in the tail.
      
      Now we have a copy of one element of that array.  Fortunately, the members
      following it in the containing structure are two non-NULL kernel pointers,
      so copy_to_iter() will not copy anything beyond the first iovec - kernel
      pointer is not (on the majority of architectures) going to be accepted by
      access_ok() in copyout() and it won't be skipped since the "length" (in
      reality - another non-NULL kernel pointer) won't be zero.
      
      So it's not going to give a guest-to-qemu escalation, but it's definitely
      a bug.  Frankly, my preference would be to verify that the very first iovec
      is long enough to hold rsp_size.  Due to the above, any users that try to
      give us vq->iov[vc.out].iov_len < sizeof(struct virtio_scsi_cmd_resp)
      would currently get a failure in vhost_scsi_complete_cmd_work()
      anyway.
      """
      
      However, the spec doesn't say anything about the legacy descriptor
      layout for the respone. So this patch tries to not assume the response
      to reside in a single separate descriptor which is what commit
      79c14141 ("vhost/scsi: Convert completion path to use") tries to
      achieve towards to ANY_LAYOUT.
      
      This is done by allocating and using dedicate resp iov in the
      command. To be safety, start with UIO_MAXIOV to be consistent with the
      limitation that we advertise to the vhost_get_vq_desc().
      
      Testing with the hacked virtio-scsi driver that use 1 descriptor for 1
      byte in the response.
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Cc: Benjamin Coddington <bcodding@redhat.com>
      Cc: Nicholas Bellinger <nab@linux-iscsi.org>
      Fixes: a77ec83a ("vhost/scsi: fix reuse of &vq->iov[out] in response")
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Message-Id: <20230119073647.76467-1-jasowang@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      6dd88fd5
  2. 25 Nov, 2022 1 commit
    • Al Viro's avatar
      use less confusing names for iov_iter direction initializers · de4eda9d
      Al Viro authored
      READ/WRITE proved to be actively confusing - the meanings are
      "data destination, as used with read(2)" and "data source, as
      used with write(2)", but people keep interpreting those as
      "we read data from it" and "we write data to it", i.e. exactly
      the wrong way.
      
      Call them ITER_DEST and ITER_SOURCE - at least that is harder
      to misinterpret...
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      de4eda9d
  3. 11 Aug, 2022 2 commits
  4. 09 Aug, 2022 1 commit
  5. 31 May, 2022 2 commits
  6. 05 Sep, 2021 1 commit
  7. 03 Jul, 2021 3 commits
  8. 04 Mar, 2021 5 commits
  9. 23 Feb, 2021 1 commit
  10. 18 Dec, 2020 1 commit
  11. 25 Nov, 2020 1 commit
  12. 15 Nov, 2020 4 commits
  13. 29 Jul, 2020 1 commit
  14. 04 Jun, 2020 1 commit
  15. 26 May, 2020 1 commit
  16. 16 Apr, 2020 1 commit
  17. 01 Apr, 2020 1 commit
  18. 23 Oct, 2019 1 commit
  19. 27 May, 2019 2 commits
  20. 12 May, 2019 1 commit
  21. 05 Feb, 2019 1 commit
  22. 29 Jan, 2019 1 commit
    • Jason Wang's avatar
      vhost: fix OOB in get_rx_bufs() · b46a0bf7
      Jason Wang authored
      After batched used ring updating was introduced in commit e2b3b35e
      ("vhost_net: batch used ring update in rx"). We tend to batch heads in
      vq->heads for more than one packet. But the quota passed to
      get_rx_bufs() was not correctly limited, which can result a OOB write
      in vq->heads.
      
              headcount = get_rx_bufs(vq, vq->heads + nvq->done_idx,
                          vhost_len, &in, vq_log, &log,
                          likely(mergeable) ? UIO_MAXIOV : 1);
      
      UIO_MAXIOV was still used which is wrong since we could have batched
      used in vq->heads, this will cause OOB if the next buffer needs more
      than 960 (1024 (UIO_MAXIOV) - 64 (VHOST_NET_BATCH)) heads after we've
      batched 64 (VHOST_NET_BATCH) heads:
      Acked-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      
      =============================================================================
      BUG kmalloc-8k (Tainted: G    B            ): Redzone overwritten
      -----------------------------------------------------------------------------
      
      INFO: 0x00000000fd93b7a2-0x00000000f0713384. First byte 0xa9 instead of 0xcc
      INFO: Allocated in alloc_pd+0x22/0x60 age=3933677 cpu=2 pid=2674
          kmem_cache_alloc_trace+0xbb/0x140
          alloc_pd+0x22/0x60
          gen8_ppgtt_create+0x11d/0x5f0
          i915_ppgtt_create+0x16/0x80
          i915_gem_create_context+0x248/0x390
          i915_gem_context_create_ioctl+0x4b/0xe0
          drm_ioctl_kernel+0xa5/0xf0
          drm_ioctl+0x2ed/0x3a0
          do_vfs_ioctl+0x9f/0x620
          ksys_ioctl+0x6b/0x80
          __x64_sys_ioctl+0x11/0x20
          do_syscall_64+0x43/0xf0
          entry_SYSCALL_64_after_hwframe+0x44/0xa9
      INFO: Slab 0x00000000d13e87af objects=3 used=3 fp=0x          (null) flags=0x200000000010201
      INFO: Object 0x0000000003278802 @offset=17064 fp=0x00000000e2e6652b
      
      Fixing this by allocating UIO_MAXIOV + VHOST_NET_BATCH iovs for
      vhost-net. This is done through set the limitation through
      vhost_dev_init(), then set_owner can allocate the number of iov in a
      per device manner.
      
      This fixes CVE-2018-16880.
      
      Fixes: e2b3b35e ("vhost_net: batch used ring update in rx")
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b46a0bf7
  23. 15 Jan, 2019 1 commit
  24. 19 Dec, 2018 1 commit
  25. 28 Nov, 2018 2 commits
  26. 25 Oct, 2018 2 commits