1. 14 3月, 2019 40 次提交
    • M
      scsi: libfc: free skb when receiving invalid flogi resp · e546c878
      Ming Lu 提交于
      [ Upstream commit 5d8fc4a9f0eec20b6c07895022a6bea3fb6dfb38 ]
      
      The issue to be fixed in this commit is when libfc found it received a
      invalid FLOGI response from FC switch, it would return without freeing the
      fc frame, which is just the skb data. This would cause memory leak if FC
      switch keeps sending invalid FLOGI responses.
      
      This fix is just to make it execute `fc_frame_free(fp)` before returning
      from function `fc_lport_flogi_resp`.
      Signed-off-by: NMing Lu <ming.lu@citrix.com>
      Reviewed-by: NHannes Reinecke <hare@suse.com>
      Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      e546c878
    • M
      qed: Fix stack out of bounds bug · 40e35210
      Manish Chopra 提交于
      [ Upstream commit ffb057f98928aa099b08e419bbe5afc26ec9f448 ]
      
      KASAN reported following bug in qed_init_qm_get_idx_from_flags
      due to inappropriate casting of "pq_flags". Fix the type of "pq_flags".
      
      [  196.624707] BUG: KASAN: stack-out-of-bounds in qed_init_qm_get_idx_from_flags+0x1a4/0x1b8 [qed]
      [  196.624712] Read of size 8 at addr ffff809b00bc7360 by task kworker/0:9/1712
      [  196.624714]
      [  196.624720] CPU: 0 PID: 1712 Comm: kworker/0:9 Not tainted 4.18.0-60.el8.aarch64+debug #1
      [  196.624723] Hardware name: To be filled by O.E.M. Saber/Saber, BIOS 0ACKL024 09/26/2018
      [  196.624733] Workqueue: events work_for_cpu_fn
      [  196.624738] Call trace:
      [  196.624742]  dump_backtrace+0x0/0x2f8
      [  196.624745]  show_stack+0x24/0x30
      [  196.624749]  dump_stack+0xe0/0x11c
      [  196.624755]  print_address_description+0x68/0x260
      [  196.624759]  kasan_report+0x178/0x340
      [  196.624762]  __asan_report_load_n_noabort+0x38/0x48
      [  196.624786]  qed_init_qm_get_idx_from_flags+0x1a4/0x1b8 [qed]
      [  196.624808]  qed_init_qm_info+0xec0/0x2200 [qed]
      [  196.624830]  qed_resc_alloc+0x284/0x7e8 [qed]
      [  196.624853]  qed_slowpath_start+0x6cc/0x1ae8 [qed]
      [  196.624864]  __qede_probe.isra.10+0x1cc/0x12c0 [qede]
      [  196.624874]  qede_probe+0x78/0xf0 [qede]
      [  196.624879]  local_pci_probe+0xc4/0x180
      [  196.624882]  work_for_cpu_fn+0x54/0x98
      [  196.624885]  process_one_work+0x758/0x1900
      [  196.624888]  worker_thread+0x4e0/0xd18
      [  196.624892]  kthread+0x2c8/0x350
      [  196.624897]  ret_from_fork+0x10/0x18
      [  196.624899]
      [  196.624902] Allocated by task 2:
      [  196.624906]  kasan_kmalloc.part.1+0x40/0x108
      [  196.624909]  kasan_kmalloc+0xb4/0xc8
      [  196.624913]  kasan_slab_alloc+0x14/0x20
      [  196.624916]  kmem_cache_alloc_node+0x1dc/0x480
      [  196.624921]  copy_process.isra.1.part.2+0x1d8/0x4a98
      [  196.624924]  _do_fork+0x150/0xfa0
      [  196.624926]  kernel_thread+0x48/0x58
      [  196.624930]  kthreadd+0x3a4/0x5a0
      [  196.624932]  ret_from_fork+0x10/0x18
      [  196.624934]
      [  196.624937] Freed by task 0:
      [  196.624938] (stack is not available)
      [  196.624940]
      [  196.624943] The buggy address belongs to the object at ffff809b00bc0000
      [  196.624943]  which belongs to the cache thread_stack of size 32768
      [  196.624946] The buggy address is located 29536 bytes inside of
      [  196.624946]  32768-byte region [ffff809b00bc0000, ffff809b00bc8000)
      [  196.624948] The buggy address belongs to the page:
      [  196.624952] page:ffff7fe026c02e00 count:1 mapcount:0 mapping:ffff809b4001c000 index:0x0 compound_mapcount: 0
      [  196.624960] flags: 0xfffff8000008100(slab|head)
      [  196.624967] raw: 0fffff8000008100 dead000000000100 dead000000000200 ffff809b4001c000
      [  196.624970] raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
      [  196.624973] page dumped because: kasan: bad access detected
      [  196.624974]
      [  196.624976] Memory state around the buggy address:
      [  196.624980]  ffff809b00bc7200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [  196.624983]  ffff809b00bc7280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [  196.624985] >ffff809b00bc7300: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 04 f2 f2 f2
      [  196.624988]                                                        ^
      [  196.624990]  ffff809b00bc7380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [  196.624993]  ffff809b00bc7400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      [  196.624995] ==================================================================
      Signed-off-by: NManish Chopra <manishc@marvell.com>
      Signed-off-by: NAriel Elior <aelior@marvell.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      40e35210
    • M
      qed: Fix system crash in ll2 xmit · 9414e085
      Manish Chopra 提交于
      [ Upstream commit 7c81626a3c37e4ac320b8ad785694ba498f24794 ]
      
      Cache number of fragments in the skb locally as in case
      of linear skb (with zero fragments), tx completion
      (or freeing of skb) may happen before driver tries
      to get number of frgaments from the skb which could
      lead to stale access to an already freed skb.
      Signed-off-by: NManish Chopra <manishc@marvell.com>
      Signed-off-by: NAriel Elior <aelior@marvell.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      9414e085
    • M
      qed: Fix VF probe failure while FLR · fac23877
      Manish Chopra 提交于
      [ Upstream commit 327852ec64205bb651be391a069784872098a3b2 ]
      
      VFs may hit VF-PF channel timeout while probing, as in some
      cases it was observed that VF FLR and VF "acquire" message
      transaction (i.e first message from VF to PF in VF's probe flow)
      could occur simultaneously which could lead VF to fail sending
      "acquire" message to PF as VF is marked disabled from HW perspective
      due to FLR, which will result into channel timeout and VF probe failure.
      
      In such cases, try retrying VF "acquire" message so that in later
      attempts it could be successful to pass message to PF after the VF
      FLR is completed and can be probed successfully.
      Signed-off-by: NManish Chopra <manishc@marvell.com>
      Signed-off-by: NAriel Elior <aelior@marvell.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      fac23877
    • M
      qed: Fix LACP pdu drops for VFs · 1ba35110
      Manish Chopra 提交于
      [ Upstream commit ff9296966e5e00b0d0d00477b2365a178f0f06a3 ]
      
      VF is always configured to drop control frames
      (with reserved mac addresses) but to work LACP
      on the VFs, it would require LACP control frames
      to be forwarded or transmitted successfully.
      
      This patch fixes this in such a way that trusted VFs
      (marked through ndo_set_vf_trust) would be allowed to
      pass the control frames such as LACP pdus.
      Signed-off-by: NManish Chopra <manishc@marvell.com>
      Signed-off-by: NAriel Elior <aelior@marvell.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      1ba35110
    • M
      qed: Fix bug in tx promiscuous mode settings · 88bce339
      Manish Chopra 提交于
      [ Upstream commit 9e71a15d8b5bbce25c637f7f8833cd3f45b65646 ]
      
      When running tx switched traffic between VNICs
      created via a bridge(to which VFs are added),
      adapter drops the unicast packets in tx flow due to
      VNIC's ucast mac being unknown to it. But VF interfaces
      being in promiscuous mode should have caused adapter
      to accept all the unknown ucast packets. Later, it
      was found that driver doesn't really configure tx
      promiscuous mode settings to accept all unknown unicast macs.
      
      This patch fixes tx promiscuous mode settings to accept all
      unknown/unmatched unicast macs and works out the scenario.
      Signed-off-by: NManish Chopra <manishc@marvell.com>
      Signed-off-by: NAriel Elior <aelior@marvell.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      88bce339
    • Y
      nfs: Fix NULL pointer dereference of dev_name · 5c72ca3b
      Yao Liu 提交于
      [ Upstream commit 80ff00172407e0aad4b10b94ef0816fc3e7813cb ]
      
      There is a NULL pointer dereference of dev_name in nfs_parse_devname()
      
      The oops looks something like:
      
        BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
        ...
        RIP: 0010:nfs_fs_mount+0x3b6/0xc20 [nfs]
        ...
        Call Trace:
         ? ida_alloc_range+0x34b/0x3d0
         ? nfs_clone_super+0x80/0x80 [nfs]
         ? nfs_free_parsed_mount_data+0x60/0x60 [nfs]
         mount_fs+0x52/0x170
         ? __init_waitqueue_head+0x3b/0x50
         vfs_kern_mount+0x6b/0x170
         do_mount+0x216/0xdc0
         ksys_mount+0x83/0xd0
         __x64_sys_mount+0x25/0x30
         do_syscall_64+0x65/0x220
         entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
      Fix this by adding a NULL check on dev_name
      Signed-off-by: NYao Liu <yotta.liu@ucloud.cn>
      Signed-off-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      5c72ca3b
    • F
      selftests: timers: use LDLIBS instead of LDFLAGS · daf04674
      Fathi Boudra 提交于
      [ Upstream commit 7d4e591bc051d3382c45caaa2530969fb42ed23d ]
      
      posix_timers fails to build due to undefined reference errors:
      
       aarch64-linaro-linux-gcc --sysroot=/build/tmp-rpb-glibc/sysroots/hikey
       -O2 -pipe -g -feliminate-unused-debug-types -O3 -Wl,-no-as-needed -Wall
       -DKTEST  -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lrt -lpthread
       posix_timers.c
       -o /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers
       /tmp/cc1FTZzT.o: In function `check_timer_create':
       /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers.c:157:
       undefined reference to `timer_create'
       /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/timers/posix_timers.c:170:
       undefined reference to `timer_settime'
       collect2: error: ld returned 1 exit status
      
      It's GNU Make and linker specific.
      
      The default Makefile rule looks like:
      
      $(CC) $(CFLAGS) $(LDFLAGS) $@ $^ $(LDLIBS)
      
      When linking is done by gcc itself, no issue, but when it needs to be passed
      to proper ld, only LDLIBS follows and then ld cannot know what libs to link
      with.
      
      More detail:
      https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
      
      LDFLAGS
      Extra flags to give to compilers when they are supposed to invoke the linker,
      ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable
      instead.
      
      LDLIBS
      Library flags or names given to compilers when they are supposed to invoke the
      linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to
      LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS
      variable.
      
      https://lkml.org/lkml/2010/2/10/362
      
      tools/perf: libraries must come after objects
      
      Link order matters, use LDLIBS instead of LDFLAGS to properly link against
      libpthread.
      Signed-off-by: NDenys Dmytriyenko <denys@ti.com>
      Signed-off-by: NFathi Boudra <fathi.boudra@linaro.org>
      Signed-off-by: NShuah Khan <shuah@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      daf04674
    • F
      selftests: net: use LDLIBS instead of LDFLAGS · c68cf083
      Fathi Boudra 提交于
      [ Upstream commit 870f193d48c25a97d61a8e6c04e3c29a2c606850 ]
      
      reuseport_bpf_numa fails to build due to undefined reference errors:
      
       aarch64-linaro-linux-gcc
       --sysroot=/build/tmp-rpb-glibc/sysroots/hikey -Wall
       -Wl,--no-as-needed -O2 -g -I../../../../usr/include/  -Wl,-O1
       -Wl,--hash-style=gnu -Wl,--as-needed -lnuma  reuseport_bpf_numa.c
       -o
       /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/net/reuseport_bpf_numa
       /tmp/ccfUuExT.o: In function `send_from_node':
       /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/net/reuseport_bpf_numa.c:138:
       undefined reference to `numa_run_on_node'
       /tmp/ccfUuExT.o: In function `main':
       /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/net/reuseport_bpf_numa.c:230:
       undefined reference to `numa_available'
       /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/net/reuseport_bpf_numa.c:233:
       undefined reference to `numa_max_node'
      
      It's GNU Make and linker specific.
      
      The default Makefile rule looks like:
      
      $(CC) $(CFLAGS) $(LDFLAGS) $@ $^ $(LDLIBS)
      
      When linking is done by gcc itself, no issue, but when it needs to be passed
      to proper ld, only LDLIBS follows and then ld cannot know what libs to link
      with.
      
      More detail:
      https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
      
      LDFLAGS
      Extra flags to give to compilers when they are supposed to invoke the linker,
      ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable
      instead.
      
      LDLIBS
      Library flags or names given to compilers when they are supposed to invoke the
      linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to
      LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS
      variable.
      
      https://lkml.org/lkml/2010/2/10/362
      
      tools/perf: libraries must come after objects
      
      Link order matters, use LDLIBS instead of LDFLAGS to properly link against
      libnuma.
      Signed-off-by: NFathi Boudra <fathi.boudra@linaro.org>
      Signed-off-by: NShuah Khan <shuah@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      c68cf083
    • A
      gpio: vf610: Mask all GPIO interrupts · eda52fa1
      Andrew Lunn 提交于
      [ Upstream commit 7ae710f9f8b2cf95297e7bbfe1c09789a7dc43d4 ]
      
      On SoC reset all GPIO interrupts are disable. However, if kexec is
      used to boot into a new kernel, the SoC does not experience a
      reset. Hence GPIO interrupts can be left enabled from the previous
      kernel. It is then possible for the interrupt to fire before an
      interrupt handler is registered, resulting in the kernel complaining
      of an "unexpected IRQ trap", the interrupt is never cleared, and so
      fires again, resulting in an interrupt storm.
      
      Disable all GPIO interrupts before registering the GPIO IRQ chip.
      
      Fixes: 7f2691a1 ("gpio: vf610: add gpiolib/IRQ chip driver for Vybrid")
      Signed-off-by: NAndrew Lunn <andrew@lunn.ch>
      Acked-by: NStefan Agner <stefan@agner.ch>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      eda52fa1
    • F
      netfilter: ebtables: compat: un-break 32bit setsockopt when no rules are present · 3355d641
      Florian Westphal 提交于
      [ Upstream commit 2035f3ff8eaa29cfb5c8e2160b0f6e85eeb21a95 ]
      
      Unlike ip(6)tables ebtables only counts user-defined chains.
      
      The effect is that a 32bit ebtables binary on a 64bit kernel can do
      'ebtables -N FOO' only after adding at least one rule, else the request
      fails with -EINVAL.
      
      This is a similar fix as done in
      3f1e53ab ("netfilter: ebtables: don't attempt to allocate 0-sized compat array").
      
      Fixes: 7d7d7e02 ("netfilter: compat: reject huge allocation requests")
      Reported-by: NFrancesco Ruggeri <fruggeri@arista.com>
      Signed-off-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      3355d641
    • A
      net: stmmac: dwmac-rk: fix error handling in rk_gmac_powerup() · 1f4ccda3
      Alexey Khoroshilov 提交于
      [ Upstream commit c69c29a1a0a8f68cd87e98ba4a5a79fb8ef2a58c ]
      
      If phy_power_on() fails in rk_gmac_powerup(), clocks are left enabled.
      
      Found by Linux Driver Verification project (linuxtesting.org).
      Signed-off-by: NAlexey Khoroshilov <khoroshilov@ispras.ru>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      1f4ccda3
    • Y
      net: hns: Fix wrong read accesses via Clause 45 MDIO protocol · 4a22084f
      Yonglong Liu 提交于
      [ Upstream commit cec8abba13e6a26729dfed41019720068eeeff2b ]
      
      When reading phy registers via Clause 45 MDIO protocol, after write
      address operation, the driver use another write address operation, so
      can not read the right value of any phy registers. This patch fixes it.
      Signed-off-by: NYonglong Liu <liuyonglong@huawei.com>
      Signed-off-by: NPeng Li <lipeng321@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      4a22084f
    • Y
      net: hns: Restart autoneg need return failed when autoneg off · 3e640b2c
      Yonglong Liu 提交于
      [ Upstream commit ed29ca8b9592562559c64d027fb5eb126e463e2c ]
      
      The hns driver of earlier devices, when autoneg off, restart autoneg
      will return -EINVAL, so make the hns driver for the latest devices
      do the same.
      Signed-off-by: NYonglong Liu <liuyonglong@huawei.com>
      Signed-off-by: NPeng Li <lipeng321@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      3e640b2c
    • Y
      net: hns: Fix for missing of_node_put() after of_parse_phandle() · 6b7d3544
      Yonglong Liu 提交于
      [ Upstream commit 263c6d75f9a544a3c2f8f6a26de4f4808d8f59cf ]
      
      In hns enet driver, we use of_parse_handle() to get hold of the
      device node related to "ae-handle" but we have missed to put
      the node reference using of_node_put() after we are done using
      the node. This patch fixes it.
      
      Note:
      This problem is stated in Link: https://lkml.org/lkml/2018/12/22/217
      
      Fixes: 48189d6a ("net: hns: enet specifies a reference to dsaf")
      Reported-by: NAlexey Khoroshilov <khoroshilov@ispras.ru>
      Signed-off-by: NYonglong Liu <liuyonglong@huawei.com>
      Signed-off-by: NPeng Li <lipeng321@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      6b7d3544
    • T
      net: altera_tse: fix msgdma_tx_completion on non-zero fill_level case · c91f6416
      Tomonori Sakita 提交于
      [ Upstream commit 6571ebce112a21ec9be68ef2f53b96fcd41fd81b ]
      
      If fill_level was not zero and status was not BUSY,
      result of "tx_prod - tx_cons - inuse" might be zero.
      Subtracting 1 unconditionally results invalid negative return value
      on this case.
      Make sure not to return an negative value.
      Signed-off-by: NTomonori Sakita <tomonori.sakita@sord.co.jp>
      Signed-off-by: NAtsushi Nemoto <atsushi.nemoto@sord.co.jp>
      Reviewed-by: NDalon L Westergreen <dalon.westergreen@linux.intel.com>
      Acked-by: NThor Thayer <thor.thayer@linux.intel.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      c91f6416
    • M
      xtensa: SMP: limit number of possible CPUs by NR_CPUS · 419bb616
      Max Filippov 提交于
      [ Upstream commit 25384ce5f9530def39421597b1457d9462df6455 ]
      
      This fixes the following warning at boot when the kernel is booted on a
      board with more CPU cores than was configured in NR_CPUS:
      
        smp_init_cpus: Core Count = 8
        smp_init_cpus: Core Id = 0
        ------------[ cut here ]------------
        WARNING: CPU: 0 PID: 0 at include/linux/cpumask.h:121 smp_init_cpus+0x54/0x74
        Modules linked in:
        CPU: 0 PID: 0 Comm: swapper Not tainted 5.0.0-rc3-00015-g1459333f88a0 #124
        Call Trace:
          __warn$part$3+0x6a/0x7c
          warn_slowpath_null+0x35/0x3c
          smp_init_cpus+0x54/0x74
          setup_arch+0x1c0/0x1d0
          start_kernel+0x44/0x310
          _startup+0x107/0x107
      Signed-off-by: NMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      419bb616
    • C
      iomap: fix a use after free in iomap_dio_rw · d9ba842e
      Christoph Hellwig 提交于
      [ Upstream commit 4ea899ead2786a30aaa8181fefa81a3df4ad28f6 ]
      
      Introduce a local wait_for_completion variable to avoid an access to the
      potentially freed dio struture after dropping the last reference count.
      
      Also use the chance to document the completion behavior to make the
      refcounting clear to the reader of the code.
      
      Fixes: ff6a9292 ("iomap: implement direct I/O")
      Reported-by: NChandan Rajendra <chandan@linux.ibm.com>
      Reported-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Tested-by: NChandan Rajendra <chandan@linux.ibm.com>
      Tested-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      d9ba842e
    • P
      iomap: get/put the page in iomap_page_create/release() · d23792f5
      Piotr Jaroszynski 提交于
      [ Upstream commit 8e47a457321ca1a74ad194ab5dcbca764bc70731 ]
      
      migrate_page_move_mapping() expects pages with private data set to have
      a page_count elevated by 1.  This is what used to happen for xfs through
      the buffer_heads code before the switch to iomap in commit 82cb1417
      ("xfs: add support for sub-pagesize writeback without buffer_heads").
      Not having the count elevated causes move_pages() to fail on memory
      mapped files coming from xfs.
      
      Make iomap compatible with the migrate_page_move_mapping() assumption by
      elevating the page count as part of iomap_page_create() and lowering it
      in iomap_page_release().
      
      It causes the move_pages() syscall to misbehave on memory mapped files
      from xfs.  It does not not move any pages, which I suppose is "just" a
      perf issue, but it also ends up returning a positive number which is out
      of spec for the syscall.  Talking to Michal Hocko, it sounds like
      returning positive numbers might be a necessary update to move_pages()
      anyway though.
      
      Fixes: 82cb1417 ("xfs: add support for sub-pagesize writeback without buffer_heads")
      Signed-off-by: NPiotr Jaroszynski <pjaroszynski@nvidia.com>
      [hch: actually get/put the page iomap_migrate_page() to make it work
            properly]
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NDave Chinner <dchinner@redhat.com>
      Reviewed-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      d23792f5
    • M
      xtensa: SMP: mark each possible CPU as present · 38f47557
      Max Filippov 提交于
      [ Upstream commit 8b1c42cdd7181200dc1fff39dcb6ac1a3fac2c25 ]
      
      Otherwise it is impossible to enable CPUs after booting with 'maxcpus'
      parameter.
      Signed-off-by: NMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      38f47557
    • M
      xtensa: smp_lx200_defconfig: fix vectors clash · c1327f9a
      Max Filippov 提交于
      [ Upstream commit 306b38305c0f86de7f17c5b091a95451dcc93d7d ]
      
      Secondary CPU reset vector overlaps part of the double exception handler
      code, resulting in weird crashes and hangups when running user code.
      Move exception vectors one page up so that they don't clash with the
      secondary CPU reset vector.
      Signed-off-by: NMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      c1327f9a
    • M
      xtensa: SMP: fix secondary CPU initialization · 8655802a
      Max Filippov 提交于
      [ Upstream commit 32a7726c4f4aadfabdb82440d84f88a5a2c8fe13 ]
      
      - add missing memory barriers to the secondary CPU synchronization spin
        loops; add comment to the matching memory barrier in the boot_secondary
        and __cpu_die functions;
      - use READ_ONCE/WRITE_ONCE to access cpu_start_id/cpu_start_ccount
        instead of reading/writing them directly;
      - re-initialize cpu_running every time before starting secondary CPU to
        flush possible previous CPU startup results.
      Signed-off-by: NMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8655802a
    • C
      selftests: cpu-hotplug: fix case where CPUs offline > CPUs present · 0165df14
      Colin Ian King 提交于
      [ Upstream commit 2b531b6137834a55857a337ac17510d6436b6fbb ]
      
      The cpu-hotplug test assumes that we can offline the maximum CPU as
      described by /sys/devices/system/cpu/offline.  However, in the case
      where the number of CPUs exceeds like kernel configuration then
      the offline count can be greater than the present count and we end
      up trying to test the offlining of a CPU that is not available to
      offline.  Fix this by testing the maximum present CPU instead.
      
      Also, the test currently offlines the CPU and does not online it,
      so fix this by onlining the CPU after the test.
      
      Fixes: d89dffa9 ("fault-injection: add selftests for cpu and memory hotplug")
      Signed-off-by: NColin Ian King <colin.king@canonical.com>
      Signed-off-by: NShuah Khan <shuah@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      0165df14
    • F
      IB/ipoib: Fix for use-after-free in ipoib_cm_tx_start · 1ee82160
      Feras Daoud 提交于
      [ Upstream commit 6ab4aba00f811a5265acc4d3eb1863bb3ca60562 ]
      
      The following BUG was reported by kasan:
      
       BUG: KASAN: use-after-free in ipoib_cm_tx_start+0x430/0x1390 [ib_ipoib]
       Read of size 80 at addr ffff88034c30bcd0 by task kworker/u16:1/24020
      
       Workqueue: ipoib_wq ipoib_cm_tx_start [ib_ipoib]
       Call Trace:
        dump_stack+0x9a/0xeb
        print_address_description+0xe3/0x2e0
        kasan_report+0x18a/0x2e0
        ? ipoib_cm_tx_start+0x430/0x1390 [ib_ipoib]
        memcpy+0x1f/0x50
        ipoib_cm_tx_start+0x430/0x1390 [ib_ipoib]
        ? kvm_clock_read+0x1f/0x30
        ? ipoib_cm_skb_reap+0x610/0x610 [ib_ipoib]
        ? __lock_is_held+0xc2/0x170
        ? process_one_work+0x880/0x1960
        ? process_one_work+0x912/0x1960
        process_one_work+0x912/0x1960
        ? wq_pool_ids_show+0x310/0x310
        ? lock_acquire+0x145/0x440
        worker_thread+0x87/0xbb0
        ? process_one_work+0x1960/0x1960
        kthread+0x314/0x3d0
        ? kthread_create_worker_on_cpu+0xc0/0xc0
        ret_from_fork+0x3a/0x50
      
       Allocated by task 0:
        kasan_kmalloc+0xa0/0xd0
        kmem_cache_alloc_trace+0x168/0x3e0
        path_rec_create+0xa2/0x1f0 [ib_ipoib]
        ipoib_start_xmit+0xa98/0x19e0 [ib_ipoib]
        dev_hard_start_xmit+0x159/0x8d0
        sch_direct_xmit+0x226/0xb40
        __dev_queue_xmit+0x1d63/0x2950
        neigh_update+0x889/0x1770
        arp_process+0xc47/0x21f0
        arp_rcv+0x462/0x760
        __netif_receive_skb_core+0x1546/0x2da0
        netif_receive_skb_internal+0xf2/0x590
        napi_gro_receive+0x28e/0x390
        ipoib_ib_handle_rx_wc_rss+0x873/0x1b60 [ib_ipoib]
        ipoib_rx_poll_rss+0x17d/0x320 [ib_ipoib]
        net_rx_action+0x427/0xe30
        __do_softirq+0x28e/0xc42
      
       Freed by task 26680:
        __kasan_slab_free+0x11d/0x160
        kfree+0xf5/0x360
        ipoib_flush_paths+0x532/0x9d0 [ib_ipoib]
        ipoib_set_mode_rss+0x1ad/0x560 [ib_ipoib]
        set_mode+0xc8/0x150 [ib_ipoib]
        kernfs_fop_write+0x279/0x440
        __vfs_write+0xd8/0x5c0
        vfs_write+0x15e/0x470
        ksys_write+0xb8/0x180
        do_syscall_64+0x9b/0x420
        entry_SYSCALL_64_after_hwframe+0x49/0xbe
      
       The buggy address belongs to the object at ffff88034c30bcc8
                      which belongs to the cache kmalloc-512 of size 512
       The buggy address is located 8 bytes inside of
                      512-byte region [ffff88034c30bcc8, ffff88034c30bec8)
       The buggy address belongs to the page:
      
      The following race between change mode and xmit flow is the reason for
      this use-after-free:
      
      Change mode     Send packet 1 to GID XX      Send packet 2 to GID XX
           |                    |                             |
         start                  |                             |
           |                    |                             |
           |                    |                             |
           |         Create new path for GID XX               |
           |           and update neigh path                  |
           |                    |                             |
           |                    |                             |
           |                    |                             |
       flush_paths              |                             |
                                |                             |
                     queue_work(cm.start_task)                |
                                |                 Path for GID XX not found
                                |                      create new path
                                |
                                |
                     start_task runs with old
                          released path
      
      There is no locking to protect the lifetime of the path through the
      ipoib_cm_tx struct, so delete it entirely and always use the newly looked
      up path under the priv->lock.
      
      Fixes: 546481c2 ("IB/ipoib: Fix memory corruption in ipoib cm mode connect flow")
      Signed-off-by: NFeras Daoud <ferasda@mellanox.com>
      Reviewed-by: NErez Shitrit <erezsh@mellanox.com>
      Signed-off-by: NLeon Romanovsky <leonro@mellanox.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      1ee82160
    • A
      riscv: Adjust mmap base address at a third of task size · dc04a00b
      Alexandre Ghiti 提交于
      [ Upstream commit ae662eec8a515ab550524e04c793b5ddf1aae3a1 ]
      
      This ratio is the most used among all other architectures and make
      icache_hygiene libhugetlbfs test pass: this test mmap lots of
      hugepages whose addresses, without this patch, reach the end of
      the process user address space.
      Signed-off-by: NAlexandre Ghiti <aghiti@upmem.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NPalmer Dabbelt <palmer@sifive.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      dc04a00b
    • M
      xtensa: SMP: fix ccount_timer_shutdown · f43e42f4
      Max Filippov 提交于
      [ Upstream commit 4fe8713b873fc881284722ce4ac47995de7cf62c ]
      
      ccount_timer_shutdown is called from the atomic context in the
      secondary_start_kernel, resulting in the following BUG:
      
      BUG: sleeping function called from invalid context
      in_atomic(): 1, irqs_disabled(): 1, pid: 0, name: swapper/1
      Preemption disabled at:
        secondary_start_kernel+0xa1/0x130
      Call Trace:
        ___might_sleep+0xe7/0xfc
        __might_sleep+0x41/0x44
        synchronize_irq+0x24/0x64
        disable_irq+0x11/0x14
        ccount_timer_shutdown+0x12/0x20
        clockevents_switch_state+0x82/0xb4
        clockevents_exchange_device+0x54/0x60
        tick_check_new_device+0x46/0x70
        clockevents_register_device+0x8c/0xc8
        clockevents_config_and_register+0x1d/0x2c
        local_timer_setup+0x75/0x7c
        secondary_start_kernel+0xb4/0x130
        should_never_return+0x32/0x35
      
      Use disable_irq_nosync instead of disable_irq to avoid it.
      This is safe because the ccount timer IRQ is per-CPU, and once IRQ is
      masked the ISR will not be called.
      Signed-off-by: NMax Filippov <jcmvbkbc@gmail.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      f43e42f4
    • T
      clk: qcom: gcc: Use active only source for CPUSS clocks · aad4dc74
      Taniya Das 提交于
      [ Upstream commit 9ff1a3b4912528f853048ccd9757ba6a2cc75557 ]
      
      The clocks of the CPUSS such as "gcc_cpuss_ahb_clk_src" is a CRITICAL
      clock and needs to vote on the active only source of XO, so as to keep
      the vote as long as CPUSS is active. Similar rbcpr_clk_src is also has
      the same requirement.
      Signed-off-by: NTaniya Das <tdas@codeaurora.org>
      Fixes: 06391edd ("clk: qcom: Add Global Clock controller (GCC) driver for SDM845")
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      aad4dc74
    • D
      clk: ti: Fix error handling in ti_clk_parse_divider_data() · cf872189
      Dan Carpenter 提交于
      [ Upstream commit 303aef8b84272d73999a3207dd05bbe10ed89dc5 ]
      
      The ti_clk_parse_divider_data() function is only called from
      _get_div_table_from_setup().  That function doesn't look at the return
      value but instead looks at the "*table" pointer.  In this case, if the
      kcalloc() fails then *table is NULL (which means success).  It should
      instead be an error pointer.
      
      The ti_clk_parse_divider_data() function has two callers.  One checks
      for errors and the other doesn't.  I have fixed it so now both handle
      errors.
      
      Fixes: 4f6be565 ("clk: ti: divider: add driver internal API for parsing divider data")
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: NTero Kristo <t-kristo@ti.com>
      Signed-off-by: NStephen Boyd <sboyd@kernel.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      cf872189
    • S
      iommu/amd: Fix IOMMU page flush when detach device from a domain · a038ed68
      Suravee Suthikulpanit 提交于
      [ Upstream commit 9825bd94e3a2baae1f4874767ae3a7d4c049720e ]
      
      When a VM is terminated, the VFIO driver detaches all pass-through
      devices from VFIO domain by clearing domain id and page table root
      pointer from each device table entry (DTE), and then invalidates
      the DTE. Then, the VFIO driver unmap pages and invalidate IOMMU pages.
      
      Currently, the IOMMU driver keeps track of which IOMMU and how many
      devices are attached to the domain. When invalidate IOMMU pages,
      the driver checks if the IOMMU is still attached to the domain before
      issuing the invalidate page command.
      
      However, since VFIO has already detached all devices from the domain,
      the subsequent INVALIDATE_IOMMU_PAGES commands are being skipped as
      there is no IOMMU attached to the domain. This results in data
      corruption and could cause the PCI device to end up in indeterministic
      state.
      
      Fix this by invalidate IOMMU pages when detach a device, and
      before decrementing the per-domain device reference counts.
      
      Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
      Suggested-by: NJoerg Roedel <joro@8bytes.org>
      Co-developed-by: NBrijesh Singh <brijesh.singh@amd.com>
      Signed-off-by: NBrijesh Singh <brijesh.singh@amd.com>
      Signed-off-by: NSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Fixes: 6de8ad9b ('x86/amd-iommu: Make iommu_flush_pages aware of multiple IOMMUs')
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      a038ed68
    • Z
      ipvs: Fix signed integer overflow when setsockopt timeout · e0b03a6b
      ZhangXiaoxu 提交于
      [ Upstream commit 53ab60baa1ac4f20b080a22c13b77b6373922fd7 ]
      
      There is a UBSAN bug report as below:
      UBSAN: Undefined behaviour in net/netfilter/ipvs/ip_vs_ctl.c:2227:21
      signed integer overflow:
      -2147483647 * 1000 cannot be represented in type 'int'
      
      Reproduce program:
      	#include <stdio.h>
      	#include <sys/types.h>
      	#include <sys/socket.h>
      
      	#define IPPROTO_IP 0
      	#define IPPROTO_RAW 255
      
      	#define IP_VS_BASE_CTL		(64+1024+64)
      	#define IP_VS_SO_SET_TIMEOUT	(IP_VS_BASE_CTL+10)
      
      	/* The argument to IP_VS_SO_GET_TIMEOUT */
      	struct ipvs_timeout_t {
      		int tcp_timeout;
      		int tcp_fin_timeout;
      		int udp_timeout;
      	};
      
      	int main() {
      		int ret = -1;
      		int sockfd = -1;
      		struct ipvs_timeout_t to;
      
      		sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
      		if (sockfd == -1) {
      			printf("socket init error\n");
      			return -1;
      		}
      
      		to.tcp_timeout = -2147483647;
      		to.tcp_fin_timeout = -2147483647;
      		to.udp_timeout = -2147483647;
      
      		ret = setsockopt(sockfd,
      				 IPPROTO_IP,
      				 IP_VS_SO_SET_TIMEOUT,
      				 (char *)(&to),
      				 sizeof(to));
      
      		printf("setsockopt return %d\n", ret);
      		return ret;
      	}
      
      Return -EINVAL if the timeout value is negative or max than 'INT_MAX / HZ'.
      Signed-off-by: NZhangXiaoxu <zhangxiaoxu5@huawei.com>
      Acked-by: NSimon Horman <horms@verge.net.au>
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      e0b03a6b
    • G
      riscv: fixup max_low_pfn with PFN_DOWN. · ffabf74c
      Guo Ren 提交于
      [ Upstream commit 28198c4639b39899a728ac89aea29d2a7a72562f ]
      
      max_low_pfn should be pfn_size not byte_size.
      Signed-off-by: NGuo Ren <ren_guo@c-sky.com>
      Signed-off-by: NMao Han <mao_han@c-sky.com>
      Signed-off-by: NPalmer Dabbelt <palmer@sifive.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      ffabf74c
    • J
      iommu/amd: Unmap all mapped pages in error path of map_sg · 9e1f977d
      Jerry Snitselaar 提交于
      [ Upstream commit f1724c0883bb0ce93b8dcb94b53dcca3b75ac9a7 ]
      
      In the error path of map_sg there is an incorrect if condition
      for breaking out of the loop that searches the scatterlist
      for mapped pages to unmap. Instead of breaking out of the
      loop once all the pages that were mapped have been unmapped,
      it will break out of the loop after it has unmapped 1 page.
      Fix the condition, so it breaks out of the loop only after
      all the mapped pages have been unmapped.
      
      Fixes: 80187fd3 ("iommu/amd: Optimize map_sg and unmap_sg")
      Cc: Joerg Roedel <joro@8bytes.org>
      Signed-off-by: NJerry Snitselaar <jsnitsel@redhat.com>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      9e1f977d
    • J
      iommu/amd: Call free_iova_fast with pfn in map_sg · 697863bf
      Jerry Snitselaar 提交于
      [ Upstream commit 51d8838d66d3249508940d8f59b07701f2129723 ]
      
      In the error path of map_sg, free_iova_fast is being called with
      address instead of the pfn. This results in a bad value getting into
      the rcache, and can result in hitting a BUG_ON when
      iova_magazine_free_pfns is called.
      
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Signed-off-by: NJerry Snitselaar <jsnitsel@redhat.com>
      Fixes: 80187fd3 ("iommu/amd: Optimize map_sg and unmap_sg")
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      697863bf
    • B
      IB/{hfi1, qib}: Fix WC.byte_len calculation for UD_SEND_WITH_IMM · 43b0c939
      Brian Welty 提交于
      [ Upstream commit 904bba211acc2112fdf866e5a2bc6cd9ecd0de1b ]
      
      The work completion length for a receiving a UD send with immediate is
      short by 4 bytes causing application using this opcode to fail.
      
      The UD receive logic incorrectly subtracts 4 bytes for immediate
      value. These bytes are already included in header length and are used to
      calculate header/payload split, so the result is these 4 bytes are
      subtracted twice, once when the header length subtracted from the overall
      length and once again in the UD opcode specific path.
      
      Remove the extra subtraction when handling the opcode.
      
      Fixes: 77241056 ("IB/hfi1: add driver files")
      Reviewed-by: NMichael J. Ruhl <michael.j.ruhl@intel.com>
      Signed-off-by: NBrian Welty <brian.welty@intel.com>
      Signed-off-by: NMike Marciniszyn <mike.marciniszyn@intel.com>
      Signed-off-by: NDennis Dalessandro <dennis.dalessandro@intel.com>
      Signed-off-by: NJason Gunthorpe <jgg@mellanox.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      43b0c939
    • T
      perf script: Fix crash when processing recorded stat data · d5f05016
      Tony Jones 提交于
      [ Upstream commit 8bf8c6da53c2265aea365a1de6038f118f522113 ]
      
      While updating perf to work with Python3 and Python2 I noticed that the
      stat-cpi script was dumping core.
      
      $ perf  stat -e cycles,instructions record -o /tmp/perf.data /bin/false
      
       Performance counter stats for '/bin/false':
      
                 802,148      cycles
      
                 604,622      instructions                                                       802,148      cycles
                 604,622      instructions
      
             0.001445842 seconds time elapsed
      
      $ perf script -i /tmp/perf.data -s scripts/python/stat-cpi.py
      Segmentation fault (core dumped)
      ...
      ...
          rblist=rblist@entry=0xb2a200 <rt_stat>,
          new_entry=new_entry@entry=0x7ffcb755c310) at util/rblist.c:33
          ctx=<optimized out>, type=<optimized out>, create=<optimized out>,
          cpu=<optimized out>, evsel=<optimized out>) at util/stat-shadow.c:118
          ctx=<optimized out>, type=<optimized out>, st=<optimized out>)
          at util/stat-shadow.c:196
          count=count@entry=727442, cpu=cpu@entry=0, st=0xb2a200 <rt_stat>)
          at util/stat-shadow.c:239
          config=config@entry=0xafeb40 <stat_config>,
          counter=counter@entry=0x133c6e0) at util/stat.c:372
      ...
      ...
      
      The issue is that since 1fcd0394 perf_stat__update_shadow_stats now calls
      update_runtime_stat passing rt_stat rather than calling update_stats but
      perf_stat__init_shadow_stats has never been called to initialize rt_stat in
      the script path processing recorded stat data.
      
      Since I can't see any reason why perf_stat__init_shadow_stats() is presently
      initialized like it is in builtin-script.c::perf_sample__fprint_metric()
      [4bd1bef8] I'm proposing it instead be initialized once in __cmd_script
      
      Committer testing:
      
      After applying the patch:
      
        # perf script -i /tmp/perf.data -s tools/perf/scripts/python/stat-cpi.py
             0.001970: cpu -1, thread -1 -> cpi 1.709079 (1075684/629394)
        #
      
      No segfault.
      Signed-off-by: NTony Jones <tonyj@suse.de>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NRavi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Fixes: 1fcd0394 ("perf stat: Update per-thread shadow stats")
      Link: http://lkml.kernel.org/r/20190120191414.12925-1-tonyj@suse.deSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      d5f05016
    • S
      perf tools: Handle TOPOLOGY headers with no CPU · 1e4b7541
      Stephane Eranian 提交于
      [ Upstream commit 1497e804d1a6e2bd9107ddf64b0310449f4673eb ]
      
      This patch fixes an issue in cpumap.c when used with the TOPOLOGY
      header. In some configurations, some NUMA nodes may have no CPU (empty
      cpulist). Yet a cpumap map must be created otherwise perf abort with an
      error. This patch handles this case by creating a dummy map.
      
        Before:
      
        $ perf record -o - -e cycles noploop 2 | perf script -i -
        0x6e8 [0x6c]: failed to process type: 80
      
        After:
      
        $ perf record -o - -e cycles noploop 2 | perf script -i -
        noploop for 2 seconds
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1547885559-1657-1-git-send-email-eranian@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      1e4b7541
    • S
      perf core: Fix perf_proc_update_handler() bug · 6ec0698f
      Stephane Eranian 提交于
      [ Upstream commit 1a51c5da5acc6c188c917ba572eebac5f8793432 ]
      
      The perf_proc_update_handler() handles /proc/sys/kernel/perf_event_max_sample_rate
      syctl variable.  When the PMU IRQ handler timing monitoring is disabled, i.e,
      when /proc/sys/kernel/perf_cpu_time_max_percent is equal to 0 or 100,
      then no modification to sysctl_perf_event_sample_rate is allowed to prevent
      possible hang from wrong values.
      
      The problem is that the test to prevent modification is made after the
      sysctl variable is modified in perf_proc_update_handler().
      
      You get an error:
      
        $ echo 10001 >/proc/sys/kernel/perf_event_max_sample_rate
        echo: write error: invalid argument
      
      But the value is still modified causing all sorts of inconsistencies:
      
        $ cat /proc/sys/kernel/perf_event_max_sample_rate
        10001
      
      This patch fixes the problem by moving the parsing of the value after
      the test.
      
      Committer testing:
      
        # echo 100 > /proc/sys/kernel/perf_cpu_time_max_percent
        # echo 10001 > /proc/sys/kernel/perf_event_max_sample_rate
        -bash: echo: write error: Invalid argument
        # cat /proc/sys/kernel/perf_event_max_sample_rate
        10001
        #
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1547169436-6266-1-git-send-email-eranian@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      6ec0698f
    • A
      perf script: Fix crash with printing mixed trace point and other events · 5d1dc10b
      Andi Kleen 提交于
      [ Upstream commit 96167167b6e17b25c0e05ecc31119b73baeab094 ]
      
      'perf script' crashes currently when printing mixed trace points and
      other events because the trace format does not handle events without
      trace meta data. Add a simple check to avoid that.
      
        % cat > test.c
        main()
        {
            printf("Hello world\n");
        }
        ^D
        % gcc -g -o test test.c
        % sudo perf probe -x test 'test.c:3'
        % perf record -e '{cpu/cpu-cycles,period=10000/,probe_test:main}:S' ./test
        % perf script
        <segfault>
      
      Committer testing:
      
      Before:
      
        # perf probe -x /lib64/libc-2.28.so malloc
        Added new event:
          probe_libc:malloc    (on malloc in /usr/lib64/libc-2.28.so)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e probe_libc:malloc -aR sleep 1
      
        # perf probe -l
        probe_libc:malloc    (on __libc_malloc@malloc/malloc.c in /usr/lib64/libc-2.28.so)
        # perf record -e '{cpu/cpu-cycles,period=10000/,probe_libc:*}:S' sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.023 MB perf.data (40 samples) ]
        # perf script
        Segmentation fault (core dumped)
        ^C
        #
      
      After:
      
        # perf script | head -6
           sleep 2888 94796.944981: 16198 cpu/cpu-cycles,period=10000/: ffffffff925dc04f get_random_u32+0x1f (/lib/modules/5.0.0-rc2+/build/vmlinux)
           sleep 2888 [-01] 94796.944981: probe_libc:malloc:
           sleep 2888 94796.944983:  4713 cpu/cpu-cycles,period=10000/: ffffffff922763af change_protection+0xcf (/lib/modules/5.0.0-rc2+/build/vmlinux)
           sleep 2888 [-01] 94796.944983: probe_libc:malloc:
           sleep 2888 94796.944986:  9934 cpu/cpu-cycles,period=10000/: ffffffff922777e0 move_page_tables+0x0 (/lib/modules/5.0.0-rc2+/build/vmlinux)
           sleep 2888 [-01] 94796.944986: probe_libc:malloc:
        #
      Signed-off-by: NAndi Kleen <ak@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Link: http://lkml.kernel.org/r/20190117194834.21940-1-andi@firstfloor.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      5d1dc10b
    • S
      vti4: Fix a ipip packet processing bug in 'IPCOMP' virtual tunnel · 8ce41db0
      Su Yanjun 提交于
      [ Upstream commit dd9ee3444014e8f28c0eefc9fffc9ac9c5248c12 ]
      
      Recently we run a network test over ipcomp virtual tunnel.We find that
      if a ipv4 packet needs fragment, then the peer can't receive
      it.
      
      We deep into the code and find that when packet need fragment the smaller
      fragment will be encapsulated by ipip not ipcomp. So when the ipip packet
      goes into xfrm, it's skb->dev is not properly set. The ipv4 reassembly code
      always set skb'dev to the last fragment's dev. After ipv4 defrag processing,
      when the kernel rp_filter parameter is set, the skb will be drop by -EXDEV
      error.
      
      This patch adds compatible support for the ipip process in ipcomp virtual tunnel.
      Signed-off-by: NSu Yanjun <suyj.fnst@cn.fujitsu.com>
      Signed-off-by: NSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      8ce41db0
    • A
      media: uvcvideo: Fix 'type' check leading to overflow · ac8befb6
      Alistair Strachan 提交于
      commit 47bb117911b051bbc90764a8bff96543cbd2005f upstream.
      
      When initially testing the Camera Terminal Descriptor wTerminalType
      field (buffer[4]), no mask is used. Later in the function, the MSB is
      overloaded to store the descriptor subtype, and so a mask of 0x7fff
      is used to check the type.
      
      If a descriptor is specially crafted to set this overloaded bit in the
      original wTerminalType field, the initial type check will fail (falling
      through, without adjusting the buffer size), but the later type checks
      will pass, assuming the buffer has been made suitably large, causing an
      overflow.
      
      Avoid this problem by checking for the MSB in the wTerminalType field.
      If the bit is set, assume the descriptor is bad, and abort parsing it.
      
      Originally reported here:
      https://groups.google.com/forum/#!topic/syzkaller/Ot1fOE6v1d8
      A similar (non-compiling) patch was provided at that time.
      Reported-by: Nsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: NAlistair Strachan <astrachan@google.com>
      Signed-off-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: NMauro Carvalho Chehab <mchehab+samsung@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ac8befb6