1. 04 Jan, 2020 40 commits
    • Thomas Richter's avatar
      s390/cpum_sf: Check for SDBT and SDB consistency · 4e61f016
      Thomas Richter authored
      [ Upstream commit 247f265f ]
      
      Each SBDT is located at a 4KB page and contains 512 entries.
      Each entry of a SDBT points to a SDB, a 4KB page containing
      sampled data. The last entry is a link to another SDBT page.
      
      When an event is created the function sequence executed is:
      
        __hw_perf_event_init()
        +--> allocate_buffers()
             +--> realloc_sampling_buffers()
      	    +---> alloc_sample_data_block()
      
      Both functions realloc_sampling_buffers() and
      alloc_sample_data_block() allocate pages and the allocation
      can fail. This is handled correctly and all allocated
      pages are freed and error -ENOMEM is returned to the
      top calling function. Finally the event is not created.
      
      Once the event has been created, the amount of initially
      allocated SDBT and SDB can be too low. This is detected
      during measurement interrupt handling, where the amount
      of lost samples is calculated. If the number of lost samples
      is too high considering sampling frequency and already allocated
      SBDs, the number of SDBs is enlarged during the next execution
      of cpumsf_pmu_enable().
      
      If more SBDs need to be allocated, functions
      
             realloc_sampling_buffers()
             +---> alloc-sample_data_block()
      
      are called to allocate more pages. Page allocation may fail
      and the returned error is ignored. A SDBT and SDB setup
      already exists.
      
      However the modified SDBTs and SDBs might end up in a situation
      where the first entry of an SDBT does not point to an SDB,
      but another SDBT, basicly an SBDT without payload.
      This can not be handled by the interrupt handler, where an SDBT
      must have at least one entry pointing to an SBD.
      
      Add a check to avoid SDBTs with out payload (SDBs) when enlarging
      the buffer setup.
      Signed-off-by: default avatarThomas Richter <tmricht@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4e61f016
    • Masahiro Yamada's avatar
      libfdt: define INT32_MAX and UINT32_MAX in libfdt_env.h · 5772cc66
      Masahiro Yamada authored
      [ Upstream commit a8de1304 ]
      
      The DTC v1.5.1 added references to (U)INT32_MAX.
      
      This is no problem for user-space programs since <stdint.h> defines
      (U)INT32_MAX along with (u)int32_t.
      
      For the kernel space, libfdt_env.h needs to be adjusted before we
      pull in the changes.
      
      In the kernel, we usually use s/u32 instead of (u)int32_t for the
      fixed-width types.
      
      Accordingly, we already have S/U32_MAX for their max values.
      So, we should not add (U)INT32_MAX to <linux/limits.h> any more.
      
      Instead, add them to the in-kernel libfdt_env.h to compile the
      latest libfdt.
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5772cc66
    • Harald Freudenberger's avatar
      s390/zcrypt: handle new reply code FILTERED_BY_HYPERVISOR · a5867bb1
      Harald Freudenberger authored
      [ Upstream commit 6733775a ]
      
      This patch introduces support for a new architectured reply
      code 0x8B indicating that a hypervisor layer (if any) has
      rejected an ap message.
      
      Linux may run as a guest on top of a hypervisor like zVM
      or KVM. So the crypto hardware seen by the ap bus may be
      restricted by the hypervisor for example only a subset like
      only clear key crypto requests may be supported. Other
      requests will be filtered out - rejected by the hypervisor.
      The new reply code 0x8B will appear in such cases and needs
      to get recognized by the ap bus and zcrypt device driver zoo.
      Signed-off-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a5867bb1
    • Arnaldo Carvalho de Melo's avatar
      perf regs: Make perf_reg_name() return "unknown" instead of NULL · b5208263
      Arnaldo Carvalho de Melo authored
      [ Upstream commit 5b596e0f ]
      
      To avoid breaking the build on arches where this is not wired up, at
      least all the other features should be made available and when using
      this specific routine, the "unknown" should point the user/developer to
      the need to wire this up on this particular hardware architecture.
      
      Detected in a container mipsel debian cross build environment, where it
      shows up as:
      
        In file included from /usr/mipsel-linux-gnu/include/stdio.h:867,
                         from /git/linux/tools/perf/lib/include/perf/cpumap.h:6,
                         from util/session.c:13:
        In function 'printf',
            inlined from 'regs_dump__printf' at util/session.c:1103:3,
            inlined from 'regs__printf' at util/session.c:1131:2:
        /usr/mipsel-linux-gnu/include/bits/stdio2.h:107:10: error: '%-5s' directive argument is null [-Werror=format-overflow=]
          107 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
              |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      cross compiler details:
      
        mipsel-linux-gnu-gcc (Debian 9.2.1-8) 9.2.1 20190909
      
      Also on mips64:
      
        In file included from /usr/mips64-linux-gnuabi64/include/stdio.h:867,
                         from /git/linux/tools/perf/lib/include/perf/cpumap.h:6,
                         from util/session.c:13:
        In function 'printf',
            inlined from 'regs_dump__printf' at util/session.c:1103:3,
            inlined from 'regs__printf' at util/session.c:1131:2,
            inlined from 'regs_user__printf' at util/session.c:1139:3,
            inlined from 'dump_sample' at util/session.c:1246:3,
            inlined from 'machines__deliver_event' at util/session.c:1421:3:
        /usr/mips64-linux-gnuabi64/include/bits/stdio2.h:107:10: error: '%-5s' directive argument is null [-Werror=format-overflow=]
          107 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
              |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        In function 'printf',
            inlined from 'regs_dump__printf' at util/session.c:1103:3,
            inlined from 'regs__printf' at util/session.c:1131:2,
            inlined from 'regs_intr__printf' at util/session.c:1147:3,
            inlined from 'dump_sample' at util/session.c:1249:3,
            inlined from 'machines__deliver_event' at util/session.c:1421:3:
        /usr/mips64-linux-gnuabi64/include/bits/stdio2.h:107:10: error: '%-5s' directive argument is null [-Werror=format-overflow=]
          107 |   return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
              |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      cross compiler details:
      
        mips64-linux-gnuabi64-gcc (Debian 9.2.1-8) 9.2.1 20190909
      
      Fixes: 2bcd355b ("perf tools: Add interface to arch registers sets")
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-95wjyv4o65nuaeweq31t7l1s@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b5208263
    • Adrian Hunter's avatar
      perf script: Fix brstackinsn for AUXTRACE · 0d1472cd
      Adrian Hunter authored
      [ Upstream commit 0cd032d3 ]
      
      brstackinsn must be allowed to be set by the user when AUX area data has
      been captured because, in that case, the branch stack might be
      synthesized on the fly. This fixes the following error:
      
      Before:
      
        $ perf record -e '{intel_pt//,cpu/mem_inst_retired.all_loads,aux-sample-size=8192/pp}:u' grep -rqs jhgjhg /boot
        [ perf record: Woken up 19 times to write data ]
        [ perf record: Captured and wrote 2.274 MB perf.data ]
        $ perf script -F +brstackinsn --xed --itrace=i1usl100 | head
        Display of branch stack assembler requested, but non all-branch filter set
        Hint: run 'perf record -b ...'
      
      After:
      
        $ perf record -e '{intel_pt//,cpu/mem_inst_retired.all_loads,aux-sample-size=8192/pp}:u' grep -rqs jhgjhg /boot
        [ perf record: Woken up 19 times to write data ]
        [ perf record: Captured and wrote 2.274 MB perf.data ]
        $ perf script -F +brstackinsn --xed --itrace=i1usl100 | head
                  grep 13759 [002]  8091.310257:       1862                                        instructions:uH:      5641d58069eb bmexec+0x86b (/bin/grep)
              bmexec+2485:
              00005641d5806b35                        jnz 0x5641d5806bd0              # MISPRED
              00005641d5806bd0                        movzxb  (%r13,%rdx,1), %eax
              00005641d5806bd6                        add %rdi, %rax
              00005641d5806bd9                        movzxb  -0x1(%rax), %edx
              00005641d5806bdd                        cmp %rax, %r14
              00005641d5806be0                        jnb 0x5641d58069c0              # MISPRED
              mismatch of LBR data and executable
              00005641d58069c0                        movzxb  (%r13,%rdx,1), %edi
      
      Fixes: 48d02a1d ("perf script: Add 'brstackinsn' for branch stacks")
      Reported-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lore.kernel.org/lkml/20191127095322.15417-1-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0d1472cd
    • Diego Elio Pettenò's avatar
      cdrom: respect device capabilities during opening action · d84fd0cb
      Diego Elio Pettenò authored
      [ Upstream commit 366ba7c7 ]
      
      Reading the TOC only works if the device can play audio, otherwise
      these commands fail (and possibly bring the device to an unhealthy
      state.)
      
      Similarly, cdrom_mmc3_profile() should only be called if the device
      supports generic packet commands.
      
      To: Jens Axboe <axboe@kernel.dk>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-scsi@vger.kernel.org
      Signed-off-by: default avatarDiego Elio Pettenò <flameeyes@flameeyes.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d84fd0cb
    • Nathan Chancellor's avatar
      powerpc: Don't add -mabi= flags when building with Clang · 593a5505
      Nathan Chancellor authored
      [ Upstream commit 465bfd9c ]
      
      When building pseries_defconfig, building vdso32 errors out:
      
        error: unknown target ABI 'elfv1'
      
      This happens because -m32 in clang changes the target to 32-bit,
      which does not allow the ABI to be changed.
      
      Commit 4dc831aa ("powerpc: Fix compiling a BE kernel with a
      powerpc64le toolchain") added these flags to fix building big endian
      kernels with a little endian GCC.
      
      Clang doesn't need -mabi because the target triple controls the
      default value. -mlittle-endian and -mbig-endian manipulate the triple
      into either powerpc64-* or powerpc64le-*, which properly sets the
      default ABI.
      
      Adding a debug print out in the PPC64TargetInfo constructor after line
      383 above shows this:
      
        $ echo | ./clang -E --target=powerpc64-linux -mbig-endian -o /dev/null -
        Default ABI: elfv1
      
        $ echo | ./clang -E --target=powerpc64-linux -mlittle-endian -o /dev/null -
        Default ABI: elfv2
      
        $ echo | ./clang -E --target=powerpc64le-linux -mbig-endian -o /dev/null -
        Default ABI: elfv1
      
        $ echo | ./clang -E --target=powerpc64le-linux -mlittle-endian -o /dev/null -
        Default ABI: elfv2
      
      Don't specify -mabi when building with clang to avoid the build error
      with -m32 and not change any code generation.
      
      -mcall-aixdesc is not an implemented flag in clang so it can be safely
      excluded as well, see commit 238abecd ("powerpc: Don't use gcc
      specific options on clang").
      
      pseries_defconfig successfully builds after this patch and
      powernv_defconfig and ppc44x_defconfig don't regress.
      Reviewed-by: default avatarDaniel Axtens <dja@axtens.net>
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      [mpe: Trim clang links in change log]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20191119045712.39633-2-natechancellor@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      593a5505
    • Masahiro Yamada's avatar
      scripts/kallsyms: fix definitely-lost memory leak · e9bcb924
      Masahiro Yamada authored
      [ Upstream commit 21915eca ]
      
      build_initial_tok_table() overwrites unused sym_entry to shrink the
      table size. Before the entry is overwritten, table[i].sym must be freed
      since it is malloc'ed data.
      
      This fixes the 'definitely lost' report from valgrind. I ran valgrind
      against x86_64_defconfig of v5.4-rc8 kernel, and here is the summary:
      
      [Before the fix]
      
        LEAK SUMMARY:
           definitely lost: 53,184 bytes in 2,874 blocks
      
      [After the fix]
      
        LEAK SUMMARY:
           definitely lost: 0 bytes in 0 blocks
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e9bcb924
    • Colin Ian King's avatar
      apparmor: fix unsigned len comparison with less than zero · 79a1eae9
      Colin Ian King authored
      [ Upstream commit 00e0590d ]
      
      The sanity check in macro update_for_len checks to see if len
      is less than zero, however, len is a size_t so it can never be
      less than zero, so this sanity check is a no-op.  Fix this by
      making len a ssize_t so the comparison will work and add ulen
      that is a size_t copy of len so that the min() macro won't
      throw warnings about comparing different types.
      
      Addresses-Coverity: ("Macro compares unsigned to 0")
      Fixes: f1bd9041 ("apparmor: add the base fns() for domain labels")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      79a1eae9
    • Vladimir Oltean's avatar
      gpio: mpc8xxx: Don't overwrite default irq_set_type callback · dcf1f67c
      Vladimir Oltean authored
      [ Upstream commit 4e50573f ]
      
      The per-SoC devtype structures can contain their own callbacks that
      overwrite mpc8xxx_gpio_devtype_default.
      
      The clear intention is that mpc8xxx_irq_set_type is used in case the SoC
      does not specify a more specific callback. But what happens is that if
      the SoC doesn't specify one, its .irq_set_type is de-facto NULL, and
      this overwrites mpc8xxx_irq_set_type to a no-op. This means that the
      following SoCs are affected:
      
      - fsl,mpc8572-gpio
      - fsl,ls1028a-gpio
      - fsl,ls1088a-gpio
      
      On these boards, the irq_set_type does exactly nothing, and the GPIO
      controller keeps its GPICR register in the hardware-default state. On
      the LS1028A, that is ACTIVE_BOTH, which means 2 interrupts are raised
      even if the IRQ client requests LEVEL_HIGH. Another implication is that
      the IRQs are not checked (e.g. level-triggered interrupts are not
      rejected, although they are not supported).
      
      Fixes: 82e39b0d ("gpio: mpc8xxx: handle differences between incarnations at a single place")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Link: https://lore.kernel.org/r/20191115125551.31061-1-olteanv@gmail.comTested-by: default avatarMichael Walle <michael@walle.cc>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dcf1f67c
    • Bart Van Assche's avatar
      scsi: target: iscsi: Wait for all commands to finish before freeing a session · b0aede21
      Bart Van Assche authored
      [ Upstream commit e9d3009c ]
      
      The iSCSI target driver is the only target driver that does not wait for
      ongoing commands to finish before freeing a session. Make the iSCSI target
      driver wait for ongoing commands to finish before freeing a session. This
      patch fixes the following KASAN complaint:
      
      BUG: KASAN: use-after-free in __lock_acquire+0xb1a/0x2710
      Read of size 8 at addr ffff8881154eca70 by task kworker/0:2/247
      
      CPU: 0 PID: 247 Comm: kworker/0:2 Not tainted 5.4.0-rc1-dbg+ #6
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
      Workqueue: target_completion target_complete_ok_work [target_core_mod]
      Call Trace:
       dump_stack+0x8a/0xd6
       print_address_description.constprop.0+0x40/0x60
       __kasan_report.cold+0x1b/0x33
       kasan_report+0x16/0x20
       __asan_load8+0x58/0x90
       __lock_acquire+0xb1a/0x2710
       lock_acquire+0xd3/0x200
       _raw_spin_lock_irqsave+0x43/0x60
       target_release_cmd_kref+0x162/0x7f0 [target_core_mod]
       target_put_sess_cmd+0x2e/0x40 [target_core_mod]
       lio_check_stop_free+0x12/0x20 [iscsi_target_mod]
       transport_cmd_check_stop_to_fabric+0xd8/0xe0 [target_core_mod]
       target_complete_ok_work+0x1b0/0x790 [target_core_mod]
       process_one_work+0x549/0xa40
       worker_thread+0x7a/0x5d0
       kthread+0x1bc/0x210
       ret_from_fork+0x24/0x30
      
      Allocated by task 889:
       save_stack+0x23/0x90
       __kasan_kmalloc.constprop.0+0xcf/0xe0
       kasan_slab_alloc+0x12/0x20
       kmem_cache_alloc+0xf6/0x360
       transport_alloc_session+0x29/0x80 [target_core_mod]
       iscsi_target_login_thread+0xcd6/0x18f0 [iscsi_target_mod]
       kthread+0x1bc/0x210
       ret_from_fork+0x24/0x30
      
      Freed by task 1025:
       save_stack+0x23/0x90
       __kasan_slab_free+0x13a/0x190
       kasan_slab_free+0x12/0x20
       kmem_cache_free+0x146/0x400
       transport_free_session+0x179/0x2f0 [target_core_mod]
       transport_deregister_session+0x130/0x180 [target_core_mod]
       iscsit_close_session+0x12c/0x350 [iscsi_target_mod]
       iscsit_logout_post_handler+0x136/0x380 [iscsi_target_mod]
       iscsit_response_queue+0x8de/0xbe0 [iscsi_target_mod]
       iscsi_target_tx_thread+0x27f/0x370 [iscsi_target_mod]
       kthread+0x1bc/0x210
       ret_from_fork+0x24/0x30
      
      The buggy address belongs to the object at ffff8881154ec9c0
       which belongs to the cache se_sess_cache of size 352
      The buggy address is located 176 bytes inside of
       352-byte region [ffff8881154ec9c0, ffff8881154ecb20)
      The buggy address belongs to the page:
      page:ffffea0004553b00 refcount:1 mapcount:0 mapping:ffff888101755400 index:0x0 compound_mapcount: 0
      flags: 0x2fff000000010200(slab|head)
      raw: 2fff000000010200 dead000000000100 dead000000000122 ffff888101755400
      raw: 0000000000000000 0000000080130013 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff8881154ec900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff8881154ec980: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
      >ffff8881154eca00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                                   ^
       ffff8881154eca80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff8881154ecb00: fb fb fb fb fc fc fc fc fc fc fc fc fc fc fc fc
      
      Cc: Mike Christie <mchristi@redhat.com>
      Link: https://lore.kernel.org/r/20191113220508.198257-3-bvanassche@acm.orgReviewed-by: default avatarRoman Bolshakov <r.bolshakov@yadro.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b0aede21
    • Anatol Pomazau's avatar
      scsi: iscsi: Don't send data to unbound connection · c007a55d
      Anatol Pomazau authored
      [ Upstream commit 238191d6 ]
      
      If a faulty initiator fails to bind the socket to the iSCSI connection
      before emitting a command, for instance, a subsequent send_pdu, it will
      crash the kernel due to a null pointer dereference in sock_sendmsg(), as
      shown in the log below.  This patch makes sure the bind succeeded before
      trying to use the socket.
      
      BUG: kernel NULL pointer dereference, address: 0000000000000018
       #PF: supervisor read access in kernel mode
       #PF: error_code(0x0000) - not-present page
      PGD 0 P4D 0
      Oops: 0000 [#1] SMP PTI
      CPU: 3 PID: 7 Comm: kworker/u8:0 Not tainted 5.4.0-rc2.iscsi+ #13
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
      [   24.158246] Workqueue: iscsi_q_0 iscsi_xmitworker
      [   24.158883] RIP: 0010:apparmor_socket_sendmsg+0x5/0x20
      [...]
      [   24.161739] RSP: 0018:ffffab6440043ca0 EFLAGS: 00010282
      [   24.162400] RAX: ffffffff891c1c00 RBX: ffffffff89d53968 RCX: 0000000000000001
      [   24.163253] RDX: 0000000000000030 RSI: ffffab6440043d00 RDI: 0000000000000000
      [   24.164104] RBP: 0000000000000030 R08: 0000000000000030 R09: 0000000000000030
      [   24.165166] R10: ffffffff893e66a0 R11: 0000000000000018 R12: ffffab6440043d00
      [   24.166038] R13: 0000000000000000 R14: 0000000000000000 R15: ffff9d5575a62e90
      [   24.166919] FS:  0000000000000000(0000) GS:ffff9d557db80000(0000) knlGS:0000000000000000
      [   24.167890] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   24.168587] CR2: 0000000000000018 CR3: 000000007a838000 CR4: 00000000000006e0
      [   24.169451] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [   24.170320] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [   24.171214] Call Trace:
      [   24.171537]  security_socket_sendmsg+0x3a/0x50
      [   24.172079]  sock_sendmsg+0x16/0x60
      [   24.172506]  iscsi_sw_tcp_xmit_segment+0x77/0x120
      [   24.173076]  iscsi_sw_tcp_pdu_xmit+0x58/0x170
      [   24.173604]  ? iscsi_dbg_trace+0x63/0x80
      [   24.174087]  iscsi_tcp_task_xmit+0x101/0x280
      [   24.174666]  iscsi_xmit_task+0x83/0x110
      [   24.175206]  iscsi_xmitworker+0x57/0x380
      [   24.175757]  ? __schedule+0x2a2/0x700
      [   24.176273]  process_one_work+0x1b5/0x360
      [   24.176837]  worker_thread+0x50/0x3c0
      [   24.177353]  kthread+0xf9/0x130
      [   24.177799]  ? process_one_work+0x360/0x360
      [   24.178401]  ? kthread_park+0x90/0x90
      [   24.178915]  ret_from_fork+0x35/0x40
      [   24.179421] Modules linked in:
      [   24.179856] CR2: 0000000000000018
      [   24.180327] ---[ end trace b4b7674b6df5f480 ]---
      Signed-off-by: default avatarAnatol Pomazau <anatol@google.com>
      Co-developed-by: default avatarFrank Mayhar <fmayhar@google.com>
      Signed-off-by: default avatarFrank Mayhar <fmayhar@google.com>
      Co-developed-by: default avatarBharath Ravi <rbharath@google.com>
      Signed-off-by: default avatarBharath Ravi <rbharath@google.com>
      Co-developed-by: default avatarKhazhimsel Kumykov <khazhy@google.com>
      Signed-off-by: default avatarKhazhimsel Kumykov <khazhy@google.com>
      Co-developed-by: default avatarGabriel Krisman Bertazi <krisman@collabora.com>
      Signed-off-by: default avatarGabriel Krisman Bertazi <krisman@collabora.com>
      Reviewed-by: default avatarLee Duncan <lduncan@suse.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c007a55d
    • Finn Thain's avatar
      scsi: NCR5380: Add disconnect_mask module parameter · 0ebfc037
      Finn Thain authored
      [ Upstream commit 0b7a2235 ]
      
      Add a module parameter to inhibit disconnect/reselect for individual
      targets. This gains compatibility with Aztec PowerMonster SCSI/SATA
      adapters with buggy firmware. (No fix is available from the vendor.)
      
      Apparently these adapters pass-through the product/vendor of the attached
      SATA device. Since they can't be identified from the response to an INQUIRY
      command, a device blacklist flag won't work.
      
      Cc: Michael Schmitz <schmitzmic@gmail.com>
      Link: https://lore.kernel.org/r/993b17545990f31f9fa5a98202b51102a68e7594.1573875417.git.fthain@telegraphics.com.auReviewed-and-tested-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0ebfc037
    • Maurizio Lombardi's avatar
      scsi: scsi_debug: num_tgts must be >= 0 · 1b4128a5
      Maurizio Lombardi authored
      [ Upstream commit aa5334c4 ]
      
      Passing the parameter "num_tgts=-1" will start an infinite loop that
      exhausts the system memory
      
      Link: https://lore.kernel.org/r/20191115163727.24626-1-mlombard@redhat.comSigned-off-by: default avatarMaurizio Lombardi <mlombard@redhat.com>
      Acked-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1b4128a5
    • Subhash Jadavani's avatar
      scsi: ufs: Fix error handing during hibern8 enter · a4c9fd61
      Subhash Jadavani authored
      [ Upstream commit 6d303e4b ]
      
      During clock gating (ufshcd_gate_work()), we first put the link hibern8 by
      calling ufshcd_uic_hibern8_enter() and if ufshcd_uic_hibern8_enter()
      returns success (0) then we gate all the clocks.  Now let’s zoom in to what
      ufshcd_uic_hibern8_enter() does internally: It calls
      __ufshcd_uic_hibern8_enter() and if failure is encountered, link recovery
      shall put the link back to the highest HS gear and returns success (0) to
      ufshcd_uic_hibern8_enter() which is the issue as link is still in active
      state due to recovery!  Now ufshcd_uic_hibern8_enter() returns success to
      ufshcd_gate_work() and hence it goes ahead with gating the UFS clock while
      link is still in active state hence I believe controller would raise UIC
      error interrupts. But when we service the interrupt, clocks might have
      already been disabled!
      
      This change fixes for this by returning failure from
      __ufshcd_uic_hibern8_enter() if recovery succeeds as link is still not in
      hibern8, upon receiving the error ufshcd_hibern8_enter() would initiate
      retry to put the link state back into hibern8.
      
      Link: https://lore.kernel.org/r/1573798172-20534-8-git-send-email-cang@codeaurora.orgReviewed-by: default avatarAvri Altman <avri.altman@wdc.com>
      Reviewed-by: default avatarBean Huo <beanhuo@micron.com>
      Signed-off-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
      Signed-off-by: default avatarCan Guo <cang@codeaurora.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a4c9fd61
    • peter chang's avatar
      scsi: pm80xx: Fix for SATA device discovery · c153c121
      peter chang authored
      [ Upstream commit ce21c63e ]
      
      Driver was missing complete() call in mpi_sata_completion which result in
      SATA abort error handling timing out. That causes the device to be left in
      the in_recovery state so subsequent commands sent to the device fail and
      the OS removes access to it.
      
      Link: https://lore.kernel.org/r/20191114100910.6153-2-deepak.ukey@microchip.comAcked-by: default avatarJack Wang <jinpu.wang@cloud.ionos.com>
      Signed-off-by: default avatarpeter chang <dpf@google.com>
      Signed-off-by: default avatarDeepak Ukey <deepak.ukey@microchip.com>
      Signed-off-by: default avatarViswas G <Viswas.G@microchip.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c153c121
    • Kevin Hao's avatar
      watchdog: Fix the race between the release of watchdog_core_data and cdev · f4c36f19
      Kevin Hao authored
      [ Upstream commit 72139dfa ]
      
      The struct cdev is embedded in the struct watchdog_core_data. In the
      current code, we manage the watchdog_core_data with a kref, but the
      cdev is manged by a kobject. There is no any relationship between
      this kref and kobject. So it is possible that the watchdog_core_data is
      freed before the cdev is entirely released. We can easily get the
      following call trace with CONFIG_DEBUG_KOBJECT_RELEASE and
      CONFIG_DEBUG_OBJECTS_TIMERS enabled.
        ODEBUG: free active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x38
        WARNING: CPU: 23 PID: 1028 at lib/debugobjects.c:481 debug_print_object+0xb0/0xf0
        Modules linked in: softdog(-) deflate ctr twofish_generic twofish_common camellia_generic serpent_generic blowfish_generic blowfish_common cast5_generic cast_common cmac xcbc af_key sch_fq_codel openvswitch nsh nf_conncount nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4
        CPU: 23 PID: 1028 Comm: modprobe Not tainted 5.3.0-next-20190924-yoctodev-standard+ #180
        Hardware name: Marvell OcteonTX CN96XX board (DT)
        pstate: 00400009 (nzcv daif +PAN -UAO)
        pc : debug_print_object+0xb0/0xf0
        lr : debug_print_object+0xb0/0xf0
        sp : ffff80001cbcfc70
        x29: ffff80001cbcfc70 x28: ffff800010ea2128
        x27: ffff800010bad000 x26: 0000000000000000
        x25: ffff80001103c640 x24: ffff80001107b268
        x23: ffff800010bad9e8 x22: ffff800010ea2128
        x21: ffff000bc2c62af8 x20: ffff80001103c600
        x19: ffff800010e867d8 x18: 0000000000000060
        x17: 0000000000000000 x16: 0000000000000000
        x15: ffff000bd7240470 x14: 6e6968207473696c
        x13: 5f72656d6974203a x12: 6570797420746365
        x11: 6a626f2029302065 x10: 7461747320657669
        x9 : 7463612820657669 x8 : 3378302f3078302b
        x7 : 0000000000001d7a x6 : ffff800010fd5889
        x5 : 0000000000000000 x4 : 0000000000000000
        x3 : 0000000000000000 x2 : ffff000bff948548
        x1 : 276a1c9e1edc2300 x0 : 0000000000000000
        Call trace:
         debug_print_object+0xb0/0xf0
         debug_check_no_obj_freed+0x1e8/0x210
         kfree+0x1b8/0x368
         watchdog_cdev_unregister+0x88/0xc8
         watchdog_dev_unregister+0x38/0x48
         watchdog_unregister_device+0xa8/0x100
         softdog_exit+0x18/0xfec4 [softdog]
         __arm64_sys_delete_module+0x174/0x200
         el0_svc_handler+0xd0/0x1c8
         el0_svc+0x8/0xc
      
      This is a common issue when using cdev embedded in a struct.
      Fortunately, we already have a mechanism to solve this kind of issue.
      Please see commit 233ed09d ("chardev: add helper function to
      register char devs with a struct device") for more detail.
      
      In this patch, we choose to embed the struct device into the
      watchdog_core_data, and use the API provided by the commit 233ed09d
      to make sure that the release of watchdog_core_data and cdev are
      in sequence.
      Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Link: https://lore.kernel.org/r/20191008112934.29669-1-haokexin@gmail.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f4c36f19
    • Andrew Duggan's avatar
      HID: rmi: Check that the RMI_STARTED bit is set before unregistering the RMI transport device · f573f404
      Andrew Duggan authored
      [ Upstream commit 8725aa4f ]
      
      In the event that the RMI device is unreachable, the calls to rmi_set_mode() or
      rmi_set_page() will fail before registering the RMI transport device. When the
      device is removed, rmi_remove() will call rmi_unregister_transport_device()
      which will attempt to access the rmi_dev pointer which was not set.
      This patch adds a check of the RMI_STARTED bit before calling
      rmi_unregister_transport_device().  The RMI_STARTED bit is only set
      after rmi_register_transport_device() completes successfully.
      
      The kernel oops was reported in this message:
      https://www.spinics.net/lists/linux-input/msg58433.html
      
      [jkosina@suse.cz: reworded changelog as agreed with Andrew]
      Signed-off-by: default avatarAndrew Duggan <aduggan@synaptics.com>
      Reported-by: default avatarFederico Cerutti <federico@ceres-c.it>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f573f404
    • Blaž Hrastnik's avatar
      HID: Improve Windows Precision Touchpad detection. · 51ade3d1
      Blaž Hrastnik authored
      [ Upstream commit 2dbc6f11 ]
      
      Per Microsoft spec, usage 0xC5 (page 0xFF) returns a blob containing
      data used to verify the touchpad as a Windows Precision Touchpad.
      
         0x85, REPORTID_PTPHQA,    //    REPORT_ID (PTPHQA)
          0x09, 0xC5,              //    USAGE (Vendor Usage 0xC5)
          0x15, 0x00,              //    LOGICAL_MINIMUM (0)
          0x26, 0xff, 0x00,        //    LOGICAL_MAXIMUM (0xff)
          0x75, 0x08,              //    REPORT_SIZE (8)
          0x96, 0x00, 0x01,        //    REPORT_COUNT (0x100 (256))
          0xb1, 0x02,              //    FEATURE (Data,Var,Abs)
      
      However, some devices, namely Microsoft's Surface line of products
      instead implement a "segmented device certification report" (usage 0xC6)
      which returns the same report, but in smaller chunks.
      
          0x06, 0x00, 0xff,        //     USAGE_PAGE (Vendor Defined)
          0x85, REPORTID_PTPHQA,   //     REPORT_ID (PTPHQA)
          0x09, 0xC6,              //     USAGE (Vendor usage for segment #)
          0x25, 0x08,              //     LOGICAL_MAXIMUM (8)
          0x75, 0x08,              //     REPORT_SIZE (8)
          0x95, 0x01,              //     REPORT_COUNT (1)
          0xb1, 0x02,              //     FEATURE (Data,Var,Abs)
          0x09, 0xC7,              //     USAGE (Vendor Usage)
          0x26, 0xff, 0x00,        //     LOGICAL_MAXIMUM (0xff)
          0x95, 0x20,              //     REPORT_COUNT (32)
          0xb1, 0x02,              //     FEATURE (Data,Var,Abs)
      
      By expanding Win8 touchpad detection to also look for the segmented
      report, all Surface touchpads are now properly recognized by
      hid-multitouch.
      Signed-off-by: default avatarBlaž Hrastnik <blaz@mxxn.io>
      Signed-off-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      51ade3d1
    • Qian Cai's avatar
      libnvdimm/btt: fix variable 'rc' set but not used · fc7b2a29
      Qian Cai authored
      [ Upstream commit 4e24e37d ]
      
      drivers/nvdimm/btt.c: In function 'btt_read_pg':
      drivers/nvdimm/btt.c:1264:8: warning: variable 'rc' set but not used
      [-Wunused-but-set-variable]
          int rc;
              ^~
      
      Add a ratelimited message in case a storm of errors is encountered.
      
      Fixes: d9b83c75 ("libnvdimm, btt: rework error clearing")
      Signed-off-by: default avatarQian Cai <cai@lca.pw>
      Reviewed-by: default avatarVishal Verma <vishal.l.verma@intel.com>
      Link: https://lore.kernel.org/r/1572530719-32161-1-git-send-email-cai@lca.pwSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fc7b2a29
    • Doug Berger's avatar
      ARM: 8937/1: spectre-v2: remove Brahma-B53 from hardening · 18f3ad4b
      Doug Berger authored
      [ Upstream commit 4ae5061a ]
      
      When the default processor handling was added to the function
      cpu_v7_spectre_init() it only excluded other ARM implemented processor
      cores. The Broadcom Brahma B53 core is not implemented by ARM so it
      ended up falling through into the set of processors that attempt to use
      the ARM_SMCCC_ARCH_WORKAROUND_1 service to harden the branch predictor.
      
      Since this workaround is not necessary for the Brahma-B53 this commit
      explicitly checks for it and prevents it from applying a branch
      predictor hardening workaround.
      
      Fixes: 10115105 ("ARM: spectre-v2: add firmware based hardening")
      Signed-off-by: default avatarDoug Berger <opendmb@gmail.com>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18f3ad4b
    • Hans de Goede's avatar
      HID: logitech-hidpp: Silence intermittent get_battery_capacity errors · f490b51a
      Hans de Goede authored
      [ Upstream commit 61005d65 ]
      
      My Logitech M185 (PID:4038) 2.4 GHz wireless HID++ mouse is causing
      intermittent errors like these in the log:
      
      [11091.034857] logitech-hidpp-device 0003:046D:4038.0006: hidpp20_batterylevel_get_battery_capacity: received protocol error 0x09
      [12388.031260] logitech-hidpp-device 0003:046D:4038.0006: hidpp20_batterylevel_get_battery_capacity: received protocol error 0x09
      [16613.718543] logitech-hidpp-device 0003:046D:4038.0006: hidpp20_batterylevel_get_battery_capacity: received protocol error 0x09
      [23529.938728] logitech-hidpp-device 0003:046D:4038.0006: hidpp20_batterylevel_get_battery_capacity: received protocol error 0x09
      
      We are already silencing error-code 0x09 (HIDPP_ERROR_RESOURCE_ERROR)
      errors in other places, lets do the same in
      hidpp20_batterylevel_get_battery_capacity to remove these harmless,
      but scary looking errors from the dmesg output.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f490b51a
    • Jinke Fan's avatar
      HID: quirks: Add quirk for HP MSU1465 PIXART OEM mouse · a6d05d75
      Jinke Fan authored
      [ Upstream commit f1a0094c ]
      
      The PixArt OEM mouse disconnets/reconnects every minute on
      Linux. All contents of dmesg are repetitive:
      
      [ 1465.810014] usb 1-2.2: USB disconnect, device number 20
      [ 1467.431509] usb 1-2.2: new low-speed USB device number 21 using xhci_hcd
      [ 1467.654982] usb 1-2.2: New USB device found, idVendor=03f0,idProduct=1f4a, bcdDevice= 1.00
      [ 1467.654985] usb 1-2.2: New USB device strings: Mfr=1, Product=2,SerialNumber=0
      [ 1467.654987] usb 1-2.2: Product: HP USB Optical Mouse
      [ 1467.654988] usb 1-2.2: Manufacturer: PixArt
      [ 1467.699722] input: PixArt HP USB Optical Mouse as /devices/pci0000:00/0000:00:07.1/0000:05:00.3/usb1/1-2/1-2.2/1-2.2:1.0/0003:03F0:1F4A.0012/input/input19
      [ 1467.700124] hid-generic 0003:03F0:1F4A.0012: input,hidraw0: USB HID v1.11 Mouse [PixArt HP USB Optical Mouse] on usb-0000:05:00.3-2.2/input0
      
      So add HID_QUIRK_ALWAYS_POLL for this one as well.
      Test the patch, the mouse is no longer disconnected and there are no
      duplicate logs in dmesg.
      
      Reference:
      https://github.com/sriemer/fix-linux-mouseSigned-off-by: default avatarJinke Fan <fanjinke@hygon.cn>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a6d05d75
    • Coly Li's avatar
      bcache: at least try to shrink 1 node in bch_mca_scan() · 247acf43
      Coly Li authored
      [ Upstream commit 9fcc34b1 ]
      
      In bch_mca_scan(), the number of shrinking btree node is calculated
      by code like this,
      	unsigned long nr = sc->nr_to_scan;
      
              nr /= c->btree_pages;
              nr = min_t(unsigned long, nr, mca_can_free(c));
      variable sc->nr_to_scan is number of objects (here is bcache B+tree
      nodes' number) to shrink, and pointer variable sc is sent from memory
      management code as parametr of a callback.
      
      If sc->nr_to_scan is smaller than c->btree_pages, after the above
      calculation, variable 'nr' will be 0 and nothing will be shrunk. It is
      frequeently observed that only 1 or 2 is set to sc->nr_to_scan and make
      nr to be zero. Then bch_mca_scan() will do nothing more then acquiring
      and releasing mutex c->bucket_lock.
      
      This patch checkes whether nr is 0 after the above calculation, if 0
      is the result then set 1 to variable 'n'. Then at least bch_mca_scan()
      will try to shrink a single B+tree node.
      Signed-off-by: default avatarColy Li <colyli@suse.de>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      247acf43
    • Robert Jarzmik's avatar
      clk: pxa: fix one of the pxa RTC clocks · 468e5cb0
      Robert Jarzmik authored
      [ Upstream commit 46acbcb4 ]
      
      The pxa27x platforms have a single IP with 2 drivers, sa1100-rtc and
      rtc-pxa drivers.
      
      A previous patch fixed the sa1100-rtc case, but the pxa-rtc wasn't
      fixed. This patch completes the previous one.
      
      Fixes: 8b6d1034 ("clk: pxa: add missing pxa27x clocks for Irda and sa1100-rtc")
      Signed-off-by: default avatarRobert Jarzmik <robert.jarzmik@free.fr>
      Link: https://lkml.kernel.org/r/20191026194420.11918-1-robert.jarzmik@free.frSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      468e5cb0
    • Finn Thain's avatar
      scsi: atari_scsi: sun3_scsi: Set sg_tablesize to 1 instead of SG_NONE · 6540d3af
      Finn Thain authored
      [ Upstream commit 79172ab2 ]
      
      Since the scsi subsystem adopted the blk-mq API, a host with zero
      sg_tablesize crashes with a NULL pointer dereference.
      
      blk_queue_max_segments: set to minimum 1
      scsi 0:0:0:0: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
      scsi target0:0:0: Beginning Domain Validation
      scsi target0:0:0: Domain Validation skipping write tests
      scsi target0:0:0: Ending Domain Validation
      blk_queue_max_segments: set to minimum 1
      scsi 0:0:1:0: Direct-Access     QEMU     QEMU HARDDISK    2.5+ PQ: 0 ANSI: 5
      scsi target0:0:1: Beginning Domain Validation
      scsi target0:0:1: Domain Validation skipping write tests
      scsi target0:0:1: Ending Domain Validation
      blk_queue_max_segments: set to minimum 1
      scsi 0:0:2:0: CD-ROM            QEMU     QEMU CD-ROM      2.5+ PQ: 0 ANSI: 5
      scsi target0:0:2: Beginning Domain Validation
      scsi target0:0:2: Domain Validation skipping write tests
      scsi target0:0:2: Ending Domain Validation
      blk_queue_max_segments: set to minimum 1
      blk_queue_max_segments: set to minimum 1
      blk_queue_max_segments: set to minimum 1
      blk_queue_max_segments: set to minimum 1
      sr 0:0:2:0: Power-on or device reset occurred
      sd 0:0:0:0: Power-on or device reset occurred
      sd 0:0:1:0: Power-on or device reset occurred
      sd 0:0:0:0: [sda] 10485762 512-byte logical blocks: (5.37 GB/5.00 GiB)
      sd 0:0:0:0: [sda] Write Protect is off
      sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
      Unable to handle kernel NULL pointer dereference at virtual address (ptrval)
      Oops: 00000000
      Modules linked in:
      PC: [<001cd874>] blk_mq_free_request+0x66/0xe2
      SR: 2004  SP: (ptrval)  a2: 00874520
      d0: 00000000    d1: 00000000    d2: 009ba800    d3: 00000000
      d4: 00000000    d5: 08000002    a0: 0087be68    a1: 009a81e0
      Process kworker/u2:2 (pid: 15, task=(ptrval))
      Frame format=7 eff addr=0000007a ssw=0505 faddr=0000007a
      wb 1 stat/addr/data: 0000 00000000 00000000
      wb 2 stat/addr/data: 0000 00000000 00000000
      wb 3 stat/addr/data: 0000 0000007a 00000000
      push data: 00000000 00000000 00000000 00000000
      Stack from 0087bd98:
              00000002 00000000 0087be72 009a7820 0087bdb4 001c4f6c 009a7820 0087bdd4
              0024d200 009a7820 0024d0dc 0087be72 009baa00 0087be68 009a5000 0087be7c
              00265d10 009a5000 0087be72 00000003 00000000 00000000 00000000 0087be68
              00000bb8 00000005 00000000 00000000 00000000 00000000 00265c56 00000000
              009ba60c 0036ddf4 00000002 ffffffff 009baa00 009ba600 009a50d6 0087be74
              00227ba0 009baa08 00000001 009baa08 009ba60c 0036ddf4 00000000 00000000
      Call Trace: [<001c4f6c>] blk_put_request+0xe/0x14
       [<0024d200>] __scsi_execute+0x124/0x174
       [<0024d0dc>] __scsi_execute+0x0/0x174
       [<00265d10>] sd_revalidate_disk+0xba/0x1f02
       [<00265c56>] sd_revalidate_disk+0x0/0x1f02
       [<0036ddf4>] strlen+0x0/0x22
       [<00227ba0>] device_add+0x3da/0x604
       [<0036ddf4>] strlen+0x0/0x22
       [<00267e64>] sd_probe+0x30c/0x4b4
       [<0002da44>] process_one_work+0x0/0x402
       [<0022b978>] really_probe+0x226/0x354
       [<0022bc34>] driver_probe_device+0xa4/0xf0
       [<0002da44>] process_one_work+0x0/0x402
       [<0022bcd0>] __driver_attach_async_helper+0x50/0x70
       [<00035dae>] async_run_entry_fn+0x36/0x130
       [<0002db88>] process_one_work+0x144/0x402
       [<0002e1aa>] worker_thread+0x0/0x570
       [<0002e29a>] worker_thread+0xf0/0x570
       [<0002e1aa>] worker_thread+0x0/0x570
       [<003768d8>] schedule+0x0/0xb8
       [<0003f58c>] __init_waitqueue_head+0x0/0x12
       [<00033e92>] kthread+0xc2/0xf6
       [<000331e8>] kthread_parkme+0x0/0x4e
       [<003768d8>] schedule+0x0/0xb8
       [<00033dd0>] kthread+0x0/0xf6
       [<00002c10>] ret_from_kernel_thread+0xc/0x14
      Code: 0280 0006 0800 56c0 4400 0280 0000 00ff <52b4> 0c3a 082b 0006 0013 6706 2042 53a8 00c4 4ab9 0047 3374 6640 202d 000c 670c
      Disabling lock debugging due to kernel taint
      
      Avoid this by setting sg_tablesize = 1.
      
      Link: https://lore.kernel.org/r/4567bcae94523b47d6f3b77450ba305823bca479.1572656814.git.fthain@telegraphics.com.auReported-and-tested-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
      Reviewed-by: default avatarMichael Schmitz <schmitzmic@gmail.com>
      References: commit 68ab2d76 ("scsi: cxlflash: Set sg_tablesize to 1 instead of SG_NONE")
      Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6540d3af
    • Gustavo L. F. Walbon's avatar
      powerpc/security: Fix wrong message when RFI Flush is disable · ebd3980c
      Gustavo L. F. Walbon authored
      [ Upstream commit 4e706af3 ]
      
      The issue was showing "Mitigation" message via sysfs whatever the
      state of "RFI Flush", but it should show "Vulnerable" when it is
      disabled.
      
      If you have "L1D private" feature enabled and not "RFI Flush" you are
      vulnerable to meltdown attacks.
      
      "RFI Flush" is the key feature to mitigate the meltdown whatever the
      "L1D private" state.
      
      SEC_FTR_L1D_THREAD_PRIV is a feature for Power9 only.
      
      So the message should be as the truth table shows:
      
        CPU | L1D private | RFI Flush |                sysfs
        ----|-------------|-----------|-------------------------------------
         P9 |    False    |   False   | Vulnerable
         P9 |    False    |   True    | Mitigation: RFI Flush
         P9 |    True     |   False   | Vulnerable: L1D private per thread
         P9 |    True     |   True    | Mitigation: RFI Flush, L1D private per thread
         P8 |    False    |   False   | Vulnerable
         P8 |    False    |   True    | Mitigation: RFI Flush
      
      Output before this fix:
        # cat /sys/devices/system/cpu/vulnerabilities/meltdown
        Mitigation: RFI Flush, L1D private per thread
        # echo 0 > /sys/kernel/debug/powerpc/rfi_flush
        # cat /sys/devices/system/cpu/vulnerabilities/meltdown
        Mitigation: L1D private per thread
      
      Output after fix:
        # cat /sys/devices/system/cpu/vulnerabilities/meltdown
        Mitigation: RFI Flush, L1D private per thread
        # echo 0 > /sys/kernel/debug/powerpc/rfi_flush
        # cat /sys/devices/system/cpu/vulnerabilities/meltdown
        Vulnerable: L1D private per thread
      Signed-off-by: default avatarGustavo L. F. Walbon <gwalbon@linux.ibm.com>
      Signed-off-by: default avatarMauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20190502210907.42375-1-gwalbon@linux.ibm.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      ebd3980c
    • Tyrel Datwyler's avatar
      PCI: rpaphp: Correctly match ibm, my-drc-index to drc-name when using drc-info · 802534c0
      Tyrel Datwyler authored
      [ Upstream commit 4f9f2d3d ]
      
      The newer ibm,drc-info property is a condensed description of the old
      ibm,drc-* properties (ie. names, types, indexes, and power-domains).
      When matching a drc-index to a drc-name we need to verify that the
      index is within the start and last drc-index range and map it to a
      drc-name using the drc-name-prefix and logical index.
      
      Fix the mapping by checking that the index is within the range of the
      current drc-info entry, and build the name from the drc-name-prefix
      concatenated with the starting drc-name-suffix value and the sequential
      index obtained by subtracting ibm,my-drc-index from this entries
      drc-start-index.
      Signed-off-by: default avatarTyrel Datwyler <tyreld@linux.ibm.com>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/1573449697-5448-10-git-send-email-tyreld@linux.ibm.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      802534c0
    • Tyrel Datwyler's avatar
      PCI: rpaphp: Annotate and correctly byte swap DRC properties · 1dc37bd4
      Tyrel Datwyler authored
      [ Upstream commit 07376867 ]
      
      The device tree is in big endian format and any properties directly
      retrieved using OF helpers that don't explicitly byte swap should
      be annotated. In particular there are several places where we grab
      the opaque property value for the old ibm,drc-* properties and the
      ibm,my-drc-index property.
      
      Fix this for better static checking by annotating values we know to
      explicitly big endian, and byte swap where appropriate.
      Signed-off-by: default avatarTyrel Datwyler <tyreld@linux.ibm.com>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/1573449697-5448-9-git-send-email-tyreld@linux.ibm.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      1dc37bd4
    • Tyrel Datwyler's avatar
      PCI: rpaphp: Don't rely on firmware feature to imply drc-info support · a22f89ba
      Tyrel Datwyler authored
      [ Upstream commit 52e2b0f1 ]
      
      In the event that the partition is migrated to a platform with older
      firmware that doesn't support the ibm,drc-info property the device
      tree is modified to remove the ibm,drc-info property and replace it
      with the older style ibm,drc-* properties for types, names, indexes,
      and power-domains. One of the requirements of the drc-info firmware
      feature is that the client is able to handle both the new property,
      and old style properties at runtime. Therefore we can't rely on the
      firmware feature alone to dictate which property is currently
      present in the device tree.
      
      Fix this short coming by checking explicitly for the ibm,drc-info
      property, and falling back to the older ibm,drc-* properties if it
      doesn't exist.
      Signed-off-by: default avatarTyrel Datwyler <tyreld@linux.ibm.com>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/1573449697-5448-6-git-send-email-tyreld@linux.ibm.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      a22f89ba
    • David Hildenbrand's avatar
      powerpc/pseries/cmm: Implement release() function for sysfs device · f6529b89
      David Hildenbrand authored
      [ Upstream commit 7d821274 ]
      
      When unloading the module, one gets
        ------------[ cut here ]------------
        Device 'cmm0' does not have a release() function, it is broken and must be fixed. See Documentation/kobject.txt.
        WARNING: CPU: 0 PID: 19308 at drivers/base/core.c:1244 .device_release+0xcc/0xf0
        ...
      
      We only have one static fake device. There is nothing to do when
      releasing the device (via cmm_exit()).
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20191031142933.10779-2-david@redhat.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      f6529b89
    • Bean Huo's avatar
      scsi: ufs: fix potential bug which ends in system hang · f7276da4
      Bean Huo authored
      [ Upstream commit cfcbae38 ]
      
      In function __ufshcd_query_descriptor(), in the event of an error
      happening, we directly goto out_unlock and forget to invaliate
      hba->dev_cmd.query.descriptor pointer. This results in this pointer still
      valid in ufshcd_copy_query_response() for other query requests which go
      through ufshcd_exec_raw_upiu_cmd(). This will cause __memcpy() crash and
      system hangs. Log as shown below:
      
      Unable to handle kernel paging request at virtual address
      ffff000012233c40
      Mem abort info:
         ESR = 0x96000047
         Exception class = DABT (current EL), IL = 32 bits
         SET = 0, FnV = 0
         EA = 0, S1PTW = 0
      Data abort info:
         ISV = 0, ISS = 0x00000047
         CM = 0, WnR = 1
      swapper pgtable: 4k pages, 48-bit VAs, pgdp = 0000000028cc735c
      [ffff000012233c40] pgd=00000000bffff003, pud=00000000bfffe003,
      pmd=00000000ba8b8003, pte=0000000000000000
       Internal error: Oops: 96000047 [#2] PREEMPT SMP
       ...
       Call trace:
        __memcpy+0x74/0x180
        ufshcd_issue_devman_upiu_cmd+0x250/0x3c0
        ufshcd_exec_raw_upiu_cmd+0xfc/0x1a8
        ufs_bsg_request+0x178/0x3b0
        bsg_queue_rq+0xc0/0x118
        blk_mq_dispatch_rq_list+0xb0/0x538
        blk_mq_sched_dispatch_requests+0x18c/0x1d8
        __blk_mq_run_hw_queue+0xb4/0x118
        blk_mq_run_work_fn+0x28/0x38
        process_one_work+0x1ec/0x470
        worker_thread+0x48/0x458
        kthread+0x130/0x138
        ret_from_fork+0x10/0x1c
       Code: 540000ab a8c12027 a88120c7 a8c12027 (a88120c7)
       ---[ end trace 793e1eb5dff69f2d ]---
       note: kworker/0:2H[2054] exited with preempt_count 1
      
      This patch is to move "descriptor = NULL" down to below the label
      "out_unlock".
      
      Fixes: d44a5f98(ufs: query descriptor API)
      Link: https://lore.kernel.org/r/20191112223436.27449-3-huobean@gmail.comReviewed-by: default avatarAlim Akhtar <alim.akhtar@samsung.com>
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarBean Huo <beanhuo@micron.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f7276da4
    • Tyrel Datwyler's avatar
      PCI: rpaphp: Fix up pointer to first drc-info entry · 68b7ccf6
      Tyrel Datwyler authored
      [ Upstream commit 9723c25f ]
      
      The first entry of the ibm,drc-info property is an int encoded count
      of the number of drc-info entries that follow. The "value" pointer
      returned by of_prop_next_u32() is still pointing at the this value
      when we call of_read_drc_info_cell(), but the helper function
      expects that value to be pointing at the first element of an entry.
      
      Fix up by incrementing the "value" pointer to point at the first
      element of the first drc-info entry prior.
      Signed-off-by: default avatarTyrel Datwyler <tyreld@linux.ibm.com>
      Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/1573449697-5448-5-git-send-email-tyreld@linux.ibm.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      68b7ccf6
    • James Smart's avatar
      scsi: lpfc: fix: Coverity: lpfc_cmpl_els_rsp(): Null pointer dereferences · 6225451c
      James Smart authored
      [ Upstream commit 6c6d59e0 ]
      
      Coverity reported the following:
      
      *** CID 101747:  Null pointer dereferences  (FORWARD_NULL)
      /drivers/scsi/lpfc/lpfc_els.c: 4439 in lpfc_cmpl_els_rsp()
      4433     			kfree(mp);
      4434     		}
      4435     		mempool_free(mbox, phba->mbox_mem_pool);
      4436     	}
      4437     out:
      4438     	if (ndlp && NLP_CHK_NODE_ACT(ndlp)) {
      vvv     CID 101747:  Null pointer dereferences  (FORWARD_NULL)
      vvv     Dereferencing null pointer "shost".
      4439     		spin_lock_irq(shost->host_lock);
      4440     		ndlp->nlp_flag &= ~(NLP_ACC_REGLOGIN | NLP_RM_DFLT_RPI);
      4441     		spin_unlock_irq(shost->host_lock);
      4442
      4443     		/* If the node is not being used by another discovery thread,
      4444     		 * and we are sending a reject, we are done with it.
      
      Fix by adding a check for non-null shost in line 4438.
      The scenario when shost is set to null is when ndlp is null.
      As such, the ndlp check present was sufficient. But better safe
      than sorry so add the shost check.
      Reported-by: default avatarcoverity-bot <keescook+coverity-bot@chromium.org>
      Addresses-Coverity-ID: 101747 ("Null pointer dereferences")
      Fixes: 2e0fef85 ("[SCSI] lpfc: NPIV: split ports")
      
      CC: James Bottomley <James.Bottomley@SteelEye.com>
      CC: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
      CC: linux-next@vger.kernel.org
      Link: https://lore.kernel.org/r/20191111230401.12958-3-jsmart2021@gmail.comReviewed-by: default avatarEwan D. Milne <emilne@redhat.com>
      Signed-off-by: default avatarDick Kennedy <dick.kennedy@broadcom.com>
      Signed-off-by: default avatarJames Smart <jsmart2021@gmail.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6225451c
    • Konstantin Khlebnikov's avatar
      fs/quota: handle overflows of sysctl fs.quota.* and report as unsigned long · a94058fe
      Konstantin Khlebnikov authored
      [ Upstream commit 6fcbcec9 ]
      
      Quota statistics counted as 64-bit per-cpu counter. Reading sums per-cpu
      fractions as signed 64-bit int, filters negative values and then reports
      lower half as signed 32-bit int.
      
      Result may looks like:
      
      fs.quota.allocated_dquots = 22327
      fs.quota.cache_hits = -489852115
      fs.quota.drops = -487288718
      fs.quota.free_dquots = 22083
      fs.quota.lookups = -486883485
      fs.quota.reads = 22327
      fs.quota.syncs = 335064
      fs.quota.writes = 3088689
      
      Values bigger than 2^31-1 reported as negative.
      
      All counters except "allocated_dquots" and "free_dquots" are monotonic,
      thus they should be reported as is without filtering negative values.
      
      Kernel doesn't have generic helper for 64-bit sysctl yet,
      let's use at least unsigned long.
      
      Link: https://lore.kernel.org/r/157337934693.2078.9842146413181153727.stgit@buzzSigned-off-by: default avatarKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a94058fe
    • Paul Cercueil's avatar
      irqchip: ingenic: Error out if IRQ domain creation failed · c99e39a3
      Paul Cercueil authored
      [ Upstream commit 52ecc876 ]
      
      If we cannot create the IRQ domain, the driver should fail to probe
      instead of succeeding with just a warning message.
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/1570015525-27018-3-git-send-email-zhouyanjie@zoho.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      c99e39a3
    • Florian Fainelli's avatar
      irqchip/irq-bcm7038-l1: Enable parent IRQ if necessary · 276010d9
      Florian Fainelli authored
      [ Upstream commit 27eebb60 ]
      
      If the 'brcm,irq-can-wake' property is specified, make sure we also
      enable the corresponding parent interrupt we are attached to.
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20191024201415.23454-4-f.fainelli@gmail.comSigned-off-by: default avatarSasha Levin <sashal@kernel.org>
      276010d9
    • Michael Hennerich's avatar
      clk: clk-gpio: propagate rate change to parent · e3c56359
      Michael Hennerich authored
      [ Upstream commit fc59462c ]
      
      For an external clock source, which is gated via a GPIO, the
      rate change should typically be propagated to the parent clock.
      
      The situation where we are requiring this propagation, is when an
      external clock is connected to override an internal clock (which typically
      has a fixed rate). The external clock can have a different rate than the
      internal one, and may also be variable, thus requiring the rate
      propagation.
      
      This rate change wasn't propagated until now, and it's unclear about cases
      where this shouldn't be propagated. Thus, it's unclear whether this is
      fixing a bug, or extending the current driver behavior. Also, it's unsure
      about whether this may break any existing setups; in the case that it does,
      a device-tree property may be added to disable this flag.
      Signed-off-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
      Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
      Link: https://lkml.kernel.org/r/20191108071718.17985-1-alexandru.ardelean@analog.comSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3c56359
    • Jeffrey Hugo's avatar
      clk: qcom: Allow constant ratio freq tables for rcg · 4572d2a5
      Jeffrey Hugo authored
      [ Upstream commit efd164b5 ]
      
      Some RCGs (the gfx_3d_src_clk in msm8998 for example) are basically just
      some constant ratio from the input across the entire frequency range.  It
      would be great if we could specify the frequency table as a single entry
      constant ratio instead of a long list, ie:
      
      	{ .src = P_GPUPLL0_OUT_EVEN, .pre_div = 3 },
              { }
      
      So, lets support that.
      
      We need to fix a corner case in qcom_find_freq() where if the freq table
      is non-null, but has no frequencies, we end up returning an "entry" before
      the table array, which is bad.  Then, we need ignore the freq from the
      table, and instead base everything on the requested freq.
      Suggested-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarJeffrey Hugo <jeffrey.l.hugo@gmail.com>
      Link: https://lkml.kernel.org/r/20191031185715.15504-1-jeffrey.l.hugo@gmail.comSigned-off-by: default avatarStephen Boyd <sboyd@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4572d2a5
    • Chao Yu's avatar
      f2fs: fix to update dir's i_pino during cross_rename · 220a7ffd
      Chao Yu authored
      [ Upstream commit 2a60637f ]
      
      As Eric reported:
      
      RENAME_EXCHANGE support was just added to fsstress in xfstests:
      
      	commit 65dfd40a97b6bbbd2a22538977bab355c5bc0f06
      	Author: kaixuxia <xiakaixu1987@gmail.com>
      	Date:   Thu Oct 31 14:41:48 2019 +0800
      
      	    fsstress: add EXCHANGE renameat2 support
      
      This is causing xfstest generic/579 to fail due to fsck.f2fs reporting errors.
      I'm not sure what the problem is, but it still happens even with all the
      fs-verity stuff in the test commented out, so that the test just runs fsstress.
      
      generic/579 23s ... 	[10:02:25]
      [    7.745370] run fstests generic/579 at 2019-11-04 10:02:25
      _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
      (see /results/f2fs/results-default/generic/579.full for details)
       [10:02:47]
      Ran: generic/579
      Failures: generic/579
      Failed 1 of 1 tests
      Xunit report: /results/f2fs/results-default/result.xml
      
      Here's the contents of 579.full:
      
      _check_generic_filesystem: filesystem on /dev/vdc is inconsistent
      *** fsck.f2fs output ***
      [ASSERT] (__chk_dots_dentries:1378)  --> Bad inode number[0x24] for '..', parent parent ino is [0xd10]
      
      The root cause is that we forgot to update directory's i_pino during
      cross_rename, fix it.
      
      Fixes: 32f9bc25 ("f2fs: support ->rename2()")
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Tested-by: default avatarEric Biggers <ebiggers@kernel.org>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      220a7ffd