1. 26 Sep, 2018 40 commits
    • Philipp Puschmann's avatar
      Bluetooth: Use lock_sock_nested in bt_accept_enqueue · ef49d0e8
      Philipp Puschmann authored
      [ Upstream commit b71c69c2 ]
      
      Fixes this warning that was provoked by a pairing:
      
      [60258.016221] WARNING: possible recursive locking detected
      [60258.021558] 4.15.0-RD1812-BSP #1 Tainted: G           O
      [60258.027146] --------------------------------------------
      [60258.032464] kworker/u5:0/70 is trying to acquire lock:
      [60258.037609]  (sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+.}, at: [<87759073>] bt_accept_enqueue+0x3c/0x74
      [60258.046863]
      [60258.046863] but task is already holding lock:
      [60258.052704]  (sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+.}, at: [<d22d7106>] l2cap_sock_new_connection_cb+0x1c/0x88
      [60258.062905]
      [60258.062905] other info that might help us debug this:
      [60258.069441]  Possible unsafe locking scenario:
      [60258.069441]
      [60258.075368]        CPU0
      [60258.077821]        ----
      [60258.080272]   lock(sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP);
      [60258.085510]   lock(sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP);
      [60258.090748]
      [60258.090748]  *** DEADLOCK ***
      [60258.090748]
      [60258.096676]  May be due to missing lock nesting notation
      [60258.096676]
      [60258.103472] 5 locks held by kworker/u5:0/70:
      [60258.107747]  #0:  ((wq_completion)%shdev->name#2){+.+.}, at: [<9460d092>] process_one_work+0x130/0x4fc
      [60258.117263]  #1:  ((work_completion)(&hdev->rx_work)){+.+.}, at: [<9460d092>] process_one_work+0x130/0x4fc
      [60258.126942]  #2:  (&conn->chan_lock){+.+.}, at: [<7877c8c3>] l2cap_connect+0x80/0x4f8
      [60258.134806]  #3:  (&chan->lock/2){+.+.}, at: [<2e16c724>] l2cap_connect+0x8c/0x4f8
      [60258.142410]  #4:  (sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+.}, at: [<d22d7106>] l2cap_sock_new_connection_cb+0x1c/0x88
      [60258.153043]
      [60258.153043] stack backtrace:
      [60258.157413] CPU: 1 PID: 70 Comm: kworker/u5:0 Tainted: G           O     4.15.0-RD1812-BSP #1
      [60258.165945] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
      [60258.172485] Workqueue: hci0 hci_rx_work
      [60258.176331] Backtrace:
      [60258.178797] [<8010c9fc>] (dump_backtrace) from [<8010ccbc>] (show_stack+0x18/0x1c)
      [60258.186379]  r7:80e55fe4 r6:80e55fe4 r5:20050093 r4:00000000
      [60258.192058] [<8010cca4>] (show_stack) from [<809864e8>] (dump_stack+0xb0/0xdc)
      [60258.199301] [<80986438>] (dump_stack) from [<8016ecc8>] (__lock_acquire+0xffc/0x11d4)
      [60258.207144]  r9:5e2bb019 r8:630f974c r7:ba8a5940 r6:ba8a5ed8 r5:815b5220 r4:80fa081c
      [60258.214901] [<8016dccc>] (__lock_acquire) from [<8016f620>] (lock_acquire+0x78/0x98)
      [60258.222655]  r10:00000040 r9:00000040 r8:808729f0 r7:00000001 r6:00000000 r5:60050013
      [60258.230491]  r4:00000000
      [60258.233045] [<8016f5a8>] (lock_acquire) from [<806ee974>] (lock_sock_nested+0x64/0x88)
      [60258.240970]  r7:00000000 r6:b796e870 r5:00000001 r4:b796e800
      [60258.246643] [<806ee910>] (lock_sock_nested) from [<808729f0>] (bt_accept_enqueue+0x3c/0x74)
      [60258.255004]  r8:00000001 r7:ba7d3c00 r6:ba7d3ea4 r5:ba7d2000 r4:b796e800
      [60258.261717] [<808729b4>] (bt_accept_enqueue) from [<808aa39c>] (l2cap_sock_new_connection_cb+0x68/0x88)
      [60258.271117]  r5:b796e800 r4:ba7d2000
      [60258.274708] [<808aa334>] (l2cap_sock_new_connection_cb) from [<808a294c>] (l2cap_connect+0x190/0x4f8)
      [60258.283933]  r5:00000001 r4:ba6dce00
      [60258.287524] [<808a27bc>] (l2cap_connect) from [<808a4a14>] (l2cap_recv_frame+0x744/0x2cf8)
      [60258.295800]  r10:ba6dcf24 r9:00000004 r8:b78d8014 r7:00000004 r6:bb05d000 r5:00000004
      [60258.303635]  r4:bb05d008
      [60258.306183] [<808a42d0>] (l2cap_recv_frame) from [<808a7808>] (l2cap_recv_acldata+0x210/0x214)
      [60258.314805]  r10:b78e7800 r9:bb05d960 r8:00000001 r7:bb05d000 r6:0000000c r5:b7957a80
      [60258.322641]  r4:ba6dce00
      [60258.325188] [<808a75f8>] (l2cap_recv_acldata) from [<8087630c>] (hci_rx_work+0x35c/0x4e8)
      [60258.333374]  r6:80e5743c r5:bb05d7c8 r4:b7957a80
      [60258.338004] [<80875fb0>] (hci_rx_work) from [<8013dc7c>] (process_one_work+0x1a4/0x4fc)
      [60258.346018]  r10:00000001 r9:00000000 r8:baabfef8 r7:ba997500 r6:baaba800 r5:baaa5d00
      [60258.353853]  r4:bb05d7c8
      [60258.356401] [<8013dad8>] (process_one_work) from [<8013e028>] (worker_thread+0x54/0x5cc)
      [60258.364503]  r10:baabe038 r9:baaba834 r8:80e05900 r7:00000088 r6:baaa5d18 r5:baaba800
      [60258.372338]  r4:baaa5d00
      [60258.374888] [<8013dfd4>] (worker_thread) from [<801448f8>] (kthread+0x134/0x160)
      [60258.382295]  r10:ba8310b8 r9:bb07dbfc r8:8013dfd4 r7:baaa5d00 r6:00000000 r5:baaa8ac0
      [60258.390130]  r4:ba831080
      [60258.392682] [<801447c4>] (kthread) from [<801080b4>] (ret_from_fork+0x14/0x20)
      [60258.399915]  r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:801447c4
      [60258.407751]  r4:baaa8ac0 r3:baabe000
      Signed-off-by: default avatarPhilipp Puschmann <pp@emlix.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ef49d0e8
    • Miklos Szeredi's avatar
      vfs: fix freeze protection in mnt_want_write_file() for overlayfs · 4f4374a9
      Miklos Szeredi authored
      [ Upstream commit a6795a58 ]
      
      The underlying real file used by overlayfs still contains the overlay path.
      This results in mnt_want_write_file() calls by the filesystem getting
      freeze protection on the wrong inode (the overlayfs one instead of the real
      one).
      
      Fix by using file_inode(file)->i_sb instead of file->f_path.mnt->mnt_sb.
      Reported-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4f4374a9
    • Jann Horn's avatar
      mtdchar: fix overflows in adjustment of `count` · b888dba2
      Jann Horn authored
      [ Upstream commit 6c6bc9ea ]
      
      The first checks in mtdchar_read() and mtdchar_write() attempt to limit
      `count` such that `*ppos + count <= mtd->size`. However, they ignore the
      possibility of `*ppos > mtd->size`, allowing the calculation of `count` to
      wrap around. `mtdchar_lseek()` prevents seeking beyond mtd->size, but the
      pread/pwrite syscalls bypass this.
      
      I haven't found any codepath on which this actually causes dangerous
      behavior, but it seems like a sensible change anyway.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b888dba2
    • Ronny Chevalier's avatar
      audit: fix use-after-free in audit_add_watch · 67e522a7
      Ronny Chevalier authored
      [ Upstream commit baa2a4fd ]
      
      audit_add_watch stores locally krule->watch without taking a reference
      on watch. Then, it calls audit_add_to_parent, and uses the watch stored
      locally.
      
      Unfortunately, it is possible that audit_add_to_parent updates
      krule->watch.
      When it happens, it also drops a reference of watch which
      could free the watch.
      
      How to reproduce (with KASAN enabled):
      
          auditctl -w /etc/passwd -F success=0 -k test_passwd
          auditctl -w /etc/passwd -F success=1 -k test_passwd2
      
      The second call to auditctl triggers the use-after-free, because
      audit_to_parent updates krule->watch to use a previous existing watch
      and drops the reference to the newly created watch.
      
      To fix the issue, we grab a reference of watch and we release it at the
      end of the function.
      Signed-off-by: default avatarRonny Chevalier <ronny.chevalier@hp.com>
      Reviewed-by: default avatarRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      67e522a7
    • Viresh Kumar's avatar
      arm64: dts: uniphier: Add missing cooling device properties for CPUs · a41ab6fe
      Viresh Kumar authored
      [ Upstream commit af0e09d0 ]
      
      The cooling device properties, like "#cooling-cells" and
      "dynamic-power-coefficient", should either be present for all the CPUs
      of a cluster or none. If these are present only for a subset of CPUs of
      a cluster then things will start falling apart as soon as the CPUs are
      brought online in a different order. For example, this will happen
      because the operating system looks for such properties in the CPU node
      it is trying to bring up, so that it can register a cooling device.
      
      Add such missing properties.
      Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a41ab6fe
    • Noa Osherovich's avatar
      net/mlx5: Add missing SET_DRIVER_VERSION command translation · ebb42f77
      Noa Osherovich authored
      [ Upstream commit 0f403910 ]
      
      When translating command opcodes to a string, SET_DRIVER_VERSION
      command was missing.
      
      Fixes: 42ca502e ('net/mlx5_core: Use a macro in mlx5_command_str()')
      Signed-off-by: default avatarNoa Osherovich <noaos@mellanox.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ebb42f77
    • Maciej W. Rozycki's avatar
      binfmt_elf: Respect error return from `regset->active' · 62e05289
      Maciej W. Rozycki authored
      [ Upstream commit 2f819db5 ]
      
      The regset API documented in <linux/regset.h> defines -ENODEV as the
      result of the `->active' handler to be used where the feature requested
      is not available on the hardware found.  However code handling core file
      note generation in `fill_thread_core_info' interpretes any non-zero
      result from the `->active' handler as the regset requested being active.
      Consequently processing continues (and hopefully gracefully fails later
      on) rather than being abandoned right away for the regset requested.
      
      Fix the problem then by making the code proceed only if a positive
      result is returned from the `->active' handler.
      Signed-off-by: default avatarMaciej W. Rozycki <macro@mips.com>
      Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
      Fixes: 4206d3aa ("elf core dump: notes user_regset")
      Patchwork: https://patchwork.linux-mips.org/patch/19332/
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: James Hogan <jhogan@kernel.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: linux-fsdevel@vger.kernel.org
      Cc: linux-mips@linux-mips.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      62e05289
    • Trond Myklebust's avatar
      NFSv4.1 fix infinite loop on I/O. · 948f1a7f
      Trond Myklebust authored
      commit 994b15b9 upstream.
      
      The previous fix broke recovery of delegated stateids because it assumes
      that if we did not mark the delegation as suspect, then the delegation has
      effectively been revoked, and so it removes that delegation irrespectively
      of whether or not it is valid and still in use. While this is "mostly
      harmless" for ordinary I/O, we've seen pNFS fail with LAYOUTGET spinning
      in an infinite loop while complaining that we're using an invalid stateid
      (in this case the all-zero stateid).
      
      What we rather want to do here is ensure that the delegation is always
      correctly marked as needing testing when that is the case. So we want
      to close the loophole offered by nfs4_schedule_stateid_recovery(),
      which marks the state as needing to be reclaimed, but not the
      delegation that may be backing it.
      
      Fixes: 0e3d3e5d ("NFSv4.1 fix infinite loop on IO BAD_STATEID error")
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Cc: stable@vger.kernel.org # v4.11+
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      948f1a7f
    • Boris Ostrovsky's avatar
      x86/EISA: Don't probe EISA bus for Xen PV guests · 99955451
      Boris Ostrovsky authored
      commit 6a92b111 upstream.
      
      For unprivileged Xen PV guests this is normal memory and ioremap will
      not be able to properly map it.
      
      While at it, since ioremap may return NULL, add a test for pointer's
      validity.
      Reported-by: default avatarAndy Smith <andy@strugglers.net>
      Signed-off-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: hpa@zytor.com
      Cc: xen-devel@lists.xenproject.org
      Cc: jgross@suse.com
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20180911195538.23289-1-boris.ostrovsky@oracle.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      99955451
    • Yabin Cui's avatar
      perf/core: Force USER_DS when recording user stack data · d9951521
      Yabin Cui authored
      commit 02e18447 upstream.
      
      Perf can record user stack data in response to a synchronous request, such
      as a tracepoint firing. If this happens under set_fs(KERNEL_DS), then we
      end up reading user stack data using __copy_from_user_inatomic() under
      set_fs(KERNEL_DS). I think this conflicts with the intention of using
      set_fs(KERNEL_DS). And it is explicitly forbidden by hardware on ARM64
      when both CONFIG_ARM64_UAO and CONFIG_ARM64_PAN are used.
      
      So fix this by forcing USER_DS when recording user stack data.
      Signed-off-by: default avatarYabin Cui <yabinc@google.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@vger.kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: 88b0193d ("perf/callchain: Force USER_DS when invoking perf_callchain_user()")
      Link: http://lkml.kernel.org/r/20180823225935.27035-1-yabinc@google.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d9951521
    • Max Filippov's avatar
      xtensa: ISS: don't allocate memory in platform_setup · 8c08224a
      Max Filippov authored
      commit ef439d49 upstream.
      
      Memory allocator is not initialized at that point yet, use static array
      instead.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c08224a
    • Dan Carpenter's avatar
      CIFS: fix wrapping bugs in num_entries() · f3259909
      Dan Carpenter authored
      commit 56446f21 upstream.
      
      The problem is that "entryptr + next_offset" and "entryptr + len + size"
      can wrap.  I ended up changing the type of "entryptr" because it makes
      the math easier when we don't have to do so much casting.
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
      Reviewed-by: default avatarPavel Shilovsky <pshilov@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f3259909
    • Dan Carpenter's avatar
      cifs: prevent integer overflow in nxt_dir_entry() · 20c8102b
      Dan Carpenter authored
      commit 8ad8aa35 upstream.
      
      The "old_entry + le32_to_cpu(pDirInfo->NextEntryOffset)" can wrap
      around so I have added a check for integer overflow.
      Reported-by: default avatarDr Silvio Cesare of InfoSect <silvio.cesare@gmail.com>
      Reviewed-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
      Reviewed-by: default avatarAurelien Aptel <aaptel@suse.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      20c8102b
    • Oliver Neukum's avatar
      Revert "cdc-acm: implement put_char() and flush_chars()" · 334902cf
      Oliver Neukum authored
      commit df3aa13c upstream.
      
      This reverts commit a81cf979.
      
      The patch causes a regression, which I cannot find the reason for.
      So let's revert for now, as a revert hurts only performance.
      
      Original report:
      I was trying to resolve the problem with Oliver but we don't get any conclusion
      for 5 months, so I am now sending this to mail list and cdc_acm authors.
      
      I am using simple request-response protocol to obtain the boiller parameters
      in constant intervals.
      
      A simple one transaction is:
      1. opening the /dev/ttyACM0
      2. sending the following 10-bytes request to the device:
         unsigned char req[] = {0x02, 0xfe, 0x01, 0x05, 0x08, 0x02, 0x01, 0x69, 0xab, 0x03};
      3. reading response (frame of 74 bytes length).
      4. closing the descriptor
      I am doing this transaction with 5 seconds intervals.
      
      Before the bad commit everything was working correctly: I've got a requests and
      a responses in a timely manner.
      
      After the bad commit more time I am using the kernel module, more problems I have.
      The graph [2] is showing the problem.
      
      As you can see after module load all seems fine but after about 30 minutes I've got
      a plenty of EAGAINs when doing read()'s and trying to read back the data.
      
      When I rmmod and insmod the cdc_acm module again, then the situation is starting
      over again: running ok shortly after load, and more time it is running, more EAGAINs
      I have when calling read().
      
      As a bonus I can see the problem on the device itself:
      The device is configured as you can see here on this screen [3].
      It has two transmision LEDs: TX and RX. Blink duration is set for 100ms.
      This is a recording before the bad commit when all is working fine: [4]
      And this is with the bad commit: [5]
      As you can see the TX led is blinking wrongly long (indicating transmission?)
      and I have problems doing read() calls (EAGAIN).
      Reported-by: default avatarMariusz Bialonczyk <manio@skyboo.net>
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Fixes: a81cf979 ("cdc-acm: implement put_char() and flush_chars()")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      334902cf
    • Jia-Ju Bai's avatar
      usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt() · 80f53998
      Jia-Ju Bai authored
      commit 6e22e3af upstream.
      
      wdm_in_callback() is a completion handler function for the USB driver.
      So it should not sleep. But it calls service_outstanding_interrupt(),
      which calls usb_submit_urb() with GFP_KERNEL.
      
      To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC.
      
      This bug is found by my static analysis tool DSAC.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      80f53998
    • Ben Hutchings's avatar
      USB: yurex: Fix buffer over-read in yurex_write() · a383de0d
      Ben Hutchings authored
      commit 7e10f14e upstream.
      
      If the written data starts with a digit, yurex_write() tries to parse
      it as an integer using simple_strtoull().  This requires a null-
      terminator, and currently there's no guarantee that there is one.
      
      (The sample program at
      https://github.com/NeoCat/YUREX-driver-for-Linux/blob/master/sample/yurex_clock.pl
      writes an integer without a null terminator.  It seems like it must
      have worked by chance!)
      
      Always add a null byte after the written data.  Enlarge the buffer
      to allow for this.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarBen Hutchings <ben.hutchings@codethink.co.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a383de0d
    • Johan Hovold's avatar
      USB: serial: ti_usb_3410_5052: fix array underflow in completion handler · a98152a6
      Johan Hovold authored
      commit 5dfdd24e upstream.
      
      Similarly to a recently reported bug in io_ti, a malicious USB device
      could set port_number to a negative value and we would underflow the
      port array in the interrupt completion handler.
      
      As these devices only have one or two ports, fix this by making sure we
      only consider the seventh bit when determining the port number (and
      ignore bits 0xb0 which are typically set to 0x30).
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a98152a6
    • Jia-Ju Bai's avatar
      usb: misc: uss720: Fix two sleep-in-atomic-context bugs · a82200ce
      Jia-Ju Bai authored
      commit bc8acc21 upstream.
      
      async_complete() in uss720.c is a completion handler function for the
      USB driver. So it should not sleep, but it is can sleep according to the
      function call paths (from bottom to top) in Linux-4.16.
      
      [FUNC] set_1284_register(GFP_KERNEL)
      drivers/usb/misc/uss720.c, 372:
        set_1284_register in parport_uss720_frob_control
      drivers/parport/ieee1284.c, 560:
        [FUNC_PTR]parport_uss720_frob_control in parport_ieee1284_ack_data_avail
      drivers/parport/ieee1284.c, 577:
        parport_ieee1284_ack_data_avail in parport_ieee1284_interrupt
      ./include/linux/parport.h, 474:
        parport_ieee1284_interrupt in parport_generic_irq
      drivers/usb/misc/uss720.c, 116:
        parport_generic_irq in async_complete
      
      [FUNC] get_1284_register(GFP_KERNEL)
      drivers/usb/misc/uss720.c, 382:
        get_1284_register in parport_uss720_read_status
      drivers/parport/ieee1284.c, 555:
        [FUNC_PTR]parport_uss720_read_status in parport_ieee1284_ack_data_avail
      drivers/parport/ieee1284.c, 577:
        parport_ieee1284_ack_data_avail in parport_ieee1284_interrupt
      ./include/linux/parport.h, 474:
        parport_ieee1284_interrupt in parport_generic_irq
      drivers/usb/misc/uss720.c, 116:
        parport_generic_irq in async_complete
      
      Note that [FUNC_PTR] means a function pointer call is used.
      
      To fix these bugs, GFP_KERNEL is replaced with GFP_ATOMIC.
      
      These bugs are found by my static analysis tool DSAC.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a82200ce
    • Johan Hovold's avatar
      USB: serial: io_ti: fix array underflow in completion handler · a7d9367c
      Johan Hovold authored
      commit 691a03cf upstream.
      
      As reported by Dan Carpenter, a malicious USB device could set
      port_number to a negative value and we would underflow the port array in
      the interrupt completion handler.
      
      As these devices only have one or two ports, fix this by making sure we
      only consider the seventh bit when determining the port number (and
      ignore bits 0xb0 which are typically set to 0x30).
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable <stable@vger.kernel.org>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a7d9367c
    • Alan Stern's avatar
      USB: net2280: Fix erroneous synchronization change · d078f295
      Alan Stern authored
      commit dec3c23c upstream.
      
      Commit f16443a0 ("USB: gadgetfs, dummy-hcd, net2280: fix locking
      for callbacks") was based on a serious misunderstanding.  It
      introduced regressions into both the dummy-hcd and net2280 drivers.
      
      The problem in dummy-hcd was fixed by commit 7dbd8f4c ("USB:
      dummy-hcd: Fix erroneous synchronization change"), but the problem in
      net2280 remains.  Namely: the ->disconnect(), ->suspend(), ->resume(),
      and ->reset() callbacks must be invoked without the private lock held;
      otherwise a deadlock will occur when the callback routine tries to
      interact with the UDC driver.
      
      This patch largely is a reversion of the relevant parts of
      f16443a0.  It also drops the private lock around the calls to
      ->suspend() and ->resume() (something the earlier patch forgot to do).
      This is safe from races with device interrupts because it occurs
      within the interrupt handler.
      
      Finally, the patch changes where the ->disconnect() callback is
      invoked when net2280_pullup() turns the pullup off.  Rather than
      making the callback from within stop_activity() at a time when dropping
      the private lock could be unsafe, the callback is moved to a point
      after the lock has already been dropped.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Fixes: f16443a0 ("USB: gadgetfs, dummy-hcd, net2280: fix locking for callbacks")
      Reported-by: default avatarD. Ziesche <dziesche@zes.com>
      Tested-by: default avatarD. Ziesche <dziesche@zes.com>
      CC: <stable@vger.kernel.org>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d078f295
    • Yoshihiro Shimoda's avatar
      usb: gadget: udc: renesas_usb3: fix maxpacket size of ep0 · 3afbeb5c
      Yoshihiro Shimoda authored
      commit dfe1a51d upstream.
      
      This patch fixes an issue that maxpacket size of ep0 is incorrect
      for SuperSpeed. Otherwise, CDC NCM class with SuperSpeed doesn't
      work correctly on this driver because its control read data size
      is more than 64 bytes.
      Reported-by: default avatarJunki Kato <junki.kato.xk@renesas.com>
      Fixes: 746bfe63 ("usb: gadget: renesas_usb3: add support for Renesas USB3.0 peripheral controller")
      Cc: <stable@vger.kernel.org> # v4.5+
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Tested-by: default avatarJunki Kato <junki.kato.xk@renesas.com>
      Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3afbeb5c
    • Maxence Duprès's avatar
      USB: add quirk for WORLDE Controller KS49 or Prodipe MIDI 49C USB controller · 6def1c17
      Maxence Duprès authored
      commit 9b83a1c3 upstream.
      
      WORLDE Controller KS49 or Prodipe MIDI 49C USB controller
      cause a -EPROTO error, a communication restart and loop again.
      
      This issue has already been fixed for KS25.
      https://lore.kernel.org/patchwork/patch/753077/
      
      I just add device 201 for KS49 in quirks.c to get it works.
      Signed-off-by: default avatarLaurent Roux <xpros64@hotmail.fr>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6def1c17
    • Jia-Ju Bai's avatar
      usb: host: u132-hcd: Fix a sleep-in-atomic-context bug in u132_get_frame() · 1dbc1fd7
      Jia-Ju Bai authored
      commit 6d4f268f upstream.
      
      i_usX2Y_subs_startup in usbusx2yaudio.c is a completion handler function
      for the USB driver. So it should not sleep, but it is can sleep
      according to the function call paths (from bottom to top) in Linux-4.16.
      
      [FUNC] msleep
      drivers/usb/host/u132-hcd.c, 2558:
      	msleep in u132_get_frame
      drivers/usb/core/hcd.c, 2231:
      	[FUNC_PTR]u132_get_frame in usb_hcd_get_frame_number
      drivers/usb/core/usb.c, 822:
      	usb_hcd_get_frame_number in usb_get_current_frame_number
      sound/usb/usx2y/usbusx2yaudio.c, 303:
      	usb_get_current_frame_number in i_usX2Y_urb_complete
      sound/usb/usx2y/usbusx2yaudio.c, 366:
      	i_usX2Y_urb_complete in i_usX2Y_subs_startup
      
      Note that [FUNC_PTR] means a function pointer call is used.
      
      To fix this bug, msleep() is replaced with mdelay().
      
      This bug is found by my static analysis tool DSAC.
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1dbc1fd7
    • Mathias Nyman's avatar
      usb: Avoid use-after-free by flushing endpoints early in usb_set_interface() · 760c41fc
      Mathias Nyman authored
      commit f9a5b4f5 upstream.
      
      The steps taken by usb core to set a new interface is very different from
      what is done on the xHC host side.
      
      xHC hardware will do everything in one go. One command is used to set up
      new endpoints, free old endpoints, check bandwidth, and run the new
      endpoints.
      
      All this is done by xHC when usb core asks the hcd to check for
      available bandwidth. At this point usb core has not yet flushed the old
      endpoints, which will cause use-after-free issues in xhci driver as
      queued URBs are cancelled on a re-allocated endpoint.
      
      To resolve this add a call to usb_disable_interface() which will flush
      the endpoints before calling usb_hcd_alloc_bandwidth()
      
      Additional checks in xhci driver will also be implemented to gracefully
      handle stale URB cancel on freed and re-allocated endpoints
      
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      760c41fc
    • Oliver Neukum's avatar
      usb: uas: add support for more quirk flags · 182d1303
      Oliver Neukum authored
      commit 42d1c6d4 upstream.
      
      The hope that UAS devices would be less broken than old style storage
      devices has turned out to be unfounded. Make UAS support more of the
      quirk flags of the old driver.
      Signed-off-by: default avatarOliver Neukum <oneukum@suse.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      182d1303
    • Tim Anderson's avatar
      USB: Add quirk to support DJI CineSSD · 0845f2a4
      Tim Anderson authored
      commit f45681f9 upstream.
      
      This device does not correctly handle the LPM operations.
      
      Also, the device cannot handle ATA pass-through commands
      and locks up when attempted while running in super speed.
      
      This patch adds the equivalent quirk logic as found in uas.
      Signed-off-by: default avatarTim Anderson <tsa@biglakesoftware.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0845f2a4
    • Tomas Winkler's avatar
      mei: bus: need to unlink client before freeing · 599f1e90
      Tomas Winkler authored
      commit 34f1166a upstream.
      
      In case a client fails to connect in mei_cldev_enable(), the
      caller won't call the mei_cldev_disable leaving the client
      in a linked stated. Upon driver unload the client structure
      will be freed in  mei_cl_bus_dev_release(), leaving a stale pointer
      on a fail_list.  This will eventually end up in crash
      during power down flow in mei_cl_set_disonnected().
      
      RIP:  mei_cl_set_disconnected+0x5/0x260[mei]
      Call trace:
      mei_cl_all_disconnect+0x22/0x30
      mei_reset+0x194/0x250
      __synchronize_hardirq+0x43/0x50
      _cond_resched+0x15/0x30
      mei_me_intr_clear+0x20/0x100
      mei_stop+0x76/0xb0
      mei_me_shutdown+0x3f/0x80
      pci_device_shutdown+0x34/0x60
      kernel_restart+0x0e/0x30
      
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200455
      Fixes: 'c110cdb1 ("mei: bus: make a client pointer always available")'
      Cc: <stable@vger.kernel.org> 4.10+
      Tested-by: default avatarGeorg Müller <georgmueller@gmx.net>
      Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      599f1e90
    • Alexander Usyskin's avatar
      mei: ignore not found client in the enumeration · b5936d27
      Alexander Usyskin authored
      commit 8d2d8935 upstream.
      
      Some of the ME clients are available only for BIOS operation and are
      removed during hand off to an OS. However the removal is not instant.
      A client may be visible on the client list when the mei driver requests
      for enumeration, while the subsequent request for properties will be
      answered with client not found error value. The default behavior
      for an error is to perform client reset while this error is harmless and
      the link reset should be prevented. This issue started to be visible due to
      suspend/resume timing changes. Currently reported only on the Haswell
      based system.
      
      Fixes:
      [33.564957] mei_me 0000:00:16.0: hbm: properties response: wrong status = 1 CLIENT_NOT_FOUND
      [33.564978] mei_me 0000:00:16.0: mei_irq_read_handler ret = -71.
      [33.565270] mei_me 0000:00:16.0: unexpected reset: dev_state = INIT_CLIENTS fw status = 1E000255 60002306 00000200 00004401 00000000 00000010
      
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: default avatarAlexander Usyskin <alexander.usyskin@intel.com>
      Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b5936d27
    • Mathias Nyman's avatar
      usb: Don't die twice if PCI xhci host is not responding in resume · 4e237cfa
      Mathias Nyman authored
      commit f3dc41c5 upstream.
      
      usb_hc_died() should only be called once, and with the primary HCD
      as parameter. It will mark both primary and secondary hcd's dead.
      
      Remove the extra call to usb_cd_died with the shared hcd as parameter.
      
      Fixes: ff9d78b3 ("USB: Set usb_hcd->state and flags for shared roothubs")
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Cc: stable <stable@vger.kernel.org>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e237cfa
    • Mathias Nyman's avatar
      xhci: Fix use after free for URB cancellation on a reallocated endpoint · 58eff5e7
      Mathias Nyman authored
      commit 4937213b upstream.
      
      Make sure the cancelled URB is on the current endpoint ring.
      
      If the endpoint ring has been reallocated since the URB was enqueued
      then the URB may contain TD and TRB pointers to a already freed ring.
      In this the case return the URB without touching any of the freed ring
      structure data.
      
      Don't try to stop the ring. It would be useless.
      
      This can occur if endpoint is not flushed before it is dropped and
      re-added, which is the case in usb_set_interface() as xhci does
      things in an odd order.
      
      Cc: <stable@vger.kernel.org>
      Tested-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarMathias Nyman <mathias.nyman@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58eff5e7
    • Gustavo A. R. Silva's avatar
      misc: hmc6352: fix potential Spectre v1 · fc320be6
      Gustavo A. R. Silva authored
      commit de916736 upstream.
      
      val is indirectly controlled by user-space, hence leading to a
      potential exploitation of the Spectre variant 1 vulnerability.
      
      This issue was detected with the help of Smatch:
      
      drivers/misc/hmc6352.c:54 compass_store() warn: potential spectre issue
      'map' [r]
      
      Fix this by sanitizing val before using it to index map
      
      Notice that given that speculation windows are large, the policy is
      to kill the speculation on the first load and not worry if it can be
      completed with a dependent load/store [1].
      
      [1] https://marc.info/?l=linux-kernel&m=152449131114778&w=2
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fc320be6
    • K. Y. Srinivasan's avatar
      Tools: hv: Fix a bug in the key delete code · 47358b34
      K. Y. Srinivasan authored
      commit 86503bd3 upstream.
      
      Fix a bug in the key delete code - the num_records range
      from 0 to num_records-1.
      Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
      Reported-by: default avatarDavid Binderman <dcb314@hotmail.com>
      Cc: <stable@vger.kernel.org>
      Reviewed-by: default avatarMichael Kelley <mikelley@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      47358b34
    • Corey Minyard's avatar
      ipmi: Fix I2C client removal in the SSIF driver · 888e989a
      Corey Minyard authored
      commit 0745dde6 upstream.
      
      The SSIF driver was removing any client that came in through the
      platform interface, but it should only remove clients that it
      added.  On a failure in the probe function, this could result
      in the following oops when the driver is removed and the
      client gets unregistered twice:
      
       CPU: 107 PID: 30266 Comm: rmmod Not tainted 4.18.0+ #80
       Hardware name: Cavium Inc. Saber/Saber, BIOS Cavium reference firmware version 7.0 08/04/2018
       pstate: 60400009 (nZCv daif +PAN -UAO)
       pc : kernfs_find_ns+0x28/0x120
       lr : kernfs_find_and_get_ns+0x40/0x60
       sp : ffff00002310fb50
       x29: ffff00002310fb50 x28: ffff800a8240f800
       x27: 0000000000000000 x26: 0000000000000000
       x25: 0000000056000000 x24: ffff000009073000
       x23: ffff000008998b38 x22: 0000000000000000
       x21: ffff800ed86de820 x20: 0000000000000000
       x19: ffff00000913a1d8 x18: 0000000000000000
       x17: 0000000000000000 x16: 0000000000000000
       x15: 0000000000000000 x14: 5300737265766972
       x13: 643d4d4554535953 x12: 0000000000000030
       x11: 0000000000000030 x10: 0101010101010101
       x9 : ffff800ea06cc3f9 x8 : 0000000000000000
       x7 : 0000000000000141 x6 : ffff000009073000
       x5 : ffff800adb706b00 x4 : 0000000000000000
       x3 : 00000000ffffffff x2 : 0000000000000000
       x1 : ffff000008998b38 x0 : ffff000008356760
       Process rmmod (pid: 30266, stack limit = 0x00000000e218418d)
       Call trace:
        kernfs_find_ns+0x28/0x120
        kernfs_find_and_get_ns+0x40/0x60
        sysfs_unmerge_group+0x2c/0x6c
        dpm_sysfs_remove+0x34/0x70
        device_del+0x58/0x30c
        device_unregister+0x30/0x7c
        i2c_unregister_device+0x84/0x90 [i2c_core]
        ssif_platform_remove+0x38/0x98 [ipmi_ssif]
        platform_drv_remove+0x2c/0x6c
        device_release_driver_internal+0x168/0x1f8
        driver_detach+0x50/0xbc
        bus_remove_driver+0x74/0xe8
        driver_unregister+0x34/0x5c
        platform_driver_unregister+0x20/0x2c
        cleanup_ipmi_ssif+0x50/0xd82c [ipmi_ssif]
        __arm64_sys_delete_module+0x1b4/0x220
        el0_svc_handler+0x104/0x160
        el0_svc+0x8/0xc
       Code: aa1e03e0 aa0203f6 aa0103f7 d503201f (7940e280)
       ---[ end trace 09f0e34cce8e2d8c ]---
       Kernel panic - not syncing: Fatal exception
       SMP: stopping secondary CPUs
       Kernel Offset: disabled
       CPU features: 0x23800c38
      
      So track the clients that the SSIF driver adds and only remove
      those.
      Reported-by: default avatarGeorge Cherian <george.cherian@cavium.com>
      Signed-off-by: default avatarCorey Minyard <cminyard@mvista.com>
      Tested-by: default avatarGeorge Cherian <george.cherian@cavium.com>
      Cc: <stable@vger.kernel.org> # 4.14.x
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      888e989a
    • Andreas Kemnade's avatar
      mmc: omap_hsmmc: fix wakeirq handling on removal · f6e23e57
      Andreas Kemnade authored
      commit 3c398f3c upstream.
      
      after unbinding mmc I get things like this:
      [  185.294067] mmc1: card 0001 removed
      [  185.305206] omap_hsmmc 480b4000.mmc: wake IRQ with no resume: -13
      
      The wakeirq stays in /proc-interrupts
      
      rebinding shows this:
      [  289.795959] genirq: Flags mismatch irq 112. 0000200a (480b4000.mmc:wakeup) vs. 0000200a (480b4000.mmc:wakeup)
      [  289.808959] omap_hsmmc 480b4000.mmc: Unable to request wake IRQ
      [  289.815338] omap_hsmmc 480b4000.mmc: no SDIO IRQ support, falling back to polling
      
      That bug seems to be introduced by switching from devm_request_irq()
      to generic wakeirq handling.
      
      So let us cleanup at removal.
      Signed-off-by: default avatarAndreas Kemnade <andreas@kemnade.info>
      Fixes: 5b83b223 ("mmc: omap_hsmmc: Change wake-up interrupt to use generic wakeirq")
      Cc: stable@vger.kernel.org # v4.2+
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f6e23e57
    • Ingo Franzki's avatar
      s390/crypto: Fix return code checking in cbc_paes_crypt() · 51e8d7d7
      Ingo Franzki authored
      commit b81126e0 upstream.
      
      The return code of cpacf_kmc() is less than the number of
      bytes to process in case of an error, not greater.
      The crypt routines for the other cipher modes already have
      this correctly.
      
      Cc: stable@vger.kernel.org # v4.11+
      Fixes: 27937843 ("s390/crypt: Add protected key AES module")
      Signed-off-by: default avatarIngo Franzki <ifranzki@linux.ibm.com>
      Acked-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
      Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      51e8d7d7
    • Aaron Knister's avatar
      IB/ipoib: Avoid a race condition between start_xmit and cm_rep_handler · b8b9c7f0
      Aaron Knister authored
      commit 816e846c upstream.
      
      Inside of start_xmit() the call to check if the connection is up and the
      queueing of the packets for later transmission is not atomic which leaves
      a window where cm_rep_handler can run, set the connection up, dequeue
      pending packets and leave the subsequently queued packets by start_xmit()
      sitting on neigh->queue until they're dropped when the connection is torn
      down. This only applies to connected mode. These dropped packets can
      really upset TCP, for example, and cause multi-minute delays in
      transmission for open connections.
      
      Here's the code in start_xmit where we check to see if the connection is
      up:
      
             if (ipoib_cm_get(neigh)) {
                     if (ipoib_cm_up(neigh)) {
                             ipoib_cm_send(dev, skb, ipoib_cm_get(neigh));
                             goto unref;
                     }
             }
      
      The race occurs if cm_rep_handler execution occurs after the above
      connection check (specifically if it gets to the point where it acquires
      priv->lock to dequeue pending skb's) but before the below code snippet in
      start_xmit where packets are queued.
      
             if (skb_queue_len(&neigh->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
                     push_pseudo_header(skb, phdr->hwaddr);
                     spin_lock_irqsave(&priv->lock, flags);
                     __skb_queue_tail(&neigh->queue, skb);
                     spin_unlock_irqrestore(&priv->lock, flags);
             } else {
                     ++dev->stats.tx_dropped;
                     dev_kfree_skb_any(skb);
             }
      
      The patch acquires the netif tx lock in cm_rep_handler for the section
      where it sets the connection up and dequeues and retransmits deferred
      skb's.
      
      Fixes: 839fcaba ("IPoIB: Connected mode experimental support")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAaron Knister <aaron.s.knister@nasa.gov>
      Tested-by: default avatarIra Weiny <ira.weiny@intel.com>
      Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b8b9c7f0
    • Juergen Gross's avatar
      xen/netfront: fix waiting for xenbus state change · 33e4afbb
      Juergen Gross authored
      commit 8edfe2e9 upstream.
      
      Commit 822fb18a ("xen-netfront: wait xenbus state change when load
      module manually") added a new wait queue to wait on for a state change
      when the module is loaded manually. Unfortunately there is no wakeup
      anywhere to stop that waiting.
      
      Instead of introducing a new wait queue rename the existing
      module_unload_q to module_wq and use it for both purposes (loading and
      unloading).
      
      As any state change of the backend might be intended to stop waiting
      do the wake_up_all() in any case when netback_changed() is called.
      
      Fixes: 822fb18a ("xen-netfront: wait xenbus state change when load module manually")
      Cc: <stable@vger.kernel.org> #4.18
      Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
      Reviewed-by: default avatarBoris Ostrovsky <boris.ostrovsky@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33e4afbb
    • Bin Yang's avatar
      pstore: Fix incorrect persistent ram buffer mapping · 1e5b3877
      Bin Yang authored
      commit 831b624d upstream.
      
      persistent_ram_vmap() returns the page start vaddr.
      persistent_ram_iomap() supports non-page-aligned mapping.
      
      persistent_ram_buffer_map() always adds offset-in-page to the vaddr
      returned from these two functions, which causes incorrect mapping of
      non-page-aligned persistent ram buffer.
      
      By default ftrace_size is 4096 and max_ftrace_cnt is nr_cpu_ids. Without
      this patch, the zone_sz in ramoops_init_przs() is 4096/nr_cpu_ids which
      might not be page aligned. If the offset-in-page > 2048, the vaddr will be
      in next page. If the next page is not mapped, it will cause kernel panic:
      
      [    0.074231] BUG: unable to handle kernel paging request at ffffa19e0081b000
      ...
      [    0.075000] RIP: 0010:persistent_ram_new+0x1f8/0x39f
      ...
      [    0.075000] Call Trace:
      [    0.075000]  ramoops_init_przs.part.10.constprop.15+0x105/0x260
      [    0.075000]  ramoops_probe+0x232/0x3a0
      [    0.075000]  platform_drv_probe+0x3e/0xa0
      [    0.075000]  driver_probe_device+0x2cd/0x400
      [    0.075000]  __driver_attach+0xe4/0x110
      [    0.075000]  ? driver_probe_device+0x400/0x400
      [    0.075000]  bus_for_each_dev+0x70/0xa0
      [    0.075000]  driver_attach+0x1e/0x20
      [    0.075000]  bus_add_driver+0x159/0x230
      [    0.075000]  ? do_early_param+0x95/0x95
      [    0.075000]  driver_register+0x70/0xc0
      [    0.075000]  ? init_pstore_fs+0x4d/0x4d
      [    0.075000]  __platform_driver_register+0x36/0x40
      [    0.075000]  ramoops_init+0x12f/0x131
      [    0.075000]  do_one_initcall+0x4d/0x12c
      [    0.075000]  ? do_early_param+0x95/0x95
      [    0.075000]  kernel_init_freeable+0x19b/0x222
      [    0.075000]  ? rest_init+0xbb/0xbb
      [    0.075000]  kernel_init+0xe/0xfc
      [    0.075000]  ret_from_fork+0x3a/0x50
      Signed-off-by: default avatarBin Yang <bin.yang@intel.com>
      [kees: add comments describing the mapping differences, updated commit log]
      Fixes: 24c3d2f3 ("staging: android: persistent_ram: Make it possible to use memory outside of bootmem")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1e5b3877
    • Parav Pandit's avatar
      RDMA/cma: Protect cma dev list with lock · 8c705dea
      Parav Pandit authored
      commit 954a8e3a upstream.
      
      When AF_IB addresses are used during rdma_resolve_addr() a lock is not
      held. A cma device can get removed while list traversal is in progress
      which may lead to crash. ie
      
              CPU0                                     CPU1
              ====                                     ====
      rdma_resolve_addr()
       cma_resolve_ib_dev()
        list_for_each()                         cma_remove_one()
          cur_dev->device                        mutex_lock(&lock)
                                                  list_del();
                                                 mutex_unlock(&lock);
                                                 cma_process_remove();
      
      
      Therefore, hold a lock while traversing the list which avoids such
      situation.
      
      Cc: <stable@vger.kernel.org> # 3.10
      Fixes: f17df3b0 ("RDMA/cma: Add support for AF_IB to rdma_resolve_addr()")
      Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
      Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
      Reviewed-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8c705dea
    • Xiao Liang's avatar
      xen-netfront: fix warn message as irq device name has '/' · a5d24760
      Xiao Liang authored
      [ Upstream commit 21f2706b ]
      
      There is a call trace generated after commit 2d408c0d(
      xen-netfront: fix queue name setting). There is no 'device/vif/xx-q0-tx' file found
      under /proc/irq/xx/.
      
      This patch only picks up device type and id as its name.
      
      With the patch, now /proc/interrupts looks like below and the warning message gone:
       70:         21          0          0          0   xen-dyn    -event     vif0-q0-tx
       71:         15          0          0          0   xen-dyn    -event     vif0-q0-rx
       72:         14          0          0          0   xen-dyn    -event     vif0-q1-tx
       73:         33          0          0          0   xen-dyn    -event     vif0-q1-rx
       74:         12          0          0          0   xen-dyn    -event     vif0-q2-tx
       75:         24          0          0          0   xen-dyn    -event     vif0-q2-rx
       76:         19          0          0          0   xen-dyn    -event     vif0-q3-tx
       77:         21          0          0          0   xen-dyn    -event     vif0-q3-rx
      
      Below is call trace information without this patch:
      
      name 'device/vif/0-q0-tx'
      WARNING: CPU: 2 PID: 37 at fs/proc/generic.c:174 __xlate_proc_name+0x85/0xa0
      RIP: 0010:__xlate_proc_name+0x85/0xa0
      RSP: 0018:ffffb85c40473c18 EFLAGS: 00010286
      RAX: 0000000000000000 RBX: 0000000000000006 RCX: 0000000000000006
      RDX: 0000000000000007 RSI: 0000000000000096 RDI: ffff984c7f516930
      RBP: ffffb85c40473cb8 R08: 000000000000002c R09: 0000000000000229
      R10: 0000000000000000 R11: 0000000000000001 R12: ffffb85c40473c98
      R13: ffffb85c40473cb8 R14: ffffb85c40473c50 R15: 0000000000000000
      FS:  0000000000000000(0000) GS:ffff984c7f500000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007f69b6899038 CR3: 000000001c20a006 CR4: 00000000001606e0
      Call Trace:
      __proc_create+0x45/0x230
      ? snprintf+0x49/0x60
      proc_mkdir_data+0x35/0x90
      register_handler_proc+0xef/0x110
      ? proc_register+0xfc/0x110
      ? proc_create_data+0x70/0xb0
      __setup_irq+0x39b/0x660
      ? request_threaded_irq+0xad/0x160
      request_threaded_irq+0xf5/0x160
      ? xennet_tx_buf_gc+0x1d0/0x1d0 [xen_netfront]
      bind_evtchn_to_irqhandler+0x3d/0x70
      ? xenbus_alloc_evtchn+0x41/0xa0
      netback_changed+0xa46/0xcda [xen_netfront]
      ? find_watch+0x40/0x40
      xenwatch_thread+0xc5/0x160
      ? finish_wait+0x80/0x80
      kthread+0x112/0x130
      ? kthread_create_worker_on_cpu+0x70/0x70
      ret_from_fork+0x35/0x40
      Code: 81 5c 00 48 85 c0 75 cc 5b 49 89 2e 31 c0 5d 4d 89 3c 24 41 5c 41 5d 41 5e 41 5f c3 4c 89 ee 48 c7 c7 40 4f 0e b4 e8 65 ea d8 ff <0f> 0b b8 fe ff ff ff 5b 5d 41 5c 41 5d 41 5e 41 5f c3 66 0f 1f
      ---[ end trace 650e5561b0caab3a ]---
      Signed-off-by: default avatarXiao Liang <xiliang@redhat.com>
      Reviewed-by: default avatarJuergen Gross <jgross@suse.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a5d24760