1. 02 Apr, 2020 40 commits
    • Matthias Reichl's avatar
      USB: cdc-acm: restore capability check order · 4826a0be
      Matthias Reichl authored
      commit 62d65bdd upstream.
      
      commit b401f8c4 ("USB: cdc-acm: fix rounding error in TIOCSSERIAL")
      introduced a regression by changing the order of capability and close
      settings change checks. When running with CAP_SYS_ADMIN setting the
      close settings to the values already set resulted in -EOPNOTSUPP.
      
      Fix this by changing the check order back to how it was before.
      
      Fixes: b401f8c4 ("USB: cdc-acm: fix rounding error in TIOCSSERIAL")
      Cc: Anthony Mallet <anthony.mallet@laas.fr>
      Cc: stable <stable@vger.kernel.org>
      Cc: Oliver Neukum <oneukum@suse.com>
      Signed-off-by: default avatarMatthias Reichl <hias@horus.com>
      Link: https://lore.kernel.org/r/20200327150350.3657-1-hias@horus.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4826a0be
    • Pawel Dembicki's avatar
      USB: serial: option: add Wistron Neweb D19Q1 · ce6edbf0
      Pawel Dembicki authored
      commit dfee7e2f upstream.
      
      This modem is embedded on dlink dwr-960 router.
      The oem configuration states:
      
      T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=480 MxCh= 0
      D: Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
      P: Vendor=1435 ProdID=d191 Rev=ff.ff
      S: Manufacturer=Android
      S: Product=Android
      S: SerialNumber=0123456789ABCDEF
      C:* #Ifs= 6 Cfg#= 1 Atr=80 MxPwr=500mA
      I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
      E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)
      E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
      E: Ad=84(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
      E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
      E: Ad=86(I) Atr=03(Int.) MxPS= 10 Ivl=32ms
      E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
      E: Ad=88(I) Atr=03(Int.) MxPS= 8 Ivl=32ms
      E: Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 5 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none)
      E: Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E: Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=125us
      
      Tested on openwrt distribution
      Signed-off-by: default avatarPawel Dembicki <paweldembicki@gmail.com>
      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>
      ce6edbf0
    • Pawel Dembicki's avatar
      USB: serial: option: add BroadMobi BM806U · 251acc89
      Pawel Dembicki authored
      commit 6cb2669c upstream.
      
      BroadMobi BM806U is an Qualcomm MDM9225 based 3G/4G modem.
      Tested hardware BM806U is mounted on D-Link DWR-921-C3 router.
      
      T:  Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
      D:  Ver= 2.01 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
      P:  Vendor=2020 ProdID=2033 Rev= 2.28
      S:  Manufacturer=Mobile Connect
      S:  Product=Mobile Connect
      S:  SerialNumber=f842866cfd5a
      C:* #Ifs= 5 Cfg#= 1 Atr=80 MxPwr=500mA
      I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
      E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
      E:  Ad=83(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
      E:  Ad=85(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
      E:  Ad=87(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
      E:  Ad=89(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
      E:  Ad=88(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      Co-developed-by: default avatarCezary Jackiewicz <cezary@eko.one.pl>
      Signed-off-by: default avatarCezary Jackiewicz <cezary@eko.one.pl>
      Signed-off-by: default avatarPawel Dembicki <paweldembicki@gmail.com>
      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>
      251acc89
    • Pawel Dembicki's avatar
      USB: serial: option: add support for ASKEY WWHC050 · ae1050f4
      Pawel Dembicki authored
      commit 007d20dc upstream.
      
      ASKEY WWHC050 is a mcie LTE modem.
      The oem configuration states:
      
      T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
      D:  Ver= 2.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
      P:  Vendor=1690 ProdID=7588 Rev=ff.ff
      S:  Manufacturer=Android
      S:  Product=Android
      S:  SerialNumber=813f0eef6e6e
      C:* #Ifs= 6 Cfg#= 1 Atr=80 MxPwr=500mA
      I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
      E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=42 Prot=01 Driver=(none)
      E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
      E:  Ad=84(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
      E:  Ad=86(I) Atr=03(Int.) MxPS=  10 Ivl=32ms
      E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 4 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=qmi_wwan
      E:  Ad=88(I) Atr=03(Int.) MxPS=   8 Ivl=32ms
      E:  Ad=87(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      I:* If#= 5 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none)
      E:  Ad=89(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
      E:  Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=125us
      
      Tested on openwrt distribution.
      Co-developed-by: default avatarCezary Jackiewicz <cezary@eko.one.pl>
      Signed-off-by: default avatarCezary Jackiewicz <cezary@eko.one.pl>
      Signed-off-by: default avatarPawel Dembicki <paweldembicki@gmail.com>
      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>
      ae1050f4
    • Masami Hiramatsu's avatar
      tools: Let O= makes handle a relative path with -C option · aae6b58c
      Masami Hiramatsu authored
      [ Upstream commit be40920f ]
      
      When I tried to compile tools/perf from the top directory with the -C
      option, the O= option didn't work correctly if I passed a relative path:
      
        $ make O=BUILD -C tools/perf/
        make: Entering directory '/home/mhiramat/ksrc/linux/tools/perf'
          BUILD:   Doing 'make -j8' parallel build
        ../scripts/Makefile.include:4: *** O=/home/mhiramat/ksrc/linux/tools/perf/BUILD does not exist.  Stop.
        make: *** [Makefile:70: all] Error 2
        make: Leaving directory '/home/mhiramat/ksrc/linux/tools/perf'
      
      The O= directory existence check failed because the check script ran in
      the build target directory instead of the directory where I ran the make
      command.
      
      To fix that, once change directory to $(PWD) and check O= directory,
      since the PWD is set to where the make command runs.
      
      Fixes: c883122a ("perf tools: Let O= makes handle relative paths")
      Reported-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Michal Marek <michal.lkml@markovi.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sasha Levin <sashal@kernel.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: stable@vger.kernel.org
      Link: http://lore.kernel.org/lkml/158351957799.3363.15269768530697526765.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      aae6b58c
    • Dan Carpenter's avatar
      Input: raydium_i2c_ts - fix error codes in raydium_i2c_boot_trigger() · fbd5896b
      Dan Carpenter authored
      [ Upstream commit 32cf3a61 ]
      
      These functions are supposed to return negative error codes but instead
      it returns true on failure and false on success.  The error codes are
      eventually propagated back to user space.
      
      Fixes: 48a2b783 ("Input: add Raydium I2C touchscreen driver")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Link: https://lore.kernel.org/r/20200303101306.4potflz7na2nn3od@kili.mountain
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fbd5896b
    • Gustavo A. R. Silva's avatar
      Input: raydium_i2c_ts - use true and false for boolean values · 9ff4173c
      Gustavo A. R. Silva authored
      [ Upstream commit 6cad4e26 ]
      
      Return statements in functions returning bool should use true or false
      instead of an integer value.
      
      This code was detected with the help of Coccinelle.
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9ff4173c
    • Torsten Hilbrich's avatar
      vti6: Fix memory leak of skb if input policy check fails · 75815657
      Torsten Hilbrich authored
      commit 2a9de3af upstream.
      
      The vti6_rcv function performs some tests on the retrieved tunnel
      including checking the IP protocol, the XFRM input policy, the
      source and destination address.
      
      In all but one places the skb is released in the error case. When
      the input policy check fails the network packet is leaked.
      
      Using the same goto-label discard in this case to fix this problem.
      
      Fixes: ed1efb2a ("ipv6: Add support for IPsec virtual tunnel interfaces")
      Signed-off-by: default avatarTorsten Hilbrich <torsten.hilbrich@secunet.com>
      Reviewed-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75815657
    • Pablo Neira Ayuso's avatar
      netfilter: nft_fwd_netdev: validate family and chain type · 282fd1fb
      Pablo Neira Ayuso authored
      commit 76a109fa upstream.
      
      Make sure the forward action is only used from ingress.
      
      Fixes: 39e6dea2 ("netfilter: nf_tables: add forward expression to the netdev family")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      282fd1fb
    • YueHaibing's avatar
      xfrm: policy: Fix doulbe free in xfrm_policy_timer · 86e98ce7
      YueHaibing authored
      commit 4c59406e upstream.
      
      After xfrm_add_policy add a policy, its ref is 2, then
      
                                   xfrm_policy_timer
                                     read_lock
                                     xp->walk.dead is 0
                                     ....
                                     mod_timer()
      xfrm_policy_kill
        policy->walk.dead = 1
        ....
        del_timer(&policy->timer)
          xfrm_pol_put //ref is 1
        xfrm_pol_put  //ref is 0
          xfrm_policy_destroy
            call_rcu
                                       xfrm_pol_hold //ref is 1
                                     read_unlock
                                     xfrm_pol_put //ref is 0
                                       xfrm_policy_destroy
                                        call_rcu
      
      xfrm_policy_destroy is called twice, which may leads to
      double free.
      
      Call Trace:
      RIP: 0010:refcount_warn_saturate+0x161/0x210
      ...
       xfrm_policy_timer+0x522/0x600
       call_timer_fn+0x1b3/0x5e0
       ? __xfrm_decode_session+0x2990/0x2990
       ? msleep+0xb0/0xb0
       ? _raw_spin_unlock_irq+0x24/0x40
       ? __xfrm_decode_session+0x2990/0x2990
       ? __xfrm_decode_session+0x2990/0x2990
       run_timer_softirq+0x5c5/0x10e0
      
      Fix this by use write_lock_bh in xfrm_policy_kill.
      
      Fixes: ea2dea9d ("xfrm: remove policy lock when accessing policy->walk.dead")
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Acked-by: default avatarTimo Teräs <timo.teras@iki.fi>
      Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86e98ce7
    • Xin Long's avatar
      xfrm: add the missing verify_sec_ctx_len check in xfrm_add_acquire · c2e254ef
      Xin Long authored
      commit a1a7e3a3 upstream.
      
      Without doing verify_sec_ctx_len() check in xfrm_add_acquire(), it may be
      out-of-bounds to access uctx->ctx_str with uctx->ctx_len, as noticed by
      syz:
      
        BUG: KASAN: slab-out-of-bounds in selinux_xfrm_alloc_user+0x237/0x430
        Read of size 768 at addr ffff8880123be9b4 by task syz-executor.1/11650
      
        Call Trace:
         dump_stack+0xe8/0x16e
         print_address_description.cold.3+0x9/0x23b
         kasan_report.cold.4+0x64/0x95
         memcpy+0x1f/0x50
         selinux_xfrm_alloc_user+0x237/0x430
         security_xfrm_policy_alloc+0x5c/0xb0
         xfrm_policy_construct+0x2b1/0x650
         xfrm_add_acquire+0x21d/0xa10
         xfrm_user_rcv_msg+0x431/0x6f0
         netlink_rcv_skb+0x15a/0x410
         xfrm_netlink_rcv+0x6d/0x90
         netlink_unicast+0x50e/0x6a0
         netlink_sendmsg+0x8ae/0xd40
         sock_sendmsg+0x133/0x170
         ___sys_sendmsg+0x834/0x9a0
         __sys_sendmsg+0x100/0x1e0
         do_syscall_64+0xe5/0x660
         entry_SYSCALL_64_after_hwframe+0x6a/0xdf
      
      So fix it by adding the missing verify_sec_ctx_len check there.
      
      Fixes: 980ebd25 ("[IPSEC]: Sync series - acquire insert")
      Reported-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c2e254ef
    • Xin Long's avatar
      xfrm: fix uctx len check in verify_sec_ctx_len · fa40d12e
      Xin Long authored
      commit 171d449a upstream.
      
      It's not sufficient to do 'uctx->len != (sizeof(struct xfrm_user_sec_ctx) +
      uctx->ctx_len)' check only, as uctx->len may be greater than nla_len(rt),
      in which case it will cause slab-out-of-bounds when accessing uctx->ctx_str
      later.
      
      This patch is to fix it by return -EINVAL when uctx->len > nla_len(rt).
      
      Fixes: df71837d ("[LSM-IPSec]: Security association restriction.")
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fa40d12e
    • Nicolas Dichtel's avatar
      vti[6]: fix packet tx through bpf_redirect() in XinY cases · 0807f594
      Nicolas Dichtel authored
      commit f1ed1026 upstream.
      
      I forgot the 4in6/6in4 cases in my previous patch. Let's fix them.
      
      Fixes: 95224166 ("vti[6]: fix packet tx through bpf_redirect()")
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0807f594
    • Edward Cree's avatar
      genirq: Fix reference leaks on irq affinity notifiers · cc24d74e
      Edward Cree authored
      commit df81dfcf upstream.
      
      The handling of notify->work did not properly maintain notify->kref in two
       cases:
      1) where the work was already scheduled, another irq_set_affinity_locked()
         would get the ref and (no-op-ly) schedule the work.  Thus when
         irq_affinity_notify() ran, it would drop the original ref but not the
         additional one.
      2) when cancelling the (old) work in irq_set_affinity_notifier(), if there
         was outstanding work a ref had been got for it but was never put.
      Fix both by checking the return values of the work handling functions
       (schedule_work() for (1) and cancel_work_sync() for (2)) and put the
       extra ref if the return value indicates preexisting work.
      
      Fixes: cd7eab44 ("genirq: Add IRQ affinity notifiers")
      Fixes: 59c39840 ("genirq: Prevent use-after-free and work list corruption")
      Signed-off-by: default avatarEdward Cree <ecree@solarflare.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Acked-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Link: https://lkml.kernel.org/r/24f5983f-2ab5-e83a-44ee-a45b5f9300f5@solarflare.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cc24d74e
    • Johannes Berg's avatar
      mac80211: mark station unauthorized before key removal · e52d8aff
      Johannes Berg authored
      commit b16798f5 upstream.
      
      If a station is still marked as authorized, mark it as no longer
      so before removing its keys. This allows frames transmitted to it
      to be rejected, providing additional protection against leaking
      plain text data during the disconnection flow.
      
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20200326155133.ccb4fb0bb356.If48f0f0504efdcf16b8921f48c6d3bb2cb763c99@changeidSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e52d8aff
    • Martin K. Petersen's avatar
      scsi: sd: Fix optimal I/O size for devices that change reported values · 95b526e7
      Martin K. Petersen authored
      commit ea697a8b upstream.
      
      Some USB bridge devices will return a default set of characteristics during
      initialization. And then, once an attached drive has spun up, substitute
      the actual parameters reported by the drive. According to the SCSI spec,
      the device should return a UNIT ATTENTION in case any reported parameters
      change. But in this case the change is made silently after a small window
      where default values are reported.
      
      Commit a83da8a4 ("scsi: sd: Optimal I/O size should be a multiple of
      physical block size") validated the reported optimal I/O size against the
      physical block size to overcome problems with devices reporting nonsensical
      transfer sizes. However, this validation did not account for the fact that
      aforementioned devices will return default values during a brief window
      during spin-up. The subsequent change in reported characteristics would
      invalidate the checking that had previously been performed.
      
      Unset a previously configured optimal I/O size should the sanity checking
      fail on subsequent revalidate attempts.
      
      Link: https://lore.kernel.org/r/33fb522e-4f61-1b76-914f-c9e6a3553c9b@gmail.com
      Cc: Bryan Gurney <bgurney@redhat.com>
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarBernhard Sulzer <micraft.b@gmail.com>
      Tested-by: default avatarBernhard Sulzer <micraft.b@gmail.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      95b526e7
    • Dirk Mueller's avatar
      scripts/dtc: Remove redundant YYLOC global declaration · 8e8ab855
      Dirk Mueller authored
      commit e33a814e upstream.
      
      gcc 10 will default to -fno-common, which causes this error at link
      time:
      
        (.text+0x0): multiple definition of `yylloc'; dtc-lexer.lex.o (symbol from plugin):(.text+0x0): first defined here
      
      This is because both dtc-lexer as well as dtc-parser define the same
      global symbol yyloc. Before with -fcommon those were merged into one
      defintion. The proper solution would be to to mark this as "extern",
      however that leads to:
      
        dtc-lexer.l:26:16: error: redundant redeclaration of 'yylloc' [-Werror=redundant-decls]
         26 | extern YYLTYPE yylloc;
            |                ^~~~~~
      In file included from dtc-lexer.l:24:
      dtc-parser.tab.h:127:16: note: previous declaration of 'yylloc' was here
        127 | extern YYLTYPE yylloc;
            |                ^~~~~~
      cc1: all warnings being treated as errors
      
      which means the declaration is completely redundant and can just be
      dropped.
      Signed-off-by: default avatarDirk Mueller <dmueller@suse.com>
      Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
      [robh: cherry-pick from upstream]
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      [nc: Also apply to dtc-lexer.lex.c_shipped due to a lack of
           e039139b, where dtc-lexer.l started being used]
      Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e8ab855
    • Masami Hiramatsu's avatar
      perf probe: Do not depend on dwfl_module_addrsym() · 791b3ea2
      Masami Hiramatsu authored
      commit 1efde275 upstream.
      
      Do not depend on dwfl_module_addrsym() because it can fail on user-space
      shared libraries.
      
      Actually, same bug was fixed by commit 664fee3d ("perf probe: Do not
      use dwfl_module_addrsym if dwarf_diename finds symbol name"), but commit
      07d36985 ("perf probe: Fix wrong address verification) reverted to
      get actual symbol address from symtab.
      
      This fixes it again by getting symbol address from DIE, and only if the
      DIE has only address range, it uses dwfl_module_addrsym().
      
      Fixes: 07d36985 ("perf probe: Fix wrong address verification)
      Reported-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: default avatarAlexandre Ghiti <alex@ghiti.fr>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Sasha Levin <sashal@kernel.org>
      Link: http://lore.kernel.org/lkml/158281812176.476.14164573830975116234.stgit@devnote2Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      791b3ea2
    • Roger Quadros's avatar
      ARM: dts: omap5: Add bus_dma_limit for L3 bus · 7ff9fb22
      Roger Quadros authored
      commit dfa7ea30 upstream.
      
      The L3 interconnect's memory map is from 0x0 to
      0xffffffff. Out of this, System memory (SDRAM) can be
      accessed from 0x80000000 to 0xffffffff (2GB)
      
      OMAP5 does support 4GB of SDRAM but upper 2GB can only be
      accessed by the MPU subsystem.
      
      Add the dma-ranges property to reflect the physical address limit
      of the L3 bus.
      
      Cc: stable@kernel.org
      Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ff9fb22
    • Roger Quadros's avatar
      ARM: dts: dra7: Add bus_dma_limit for L3 bus · 35e50a4f
      Roger Quadros authored
      commit cfb5d65f upstream.
      
      The L3 interconnect's memory map is from 0x0 to
      0xffffffff. Out of this, System memory (SDRAM) can be
      accessed from 0x80000000 to 0xffffffff (2GB)
      
      DRA7 does support 4GB of SDRAM but upper 2GB can only be
      accessed by the MPU subsystem.
      
      Add the dma-ranges property to reflect the physical address limit
      of the L3 bus.
      
      Issues ere observed only with SATA on DRA7-EVM with 4GB RAM
      and CONFIG_ARM_LPAE enabled. This is because the controller
      supports 64-bit DMA and its driver sets the dma_mask to 64-bit
      thus resulting in DMA accesses beyond L3 limit of 2G.
      
      Setting the correct bus_dma_limit fixes the issue.
      Signed-off-by: default avatarRoger Quadros <rogerq@ti.com>
      Cc: stable@kernel.org
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35e50a4f
    • Chuhong Yuan's avatar
      i2c: hix5hd2: add missed clk_disable_unprepare in remove · 01d5bf94
      Chuhong Yuan authored
      commit e1b9f99f upstream.
      
      The driver forgets to disable and unprepare clk when remove.
      Add a call to clk_disable_unprepare to fix it.
      Signed-off-by: default avatarChuhong Yuan <hslester96@gmail.com>
      Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
      Cc: stable@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      01d5bf94
    • Dominik Czarnota's avatar
      sxgbe: Fix off by one in samsung driver strncpy size arg · 2f5432ef
      Dominik Czarnota authored
      [ Upstream commit f3cc008b ]
      
      This patch fixes an off-by-one error in strncpy size argument in
      drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c. The issue is that in:
      
              strncmp(opt, "eee_timer:", 6)
      
      the passed string literal: "eee_timer:" has 10 bytes (without the NULL
      byte) and the passed size argument is 6. As a result, the logic will
      also accept other, malformed strings, e.g. "eee_tiXXX:".
      
      This bug doesn't seem to have any security impact since its present in
      module's cmdline parsing code.
      Signed-off-by: default avatarDominik Czarnota <dominik.b.czarnota@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2f5432ef
    • Nicolas Cavallari's avatar
      mac80211: Do not send mesh HWMP PREQ if HWMP is disabled · a8351c8a
      Nicolas Cavallari authored
      [ Upstream commit ba32679c ]
      
      When trying to transmit to an unknown destination, the mesh code would
      unconditionally transmit a HWMP PREQ even if HWMP is not the current
      path selection algorithm.
      Signed-off-by: default avatarNicolas Cavallari <nicolas.cavallari@green-communications.fr>
      Link: https://lore.kernel.org/r/20200305140409.12204-1-cavallar@lri.frSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a8351c8a
    • Wen Xiong's avatar
      scsi: ipr: Fix softlockup when rescanning devices in petitboot · 9509c913
      Wen Xiong authored
      [ Upstream commit 394b6171 ]
      
      When trying to rescan disks in petitboot shell, we hit the following
      softlockup stacktrace:
      
      Kernel panic - not syncing: System is deadlocked on memory
      [  241.223394] CPU: 32 PID: 693 Comm: sh Not tainted 5.4.16-openpower1 #1
      [  241.223406] Call Trace:
      [  241.223415] [c0000003f07c3180] [c000000000493fc4] dump_stack+0xa4/0xd8 (unreliable)
      [  241.223432] [c0000003f07c31c0] [c00000000007d4ac] panic+0x148/0x3cc
      [  241.223446] [c0000003f07c3260] [c000000000114b10] out_of_memory+0x468/0x4c4
      [  241.223461] [c0000003f07c3300] [c0000000001472b0] __alloc_pages_slowpath+0x594/0x6d8
      [  241.223476] [c0000003f07c3420] [c00000000014757c] __alloc_pages_nodemask+0x188/0x1a4
      [  241.223492] [c0000003f07c34a0] [c000000000153e10] alloc_pages_current+0xcc/0xd8
      [  241.223508] [c0000003f07c34e0] [c0000000001577ac] alloc_slab_page+0x30/0x98
      [  241.223524] [c0000003f07c3520] [c0000000001597fc] new_slab+0x138/0x40c
      [  241.223538] [c0000003f07c35f0] [c00000000015b204] ___slab_alloc+0x1e4/0x404
      [  241.223552] [c0000003f07c36c0] [c00000000015b450] __slab_alloc+0x2c/0x48
      [  241.223566] [c0000003f07c36f0] [c00000000015b754] kmem_cache_alloc_node+0x9c/0x1b4
      [  241.223582] [c0000003f07c3760] [c000000000218c48] blk_alloc_queue_node+0x34/0x270
      [  241.223599] [c0000003f07c37b0] [c000000000226574] blk_mq_init_queue+0x2c/0x78
      [  241.223615] [c0000003f07c37e0] [c0000000002ff710] scsi_mq_alloc_queue+0x28/0x70
      [  241.223631] [c0000003f07c3810] [c0000000003005b8] scsi_alloc_sdev+0x184/0x264
      [  241.223647] [c0000003f07c38a0] [c000000000300ba0] scsi_probe_and_add_lun+0x288/0xa3c
      [  241.223663] [c0000003f07c3a00] [c000000000301768] __scsi_scan_target+0xcc/0x478
      [  241.223679] [c0000003f07c3b20] [c000000000301c64] scsi_scan_channel.part.9+0x74/0x7c
      [  241.223696] [c0000003f07c3b70] [c000000000301df4] scsi_scan_host_selected+0xe0/0x158
      [  241.223712] [c0000003f07c3bd0] [c000000000303f04] store_scan+0x104/0x114
      [  241.223727] [c0000003f07c3cb0] [c0000000002d5ac4] dev_attr_store+0x30/0x4c
      [  241.223741] [c0000003f07c3cd0] [c0000000001dbc34] sysfs_kf_write+0x64/0x78
      [  241.223756] [c0000003f07c3cf0] [c0000000001da858] kernfs_fop_write+0x170/0x1b8
      [  241.223773] [c0000003f07c3d40] [c0000000001621fc] __vfs_write+0x34/0x60
      [  241.223787] [c0000003f07c3d60] [c000000000163c2c] vfs_write+0xa8/0xcc
      [  241.223802] [c0000003f07c3db0] [c000000000163df4] ksys_write+0x70/0xbc
      [  241.223816] [c0000003f07c3e20] [c00000000000b40c] system_call+0x5c/0x68
      
      As a part of the scan process Linux will allocate and configure a
      scsi_device for each target to be scanned. If the device is not present,
      then the scsi_device is torn down. As a part of scsi_device teardown a
      workqueue item will be scheduled and the lockups we see are because there
      are 250k workqueue items to be processed.  Accoding to the specification of
      SIS-64 sas controller, max_channel should be decreased on SIS-64 adapters
      to 4.
      
      The patch fixes softlockup issue.
      
      Thanks for Oliver Halloran's help with debugging and explanation!
      
      Link: https://lore.kernel.org/r/1583510248-23672-1-git-send-email-wenxiong@linux.vnet.ibm.comSigned-off-by: default avatarWen Xiong <wenxiong@linux.vnet.ibm.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9509c913
    • Madalin Bucur's avatar
      dt-bindings: net: FMan erratum A050385 · 4fe8dc06
      Madalin Bucur authored
      [ Upstream commit 26d5bb9e ]
      
      FMAN DMA read or writes under heavy traffic load may cause FMAN
      internal resource leak; thus stopping further packet processing.
      
      The FMAN internal queue can overflow when FMAN splits single
      read or write transactions into multiple smaller transactions
      such that more than 17 AXI transactions are in flight from FMAN
      to interconnect. When the FMAN internal queue overflows, it can
      stall further packet processing. The issue can occur with any one
      of the following three conditions:
      
        1. FMAN AXI transaction crosses 4K address boundary (Errata
           A010022)
        2. FMAN DMA address for an AXI transaction is not 16 byte
           aligned, i.e. the last 4 bits of an address are non-zero
        3. Scatter Gather (SG) frames have more than one SG buffer in
           the SG list and any one of the buffers, except the last
           buffer in the SG list has data size that is not a multiple
           of 16 bytes, i.e., other than 16, 32, 48, 64, etc.
      
      With any one of the above three conditions present, there is
      likelihood of stalled FMAN packet processing, especially under
      stress with multiple ports injecting line-rate traffic.
      
      To avoid situations that stall FMAN packet processing, all of the
      above three conditions must be avoided; therefore, configure the
      system with the following rules:
      
        1. Frame buffers must not span a 4KB address boundary, unless
           the frame start address is 256 byte aligned
        2. All FMAN DMA start addresses (for example, BMAN buffer
           address, FD[address] + FD[offset]) are 16B aligned
        3. SG table and buffer addresses are 16B aligned and the size
           of SG buffers are multiple of 16 bytes, except for the last
           SG buffer that can be of any size.
      
      Additional workaround notes:
      - Address alignment of 64 bytes is recommended for maximally
      efficient system bus transactions (although 16 byte alignment is
      sufficient to avoid the stall condition)
      - To support frame sizes that are larger than 4K bytes, there are
      two options:
        1. Large single buffer frames that span a 4KB page boundary can
           be converted into SG frames to avoid transaction splits at
           the 4KB boundary,
        2. Align the large single buffer to 256B address boundaries,
           ensure that the frame address plus offset is 256B aligned.
      - If software generated SG frames have buffers that are unaligned
      and with random non-multiple of 16 byte lengths, before
      transmitting such frames via FMAN, frames will need to be copied
      into a new single buffer or multiple buffer SG frame that is
      compliant with the three rules listed above.
      Signed-off-by: default avatarMadalin Bucur <madalin.bucur@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4fe8dc06
    • Mike Gilbert's avatar
      cpupower: avoid multiple definition with gcc -fno-common · 85e8b90e
      Mike Gilbert authored
      [ Upstream commit 2de7fb60 ]
      
      Building cpupower with -fno-common in CFLAGS results in errors due to
      multiple definitions of the 'cpu_count' and 'start_time' variables.
      
      ./utils/idle_monitor/snb_idle.o:./utils/idle_monitor/cpupower-monitor.h:28:
      multiple definition of `cpu_count';
      ./utils/idle_monitor/nhm_idle.o:./utils/idle_monitor/cpupower-monitor.h:28:
      first defined here
      ...
      ./utils/idle_monitor/cpuidle_sysfs.o:./utils/idle_monitor/cpuidle_sysfs.c:22:
      multiple definition of `start_time';
      ./utils/idle_monitor/amd_fam14h_idle.o:./utils/idle_monitor/amd_fam14h_idle.c:85:
      first defined here
      
      The -fno-common option will be enabled by default in GCC 10.
      
      Bug: https://bugs.gentoo.org/707462Signed-off-by: default avatarMike Gilbert <floppym@gentoo.org>
      Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      85e8b90e
    • Sabrina Dubroca's avatar
      net: ipv4: don't let PMTU updates increase route MTU · 14c137ce
      Sabrina Dubroca authored
      [ Upstream commit 28d35bcd ]
      
      When an MTU update with PMTU smaller than net.ipv4.route.min_pmtu is
      received, we must clamp its value. However, we can receive a PMTU
      exception with PMTU < old_mtu < ip_rt_min_pmtu, which would lead to an
      increase in PMTU.
      
      To fix this, take the smallest of the old MTU and ip_rt_min_pmtu.
      
      Before this patch, in case of an update, the exception's MTU would
      always change. Now, an exception can have only its lock flag updated,
      but not the MTU, so we need to add a check on locking to the following
      "is this exception getting updated, or close to expiring?" test.
      
      Fixes: d52e5a7e ("ipv4: lock mtu in fnhe when received PMTU < net.ipv4.route.min_pmtu")
      Signed-off-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Reviewed-by: default avatarStefano Brivio <sbrivio@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      14c137ce
    • Sean Christopherson's avatar
      KVM: VMX: Do not allow reexecute_instruction() when skipping MMIO instr · 6be2735f
      Sean Christopherson authored
      [ Upstream commit c4409905 ]
      
      Re-execution after an emulation decode failure is only intended to
      handle a case where two or vCPUs race to write a shadowed page, i.e.
      we should never re-execute an instruction as part of MMIO emulation.
      As handle_ept_misconfig() is only used for MMIO emulation, it should
      pass EMULTYPE_NO_REEXECUTE when using the emulator to skip an instr
      in the fast-MMIO case where VM_EXIT_INSTRUCTION_LEN is invalid.
      
      And because the cr2 value passed to x86_emulate_instruction() is only
      destined for use when retrying or reexecuting, we can simply call
      emulate_instruction().
      
      Fixes: d391f120 ("x86/kvm/vmx: do not use vm-exit instruction length
                            for fast MMIO when running nested")
      Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6be2735f
    • Taehee Yoo's avatar
      hsr: set .netnsok flag · 03e7234b
      Taehee Yoo authored
      [ Upstream commit 09e91dbe ]
      
      The hsr module has been supporting the list and status command.
      (HSR_C_GET_NODE_LIST and HSR_C_GET_NODE_STATUS)
      These commands send node information to the user-space via generic netlink.
      But, in the non-init_net namespace, these commands are not allowed
      because .netnsok flag is false.
      So, there is no way to get node information in the non-init_net namespace.
      
      Fixes: f421436a ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      03e7234b
    • Taehee Yoo's avatar
      hsr: add restart routine into hsr_get_node_list() · c669c937
      Taehee Yoo authored
      [ Upstream commit ca19c70f ]
      
      The hsr_get_node_list() is to send node addresses to the userspace.
      If there are so many nodes, it could fail because of buffer size.
      In order to avoid this failure, the restart routine is added.
      
      Fixes: f421436a ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c669c937
    • Taehee Yoo's avatar
      hsr: use rcu_read_lock() in hsr_get_node_{list/status}() · 9bc97bc6
      Taehee Yoo authored
      [ Upstream commit 173756b8 ]
      
      hsr_get_node_{list/status}() are not under rtnl_lock() because
      they are callback functions of generic netlink.
      But they use __dev_get_by_index() without rtnl_lock().
      So, it would use unsafe data.
      In order to fix it, rcu_read_lock() and dev_get_by_index_rcu()
      are used instead of __dev_get_by_index().
      
      Fixes: f421436a ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9bc97bc6
    • Jisheng Zhang's avatar
      net: mvneta: Fix the case where the last poll did not process all rx · dabbf0e8
      Jisheng Zhang authored
      [ Upstream commit 065fd83e ]
      
      For the case where the last mvneta_poll did not process all
      RX packets, we need to xor the pp->cause_rx_tx or port->cause_rx_tx
      before claculating the rx_queue.
      
      Fixes: 2dcf75e2 ("net: mvneta: Associate RX queues with each CPU")
      Signed-off-by: default avatarJisheng Zhang <Jisheng.Zhang@synaptics.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dabbf0e8
    • Taehee Yoo's avatar
      vxlan: check return value of gro_cells_init() · cc42f986
      Taehee Yoo authored
      [ Upstream commit 384d91c2 ]
      
      gro_cells_init() returns error if memory allocation is failed.
      But the vxlan module doesn't check the return value of gro_cells_init().
      
      Fixes: 58ce31cc ("vxlan: GRO support at tunnel layer")`
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cc42f986
    • Oliver Hartkopp's avatar
      slcan: not call free_netdev before rtnl_unlock in slcan_open · a1c9b231
      Oliver Hartkopp authored
      [ Upstream commit 2091a3d4 ]
      
      As the description before netdev_run_todo, we cannot call free_netdev
      before rtnl_unlock, fix it by reorder the code.
      
      This patch is a 1:1 copy of upstream slip.c commit f596c870
      ("slip: not call free_netdev before rtnl_unlock in slip_open").
      Reported-by: default avataryangerkun <yangerkun@huawei.com>
      Signed-off-by: default avatarOliver Hartkopp <socketcan@hartkopp.net>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a1c9b231
    • Dan Carpenter's avatar
      NFC: fdp: Fix a signedness bug in fdp_nci_send_patch() · 93b84b9c
      Dan Carpenter authored
      [ Upstream commit 0dcdf9f6 ]
      
      The nci_conn_max_data_pkt_payload_size() function sometimes returns
      -EPROTO so "max_size" needs to be signed for the error handling to
      work.  We can make "payload_size" an int as well.
      
      Fixes: a06347c0 ("NFC: Add Intel Fields Peak NFC solution driver")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93b84b9c
    • Cong Wang's avatar
      net_sched: keep alloc_hash updated after hash allocation · c4453d28
      Cong Wang authored
      [ Upstream commit 0d1c3530 ]
      
      In commit 599be01e ("net_sched: fix an OOB access in cls_tcindex")
      I moved cp->hash calculation before the first
      tcindex_alloc_perfect_hash(), but cp->alloc_hash is left untouched.
      This difference could lead to another out of bound access.
      
      cp->alloc_hash should always be the size allocated, we should
      update it after this tcindex_alloc_perfect_hash().
      
      Reported-and-tested-by: syzbot+dcc34d54d68ef7d2d53d@syzkaller.appspotmail.com
      Reported-and-tested-by: syzbot+c72da7b9ed57cde6fca2@syzkaller.appspotmail.com
      Fixes: 599be01e ("net_sched: fix an OOB access in cls_tcindex")
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c4453d28
    • Cong Wang's avatar
      net_sched: cls_route: remove the right filter from hashtable · 97a8e7af
      Cong Wang authored
      [ Upstream commit ef299cc3 ]
      
      route4_change() allocates a new filter and copies values from
      the old one. After the new filter is inserted into the hash
      table, the old filter should be removed and freed, as the final
      step of the update.
      
      However, the current code mistakenly removes the new one. This
      looks apparently wrong to me, and it causes double "free" and
      use-after-free too, as reported by syzbot.
      
      Reported-and-tested-by: syzbot+f9b32aaacd60305d9687@syzkaller.appspotmail.com
      Reported-and-tested-by: syzbot+2f8c233f131943d6056d@syzkaller.appspotmail.com
      Reported-and-tested-by: syzbot+9c2df9fd5e9445b74e01@syzkaller.appspotmail.com
      Fixes: 1109c005 ("net: sched: RCU cls_route")
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      97a8e7af
    • Florian Fainelli's avatar
      net: dsa: Fix duplicate frames flooded by learning · 5e845dc6
      Florian Fainelli authored
      [ Upstream commit 0e62f543 ]
      
      When both the switch and the bridge are learning about new addresses,
      switch ports attached to the bridge would see duplicate ARP frames
      because both entities would attempt to send them.
      
      Fixes: 5037d532 ("net: dsa: add Broadcom tag RX/TX handler")
      Reported-by: default avatarMaxime Bizon <mbizon@freebox.fr>
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Reviewed-by: default avatarVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e845dc6
    • Willem de Bruijn's avatar
      macsec: restrict to ethernet devices · 52d58912
      Willem de Bruijn authored
      [ Upstream commit b06d072c ]
      
      Only attach macsec to ethernet devices.
      
      Syzbot was able to trigger a KMSAN warning in macsec_handle_frame
      by attaching to a phonet device.
      
      Macvlan has a similar check in macvlan_port_create.
      
      v1->v2
        - fix commit message typo
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      52d58912
    • Taehee Yoo's avatar
      hsr: fix general protection fault in hsr_addr_is_self() · a6362a9f
      Taehee Yoo authored
      [ Upstream commit 3a303cfd ]
      
      The port->hsr is used in the hsr_handle_frame(), which is a
      callback of rx_handler.
      hsr master and slaves are initialized in hsr_add_port().
      This function initializes several pointers, which includes port->hsr after
      registering rx_handler.
      So, in the rx_handler routine, un-initialized pointer would be used.
      In order to fix this, pointers should be initialized before
      registering rx_handler.
      
      Test commands:
          ip netns del left
          ip netns del right
          modprobe -rv veth
          modprobe -rv hsr
          killall ping
          modprobe hsr
          ip netns add left
          ip netns add right
          ip link add veth0 type veth peer name veth1
          ip link add veth2 type veth peer name veth3
          ip link add veth4 type veth peer name veth5
          ip link set veth1 netns left
          ip link set veth3 netns right
          ip link set veth4 netns left
          ip link set veth5 netns right
          ip link set veth0 up
          ip link set veth2 up
          ip link set veth0 address fc:00:00:00:00:01
          ip link set veth2 address fc:00:00:00:00:02
          ip netns exec left ip link set veth1 up
          ip netns exec left ip link set veth4 up
          ip netns exec right ip link set veth3 up
          ip netns exec right ip link set veth5 up
          ip link add hsr0 type hsr slave1 veth0 slave2 veth2
          ip a a 192.168.100.1/24 dev hsr0
          ip link set hsr0 up
          ip netns exec left ip link add hsr1 type hsr slave1 veth1 slave2 veth4
          ip netns exec left ip a a 192.168.100.2/24 dev hsr1
          ip netns exec left ip link set hsr1 up
          ip netns exec left ip n a 192.168.100.1 dev hsr1 lladdr \
      	    fc:00:00:00:00:01 nud permanent
          ip netns exec left ip n r 192.168.100.1 dev hsr1 lladdr \
      	    fc:00:00:00:00:01 nud permanent
          for i in {1..100}
          do
              ip netns exec left ping 192.168.100.1 &
          done
          ip netns exec left hping3 192.168.100.1 -2 --flood &
          ip netns exec right ip link add hsr2 type hsr slave1 veth3 slave2 veth5
          ip netns exec right ip a a 192.168.100.3/24 dev hsr2
          ip netns exec right ip link set hsr2 up
          ip netns exec right ip n a 192.168.100.1 dev hsr2 lladdr \
      	    fc:00:00:00:00:02 nud permanent
          ip netns exec right ip n r 192.168.100.1 dev hsr2 lladdr \
      	    fc:00:00:00:00:02 nud permanent
          for i in {1..100}
          do
              ip netns exec right ping 192.168.100.1 &
          done
          ip netns exec right hping3 192.168.100.1 -2 --flood &
          while :
          do
              ip link add hsr0 type hsr slave1 veth0 slave2 veth2
      	ip a a 192.168.100.1/24 dev hsr0
      	ip link set hsr0 up
      	ip link del hsr0
          done
      
      Splat looks like:
      [  120.954938][    C0] general protection fault, probably for non-canonical address 0xdffffc0000000006: 0000 [#1]I
      [  120.957761][    C0] KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037]
      [  120.959064][    C0] CPU: 0 PID: 1511 Comm: hping3 Not tainted 5.6.0-rc5+ #460
      [  120.960054][    C0] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
      [  120.962261][    C0] RIP: 0010:hsr_addr_is_self+0x65/0x2a0 [hsr]
      [  120.963149][    C0] Code: 44 24 18 70 73 2f c0 48 c1 eb 03 48 8d 04 13 c7 00 f1 f1 f1 f1 c7 40 04 00 f2 f2 f2 4
      [  120.966277][    C0] RSP: 0018:ffff8880d9c09af0 EFLAGS: 00010206
      [  120.967293][    C0] RAX: 0000000000000006 RBX: 1ffff1101b38135f RCX: 0000000000000000
      [  120.968516][    C0] RDX: dffffc0000000000 RSI: ffff8880d17cb208 RDI: 0000000000000000
      [  120.969718][    C0] RBP: 0000000000000030 R08: ffffed101b3c0e3c R09: 0000000000000001
      [  120.972203][    C0] R10: 0000000000000001 R11: ffffed101b3c0e3b R12: 0000000000000000
      [  120.973379][    C0] R13: ffff8880aaf80100 R14: ffff8880aaf800f2 R15: ffff8880aaf80040
      [  120.974410][    C0] FS:  00007f58e693f740(0000) GS:ffff8880d9c00000(0000) knlGS:0000000000000000
      [  120.979794][    C0] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  120.980773][    C0] CR2: 00007ffcb8b38f29 CR3: 00000000afe8e001 CR4: 00000000000606f0
      [  120.981945][    C0] Call Trace:
      [  120.982411][    C0]  <IRQ>
      [  120.982848][    C0]  ? hsr_add_node+0x8c0/0x8c0 [hsr]
      [  120.983522][    C0]  ? rcu_read_lock_held+0x90/0xa0
      [  120.984159][    C0]  ? rcu_read_lock_sched_held+0xc0/0xc0
      [  120.984944][    C0]  hsr_handle_frame+0x1db/0x4e0 [hsr]
      [  120.985597][    C0]  ? hsr_nl_nodedown+0x2b0/0x2b0 [hsr]
      [  120.986289][    C0]  __netif_receive_skb_core+0x6bf/0x3170
      [  120.992513][    C0]  ? check_chain_key+0x236/0x5d0
      [  120.993223][    C0]  ? do_xdp_generic+0x1460/0x1460
      [  120.993875][    C0]  ? register_lock_class+0x14d0/0x14d0
      [  120.994609][    C0]  ? __netif_receive_skb_one_core+0x8d/0x160
      [  120.995377][    C0]  __netif_receive_skb_one_core+0x8d/0x160
      [  120.996204][    C0]  ? __netif_receive_skb_core+0x3170/0x3170
      [ ... ]
      
      Reported-by: syzbot+fcf5dd39282ceb27108d@syzkaller.appspotmail.com
      Fixes: c5a75911 ("net/hsr: Use list_head (and rcu) instead of array for slave devices.")
      Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a6362a9f