1. 05 Sep, 2018 40 commits
    • Kiran Kumar Modukuri's avatar
      cachefiles: Fix refcounting bug in backing-file read monitoring · 4029dd9f
      Kiran Kumar Modukuri authored
      [ Upstream commit 934140ab ]
      
      cachefiles_read_waiter() has the right to access a 'monitor' object by
      virtue of being called under the waitqueue lock for one of the pages in its
      purview.  However, it has no ref on that monitor object or on the
      associated operation.
      
      What it is allowed to do is to move the monitor object to the operation's
      to_do list, but once it drops the work_lock, it's actually no longer
      permitted to access that object.  However, it is trying to enqueue the
      retrieval operation for processing - but it can only do this via a pointer
      in the monitor object, something it shouldn't be doing.
      
      If it doesn't enqueue the operation, the operation may not get processed.
      If the order is flipped so that the enqueue is first, then it's possible
      for the work processor to look at the to_do list before the monitor is
      enqueued upon it.
      
      Fix this by getting a ref on the operation so that we can trust that it
      will still be there once we've added the monitor to the to_do list and
      dropped the work_lock.  The op can then be enqueued after the lock is
      dropped.
      
      The bug can manifest in one of a couple of ways.  The first manifestation
      looks like:
      
       FS-Cache:
       FS-Cache: Assertion failed
       FS-Cache: 6 == 5 is false
       ------------[ cut here ]------------
       kernel BUG at fs/fscache/operation.c:494!
       RIP: 0010:fscache_put_operation+0x1e3/0x1f0
       ...
       fscache_op_work_func+0x26/0x50
       process_one_work+0x131/0x290
       worker_thread+0x45/0x360
       kthread+0xf8/0x130
       ? create_worker+0x190/0x190
       ? kthread_cancel_work_sync+0x10/0x10
       ret_from_fork+0x1f/0x30
      
      This is due to the operation being in the DEAD state (6) rather than
      INITIALISED, COMPLETE or CANCELLED (5) because it's already passed through
      fscache_put_operation().
      
      The bug can also manifest like the following:
      
       kernel BUG at fs/fscache/operation.c:69!
       ...
          [exception RIP: fscache_enqueue_operation+246]
       ...
       #7 [ffff883fff083c10] fscache_enqueue_operation at ffffffffa0b793c6
       #8 [ffff883fff083c28] cachefiles_read_waiter at ffffffffa0b15a48
       #9 [ffff883fff083c48] __wake_up_common at ffffffff810af028
      
      I'm not entirely certain as to which is line 69 in Lei's kernel, so I'm not
      entirely clear which assertion failed.
      
      Fixes: 9ae326a6 ("CacheFiles: A cache that backs onto a mounted filesystem")
      Reported-by: default avatarLei Xue <carmark.dlut@gmail.com>
      Reported-by: default avatarVegard Nossum <vegard.nossum@gmail.com>
      Reported-by: default avatarAnthony DeRobertis <aderobertis@metrics.net>
      Reported-by: default avatarNeilBrown <neilb@suse.com>
      Reported-by: default avatarDaniel Axtens <dja@axtens.net>
      Reported-by: default avatarKiran Kumar Modukuri <kiran.modukuri@gmail.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarDaniel Axtens <dja@axtens.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4029dd9f
    • Kiran Kumar Modukuri's avatar
      fscache: Allow cancelled operations to be enqueued · 819b476c
      Kiran Kumar Modukuri authored
      [ Upstream commit d0eb06af ]
      
      Alter the state-check assertion in fscache_enqueue_operation() to allow
      cancelled operations to be given processing time so they can be cleaned up.
      
      Also fix a debugging statement that was requiring such operations to have
      an object assigned.
      
      Fixes: 9ae326a6 ("CacheFiles: A cache that backs onto a mounted filesystem")
      Reported-by: default avatarKiran Kumar Modukuri <kiran.modukuri@gmail.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      819b476c
    • Kees Cook's avatar
      x86/boot: Fix if_changed build flip/flop bug · 165335d4
      Kees Cook authored
      [ Upstream commit 92a47286 ]
      
      Dirk Gouders reported that two consecutive "make" invocations on an
      already compiled tree will show alternating behaviors:
      
      $ make
        CALL    scripts/checksyscalls.sh
        DESCEND  objtool
        CHK     include/generated/compile.h
        DATAREL arch/x86/boot/compressed/vmlinux
      Kernel: arch/x86/boot/bzImage is ready  (#48)
        Building modules, stage 2.
        MODPOST 165 modules
      
      $ make
        CALL    scripts/checksyscalls.sh
        DESCEND  objtool
        CHK     include/generated/compile.h
        LD      arch/x86/boot/compressed/vmlinux
        ZOFFSET arch/x86/boot/zoffset.h
        AS      arch/x86/boot/header.o
        LD      arch/x86/boot/setup.elf
        OBJCOPY arch/x86/boot/setup.bin
        OBJCOPY arch/x86/boot/vmlinux.bin
        BUILD   arch/x86/boot/bzImage
      Setup is 15644 bytes (padded to 15872 bytes).
      System is 6663 kB
      CRC 3eb90f40
      Kernel: arch/x86/boot/bzImage is ready  (#48)
        Building modules, stage 2.
        MODPOST 165 modules
      
      He bisected it back to:
      
          commit 98f78525 ("x86/boot: Refuse to build with data relocations")
      
      The root cause was the use of the "if_changed" kbuild function multiple
      times for the same target. It was designed to only be used once per
      target, otherwise it will effectively always trigger, flipping back and
      forth between the two commands getting recorded by "if_changed". Instead,
      this patch merges the two commands into a single function to get stable
      build artifacts (i.e. .vmlinux.cmd), and a single build behavior.
      Bisected-and-Reported-by: default avatarDirk Gouders <dirk@gouders.net>
      Fix-Suggested-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reviewed-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Link: http://lkml.kernel.org/r/20180724230827.GA37823@beastSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      165335d4
    • Hailong Liu's avatar
      sched/rt: Restore rt_runtime after disabling RT_RUNTIME_SHARE · d35aab9d
      Hailong Liu authored
      [ Upstream commit f3d133ee ]
      
      NO_RT_RUNTIME_SHARE feature is used to prevent a CPU borrow enough
      runtime with a spin-rt-task.
      
      However, if RT_RUNTIME_SHARE feature is enabled and rt_rq has borrowd
      enough rt_runtime at the beginning, rt_runtime can't be restored to
      its initial bandwidth rt_runtime after we disable RT_RUNTIME_SHARE.
      
      E.g. on my PC with 4 cores, procedure to reproduce:
      1) Make sure  RT_RUNTIME_SHARE is enabled
       cat /sys/kernel/debug/sched_features
        GENTLE_FAIR_SLEEPERS START_DEBIT NO_NEXT_BUDDY LAST_BUDDY
        CACHE_HOT_BUDDY WAKEUP_PREEMPTION NO_HRTICK NO_DOUBLE_TICK
        LB_BIAS NONTASK_CAPACITY TTWU_QUEUE NO_SIS_AVG_CPU SIS_PROP
        NO_WARN_DOUBLE_CLOCK RT_PUSH_IPI RT_RUNTIME_SHARE NO_LB_MIN
        ATTACH_AGE_LOAD WA_IDLE WA_WEIGHT WA_BIAS
      2) Start a spin-rt-task
       ./loop_rr &
      3) set affinity to the last cpu
       taskset -p 8 $pid_of_loop_rr
      4) Observe that last cpu have borrowed enough runtime.
       cat /proc/sched_debug | grep rt_runtime
        .rt_runtime                    : 950.000000
        .rt_runtime                    : 900.000000
        .rt_runtime                    : 950.000000
        .rt_runtime                    : 1000.000000
      5) Disable RT_RUNTIME_SHARE
       echo NO_RT_RUNTIME_SHARE > /sys/kernel/debug/sched_features
      6) Observe that rt_runtime can not been restored
       cat /proc/sched_debug | grep rt_runtime
        .rt_runtime                    : 950.000000
        .rt_runtime                    : 900.000000
        .rt_runtime                    : 950.000000
        .rt_runtime                    : 1000.000000
      
      This patch help to restore rt_runtime after we disable
      RT_RUNTIME_SHARE.
      Signed-off-by: default avatarHailong Liu <liu.hailong6@zte.com.cn>
      Signed-off-by: default avatarJiang Biao <jiang.biao2@zte.com.cn>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: zhong.weidong@zte.com.cn
      Link: http://lkml.kernel.org/r/1531874815-39357-1-git-send-email-liu.hailong6@zte.com.cnSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d35aab9d
    • Peter Rosin's avatar
      i2c/mux, locking/core: Annotate the nested rt_mutex usage · 0ba83f87
      Peter Rosin authored
      [ Upstream commit 7b94ea50 ]
      
      If an i2c topology has instances of nested muxes, then a lockdep splat
      is produced when when i2c_parent_lock_bus() is called.  Here is an
      example:
      
        ============================================
        WARNING: possible recursive locking detected
        --------------------------------------------
        insmod/68159 is trying to acquire lock:
          (i2c_register_adapter#2){+.+.}, at: i2c_parent_lock_bus+0x32/0x50 [i2c_mux]
      
        but task is already holding lock:
          (i2c_register_adapter#2){+.+.}, at: i2c_parent_lock_bus+0x32/0x50 [i2c_mux]
      
        other info that might help us debug this:
          Possible unsafe locking scenario:
      
                CPU0
                ----
           lock(i2c_register_adapter#2);
           lock(i2c_register_adapter#2);
      
          *** DEADLOCK ***
      
          May be due to missing lock nesting notation
      
        1 lock held by insmod/68159:
          #0:  (i2c_register_adapter#2){+.+.}, at: i2c_parent_lock_bus+0x32/0x50 [i2c_mux]
      
        stack backtrace:
        CPU: 13 PID: 68159 Comm: insmod Tainted: G           O
        Call Trace:
          dump_stack+0x67/0x98
          __lock_acquire+0x162e/0x1780
          lock_acquire+0xba/0x200
          rt_mutex_lock+0x44/0x60
          i2c_parent_lock_bus+0x32/0x50 [i2c_mux]
          i2c_parent_lock_bus+0x3e/0x50 [i2c_mux]
          i2c_smbus_xfer+0xf0/0x700
          i2c_smbus_read_byte+0x42/0x70
          my2c_init+0xa2/0x1000 [my2c]
          do_one_initcall+0x51/0x192
          do_init_module+0x62/0x216
          load_module+0x20f9/0x2b50
          SYSC_init_module+0x19a/0x1c0
          SyS_init_module+0xe/0x10
          do_syscall_64+0x6c/0x1a0
          entry_SYSCALL_64_after_hwframe+0x42/0xb7
      Reported-by: default avatarJohn Sperbeck <jsperbeck@google.com>
      Tested-by: default avatarJohn Sperbeck <jsperbeck@google.com>
      Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Deepa Dinamani <deepadinamani@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Chang <dpf@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Wolfram Sang <wsa@the-dreams.de>
      Link: http://lkml.kernel.org/r/20180720083914.1950-3-peda@axentia.seSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0ba83f87
    • Peter Rosin's avatar
      locking/rtmutex: Allow specifying a subclass for nested locking · b3da5df2
      Peter Rosin authored
      [ Upstream commit 62cedf3e ]
      
      Needed for annotating rt_mutex locks.
      Tested-by: default avatarJohn Sperbeck <jsperbeck@google.com>
      Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Deepa Dinamani <deepadinamani@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Chang <dpf@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Philippe Ombredanne <pombredanne@nexb.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Wolfram Sang <wsa@the-dreams.de>
      Link: http://lkml.kernel.org/r/20180720083914.1950-2-peda@axentia.seSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b3da5df2
    • Shubhrajyoti Datta's avatar
      net: axienet: Fix double deregister of mdio · 354e35be
      Shubhrajyoti Datta authored
      [ Upstream commit 03bc7cab ]
      
      If the registration fails then mdio_unregister is called.
      However at unbind the unregister ia attempted again resulting
      in the below crash
      
      [   73.544038] kernel BUG at drivers/net/phy/mdio_bus.c:415!
      [   73.549362] Internal error: Oops - BUG: 0 [#1] SMP
      [   73.554127] Modules linked in:
      [   73.557168] CPU: 0 PID: 2249 Comm: sh Not tainted 4.14.0 #183
      [   73.562895] Hardware name: xlnx,zynqmp (DT)
      [   73.567062] task: ffffffc879e41180 task.stack: ffffff800cbe0000
      [   73.572973] PC is at mdiobus_unregister+0x84/0x88
      [   73.577656] LR is at axienet_mdio_teardown+0x18/0x30
      [   73.582601] pc : [<ffffff80085fa4cc>] lr : [<ffffff8008616858>]
      pstate: 20000145
      [   73.589981] sp : ffffff800cbe3c30
      [   73.593277] x29: ffffff800cbe3c30 x28: ffffffc879e41180
      [   73.598573] x27: ffffff8008a21000 x26: 0000000000000040
      [   73.603868] x25: 0000000000000124 x24: ffffffc879efe920
      [   73.609164] x23: 0000000000000060 x22: ffffffc879e02000
      [   73.614459] x21: ffffffc879e02800 x20: ffffffc87b0b8870
      [   73.619754] x19: ffffffc879e02800 x18: 000000000000025d
      [   73.625050] x17: 0000007f9a719ad0 x16: ffffff8008195bd8
      [   73.630345] x15: 0000007f9a6b3d00 x14: 0000000000000010
      [   73.635640] x13: 74656e7265687465 x12: 0000000000000030
      [   73.640935] x11: 0000000000000030 x10: 0101010101010101
      [   73.646231] x9 : 241f394f42533300 x8 : ffffffc8799f6e98
      [   73.651526] x7 : ffffffc8799f6f18 x6 : ffffffc87b0ba318
      [   73.656822] x5 : ffffffc87b0ba498 x4 : 0000000000000000
      [   73.662117] x3 : 0000000000000000 x2 : 0000000000000008
      [   73.667412] x1 : 0000000000000004 x0 : ffffffc8799f4000
      [   73.672708] Process sh (pid: 2249, stack limit = 0xffffff800cbe0000)
      
      Fix the same by making the bus NULL on unregister.
      Signed-off-by: default avatarShubhrajyoti Datta <shubhrajyoti.datta@xilinx.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>
      354e35be
    • Aleksander Morgado's avatar
      qmi_wwan: fix interface number for DW5821e production firmware · f6386884
      Aleksander Morgado authored
      [ Upstream commit f25e1392 ]
      
      The original mapping for the DW5821e was done using a development
      version of the firmware. Confirmed with the vendor that the final
      USB layout ends up exposing the QMI control/data ports in USB
      config #1, interface #0, not in interface #1 (which is now a HID
      interface).
      
      T:  Bus=01 Lev=03 Prnt=04 Port=00 Cnt=01 Dev#= 16 Spd=480 MxCh= 0
      D:  Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  2
      P:  Vendor=413c ProdID=81d7 Rev=03.18
      S:  Manufacturer=DELL
      S:  Product=DW5821e Snapdragon X20 LTE
      S:  SerialNumber=0123456789ABCDEF
      C:  #Ifs= 6 Cfg#= 1 Atr=a0 MxPwr=500mA
      I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
      I:  If#= 1 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid
      I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
      I:  If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
      I:  If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
      I:  If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
      
      Fixes: e7e197ed ("qmi_wwan: add support for the Dell Wireless 5821e module")
      Signed-off-by: default avatarAleksander Morgado <aleksander@aleksander.es>
      Acked-by: default avatarBjørn Mork <bjorn@mork.no>
      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>
      f6386884
    • Sudarsana Reddy Kalluru's avatar
      bnx2x: Fix invalid memory access in rss hash config path. · 637de2c0
      Sudarsana Reddy Kalluru authored
      [ Upstream commit ae2dcb28 ]
      
      Rx hash/filter table configuration uses rss_conf_obj to configure filters
      in the hardware. This object is initialized only when the interface is
      brought up.
      This patch adds driver changes to configure rss params only when the device
      is in opened state. In port disabled case, the config will be cached in the
      driver structure which will be applied in the successive load path.
      
      Please consider applying it to 'net' branch.
      Signed-off-by: default avatarSudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.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>
      637de2c0
    • Guenter Roeck's avatar
      media: staging: omap4iss: Include asm/cacheflush.h after generic includes · 1875957f
      Guenter Roeck authored
      [ Upstream commit 0894da84 ]
      
      Including asm/cacheflush.h first results in the following build error
      when trying to build sparc32:allmodconfig, because 'struct page' has not
      been declared, and the function declaration ends up creating a separate
      (private) declaration of struct page (as a result of function arguments
      being in the scope of the function declaration and definition, not in
      global scope).
      
      The C scoping rules do not just affect variable visibility, they also
      affect type declaration visibility.
      
      The end result is that when the actual call site is seen in
      <linux/highmem.h>, the 'struct page' type in the caller is not the same
      'struct page' that the function was declared with, resulting in:
      
        In file included from arch/sparc/include/asm/page.h:10:0,
                         ...
                         from drivers/staging/media/omap4iss/iss_video.c:15:
        include/linux/highmem.h: In function 'clear_user_highpage':
        include/linux/highmem.h:137:31: error:
      	passing argument 1 of 'sparc_flush_page_to_ram' from incompatible
      	pointer type
      
      Include generic includes files first to fix the problem.
      
      Fixes: fc96d58c ("[media] v4l: omap4iss: Add support for OMAP4 camera interface - Video devices")
      Suggested-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      [ Added explanation of C scope rules - Linus ]
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1875957f
    • Thomas Gleixner's avatar
      perf/x86/amd/ibs: Don't access non-started event · 00f795e1
      Thomas Gleixner authored
      [ Upstream commit d2753e6b ]
      
      Paul Menzel reported the following bug:
      
      > Enabling the undefined behavior sanitizer and building GNU/Linux 4.18-rc5+
      > (with some unrelated commits) with GCC 8.1.0 from Debian Sid/unstable, the
      > warning below is shown.
      >
      > > [    2.111913]
      > > ================================================================================
      > > [    2.111917] UBSAN: Undefined behaviour in arch/x86/events/amd/ibs.c:582:24
      > > [    2.111919] member access within null pointer of type 'struct perf_event'
      > > [    2.111926] CPU: 0 PID: 144 Comm: udevadm Not tainted 4.18.0-rc5-00316-g4864b68cedf2 #104
      > > [    2.111928] Hardware name: ASROCK E350M1/E350M1, BIOS TIMELESS 01/01/1970
      > > [    2.111930] Call Trace:
      > > [    2.111943]  dump_stack+0x55/0x89
      > > [    2.111949]  ubsan_epilogue+0xb/0x33
      > > [    2.111953]  handle_null_ptr_deref+0x7f/0x90
      > > [    2.111958]  __ubsan_handle_type_mismatch_v1+0x55/0x60
      > > [    2.111964]  perf_ibs_handle_irq+0x596/0x620
      
      The code dereferences event before checking the STARTED bit. Patch
      below should cure the issue.
      
      The warning should not trigger, if I analyzed the thing correctly.
      (And Paul's testing confirms this.)
      Reported-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Tested-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Paul Menzel <pmenzel+linux-x86@molgen.mpg.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1807200958390.1580@nanos.tec.linutronix.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      00f795e1
    • Alexander Sverdlin's avatar
      i2c: davinci: Avoid zero value of CLKH · 385b40b4
      Alexander Sverdlin authored
      [ Upstream commit cc8de9a6 ]
      
      If CLKH is set to 0 I2C clock is not generated at all, so avoid this value
      and stretch the clock in this case.
      Signed-off-by: default avatarAlexander Sverdlin <alexander.sverdlin@nokia.com>
      Acked-by: default avatarSekhar Nori <nsekhar@ti.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      385b40b4
    • Faiz Abbas's avatar
      can: m_can: Move accessing of message ram to after clocks are enabled · 562d7bc6
      Faiz Abbas authored
      [ Upstream commit 54e4a0c4 ]
      
      MCAN message ram should only be accessed once clocks are enabled.
      Therefore, move the call to parse/init the message ram to after
      clocks are enabled.
      Signed-off-by: default avatarFaiz Abbas <faiz_abbas@ti.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      562d7bc6
    • Nicholas Mc Guire's avatar
      can: mpc5xxx_can: check of_iomap return before use · 0b14a856
      Nicholas Mc Guire authored
      [ Upstream commit b5c1a23b ]
      
      of_iomap() can return NULL so that return needs to be checked and NULL
      treated as failure. While at it also take care of the missing
      of_node_put() in the error path.
      Signed-off-by: default avatarNicholas Mc Guire <hofrat@osadl.org>
      Fixes: commit afa17a50 ("net/can: add driver for mscan family & mpc52xx_mscan")
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0b14a856
    • Randy Dunlap's avatar
      net: prevent ISA drivers from building on PPC32 · 06ab4273
      Randy Dunlap authored
      [ Upstream commit c9ce1fa1 ]
      
      Prevent drivers from building on PPC32 if they use isa_bus_to_virt(),
      isa_virt_to_bus(), or isa_page_to_bus(), which are not available and
      thus cause build errors.
      
      ../drivers/net/ethernet/3com/3c515.c: In function 'corkscrew_open':
      ../drivers/net/ethernet/3com/3c515.c:824:9: error: implicit declaration of function 'isa_virt_to_bus'; did you mean 'virt_to_bus'? [-Werror=implicit-function-declaration]
      
      ../drivers/net/ethernet/amd/lance.c: In function 'lance_rx':
      ../drivers/net/ethernet/amd/lance.c:1203:23: error: implicit declaration of function 'isa_bus_to_virt'; did you mean 'bus_to_virt'? [-Werror=implicit-function-declaration]
      
      ../drivers/net/ethernet/amd/ni65.c: In function 'ni65_init_lance':
      ../drivers/net/ethernet/amd/ni65.c:585:20: error: implicit declaration of function 'isa_virt_to_bus'; did you mean 'virt_to_bus'? [-Werror=implicit-function-declaration]
      
      ../drivers/net/ethernet/cirrus/cs89x0.c: In function 'net_open':
      ../drivers/net/ethernet/cirrus/cs89x0.c:897:20: error: implicit declaration of function 'isa_virt_to_bus'; did you mean 'virt_to_bus'? [-Werror=implicit-function-declaration]
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Suggested-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      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>
      06ab4273
    • Florian Westphal's avatar
      atl1c: reserve min skb headroom · 5803ce5e
      Florian Westphal authored
      [ Upstream commit 6e568307 ]
      
      Got crash report with following backtrace:
      BUG: unable to handle kernel paging request at ffff8801869daffe
      RIP: 0010:[<ffffffff816429c4>]  [<ffffffff816429c4>] ip6_finish_output2+0x394/0x4c0
      RSP: 0018:ffff880186c83a98  EFLAGS: 00010283
      RAX: ffff8801869db00e ...
        [<ffffffff81644cdc>] ip6_finish_output+0x8c/0xf0
        [<ffffffff81644d97>] ip6_output+0x57/0x100
        [<ffffffff81643dc9>] ip6_forward+0x4b9/0x840
        [<ffffffff81645566>] ip6_rcv_finish+0x66/0xc0
        [<ffffffff81645db9>] ipv6_rcv+0x319/0x530
        [<ffffffff815892ac>] netif_receive_skb+0x1c/0x70
        [<ffffffffc0060bec>] atl1c_clean+0x1ec/0x310 [atl1c]
        ...
      
      The bad access is in neigh_hh_output(), at skb->data - 16 (HH_DATA_MOD).
      atl1c driver provided skb with no headroom, so 14 bytes (ethernet
      header) got pulled, but then 16 are copied.
      
      Reserve NET_SKB_PAD bytes headroom, like netdev_alloc_skb().
      
      Compile tested only; I lack hardware.
      
      Fixes: 7b701764 ("atl1c: Fix misuse of netdev_alloc_skb in refilling rx ring")
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.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>
      5803ce5e
    • Sudarsana Reddy Kalluru's avatar
      qed: Correct Multicast API to reflect existence of 256 approximate buckets. · ffb34418
      Sudarsana Reddy Kalluru authored
      [ Upstream commit 25c020a9 ]
      
      FW hsi contains 256 approximation buckets which are split in ramrod into
      eight u32 values, but driver is using eight 'unsigned long' variables.
      
      This patch fixes the mcast logic by making the API utilize u32.
      
      Fixes: 83aeb933 ("qed*: Trivial modifications")
      Signed-off-by: default avatarSudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com>
      Signed-off-by: default avatarAriel Elior <ariel.elior@cavium.com>
      Signed-off-by: default avatarMichal Kalderon <Michal.Kalderon@cavium.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>
      ffb34418
    • Sudarsana Reddy Kalluru's avatar
      qed: Fix possible race for the link state value. · f4e284f1
      Sudarsana Reddy Kalluru authored
      [ Upstream commit 58874c7b ]
      
      There's a possible race where driver can read link status in mid-transition
      and see that virtual-link is up yet speed is 0. Since in this
      mid-transition we're guaranteed to see a mailbox from MFW soon, we can
      afford to treat this as link down.
      
      Fixes: cc875c2e ("qed: Add link support")
      Signed-off-by: default avatarSudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com>
      Signed-off-by: default avatarAriel Elior <ariel.elior@cavium.com>
      Signed-off-by: default avatarMichal Kalderon <Michal.Kalderon@cavium.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>
      f4e284f1
    • Sudarsana Reddy Kalluru's avatar
      qed: Fix link flap issue due to mismatching EEE capabilities. · 77c65d5f
      Sudarsana Reddy Kalluru authored
      [ Upstream commit 4ad95a93 ]
      
      Apparently, MFW publishes EEE capabilities even for Fiber-boards that don't
      support them, and later since qed internally sets adv_caps it would cause
      link-flap avoidance (LFA) to fail when driver would initiate the link.
      This in turn delays the link, causing traffic to fail.
      
      Driver has been modified to not to ask MFW for any EEE config if EEE isn't
      to be enabled.
      
      Fixes: 645874e5 ("qed: Add support for Energy efficient ethernet.")
      Signed-off-by: default avatarSudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com>
      Signed-off-by: default avatarAriel Elior <ariel.elior@cavium.com>
      Signed-off-by: default avatarMichal Kalderon <Michal.Kalderon@cavium.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>
      77c65d5f
    • YueHaibing's avatar
      net: caif: Add a missing rcu_read_unlock() in caif_flow_cb · b970d8a1
      YueHaibing authored
      [ Upstream commit 64119e05 ]
      
      Add a missing rcu_read_unlock in the error path
      
      Fixes: c95567c8 ("caif: added check for potential null return")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.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>
      b970d8a1
    • Len Brown's avatar
      tools/power turbostat: fix -S on UP systems · a10170d9
      Len Brown authored
      [ Upstream commit 9d83601a ]
      
      The -S (system summary) option failed to print any data on a 1-processor system.
      Reported-by: default avatarArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
      Signed-off-by: default avatarLen Brown <len.brown@intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a10170d9
    • Sean Christopherson's avatar
      KVM: vmx: use local variable for current_vmptr when emulating VMPTRST · 10ca6b3f
      Sean Christopherson authored
      [ Upstream commit 0a06d425 ]
      
      Do not expose the address of vmx->nested.current_vmptr to
      kvm_write_guest_virt_system() as the resulting __copy_to_user()
      call will trigger a WARN when CONFIG_HARDENED_USERCOPY is
      enabled.
      
      Opportunistically clean up variable names in handle_vmptrst()
      to improve readability, e.g. vmcs_gva is misleading as the
      memory operand of VMPTRST is plain memory, not a VMCS.
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Tested-by: default avatarPeter Shier <pshier@google.com>
      Reviewed-by: default avatarPeter Shier <pshier@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      10ca6b3f
    • Florian Westphal's avatar
      netfilter: nf_tables: don't allow to rename to already-pending name · 123534db
      Florian Westphal authored
      [ Upstream commit c6cc94df ]
      
      Its possible to rename two chains to the same name in one
      transaction:
      
      nft add chain t c1
      nft add chain t c2
      nft 'rename chain t c1 c3;rename chain t c2 c3'
      
      This creates two chains named 'c3'.
      
      Appears to be harmless, both chains can still be deleted both
      by name or handle, but, nevertheless, its a bug.
      
      Walk transaction log and also compare vs. the pending renames.
      
      Both chains can still be deleted, but nevertheless it is a bug as
      we don't allow to create chains with identical names, so we should
      prevent this from happening-by-rename too.
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      123534db
    • Florian Westphal's avatar
      netfilter: nf_tables: fix memory leaks on chain rename · 4a0144a4
      Florian Westphal authored
      [ Upstream commit 9f8aac0b ]
      
      The new name is stored in the transaction metadata, on commit,
      the pointers to the old and new names are swapped.
      
      Therefore in abort and commit case we have to free the
      pointer in the chain_trans container.
      
      In commit case, the pointer can be used by another cpu that
      is currently dumping the renamed chain, thus kfree needs to
      happen after waiting for rcu readers to complete.
      
      Fixes: b7263e07 ("netfilter: nf_tables: Allow chain name of up to 255 chars")
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4a0144a4
    • Daniel Borkmann's avatar
      bpf, ppc64: fix unexpected r0=0 exit path inside bpf_xadd · e3476a6d
      Daniel Borkmann authored
      [ Upstream commit b9c1e60e ]
      
      None of the JITs is allowed to implement exit paths from the BPF
      insn mappings other than BPF_JMP | BPF_EXIT. In the BPF core code
      we have a couple of rewrites in eBPF (e.g. LD_ABS / LD_IND) and
      in eBPF to cBPF translation to retain old existing behavior where
      exceptions may occur; they are also tightly controlled by the
      verifier where it disallows some of the features such as BPF to
      BPF calls when legacy LD_ABS / LD_IND ops are present in the BPF
      program. During recent review of all BPF_XADD JIT implementations
      I noticed that the ppc64 one is buggy in that it contains two
      jumps to exit paths. This is problematic as this can bypass verifier
      expectations e.g. pointed out in commit f6b1b3bf ("bpf: fix
      subprog verifier bypass by div/mod by 0 exception"). The first
      exit path is obsoleted by the fix in ca369602 ("bpf: allow xadd
      only on aligned memory") anyway, and for the second one we need to
      do a fetch, add and store loop if the reservation from lwarx/ldarx
      was lost in the meantime.
      
      Fixes: 156d0e29 ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF")
      Reviewed-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Reviewed-by: default avatarSandipan Das <sandipan@linux.vnet.ibm.com>
      Tested-by: default avatarSandipan Das <sandipan@linux.vnet.ibm.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e3476a6d
    • Taehee Yoo's avatar
      netfilter: nft_set_hash: add rcu_barrier() in the nft_rhash_destroy() · a685c4c4
      Taehee Yoo authored
      [ Upstream commit 9970a8e4 ]
      
      GC of set uses call_rcu() to destroy elements.
      So that elements would be destroyed after destroying sets and chains.
      But, elements should be destroyed before destroying sets and chains.
      In order to wait calling call_rcu(), a rcu_barrier() is added.
      
      In order to test correctly, below patch should be applied.
      https://patchwork.ozlabs.org/patch/940883/
      
      test scripts:
         %cat test.nft
         table ip aa {
      	   map map1 {
      		   type ipv4_addr : verdict; flags timeout;
      		   elements = {
      			   0 : jump a0,
      			   1 : jump a0,
      			   2 : jump a0,
      			   3 : jump a0,
      			   4 : jump a0,
      			   5 : jump a0,
      			   6 : jump a0,
      			   7 : jump a0,
      			   8 : jump a0,
      			   9 : jump a0,
      		   }
      		   timeout 1s;
      	   }
      	   chain a0 {
      	   }
         }
         flush ruleset
      
         [ ... ]
      
         table ip aa {
      	   map map1 {
      		   type ipv4_addr : verdict; flags timeout;
      		   elements = {
      			   0 : jump a0,
      			   1 : jump a0,
      			   2 : jump a0,
      			   3 : jump a0,
      			   4 : jump a0,
      			   5 : jump a0,
      			   6 : jump a0,
      			   7 : jump a0,
      			   8 : jump a0,
      			   9 : jump a0,
      		   }
      		   timeout 1s;
      	   }
      	   chain a0 {
      	   }
         }
         flush ruleset
      
      Splat looks like:
      [  200.795603] kernel BUG at net/netfilter/nf_tables_api.c:1363!
      [  200.806944] invalid opcode: 0000 [#1] SMP DEBUG_PAGEALLOC KASAN PTI
      [  200.812253] CPU: 1 PID: 1582 Comm: nft Not tainted 4.17.0+ #24
      [  200.820297] Hardware name: To be filled by O.E.M. To be filled by O.E.M./Aptio CRB, BIOS 5.6.5 07/08/2015
      [  200.830309] RIP: 0010:nf_tables_chain_destroy.isra.34+0x62/0x240 [nf_tables]
      [  200.838317] Code: 43 50 85 c0 74 26 48 8b 45 00 48 8b 4d 08 ba 54 05 00 00 48 c7 c6 60 6d 29 c0 48 c7 c7 c0 65 29 c0
      4c 8b 40 08 e8 58 e5 fd f8 <0f> 0b 48 89 da 48 b8 00 00 00 00 00 fc ff
      [  200.860366] RSP: 0000:ffff880118dbf4d0 EFLAGS: 00010282
      [  200.866354] RAX: 0000000000000061 RBX: ffff88010cdeaf08 RCX: 0000000000000000
      [  200.874355] RDX: 0000000000000061 RSI: 0000000000000008 RDI: ffffed00231b7e90
      [  200.882361] RBP: ffff880118dbf4e8 R08: ffffed002373bcfb R09: ffffed002373bcfa
      [  200.890354] R10: 0000000000000000 R11: ffffed002373bcfb R12: dead000000000200
      [  200.898356] R13: dead000000000100 R14: ffffffffbb62af38 R15: dffffc0000000000
      [  200.906354] FS:  00007fefc31fd700(0000) GS:ffff88011b800000(0000) knlGS:0000000000000000
      [  200.915533] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  200.922355] CR2: 0000557f1c8e9128 CR3: 0000000106880000 CR4: 00000000001006e0
      [  200.930353] Call Trace:
      [  200.932351]  ? nf_tables_commit+0x26f6/0x2c60 [nf_tables]
      [  200.939525]  ? nf_tables_setelem_notify.constprop.49+0x1a0/0x1a0 [nf_tables]
      [  200.947525]  ? nf_tables_delchain+0x6e0/0x6e0 [nf_tables]
      [  200.952383]  ? nft_add_set_elem+0x1700/0x1700 [nf_tables]
      [  200.959532]  ? nla_parse+0xab/0x230
      [  200.963529]  ? nfnetlink_rcv_batch+0xd06/0x10d0 [nfnetlink]
      [  200.968384]  ? nfnetlink_net_init+0x130/0x130 [nfnetlink]
      [  200.975525]  ? debug_show_all_locks+0x290/0x290
      [  200.980363]  ? debug_show_all_locks+0x290/0x290
      [  200.986356]  ? sched_clock_cpu+0x132/0x170
      [  200.990352]  ? find_held_lock+0x39/0x1b0
      [  200.994355]  ? sched_clock_local+0x10d/0x130
      [  200.999531]  ? memset+0x1f/0x40
      
      Fixes: 9d098292 ("netfilter: nft_hash: add support for timeouts")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a685c4c4
    • Eugeniu Rosca's avatar
      usb: gadget: f_uac2: fix endianness of 'struct cntrl_*_lay3' · 70e88fef
      Eugeniu Rosca authored
      [ Upstream commit eec24f2a ]
      
      The list [1] of commits doing endianness fixes in USB subsystem is long
      due to below quote from USB spec Revision 2.0 from April 27, 2000:
      
      ------------
      8.1 Byte/Bit Ordering
      
      Multiple byte fields in standard descriptors, requests, and responses
      are interpreted as and moved over the bus in little-endian order, i.e.
      LSB to MSB.
      ------------
      
      This commit belongs to the same family.
      
      [1] Example of endianness fixes in USB subsystem:
      commit 14e1d56c ("usb: gadget: f_uac2: endianness fixes.")
      commit 42370b82 ("usb: gadget: f_uac1: endianness fixes.")
      commit 63afd5cc ("USB: chaoskey: fix Alea quirk on big-endian hosts")
      commit 74098c4a ("usb: gadget: acm: fix endianness in notifications")
      commit cdd7928d ("ACM gadget: fix endianness in notifications")
      commit 323ece54 ("cdc-wdm: fix endianness bug in debug statements")
      commit e102609f ("usb: gadget: uvc: Fix endianness mismatches")
             list goes on
      
      Fixes: 132fcb46 ("usb: gadget: Add Audio Class 2.0 Driver")
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Reviewed-by: default avatarRuslan Bilovol <ruslan.bilovol@gmail.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      70e88fef
    • Peter Senna Tschudin's avatar
      tools: usb: ffs-test: Fix build on big endian systems · 7cd80fc1
      Peter Senna Tschudin authored
      [ Upstream commit a2b22ddd ]
      
      The tools/usb/ffs-test.c file defines cpu_to_le16/32 by using the C
      library htole16/32 function calls. However, cpu_to_le16/32 are used when
      initializing structures, i.e in a context where a function call is not
      allowed.
      
      It works fine on little endian systems because htole16/32 are defined by
      the C library as no-ops. But on big-endian systems, they are actually
      doing something, which might involve calling a function, causing build
      failures, such as:
      
         ffs-test.c:48:25: error: initializer element is not constant
          #define cpu_to_le32(x)  htole32(x)
                                  ^~~~~~~
         ffs-test.c:128:12: note: in expansion of macro ‘cpu_to_le32’
            .magic = cpu_to_le32(FUNCTIONFS_DESCRIPTORS_MAGIC_V2),
                     ^~~~~~~~~~~
      
      To solve this, we code cpu_to_le16/32 in a way that allows them to be
      used when initializing structures. This fix was imported from
      meta-openembedded/android-tools/fix-big-endian-build.patch written by
      Thomas Petazzoni <thomas.petazzoni@free-electrons.com>.
      
      CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Signed-off-by: default avatarPeter Senna Tschudin <peter.senna@gmail.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7cd80fc1
    • Randy Dunlap's avatar
      usb/phy: fix PPC64 build errors in phy-fsl-usb.c · 645fef5e
      Randy Dunlap authored
      [ Upstream commit a39ba90a ]
      
      Fix build errors when built for PPC64:
      These variables are only used on PPC32 so they don't need to be
      initialized for PPC64.
      
      ../drivers/usb/phy/phy-fsl-usb.c: In function 'usb_otg_start':
      ../drivers/usb/phy/phy-fsl-usb.c:865:3: error: '_fsl_readl' undeclared (first use in this function); did you mean 'fsl_readl'?
         _fsl_readl = _fsl_readl_be;
      ../drivers/usb/phy/phy-fsl-usb.c:865:16: error: '_fsl_readl_be' undeclared (first use in this function); did you mean 'fsl_readl'?
         _fsl_readl = _fsl_readl_be;
      ../drivers/usb/phy/phy-fsl-usb.c:866:3: error: '_fsl_writel' undeclared (first use in this function); did you mean 'fsl_writel'?
         _fsl_writel = _fsl_writel_be;
      ../drivers/usb/phy/phy-fsl-usb.c:866:17: error: '_fsl_writel_be' undeclared (first use in this function); did you mean 'fsl_writel'?
         _fsl_writel = _fsl_writel_be;
      ../drivers/usb/phy/phy-fsl-usb.c:868:16: error: '_fsl_readl_le' undeclared (first use in this function); did you mean 'fsl_readl'?
         _fsl_readl = _fsl_readl_le;
      ../drivers/usb/phy/phy-fsl-usb.c:869:17: error: '_fsl_writel_le' undeclared (first use in this function); did you mean 'fsl_writel'?
         _fsl_writel = _fsl_writel_le;
      
      and the sysfs "show" function return type should be ssize_t, not int:
      
      ../drivers/usb/phy/phy-fsl-usb.c:1042:49: error: initialization of 'ssize_t (*)(struct device *, struct device_attribute *, char *)' {aka 'long int (*)(struct device *, struct device_attribute *, char *)'} from incompatible pointer type 'int (*)(struct device *, struct device_attribute *, char *)' [-Werror=incompatible-pointer-types]
       static DEVICE_ATTR(fsl_usb2_otg_state, S_IRUGO, show_fsl_usb2_otg_state, NULL);
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: linux-usb@vger.kernel.org
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: linuxppc-dev@lists.ozlabs.org
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      645fef5e
    • Vladimir Zapolskiy's avatar
      usb: gadget: u_audio: protect stream runtime fields with stream spinlock · a362655d
      Vladimir Zapolskiy authored
      [ Upstream commit 56bc6158 ]
      
      The change protects almost the whole body of u_audio_iso_complete()
      function by PCM stream lock, this is mainly sufficient to avoid a race
      between USB request completion and stream termination, the change
      prevents a possibility of invalid memory access in interrupt context
      by memcpy():
      
          Unable to handle kernel paging request at virtual address 00004e80
          pgd = c0004000
          [00004e80] *pgd=00000000
          Internal error: Oops: 817 [#1] PREEMPT SMP ARM
          CPU: 0 PID: 3 Comm: ksoftirqd/0 Tainted: G         C   3.14.54+ #117
          task: da180b80 ti: da192000 task.ti: da192000
          PC is at memcpy+0x50/0x330
          LR is at 0xcdd92b0e
          pc : [<c029ef30>]    lr : [<cdd92b0e>]    psr: 20000193
          sp : da193ce4  ip : dd86ae26  fp : 0000b180
          r10: daf81680  r9 : 00000000  r8 : d58a01ea
          r7 : 2c0b43e4  r6 : acdfb08b  r5 : 01a271cf  r4 : 87389377
          r3 : 69469782  r2 : 00000020  r1 : daf82fe0  r0 : 00004e80
          Flags: nzCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
          Control: 10c5387d  Table: 2b70804a  DAC: 00000015
          Process ksoftirqd/0 (pid: 3, stack limit = 0xda192238)
      
      Also added a check for potential !runtime condition, commonly it is
      done by PCM_RUNTIME_CHECK(substream) in the beginning, however this
      does not completely prevent from oopses in u_audio_iso_complete(),
      because the proper protection scheme must be implemented in PCM
      library functions.
      
      An example of *not fixed* oops due to substream->runtime->*
      dereference by snd_pcm_running(substream) from
      snd_pcm_period_elapsed(), where substream->runtime is gone while
      waiting the substream lock:
      
          Unable to handle kernel paging request at virtual address 6b6b6b6b
          pgd = db7e4000
          [6b6b6b6b] *pgd=00000000
          CPU: 0 PID: 193 Comm: klogd Tainted: G         C   3.14.54+ #118
          task: db5ac500 ti: db60c000 task.ti: db60c000
          PC is at snd_pcm_period_elapsed+0x48/0xd8 [snd_pcm]
          LR is at snd_pcm_period_elapsed+0x40/0xd8 [snd_pcm]
          pc : [<>]    lr : [<>]    psr: 60000193
          Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment user
          Control: 10c5387d  Table: 2b7e404a  DAC: 00000015
          Process klogd (pid: 193, stack limit = 0xdb60c238)
          [<>] (snd_pcm_period_elapsed [snd_pcm]) from [<>] (udc_irq+0x500/0xbbc)
          [<>] (udc_irq) from [<>] (ci_irq+0x280/0x304)
          [<>] (ci_irq) from [<>] (handle_irq_event_percpu+0xa4/0x40c)
          [<>] (handle_irq_event_percpu) from [<>] (handle_irq_event+0x3c/0x5c)
          [<>] (handle_irq_event) from [<>] (handle_fasteoi_irq+0xc4/0x110)
          [<>] (handle_fasteoi_irq) from [<>] (generic_handle_irq+0x20/0x30)
          [<>] (generic_handle_irq) from [<>] (handle_IRQ+0x80/0xc0)
          [<>] (handle_IRQ) from [<>] (gic_handle_irq+0x3c/0x60)
          [<>] (gic_handle_irq) from [<>] (__irq_svc+0x44/0x78)
      Signed-off-by: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      [erosca: W/o this patch, with minimal instrumentation [1], I can
               consistently reproduce BUG: KASAN: use-after-free [2]]
      
      [1] Instrumentation to reproduce issue [2]:
      #  diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c
      #  index a72295c953bb..bd0b308024fe 100644
      #  --- a/drivers/usb/gadget/function/u_audio.c
      #  +++ b/drivers/usb/gadget/function/u_audio.c
      #  @@ -16,6 +16,7 @@
      #   #include <sound/core.h>
      #   #include <sound/pcm.h>
      #   #include <sound/pcm_params.h>
      #  +#include <linux/delay.h>
      # 
      #   #include "u_audio.h"
      # 
      #  @@ -147,6 +148,8 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req)
      # 
      # 	spin_unlock_irqrestore(&prm->lock, flags);
      # 
      #  +	udelay(500); //delay here to increase probability of parallel activities
      #  +
      # 	/* Pack USB load in ALSA ring buffer */
      # 	pending = prm->dma_bytes - hw_ptr;
      
      [2] After applying [1], below BUG occurs on Rcar-H3-Salvator-X board:
      ==================================================================
      BUG: KASAN: use-after-free in u_audio_iso_complete+0x24c/0x520 [u_audio]
      Read of size 8 at addr ffff8006cafcc248 by task swapper/0/0
      
      CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        WC      4.14.47+ #160
      Hardware name: Renesas Salvator-X board based on r8a7795 ES2.0+ (DT)
      Call trace:
      [<ffff2000080925ac>] dump_backtrace+0x0/0x364
      [<ffff200008092924>] show_stack+0x14/0x1c
      [<ffff200008f8dbcc>] dump_stack+0x108/0x174
      [<ffff2000083c71b8>] print_address_description+0x7c/0x32c
      [<ffff2000083c78e8>] kasan_report+0x324/0x354
      [<ffff2000083c6114>] __asan_load8+0x24/0x94
      [<ffff2000021d1b34>] u_audio_iso_complete+0x24c/0x520 [u_audio]
      [<ffff20000152fe50>] usb_gadget_giveback_request+0x480/0x4d0 [udc_core]
      [<ffff200001860ab8>] usbhsg_queue_done+0x100/0x130 [renesas_usbhs]
      [<ffff20000185f814>] usbhsf_pkt_handler+0x1a4/0x298 [renesas_usbhs]
      [<ffff20000185fb38>] usbhsf_irq_ready+0x128/0x178 [renesas_usbhs]
      [<ffff200001859cc8>] usbhs_interrupt+0x440/0x490 [renesas_usbhs]
      [<ffff2000081a0288>] __handle_irq_event_percpu+0x594/0xa58
      [<ffff2000081a07d0>] handle_irq_event_percpu+0x84/0x12c
      [<ffff2000081a0928>] handle_irq_event+0xb0/0x10c
      [<ffff2000081a8384>] handle_fasteoi_irq+0x1e0/0x2ec
      [<ffff20000819e5f8>] generic_handle_irq+0x2c/0x44
      [<ffff20000819f0d0>] __handle_domain_irq+0x190/0x194
      [<ffff20000808177c>] gic_handle_irq+0x80/0xac
      Exception stack(0xffff200009e97c80 to 0xffff200009e97dc0)
      7c80: 0000000000000000 0000000000000000 0000000000000003 ffff200008179298
      7ca0: ffff20000ae1c180 dfff200000000000 0000000000000000 ffff2000081f9a88
      7cc0: ffff200009eb5960 ffff200009e97cf0 0000000000001600 ffff0400041b064b
      7ce0: 0000000000000000 0000000000000002 0000000200000001 0000000000000001
      7d00: ffff20000842197c 0000ffff958c4970 0000000000000000 ffff8006da0d5b80
      7d20: ffff8006d4678498 0000000000000000 000000126bde0a8b ffff8006d4678480
      7d40: 0000000000000000 000000126bdbea64 ffff200008fd0000 ffff8006fffff980
      7d60: 00000000495f0018 ffff200009e97dc0 ffff200008b6c4ec ffff200009e97dc0
      7d80: ffff200008b6c4f0 0000000020000145 ffff8006da0d5b80 ffff8006d4678498
      7da0: ffffffffffffffff ffff8006d4678498 ffff200009e97dc0 ffff200008b6c4f0
      [<ffff200008084034>] el1_irq+0xb4/0x12c
      [<ffff200008b6c4f0>] cpuidle_enter_state+0x818/0x844
      [<ffff200008b6c59c>] cpuidle_enter+0x18/0x20
      [<ffff20000815f2e4>] call_cpuidle+0x98/0x9c
      [<ffff20000815f674>] do_idle+0x214/0x264
      [<ffff20000815facc>] cpu_startup_entry+0x20/0x24
      [<ffff200008fb09d8>] rest_init+0x30c/0x320
      [<ffff2000095f1338>] start_kernel+0x570/0x5b0
      ---<-snip->---
      
      Fixes: 132fcb46 ("usb: gadget: Add Audio Class 2.0 Driver")
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a362655d
    • Vladimir Zapolskiy's avatar
      usb: gadget: u_audio: remove cached period bytes value · c7d18686
      Vladimir Zapolskiy authored
      [ Upstream commit 773e53d5 ]
      
      Substream period size potentially can be changed in runtime, however
      this is not accounted in the data copying routine, the change replaces
      the cached value with an actual value from substream runtime.
      
      As a side effect the change also removes a potential division by zero
      in u_audio_iso_complete() function, if there is a race with
      uac_pcm_hw_free(), which sets prm->period_size to 0.
      
      Fixes: 132fcb46 ("usb: gadget: Add Audio Class 2.0 Driver")
      Signed-off-by: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c7d18686
    • Vladimir Zapolskiy's avatar
      usb: gadget: u_audio: remove caching of stream buffer parameters · 42b09bec
      Vladimir Zapolskiy authored
      [ Upstream commit 96afb54e ]
      
      There is no necessity to copy PCM stream ring buffer area and size
      properties to UAC private data structure, these values can be got
      from substream itself.
      
      The change gives more control on substream and avoid stale caching.
      
      Fixes: 132fcb46 ("usb: gadget: Add Audio Class 2.0 Driver")
      Signed-off-by: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      42b09bec
    • Joshua Frkuska's avatar
      usb: gadget: u_audio: update hw_ptr in iso_complete after data copied · 224c0d08
      Joshua Frkuska authored
      [ Upstream commit 6b37bd78 ]
      
      In u_audio_iso_complete, the runtime hw_ptr is updated before the
      data is actually copied over to/from the buffer/dma area. When
      ALSA uses this hw_ptr, the data may not actually be available to
      be used. This causes trash/stale audio to play/record. This
      patch updates the hw_ptr after the data has been copied to avoid
      this.
      
      Fixes: 132fcb46 ("usb: gadget: Add Audio Class 2.0 Driver")
      Signed-off-by: default avatarJoshua Frkuska <joshua_frkuska@mentor.com>
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      224c0d08
    • Eugeniu Rosca's avatar
      usb: gadget: u_audio: fix pcm/card naming in g_audio_setup() · dc126a1e
      Eugeniu Rosca authored
      [ Upstream commit dfa042fa ]
      
      Fix below smatch (v0.5.0-4443-g69e9094e11c1) warnings:
      drivers/usb/gadget/function/u_audio.c:607 g_audio_setup() warn: strcpy() 'pcm_name' of unknown size might be too large for 'pcm->name'
      drivers/usb/gadget/function/u_audio.c:614 g_audio_setup() warn: strcpy() 'card_name' of unknown size might be too large for 'card->driver'
      drivers/usb/gadget/function/u_audio.c:615 g_audio_setup() warn: strcpy() 'card_name' of unknown size might be too large for 'card->shortname'
      
      Below commits performed a similar 's/strcpy/strlcpy/' rework:
      * v2.6.31 commit 8372d498 ("ALSA: ctxfi - Fix PCM device naming")
      * v4.14 commit 003d3e70 ("ALSA: ad1848: fix format string overflow warning")
      * v4.14 commit 6d8b04de ("ALSA: cs423x: fix format string overflow warning")
      
      Fixes: eb9fecb9 ("usb: gadget: f_uac2: split out audio core")
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dc126a1e
    • Eugeniu Rosca's avatar
      usb: gadget: f_uac2: fix error handling in afunc_bind (again) · fa18ff7e
      Eugeniu Rosca authored
      [ Upstream commit e87581fe ]
      
      If usb_ep_autoconfig() fails (i.e. returns a null endpoint descriptor),
      we expect afunc_bind() to fail (i.e. return a negative error code).
      
      However, due to v4.10-rc1 commit f1d3861d ("usb: gadget: f_uac2: fix
      error handling at afunc_bind"), afunc_bind() returns zero, telling the
      caller that it succeeded. This then generates NULL pointer dereference
      in below scenario on Rcar H3-ES20-Salvator-X target:
      
      rcar-gen3:/home/root# modprobe g_audio
      [  626.521155] g_audio gadget: afunc_bind:565 Error!
      [  626.526319] g_audio gadget: Linux USB Audio Gadget, version: Feb 2, 2012
      [  626.533405] g_audio gadget: g_audio ready
      rcar-gen3:/home/root#
      rcar-gen3:/home/root# modprobe -r g_audio
      [  728.256707] ==================================================================
      [  728.264293] BUG: KASAN: null-ptr-deref in u_audio_stop_capture+0x70/0x268 [u_audio]
      [  728.272244] Read of size 8 at addr 00000000000000a0 by task modprobe/2545
      [  728.279309]
      [  728.280849] CPU: 0 PID: 2545 Comm: modprobe Tainted: G        WC      4.14.47+ #152
      [  728.288778] Hardware name: Renesas Salvator-X board based on r8a7795 ES2.0+ (DT)
      [  728.296454] Call trace:
      [  728.299151] [<ffff2000080925ac>] dump_backtrace+0x0/0x364
      [  728.304808] [<ffff200008092924>] show_stack+0x14/0x1c
      [  728.310081] [<ffff200008f8d5cc>] dump_stack+0x108/0x174
      [  728.315522] [<ffff2000083c77c8>] kasan_report+0x1fc/0x354
      [  728.321134] [<ffff2000083c611c>] __asan_load8+0x24/0x94
      [  728.326600] [<ffff2000021e1618>] u_audio_stop_capture+0x70/0x268 [u_audio]
      [  728.333735] [<ffff2000021f8b7c>] afunc_disable+0x44/0x60 [usb_f_uac2]
      [  728.340503] [<ffff20000218177c>] usb_remove_function+0x9c/0x210 [libcomposite]
      [  728.348060] [<ffff200002183320>] remove_config.isra.2+0x1d8/0x218 [libcomposite]
      [  728.355788] [<ffff200002186c54>] __composite_unbind+0x104/0x1f8 [libcomposite]
      [  728.363339] [<ffff200002186d58>] composite_unbind+0x10/0x18 [libcomposite]
      [  728.370536] [<ffff20000152f158>] usb_gadget_remove_driver+0xc0/0x170 [udc_core]
      [  728.378172] [<ffff20000153154c>] usb_gadget_unregister_driver+0x1cc/0x258 [udc_core]
      [  728.386274] [<ffff200002180de8>] usb_composite_unregister+0x10/0x18 [libcomposite]
      [  728.394116] [<ffff2000021d035c>] audio_driver_exit+0x14/0x28 [g_audio]
      [  728.400878] [<ffff200008213ed4>] SyS_delete_module+0x288/0x32c
      [  728.406935] Exception stack(0xffff8006cf6c7ec0 to 0xffff8006cf6c8000)
      [  728.413624] 7ec0: 0000000006136428 0000000000000800 0000000000000000 0000ffffd706efe8
      [  728.421718] 7ee0: 0000ffffd706efe9 000000000000000a 1999999999999999 0000000000000000
      [  728.429792] 7f00: 000000000000006a 000000000042c078 0000000000000000 0000000000000005
      [  728.437870] 7f20: 0000000000000000 0000000000000000 0000000000000004 0000000000000000
      [  728.445952] 7f40: 000000000042bfc8 0000ffffbc7c8f40 0000000000000000 00000000061363c0
      [  728.454035] 7f60: 0000000006136428 0000000000000000 0000000000000000 0000000006136428
      [  728.462114] 7f80: 000000000042c000 0000ffffd7071448 000000000042c000 0000000000000000
      [  728.470190] 7fa0: 00000000061350c0 0000ffffd7070010 000000000041129c 0000ffffd7070010
      [  728.478281] 7fc0: 0000ffffbc7c8f48 0000000060000000 0000000006136428 000000000000006a
      [  728.486351] 7fe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      [  728.494434] [<ffff200008084780>] el0_svc_naked+0x34/0x38
      [  728.499957] ==================================================================
      [  728.507801] Unable to handle kernel NULL pointer dereference at virtual address 000000a0
      [  728.517742] Mem abort info:
      [  728.520993]   Exception class = DABT (current EL), IL = 32 bits
      [  728.527375]   SET = 0, FnV = 0
      [  728.530731]   EA = 0, S1PTW = 0
      [  728.534361] Data abort info:
      [  728.537650]   ISV = 0, ISS = 0x00000006
      [  728.541863]   CM = 0, WnR = 0
      [  728.545167] user pgtable: 4k pages, 48-bit VAs, pgd = ffff8006c6100000
      [  728.552156] [00000000000000a0] *pgd=0000000716a8d003
      [  728.557519] , *pud=00000007116fc003
      [  728.561259] , *pmd=0000000000000000
      [  728.564985] Internal error: Oops: 96000006 [#1] PREEMPT SMP
      [  728.570815] Modules linked in:
      [  728.574023]  usb_f_uac2
      [  728.576560]  u_audio
      [  728.578827]  g_audio(-)
      [  728.581361]  libcomposite
      [  728.584071]  configfs
      [  728.586428]  aes_ce_blk
      [  728.588960]  sata_rcar
      [  728.591421]  crypto_simd
      [  728.594039]  cryptd
      [  728.596217]  libata
      [  728.598396]  aes_ce_cipher
      [  728.601188]  crc32_ce
      [  728.603542]  ghash_ce
      [  728.605896]  gf128mul
      [  728.608250]  aes_arm64
      [  728.610692]  scsi_mod
      [  728.613046]  sha2_ce
      [  728.615313]  xhci_plat_hcd
      [  728.618106]  sha256_arm64
      [  728.620811]  sha1_ce
      [  728.623077]  renesas_usbhs
      [  728.625869]  xhci_hcd
      [  728.628243]  renesas_usb3
      [  728.630948]  sha1_generic
      [  728.633670]  ravb_streaming(C)
      [  728.636814]  udc_core
      [  728.639168]  cpufreq_dt
      [  728.641697]  rcar_gen3_thermal
      [  728.644840]  usb_dmac
      [  728.647194]  pwm_rcar
      [  728.649548]  thermal_sys
      [  728.652165]  virt_dma
      [  728.654519]  mch_core(C)
      [  728.657137]  pwm_bl
      [  728.659315]  snd_soc_rcar
      [  728.662020]  snd_aloop
      [  728.664462]  snd_soc_generic_card
      [  728.667869]  snd_soc_ak4613
      [  728.670749]  ipv6
      [  728.672768]  autofs4
      [  728.675052] CPU: 0 PID: 2545 Comm: modprobe Tainted: G    B   WC      4.14.47+ #152
      [  728.682973] Hardware name: Renesas Salvator-X board based on r8a7795 ES2.0+ (DT)
      [  728.690637] task: ffff8006ced38000 task.stack: ffff8006cf6c0000
      [  728.696814] PC is at u_audio_stop_capture+0x70/0x268 [u_audio]
      [  728.702896] LR is at u_audio_stop_capture+0x70/0x268 [u_audio]
      [  728.708964] pc : [<ffff2000021e1618>] lr : [<ffff2000021e1618>] pstate: 60000145
      [  728.716620] sp : ffff8006cf6c7a50
      [  728.720154] x29: ffff8006cf6c7a50
      [  728.723760] x28: ffff8006ced38000
      [  728.727272] x27: ffff200008fd7000
      [  728.730857] x26: ffff2000021d2340
      [  728.734361] x25: 0000000000000000
      [  728.737948] x24: ffff200009e94b08
      [  728.741452] x23: 00000000000000a0
      [  728.745052] x22: 00000000000000a8
      [  728.748558] x21: 1ffff000d9ed8f7c
      [  728.752142] x20: ffff8006d671a800
      [  728.755646] x19: 0000000000000000
      [  728.759231] x18: 0000000000000000
      [  728.762736] x17: 0000ffffbc7c8f40
      [  728.766320] x16: ffff200008213c4c
      [  728.769823] x15: 0000000000000000
      [  728.773408] x14: 0720072007200720
      [  728.776912] x13: 0720072007200720
      [  728.780497] x12: ffffffffffffffff
      [  728.784001] x11: 0000000000000040
      [  728.787598] x10: 0000000000001600
      [  728.791103] x9 : ffff8006cf6c77a0
      [  728.794689] x8 : ffff8006ced39660
      [  728.798193] x7 : ffff20000811c738
      [  728.801794] x6 : 0000000000000000
      [  728.805299] x5 : dfff200000000000
      [  728.808885] x4 : ffff8006ced38000
      [  728.812390] x3 : ffff200008fb46e8
      [  728.815976] x2 : 0000000000000007
      [  728.819480] x1 : 3ba68643e7431500
      [  728.823066] x0 : 0000000000000000
      [  728.826574] Process modprobe (pid: 2545, stack limit = 0xffff8006cf6c0000)
      [  728.833704] Call trace:
      [  728.836292] Exception stack(0xffff8006cf6c7910 to 0xffff8006cf6c7a50)
      [  728.842987] 7900:                                   0000000000000000 3ba68643e7431500
      [  728.851084] 7920: 0000000000000007 ffff200008fb46e8 ffff8006ced38000 dfff200000000000
      [  728.859173] 7940: 0000000000000000 ffff20000811c738 ffff8006ced39660 ffff8006cf6c77a0
      [  728.867248] 7960: 0000000000001600 0000000000000040 ffffffffffffffff 0720072007200720
      [  728.875323] 7980: 0720072007200720 0000000000000000 ffff200008213c4c 0000ffffbc7c8f40
      [  728.883412] 79a0: 0000000000000000 0000000000000000 ffff8006d671a800 1ffff000d9ed8f7c
      [  728.891485] 79c0: 00000000000000a8 00000000000000a0 ffff200009e94b08 0000000000000000
      [  728.899561] 79e0: ffff2000021d2340 ffff200008fd7000 ffff8006ced38000 ffff8006cf6c7a50
      [  728.907636] 7a00: ffff2000021e1618 ffff8006cf6c7a50 ffff2000021e1618 0000000060000145
      [  728.915710] 7a20: 0000000000000008 0000000000000000 0000ffffffffffff 3ba68643e7431500
      [  728.923780] 7a40: ffff8006cf6c7a50 ffff2000021e1618
      [  728.928880] [<ffff2000021e1618>] u_audio_stop_capture+0x70/0x268 [u_audio]
      [  728.936032] [<ffff2000021f8b7c>] afunc_disable+0x44/0x60 [usb_f_uac2]
      [  728.942822] [<ffff20000218177c>] usb_remove_function+0x9c/0x210 [libcomposite]
      [  728.950385] [<ffff200002183320>] remove_config.isra.2+0x1d8/0x218 [libcomposite]
      [  728.958134] [<ffff200002186c54>] __composite_unbind+0x104/0x1f8 [libcomposite]
      [  728.965689] [<ffff200002186d58>] composite_unbind+0x10/0x18 [libcomposite]
      [  728.972882] [<ffff20000152f158>] usb_gadget_remove_driver+0xc0/0x170 [udc_core]
      [  728.980522] [<ffff20000153154c>] usb_gadget_unregister_driver+0x1cc/0x258 [udc_core]
      [  728.988638] [<ffff200002180de8>] usb_composite_unregister+0x10/0x18 [libcomposite]
      [  728.996472] [<ffff2000021d035c>] audio_driver_exit+0x14/0x28 [g_audio]
      [  729.003231] [<ffff200008213ed4>] SyS_delete_module+0x288/0x32c
      [  729.009278] Exception stack(0xffff8006cf6c7ec0 to 0xffff8006cf6c8000)
      [  729.015946] 7ec0: 0000000006136428 0000000000000800 0000000000000000 0000ffffd706efe8
      [  729.024022] 7ee0: 0000ffffd706efe9 000000000000000a 1999999999999999 0000000000000000
      [  729.032099] 7f00: 000000000000006a 000000000042c078 0000000000000000 0000000000000005
      [  729.040172] 7f20: 0000000000000000 0000000000000000 0000000000000004 0000000000000000
      [  729.048263] 7f40: 000000000042bfc8 0000ffffbc7c8f40 0000000000000000 00000000061363c0
      [  729.056337] 7f60: 0000000006136428 0000000000000000 0000000000000000 0000000006136428
      [  729.064411] 7f80: 000000000042c000 0000ffffd7071448 000000000042c000 0000000000000000
      [  729.072484] 7fa0: 00000000061350c0 0000ffffd7070010 000000000041129c 0000ffffd7070010
      [  729.080563] 7fc0: 0000ffffbc7c8f48 0000000060000000 0000000006136428 000000000000006a
      [  729.088636] 7fe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
      [  729.096733] [<ffff200008084780>] el0_svc_naked+0x34/0x38
      [  729.102259] Code: 9597d1b3 aa1703e0 9102a276 958792b9 (f9405275)
      [  729.108617] ---[ end trace 7560c5fa3d100243 ]---
      
      After this patch is applied, the issue is fixed:
      rcar-gen3:/home/root# modprobe g_audio
      [   59.217127] g_audio gadget: afunc_bind:565 Error!
      [   59.222329] g_audio ee020000.usb: failed to start g_audio: -19
      modprobe: ERROR: could not insert 'g_audio': No such device
      rcar-gen3:/home/root# modprobe -r g_audio
      rcar-gen3:/home/root#
      
      Fixes: f1d3861d ("usb: gadget: f_uac2: fix error handling at afunc_bind")
      Signed-off-by: default avatarEugeniu Rosca <erosca@de.adit-jv.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fa18ff7e
    • Jia-Ju Bai's avatar
      usb: gadget: r8a66597: Fix a possible sleep-in-atomic-context bugs in r8a66597_queue() · 43b058dc
      Jia-Ju Bai authored
      [ Upstream commit f36b507c ]
      
      The driver may sleep in an interrupt handler.
      The function call path (from bottom to top) in Linux-4.16.7 is:
      
      [FUNC] r8a66597_queue(GFP_KERNEL)
      drivers/usb/gadget/udc/r8a66597-udc.c, 1193:
      		r8a66597_queue in get_status
      drivers/usb/gadget/udc/r8a66597-udc.c, 1301:
      		get_status in setup_packet
      drivers/usb/gadget/udc/r8a66597-udc.c, 1381:
      		setup_packet in irq_control_stage
      drivers/usb/gadget/udc/r8a66597-udc.c, 1508:
      		irq_control_stage in r8a66597_irq (interrupt handler)
      
      To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC.
      
      This bug is found by my static analysis tool (DSAC-2) and checked by
      my code review.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43b058dc
    • Jia-Ju Bai's avatar
      usb: gadget: r8a66597: Fix two possible sleep-in-atomic-context bugs in init_controller() · 3f41c2d0
      Jia-Ju Bai authored
      [ Upstream commit 0602088b ]
      
      The driver may sleep with holding a spinlock.
      The function call paths (from bottom to top) in Linux-4.16.7 are:
      
      [FUNC] msleep
      drivers/usb/gadget/udc/r8a66597-udc.c, 839:
      		msleep in init_controller
      drivers/usb/gadget/udc/r8a66597-udc.c, 96:
      		init_controller in r8a66597_usb_disconnect
      drivers/usb/gadget/udc/r8a66597-udc.c, 93:
      		spin_lock in r8a66597_usb_disconnect
      
      [FUNC] msleep
      drivers/usb/gadget/udc/r8a66597-udc.c, 835:
      		msleep in init_controller
      drivers/usb/gadget/udc/r8a66597-udc.c, 96:
      		init_controller in r8a66597_usb_disconnect
      drivers/usb/gadget/udc/r8a66597-udc.c, 93:
      		spin_lock in r8a66597_usb_disconnect
      
      To fix these bugs, msleep() is replaced with mdelay().
      
      This bug is found by my static analysis tool (DSAC-2) and checked by
      my code review.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f41c2d0
    • Josef Bacik's avatar
      nbd: handle unexpected replies better · 05ee6166
      Josef Bacik authored
      [ Upstream commit 8f3ea359 ]
      
      If the server or network is misbehaving and we get an unexpected reply
      we can sometimes miss the request not being started and wait on a
      request and never get a response, or even double complete the same
      request.  Fix this by replacing the send_complete completion with just a
      per command lock.  Add a per command cookie as well so that we can know
      if we're getting a double completion for a previous event.  Also check
      to make sure we dont have REQUEUED set as that means we raced with the
      timeout handler and need to just let the retry occur.
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      05ee6166
    • Josef Bacik's avatar
      nbd: don't requeue the same request twice. · ced413c5
      Josef Bacik authored
      [ Upstream commit d7d94d48 ]
      
      We can race with the snd timeout and the per-request timeout and end up
      requeuing the same request twice.  We can't use the send_complete
      completion to tell if everything is ok because we hold the tx_lock
      during send, so the timeout stuff will block waiting to mark the socket
      dead, and we could be marked complete and still requeue.  Instead add a
      flag to the socket so we know whether we've been requeued yet.
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ced413c5
    • Lucas Stach's avatar
      drm/imx: imx-ldb: check if channel is enabled before printing warning · 962ff36d
      Lucas Stach authored
      [ Upstream commit c80d673b ]
      
      If the second LVDS channel has been disabled in the DT when using dual-channel
      mode we should not print a warning.
      Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
      Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      962ff36d