Skip to content
  1. May 22, 2021
    • Pablo Neira Ayuso's avatar
      netfilter: nfnetlink_osf: Fix a missing skb_header_pointer() NULL check · e11924b7
      Pablo Neira Ayuso authored
      [ Upstream commit 5e024c32 ]
      
      Do not assume that the tcph->doff field is correct when parsing for TCP
      options, skb_header_pointer() might fail to fetch these bits.
      
      Fixes: 11eeef41
      
       ("netfilter: passive OS fingerprint xtables match")
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e11924b7
    • Cong Wang's avatar
      smc: disallow TCP_ULP in smc_setsockopt() · bb101fb4
      Cong Wang authored
      [ Upstream commit 86214366
      
       ]
      
      syzbot is able to setup kTLS on an SMC socket which coincidentally
      uses sk_user_data too. Later, kTLS treats it as psock so triggers a
      refcnt warning. The root cause is that smc_setsockopt() simply calls
      TCP setsockopt() which includes TCP_ULP. I do not think it makes
      sense to setup kTLS on top of SMC sockets, so we should just disallow
      this setup.
      
      It is hard to find a commit to blame, but we can apply this patch
      since the beginning of TCP_ULP.
      
      Reported-and-tested-by: default avatar <syzbot+b54a1ce86ba4a623b7f0@syzkaller.appspotmail.com>
      Fixes: 734942cc
      
       ("tcp: ULP infrastructure")
      Cc: John Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
      Signed-off-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bb101fb4
    • Maciej Żenczykowski's avatar
      net: fix nla_strcmp to handle more then one trailing null character · 4f21d7eb
      Maciej Żenczykowski authored
      [ Upstream commit 2c16db6c
      
       ]
      
      Android userspace has been using TCA_KIND with a char[IFNAMESIZ]
      many-null-terminated buffer containing the string 'bpf'.
      
      This works on 4.19 and ceases to work on 5.10.
      
      I'm not entirely sure what fixes tag to use, but I think the issue
      was likely introduced in the below mentioned 5.4 commit.
      
      Reported-by: default avatarNucca Chen <nuccachen@google.com>
      Cc: Cong Wang <xiyou.wangcong@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
      Cc: Jamal Hadi Salim <jhs@mojatatu.com>
      Cc: Jiri Pirko <jiri@mellanox.com>
      Cc: Jiri Pirko <jiri@resnulli.us>
      Fixes: 62794fc4
      
       ("net_sched: add max len check for TCA_KIND")
      Change-Id: I66dc281f165a2858fc29a44869a270a2d698a82b
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4f21d7eb
    • Miaohe Lin's avatar
      ksm: fix potential missing rmap_item for stable_node · 3a794e45
      Miaohe Lin authored
      [ Upstream commit c89a384e ]
      
      When removing rmap_item from stable tree, STABLE_FLAG of rmap_item is
      cleared with head reserved.  So the following scenario might happen: For
      ksm page with rmap_item1:
      
      cmp_and_merge_page
        stable_node->head = &migrate_nodes;
        remove_rmap_item_from_tree, but head still equal to stable_node;
        try_to_merge_with_ksm_page failed;
        return;
      
      For the same ksm page with rmap_item2, stable node migration succeed this
      time.  The stable_node->head does not equal to migrate_nodes now.  For ksm
      page with rmap_item1 again:
      
      cmp_and_merge_page
       stable_node->head != &migrate_nodes && rmap_item->head == stable_node
       return;
      
      We would miss the rmap_item for stable_node and might result in failed
      rmap_walk_ksm().  Fix this by set rmap_item->head to NULL when rmap_item
      is removed from stable tree.
      
      Link: https://lkml.kernel.org/r/20210330140228.45635-5-linmiaohe@huawei.com
      Fixes: 4146d2d6
      
       ("ksm: make !merge_across_nodes migration safe")
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Cc: Hugh Dickins <hughd@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>
      3a794e45
    • Miaohe Lin's avatar
      mm/hugeltb: handle the error case in hugetlb_fix_reserve_counts() · 2e8b30d7
      Miaohe Lin authored
      [ Upstream commit da56388c ]
      
      A rare out of memory error would prevent removal of the reserve map region
      for a page.  hugetlb_fix_reserve_counts() handles this rare case to avoid
      dangling with incorrect counts.  Unfortunately, hugepage_subpool_get_pages
      and hugetlb_acct_memory could possibly fail too.  We should correctly
      handle these cases.
      
      Link: https://lkml.kernel.org/r/20210410072348.20437-5-linmiaohe@huawei.com
      Fixes: b5cec28d
      
       ("hugetlbfs: truncate_hugepages() takes a range of pages")
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Cc: Feilong Lin <linfeilong@huawei.com>
      Cc: Mike Kravetz <mike.kravetz@oracle.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>
      2e8b30d7
    • Miaohe Lin's avatar
      khugepaged: fix wrong result value for trace_mm_collapse_huge_page_isolate() · fdacfd77
      Miaohe Lin authored
      [ Upstream commit 74e579bf ]
      
      In writable and !referenced case, the result value should be
      SCAN_LACK_REFERENCED_PAGE for trace_mm_collapse_huge_page_isolate()
      instead of default 0 (SCAN_FAIL) here.
      
      Link: https://lkml.kernel.org/r/20210306032947.35921-5-linmiaohe@huawei.com
      Fixes: 7d2eba05
      
       ("mm: add tracepoint for scanning pages")
      Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
      Acked-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Cc: Dan Carpenter <dan.carpenter@oracle.com>
      Cc: Ebru Akagunduz <ebru.akagunduz@gmail.com>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Rik van Riel <riel@redhat.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>
      fdacfd77
    • Kees Cook's avatar
      drm/radeon: Avoid power table parsing memory leaks · cd9e6735
      Kees Cook authored
      [ Upstream commit c69f2713 ]
      
      Avoid leaving a hanging pre-allocated clock_info if last mode is
      invalid, and avoid heap corruption if no valid modes are found.
      
      Bug: https://bugzilla.kernel.org/show_bug.cgi?id=211537
      Fixes: 6991b8f2
      
       ("drm/radeon/kms: fix segfault in pm rework")
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cd9e6735
    • Kees Cook's avatar
      drm/radeon: Fix off-by-one power_state index heap overwrite · d241510b
      Kees Cook authored
      [ Upstream commit 5bbf2193
      
       ]
      
      An out of bounds write happens when setting the default power state.
      KASAN sees this as:
      
      [drm] radeon: 512M of GTT memory ready.
      [drm] GART: num cpu pages 131072, num gpu pages 131072
      ==================================================================
      BUG: KASAN: slab-out-of-bounds in
      radeon_atombios_parse_power_table_1_3+0x1837/0x1998 [radeon]
      Write of size 4 at addr ffff88810178d858 by task systemd-udevd/157
      
      CPU: 0 PID: 157 Comm: systemd-udevd Not tainted 5.12.0-E620 #50
      Hardware name: eMachines        eMachines E620  /Nile       , BIOS V1.03 09/30/2008
      Call Trace:
       dump_stack+0xa5/0xe6
       print_address_description.constprop.0+0x18/0x239
       kasan_report+0x170/0x1a8
       radeon_atombios_parse_power_table_1_3+0x1837/0x1998 [radeon]
       radeon_atombios_get_power_modes+0x144/0x1888 [radeon]
       radeon_pm_init+0x1019/0x1904 [radeon]
       rs690_init+0x76e/0x84a [radeon]
       radeon_device_init+0x1c1a/0x21e5 [radeon]
       radeon_driver_load_kms+0xf5/0x30b [radeon]
       drm_dev_register+0x255/0x4a0 [drm]
       radeon_pci_probe+0x246/0x2f6 [radeon]
       pci_device_probe+0x1aa/0x294
       really_probe+0x30e/0x850
       driver_probe_device+0xe6/0x135
       device_driver_attach+0xc1/0xf8
       __driver_attach+0x13f/0x146
       bus_for_each_dev+0xfa/0x146
       bus_add_driver+0x2b3/0x447
       driver_register+0x242/0x2c1
       do_one_initcall+0x149/0x2fd
       do_init_module+0x1ae/0x573
       load_module+0x4dee/0x5cca
       __do_sys_finit_module+0xf1/0x140
       do_syscall_64+0x33/0x40
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      
      Without KASAN, this will manifest later when the kernel attempts to
      allocate memory that was stomped, since it collides with the inline slab
      freelist pointer:
      
      invalid opcode: 0000 [#1] SMP NOPTI
      CPU: 0 PID: 781 Comm: openrc-run.sh Tainted: G        W 5.10.12-gentoo-E620 #2
      Hardware name: eMachines        eMachines E620  /Nile , BIOS V1.03       09/30/2008
      RIP: 0010:kfree+0x115/0x230
      Code: 89 c5 e8 75 ea ff ff 48 8b 00 0f ba e0 09 72 63 e8 1f f4 ff ff 41 89 c4 48 8b 45 00 0f ba e0 10 72 0a 48 8b 45 08 a8 01 75 02 <0f> 0b 44 89 e1 48 c7 c2 00 f0 ff ff be 06 00 00 00 48 d3 e2 48 c7
      RSP: 0018:ffffb42f40267e10 EFLAGS: 00010246
      RAX: ffffd61280ee8d88 RBX: 0000000000000004 RCX: 000000008010000d
      RDX: 4000000000000000 RSI: ffffffffba1360b0 RDI: ffffd61280ee8d80
      RBP: ffffd61280ee8d80 R08: ffffffffb91bebdf R09: 0000000000000000
      R10: ffff8fe2c1047ac8 R11: 0000000000000000 R12: 0000000000000000
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000100
      FS:  00007fe80eff6b68(0000) GS:ffff8fe339c00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007fe80eec7bc0 CR3: 0000000038012000 CR4: 00000000000006f0
      Call Trace:
       __free_fdtable+0x16/0x1f
       put_files_struct+0x81/0x9b
       do_exit+0x433/0x94d
       do_group_exit+0xa6/0xa6
       __x64_sys_exit_group+0xf/0xf
       do_syscall_64+0x33/0x40
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      RIP: 0033:0x7fe80ef64bea
      Code: Unable to access opcode bytes at RIP 0x7fe80ef64bc0.
      RSP: 002b:00007ffdb1c47528 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
      RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007fe80ef64bea
      RDX: 00007fe80ef64f60 RSI: 0000000000000000 RDI: 0000000000000000
      RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000000
      R10: 00007fe80ee2c620 R11: 0000000000000246 R12: 00007fe80eff41e0
      R13: 00000000ffffffff R14: 0000000000000024 R15: 00007fe80edf9cd0
      Modules linked in: radeon(+) ath5k(+) snd_hda_codec_realtek ...
      
      Use a valid power_state index when initializing the "flags" and "misc"
      and "misc2" fields.
      
      Bug: https://bugzilla.kernel.org/show_bug.cgi?id=211537
      Reported-by: default avatarErhard F. <erhard_f@mailbox.org>
      Fixes: a48b9b4e ("drm/radeon/kms/pm: add asic specific callbacks for getting power state (v2)")
      Fixes: 79daedc9
      
       ("drm/radeon/kms: minor pm cleanups")
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d241510b
    • Pablo Neira Ayuso's avatar
      netfilter: xt_SECMARK: add new revision to fix structure layout · 20bff2f8
      Pablo Neira Ayuso authored
      [ Upstream commit c7d13358 ]
      
      This extension breaks when trying to delete rules, add a new revision to
      fix this.
      
      Fixes: 5e6874cd
      
       ("[SECMARK]: Add xtables SECMARK target")
      Signed-off-by: default avatarPhil Sutter <phil@nwl.cc>
      Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      20bff2f8
    • Xin Long's avatar
      sctp: fix a SCTP_MIB_CURRESTAB leak in sctp_sf_do_dupcook_b · 80ff0060
      Xin Long authored
      [ Upstream commit f282df03 ]
      
      Normally SCTP_MIB_CURRESTAB is always incremented once asoc enter into
      ESTABLISHED from the state < ESTABLISHED and decremented when the asoc
      is being deleted.
      
      However, in sctp_sf_do_dupcook_b(), the asoc's state can be changed to
      ESTABLISHED from the state >= ESTABLISHED where it shouldn't increment
      SCTP_MIB_CURRESTAB. Otherwise, one asoc may increment MIB_CURRESTAB
      multiple times but only decrement once at the end.
      
      I was able to reproduce it by using scapy to do the 4-way shakehands,
      after that I replayed the COOKIE-ECHO chunk with 'peer_vtag' field
      changed to different values, and SCTP_MIB_CURRESTAB was incremented
      multiple times and never went back to 0 even when the asoc was freed.
      
      This patch is to fix it by only incrementing SCTP_MIB_CURRESTAB when
      the state < ESTABLISHED in sctp_sf_do_dupcook_b().
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Reported-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      80ff0060
    • Lv Yunlong's avatar
      ethernet:enic: Fix a use after free bug in enic_hard_start_xmit · 25a87b1f
      Lv Yunlong authored
      [ Upstream commit 643001b4 ]
      
      In enic_hard_start_xmit, it calls enic_queue_wq_skb(). Inside
      enic_queue_wq_skb, if some error happens, the skb will be freed
      by dev_kfree_skb(skb). But the freed skb is still used in
      skb_tx_timestamp(skb).
      
      My patch makes enic_queue_wq_skb() return error and goto spin_unlock()
      incase of error. The solution is provided by Govind.
      See https://lkml.org/lkml/2021/4/30/961.
      
      Fixes: fb7516d4
      
       ("enic: add sw timestamp support")
      Signed-off-by: default avatarLv Yunlong <lyl2019@mail.ustc.edu.cn>
      Acked-by: default avatarGovindarajulu Varadarajan <gvaradar@cisco.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      25a87b1f
    • Xin Long's avatar
      sctp: do asoc update earlier in sctp_sf_do_dupcook_a · d624f299
      Xin Long authored
      [ Upstream commit 35b4f244 ]
      
      There's a panic that occurs in a few of envs, the call trace is as below:
      
        [] general protection fault, ... 0x29acd70f1000a: 0000 [#1] SMP PTI
        [] RIP: 0010:sctp_ulpevent_notify_peer_addr_change+0x4b/0x1fa [sctp]
        []  sctp_assoc_control_transport+0x1b9/0x210 [sctp]
        []  sctp_do_8_2_transport_strike.isra.16+0x15c/0x220 [sctp]
        []  sctp_cmd_interpreter.isra.21+0x1231/0x1a10 [sctp]
        []  sctp_do_sm+0xc3/0x2a0 [sctp]
        []  sctp_generate_timeout_event+0x81/0xf0 [sctp]
      
      This is caused by a transport use-after-free issue. When processing a
      duplicate COOKIE-ECHO chunk in sctp_sf_do_dupcook_a(), both COOKIE-ACK
      and SHUTDOWN chunks are allocated with the transort from the new asoc.
      However, later in the sideeffect machine, the old asoc is used to send
      them out and old asoc's shutdown_last_sent_to is set to the transport
      that SHUTDOWN chunk attached to in sctp_cmd_setup_t2(), which actually
      belongs to the new asoc. After the new_asoc is freed and the old asoc
      T2 timeout, the old asoc's shutdown_last_sent_to that is already freed
      would be accessed in sctp_sf_t2_timer_expire().
      
      Thanks Alexander and Jere for helping dig into this issue.
      
      To fix it, this patch is to do the asoc update first, then allocate
      the COOKIE-ACK and SHUTDOWN chunks with the 'updated' old asoc. This
      would make more sense, as a chunk from an asoc shouldn't be sent out
      with another asoc. We had fixed quite a few issues caused by this.
      
      Fixes: 145cb2f7
      
       ("sctp: Fix bundling of SHUTDOWN with COOKIE-ACK")
      Reported-by: default avatarAlexander Sverdlin <alexander.sverdlin@nokia.com>
      Reported-by: default avatar <syzbot+bbe538efd1046586f587@syzkaller.appspotmail.com>
      Reported-by: default avatarMichal Tesar <mtesar@redhat.com>
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d624f299
    • Yufeng Mo's avatar
      net: hns3: disable phy loopback setting in hclge_mac_start_phy · 2b5f418f
      Yufeng Mo authored
      [ Upstream commit 472497d0 ]
      
      If selftest and reset are performed at the same time, the phy
      loopback setting may be still in enable state after the reset,
      and device cannot link up. So fix this issue by disabling phy
      loopback before phy_start().
      
      Fixes: 256727da
      
       ("net: hns3: Add MDIO support to HNS3 Ethernet driver for hip08 SoC")
      Signed-off-by: default avatarYufeng Mo <moyufeng@huawei.com>
      Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2b5f418f
    • Nobuhiro Iwamatsu's avatar
      rtc: ds1307: Fix wday settings for rx8130 · 76c0f76b
      Nobuhiro Iwamatsu authored
      [ Upstream commit 204756f0 ]
      
      rx8130 wday specifies the bit position, not BCD.
      
      Fixes: ee0981be
      
       ("rtc: ds1307: Add support for Epson RX8130CE")
      Signed-off-by: default avatarNobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>
      Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
      Link: https://lore.kernel.org/r/20210420023917.1949066-1-nobuhiro1.iwamatsu@toshiba.co.jp
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      76c0f76b
    • Olga Kornievskaia's avatar
      NFSv4.2 fix handling of sr_eof in SEEK's reply · 28a55a8a
      Olga Kornievskaia authored
      [ Upstream commit 73f5c88f ]
      
      Currently the client ignores the value of the sr_eof of the SEEK
      operation. According to the spec, if the server didn't find the
      requested extent and reached the end of the file, the server
      would return sr_eof=true. In case the request for DATA and no
      data was found (ie in the middle of the hole), then the lseek
      expects that ENXIO would be returned.
      
      Fixes: 1c6dcbe5
      
       ("NFS: Implement SEEK")
      Signed-off-by: default avatarOlga Kornievskaia <kolga@netapp.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      28a55a8a
    • Nikola Livic's avatar
      pNFS/flexfiles: fix incorrect size check in decode_nfs_fh() · f27638a9
      Nikola Livic authored
      [ Upstream commit ed34695e ]
      
      We (adam zabrocki, alexander matrosov, alexander tereshkin, maksym
      bazalii) observed the check:
      
      	if (fh->size > sizeof(struct nfs_fh))
      
      should not use the size of the nfs_fh struct which includes an extra two
      bytes from the size field.
      
      struct nfs_fh {
      	unsigned short         size;
      	unsigned char          data[NFS_MAXFHSIZE];
      }
      
      but should determine the size from data[NFS_MAXFHSIZE] so the memcpy
      will not write 2 bytes beyond destination.  The proposed fix is to
      compare against the NFS_MAXFHSIZE directly, as is done elsewhere in fs
      code base.
      
      Fixes: d67ae825
      
       ("pnfs/flexfiles: Add the FlexFile Layout Driver")
      Signed-off-by: default avatarNikola Livic <nlivic@gmail.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f27638a9
    • Yang Yingliang's avatar
      PCI: endpoint: Fix missing destroy_workqueue() · fb787dcb
      Yang Yingliang authored
      [ Upstream commit acaef798 ]
      
      Add the missing destroy_workqueue() before return from
      pci_epf_test_init() in the error handling case and add
      destroy_workqueue() in pci_epf_test_exit().
      
      Link: https://lore.kernel.org/r/20210331084012.2091010-1-yangyingliang@huawei.com
      Fixes: 349e7a85
      
       ("PCI: endpoint: functions: Add an EP function to test PCI")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fb787dcb
    • Trond Myklebust's avatar
      NFS: Deal correctly with attribute generation counter overflow · e6681459
      Trond Myklebust authored
      [ Upstream commit 9fdbfad1 ]
      
      We need to use unsigned long subtraction and then convert to signed in
      order to deal correcly with C overflow rules.
      
      Fixes: f5062003
      
       ("NFS: Set an attribute barrier on all updates")
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e6681459
    • Trond Myklebust's avatar
      NFSv4.2: Always flush out writes in nfs42_proc_fallocate() · e5370bd9
      Trond Myklebust authored
      [ Upstream commit 99f23783 ]
      
      Whether we're allocating or delallocating space, we should flush out the
      pending writes in order to avoid races with attribute updates.
      
      Fixes: 1e564d3d
      
       ("NFSv4.2: Fix a race in nfs42_proc_deallocate()")
      Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e5370bd9
    • Jia-Ju Bai's avatar
      rpmsg: qcom_glink_native: fix error return code of qcom_glink_rx_data() · 85b1a9c3
      Jia-Ju Bai authored
      [ Upstream commit 26594c6b ]
      
      When idr_find() returns NULL to intent, no error return code of
      qcom_glink_rx_data() is assigned.
      To fix this bug, ret is assigned with -ENOENT in this case.
      
      Fixes: 64f95f87
      
       ("rpmsg: glink: Use the local intents when receiving data")
      Reported-by: default avatarTOTE Robot <oslab@tsinghua.edu.cn>
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Link: https://lore.kernel.org/r/20210306133624.17237-1-baijiaju1990@gmail.com
      Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      85b1a9c3
    • Zhen Lei's avatar
      ARM: 9064/1: hw_breakpoint: Do not directly check the event's overflow_handler hook · a9938d6d
      Zhen Lei authored
      [ Upstream commit a506bd57 ]
      
      The commit 1879445d ("perf/core: Set event's default
      ::overflow_handler()") set a default event->overflow_handler in
      perf_event_alloc(), and replace the check event->overflow_handler with
      is_default_overflow_handler(), but one is missing.
      
      Currently, the bp->overflow_handler can not be NULL. As a result,
      enable_single_step() is always not invoked.
      
      Comments from Zhen Lei:
      
       https://patchwork.kernel.org/project/linux-arm-kernel/patch/20210207105934.2001-1-thunder.leizhen@huawei.com/
      
      Fixes: 1879445d
      
       ("perf/core: Set event's default ::overflow_handler()")
      Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Acked-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a9938d6d
    • Dmitry Baryshkov's avatar
      PCI: Release OF node in pci_scan_device()'s error path · 691062fe
      Dmitry Baryshkov authored
      [ Upstream commit c99e755a ]
      
      In pci_scan_device(), if pci_setup_device() fails for any reason, the code
      will not release device's of_node by calling pci_release_of_node().  Fix
      that by calling the release function.
      
      Fixes: 98d9f30c
      
       ("pci/of: Match PCI devices to OF nodes dynamically")
      Link: https://lore.kernel.org/r/20210124232826.1879-1-dmitry.baryshkov@linaro.org
      Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      691062fe
    • Pali Rohár's avatar
      PCI: iproc: Fix return value of iproc_msi_irq_domain_alloc() · a243eb7d
      Pali Rohár authored
      [ Upstream commit 1e83130f ]
      
      IRQ domain alloc function should return zero on success. Non-zero value
      indicates failure.
      
      Link: https://lore.kernel.org/r/20210303142202.25780-1-pali@kernel.org
      Fixes: fc54bae2
      
       ("PCI: iproc: Allow allocation of multiple MSIs")
      Signed-off-by: default avatarPali Rohár <pali@kernel.org>
      Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
      Reviewed-by: default avatarKrzysztof Wilczyński <kw@linux.com>
      Acked-by: default avatarRay Jui <ray.jui@broadcom.com>
      Acked-by: default avatarMarc Zyngier <maz@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a243eb7d
    • Colin Ian King's avatar
      f2fs: fix a redundant call to f2fs_balance_fs if an error occurs · b8ee9406
      Colin Ian King authored
      [ Upstream commit 28e18ee6 ]
      
      The  uninitialized variable dn.node_changed does not get set when a
      call to f2fs_get_node_page fails.  This uninitialized value gets used
      in the call to f2fs_balance_fs() that may or not may not balances
      dirty node and dentry pages depending on the uninitialized state of
      the variable. Fix this by only calling f2fs_balance_fs if err is
      not set.
      
      Thanks to Jaegeuk Kim for suggesting an appropriate fix.
      
      Addresses-Coverity: ("Uninitialized scalar variable")
      Fixes: 2a340760
      
       ("f2fs: call f2fs_balance_fs only when node was changed")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b8ee9406
    • David Ward's avatar
      ASoC: rt286: Make RT286_SET_GPIO_* readable and writable · 312a7bac
      David Ward authored
      [ Upstream commit cd8499d5
      
       ]
      
      The GPIO configuration cannot be applied if the registers are inaccessible.
      This prevented the headset mic from working on the Dell XPS 13 9343.
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=114171
      Signed-off-by: default avatarDavid Ward <david.ward@gatech.edu>
      Link: https://lore.kernel.org/r/20210418134658.4333-5-david.ward@gatech.edu
      Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      312a7bac
    • Sergei Trofimovich's avatar
      ia64: module: fix symbolizer crash on fdescr · 0f6a8867
      Sergei Trofimovich authored
      [ Upstream commit 99e729bd
      
       ]
      
      Noticed failure as a crash on ia64 when tried to symbolize all backtraces
      collected by page_owner=on:
      
          $ cat /sys/kernel/debug/page_owner
          <oops>
      
          CPU: 1 PID: 2074 Comm: cat Not tainted 5.12.0-rc4 #226
          Hardware name: hp server rx3600, BIOS 04.03 04/08/2008
          ip is at dereference_module_function_descriptor+0x41/0x100
      
      Crash happens at dereference_module_function_descriptor() due to
      use-after-free when dereferencing ".opd" section header.
      
      All section headers are already freed after module is laoded successfully.
      
      To keep symbolizer working the change stores ".opd" address and size after
      module is relocated to a new place and before section headers are
      discarded.
      
      To make similar errors less obscure module_finalize() now zeroes out all
      variables relevant to module loading only.
      
      Link: https://lkml.kernel.org/r/20210403074803.3309096-1-slyfox@gentoo.org
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.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>
      0f6a8867
    • Felix Fietkau's avatar
      net: ethernet: mtk_eth_soc: fix RX VLAN offload · 65fecc2d
      Felix Fietkau authored
      [ Upstream commit 3f57d8c4
      
       ]
      
      The VLAN ID in the rx descriptor is only valid if the RX_DMA_VTAG bit is
      set. Fixes frames wrongly marked with VLAN tags.
      
      Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
      [Ilya: fix commit message]
      Signed-off-by: default avatarIlya Lipnitskiy <ilya.lipnitskiy@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      65fecc2d
    • Alexey Kardashevskiy's avatar
      powerpc/iommu: Annotate nested lock for lockdep · 2708da3d
      Alexey Kardashevskiy authored
      [ Upstream commit cc7130bf
      
       ]
      
      The IOMMU table is divided into pools for concurrent mappings and each
      pool has a separate spinlock. When taking the ownership of an IOMMU group
      to pass through a device to a VM, we lock these spinlocks which triggers
      a false negative warning in lockdep (below).
      
      This fixes it by annotating the large pool's spinlock as a nest lock
      which makes lockdep not complaining when locking nested locks if
      the nest lock is locked already.
      
      ===
      WARNING: possible recursive locking detected
      5.11.0-le_syzkaller_a+fstn1 #100 Not tainted
      --------------------------------------------
      qemu-system-ppc/4129 is trying to acquire lock:
      c0000000119bddb0 (&(p->lock)/1){....}-{2:2}, at: iommu_take_ownership+0xac/0x1e0
      
      but task is already holding lock:
      c0000000119bdd30 (&(p->lock)/1){....}-{2:2}, at: iommu_take_ownership+0xac/0x1e0
      
      other info that might help us debug this:
       Possible unsafe locking scenario:
      
             CPU0
             ----
        lock(&(p->lock)/1);
        lock(&(p->lock)/1);
      ===
      
      Signed-off-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210301063653.51003-1-aik@ozlabs.ru
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2708da3d
    • Gustavo A. R. Silva's avatar
      wl3501_cs: Fix out-of-bounds warnings in wl3501_mgmt_join · cb821483
      Gustavo A. R. Silva authored
      [ Upstream commit bb43e571
      
       ]
      
      Fix the following out-of-bounds warnings by adding a new structure
      wl3501_req instead of duplicating the same members in structure
      wl3501_join_req and wl3501_scan_confirm:
      
      arch/x86/include/asm/string_32.h:182:25: warning: '__builtin_memcpy' offset [39, 108] from the object at 'sig' is out of the bounds of referenced subobject 'beacon_period' with type 'short unsigned int' at offset 36 [-Warray-bounds]
      arch/x86/include/asm/string_32.h:182:25: warning: '__builtin_memcpy' offset [25, 95] from the object at 'sig' is out of the bounds of referenced subobject 'beacon_period' with type 'short unsigned int' at offset 22 [-Warray-bounds]
      
      Refactor the code, accordingly:
      
      $ pahole -C wl3501_req drivers/net/wireless/wl3501_cs.o
      struct wl3501_req {
              u16                        beacon_period;        /*     0     2 */
              u16                        dtim_period;          /*     2     2 */
              u16                        cap_info;             /*     4     2 */
              u8                         bss_type;             /*     6     1 */
              u8                         bssid[6];             /*     7     6 */
              struct iw_mgmt_essid_pset  ssid;                 /*    13    34 */
              struct iw_mgmt_ds_pset     ds_pset;              /*    47     3 */
              struct iw_mgmt_cf_pset     cf_pset;              /*    50     8 */
              struct iw_mgmt_ibss_pset   ibss_pset;            /*    58     4 */
              struct iw_mgmt_data_rset   bss_basic_rset;       /*    62    10 */
      
              /* size: 72, cachelines: 2, members: 10 */
              /* last cacheline: 8 bytes */
      };
      
      $ pahole -C wl3501_join_req drivers/net/wireless/wl3501_cs.o
      struct wl3501_join_req {
              u16                        next_blk;             /*     0     2 */
              u8                         sig_id;               /*     2     1 */
              u8                         reserved;             /*     3     1 */
              struct iw_mgmt_data_rset   operational_rset;     /*     4    10 */
              u16                        reserved2;            /*    14     2 */
              u16                        timeout;              /*    16     2 */
              u16                        probe_delay;          /*    18     2 */
              u8                         timestamp[8];         /*    20     8 */
              u8                         local_time[8];        /*    28     8 */
              struct wl3501_req          req;                  /*    36    72 */
      
              /* size: 108, cachelines: 2, members: 10 */
              /* last cacheline: 44 bytes */
      };
      
      $ pahole -C wl3501_scan_confirm drivers/net/wireless/wl3501_cs.o
      struct wl3501_scan_confirm {
              u16                        next_blk;             /*     0     2 */
              u8                         sig_id;               /*     2     1 */
              u8                         reserved;             /*     3     1 */
              u16                        status;               /*     4     2 */
              char                       timestamp[8];         /*     6     8 */
              char                       localtime[8];         /*    14     8 */
              struct wl3501_req          req;                  /*    22    72 */
              /* --- cacheline 1 boundary (64 bytes) was 30 bytes ago --- */
              u8                         rssi;                 /*    94     1 */
      
              /* size: 96, cachelines: 2, members: 8 */
              /* padding: 1 */
              /* last cacheline: 32 bytes */
      };
      
      The problem is that the original code is trying to copy data into a
      bunch of struct members adjacent to each other in a single call to
      memcpy(). Now that a new struct wl3501_req enclosing all those adjacent
      members is introduced, memcpy() doesn't overrun the length of
      &sig.beacon_period and &this->bss_set[i].beacon_period, because the
      address of the new struct object _req_ is used as the destination,
      instead.
      
      This helps with the ongoing efforts to globally enable -Warray-bounds
      and get us closer to being able to tighten the FORTIFY_SOURCE routines
      on memcpy().
      
      Link: https://github.com/KSPP/linux/issues/109
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/1fbaf516da763b50edac47d792a9145aa4482e29.1618442265.git.gustavoars@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cb821483
    • Gustavo A. R. Silva's avatar
      wl3501_cs: Fix out-of-bounds warnings in wl3501_send_pkt · 91a2f3c5
      Gustavo A. R. Silva authored
      [ Upstream commit 820aa376
      
       ]
      
      Fix the following out-of-bounds warnings by enclosing structure members
      daddr and saddr into new struct addr, in structures wl3501_md_req and
      wl3501_md_ind:
      
      arch/x86/include/asm/string_32.h:182:25: warning: '__builtin_memcpy' offset [18, 23] from the object at 'sig' is out of the bounds of referenced subobject 'daddr' with type 'u8[6]' {aka 'unsigned char[6]'} at offset 11 [-Warray-bounds]
      arch/x86/include/asm/string_32.h:182:25: warning: '__builtin_memcpy' offset [18, 23] from the object at 'sig' is out of the bounds of referenced subobject 'daddr' with type 'u8[6]' {aka 'unsigned char[6]'} at offset 11 [-Warray-bounds]
      
      Refactor the code, accordingly:
      
      $ pahole -C wl3501_md_req drivers/net/wireless/wl3501_cs.o
      struct wl3501_md_req {
      	u16                        next_blk;             /*     0     2 */
      	u8                         sig_id;               /*     2     1 */
      	u8                         routing;              /*     3     1 */
      	u16                        data;                 /*     4     2 */
      	u16                        size;                 /*     6     2 */
      	u8                         pri;                  /*     8     1 */
      	u8                         service_class;        /*     9     1 */
      	struct {
      		u8                 daddr[6];             /*    10     6 */
      		u8                 saddr[6];             /*    16     6 */
      	} addr;                                          /*    10    12 */
      
      	/* size: 22, cachelines: 1, members: 8 */
      	/* last cacheline: 22 bytes */
      };
      
      $ pahole -C wl3501_md_ind drivers/net/wireless/wl3501_cs.o
      struct wl3501_md_ind {
      	u16                        next_blk;             /*     0     2 */
      	u8                         sig_id;               /*     2     1 */
      	u8                         routing;              /*     3     1 */
      	u16                        data;                 /*     4     2 */
      	u16                        size;                 /*     6     2 */
      	u8                         reception;            /*     8     1 */
      	u8                         pri;                  /*     9     1 */
      	u8                         service_class;        /*    10     1 */
      	struct {
      		u8                 daddr[6];             /*    11     6 */
      		u8                 saddr[6];             /*    17     6 */
      	} addr;                                          /*    11    12 */
      
      	/* size: 24, cachelines: 1, members: 9 */
      	/* padding: 1 */
      	/* last cacheline: 24 bytes */
      };
      
      The problem is that the original code is trying to copy data into a
      couple of arrays adjacent to each other in a single call to memcpy().
      Now that a new struct _addr_ enclosing those two adjacent arrays
      is introduced, memcpy() doesn't overrun the length of &sig.daddr[0]
      and &sig.daddr, because the address of the new struct object _addr_
      is used, instead.
      
      This helps with the ongoing efforts to globally enable -Warray-bounds
      and get us closer to being able to tighten the FORTIFY_SOURCE routines
      on memcpy().
      
      Link: https://github.com/KSPP/linux/issues/109
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
      Link: https://lore.kernel.org/r/d260fe56aed7112bff2be5b4d152d03ad7b78e78.1618442265.git.gustavoars@kernel.org
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      91a2f3c5
    • Michael Ellerman's avatar
      powerpc/pseries: Stop calling printk in rtas_stop_self() · 8e3bd088
      Michael Ellerman authored
      [ Upstream commit ed8029d7
      
       ]
      
      RCU complains about us calling printk() from an offline CPU:
      
        =============================
        WARNING: suspicious RCU usage
        5.12.0-rc7-02874-g7cf90e481cb8 #1 Not tainted
        -----------------------------
        kernel/locking/lockdep.c:3568 RCU-list traversed in non-reader section!!
      
        other info that might help us debug this:
      
        RCU used illegally from offline CPU!
        rcu_scheduler_active = 2, debug_locks = 1
        no locks held by swapper/0/0.
      
        stack backtrace:
        CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.12.0-rc7-02874-g7cf90e481cb8 #1
        Call Trace:
          dump_stack+0xec/0x144 (unreliable)
          lockdep_rcu_suspicious+0x124/0x144
          __lock_acquire+0x1098/0x28b0
          lock_acquire+0x128/0x600
          _raw_spin_lock_irqsave+0x6c/0xc0
          down_trylock+0x2c/0x70
          __down_trylock_console_sem+0x60/0x140
          vprintk_emit+0x1a8/0x4b0
          vprintk_func+0xcc/0x200
          printk+0x40/0x54
          pseries_cpu_offline_self+0xc0/0x120
          arch_cpu_idle_dead+0x54/0x70
          do_idle+0x174/0x4a0
          cpu_startup_entry+0x38/0x40
          rest_init+0x268/0x388
          start_kernel+0x748/0x790
          start_here_common+0x1c/0x614
      
      Which happens because by the time we get to rtas_stop_self() we are
      already offline. In addition the message can be spammy, and is not that
      helpful for users, so remove it.
      
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210418135413.1204031-1-mpe@ellerman.id.au
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8e3bd088
    • Yaqi Chen's avatar
      samples/bpf: Fix broken tracex1 due to kprobe argument change · adf112b5
      Yaqi Chen authored
      [ Upstream commit 137733d0 ]
      
      >From commit c0bbbdc3
      
       ("__netif_receive_skb_core: pass skb by
      reference"), the first argument passed into __netif_receive_skb_core
      has changed to reference of a skb pointer.
      
      This commit fixes by using bpf_probe_read_kernel.
      
      Signed-off-by: default avatarYaqi Chen <chendotjs@gmail.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarYonghong Song <yhs@fb.com>
      Link: https://lore.kernel.org/bpf/20210416154803.37157-1-chendotjs@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      adf112b5
    • Gustavo A. R. Silva's avatar
      ethtool: ioctl: Fix out-of-bounds warning in store_link_ksettings_for_user() · b1352870
      Gustavo A. R. Silva authored
      [ Upstream commit c1d9e34e
      
       ]
      
      Fix the following out-of-bounds warning:
      
      net/ethtool/ioctl.c:492:2: warning: 'memcpy' offset [49, 84] from the object at 'link_usettings' is out of the bounds of referenced subobject 'base' with type 'struct ethtool_link_settings' at offset 0 [-Warray-bounds]
      
      The problem is that the original code is trying to copy data into a
      some struct members adjacent to each other in a single call to
      memcpy(). This causes a legitimate compiler warning because memcpy()
      overruns the length of &link_usettings.base. Fix this by directly
      using &link_usettings and _from_ as destination and source addresses,
      instead.
      
      This helps with the ongoing efforts to globally enable -Warray-bounds
      and get us closer to being able to tighten the FORTIFY_SOURCE routines
      on memcpy().
      
      Link: https://github.com/KSPP/linux/issues/109
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b1352870
    • David Ward's avatar
      ASoC: rt286: Generalize support for ALC3263 codec · 562bf0db
      David Ward authored
      [ Upstream commit aa2f9c12
      
       ]
      
      The ALC3263 codec on the XPS 13 9343 is also found on the Latitude 13 7350
      and Venue 11 Pro 7140. They require the same handling for the combo jack to
      work with a headset: GPIO pin 6 must be set.
      
      The HDA driver always sets this pin on the ALC3263, which it distinguishes
      by the codec vendor/device ID 0x10ec0288 and PCI subsystem vendor ID 0x1028
      (Dell). The ASoC driver does not use PCI, so adapt this check to use DMI to
      determine if Dell is the system vendor.
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=150601
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=205961
      Signed-off-by: default avatarDavid Ward <david.ward@gatech.edu>
      Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/20210418134658.4333-6-david.ward@gatech.edu
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      562bf0db
    • Srikar Dronamraju's avatar
      powerpc/smp: Set numa node before updating mask · efeb91f6
      Srikar Dronamraju authored
      [ Upstream commit 6980d13f
      
       ]
      
      Geethika reported a trace when doing a dlpar CPU add.
      
      ------------[ cut here ]------------
      WARNING: CPU: 152 PID: 1134 at kernel/sched/topology.c:2057
      CPU: 152 PID: 1134 Comm: kworker/152:1 Not tainted 5.12.0-rc5-master #5
      Workqueue: events cpuset_hotplug_workfn
      NIP:  c0000000001cfc14 LR: c0000000001cfc10 CTR: c0000000007e3420
      REGS: c0000034a08eb260 TRAP: 0700   Not tainted  (5.12.0-rc5-master+)
      MSR:  8000000000029033 <SF,EE,ME,IR,DR,RI,LE>  CR: 28828422  XER: 00000020
      CFAR: c0000000001fd888 IRQMASK: 0 #012GPR00: c0000000001cfc10
      c0000034a08eb500 c000000001f35400 0000000000000027 #012GPR04:
      c0000035abaa8010 c0000035abb30a00 0000000000000027 c0000035abaa8018
      #012GPR08: 0000000000000023 c0000035abaaef48 00000035aa540000
      c0000035a49dffe8 #012GPR12: 0000000028828424 c0000035bf1a1c80
      0000000000000497 0000000000000004 #012GPR16: c00000000347a258
      0000000000000140 c00000000203d468 c000000001a1a490 #012GPR20:
      c000000001f9c160 c0000034adf70920 c0000034aec9fd20 0000000100087bd3
      #012GPR24: 0000000100087bd3 c0000035b3de09f8 0000000000000030
      c0000035b3de09f8 #012GPR28: 0000000000000028 c00000000347a280
      c0000034aefe0b00 c0000000010a2a68
      NIP [c0000000001cfc14] build_sched_domains+0x6a4/0x1500
      LR [c0000000001cfc10] build_sched_domains+0x6a0/0x1500
      Call Trace:
      [c0000034a08eb500] [c0000000001cfc10] build_sched_domains+0x6a0/0x1500 (unreliable)
      [c0000034a08eb640] [c0000000001d1e6c] partition_sched_domains_locked+0x3ec/0x530
      [c0000034a08eb6e0] [c0000000002936d4] rebuild_sched_domains_locked+0x524/0xbf0
      [c0000034a08eb7e0] [c000000000296bb0] rebuild_sched_domains+0x40/0x70
      [c0000034a08eb810] [c000000000296e74] cpuset_hotplug_workfn+0x294/0xe20
      [c0000034a08ebc30] [c000000000178dd0] process_one_work+0x300/0x670
      [c0000034a08ebd10] [c0000000001791b8] worker_thread+0x78/0x520
      [c0000034a08ebda0] [c000000000185090] kthread+0x1a0/0x1b0
      [c0000034a08ebe10] [c00000000000ccec] ret_from_kernel_thread+0x5c/0x70
      Instruction dump:
      7d2903a6 4e800421 e8410018 7f67db78 7fe6fb78 7f45d378 7f84e378 7c681b78
      3c62ff1a 3863c6f8 4802dc35 60000000 <0fe00000> 3920fff4 f9210070 e86100a0
      ---[ end trace 532d9066d3d4d7ec ]---
      
      Some of the per-CPU masks use cpu_cpu_mask as a filter to limit the search
      for related CPUs. On a dlpar add of a CPU, update cpu_cpu_mask before
      updating the per-CPU masks. This will ensure the cpu_cpu_mask is updated
      correctly before its used in setting the masks. Setting the numa_node will
      ensure that when cpu_cpu_mask() gets called, the correct node number is
      used. This code movement helped fix the above call trace.
      
      Reported-by: default avatarGeetika Moolchandani <Geetika.Moolchandani1@ibm.com>
      Signed-off-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      Reviewed-by: default avatarNathan Lynch <nathanl@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210401154200.150077-1-srikar@linux.vnet.ibm.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      efeb91f6
    • Gustavo A. R. Silva's avatar
      sctp: Fix out-of-bounds warning in sctp_process_asconf_param() · b51e7468
      Gustavo A. R. Silva authored
      [ Upstream commit e5272ad4
      
       ]
      
      Fix the following out-of-bounds warning:
      
      net/sctp/sm_make_chunk.c:3150:4: warning: 'memcpy' offset [17, 28] from the object at 'addr' is out of the bounds of referenced subobject 'v4' with type 'struct sockaddr_in' at offset 0 [-Warray-bounds]
      
      This helps with the ongoing efforts to globally enable -Warray-bounds
      and get us closer to being able to tighten the FORTIFY_SOURCE routines
      on memcpy().
      
      Link: https://github.com/KSPP/linux/issues/109
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b51e7468
    • Mihai Moldovan's avatar
      kconfig: nconf: stop endless search loops · 4b35fe92
      Mihai Moldovan authored
      [ Upstream commit 8c94b430
      
       ]
      
      If the user selects the very first entry in a page and performs a
      search-up operation, or selects the very last entry in a page and
      performs a search-down operation that will not succeed (e.g., via
      [/]asdfzzz[Up Arrow]), nconf will never terminate searching the page.
      
      The reason is that in this case, the starting point will be set to -1
      or n, which is then translated into (n - 1) (i.e., the last entry of
      the page) or 0 (i.e., the first entry of the page) and finally the
      search begins. This continues to work fine until the index reaches 0 or
      (n - 1), at which point it will be decremented to -1 or incremented to
      n, but not checked against the starting point right away. Instead, it's
      wrapped around to the bottom or top again, after which the starting
      point check occurs... and naturally fails.
      
      My original implementation added another check for -1 before wrapping
      the running index variable around, but Masahiro Yamada pointed out that
      the actual issue is that the comparison point (starting point) exceeds
      bounds (i.e., the [0,n-1] interval) in the first place and that,
      instead, the starting point should be fixed.
      
      This has the welcome side-effect of also fixing the case where the
      starting point was n while searching down, which also lead to an
      infinite loop.
      
      OTOH, this code is now essentially all his work.
      
      Amazingly, nobody seems to have been hit by this for 11 years - or at
      the very least nobody bothered to debug and fix this.
      
      Signed-off-by: default avatarMihai Moldovan <ionic@ionic.de>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4b35fe92
    • Yonghong Song's avatar
      selftests: Set CC to clang in lib.mk if LLVM is set · b9ef1725
      Yonghong Song authored
      [ Upstream commit 26e6dd10
      
       ]
      
      selftests/bpf/Makefile includes lib.mk. With the following command
        make -j60 LLVM=1 LLVM_IAS=1  <=== compile kernel
        make -j60 -C tools/testing/selftests/bpf LLVM=1 LLVM_IAS=1 V=1
      some files are still compiled with gcc. This patch
      fixed lib.mk issue which sets CC to gcc in all cases.
      
      Signed-off-by: default avatarYonghong Song <yhs@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210413153413.3027426-1-yhs@fb.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b9ef1725
    • Miklos Szeredi's avatar
      cuse: prevent clone · 2bb2ff46
      Miklos Szeredi authored
      [ Upstream commit 8217673d
      
       ]
      
      For cloned connections cuse_channel_release() will be called more than
      once, resulting in use after free.
      
      Prevent device cloning for CUSE, which does not make sense at this point,
      and highly unlikely to be used in real life.
      
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2bb2ff46
    • Krzysztof Kozlowski's avatar
      pinctrl: samsung: use 'int' for register masks in Exynos · 2a87966b
      Krzysztof Kozlowski authored
      [ Upstream commit fa0c10a5
      
       ]
      
      The Special Function Registers on all Exynos SoC, including ARM64, are
      32-bit wide, so entire driver uses matching functions like readl() or
      writel().  On 64-bit ARM using unsigned long for register masks:
      1. makes little sense as immediately after bitwise operation it will be
         cast to 32-bit value when calling writel(),
      2. is actually error-prone because it might promote other operands to
         64-bit.
      
      Addresses-Coverity: Unintentional integer overflow
      Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
      Reviewed-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
      Link: https://lore.kernel.org/r/20210408195029.69974-1-krzysztof.kozlowski@canonical.com
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2a87966b