1. 07 8月, 2019 29 次提交
  2. 04 8月, 2019 11 次提交
    • B
      scsi: core: Avoid that a kernel warning appears during system resume · 475f7781
      Bart Van Assche 提交于
      commit 17605afaae825b0291f80c62a7f6565879edaa8a upstream.
      
      Since scsi_device_quiesce() skips SCSI devices that have another state than
      RUNNING, OFFLINE or TRANSPORT_OFFLINE, scsi_device_resume() should not
      complain about SCSI devices that have been skipped. Hence this patch.  This
      patch avoids that the following warning appears during resume:
      
      WARNING: CPU: 3 PID: 1039 at blk_clear_pm_only+0x2a/0x30
      CPU: 3 PID: 1039 Comm: kworker/u8:49 Not tainted 5.0.0+ #1
      Hardware name: LENOVO 4180F42/4180F42, BIOS 83ET75WW (1.45 ) 05/10/2013
      Workqueue: events_unbound async_run_entry_fn
      RIP: 0010:blk_clear_pm_only+0x2a/0x30
      Call Trace:
       ? scsi_device_resume+0x28/0x50
       ? scsi_dev_type_resume+0x2b/0x80
       ? async_run_entry_fn+0x2c/0xd0
       ? process_one_work+0x1f0/0x3f0
       ? worker_thread+0x28/0x3c0
       ? process_one_work+0x3f0/0x3f0
       ? kthread+0x10c/0x130
       ? __kthread_create_on_node+0x150/0x150
       ? ret_from_fork+0x1f/0x30
      
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Hannes Reinecke <hare@suse.com>
      Cc: Ming Lei <ming.lei@redhat.com>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: Oleksandr Natalenko <oleksandr@natalenko.name>
      Cc: Martin Steigerwald <martin@lichtvoll.de>
      Cc: <stable@vger.kernel.org>
      Reported-by: NJisheng Zhang <Jisheng.Zhang@synaptics.com>
      Tested-by: NJisheng Zhang <Jisheng.Zhang@synaptics.com>
      Fixes: 3a0a5299 ("block, scsi: Make SCSI quiesce and resume work reliably") # v4.15
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      475f7781
    • B
      block, scsi: Change the preempt-only flag into a counter · c58a6507
      Bart Van Assche 提交于
      commit cd84a62e0078dce09f4ed349bec84f86c9d54b30 upstream.
      
      The RQF_PREEMPT flag is used for three purposes:
      - In the SCSI core, for making sure that power management requests
        are executed even if a device is in the "quiesced" state.
      - For domain validation by SCSI drivers that use the parallel port.
      - In the IDE driver, for IDE preempt requests.
      Rename "preempt-only" into "pm-only" because the primary purpose of
      this mode is power management. Since the power management core may
      but does not have to resume a runtime suspended device before
      performing system-wide suspend and since a later patch will set
      "pm-only" mode as long as a block device is runtime suspended, make
      it possible to set "pm-only" mode from more than one context. Since
      with this change scsi_device_quiesce() is no longer idempotent, make
      that function return early if it is called for a quiesced queue.
      Signed-off-by: NBart Van Assche <bvanassche@acm.org>
      Acked-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NMing Lei <ming.lei@redhat.com>
      Cc: Jianchao Wang <jianchao.w.wang@oracle.com>
      Cc: Johannes Thumshirn <jthumshirn@suse.de>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c58a6507
    • M
      drivers/pps/pps.c: clear offset flags in PPS_SETPARAMS ioctl · 135e7737
      Miroslav Lichvar 提交于
      commit 5515e9a6273b8c02034466bcbd717ac9f53dab99 upstream.
      
      The PPS assert/clear offset corrections are set by the PPS_SETPARAMS
      ioctl in the pps_ktime structs, which also contain flags.  The flags are
      not initialized by applications (using the timepps.h header) and they
      are not used by the kernel for anything except returning them back in
      the PPS_GETPARAMS ioctl.
      
      Set the flags to zero to make it clear they are unused and avoid leaking
      uninitialized data of the PPS_SETPARAMS caller to other applications
      that have a read access to the PPS device.
      
      Link: http://lkml.kernel.org/r/20190702092251.24303-1-mlichvar@redhat.comSigned-off-by: NMiroslav Lichvar <mlichvar@redhat.com>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Acked-by: NRodolfo Giometti <giometti@enneenne.com>
      Cc: Greg KH <greg@kroah.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      135e7737
    • J
      vhost: scsi: add weight support · 02cdc166
      Jason Wang 提交于
      commit c1ea02f15ab5efb3e93fc3144d895410bf79fcf2 upstream.
      
      This patch will check the weight and exit the loop if we exceeds the
      weight. This is useful for preventing scsi kthread from hogging cpu
      which is guest triggerable.
      
      This addresses CVE-2019-3900.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Fixes: 057cbf49 ("tcm_vhost: Initial merge for vhost level target fabric driver")
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      [jwang: backport to 4.19]
      Signed-off-by: NJack Wang <jinpu.wang@cloud.ionos.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      02cdc166
    • J
      vhost: vsock: add weight support · 23991010
      Jason Wang 提交于
      commit e79b431fb901ba1106670bcc80b9b617b25def7d upstream.
      
      This patch will check the weight and exit the loop if we exceeds the
      weight. This is useful for preventing vsock kthread from hogging cpu
      which is guest triggerable. The weight can help to avoid starving the
      request from on direction while another direction is being processed.
      
      The value of weight is picked from vhost-net.
      
      This addresses CVE-2019-3900.
      
      Cc: Stefan Hajnoczi <stefanha@redhat.com>
      Fixes: 433fc58e ("VSOCK: Introduce vhost_vsock.ko")
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23991010
    • J
      vhost_net: fix possible infinite loop · 3af3b843
      Jason Wang 提交于
      commit e2412c07f8f3040593dfb88207865a3cd58680c0 upstream.
      
      When the rx buffer is too small for a packet, we will discard the vq
      descriptor and retry it for the next packet:
      
      while ((sock_len = vhost_net_rx_peek_head_len(net, sock->sk,
      					      &busyloop_intr))) {
      ...
      	/* On overrun, truncate and discard */
      	if (unlikely(headcount > UIO_MAXIOV)) {
      		iov_iter_init(&msg.msg_iter, READ, vq->iov, 1, 1);
      		err = sock->ops->recvmsg(sock, &msg,
      					 1, MSG_DONTWAIT | MSG_TRUNC);
      		pr_debug("Discarded rx packet: len %zd\n", sock_len);
      		continue;
      	}
      ...
      }
      
      This makes it possible to trigger a infinite while..continue loop
      through the co-opreation of two VMs like:
      
      1) Malicious VM1 allocate 1 byte rx buffer and try to slow down the
         vhost process as much as possible e.g using indirect descriptors or
         other.
      2) Malicious VM2 generate packets to VM1 as fast as possible
      
      Fixing this by checking against weight at the end of RX and TX
      loop. This also eliminate other similar cases when:
      
      - userspace is consuming the packets in the meanwhile
      - theoretical TOCTOU attack if guest moving avail index back and forth
        to hit the continue after vhost find guest just add new buffers
      
      This addresses CVE-2019-3900.
      
      Fixes: d8316f39 ("vhost: fix total length when packets are too short")
      Fixes: 3a4d5c94 ("vhost_net: a kernel-level virtio server")
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      [jwang: backport to 4.19]
      Signed-off-by: NJack Wang <jinpu.wang@cloud.ionos.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3af3b843
    • J
      vhost: introduce vhost_exceeds_weight() · ad5fc895
      Jason Wang 提交于
      commit e82b9b0727ff6d665fff2d326162b460dded554d upstream.
      
      We used to have vhost_exceeds_weight() for vhost-net to:
      
      - prevent vhost kthread from hogging the cpu
      - balance the time spent between TX and RX
      
      This function could be useful for vsock and scsi as well. So move it
      to vhost.c. Device must specify a weight which counts the number of
      requests, or it can also specific a byte_weight which counts the
      number of bytes that has been processed.
      Signed-off-by: NJason Wang <jasowang@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      [jwang: backport to 4.19, fix conflict in net.c]
      Signed-off-by: NJack Wang <jinpu.wang@cloud.ionos.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ad5fc895
    • V
      Bluetooth: hci_uart: check for missing tty operations · 56966212
      Vladis Dronov 提交于
      commit b36a1552d7319bbfd5cf7f08726c23c5c66d4f73 upstream.
      
      Certain ttys operations (pty_unix98_ops) lack tiocmget() and tiocmset()
      functions which are called by the certain HCI UART protocols (hci_ath,
      hci_bcm, hci_intel, hci_mrvl, hci_qca) via hci_uart_set_flow_control()
      or directly. This leads to an execution at NULL and can be triggered by
      an unprivileged user. Fix this by adding a helper function and a check
      for the missing tty operations in the protocols code.
      
      This fixes CVE-2019-10207. The Fixes: lines list commits where calls to
      tiocm[gs]et() or hci_uart_set_flow_control() were added to the HCI UART
      protocols.
      
      Link: https://syzkaller.appspot.com/bug?id=1b42faa2848963564a5b1b7f8c837ea7b55ffa50
      Reported-by: syzbot+79337b501d6aa974d0f6@syzkaller.appspotmail.com
      Cc: stable@vger.kernel.org # v2.6.36+
      Fixes: b3190df6 ("Bluetooth: Support for Atheros AR300x serial chip")
      Fixes: 118612fb ("Bluetooth: hci_bcm: Add suspend/resume PM functions")
      Fixes: ff289559 ("Bluetooth: hci_intel: Add Intel baudrate configuration support")
      Fixes: 162f812f ("Bluetooth: hci_uart: Add Marvell support")
      Fixes: fa9ad876 ("Bluetooth: hci_qca: Add support for Qualcomm Bluetooth chip wcn3990")
      Signed-off-by: NVladis Dronov <vdronov@redhat.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Reviewed-by: NYu-Chen, Cho <acho@suse.com>
      Tested-by: NYu-Chen, Cho <acho@suse.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      56966212
    • D
      iommu/vt-d: Don't queue_iova() if there is no flush queue · 4fd0eb60
      Dmitry Safonov 提交于
      commit effa467870c7612012885df4e246bdb8ffd8e44c upstream.
      
      Intel VT-d driver was reworked to use common deferred flushing
      implementation. Previously there was one global per-cpu flush queue,
      afterwards - one per domain.
      
      Before deferring a flush, the queue should be allocated and initialized.
      
      Currently only domains with IOMMU_DOMAIN_DMA type initialize their flush
      queue. It's probably worth to init it for static or unmanaged domains
      too, but it may be arguable - I'm leaving it to iommu folks.
      
      Prevent queuing an iova flush if the domain doesn't have a queue.
      The defensive check seems to be worth to keep even if queue would be
      initialized for all kinds of domains. And is easy backportable.
      
      On 4.19.43 stable kernel it has a user-visible effect: previously for
      devices in si domain there were crashes, on sata devices:
      
       BUG: spinlock bad magic on CPU#6, swapper/0/1
        lock: 0xffff88844f582008, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
       CPU: 6 PID: 1 Comm: swapper/0 Not tainted 4.19.43 #1
       Call Trace:
        <IRQ>
        dump_stack+0x61/0x7e
        spin_bug+0x9d/0xa3
        do_raw_spin_lock+0x22/0x8e
        _raw_spin_lock_irqsave+0x32/0x3a
        queue_iova+0x45/0x115
        intel_unmap+0x107/0x113
        intel_unmap_sg+0x6b/0x76
        __ata_qc_complete+0x7f/0x103
        ata_qc_complete+0x9b/0x26a
        ata_qc_complete_multiple+0xd0/0xe3
        ahci_handle_port_interrupt+0x3ee/0x48a
        ahci_handle_port_intr+0x73/0xa9
        ahci_single_level_irq_intr+0x40/0x60
        __handle_irq_event_percpu+0x7f/0x19a
        handle_irq_event_percpu+0x32/0x72
        handle_irq_event+0x38/0x56
        handle_edge_irq+0x102/0x121
        handle_irq+0x147/0x15c
        do_IRQ+0x66/0xf2
        common_interrupt+0xf/0xf
       RIP: 0010:__do_softirq+0x8c/0x2df
      
      The same for usb devices that use ehci-pci:
       BUG: spinlock bad magic on CPU#0, swapper/0/1
        lock: 0xffff88844f402008, .magic: 00000000, .owner: <none>/-1, .owner_cpu: 0
       CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.19.43 #4
       Call Trace:
        <IRQ>
        dump_stack+0x61/0x7e
        spin_bug+0x9d/0xa3
        do_raw_spin_lock+0x22/0x8e
        _raw_spin_lock_irqsave+0x32/0x3a
        queue_iova+0x77/0x145
        intel_unmap+0x107/0x113
        intel_unmap_page+0xe/0x10
        usb_hcd_unmap_urb_setup_for_dma+0x53/0x9d
        usb_hcd_unmap_urb_for_dma+0x17/0x100
        unmap_urb_for_dma+0x22/0x24
        __usb_hcd_giveback_urb+0x51/0xc3
        usb_giveback_urb_bh+0x97/0xde
        tasklet_action_common.isra.4+0x5f/0xa1
        tasklet_action+0x2d/0x30
        __do_softirq+0x138/0x2df
        irq_exit+0x7d/0x8b
        smp_apic_timer_interrupt+0x10f/0x151
        apic_timer_interrupt+0xf/0x20
        </IRQ>
       RIP: 0010:_raw_spin_unlock_irqrestore+0x17/0x39
      
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Lu Baolu <baolu.lu@linux.intel.com>
      Cc: iommu@lists.linux-foundation.org
      Cc: <stable@vger.kernel.org> # 4.14+
      Fixes: 13cf0174 ("iommu/vt-d: Make use of iova deferred flushing")
      Signed-off-by: NDmitry Safonov <dima@arista.com>
      Reviewed-by: NLu Baolu <baolu.lu@linux.intel.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      [v4.14-port notes:
      o minor conflict with untrusted IOMMU devices check under if-condition]
      Signed-off-by: NDmitry Safonov <dima@arista.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4fd0eb60
    • L
      media: radio-raremono: change devm_k*alloc to k*alloc · b3836af8
      Luke Nowakowski-Krijger 提交于
      commit c666355e60ddb4748ead3bdd983e3f7f2224aaf0 upstream.
      
      Change devm_k*alloc to k*alloc to manually allocate memory
      
      The manual allocation and freeing of memory is necessary because when
      the USB radio is disconnected, the memory associated with devm_k*alloc
      is freed. Meaning if we still have unresolved references to the radio
      device, then we get use-after-free errors.
      
      This patch fixes this by manually allocating memory, and freeing it in
      the v4l2.release callback that gets called when the last radio device
      exits.
      
      Reported-and-tested-by: syzbot+a4387f5b6b799f6becbf@syzkaller.appspotmail.com
      Signed-off-by: NLuke Nowakowski-Krijger <lnowakow@eng.ucsd.edu>
      Signed-off-by: NHans Verkuil <hverkuil-cisco@xs4all.nl>
      [hverkuil-cisco@xs4all.nl: cleaned up two small checkpatch.pl warnings]
      [hverkuil-cisco@xs4all.nl: prefix subject with driver name]
      Signed-off-by: NMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b3836af8
    • A
      media: pvrusb2: use a different format for warnings · 8edcabb2
      Andrey Konovalov 提交于
      commit 1753c7c4367aa1201e1e5d0a601897ab33444af1 upstream.
      
      When the pvrusb2 driver detects that there's something wrong with the
      device, it prints a warning message. Right now those message are
      printed in two different formats:
      
      1. ***WARNING*** message here
      2. WARNING: message here
      
      There's an issue with the second format. Syzkaller recognizes it as a
      message produced by a WARN_ON(), which is used to indicate a bug in the
      kernel. However pvrusb2 prints those warnings to indicate an issue with
      the device, not the bug in the kernel.
      
      This patch changes the pvrusb2 driver to consistently use the first
      warning message format. This will unblock syzkaller testing of this
      driver.
      
      Reported-by: syzbot+af8f8d2ac0d39b0ed3a0@syzkaller.appspotmail.com
      Reported-by: syzbot+170a86bf206dd2c6217e@syzkaller.appspotmail.com
      Signed-off-by: NAndrey Konovalov <andreyknvl@google.com>
      Reviewed-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: NMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8edcabb2