Skip to content
  1. Nov 19, 2021
    • Jie Wang's avatar
      net: hns3: fix ROCE base interrupt vector initialization bug · bcbee7cf
      Jie Wang authored
      [ Upstream commit beb27ca4 ]
      
      Currently, NIC init ROCE interrupt vector with MSIX interrupt. But ROCE use
      pci_irq_vector() to get interrupt vector, which adds the relative interrupt
      vector again and gets wrong interrupt vector.
      
      So fixes it by assign relative interrupt vector to ROCE instead of MSIX
      interrupt vector and delete the unused struct member base_msi_vector
      declaration of hclgevf_dev.
      
      Fixes: 46a3df9f
      
       ("net: hns3: Add HNS3 Acceleration Engine & Compatibility Layer Support")
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bcbee7cf
    • Eric Dumazet's avatar
      net/sched: sch_taprio: fix undefined behavior in ktime_mono_to_any · 3e13ce88
      Eric Dumazet authored
      [ Upstream commit 6dc25401 ]
      
      1) if q->tk_offset == TK_OFFS_MAX, then get_tcp_tstamp() calls
         ktime_mono_to_any() with out-of-bound value.
      
      2) if q->tk_offset is changed in taprio_parse_clockid(),
         taprio_get_time() might also call ktime_mono_to_any()
         with out-of-bound value as sysbot found:
      
      UBSAN: array-index-out-of-bounds in kernel/time/timekeeping.c:908:27
      index 3 is out of range for type 'ktime_t *[3]'
      CPU: 1 PID: 25668 Comm: kworker/u4:0 Not tainted 5.15.0-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
       ubsan_epilogue+0xb/0x5a lib/ubsan.c:151
       __ubsan_handle_out_of_bounds.cold+0x62/0x6c lib/ubsan.c:291
       ktime_mono_to_any+0x1d4/0x1e0 kernel/time/timekeeping.c:908
       get_tcp_tstamp net/sched/sch_taprio.c:322 [inline]
       get_packet_txtime net/sched/sch_taprio.c:353 [inline]
       taprio_enqueue_one+0x5b0/0x1460 net/sched/sch_taprio.c:420
       taprio_enqueue+0x3b1/0x730 net/sched/sch_taprio.c:485
       dev_qdisc_enqueue+0x40/0x300 net/core/dev.c:3785
       __dev_xmit_skb net/core/dev.c:3869 [inline]
       __dev_queue_xmit+0x1f6e/0x3630 net/core/dev.c:4194
       batadv_send_skb_packet+0x4a9/0x5f0 net/batman-adv/send.c:108
       batadv_iv_ogm_send_to_if net/batman-adv/bat_iv_ogm.c:393 [inline]
       batadv_iv_ogm_emit net/batman-adv/bat_iv_ogm.c:421 [inline]
       batadv_iv_send_outstanding_bat_ogm_packet+0x6d7/0x8e0 net/batman-adv/bat_iv_ogm.c:1701
       process_one_work+0x9b2/0x1690 kernel/workqueue.c:2298
       worker_thread+0x658/0x11f0 kernel/workqueue.c:2445
       kthread+0x405/0x4f0 kernel/kthread.c:327
       ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
      
      Fixes: 7ede7b03 ("taprio: make clock reference conversions easier")
      Fixes: 54002066
      
       ("taprio: Adjust timestamps for TCP packets")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Vedang Patel <vedang.patel@intel.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Reviewed-by: default avatarVinicius Costa Gomes <vinicius.gomes@intel.com>
      Link: https://lore.kernel.org/r/20211108180815.1822479-1-eric.dumazet@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3e13ce88
    • Marek Behún's avatar
      net: dsa: mv88e6xxx: Don't support >1G speeds on 6191X on ports other than 10 · 422fb879
      Marek Behún authored
      [ Upstream commit dc2fc9f0 ]
      
      Model 88E6191X only supports >1G speeds on port 10. Port 0 and 9 are
      only 1G.
      
      Fixes: de776d0d
      
       ("net: dsa: mv88e6xxx: add support for mv88e6393x family")
      Signed-off-by: default avatarMarek Behún <kabel@kernel.org>
      Cc: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Link: https://lore.kernel.org/r/20211104171747.10509-1-kabel@kernel.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      422fb879
    • Evan Quan's avatar
      drm/amdgpu: fix uvd crash on Polaris12 during driver unloading · f17e9e81
      Evan Quan authored
      [ Upstream commit 4fc30ea7 ]
      
      There was a change(below) target for such issue:
      d82e2c24 ("drm/amdgpu: Fix crash on device remove/driver unload")
      But the fix for VI ASICs was missing there. This is a supplement for
      that.
      
      Fixes: d82e2c24
      
       ("drm/amdgpu: Fix crash on device remove/driver unload")
      
      Signed-off-by: default avatarEvan Quan <evan.quan@amd.com>
      Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f17e9e81
    • Muchun Song's avatar
      seq_file: fix passing wrong private data · f00e054b
      Muchun Song authored
      [ Upstream commit 10a6de19 ]
      
      DEFINE_PROC_SHOW_ATTRIBUTE() is supposed to be used to define a series
      of functions and variables to register proc file easily. And the users
      can use proc_create_data() to pass their own private data and get it
      via seq->private in the callback. Unfortunately, the proc file system
      use PDE_DATA() to get private data instead of inode->i_private. So fix
      it. Fortunately, there only one user of it which does not pass any
      private data, so this bug does not break any in-tree codes.
      
      Link: https://lkml.kernel.org/r/20211029032638.84884-1-songmuchun@bytedance.com
      Fixes: 97a32539
      
       ("proc: convert everything to "struct proc_ops"")
      Signed-off-by: default avatarMuchun Song <songmuchun@bytedance.com>
      Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Florent Revest <revest@chromium.org>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f00e054b
    • Andrew Halaney's avatar
      init: make unknown command line param message clearer · acdc5065
      Andrew Halaney authored
      [ Upstream commit 8bc2b3dc ]
      
      The prior message is confusing users, which is the exact opposite of the
      goal.  If the message is being seen, one of the following situations is
      happening:
      
       1. the param is misspelled
       2. the param is not valid due to the kernel configuration
       3. the param is intended for init but isn't after the '--'
          delineator on the command line
      
      To make that more clear to the user, explicitly mention "kernel command
      line" and also note that the params are still passed to user space to
      avoid causing any alarm over params intended for init.
      
      Link: https://lkml.kernel.org/r/20211013223502.96756-1-ahalaney@redhat.com
      Fixes: 86d1919a
      
       ("init: print out unknown kernel parameters")
      Signed-off-by: default avatarAndrew Halaney <ahalaney@redhat.com>
      Suggested-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Borislav Petkov <bp@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      acdc5065
    • Imre Deak's avatar
      drm/i915/fb: Fix rounding error in subsampled plane size calculation · 2cf82ea0
      Imre Deak authored
      [ Upstream commit 90ab96f3 ]
      
      For NV12 FBs with odd main surface tile-row height the CCS surface
      height was incorrectly calculated 1 less than the actual value. Fix this
      by rounding up the result of divison. For consistency do the same for
      the CCS surface width calculation.
      
      Fixes: b3e57bcc
      
       ("drm/i915/tgl: Gen-12 render decompression")
      Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
      Reviewed-by: default avatarJuha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20211026225105.2783797-2-imre.deak@intel.com
      (cherry picked from commit 2ee5ef9c
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2cf82ea0
    • Dan Carpenter's avatar
      gve: Fix off by one in gve_tx_timeout() · fea0b950
      Dan Carpenter authored
      [ Upstream commit 1c360cc1 ]
      
      The priv->ntfy_blocks[] has "priv->num_ntfy_blks" elements so this >
      needs to be >= to prevent an off by one bug.  The priv->ntfy_blocks[]
      array is allocated in gve_alloc_notify_blocks().
      
      Fixes: 87a7f321
      
       ("gve: Recover from queue stall due to missed IRQ")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fea0b950
    • Arnd Bergmann's avatar
      dmaengine: stm32-dma: avoid 64-bit division in stm32_dma_get_max_width · 0bf8323e
      Arnd Bergmann authored
      [ Upstream commit 24983633 ]
      
      Using the % operator on a 64-bit variable is expensive and can
      cause a link failure:
      
      arm-linux-gnueabi-ld: drivers/dma/stm32-dma.o: in function `stm32_dma_get_max_width':
      stm32-dma.c:(.text+0x170): undefined reference to `__aeabi_uldivmod'
      arm-linux-gnueabi-ld: drivers/dma/stm32-dma.o: in function `stm32_dma_set_xfer_param':
      stm32-dma.c:(.text+0x1cd4): undefined reference to `__aeabi_uldivmod'
      
      As we know that we just want to check the alignment in
      stm32_dma_get_max_width(), there is no need for a full division, and
      using a simple mask is a faster replacement.
      
      Same in stm32_dma_set_xfer_param(), change this to only allow burst
      transfers if the address is a multiple of the length.
      stm32_dma_get_best_burst just after will take buf_len into account to fix
      burst in case of misalignment.
      
      Fixes: b20fd5fa
      
       ("dmaengine: stm32-dma: fix stm32_dma_get_max_width")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarAmelie Delaunay <amelie.delaunay@foss.st.com>
      Link: https://lore.kernel.org/r/20211103153312.41483-1-amelie.delaunay@foss.st.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0bf8323e
    • Amelie Delaunay's avatar
      dmaengine: stm32-dma: fix burst in case of unaligned memory address · 4ee1ac7f
      Amelie Delaunay authored
      [ Upstream commit af229d2c
      
       ]
      
      Theorically, address pointers used by STM32 DMA must be chosen so as to
      ensure that all transfers within a burst block are aligned on the address
      boundary equal to the size of the transfer.
      If this is always the case for peripheral addresses on STM32, it is not for
      memory addresses if the user doesn't respect this alignment constraint.
      To avoid a weird behavior of the DMA controller in this case (no error
      triggered but data are not transferred as expected), force no burst.
      
      Signed-off-by: default avatarAmelie Delaunay <amelie.delaunay@foss.st.com>
      Link: https://lore.kernel.org/r/20211011094259.315023-4-amelie.delaunay@foss.st.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4ee1ac7f
    • Jussi Maki's avatar
      bpf, sockmap: sk_skb data_end access incorrect when src_reg = dst_reg · 0bff34d6
      Jussi Maki authored
      [ Upstream commit b2c46181 ]
      
      The current conversion of skb->data_end reads like this:
      
        ; data_end = (void*)(long)skb->data_end;
         559: (79) r1 = *(u64 *)(r2 +200)   ; r1  = skb->data
         560: (61) r11 = *(u32 *)(r2 +112)  ; r11 = skb->len
         561: (0f) r1 += r11
         562: (61) r11 = *(u32 *)(r2 +116)
         563: (1f) r1 -= r11
      
      But similar to the case in 84f44df6 ("bpf: sock_ops sk access may stomp
      registers when dst_reg = src_reg"), the code will read an incorrect skb->len
      when src == dst. In this case we end up generating this xlated code:
      
        ; data_end = (void*)(long)skb->data_end;
         559: (79) r1 = *(u64 *)(r1 +200)   ; r1  = skb->data
         560: (61) r11 = *(u32 *)(r1 +112)  ; r11 = (skb->data)->len
         561: (0f) r1 += r11
         562: (61) r11 = *(u32 *)(r1 +116)
         563: (1f) r1 -= r11
      
      ... where line 560 is the reading 4B of (skb->data + 112) instead of the
      intended skb->len Here the skb pointer in r1 gets set to skb->data and the
      later deref for skb->len ends up following skb->data instead of skb.
      
      This fixes the issue similarly to the patch mentioned above by creating an
      additional temporary variable and using to store the register when dst_reg =
      src_reg. We name the variable bpf_temp_reg and place it in the cb context for
      sk_skb. Then we restore from the temp to ensure nothing is lost.
      
      Fixes: 16137b09
      
       ("bpf: Compute data_end dynamically with JIT code")
      Signed-off-by: default avatarJussi Maki <joamaki@gmail.com>
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/bpf/20211103204736.248403-6-john.fastabend@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0bff34d6
    • John Fastabend's avatar
      bpf: sockmap, strparser, and tls are reusing qdisc_skb_cb and colliding · 1a8dba02
      John Fastabend authored
      [ Upstream commit e0dc3b93 ]
      
      Strparser is reusing the qdisc_skb_cb struct to stash the skb message handling
      progress, e.g. offset and length of the skb. First this is poorly named and
      inherits a struct from qdisc that doesn't reflect the actual usage of cb[] at
      this layer.
      
      But, more importantly strparser is using the following to access its metadata.
      
        (struct _strp_msg *)((void *)skb->cb + offsetof(struct qdisc_skb_cb, data))
      
      Where _strp_msg is defined as:
      
        struct _strp_msg {
              struct strp_msg            strp;                 /*     0     8 */
              int                        accum_len;            /*     8     4 */
      
              /* size: 12, cachelines: 1, members: 2 */
              /* last cacheline: 12 bytes */
        };
      
      So we use 12 bytes of ->data[] in struct. However in BPF code running parser
      and verdict the user has read capabilities into the data[] array as well. Its
      not too problematic, but we should not be exposing internal state to BPF
      program. If its really needed then we can use the probe_read() APIs which allow
      reading kernel memory. And I don't believe cb[] layer poses any API breakage by
      moving this around because programs can't depend on cb[] across layers.
      
      In order to fix another issue with a ctx rewrite we need to stash a temp
      variable somewhere. To make this work cleanly this patch builds a cb struct
      for sk_skb types called sk_skb_cb struct. Then we can use this consistently
      in the strparser, sockmap space. Additionally we can start allowing ->cb[]
      write access after this.
      
      Fixes: 604326b4
      
       ("bpf, sockmap: convert to generic sk_msg interface")
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: default avatarJussi Maki <joamaki@gmail.com>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/bpf/20211103204736.248403-5-john.fastabend@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1a8dba02
    • John Fastabend's avatar
      bpf, sockmap: Fix race in ingress receive verdict with redirect to self · c5cc0d23
      John Fastabend authored
      [ Upstream commit c5d2177a ]
      
      A socket in a sockmap may have different combinations of programs attached
      depending on configuration. There can be no programs in which case the socket
      acts as a sink only. There can be a TX program in this case a BPF program is
      attached to sending side, but no RX program is attached. There can be an RX
      program only where sends have no BPF program attached, but receives are hooked
      with BPF. And finally, both TX and RX programs may be attached. Giving us the
      permutations:
      
       None, Tx, Rx, and TxRx
      
      To date most of our use cases have been TX case being used as a fast datapath
      to directly copy between local application and a userspace proxy. Or Rx cases
      and TxRX applications that are operating an in kernel based proxy. The traffic
      in the first case where we hook applications into a userspace application looks
      like this:
      
        AppA  redirect   AppB
         Tx <-----------> Rx
         |                |
         +                +
         TCP <--> lo <--> TCP
      
      In this case all traffic from AppA (after 3whs) is copied into the AppB
      ingress queue and no traffic is ever on the TCP recieive_queue.
      
      In the second case the application never receives, except in some rare error
      cases, traffic on the actual user space socket. Instead the send happens in
      the kernel.
      
                 AppProxy       socket pool
             sk0 ------------->{sk1,sk2, skn}
              ^                      |
              |                      |
              |                      v
             ingress              lb egress
             TCP                  TCP
      
      Here because traffic is never read off the socket with userspace recv() APIs
      there is only ever one reader on the sk receive_queue. Namely the BPF programs.
      
      However, we've started to introduce a third configuration where the BPF program
      on receive should process the data, but then the normal case is to push the
      data into the receive queue of AppB.
      
             AppB
             recv()                (userspace)
           -----------------------
             tcp_bpf_recvmsg()     (kernel)
               |             |
               |             |
               |             |
             ingress_msgQ    |
               |             |
             RX_BPF          |
               |             |
               v             v
             sk->receive_queue
      
      This is different from the App{A,B} redirect because traffic is first received
      on the sk->receive_queue.
      
      Now for the issue. The tcp_bpf_recvmsg() handler first checks the ingress_msg
      queue for any data handled by the BPF rx program and returned with PASS code
      so that it was enqueued on the ingress msg queue. Then if no data exists on
      that queue it checks the socket receive queue. Unfortunately, this is the same
      receive_queue the BPF program is reading data off of. So we get a race. Its
      possible for the recvmsg() hook to pull data off the receive_queue before the
      BPF hook has a chance to read it. It typically happens when an application is
      banging on recv() and getting EAGAINs. Until they manage to race with the RX
      BPF program.
      
      To fix this we note that before this patch at attach time when the socket is
      loaded into the map we check if it needs a TX program or just the base set of
      proto bpf hooks. Then it uses the above general RX hook regardless of if we
      have a BPF program attached at rx or not. This patch now extends this check to
      handle all cases enumerated above, TX, RX, TXRX, and none. And to fix above
      race when an RX program is attached we use a new hook that is nearly identical
      to the old one except now we do not let the recv() call skip the RX BPF program.
      Now only the BPF program pulls data from sk->receive_queue and recv() only
      pulls data from the ingress msgQ post BPF program handling.
      
      With this resolved our AppB from above has been up and running for many hours
      without detecting any errors. We do this by correlating counters in RX BPF
      events and the AppB to ensure data is never skipping the BPF program. Selftests,
      was not able to detect this because we only run them for a short period of time
      on well ordered send/recvs so we don't get any of the noise we see in real
      application environments.
      
      Fixes: 51199405
      
       ("bpf: skb_verdict, support SK_PASS on RX BPF path")
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: default avatarJussi Maki <joamaki@gmail.com>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/bpf/20211103204736.248403-4-john.fastabend@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c5cc0d23
    • John Fastabend's avatar
      bpf, sockmap: Remove unhash handler for BPF sockmap usage · 41c65a3c
      John Fastabend authored
      [ Upstream commit b8b8315e ]
      
      We do not need to handle unhash from BPF side we can simply wait for the
      close to happen. The original concern was a socket could transition from
      ESTABLISHED state to a new state while the BPF hook was still attached.
      But, we convinced ourself this is no longer possible and we also improved
      BPF sockmap to handle listen sockets so this is no longer a problem.
      
      More importantly though there are cases where unhash is called when data is
      in the receive queue. The BPF unhash logic will flush this data which is
      wrong. To be correct it should keep the data in the receive queue and allow
      a receiving application to continue reading the data. This may happen when
      tcp_abort() is received for example. Instead of complicating the logic in
      unhash simply moving all this to tcp_close() hook solves this.
      
      Fixes: 51199405
      
       ("bpf: skb_verdict, support SK_PASS on RX BPF path")
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: default avatarJussi Maki <joamaki@gmail.com>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Link: https://lore.kernel.org/bpf/20211103204736.248403-3-john.fastabend@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      41c65a3c
    • Arnd Bergmann's avatar
      arm64: pgtable: make __pte_to_phys/__phys_to_pte_val inline functions · b90d961c
      Arnd Bergmann authored
      [ Upstream commit c7c386fb ]
      
      gcc warns about undefined behavior the vmalloc code when building
      with CONFIG_ARM64_PA_BITS_52, when the 'idx++' in the argument to
      __phys_to_pte_val() is evaluated twice:
      
      mm/vmalloc.c: In function 'vmap_pfn_apply':
      mm/vmalloc.c:2800:58: error: operation on 'data->idx' may be undefined [-Werror=sequence-point]
       2800 |         *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
            |                                                 ~~~~~~~~~^~
      arch/arm64/include/asm/pgtable-types.h:25:37: note: in definition of macro '__pte'
         25 | #define __pte(x)        ((pte_t) { (x) } )
            |                                     ^
      arch/arm64/include/asm/pgtable.h:80:15: note: in expansion of macro '__phys_to_pte_val'
         80 |         __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot))
            |               ^~~~~~~~~~~~~~~~~
      mm/vmalloc.c:2800:30: note: in expansion of macro 'pfn_pte'
       2800 |         *pte = pte_mkspecial(pfn_pte(data->pfns[data->idx++], data->prot));
            |                              ^~~~~~~
      
      I have no idea why this never showed up earlier, but the safest
      workaround appears to be changing those macros into inline functions
      so the arguments get evaluated only once.
      
      Cc: Matthew Wilcox <willy@infradead.org>
      Fixes: 75387b92
      
       ("arm64: handle 52-bit physical addresses in page table entries")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20211105075414.2553155-1-arnd@kernel.org
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b90d961c
    • Reiji Watanabe's avatar
      arm64: arm64_ftr_reg->name may not be a human-readable string · f8289150
      Reiji Watanabe authored
      [ Upstream commit 9dc232a8 ]
      
      The id argument of ARM64_FTR_REG_OVERRIDE() is used for two purposes:
      one as the system register encoding (used for the sys_id field of
      __ftr_reg_entry), and the other as the register name (stringified
      and used for the name field of arm64_ftr_reg), which is debug
      information. The id argument is supposed to be a macro that
      indicates an encoding of the register (eg. SYS_ID_AA64PFR0_EL1, etc).
      
      ARM64_FTR_REG(), which also has the same id argument,
      uses ARM64_FTR_REG_OVERRIDE() and passes the id to the macro.
      Since the id argument is completely macro-expanded before it is
      substituted into a macro body of ARM64_FTR_REG_OVERRIDE(),
      the stringified id in the body of ARM64_FTR_REG_OVERRIDE is not
      a human-readable register name, but a string of numeric bitwise
      operations.
      
      Fix this so that human-readable register names are available as
      debug information.
      
      Fixes: 8f266a5d
      
       ("arm64: cpufeature: Add global feature override facility")
      Signed-off-by: default avatarReiji Watanabe <reijiw@google.com>
      Reviewed-by: default avatarOliver Upton <oupton@google.com>
      Acked-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20211101045421.2215822-1-reijiw@google.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f8289150
    • Christophe JAILLET's avatar
      litex_liteeth: Fix a double free in the remove function · 2d57d522
      Christophe JAILLET authored
      [ Upstream commit c45231a7 ]
      
      'netdev' is a managed resource allocated in the probe using
      'devm_alloc_etherdev()'.
      It must not be freed explicitly in the remove function.
      
      Fixes: ee7da21a
      
       ("net: Add driver for LiteX's LiteETH network interface")
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2d57d522
    • Chengfeng Ye's avatar
      nfc: pn533: Fix double free when pn533_fill_fragment_skbs() fails · 2d2dfc33
      Chengfeng Ye authored
      [ Upstream commit 9fec40f8 ]
      
      skb is already freed by dev_kfree_skb in pn533_fill_fragment_skbs,
      but follow error handler branch when pn533_fill_fragment_skbs()
      fails, skb is freed again, results in double free issue. Fix this
      by not free skb in error path of pn533_fill_fragment_skbs.
      
      Fixes: 963a82e0 ("NFC: pn533: Split large Tx frames in chunks")
      Fixes: 93ad4202
      
       ("NFC: pn533: Target mode Tx fragmentation support")
      Signed-off-by: default avatarChengfeng Ye <cyeaa@connect.ust.hk>
      Reviewed-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2d2dfc33
    • Eric Dumazet's avatar
      llc: fix out-of-bound array index in llc_sk_dev_hash() · 72fb40d8
      Eric Dumazet authored
      [ Upstream commit 8ac9dfd5 ]
      
      Both ifindex and LLC_SK_DEV_HASH_ENTRIES are signed.
      
      This means that (ifindex % LLC_SK_DEV_HASH_ENTRIES) is negative
      if @ifindex is negative.
      
      We could simply make LLC_SK_DEV_HASH_ENTRIES unsigned.
      
      In this patch I chose to use hash_32() to get more entropy
      from @ifindex, like llc_sk_laddr_hashfn().
      
      UBSAN: array-index-out-of-bounds in ./include/net/llc.h:75:26
      index -43 is out of range for type 'hlist_head [64]'
      CPU: 1 PID: 20999 Comm: syz-executor.3 Not tainted 5.15.0-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
       ubsan_epilogue+0xb/0x5a lib/ubsan.c:151
       __ubsan_handle_out_of_bounds.cold+0x62/0x6c lib/ubsan.c:291
       llc_sk_dev_hash include/net/llc.h:75 [inline]
       llc_sap_add_socket+0x49c/0x520 net/llc/llc_conn.c:697
       llc_ui_bind+0x680/0xd70 net/llc/af_llc.c:404
       __sys_bind+0x1e9/0x250 net/socket.c:1693
       __do_sys_bind net/socket.c:1704 [inline]
       __se_sys_bind net/socket.c:1702 [inline]
       __x64_sys_bind+0x6f/0xb0 net/socket.c:1702
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7fa503407ae9
      
      Fixes: 6d2e3ea2
      
       ("llc: use a device based hash table to speed up multicast delivery")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      72fb40d8
    • Ian Rogers's avatar
      perf bpf: Add missing free to bpf_event__print_bpf_prog_info() · 63609f11
      Ian Rogers authored
      [ Upstream commit 88c42f4d ]
      
      If btf__new() is called then there needs to be a corresponding btf__free().
      
      Fixes: f8dfeae0
      
       ("perf bpf: Show more BPF program info in print_bpf_prog_info()")
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrii Nakryiko <andrii@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: John Fastabend <john.fastabend@gmail.com>
      Cc: KP Singh <kpsingh@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Tiezhu Yang <yangtiezhu@loongson.cn>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20211106053733.3580931-2-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      63609f11
    • Dan Carpenter's avatar
      zram: off by one in read_block_state() · 18fdce80
      Dan Carpenter authored
      [ Upstream commit a88e03cf ]
      
      snprintf() returns the number of bytes it would have printed if there
      were space.  But it does not count the NUL terminator.  So that means
      that if "count == copied" then this has already overflowed by one
      character.
      
      This bug likely isn't super harmful in real life.
      
      Link: https://lkml.kernel.org/r/20210916130404.GA25094@kili
      Fixes: c0265342
      
       ("zram: introduce zram memory tracking")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      18fdce80
    • Miaohe Lin's avatar
      mm/zsmalloc.c: close race window between zs_pool_dec_isolated() and zs_unregister_migration() · 3d6b113c
      Miaohe Lin authored
      [ Upstream commit afe8605c ]
      
      There is one possible race window between zs_pool_dec_isolated() and
      zs_unregister_migration() because wait_for_isolated_drain() checks the
      isolated count without holding class->lock and there is no order inside
      zs_pool_dec_isolated().  Thus the below race window could be possible:
      
        zs_pool_dec_isolated		zs_unregister_migration
          check pool->destroying != 0
      				  pool->destroying = true;
      				  smp_mb();
      				  wait_for_isolated_drain()
      				    wait for pool->isolated_pages == 0
          atomic_long_dec(&pool->isolated_pages);
          atomic_long_read(&pool->isolated_pages) == 0
      
      Since we observe the pool->destroying (false) before atomic_long_dec()
      for pool->isolated_pages, waking pool->migration_wait up is missed.
      
      Fix this by ensure checking pool->destroying happens after the
      atomic_long_dec(&pool->isolated_pages).
      
      Link: https://lkml.kernel.org/r/20210708115027.7557-1-linmiaohe@huawei.com
      Fixes: 701d6785
      
       ("mm/zsmalloc.c: fix race condition in zs_destroy_pool")
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Henry Burns <henryburns@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d6b113c
    • Marc Kleine-Budde's avatar
      can: mcp251xfd: mcp251xfd_chip_start(): fix error handling for mcp251xfd_chip_rx_int_enable() · 1ba8ddd8
      Marc Kleine-Budde authored
      [ Upstream commit 69c55f6e ]
      
      This patch fixes the error handling for mcp251xfd_chip_rx_int_enable().
      Instead just returning the error, properly shut down the chip.
      
      Link: https://lore.kernel.org/all/20211106201526.44292-2-mkl@pengutronix.de
      Fixes: 55e5b97f
      
       ("can: mcp25xxfd: add driver for Microchip MCP25xxFD SPI CAN")
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1ba8ddd8
    • Vincent Mailhol's avatar
      can: etas_es58x: es58x_rx_err_msg(): fix memory leak in error path · 7eb0881a
      Vincent Mailhol authored
      [ Upstream commit d9447f76 ]
      
      In es58x_rx_err_msg(), if can->do_set_mode() fails, the function
      directly returns without calling netif_rx(skb). This means that the
      skb previously allocated by alloc_can_err_skb() is not freed. In other
      terms, this is a memory leak.
      
      This patch simply removes the return statement in the error branch and
      let the function continue.
      
      Issue was found with GCC -fanalyzer, please follow the link below for
      details.
      
      Fixes: 85372578
      
       ("can: etas_es58x: add core support for ETAS ES58X CAN USB interfaces")
      Link: https://lore.kernel.org/all/20211026180740.1953265-1-mailhol.vincent@wanadoo.fr
      Signed-off-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7eb0881a
    • Alex Deucher's avatar
      drm/amdgpu/powerplay: fix sysfs_emit/sysfs_emit_at handling · e16a1e4b
      Alex Deucher authored
      [ Upstream commit e9c76719 ]
      
      sysfs_emit and sysfs_emit_at requrie a page boundary
      aligned buf address. Make them happy!
      
      v2: fix sysfs_emit -> sysfs_emit_at missed conversions
      
      Cc: Lang Yu <lang.yu@amd.com>
      Cc: Darren Powell <darren.powell@amd.com>
      Fixes: 6db0c87a
      
       ("amdgpu/pm: Replace hwmgr smu usage of sprintf with sysfs_emit")
      Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1774
      Reviewed-by: default avatarLang Yu <lang.yu@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e16a1e4b
    • Fabio Estevam's avatar
      Revert "drm/imx: Annotate dma-fence critical section in commit path" · 97308cd5
      Fabio Estevam authored
      [ Upstream commit 14d9a37c ]
      
      This reverts commit f4b34faa.
      
      Since commit f4b34faa ("drm/imx: Annotate dma-fence critical section in
      commit path") the following possible circular dependency is detected:
      
      [    5.001811] ======================================================
      [    5.001817] WARNING: possible circular locking dependency detected
      [    5.001824] 5.14.9-01225-g45da36cc6fcc-dirty #1 Tainted: G        W
      [    5.001833] ------------------------------------------------------
      [    5.001838] kworker/u8:0/7 is trying to acquire lock:
      [    5.001848] c1752080 (regulator_list_mutex){+.+.}-{3:3}, at: regulator_lock_dependent+0x40/0x294
      [    5.001903]
      [    5.001903] but task is already holding lock:
      [    5.001909] c176df78 (dma_fence_map){++++}-{0:0}, at: imx_drm_atomic_commit_tail+0x10/0x160
      [    5.001957]
      [    5.001957] which lock already depends on the new lock.
      ...
      
      Revert it for now.
      
      Tested on a imx6q-sabresd.
      
      Fixes: f4b34faa
      
       ("drm/imx: Annotate dma-fence critical section in commit path")
      Signed-off-by: default avatarFabio Estevam <festevam@gmail.com>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20211104001112.4035691-1-festevam@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      97308cd5
    • Arnd Bergmann's avatar
      drm: fb_helper: improve CONFIG_FB dependency · 94e18f5a
      Arnd Bergmann authored
      [ Upstream commit 9d6366e7 ]
      
      My previous patch correctly addressed the possible link failure, but as
      Jani points out, the dependency is now stricter than it needs to be.
      
      Change it again, to allow DRM_FBDEV_EMULATION to be used when
      DRM_KMS_HELPER and FB are both loadable modules and DRM is linked into
      the kernel.
      
      As a side-effect, the option is now only visible when at least one DRM
      driver makes use of DRM_KMS_HELPER. This is better, because the option
      has no effect otherwise.
      
      Fixes: 606b1028
      
       ("drm: fb_helper: fix CONFIG_FB dependency")
      Suggested-by: default avatarAcked-by: Jani Nikula <jani.nikula@intel.com>
      Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20211029120307.1407047-1-arnd@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      94e18f5a
    • Hangbin Liu's avatar
      selftests/bpf/xdp_redirect_multi: Limit the tests in netns · 39db3e56
      Hangbin Liu authored
      [ Upstream commit 8955c1a3 ]
      
      As I want to test both DEVMAP and DEVMAP_HASH in XDP multicast redirect, I
      limited DEVMAP max entries to a small value for performace. When the test
      runs after amount of interface creating/deleting tests. The interface index
      will exceed the map max entries and xdp_redirect_multi will error out with
      "Get interfacesInterface index to large".
      
      Fix this issue by limit the tests in netns and specify the ifindex when
      creating interfaces.
      
      Fixes: d2329247
      
       ("selftests/bpf: Add xdp_redirect_multi test")
      Reported-by: default avatarJiri Benc <jbenc@redhat.com>
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20211027033553.962413-5-liuhangbin@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      39db3e56
    • Hangbin Liu's avatar
      selftests/bpf/xdp_redirect_multi: Give tcpdump a chance to terminate cleanly · a99e4d94
      Hangbin Liu authored
      [ Upstream commit 648c3677 ]
      
      No need to kill tcpdump with -9.
      
      Fixes: d2329247
      
       ("selftests/bpf: Add xdp_redirect_multi test")
      Suggested-by: default avatarJiri Benc <jbenc@redhat.com>
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20211027033553.962413-4-liuhangbin@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a99e4d94
    • Hangbin Liu's avatar
      selftests/bpf/xdp_redirect_multi: Use arping to accurate the arp number · 00f99113
      Hangbin Liu authored
      [ Upstream commit f53ea9db ]
      
      The arp request number triggered by ping none exist address is not accurate,
      which may lead the test false negative/positive. Change to use arping to
      accurate the arp number. Also do not use grep pattern match for dot.
      
      Fixes: d2329247
      
       ("selftests/bpf: Add xdp_redirect_multi test")
      Suggested-by: default avatarJiri Benc <jbenc@redhat.com>
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20211027033553.962413-3-liuhangbin@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      00f99113
    • Hangbin Liu's avatar
      selftests/bpf/xdp_redirect_multi: Put the logs to tmp folder · ddf4f389
      Hangbin Liu authored
      [ Upstream commit 8b4ac13a ]
      
      The xdp_redirect_multi test logs are created in selftest folder and not cleaned
      after test. Let's creat a tmp dir and remove the logs after testing.
      
      Fixes: d2329247
      
       ("selftests/bpf: Add xdp_redirect_multi test")
      Suggested-by: default avatarJiri Benc <jbenc@redhat.com>
      Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Link: https://lore.kernel.org/bpf/20211027033553.962413-2-liuhangbin@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ddf4f389
    • Mehrdad Arshad Rad's avatar
      libbpf: Fix lookup_and_delete_elem_flags error reporting · e13c7544
      Mehrdad Arshad Rad authored
      [ Upstream commit 64165ddf ]
      
      Fix bpf_map_lookup_and_delete_elem_flags() to pass the return code through
      libbpf_err_errno() as we do similarly in bpf_map_lookup_and_delete_elem().
      
      Fixes: f12b6543
      
       ("libbpf: Streamline error reporting for low-level APIs")
      Signed-off-by: default avatarMehrdad Arshad Rad <arshad.rad@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20211104171354.11072-1-arshad.rad@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e13c7544
    • Rafael J. Wysocki's avatar
      ACPI: PM: Fix device wakeup power reference counting error · f0f8307c
      Rafael J. Wysocki authored
      [ Upstream commit 452a3e72 ]
      
      Fix a device wakeup power reference counting error introduced by
      commit a2d7b2e0 ("ACPI: PM: Fix sharing of wakeup power
      resources") because of a coding mistake.
      
      Fixes: a2d7b2e0
      
       ("ACPI: PM: Fix sharing of wakeup power resources")
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f0f8307c
    • Kai Song's avatar
      mfd: altera-sysmgr: Fix a mistake caused by resource_size conversion · 27f2e5b9
      Kai Song authored
      [ Upstream commit fae2570d ]
      
      The resource_size defines that:
      	res->end - res->start + 1;
      The origin original code is:
      	sysmgr_config.max_register = res->end - res->start - 3;
      
      So, the correct fix is that:
      	sysmgr_config.max_register = resource_size(res) - 4;
      
      Fixes: d12edf96
      
       ("mfd: altera-sysmgr: Use resource_size function on resource object")
      Signed-off-by: default avatarKai Song <songkai01@inspur.com>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Link: https://lore.kernel.org/r/20211006141926.6120-1-songkai01@inspur.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      27f2e5b9
    • Mark Brown's avatar
      mfd: sprd: Add SPI device ID table · 5fb2bcf0
      Mark Brown authored
      [ Upstream commit c5c7f067 ]
      
      Currently autoloading for SPI devices does not use the DT ID table, it uses
      SPI modalises. Supporting OF modalises is going to be difficult if not
      impractical, an attempt was made but has been reverted, so ensure that
      module autoloading works for this driver by adding a SPI device ID table.
      
      Fixes: 96c8395e
      
       ("spi: Revert modalias changes")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarBaolin Wang <baolin.wang7@gmail.com>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Link: https://lore.kernel.org/r/20210924143347.14721-4-broonie@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5fb2bcf0
    • Mark Brown's avatar
      mfd: cpcap: Add SPI device ID table · bd20d4d8
      Mark Brown authored
      [ Upstream commit d5fa8592 ]
      
      Currently autoloading for SPI devices does not use the DT ID table, it uses
      SPI modalises. Supporting OF modalises is going to be difficult if not
      impractical, an attempt was made but has been reverted, so ensure that
      module autoloading works for this driver by adding a SPI device ID table.
      
      Fixes: 96c8395e
      
       ("spi: Revert modalias changes")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Link: https://lore.kernel.org/r/20210924143347.14721-3-broonie@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bd20d4d8
    • Krzysztof Kozlowski's avatar
      mfd: core: Add missing of_node_put for loop iteration · 34b1f6db
      Krzysztof Kozlowski authored
      [ Upstream commit 002be811 ]
      
      Early exits from for_each_child_of_node() should decrement the
      node reference counter.  Reported by Coccinelle:
      
        drivers/mfd/mfd-core.c:197:2-24: WARNING:
          Function "for_each_child_of_node" should have of_node_put() before goto around lines 209.
      
      Fixes: c94bb233
      
       ("mfd: Make MFD core code Device Tree and IRQ domain aware")
      Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Link: https://lore.kernel.org/r/20210528115126.18370-1-krzysztof.kozlowski@canonical.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      34b1f6db
    • Takashi Iwai's avatar
      ALSA: memalloc: Catch call with NULL snd_dma_buffer pointer · ca1362fd
      Takashi Iwai authored
      [ Upstream commit dce94461 ]
      
      Although we've covered all calls with NULL dma buffer pointer, so far,
      there may be still some else in the wild.  For catching such a case
      more easily, add a WARN_ON_ONCE() in snd_dma_get_ops().
      
      Fixes: 37af81c5
      
       ("ALSA: core: Abstract memory alloc helpers")
      Link: https://lore.kernel.org/r/20211105102103.28148-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ca1362fd
    • Arnd Bergmann's avatar
      octeontx2-pf: select CONFIG_NET_DEVLINK · e9806f88
      Arnd Bergmann authored
      [ Upstream commit 9cbc3367 ]
      
      The octeontx2 pf nic driver failsz to link when the devlink support
      is not reachable:
      
      aarch64-linux-ld: drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.o: in function `otx2_dl_mcam_count_get':
      otx2_devlink.c:(.text+0x10): undefined reference to `devlink_priv'
      aarch64-linux-ld: drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.o: in function `otx2_dl_mcam_count_validate':
      otx2_devlink.c:(.text+0x50): undefined reference to `devlink_priv'
      aarch64-linux-ld: drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.o: in function `otx2_dl_mcam_count_set':
      otx2_devlink.c:(.text+0xd0): undefined reference to `devlink_priv'
      aarch64-linux-ld: drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.o: in function `otx2_devlink_info_get':
      otx2_devlink.c:(.text+0x150): undefined reference to `devlink_priv'
      
      This is already selected by the admin function driver, but not the
      actual nic, which might be built-in when the af driver is not.
      
      Fixes: 2da48943
      
       ("octeontx2-pf: devlink params support to set mcam entry count")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e9806f88
    • Huang Guobin's avatar
      bonding: Fix a use-after-free problem when bond_sysfs_slave_add() failed · 0c49ae7a
      Huang Guobin authored
      [ Upstream commit b93c6a91 ]
      
      When I do fuzz test for bonding device interface, I got the following
      use-after-free Calltrace:
      
      ==================================================================
      BUG: KASAN: use-after-free in bond_enslave+0x1521/0x24f0
      Read of size 8 at addr ffff88825bc11c00 by task ifenslave/7365
      
      CPU: 5 PID: 7365 Comm: ifenslave Tainted: G            E     5.15.0-rc1+ #13
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014
      Call Trace:
       dump_stack_lvl+0x6c/0x8b
       print_address_description.constprop.0+0x48/0x70
       kasan_report.cold+0x82/0xdb
       __asan_load8+0x69/0x90
       bond_enslave+0x1521/0x24f0
       bond_do_ioctl+0x3e0/0x450
       dev_ifsioc+0x2ba/0x970
       dev_ioctl+0x112/0x710
       sock_do_ioctl+0x118/0x1b0
       sock_ioctl+0x2e0/0x490
       __x64_sys_ioctl+0x118/0x150
       do_syscall_64+0x35/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7f19159cf577
      Code: b3 66 90 48 8b 05 11 89 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 78
      RSP: 002b:00007ffeb3083c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      RAX: ffffffffffffffda RBX: 00007ffeb3084bca RCX: 00007f19159cf577
      RDX: 00007ffeb3083ce0 RSI: 0000000000008990 RDI: 0000000000000003
      RBP: 00007ffeb3084bc4 R08: 0000000000000040 R09: 0000000000000000
      R10: 00007ffeb3084bc0 R11: 0000000000000246 R12: 00007ffeb3083ce0
      R13: 0000000000000000 R14: 0000000000000000 R15: 00007ffeb3083cb0
      
      Allocated by task 7365:
       kasan_save_stack+0x23/0x50
       __kasan_kmalloc+0x83/0xa0
       kmem_cache_alloc_trace+0x22e/0x470
       bond_enslave+0x2e1/0x24f0
       bond_do_ioctl+0x3e0/0x450
       dev_ifsioc+0x2ba/0x970
       dev_ioctl+0x112/0x710
       sock_do_ioctl+0x118/0x1b0
       sock_ioctl+0x2e0/0x490
       __x64_sys_ioctl+0x118/0x150
       do_syscall_64+0x35/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Freed by task 7365:
       kasan_save_stack+0x23/0x50
       kasan_set_track+0x20/0x30
       kasan_set_free_info+0x24/0x40
       __kasan_slab_free+0xf2/0x130
       kfree+0xd1/0x5c0
       slave_kobj_release+0x61/0x90
       kobject_put+0x102/0x180
       bond_sysfs_slave_add+0x7a/0xa0
       bond_enslave+0x11b6/0x24f0
       bond_do_ioctl+0x3e0/0x450
       dev_ifsioc+0x2ba/0x970
       dev_ioctl+0x112/0x710
       sock_do_ioctl+0x118/0x1b0
       sock_ioctl+0x2e0/0x490
       __x64_sys_ioctl+0x118/0x150
       do_syscall_64+0x35/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Last potentially related work creation:
       kasan_save_stack+0x23/0x50
       kasan_record_aux_stack+0xb7/0xd0
       insert_work+0x43/0x190
       __queue_work+0x2e3/0x970
       delayed_work_timer_fn+0x3e/0x50
       call_timer_fn+0x148/0x470
       run_timer_softirq+0x8a8/0xc50
       __do_softirq+0x107/0x55f
      
      Second to last potentially related work creation:
       kasan_save_stack+0x23/0x50
       kasan_record_aux_stack+0xb7/0xd0
       insert_work+0x43/0x190
       __queue_work+0x2e3/0x970
       __queue_delayed_work+0x130/0x180
       queue_delayed_work_on+0xa7/0xb0
       bond_enslave+0xe25/0x24f0
       bond_do_ioctl+0x3e0/0x450
       dev_ifsioc+0x2ba/0x970
       dev_ioctl+0x112/0x710
       sock_do_ioctl+0x118/0x1b0
       sock_ioctl+0x2e0/0x490
       __x64_sys_ioctl+0x118/0x150
       do_syscall_64+0x35/0xb0
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      The buggy address belongs to the object at ffff88825bc11c00
       which belongs to the cache kmalloc-1k of size 1024
      The buggy address is located 0 bytes inside of
       1024-byte region [ffff88825bc11c00, ffff88825bc12000)
      The buggy address belongs to the page:
      page:ffffea00096f0400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x25bc10
      head:ffffea00096f0400 order:3 compound_mapcount:0 compound_pincount:0
      flags: 0x57ff00000010200(slab|head|node=1|zone=2|lastcpupid=0x7ff)
      raw: 057ff00000010200 ffffea0009a71c08 ffff888240001968 ffff88810004dbc0
      raw: 0000000000000000 00000000000a000a 00000001ffffffff 0000000000000000
      page dumped because: kasan: bad access detected
      
      Memory state around the buggy address:
       ffff88825bc11b00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
       ffff88825bc11b80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      >ffff88825bc11c00: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                         ^
       ffff88825bc11c80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
       ffff88825bc11d00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
      ==================================================================
      
      Put new_slave in bond_sysfs_slave_add() will cause use-after-free problems
      when new_slave is accessed in the subsequent error handling process. Since
      new_slave will be put in the subsequent error handling process, remove the
      unnecessary put to fix it.
      In addition, when sysfs_create_file() fails, if some files have been crea-
      ted successfully, we need to call sysfs_remove_file() to remove them.
      Since there are sysfs_create_files() & sysfs_remove_files() can be used,
      use these two functions instead.
      
      Fixes: 7afcaec4
      
       (bonding: use kobject_put instead of _del after kobject_add)
      Signed-off-by: default avatarHuang Guobin <huangguobin4@huawei.com>
      Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0c49ae7a