05 Sep, 2018

40 commits

  • [ Upstream commit 82f4f3e69c5c29bce940dd87a2c0f16c51d48d17 ]

    Add a testcase for checking snapshot and tracing_on
    relationship. This ensures that the snapshotting doesn't
    affect current tracing on/off settings.

    Link: http://lkml.kernel.org/r/153149932412.11274.15289227592627901488.stgit@devbox

    Cc: Tom Zanussi
    Cc: Hiraku Toyooka
    Signed-off-by: Masami Hiramatsu
    Cc: Ingo Molnar
    Cc: Shuah Khan
    Cc: linux-kselftest@vger.kernel.org
    Signed-off-by: Steven Rostedt (VMware)
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     
  • [ Upstream commit c2412ac45a8f8f1cd582723c1a139608694d410d ]

    If we meet a conflicting object that is marked FSCACHE_OBJECT_IS_LIVE in
    the active object tree, we have been emitting a BUG after logging
    information about it and the new object.

    Instead, we should wait for the CACHEFILES_OBJECT_ACTIVE flag to be cleared
    on the old object (or return an error). The ACTIVE flag should be cleared
    after it has been removed from the active object tree. A timeout of 60s is
    used in the wait, so we shouldn't be able to get stuck there.

    Fixes: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem")
    Signed-off-by: Kiran Kumar Modukuri
    Signed-off-by: David Howells
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Kiran Kumar Modukuri
     
  • [ Upstream commit 934140ab028713a61de8bca58c05332416d037d1 ]

    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: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem")
    Reported-by: Lei Xue
    Reported-by: Vegard Nossum
    Reported-by: Anthony DeRobertis
    Reported-by: NeilBrown
    Reported-by: Daniel Axtens
    Reported-by: Kiran Kumar Modukuri
    Signed-off-by: David Howells
    Reviewed-by: Daniel Axtens
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Kiran Kumar Modukuri
     
  • [ Upstream commit d0eb06afe712b7b103b6361f40a9a0c638524669 ]

    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: 9ae326a69004 ("CacheFiles: A cache that backs onto a mounted filesystem")
    Reported-by: Kiran Kumar Modukuri
    Signed-off-by: David Howells
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Kiran Kumar Modukuri
     
  • [ Upstream commit 92a4728608a8fd228c572bc8ff50dd98aa0ddf2a ]

    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 98f78525371b ("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: Dirk Gouders
    Fix-Suggested-by: Masahiro Yamada
    Signed-off-by: Kees Cook
    Reviewed-by: Masahiro Yamada
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/20180724230827.GA37823@beast
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Kees Cook
     
  • [ Upstream commit f3d133ee0a17d5694c6f21873eec9863e11fa423 ]

    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: Hailong Liu
    Signed-off-by: Jiang Biao
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: zhong.weidong@zte.com.cn
    Link: http://lkml.kernel.org/r/1531874815-39357-1-git-send-email-liu.hailong6@zte.com.cn
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Hailong Liu
     
  • [ Upstream commit 7b94ea50514d1a0dc94f02723b603c27bc0ea597 ]

    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: John Sperbeck
    Tested-by: John Sperbeck
    Signed-off-by: Peter Rosin
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Davidlohr Bueso
    Cc: Deepa Dinamani
    Cc: Greg Kroah-Hartman
    Cc: Linus Torvalds
    Cc: Peter Chang
    Cc: Peter Zijlstra
    Cc: Philippe Ombredanne
    Cc: Thomas Gleixner
    Cc: Will Deacon
    Cc: Wolfram Sang
    Link: http://lkml.kernel.org/r/20180720083914.1950-3-peda@axentia.se
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Peter Rosin
     
  • [ Upstream commit 62cedf3e60af03e47849fe2bd6a03ec179422a8a ]

    Needed for annotating rt_mutex locks.

    Tested-by: John Sperbeck
    Signed-off-by: Peter Rosin
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Davidlohr Bueso
    Cc: Deepa Dinamani
    Cc: Greg Kroah-Hartman
    Cc: Linus Torvalds
    Cc: Peter Chang
    Cc: Peter Zijlstra
    Cc: Philippe Ombredanne
    Cc: Thomas Gleixner
    Cc: Will Deacon
    Cc: Wolfram Sang
    Link: http://lkml.kernel.org/r/20180720083914.1950-2-peda@axentia.se
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Peter Rosin
     
  • [ Upstream commit 03bc7cab7d7218088412a75e141696a89059ab00 ]

    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 : [] lr : []
    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: Shubhrajyoti Datta
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Shubhrajyoti Datta
     
  • [ Upstream commit f25e1392fdb556290957142ac2da33a02cbff403 ]

    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: e7e197edd09c25 ("qmi_wwan: add support for the Dell Wireless 5821e module")
    Signed-off-by: Aleksander Morgado
    Acked-by: Bjørn Mork
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Aleksander Morgado
     
  • [ Upstream commit ae2dcb28c24794a87e424a726a1cf1a61980f52d ]

    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: Sudarsana Reddy Kalluru
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sudarsana Reddy Kalluru
     
  • [ Upstream commit 0894da849f145af51bde88a6b84f95b9c9e0bc66 ]

    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
    , 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: fc96d58c10162 ("[media] v4l: omap4iss: Add support for OMAP4 camera interface - Video devices")
    Suggested-by: Linus Torvalds
    Acked-by: David S. Miller
    Cc: Randy Dunlap
    Signed-off-by: Guenter Roeck
    [ Added explanation of C scope rules - Linus ]
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Guenter Roeck
     
  • [ Upstream commit d2753e6b4882a637a0e8fb3b9c2e15f33265300e ]

    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: Paul Menzel
    Tested-by: Paul Menzel
    Signed-off-by: Thomas Gleixner
    Cc: Alexander Shishkin
    Cc: Arnaldo Carvalho de Melo
    Cc: Borislav Petkov
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Paul Menzel
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Vince Weaver
    Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1807200958390.1580@nanos.tec.linutronix.de
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     
  • [ Upstream commit cc8de9a68599b261244ea453b38678229f06ada7 ]

    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: Alexander Sverdlin
    Acked-by: Sekhar Nori
    Signed-off-by: Wolfram Sang
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Alexander Sverdlin
     
  • [ Upstream commit 54e4a0c486041dc1c20593d997fafd67089e8408 ]

    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: Faiz Abbas
    Signed-off-by: Marc Kleine-Budde
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Faiz Abbas
     
  • [ Upstream commit b5c1a23b17e563b656cc9bb76ce5323b997d90e8 ]

    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: Nicholas Mc Guire
    Fixes: commit afa17a500a36 ("net/can: add driver for mscan family & mpc52xx_mscan")
    Signed-off-by: Marc Kleine-Budde
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Nicholas Mc Guire
     
  • [ Upstream commit c9ce1fa1c24b08e13c2a3b5b1f94a19c9eaa982c ]

    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: Randy Dunlap
    Suggested-by: Michael Ellerman
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     
  • [ Upstream commit 6e56830776828d8ca9897fc4429eeab47c3bb432 ]

    Got crash report with following backtrace:
    BUG: unable to handle kernel paging request at ffff8801869daffe
    RIP: 0010:[] [] ip6_finish_output2+0x394/0x4c0
    RSP: 0018:ffff880186c83a98 EFLAGS: 00010283
    RAX: ffff8801869db00e ...
    [] ip6_finish_output+0x8c/0xf0
    [] ip6_output+0x57/0x100
    [] ip6_forward+0x4b9/0x840
    [] ip6_rcv_finish+0x66/0xc0
    [] ipv6_rcv+0x319/0x530
    [] netif_receive_skb+0x1c/0x70
    [] 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: 7b7017642199 ("atl1c: Fix misuse of netdev_alloc_skb in refilling rx ring")
    Signed-off-by: Florian Westphal
    Reviewed-by: Eric Dumazet
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     
  • [ Upstream commit 25c020a90919632b3425c19dc09188d56b9ed59a ]

    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: Sudarsana Reddy Kalluru
    Signed-off-by: Ariel Elior
    Signed-off-by: Michal Kalderon
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sudarsana Reddy Kalluru
     
  • [ Upstream commit 58874c7b246109d8efb2b0099d1aa296d6bfc3fa ]

    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: Sudarsana Reddy Kalluru
    Signed-off-by: Ariel Elior
    Signed-off-by: Michal Kalderon
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sudarsana Reddy Kalluru
     
  • [ Upstream commit 4ad95a93a702ec4f4fb5159b822797ba67b8cbbe ]

    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: Sudarsana Reddy Kalluru
    Signed-off-by: Ariel Elior
    Signed-off-by: Michal Kalderon
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sudarsana Reddy Kalluru
     
  • [ Upstream commit 64119e05f7b31e83e2555f6782e6cdc8f81c63f4 ]

    Add a missing rcu_read_unlock in the error path

    Fixes: c95567c80352 ("caif: added check for potential null return")
    Signed-off-by: YueHaibing
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    YueHaibing
     
  • [ Upstream commit 9d83601a9cc1884d1b5706ee2acc661d558c6838 ]

    The -S (system summary) option failed to print any data on a 1-processor system.

    Reported-by: Artem Bityutskiy
    Signed-off-by: Len Brown
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Len Brown
     
  • [ Upstream commit 0a06d4256674c4e041945b52044941995fee237d ]

    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: Sean Christopherson
    Tested-by: Peter Shier
    Reviewed-by: Peter Shier
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Sean Christopherson
     
  • [ Upstream commit c6cc94df65c3174be92afbee638f11cbb5e606a7 ]

    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: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     
  • [ Upstream commit 9f8aac0be21ed5f99bd5ba0ff315d710737d1794 ]

    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: b7263e071a ("netfilter: nf_tables: Allow chain name of up to 255 chars")
    Signed-off-by: Florian Westphal
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Florian Westphal
     
  • [ Upstream commit b9c1e60e7bf4e64ac1b4f4d6d593f0bb57886973 ]

    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 f6b1b3bf0d5f ("bpf: fix
    subprog verifier bypass by div/mod by 0 exception"). The first
    exit path is obsoleted by the fix in ca36960211eb ("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: 156d0e290e96 ("powerpc/ebpf/jit: Implement JIT compiler for extended BPF")
    Reviewed-by: Naveen N. Rao
    Reviewed-by: Sandipan Das
    Tested-by: Sandipan Das
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Daniel Borkmann
     
  • [ Upstream commit 9970a8e40d4c39e23d62d32540366d1d7d2cce9b ]

    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 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: 9d0982927e79 ("netfilter: nft_hash: add support for timeouts")
    Signed-off-by: Taehee Yoo
    Signed-off-by: Pablo Neira Ayuso
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Taehee Yoo
     
  • [ Upstream commit eec24f2a0d4dc3b1d95a3ccd2feb523ede3ba775 ]

    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 14e1d56cbea6 ("usb: gadget: f_uac2: endianness fixes.")
    commit 42370b821168 ("usb: gadget: f_uac1: endianness fixes.")
    commit 63afd5cc7877 ("USB: chaoskey: fix Alea quirk on big-endian hosts")
    commit 74098c4ac782 ("usb: gadget: acm: fix endianness in notifications")
    commit cdd7928df0d2 ("ACM gadget: fix endianness in notifications")
    commit 323ece54e076 ("cdc-wdm: fix endianness bug in debug statements")
    commit e102609f1072 ("usb: gadget: uvc: Fix endianness mismatches")
    list goes on

    Fixes: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver")
    Signed-off-by: Eugeniu Rosca
    Reviewed-by: Ruslan Bilovol
    Signed-off-by: Felipe Balbi

    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Eugeniu Rosca
     
  • [ Upstream commit a2b22dddc7bb6110ac3b5ed1a60aa9279836fadb ]

    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 .

    CC: Thomas Petazzoni
    Signed-off-by: Peter Senna Tschudin
    Signed-off-by: Felipe Balbi
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Peter Senna Tschudin
     
  • [ Upstream commit a39ba90a1cc7010edb0a7132e1b67f3d80b994e9 ]

    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: Randy Dunlap
    Cc: Felipe Balbi
    Cc: linux-usb@vger.kernel.org
    Cc: Michael Ellerman
    Cc: linuxppc-dev@lists.ozlabs.org
    Signed-off-by: Felipe Balbi
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Randy Dunlap
     
  • [ Upstream commit 56bc61587daadef67712068f251c4ef2e3932d94 ]

    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 : [] lr : [] 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: Vladimir Zapolskiy
    [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
    # #include
    # #include
    # +#include
    #
    # #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:
    [] dump_backtrace+0x0/0x364
    [] show_stack+0x14/0x1c
    [] dump_stack+0x108/0x174
    [] print_address_description+0x7c/0x32c
    [] kasan_report+0x324/0x354
    [] __asan_load8+0x24/0x94
    [] u_audio_iso_complete+0x24c/0x520 [u_audio]
    [] usb_gadget_giveback_request+0x480/0x4d0 [udc_core]
    [] usbhsg_queue_done+0x100/0x130 [renesas_usbhs]
    [] usbhsf_pkt_handler+0x1a4/0x298 [renesas_usbhs]
    [] usbhsf_irq_ready+0x128/0x178 [renesas_usbhs]
    [] usbhs_interrupt+0x440/0x490 [renesas_usbhs]
    [] __handle_irq_event_percpu+0x594/0xa58
    [] handle_irq_event_percpu+0x84/0x12c
    [] handle_irq_event+0xb0/0x10c
    [] handle_fasteoi_irq+0x1e0/0x2ec
    [] generic_handle_irq+0x2c/0x44
    [] __handle_domain_irq+0x190/0x194
    [] 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
    [] el1_irq+0xb4/0x12c
    [] cpuidle_enter_state+0x818/0x844
    [] cpuidle_enter+0x18/0x20
    [] call_cpuidle+0x98/0x9c
    [] do_idle+0x214/0x264
    [] cpu_startup_entry+0x20/0x24
    [] rest_init+0x30c/0x320
    [] start_kernel+0x570/0x5b0
    ------

    Fixes: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver")
    Signed-off-by: Eugeniu Rosca
    Signed-off-by: Felipe Balbi
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Vladimir Zapolskiy
     
  • [ Upstream commit 773e53d50e227b0c03d0bb434c1636f6c49c75b2 ]

    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: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver")
    Signed-off-by: Vladimir Zapolskiy
    Signed-off-by: Eugeniu Rosca
    Signed-off-by: Felipe Balbi
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Vladimir Zapolskiy
     
  • [ Upstream commit 96afb54ece0ee903d23a7ac04ddc461413b972c4 ]

    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: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver")
    Signed-off-by: Vladimir Zapolskiy
    Signed-off-by: Eugeniu Rosca
    Signed-off-by: Felipe Balbi
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Vladimir Zapolskiy
     
  • [ Upstream commit 6b37bd78d30c890e575a1bda22978d1d2a233362 ]

    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: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver")
    Signed-off-by: Joshua Frkuska
    Signed-off-by: Eugeniu Rosca
    Signed-off-by: Felipe Balbi
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Joshua Frkuska
     
  • [ Upstream commit dfa042fa310caa475667b8c38d852f14439e0b01 ]

    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 8372d4980fbc ("ALSA: ctxfi - Fix PCM device naming")
    * v4.14 commit 003d3e70dbeb ("ALSA: ad1848: fix format string overflow warning")
    * v4.14 commit 6d8b04de87e1 ("ALSA: cs423x: fix format string overflow warning")

    Fixes: eb9fecb9e69b ("usb: gadget: f_uac2: split out audio core")
    Signed-off-by: Eugeniu Rosca
    Signed-off-by: Felipe Balbi
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Eugeniu Rosca
     
  • [ Upstream commit e87581fe0509020f77ebf0b7c4c1c338c6a4bcf6 ]

    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 f1d3861d63a5 ("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] [] dump_backtrace+0x0/0x364
    [ 728.304808] [] show_stack+0x14/0x1c
    [ 728.310081] [] dump_stack+0x108/0x174
    [ 728.315522] [] kasan_report+0x1fc/0x354
    [ 728.321134] [] __asan_load8+0x24/0x94
    [ 728.326600] [] u_audio_stop_capture+0x70/0x268 [u_audio]
    [ 728.333735] [] afunc_disable+0x44/0x60 [usb_f_uac2]
    [ 728.340503] [] usb_remove_function+0x9c/0x210 [libcomposite]
    [ 728.348060] [] remove_config.isra.2+0x1d8/0x218 [libcomposite]
    [ 728.355788] [] __composite_unbind+0x104/0x1f8 [libcomposite]
    [ 728.363339] [] composite_unbind+0x10/0x18 [libcomposite]
    [ 728.370536] [] usb_gadget_remove_driver+0xc0/0x170 [udc_core]
    [ 728.378172] [] usb_gadget_unregister_driver+0x1cc/0x258 [udc_core]
    [ 728.386274] [] usb_composite_unregister+0x10/0x18 [libcomposite]
    [ 728.394116] [] audio_driver_exit+0x14/0x28 [g_audio]
    [ 728.400878] [] 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] [] 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 : [] lr : [] 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] [] u_audio_stop_capture+0x70/0x268 [u_audio]
    [ 728.936032] [] afunc_disable+0x44/0x60 [usb_f_uac2]
    [ 728.942822] [] usb_remove_function+0x9c/0x210 [libcomposite]
    [ 728.950385] [] remove_config.isra.2+0x1d8/0x218 [libcomposite]
    [ 728.958134] [] __composite_unbind+0x104/0x1f8 [libcomposite]
    [ 728.965689] [] composite_unbind+0x10/0x18 [libcomposite]
    [ 728.972882] [] usb_gadget_remove_driver+0xc0/0x170 [udc_core]
    [ 728.980522] [] usb_gadget_unregister_driver+0x1cc/0x258 [udc_core]
    [ 728.988638] [] usb_composite_unregister+0x10/0x18 [libcomposite]
    [ 728.996472] [] audio_driver_exit+0x14/0x28 [g_audio]
    [ 729.003231] [] 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] [] 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: f1d3861d63a5 ("usb: gadget: f_uac2: fix error handling at afunc_bind")
    Signed-off-by: Eugeniu Rosca
    Signed-off-by: Felipe Balbi
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Eugeniu Rosca
     
  • [ Upstream commit f36b507c14c4b6e634463a610294e9cb0065c8ea ]

    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: Jia-Ju Bai
    Signed-off-by: Felipe Balbi
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jia-Ju Bai
     
  • [ Upstream commit 0602088b10a7c0b4e044a810678ef93d7cc5bf48 ]

    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: Jia-Ju Bai
    Signed-off-by: Felipe Balbi
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Jia-Ju Bai
     
  • [ Upstream commit 8f3ea35929a0806ad1397db99a89ffee0140822a ]

    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: Josef Bacik
    Signed-off-by: Jens Axboe
    Signed-off-by: Sasha Levin
    Signed-off-by: Greg Kroah-Hartman

    Josef Bacik