1. 26 Sep, 2018 40 commits
    • Jia-Ju Bai's avatar
      usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt() · b8b53ade
      Jia-Ju Bai authored
      commit 6e22e3af upstream.
      
      wdm_in_callback() is a completion handler function for the USB driver.
      So it should not sleep. But it calls service_outstanding_interrupt(),
      which calls usb_submit_urb() with GFP_KERNEL.
      
      To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC.
      
      This bug is found by my static analysis tool DSAC.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b8b53ade
    • Ben Hutchings's avatar
      USB: yurex: Fix buffer over-read in yurex_write() · 4be36bcc
      Ben Hutchings authored
      commit 7e10f14e upstream.
      
      If the written data starts with a digit, yurex_write() tries to parse
      it as an integer using simple_strtoull().  This requires a null-
      terminator, and currently there's no guarantee that there is one.
      
      (The sample program at
      https://github.com/NeoCat/YUREX-driver-for-Linux/blob/master/sample/yurex_clock.pl
      writes an integer without a null terminator.  It seems like it must
      have worked by chance!)
      
      Always add a null byte after the written data.  Enlarge the buffer
      to allow for this.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4be36bcc
    • Jia-Ju Bai's avatar
      usb: misc: uss720: Fix two sleep-in-atomic-context bugs · b214cde7
      Jia-Ju Bai authored
      commit bc8acc21 upstream.
      
      async_complete() in uss720.c is a completion handler function for the
      USB driver. So it should not sleep, but it is can sleep according to the
      function call paths (from bottom to top) in Linux-4.16.
      
      [FUNC] set_1284_register(GFP_KERNEL)
      drivers/usb/misc/uss720.c, 372:
        set_1284_register in parport_uss720_frob_control
      drivers/parport/ieee1284.c, 560:
        [FUNC_PTR]parport_uss720_frob_control in parport_ieee1284_ack_data_avail
      drivers/parport/ieee1284.c, 577:
        parport_ieee1284_ack_data_avail in parport_ieee1284_interrupt
      ./include/linux/parport.h, 474:
        parport_ieee1284_interrupt in parport_generic_irq
      drivers/usb/misc/uss720.c, 116:
        parport_generic_irq in async_complete
      
      [FUNC] get_1284_register(GFP_KERNEL)
      drivers/usb/misc/uss720.c, 382:
        get_1284_register in parport_uss720_read_status
      drivers/parport/ieee1284.c, 555:
        [FUNC_PTR]parport_uss720_read_status in parport_ieee1284_ack_data_avail
      drivers/parport/ieee1284.c, 577:
        parport_ieee1284_ack_data_avail in parport_ieee1284_interrupt
      ./include/linux/parport.h, 474:
        parport_ieee1284_interrupt in parport_generic_irq
      drivers/usb/misc/uss720.c, 116:
        parport_generic_irq in async_complete
      
      Note that [FUNC_PTR] means a function pointer call is used.
      
      To fix these bugs, GFP_KERNEL is replaced with GFP_ATOMIC.
      
      These bugs are found by my static analysis tool DSAC.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b214cde7
    • Johan Hovold's avatar
      USB: serial: io_ti: fix array underflow in completion handler · 403c5c23
      Johan Hovold authored
      commit 691a03cf upstream.
      
      As reported by Dan Carpenter, a malicious USB device could set
      port_number to a negative value and we would underflow the port array in
      the interrupt completion handler.
      
      As these devices only have one or two ports, fix this by making sure we
      only consider the seventh bit when determining the port number (and
      ignore bits 0xb0 which are typically set to 0x30).
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      403c5c23
    • Alan Stern's avatar
      USB: net2280: Fix erroneous synchronization change · f409f340
      Alan Stern authored
      commit dec3c23c upstream.
      
      Commit f16443a0 ("USB: gadgetfs, dummy-hcd, net2280: fix locking
      for callbacks") was based on a serious misunderstanding.  It
      introduced regressions into both the dummy-hcd and net2280 drivers.
      
      The problem in dummy-hcd was fixed by commit 7dbd8f4c ("USB:
      dummy-hcd: Fix erroneous synchronization change"), but the problem in
      net2280 remains.  Namely: the ->disconnect(), ->suspend(), ->resume(),
      and ->reset() callbacks must be invoked without the private lock held;
      otherwise a deadlock will occur when the callback routine tries to
      interact with the UDC driver.
      
      This patch largely is a reversion of the relevant parts of
      f16443a0.  It also drops the private lock around the calls to
      ->suspend() and ->resume() (something the earlier patch forgot to do).
      This is safe from races with device interrupts because it occurs
      within the interrupt handler.
      
      Finally, the patch changes where the ->disconnect() callback is
      invoked when net2280_pullup() turns the pullup off.  Rather than
      making the callback from within stop_activity() at a time when dropping
      the private lock could be unsafe, the callback is moved to a point
      after the lock has already been dropped.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Fixes: f16443a0 ("USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks")
      Reported-by: default avatarD. Ziesche <dziesche@zes.com>
      Tested-by: default avatarD. Ziesche <dziesche@zes.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f409f340
    • Maxence Duprès's avatar
      USB: add quirk for WORLDE Controller KS49 or Prodipe MIDI 49C USB controller · 34f1df0f
      Maxence Duprès authored
      commit 9b83a1c3 upstream.
      
      WORLDE Controller KS49 or Prodipe MIDI 49C USB controller
      cause a -EPROTO error, a communication restart and loop again.
      
      This issue has already been fixed for KS25.
      https://lore.kernel.org/patchwork/patch/753077/
      
      I just add device 201 for KS49 in quirks.c to get it works.
      Signed-off-by: default avatarLaurent Roux <xpros64@hotmail.fr>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      34f1df0f
    • Jia-Ju Bai's avatar
      usb: host: u132-hcd: Fix a sleep-in-atomic-context bug in u132_get_frame() · 637acc7b
      Jia-Ju Bai authored
      commit 6d4f268f upstream.
      
      i_usX2Y_subs_startup in usbusx2yaudio.c is a completion handler function
      for the USB driver. So it should not sleep, but it is can sleep
      according to the function call paths (from bottom to top) in Linux-4.16.
      
      [FUNC] msleep
      drivers/usb/host/u132-hcd.c, 2558:
      	msleep in u132_get_frame
      drivers/usb/core/hcd.c, 2231:
      	[FUNC_PTR]u132_get_frame in usb_hcd_get_frame_number
      drivers/usb/core/usb.c, 822:
      	usb_hcd_get_frame_number in usb_get_current_frame_number
      sound/usb/usx2y/usbusx2yaudio.c, 303:
      	usb_get_current_frame_number in i_usX2Y_urb_complete
      sound/usb/usx2y/usbusx2yaudio.c, 366:
      	i_usX2Y_urb_complete in i_usX2Y_subs_startup
      
      Note that [FUNC_PTR] means a function pointer call is used.
      
      To fix this bug, msleep() is replaced with mdelay().
      
      This bug is found by my static analysis tool DSAC.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      637acc7b
    • Mathias Nyman's avatar
      usb: Avoid use-after-free by flushing endpoints early in usb_set_interface() · 35bcdf48
      Mathias Nyman authored
      commit f9a5b4f5 upstream.
      
      The steps taken by usb core to set a new interface is very different from
      what is done on the xHC host side.
      
      xHC hardware will do everything in one go. One command is used to set up
      new endpoints, free old endpoints, check bandwidth, and run the new
      endpoints.
      
      All this is done by xHC when usb core asks the hcd to check for
      available bandwidth. At this point usb core has not yet flushed the old
      endpoints, which will cause use-after-free issues in xhci driver as
      queued URBs are cancelled on a re-allocated endpoint.
      
      To resolve this add a call to usb_disable_interface() which will flush
      the endpoints before calling usb_hcd_alloc_bandwidth()
      
      Additional checks in xhci driver will also be implemented to gracefully
      handle stale URB cancel on freed and re-allocated endpoints
      
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35bcdf48
    • Tim Anderson's avatar
      USB: Add quirk to support DJI CineSSD · 49c05a00
      Tim Anderson authored
      commit f45681f9 upstream.
      
      This device does not correctly handle the LPM operations.
      
      Also, the device cannot handle ATA pass-through commands
      and locks up when attempted while running in super speed.
      
      This patch adds the equivalent quirk logic as found in uas.
      Signed-off-by: default avatarTim Anderson <tsa@biglakesoftware.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      49c05a00
    • Mathias Nyman's avatar
      usb: Don't die twice if PCI xhci host is not responding in resume · c343fc80
      Mathias Nyman authored
      commit f3dc41c5 upstream.
      
      usb_hc_died() should only be called once, and with the primary HCD
      as parameter. It will mark both primary and secondary hcd's dead.
      
      Remove the extra call to usb_cd_died with the shared hcd as parameter.
      
      Fixes: ff9d78b3 ("USB: Set usb_hcd->state and flags for shared roothubs")
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c343fc80
    • Gustavo A. R. Silva's avatar
      misc: hmc6352: fix potential Spectre v1 · 68fe884e
      Gustavo A. R. Silva authored
      commit de916736 upstream.
      
      val is indirectly controlled by user-space, hence leading to a
      potential exploitation of the Spectre variant 1 vulnerability.
      
      This issue was detected with the help of Smatch:
      
      drivers/misc/hmc6352.c:54 compass_store() warn: potential spectre issue
      'map' [r]
      
      Fix this by sanitizing val before using it to index map
      
      Notice that given that speculation windows are large, the policy is
      to kill the speculation on the first load and not worry if it can be
      completed with a dependent load/store [1].
      
      [1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      68fe884e
    • K. Y. Srinivasan's avatar
      Tools: hv: Fix a bug in the key delete code · c527796f
      K. Y. Srinivasan authored
      commit 86503bd3 upstream.
      
      Fix a bug in the key delete code - the num_records range
      from 0 to num_records-1.
      Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
      Reported-by: default avatarDavid Binderman <dcb314@hotmail.com>
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarMichael Kelley <mikelley@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c527796f
    • Aaron Knister's avatar
      IB/ipoib: Avoid a race condition between start_xmit and cm_rep_handler · ee4d1a30
      Aaron Knister authored
      commit 816e846c upstream.
      
      Inside of start_xmit() the call to check if the connection is up and the
      queueing of the packets for later transmission is not atomic which leaves
      a window where cm_rep_handler can run, set the connection up, dequeue
      pending packets and leave the subsequently queued packets by start_xmit()
      sitting on neigh->queue until they're dropped when the connection is torn
      down. This only applies to connected mode. These dropped packets can
      really upset TCP, for example, and cause multi-minute delays in
      transmission for open connections.
      
      Here's the code in start_xmit where we check to see if the connection is
      up:
      
             if (ipoib_cm_get(neigh)) {
                     if (ipoib_cm_up(neigh)) {
                             ipoib_cm_send(dev, skb, ipoib_cm_get(neigh));
                             goto unref;
                     }
             }
      
      The race occurs if cm_rep_handler execution occurs after the above
      connection check (specifically if it gets to the point where it acquires
      priv->lock to dequeue pending skb's) but before the below code snippet in
      start_xmit where packets are queued.
      
             if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
                     push_pseudo_header(skb, phdr->hwaddr);
                     spin_lock_irqsave(&priv->lock, flags);
                     __skb_queue_tail(&neigh->queue, skb);
                     spin_unlock_irqrestore(&priv->lock, flags);
             } else {
                     ++dev->stats.tx_dropped;
                     dev_kfree_skb_any(skb);
             }
      
      The patch acquires the netif tx lock in cm_rep_handler for the section
      where it sets the connection up and dequeues and retransmits deferred
      skb's.
      
      Fixes: 839fcaba ("IPoIB: Connected mode experimental support")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAaron Knister <aaron.s.knister@nasa.gov>
      Tested-by: default avatarIra Weiny <ira.weiny@intel.com>
      Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee4d1a30
    • Juergen Gross's avatar
      xen/netfront: fix waiting for xenbus state change · a739cb3e
      Juergen Gross authored
      commit 8edfe2e9 upstream.
      
      Commit 822fb18a ("xen-netfront: wait xenbus state change when load
      module manually") added a new wait queue to wait on for a state change
      when the module is loaded manually. Unfortunately there is no wakeup
      anywhere to stop that waiting.
      
      Instead of introducing a new wait queue rename the existing
      module_unload_q to module_wq and use it for both purposes (loading and
      unloading).
      
      As any state change of the backend might be intended to stop waiting
      do the wake_up_all() in any case when netback_changed() is called.
      
      Fixes: 822fb18a ("xen-netfront: wait xenbus state change when load module manually")
      Cc: <stable@vger.kernel.org> #4.18
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a739cb3e
    • Bin Yang's avatar
      pstore: Fix incorrect persistent ram buffer mapping · 1cd01dba
      Bin Yang authored
      commit 831b624d upstream.
      
      persistent_ram_vmap() returns the page start vaddr.
      persistent_ram_iomap() supports non-page-aligned mapping.
      
      persistent_ram_buffer_map() always adds offset-in-page to the vaddr
      returned from these two functions, which causes incorrect mapping of
      non-page-aligned persistent ram buffer.
      
      By default ftrace_size is 4096 and max_ftrace_cnt is nr_cpu_ids. Without
      this patch, the zone_sz in ramoops_init_przs() is 4096/nr_cpu_ids which
      might not be page aligned. If the offset-in-page > 2048, the vaddr will be
      in next page. If the next page is not mapped, it will cause kernel panic:
      
      [    0.074231] BUG: unable to handle kernel paging request at ffffa19e0081b000
      ...
      [    0.075000] RIP: 0010:persistent_ram_new+0x1f8/0x39f
      ...
      [    0.075000] Call Trace:
      [    0.075000]  ramoops_init_przs.part.10.constprop.15+0x105/0x260
      [    0.075000]  ramoops_probe+0x232/0x3a0
      [    0.075000]  platform_drv_probe+0x3e/0xa0
      [    0.075000]  driver_probe_device+0x2cd/0x400
      [    0.075000]  __driver_attach+0xe4/0x110
      [    0.075000]  ? driver_probe_device+0x400/0x400
      [    0.075000]  bus_for_each_dev+0x70/0xa0
      [    0.075000]  driver_attach+0x1e/0x20
      [    0.075000]  bus_add_driver+0x159/0x230
      [    0.075000]  ? do_early_param+0x95/0x95
      [    0.075000]  driver_register+0x70/0xc0
      [    0.075000]  ? init_pstore_fs+0x4d/0x4d
      [    0.075000]  __platform_driver_register+0x36/0x40
      [    0.075000]  ramoops_init+0x12f/0x131
      [    0.075000]  do_one_initcall+0x4d/0x12c
      [    0.075000]  ? do_early_param+0x95/0x95
      [    0.075000]  kernel_init_freeable+0x19b/0x222
      [    0.075000]  ? rest_init+0xbb/0xbb
      [    0.075000]  kernel_init+0xe/0xfc
      [    0.075000]  ret_from_fork+0x3a/0x50
      Signed-off-by: default avatarBin Yang <bin.yang@intel.com>
      [kees: add comments describing the mapping differences, updated commit log]
      Fixes: 24c3d2f3 ("staging: android: persistent_ram: Make it possible to use memory outside of bootmem")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1cd01dba
    • Parav Pandit's avatar
      RDMA/cma: Protect cma dev list with lock · 07c63fd0
      Parav Pandit authored
      commit 954a8e3a upstream.
      
      When AF_IB addresses are used during rdma_resolve_addr() a lock is not
      held. A cma device can get removed while list traversal is in progress
      which may lead to crash. ie
      
              CPU0                                     CPU1
              ====                                     ====
      rdma_resolve_addr()
       cma_resolve_ib_dev()
        list_for_each()                         cma_remove_one()
          cur_dev->device                        mutex_lock(&lock)
                                                  list_del();
                                                 mutex_unlock(&lock);
                                                 cma_process_remove();
      
      
      Therefore, hold a lock while traversing the list which avoids such
      situation.
      
      Cc: <stable@vger.kernel.org> # 3.10
      Fixes: f17df3b0 ("RDMA/cma: Add support for AF_IB to rdma_resolve_addr()")
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      07c63fd0
    • Xiao Liang's avatar
      xen-netfront: fix warn message as irq device name has '/' · 12c3ba18
      Xiao Liang authored
      [ Upstream commit 21f2706b ]
      
      There is a call trace generated after commit 2d408c0d(
      xen-netfront: fix queue name setting). There is no 'device/vif/xx-q0-tx' file found
      under /proc/irq/xx/.
      
      This patch only picks up device type and id as its name.
      
      With the patch, now /proc/interrupts looks like below and the warning message gone:
       70:         21          0          0          0   xen-dyn    -event     vif0-q0-tx
       71:         15          0          0          0   xen-dyn    -event     vif0-q0-rx
       72:         14          0          0          0   xen-dyn    -event     vif0-q1-tx
       73:         33          0          0          0   xen-dyn    -event     vif0-q1-rx
       74:         12          0          0          0   xen-dyn    -event     vif0-q2-tx
       75:         24          0          0          0   xen-dyn    -event     vif0-q2-rx
       76:         19          0          0          0   xen-dyn    -event     vif0-q3-tx
       77:         21          0          0          0   xen-dyn    -event     vif0-q3-rx
      
      Below is call trace information without this patch:
      
      name 'device/vif/0-q0-tx'
      WARNING: CPU: 2 PID: 37 at fs/proc/generic.c:174 __xlate_proc_name+0x85/0xa0
      RIP: 0010:__xlate_proc_name+0x85/0xa0
      RSP: 0018:ffffb85c40473c18 EFLAGS: 00010286
      RAX: 0000000000000000 RBX: 0000000000000006 RCX: 0000000000000006
      RDX: 0000000000000007 RSI: 0000000000000096 RDI: ffff984c7f516930
      RBP: ffffb85c40473cb8 R08: 000000000000002c R09: 0000000000000229
      R10: 0000000000000000 R11: 0000000000000001 R12: ffffb85c40473c98
      R13: ffffb85c40473cb8 R14: ffffb85c40473c50 R15: 0000000000000000
      FS:  0000000000000000(0000) GS:ffff984c7f500000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f69b6899038 CR3: 000000001c20a006 CR4: 00000000001606e0
      Call Trace:
      __proc_create+0x45/0x230
      ? snprintf+0x49/0x60
      proc_mkdir_data+0x35/0x90
      register_handler_proc+0xef/0x110
      ? proc_register+0xfc/0x110
      ? proc_create_data+0x70/0xb0
      __setup_irq+0x39b/0x660
      ? request_threaded_irq+0xad/0x160
      request_threaded_irq+0xf5/0x160
      ? xennet_tx_buf_gc+0x1d0/0x1d0 [xen_netfront]
      bind_evtchn_to_irqhandler+0x3d/0x70
      ? xenbus_alloc_evtchn+0x41/0xa0
      netback_changed+0xa46/0xcda [xen_netfront]
      ? find_watch+0x40/0x40
      xenwatch_thread+0xc5/0x160
      ? finish_wait+0x80/0x80
      kthread+0x112/0x130
      ? kthread_create_worker_on_cpu+0x70/0x70
      ret_from_fork+0x35/0x40
      Code: 81 5c 00 48 85 c0 75 cc 5b 49 89 2e 31 c0 5d 4d 89 3c 24 41 5c 41 5d 41 5e 41 5f c3 4c 89 ee 48 c7 c7 40 4f 0e b4 e8 65 ea d8 ff <0f> 0b b8 fe ff ff ff 5b 5d 41 5c 41 5d 41 5e 41 5f c3 66 0f 1f
      ---[ end trace 650e5561b0caab3a ]---
      Signed-off-by: default avatarXiao Liang <xiliang@redhat.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      12c3ba18
    • Michael Müller's avatar
      crypto: sharah - Unregister correct algorithms for SAHARA 3 · 71501201
      Michael Müller authored
      [ Upstream commit 0e7d4d93 ]
      
      This patch fixes two typos related to unregistering algorithms supported by
      SAHARAH 3. In sahara_register_algs the wrong algorithms are unregistered
      in case of an error. In sahara_unregister_algs the wrong array is used to
      determine the iteration count.
      Signed-off-by: default avatarMichael Müller <michael@fds-team.de>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71501201
    • Randy Dunlap's avatar
      platform/x86: toshiba_acpi: Fix defined but not used build warnings · da189ebd
      Randy Dunlap authored
      [ Upstream commit c2e2a618 ]
      
      Fix a build warning in toshiba_acpi.c when CONFIG_PROC_FS is not enabled
      by marking the unused function as __maybe_unused.
      
      ../drivers/platform/x86/toshiba_acpi.c:1685:12: warning: 'version_proc_show' defined but not used [-Wunused-function]
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Azael Avalos <coproscefalo@gmail.com>
      Cc: platform-driver-x86@vger.kernel.org
      Cc: Andy Shevchenko <andy@infradead.org>
      Signed-off-by: default avatarDarren Hart (VMware) <dvhart@infradead.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      da189ebd
    • Julian Wiedmann's avatar
      s390/qeth: reset layer2 attribute on layer switch · a4b8132c
      Julian Wiedmann authored
      [ Upstream commit 70551dc4 ]
      
      After the subdriver's remove() routine has completed, the card's layer
      mode is undetermined again. Reflect this in the layer2 field.
      
      If qeth_dev_layer2_store() hits an error after remove() was called, the
      card _always_ requires a setup(), even if the previous layer mode is
      requested again.
      But qeth_dev_layer2_store() bails out early if the requested layer mode
      still matches the current one. So unless we reset the layer2 field,
      re-probing the card back to its previous mode is currently not possible.
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4b8132c
    • Julian Wiedmann's avatar
      s390/qeth: fix race in used-buffer accounting · 29162495
      Julian Wiedmann authored
      [ Upstream commit a702349a ]
      
      By updating q->used_buffers only _after_ do_QDIO() has completed, there
      is a potential race against the buffer's TX completion. In the unlikely
      case that the TX completion path wins, qeth_qdio_output_handler() would
      decrement the counter before qeth_flush_buffers() even incremented it.
      Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      29162495
    • Loic Poulain's avatar
      arm64: dts: qcom: db410c: Fix Bluetooth LED trigger · 4f3381ab
      Loic Poulain authored
      [ Upstream commit e53db018 ]
      
      Current LED trigger, 'bt', is not known/used by any existing driver.
      Fix this by renaming it to 'bluetooth-power' trigger which is
      controlled by the Bluetooth subsystem.
      
      Fixes: 9943230c ("arm64: dts: qcom: Add apq8016-sbc board LED's related device nodes")
      Signed-off-by: default avatarLoic Poulain <loic.poulain@linaro.org>
      Signed-off-by: default avatarAndy Gross <andy.gross@linaro.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4f3381ab
    • Vitaly Kuznetsov's avatar
      xen-netfront: fix queue name setting · 2e0c018c
      Vitaly Kuznetsov authored
      [ Upstream commit 2d408c0d ]
      
      Commit f599c64f ("xen-netfront: Fix race between device setup and
      open") changed the initialization order: xennet_create_queues() now
      happens before we do register_netdev() so using netdev->name in
      xennet_init_queue() is incorrect, we end up with the following in
      /proc/interrupts:
      
       60:        139          0   xen-dyn    -event     eth%d-q0-tx
       61:        265          0   xen-dyn    -event     eth%d-q0-rx
       62:        234          0   xen-dyn    -event     eth%d-q1-tx
       63:          1          0   xen-dyn    -event     eth%d-q1-rx
      
      and this looks ugly. Actually, using early netdev name (even when it's
      already set) is also not ideal: nowadays we tend to rename eth devices
      and queue name may end up not corresponding to the netdev name.
      
      Use nodename from xenbus device for queue naming: this can't change in VM's
      lifetime. Now /proc/interrupts looks like
      
       62:        202          0   xen-dyn    -event     device/vif/0-q0-tx
       63:        317          0   xen-dyn    -event     device/vif/0-q0-rx
       64:        262          0   xen-dyn    -event     device/vif/0-q1-tx
       65:         17          0   xen-dyn    -event     device/vif/0-q1-rx
      
      Fixes: f599c64f ("xen-netfront: Fix race between device setup and open")
      Signed-off-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Reviewed-by: default avatarRoss Lagerwall <ross.lagerwall@citrix.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e0c018c
    • Manikanta Pubbisetty's avatar
      mac80211: restrict delayed tailroom needed decrement · 77332078
      Manikanta Pubbisetty authored
      [ Upstream commit 133bf90d ]
      
      As explained in ieee80211_delayed_tailroom_dec(), during roam,
      keys of the old AP will be destroyed and new keys will be
      installed. Deletion of the old key causes
      crypto_tx_tailroom_needed_cnt to go from 1 to 0 and the new key
      installation causes a transition from 0 to 1.
      
      Whenever crypto_tx_tailroom_needed_cnt transitions from 0 to 1,
      we invoke synchronize_net(); the reason for doing this is to avoid
      a race in the TX path as explained in increment_tailroom_need_count().
      This synchronize_net() operation can be slow and can affect the station
      roam time. To avoid this, decrementing the crypto_tx_tailroom_needed_cnt
      is delayed for a while so that upon installation of new key the
      transition would be from 1 to 2 instead of 0 to 1 and thereby
      improving the roam time.
      
      This is all correct for a STA iftype, but deferring the tailroom_needed
      decrement for other iftypes may be unnecessary.
      
      For example, let's consider the case of a 4-addr client connecting to
      an AP for which AP_VLAN interface is also created, let the initial
      value for tailroom_needed on the AP be 1.
      
      * 4-addr client connects to the AP (AP: tailroom_needed = 1)
      * AP will clear old keys, delay decrement of tailroom_needed count
      * AP_VLAN is created, it takes the tailroom count from master
        (AP_VLAN: tailroom_needed = 1, AP: tailroom_needed = 1)
      * Install new key for the station, assume key is plumbed in the HW,
        there won't be any change in tailroom_needed count on AP iface
      * Delayed decrement of tailroom_needed count on AP
        (AP: tailroom_needed = 0, AP_VLAN: tailroom_needed = 1)
      
      Because of the delayed decrement on AP iface, tailroom_needed count goes
      out of sync between AP(master iface) and AP_VLAN(slave iface) and
      there would be unnecessary tailroom created for the packets going
      through AP_VLAN iface.
      
      Also, WARN_ONs were observed while trying to bring down the AP_VLAN
      interface:
      (warn_slowpath_common) (warn_slowpath_null+0x18/0x20)
      (warn_slowpath_null) (ieee80211_free_keys+0x114/0x1e4)
      (ieee80211_free_keys) (ieee80211_del_virtual_monitor+0x51c/0x850)
      (ieee80211_del_virtual_monitor) (ieee80211_stop+0x30/0x3c)
      (ieee80211_stop) (__dev_close_many+0x94/0xb8)
      (__dev_close_many) (dev_close_many+0x5c/0xc8)
      
      Restricting delayed decrement to station interface alone fixes the problem
      and it makes sense to do so because delayed decrement is done to improve
      roam time which is applicable only for client devices.
      Signed-off-by: default avatarManikanta Pubbisetty <mpubbise@codeaurora.org>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      77332078
    • Paul Cercueil's avatar
      MIPS: jz4740: Bump zload address · 2ca7b66d
      Paul Cercueil authored
      [ Upstream commit c6ea7e97 ]
      
      Having the zload address at 0x8060.0000 means the size of the
      uncompressed kernel cannot be bigger than around 6 MiB, as it is
      deflated at address 0x8001.0000.
      
      This limit is too small; a kernel with some built-in drivers and things
      like debugfs enabled will already be over 6 MiB in size, and so will
      fail to extract properly.
      
      To fix this, we bump the zload address from 0x8060.0000 to 0x8100.0000.
      
      This is fine, as all the boards featuring Ingenic JZ SoCs have at least
      32 MiB of RAM, and use u-boot or compatible bootloaders which won't
      hardcode the load address but read it from the uImage's header.
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/19787/
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2ca7b66d
    • Nicholas Piggin's avatar
      powerpc/powernv: opal_put_chars partial write fix · 8e8c3ba5
      Nicholas Piggin authored
      [ Upstream commit bd90284c ]
      
      The intention here is to consume and discard the remaining buffer
      upon error. This works if there has not been a previous partial write.
      If there has been, then total_len is no longer total number of bytes
      to copy. total_len is always "bytes left to copy", so it should be
      added to written bytes.
      
      This code may not be exercised any more if partial writes will not be
      hit, but this is a small bugfix before a larger change.
      Reviewed-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e8c3ba5
    • Sandipan Das's avatar
      perf powerpc: Fix callchain ip filtering · d4aa4e4f
      Sandipan Das authored
      [ Upstream commit c715fcfd ]
      
      For powerpc64, redundant entries in the callchain are filtered out by
      determining the state of the return address and the stack frame using
      DWARF debug information.
      
      For making these filtering decisions we must analyze the debug
      information for the location corresponding to the program counter value,
      i.e. the first entry in the callchain, and not the LR value; otherwise,
      perf may filter out either the second or the third entry in the
      callchain incorrectly.
      
      This can be observed on a powerpc64le system running Fedora 27 as shown
      below.
      
      Case 1 - Attaching a probe at inet_pton+0x8 (binary offset 0x15af28).
               Return address is still in LR and a new stack frame is not yet
               allocated. The LR value, i.e. the second entry, should not be
      	 filtered out.
      
        # objdump -d /usr/lib64/libc-2.26.so | less
        ...
        000000000010eb10 <gaih_inet.constprop.7>:
        ...
          10fa48:       78 bb e4 7e     mr      r4,r23
          10fa4c:       0a 00 60 38     li      r3,10
          10fa50:       d9 b4 04 48     bl      15af28 <inet_pton+0x8>
          10fa54:       00 00 00 60     nop
          10fa58:       ac f4 ff 4b     b       10ef04 <gaih_inet.constprop.7+0x3f4>
        ...
        0000000000110450 <getaddrinfo>:
        ...
          1105a8:       54 00 ff 38     addi    r7,r31,84
          1105ac:       58 00 df 38     addi    r6,r31,88
          1105b0:       69 e5 ff 4b     bl      10eb18 <gaih_inet.constprop.7+0x8>
          1105b4:       78 1b 71 7c     mr      r17,r3
          1105b8:       50 01 7f e8     ld      r3,336(r31)
        ...
        000000000015af20 <inet_pton>:
          15af20:       0b 00 4c 3c     addis   r2,r12,11
          15af24:       e0 c1 42 38     addi    r2,r2,-15904
          15af28:       a6 02 08 7c     mflr    r0
          15af2c:       f0 ff c1 fb     std     r30,-16(r1)
          15af30:       f8 ff e1 fb     std     r31,-8(r1)
        ...
      
        # perf probe -x /usr/lib64/libc-2.26.so -a inet_pton+0x8
        # perf record -e probe_libc:inet_pton -g ping -6 -c 1 ::1
        # perf script
      
      Before:
      
        ping  4507 [002] 514985.546540: probe_libc:inet_pton: (7fffa7dbaf28)
                    7fffa7dbaf28 __GI___inet_pton+0x8 (/usr/lib64/libc-2.26.so)
                    7fffa7d705b4 getaddrinfo+0x164 (/usr/lib64/libc-2.26.so)
                       13fb52d70 _init+0xbfc (/usr/bin/ping)
                    7fffa7c836a0 generic_start_main.isra.0+0x140 (/usr/lib64/libc-2.26.so)
                    7fffa7c83898 __libc_start_main+0xb8 (/usr/lib64/libc-2.26.so)
                               0 [unknown] ([unknown])
      
      After:
      
        ping  4507 [002] 514985.546540: probe_libc:inet_pton: (7fffa7dbaf28)
                    7fffa7dbaf28 __GI___inet_pton+0x8 (/usr/lib64/libc-2.26.so)
                    7fffa7d6fa54 gaih_inet.constprop.7+0xf44 (/usr/lib64/libc-2.26.so)
                    7fffa7d705b4 getaddrinfo+0x164 (/usr/lib64/libc-2.26.so)
                       13fb52d70 _init+0xbfc (/usr/bin/ping)
                    7fffa7c836a0 generic_start_main.isra.0+0x140 (/usr/lib64/libc-2.26.so)
                    7fffa7c83898 __libc_start_main+0xb8 (/usr/lib64/libc-2.26.so)
                               0 [unknown] ([unknown])
      
      Case 2 - Attaching a probe at _int_malloc+0x180 (binary offset 0x9cf10).
               Return address in still in LR and a new stack frame has already
               been allocated but not used. The caller's caller, i.e. the third
      	 entry, is invalid and should be filtered out and not the second
      	 one.
      
        # objdump -d /usr/lib64/libc-2.26.so | less
        ...
        000000000009cd90 <_int_malloc>:
           9cd90:       17 00 4c 3c     addis   r2,r12,23
           9cd94:       70 a3 42 38     addi    r2,r2,-23696
           9cd98:       26 00 80 7d     mfcr    r12
           9cd9c:       f8 ff e1 fb     std     r31,-8(r1)
           9cda0:       17 00 e4 3b     addi    r31,r4,23
           9cda4:       d8 ff 61 fb     std     r27,-40(r1)
           9cda8:       78 23 9b 7c     mr      r27,r4
           9cdac:       1f 00 bf 2b     cmpldi  cr7,r31,31
           9cdb0:       f0 ff c1 fb     std     r30,-16(r1)
           9cdb4:       b0 ff c1 fa     std     r22,-80(r1)
           9cdb8:       78 1b 7e 7c     mr      r30,r3
           9cdbc:       08 00 81 91     stw     r12,8(r1)
           9cdc0:       11 ff 21 f8     stdu    r1,-240(r1)
           9cdc4:       4c 01 9d 41     bgt     cr7,9cf10 <_int_malloc+0x180>
           9cdc8:       20 00 a4 2b     cmpldi  cr7,r4,32
        ...
           9cf08:       00 00 00 60     nop
           9cf0c:       00 00 42 60     ori     r2,r2,0
           9cf10:       e4 06 ff 7b     rldicr  r31,r31,0,59
           9cf14:       40 f8 a4 7f     cmpld   cr7,r4,r31
           9cf18:       68 05 9d 41     bgt     cr7,9d480 <_int_malloc+0x6f0>
        ...
        000000000009e3c0 <tcache_init.part.4>:
        ...
           9e420:       40 02 80 38     li      r4,576
           9e424:       78 fb e3 7f     mr      r3,r31
           9e428:       71 e9 ff 4b     bl      9cd98 <_int_malloc+0x8>
           9e42c:       00 00 a3 2f     cmpdi   cr7,r3,0
           9e430:       78 1b 7e 7c     mr      r30,r3
        ...
        000000000009f7a0 <__libc_malloc>:
        ...
           9f8f8:       00 00 89 2f     cmpwi   cr7,r9,0
           9f8fc:       1c ff 9e 40     bne     cr7,9f818 <__libc_malloc+0x78>
           9f900:       c9 ea ff 4b     bl      9e3c8 <tcache_init.part.4+0x8>
           9f904:       00 00 00 60     nop
           9f908:       e8 90 22 e9     ld      r9,-28440(r2)
        ...
      
        # perf probe -x /usr/lib64/libc-2.26.so -a _int_malloc+0x180
        # perf record -e probe_libc:_int_malloc -g ./test-malloc
        # perf script
      
      Before:
      
        test-malloc  6554 [009] 515975.797403: probe_libc:_int_malloc: (7fffa6e6cf10)
                    7fffa6e6cf10 _int_malloc+0x180 (/usr/lib64/libc-2.26.so)
                    7fffa6dd0000 [unknown] (/usr/lib64/libc-2.26.so)
                    7fffa6e6f904 malloc+0x164 (/usr/lib64/libc-2.26.so)
                    7fffa6e6f9fc malloc+0x25c (/usr/lib64/libc-2.26.so)
                        100006b4 main+0x38 (/home/testuser/test-malloc)
                    7fffa6df36a0 generic_start_main.isra.0+0x140 (/usr/lib64/libc-2.26.so)
                    7fffa6df3898 __libc_start_main+0xb8 (/usr/lib64/libc-2.26.so)
                               0 [unknown] ([unknown])
      
      After:
      
        test-malloc  6554 [009] 515975.797403: probe_libc:_int_malloc: (7fffa6e6cf10)
                    7fffa6e6cf10 _int_malloc+0x180 (/usr/lib64/libc-2.26.so)
                    7fffa6e6e42c tcache_init.part.4+0x6c (/usr/lib64/libc-2.26.so)
                    7fffa6e6f904 malloc+0x164 (/usr/lib64/libc-2.26.so)
                    7fffa6e6f9fc malloc+0x25c (/usr/lib64/libc-2.26.so)
                        100006b4 main+0x38 (/home/sandipan/test-malloc)
                    7fffa6df36a0 generic_start_main.isra.0+0x140 (/usr/lib64/libc-2.26.so)
                    7fffa6df3898 __libc_start_main+0xb8 (/usr/lib64/libc-2.26.so)
                               0 [unknown] ([unknown])
      Signed-off-by: default avatarSandipan Das <sandipan@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Maynard Johnson <maynard@us.ibm.com>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Fixes: a60335ba ("perf tools powerpc: Adjust callchain based on DWARF debug info")
      Link: http://lkml.kernel.org/r/24bb726d91ed173aebc972ec3f41a2ef2249434e.1530724939.git.sandipan@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d4aa4e4f
    • Krzysztof Kozlowski's avatar
      ARM: exynos: Clear global variable on init error path · 016353ef
      Krzysztof Kozlowski authored
      [ Upstream commit cd480691 ]
      
      For most of Exynos SoCs, Power Management Unit (PMU) address space is
      mapped into global variable 'pmu_base_addr' very early when initializing
      PMU interrupt controller.  A lot of other machine code depends on it so
      when doing iounmap() on this address, clear the global as well to avoid
      usage of invalid value (pointing to unmapped memory region).
      
      Properly mapped PMU address space is a requirement for all other machine
      code so this fix is purely theoretical.  Boot will fail immediately in
      many other places after following this error path.
      Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      016353ef
    • Fredrik Noring's avatar
      fbdev: Distinguish between interlaced and progressive modes · 57a1dd74
      Fredrik Noring authored
      [ Upstream commit 1ba0a59c ]
      
      I discovered the problem when developing a frame buffer driver for the
      PlayStation 2 (not yet merged), using the following video modes for the
      PlayStation 3 in drivers/video/fbdev/ps3fb.c:
      
          }, {
              /* 1080if */
              "1080if", 50, 1920, 1080, 13468, 148, 484, 36, 4, 88, 5,
              FB_SYNC_BROADCAST, FB_VMODE_INTERLACED
          }, {
              /* 1080pf */
              "1080pf", 50, 1920, 1080, 6734, 148, 484, 36, 4, 88, 5,
              FB_SYNC_BROADCAST, FB_VMODE_NONINTERLACED
          },
      
      In ps3fb_probe, the mode_option module parameter is used with fb_find_mode
      but it can only select the interlaced variant of 1920x1080 since the loop
      matching the modes does not take the difference between interlaced and
      progressive modes into account.
      
      In short, without the patch, progressive 1920x1080 cannot be chosen as a
      mode_option parameter since fb_find_mode (falsely) thinks interlace is a
      perfect match.
      Signed-off-by: default avatarFredrik Noring <noring@nocrew.org>
      Cc: "Maciej W. Rozycki" <macro@linux-mips.org>
      [b.zolnierkie: updated patch description]
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      57a1dd74
    • Sandipan Das's avatar
      perf powerpc: Fix callchain ip filtering when return address is in a register · e71975f0
      Sandipan Das authored
      [ Upstream commit 9068533e ]
      
      For powerpc64, perf will filter out the second entry in the callchain,
      i.e. the LR value, if the return address of the function corresponding
      to the probed location has already been saved on its caller's stack.
      
      The state of the return address is determined using debug information.
      At any point within a function, if the return address is already saved
      somewhere, a DWARF expression can tell us about its location. If the
      return address in still in LR only, no DWARF expression would exist.
      
      Typically, the instructions in a function's prologue first copy the LR
      value to R0 and then pushes R0 on to the stack. If LR has already been
      copied to R0 but R0 is yet to be pushed to the stack, we can still get a
      DWARF expression that says that the return address is in R0. This is
      indicating that getting a DWARF expression for the return address does
      not guarantee the fact that it has already been saved on the stack.
      
      This can be observed on a powerpc64le system running Fedora 27 as shown
      below.
      
        # objdump -d /usr/lib64/libc-2.26.so | less
        ...
        000000000015af20 <inet_pton>:
          15af20:       0b 00 4c 3c     addis   r2,r12,11
          15af24:       e0 c1 42 38     addi    r2,r2,-15904
          15af28:       a6 02 08 7c     mflr    r0
          15af2c:       f0 ff c1 fb     std     r30,-16(r1)
          15af30:       f8 ff e1 fb     std     r31,-8(r1)
          15af34:       78 1b 7f 7c     mr      r31,r3
          15af38:       78 23 83 7c     mr      r3,r4
          15af3c:       78 2b be 7c     mr      r30,r5
          15af40:       10 00 01 f8     std     r0,16(r1)
          15af44:       c1 ff 21 f8     stdu    r1,-64(r1)
          15af48:       28 00 81 f8     std     r4,40(r1)
        ...
      
        # readelf --debug-dump=frames-interp /usr/lib64/libc-2.26.so | less
        ...
        00027024 0000000000000024 00027028 FDE cie=00000000 pc=000000000015af20..000000000015af88
           LOC           CFA      r30   r31   ra
        000000000015af20 r1+0     u     u     u
        000000000015af34 r1+0     c-16  c-8   r0
        000000000015af48 r1+64    c-16  c-8   c+16
        000000000015af5c r1+0     c-16  c-8   c+16
        000000000015af78 r1+0     u     u
        ...
      
        # perf probe -x /usr/lib64/libc-2.26.so -a inet_pton+0x18
        # perf record -e probe_libc:inet_pton -g ping -6 -c 1 ::1
        # perf script
      
      Before:
      
        ping  2829 [005] 512917.460174: probe_libc:inet_pton: (7fff7e2baf38)
                    7fff7e2baf38 __GI___inet_pton+0x18 (/usr/lib64/libc-2.26.so)
                    7fff7e2705b4 getaddrinfo+0x164 (/usr/lib64/libc-2.26.so)
                       12f152d70 _init+0xbfc (/usr/bin/ping)
                    7fff7e1836a0 generic_start_main.isra.0+0x140 (/usr/lib64/libc-2.26.so)
                    7fff7e183898 __libc_start_main+0xb8 (/usr/lib64/libc-2.26.so)
                               0 [unknown] ([unknown])
      
      After:
      
        ping  2829 [005] 512917.460174: probe_libc:inet_pton: (7fff7e2baf38)
                    7fff7e2baf38 __GI___inet_pton+0x18 (/usr/lib64/libc-2.26.so)
                    7fff7e26fa54 gaih_inet.constprop.7+0xf44 (/usr/lib64/libc-2.26.so)
                    7fff7e2705b4 getaddrinfo+0x164 (/usr/lib64/libc-2.26.so)
                       12f152d70 _init+0xbfc (/usr/bin/ping)
                    7fff7e1836a0 generic_start_main.isra.0+0x140 (/usr/lib64/libc-2.26.so)
                    7fff7e183898 __libc_start_main+0xb8 (/usr/lib64/libc-2.26.so)
                               0 [unknown] ([unknown])
      Reported-by: default avatarRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Signed-off-by: default avatarSandipan Das <sandipan@linux.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Maynard Johnson <maynard@us.ibm.com>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Link: http://lkml.kernel.org/r/66e848a7bdf2d43b39210a705ff6d828a0865661.1530724939.git.sandipan@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e71975f0
    • Randy Dunlap's avatar
      fbdev/via: fix defined but not used warning · 5a85c8d6
      Randy Dunlap authored
      [ Upstream commit b6566b47 ]
      
      Fix a build warning in viafbdev.c when CONFIG_PROC_FS is not enabled
      by marking the unused function as __maybe_unused.
      
      ../drivers/video/fbdev/via/viafbdev.c:1471:12: warning: 'viafb_sup_odev_proc_show' defined but not used [-Wunused-function]
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5a85c8d6
    • Anton Vasilyev's avatar
      video: goldfishfb: fix memory leak on driver remove · 1401b76d
      Anton Vasilyev authored
      [ Upstream commit 5958fde7 ]
      
      goldfish_fb_probe() allocates memory for fb, but goldfish_fb_remove() does
      not have deallocation of fb, which leads to memory leak on probe/remove.
      
      The patch adds deallocation into goldfish_fb_remove().
      
      Found by Linux Driver Verification project (linuxtesting.org).
      Signed-off-by: default avatarAnton Vasilyev <vasilyev@ispras.ru>
      Cc: Aleksandar Markovic <aleksandar.markovic@mips.com>
      Cc: Miodrag Dinic <miodrag.dinic@mips.com>
      Cc: Goran Ferenc <goran.ferenc@mips.com>
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1401b76d
    • Dan Carpenter's avatar
      fbdev: omapfb: off by one in omapfb_register_client() · 98c05956
      Dan Carpenter authored
      [ Upstream commit 5ec1ec35 ]
      
      The omapfb_register_client[] array has OMAPFB_PLANE_NUM elements so the
      > should be >= or we are one element beyond the end of the array.
      
      Fixes: 8b08cf2b ("OMAP: add TI OMAP framebuffer driver")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Cc: Imre Deak <imre.deak@solidboot.com>
      Signed-off-by: default avatarBartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      98c05956
    • Randy Dunlap's avatar
      mtd/maps: fix solutionengine.c printk format warnings · 66e32b78
      Randy Dunlap authored
      [ Upstream commit 1d25e3ee ]
      
      Fix 2 printk format warnings (this driver is currently only used by
      arch/sh/) by using "%pap" instead of "%lx".
      
      Fixes these build warnings:
      
      ../drivers/mtd/maps/solutionengine.c: In function 'init_soleng_maps':
      ../include/linux/kern_levels.h:5:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'resource_size_t' {aka 'unsigned int'} [-Wformat=]
      ../drivers/mtd/maps/solutionengine.c:62:54: note: format string is defined here
        printk(KERN_NOTICE "Solution Engine: Flash at 0x%08lx, EPROM at 0x%08lx\n",
                                                        ~~~~^
                                                        %08x
      ../include/linux/kern_levels.h:5:18: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'resource_size_t' {aka 'unsigned int'} [-Wformat=]
      ../drivers/mtd/maps/solutionengine.c:62:72: note: format string is defined here
        printk(KERN_NOTICE "Solution Engine: Flash at 0x%08lx, EPROM at 0x%08lx\n",
                                                                          ~~~~^
                                                                          %08x
      
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Brian Norris <computersforpeace@gmail.com>
      Cc: Boris Brezillon <boris.brezillon@bootlin.com>
      Cc: Marek Vasut <marek.vasut@gmail.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: linux-mtd@lists.infradead.org
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: linux-sh@vger.kernel.org
      Cc: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      66e32b78
    • Hans Verkuil's avatar
      media: videobuf2-core: check for q->error in vb2_core_qbuf() · 0eda7472
      Hans Verkuil authored
      [ Upstream commit b509d733 ]
      
      The vb2_core_qbuf() function didn't check if q->error was set. It is
      checked in __buf_prepare(), but that function isn't called if the buffer
      was already prepared before with VIDIOC_PREPARE_BUF.
      
      So check it at the start of vb2_core_qbuf() as well.
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0eda7472
    • Felix Fietkau's avatar
      MIPS: ath79: fix system restart · 9f6d6fb5
      Felix Fietkau authored
      [ Upstream commit f8a7bfe1 ]
      
      This patch disables irq on reboot to fix hang issues that were observed
      due to pending interrupts.
      Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
      Signed-off-by: default avatarJohn Crispin <john@phrozen.org>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Patchwork: https://patchwork.linux-mips.org/patch/19913/
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-mips@linux-mips.org
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9f6d6fb5
    • John Keeping's avatar
      dmaengine: pl330: fix irq race with terminate_all · 46c66ac9
      John Keeping authored
      [ Upstream commit e4975654 ]
      
      In pl330_update() when checking if a channel has been aborted, the
      channel's lock is not taken, only the overall pl330_dmac lock.  But in
      pl330_terminate_all() the aborted flag (req_running==-1) is set under
      the channel lock and not the pl330_dmac lock.
      
      With threaded interrupts, this leads to a potential race:
      
          pl330_terminate_all	        pl330_update
          -------------------         ------------
          lock channel
                                      entry
          lock pl330
          _stop channel
          unlock pl330
                                      lock pl330
                                      check req_running != -1
          req_running = -1
                                      _start channel
      Signed-off-by: default avatarJohn Keeping <john@metanate.com>
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      46c66ac9
    • Masahiro Yamada's avatar
      kbuild: add .DELETE_ON_ERROR special target · d6ac46c7
      Masahiro Yamada authored
      [ Upstream commit 9c2af1c7 ]
      
      If Make gets a fatal signal while a shell is executing, it may delete
      the target file that the recipe was supposed to update.  This is needed
      to make sure that it is remade from scratch when Make is next run; if
      Make is interrupted after the recipe has begun to write the target file,
      it results in an incomplete file whose time stamp is newer than that
      of the prerequisites files.  Make automatically deletes the incomplete
      file on interrupt unless the target is marked .PRECIOUS.
      
      The situation is just the same as when the shell fails for some reasons.
      Usually when a recipe line fails, if it has changed the target file at
      all, the file is corrupted, or at least it is not completely updated.
      Yet the file’s time stamp says that it is now up to date, so the next
      time Make runs, it will not try to update that file.
      
      However, Make does not cater to delete the incomplete target file in
      this case.  We need to add .DELETE_ON_ERROR somewhere in the Makefile
      to request it.
      
      scripts/Kbuild.include seems a suitable place to add it because it is
      included from almost all sub-makes.
      
      Please note .DELETE_ON_ERROR is not effective for phony targets.
      
      The external module building should never ever touch the kernel tree.
      The following recipe fails if include/generated/autoconf.h is missing.
      However, include/config/auto.conf is not deleted since it is a phony
      target.
      
       PHONY += include/config/auto.conf
      
       include/config/auto.conf:
               $(Q)test -e include/generated/autoconf.h -a -e $@ || (          \
               echo >&2;                                                       \
               echo >&2 "  ERROR: Kernel configuration is invalid.";           \
               echo >&2 "         include/generated/autoconf.h or $@ are missing.";\
               echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it."; \
               echo >&2 ;                                                      \
               /bin/false)
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d6ac46c7
    • Nicholas Mc Guire's avatar
      clk: imx6ul: fix missing of_node_put() · 210006ef
      Nicholas Mc Guire authored
      [ Upstream commit 11177e7a ]
      
      of_find_compatible_node() is returning a device node with refcount
      incremented and must be explicitly decremented after the last use
      which is right after the us in of_iomap() here.
      Signed-off-by: default avatarNicholas Mc Guire <hofrat@osadl.org>
      Fixes: 787b4271 ("clk: imx: add imx6ul clk tree support")
      Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      210006ef
    • Andreas Gruenbacher's avatar
      gfs2: Special-case rindex for gfs2_grow · 9e8d585c
      Andreas Gruenbacher authored
      [ Upstream commit 77612578 ]
      
      To speed up the common case of appending to a file,
      gfs2_write_alloc_required presumes that writing beyond the end of a file
      will always require additional blocks to be allocated.  This assumption
      is incorrect for preallocates files, but there are no negative
      consequences as long as *some* space is still left on the filesystem.
      
      One special file that always has some space preallocated beyond the end
      of the file is the rindex: when growing a filesystem, gfs2_grow adds one
      or more new resource groups and appends records describing those
      resource groups to the rindex; the preallocated space ensures that this
      is always possible.
      
      However, when a filesystem is completely full, gfs2_write_alloc_required
      will indicate that an additional allocation is required, and appending
      the next record to the rindex will fail even though space for that
      record has already been preallocated.  To fix that, skip the incorrect
      optimization in gfs2_write_alloc_required, but for the rindex only.
      Other writes to preallocated space beyond the end of the file are still
      allowed to fail on completely full filesystems.
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Reviewed-by: default avatarBob Peterson <rpeterso@redhat.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9e8d585c