Skip to content
Snippets Groups Projects
  1. Apr 01, 2021
  2. Mar 29, 2021
    • Liu Shixin's avatar
      mm/vmscan: fix uncleaned mem_cgroup_uncharge · edc25b11
      Liu Shixin authored
      hulk inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I3CG47
      
      
      CVE: NA
      
      -------------------------------------------------
      
      Patch a222f341 ("mm: generalize putback scan functions") has combined
      move_active_pages_to_lru() and putback_inactive_pages() into single move_pages_to_lru().
      But we didn't backport this patch so move_active_pages_to_lru() is still existed.
      When We moved mem_cgroup_uncharge() in 7ae88534 ("mm: move mem_cgroup_uncharge
      out of __page_cache_release()"), move_active_pages_to_lru() should be changed together.
      
      Fixes: 7ae88534 ("mm: move mem_cgroup_uncharge out of __page_cache_release()")
      Signed-off-by: default avatarLiu Shixin <liushixin2@huawei.com>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
    • Dan Carpenter's avatar
      staging: rtl8188eu: prevent ->ssid overflow in rtw_wx_set_scan() · a932847b
      Dan Carpenter authored
      
      stable inclusion
      from linux-4.19.181
      commit eda4378094de16090d74eacea3d8c10f7719ed25
      CVE: CVE-2021-28660
      
      --------------------------------
      
      commit 74b6b20df8cfe90ada777d621b54c32e69e27cd7 upstream.
      
      This code has a check to prevent read overflow but it needs another
      check to prevent writing beyond the end of the ->ssid[] array.
      
      Fixes: a2c60d42 ("staging: r8188eu: Add files for new driver - part 16")
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/YEHymwsnHewzoam7@mwanda
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      a932847b
    • Tyrel Datwyler's avatar
      PCI: rpadlpar: Fix potential drc_name corruption in store functions · b591ac38
      Tyrel Datwyler authored
      
      stable inclusion
      from linux-4.19.183
      commit f27a00f0d5b0646a52633e98f5fc3ef719004dcd
      CVE: CVE-2021-28972
      
      --------------------------------
      
      commit cc7a0bb058b85ea03db87169c60c7cfdd5d34678 upstream.
      
      Both add_slot_store() and remove_slot_store() try to fix up the
      drc_name copied from the store buffer by placing a NUL terminator at
      nbyte + 1 or in place of a '\n' if present. However, the static buffer
      that we copy the drc_name data into is not zeroed and can contain
      anything past the n-th byte.
      
      This is problematic if a '\n' byte appears in that buffer after nbytes
      and the string copied into the store buffer was not NUL terminated to
      start with as the strchr() search for a '\n' byte will mark this
      incorrectly as the end of the drc_name string resulting in a drc_name
      string that contains garbage data after the n-th byte.
      
      Additionally it will cause us to overwrite that '\n' byte on the stack
      with NUL, potentially corrupting data on the stack.
      
      The following debugging shows an example of the drmgr utility writing
      "PHB 4543" to the add_slot sysfs attribute, but add_slot_store()
      logging a corrupted string value.
      
        drmgr: drmgr: -c phb -a -s PHB 4543 -d 1
        add_slot_store: drc_name = PHB 4543°|<82>!, rc = -19
      
      Fix this by using strscpy() instead of memcpy() to ensure the string
      is NUL terminated when copied into the static drc_name buffer.
      Further, since the string is now NUL terminated the code only needs to
      change '\n' to '\0' when present.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarTyrel Datwyler <tyreld@linux.ibm.com>
      [mpe: Reformat change log and add mention of possible stack corruption]
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210315214821.452959-1-tyreld@linux.ibm.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Reviewed-by: default avatarXiongfeng Wang <wangxiongfeng2@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      b591ac38
    • Kan Liang's avatar
      perf/x86/intel: Fix a crash caused by zero PEBS status · 1602e62b
      Kan Liang authored
      stable inclusion
      from linux-4.19.183
      commit b35214c541365c7dd7c9d5f44a02b0633a1cc83f
      CVE: CVE-2021-28971
      
      --------------------------------
      
      commit d88d05a9e0b6d9356e97129d4ff9942d765f46ea upstream.
      
      A repeatable crash can be triggered by the perf_fuzzer on some Haswell
      system.
      https://lore.kernel.org/lkml/7170d3b-c17f-1ded-52aa-cc6d9ae999f4@maine.edu/
      
      
      
      For some old CPUs (HSW and earlier), the PEBS status in a PEBS record
      may be mistakenly set to 0. To minimize the impact of the defect, the
      commit was introduced to try to avoid dropping the PEBS record for some
      cases. It adds a check in the intel_pmu_drain_pebs_nhm(), and updates
      the local pebs_status accordingly. However, it doesn't correct the PEBS
      status in the PEBS record, which may trigger the crash, especially for
      the large PEBS.
      
      It's possible that all the PEBS records in a large PEBS have the PEBS
      status 0. If so, the first get_next_pebs_record_by_bit() in the
      __intel_pmu_pebs_event() returns NULL. The at = NULL. Since it's a large
      PEBS, the 'count' parameter must > 1. The second
      get_next_pebs_record_by_bit() will crash.
      
      Besides the local pebs_status, correct the PEBS status in the PEBS
      record as well.
      
      Fixes: 01330d72 ("perf/x86: Allow zero PEBS status with only single active event")
      Reported-by: default avatarVince Weaver <vincent.weaver@maine.edu>
      Suggested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/1615555298-140216-1-git-send-email-kan.liang@linux.intel.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Reviewed-by: default avatarJian Cheng <cj.chengjian@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      1602e62b
    • Filipe Manana's avatar
      btrfs: fix race when cloning extent buffer during rewind of an old root · 311dd851
      Filipe Manana authored
      
      stable inclusion
      from linux-4.19.183
      commit 12dc6889bcff1bc2921a1587afca55ca4091b73e
      CVE: CVE-2021-28964
      
      --------------------------------
      
      commit dbcc7d57bffc0c8cac9dac11bec548597d59a6a5 upstream.
      
      While resolving backreferences, as part of a logical ino ioctl call or
      fiemap, we can end up hitting a BUG_ON() when replaying tree mod log
      operations of a root, triggering a stack trace like the following:
      
        ------------[ cut here ]------------
        kernel BUG at fs/btrfs/ctree.c:1210!
        invalid opcode: 0000 [#1] SMP KASAN PTI
        CPU: 1 PID: 19054 Comm: crawl_335 Tainted: G        W         5.11.0-2d11c0084b02-misc-next+ #89
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-1 04/01/2014
        RIP: 0010:__tree_mod_log_rewind+0x3b1/0x3c0
        Code: 05 48 8d 74 10 (...)
        RSP: 0018:ffffc90001eb70b8 EFLAGS: 00010297
        RAX: 0000000000000000 RBX: ffff88812344e400 RCX: ffffffffb28933b6
        RDX: 0000000000000007 RSI: dffffc0000000000 RDI: ffff88812344e42c
        RBP: ffffc90001eb7108 R08: 1ffff11020b60a20 R09: ffffed1020b60a20
        R10: ffff888105b050f9 R11: ffffed1020b60a1f R12: 00000000000000ee
        R13: ffff8880195520c0 R14: ffff8881bc958500 R15: ffff88812344e42c
        FS:  00007fd1955e8700(0000) GS:ffff8881f5600000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007efdb7928718 CR3: 000000010103a006 CR4: 0000000000170ee0
        Call Trace:
         btrfs_search_old_slot+0x265/0x10d0
         ? lock_acquired+0xbb/0x600
         ? btrfs_search_slot+0x1090/0x1090
         ? free_extent_buffer.part.61+0xd7/0x140
         ? free_extent_buffer+0x13/0x20
         resolve_indirect_refs+0x3e9/0xfc0
         ? lock_downgrade+0x3d0/0x3d0
         ? __kasan_check_read+0x11/0x20
         ? add_prelim_ref.part.11+0x150/0x150
         ? lock_downgrade+0x3d0/0x3d0
         ? __kasan_check_read+0x11/0x20
         ? lock_acquired+0xbb/0x600
         ? __kasan_check_write+0x14/0x20
         ? do_raw_spin_unlock+0xa8/0x140
         ? rb_insert_color+0x30/0x360
         ? prelim_ref_insert+0x12d/0x430
         find_parent_nodes+0x5c3/0x1830
         ? resolve_indirect_refs+0xfc0/0xfc0
         ? lock_release+0xc8/0x620
         ? fs_reclaim_acquire+0x67/0xf0
         ? lock_acquire+0xc7/0x510
         ? lock_downgrade+0x3d0/0x3d0
         ? lockdep_hardirqs_on_prepare+0x160/0x210
         ? lock_release+0xc8/0x620
         ? fs_reclaim_acquire+0x67/0xf0
         ? lock_acquire+0xc7/0x510
         ? poison_range+0x38/0x40
         ? unpoison_range+0x14/0x40
         ? trace_hardirqs_on+0x55/0x120
         btrfs_find_all_roots_safe+0x142/0x1e0
         ? find_parent_nodes+0x1830/0x1830
         ? btrfs_inode_flags_to_xflags+0x50/0x50
         iterate_extent_inodes+0x20e/0x580
         ? tree_backref_for_extent+0x230/0x230
         ? lock_downgrade+0x3d0/0x3d0
         ? read_extent_buffer+0xdd/0x110
         ? lock_downgrade+0x3d0/0x3d0
         ? __kasan_check_read+0x11/0x20
         ? lock_acquired+0xbb/0x600
         ? __kasan_check_write+0x14/0x20
         ? _raw_spin_unlock+0x22/0x30
         ? __kasan_check_write+0x14/0x20
         iterate_inodes_from_logical+0x129/0x170
         ? iterate_inodes_from_logical+0x129/0x170
         ? btrfs_inode_flags_to_xflags+0x50/0x50
         ? iterate_extent_inodes+0x580/0x580
         ? __vmalloc_node+0x92/0xb0
         ? init_data_container+0x34/0xb0
         ? init_data_container+0x34/0xb0
         ? kvmalloc_node+0x60/0x80
         btrfs_ioctl_logical_to_ino+0x158/0x230
         btrfs_ioctl+0x205e/0x4040
         ? __might_sleep+0x71/0xe0
         ? btrfs_ioctl_get_supported_features+0x30/0x30
         ? getrusage+0x4b6/0x9c0
         ? __kasan_check_read+0x11/0x20
         ? lock_release+0xc8/0x620
         ? __might_fault+0x64/0xd0
         ? lock_acquire+0xc7/0x510
         ? lock_downgrade+0x3d0/0x3d0
         ? lockdep_hardirqs_on_prepare+0x210/0x210
         ? lockdep_hardirqs_on_prepare+0x210/0x210
         ? __kasan_check_read+0x11/0x20
         ? do_vfs_ioctl+0xfc/0x9d0
         ? ioctl_file_clone+0xe0/0xe0
         ? lock_downgrade+0x3d0/0x3d0
         ? lockdep_hardirqs_on_prepare+0x210/0x210
         ? __kasan_check_read+0x11/0x20
         ? lock_release+0xc8/0x620
         ? __task_pid_nr_ns+0xd3/0x250
         ? lock_acquire+0xc7/0x510
         ? __fget_files+0x160/0x230
         ? __fget_light+0xf2/0x110
         __x64_sys_ioctl+0xc3/0x100
         do_syscall_64+0x37/0x80
         entry_SYSCALL_64_after_hwframe+0x44/0xa9
        RIP: 0033:0x7fd1976e2427
        Code: 00 00 90 48 8b 05 (...)
        RSP: 002b:00007fd1955e5cf8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
        RAX: ffffffffffffffda RBX: 00007fd1955e5f40 RCX: 00007fd1976e2427
        RDX: 00007fd1955e5f48 RSI: 00000000c038943b RDI: 0000000000000004
        RBP: 0000000001000000 R08: 0000000000000000 R09: 00007fd1955e6120
        R10: 0000557835366b00 R11: 0000000000000246 R12: 0000000000000004
        R13: 00007fd1955e5f48 R14: 00007fd1955e5f40 R15: 00007fd1955e5ef8
        Modules linked in:
        ---[ end trace ec8931a1c36e57be ]---
      
        (gdb) l *(__tree_mod_log_rewind+0x3b1)
        0xffffffff81893521 is in __tree_mod_log_rewind (fs/btrfs/ctree.c:1210).
        1205                     * the modification. as we're going backwards, we do the
        1206                     * opposite of each operation here.
        1207                     */
        1208                    switch (tm->op) {
        1209                    case MOD_LOG_KEY_REMOVE_WHILE_FREEING:
        1210                            BUG_ON(tm->slot < n);
        1211                            fallthrough;
        1212                    case MOD_LOG_KEY_REMOVE_WHILE_MOVING:
        1213                    case MOD_LOG_KEY_REMOVE:
        1214                            btrfs_set_node_key(eb, &tm->key, tm->slot);
      
      Here's what happens to hit that BUG_ON():
      
      1) We have one tree mod log user (through fiemap or the logical ino ioctl),
         with a sequence number of 1, so we have fs_info->tree_mod_seq == 1;
      
      2) Another task is at ctree.c:balance_level() and we have eb X currently as
         the root of the tree, and we promote its single child, eb Y, as the new
         root.
      
         Then, at ctree.c:balance_level(), we call:
      
            tree_mod_log_insert_root(eb X, eb Y, 1);
      
      3) At tree_mod_log_insert_root() we create tree mod log elements for each
         slot of eb X, of operation type MOD_LOG_KEY_REMOVE_WHILE_FREEING each
         with a ->logical pointing to ebX->start. These are placed in an array
         named tm_list.
         Lets assume there are N elements (N pointers in eb X);
      
      4) Then, still at tree_mod_log_insert_root(), we create a tree mod log
         element of operation type MOD_LOG_ROOT_REPLACE, ->logical set to
         ebY->start, ->old_root.logical set to ebX->start, ->old_root.level set
         to the level of eb X and ->generation set to the generation of eb X;
      
      5) Then tree_mod_log_insert_root() calls tree_mod_log_free_eb() with
         tm_list as argument. After that, tree_mod_log_free_eb() calls
         __tree_mod_log_insert() for each member of tm_list in reverse order,
         from highest slot in eb X, slot N - 1, to slot 0 of eb X;
      
      6) __tree_mod_log_insert() sets the sequence number of each given tree mod
         log operation - it increments fs_info->tree_mod_seq and sets
         fs_info->tree_mod_seq as the sequence number of the given tree mod log
         operation.
      
         This means that for the tm_list created at tree_mod_log_insert_root(),
         the element corresponding to slot 0 of eb X has the highest sequence
         number (1 + N), and the element corresponding to the last slot has the
         lowest sequence number (2);
      
      7) Then, after inserting tm_list's elements into the tree mod log rbtree,
         the MOD_LOG_ROOT_REPLACE element is inserted, which gets the highest
         sequence number, which is N + 2;
      
      8) Back to ctree.c:balance_level(), we free eb X by calling
         btrfs_free_tree_block() on it. Because eb X was created in the current
         transaction, has no other references and writeback did not happen for
         it, we add it back to the free space cache/tree;
      
      9) Later some other task T allocates the metadata extent from eb X, since
         it is marked as free space in the space cache/tree, and uses it as a
         node for some other btree;
      
      10) The tree mod log user task calls btrfs_search_old_slot(), which calls
          get_old_root(), and finally that calls __tree_mod_log_oldest_root()
          with time_seq == 1 and eb_root == eb Y;
      
      11) First iteration of the while loop finds the tree mod log element with
          sequence number N + 2, for the logical address of eb Y and of type
          MOD_LOG_ROOT_REPLACE;
      
      12) Because the operation type is MOD_LOG_ROOT_REPLACE, we don't break out
          of the loop, and set root_logical to point to tm->old_root.logical
          which corresponds to the logical address of eb X;
      
      13) On the next iteration of the while loop, the call to
          tree_mod_log_search_oldest() returns the smallest tree mod log element
          for the logical address of eb X, which has a sequence number of 2, an
          operation type of MOD_LOG_KEY_REMOVE_WHILE_FREEING and corresponds to
          the old slot N - 1 of eb X (eb X had N items in it before being freed);
      
      14) We then break out of the while loop and return the tree mod log operation
          of type MOD_LOG_ROOT_REPLACE (eb Y), and not the one for slot N - 1 of
          eb X, to get_old_root();
      
      15) At get_old_root(), we process the MOD_LOG_ROOT_REPLACE operation
          and set "logical" to the logical address of eb X, which was the old
          root. We then call tree_mod_log_search() passing it the logical
          address of eb X and time_seq == 1;
      
      16) Then before calling tree_mod_log_search(), task T adds a key to eb X,
          which results in adding a tree mod log operation of type
          MOD_LOG_KEY_ADD to the tree mod log - this is done at
          ctree.c:insert_ptr() - but after adding the tree mod log operation
          and before updating the number of items in eb X from 0 to 1...
      
      17) The task at get_old_root() calls tree_mod_log_search() and gets the
          tree mod log operation of type MOD_LOG_KEY_ADD just added by task T.
          Then it enters the following if branch:
      
          if (old_root && tm && tm->op != MOD_LOG_KEY_REMOVE_WHILE_FREEING) {
             (...)
          } (...)
      
          Calls read_tree_block() for eb X, which gets a reference on eb X but
          does not lock it - task T has it locked.
          Then it clones eb X while it has nritems set to 0 in its header, before
          task T sets nritems to 1 in eb X's header. From hereupon we use the
          clone of eb X which no other task has access to;
      
      18) Then we call __tree_mod_log_rewind(), passing it the MOD_LOG_KEY_ADD
          mod log operation we just got from tree_mod_log_search() in the
          previous step and the cloned version of eb X;
      
      19) At __tree_mod_log_rewind(), we set the local variable "n" to the number
          of items set in eb X's clone, which is 0. Then we enter the while loop,
          and in its first iteration we process the MOD_LOG_KEY_ADD operation,
          which just decrements "n" from 0 to (u32)-1, since "n" is declared with
          a type of u32. At the end of this iteration we call rb_next() to find the
          next tree mod log operation for eb X, that gives us the mod log operation
          of type MOD_LOG_KEY_REMOVE_WHILE_FREEING, for slot 0, with a sequence
          number of N + 1 (steps 3 to 6);
      
      20) Then we go back to the top of the while loop and trigger the following
          BUG_ON():
      
              (...)
              switch (tm->op) {
              case MOD_LOG_KEY_REMOVE_WHILE_FREEING:
                       BUG_ON(tm->slot < n);
                       fallthrough;
              (...)
      
          Because "n" has a value of (u32)-1 (4294967295) and tm->slot is 0.
      
      Fix this by taking a read lock on the extent buffer before cloning it at
      ctree.c:get_old_root(). This should be done regardless of the extent
      buffer having been freed and reused, as a concurrent task might be
      modifying it (while holding a write lock on it).
      
      Reported-by: default avatarZygo Blaxell <ce3g8jdj@umail.furryterror.org>
      Link: https://lore.kernel.org/linux-btrfs/20210227155037.GN28049@hungrycats.org/
      
      
      Fixes: 834328a8 ("Btrfs: tree mod log's old roots could still be part of the tree")
      CC: stable@vger.kernel.org # 4.4+
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      311dd851
    • Piotr Krysiuk's avatar
      bpf: Fix off-by-one for area size in creating mask to left · 87d185f3
      Piotr Krysiuk authored
      
      stable inclusion
      from linux-4.19.182
      commit ec5307f2ed2377fc55f0a8c990c6004c63014a54
      CVE: CVE-2020-27171
      
      --------------------------------
      
      commit 10d2bb2e6b1d8c4576c56a748f697dbeb8388899 upstream.
      
      retrieve_ptr_limit() computes the ptr_limit for registers with stack and
      map_value type. ptr_limit is the size of the memory area that is still
      valid / in-bounds from the point of the current position and direction
      of the operation (add / sub). This size will later be used for masking
      the operation such that attempting out-of-bounds access in the speculative
      domain is redirected to remain within the bounds of the current map value.
      
      When masking to the right the size is correct, however, when masking to
      the left, the size is off-by-one which would lead to an incorrect mask
      and thus incorrect arithmetic operation in the non-speculative domain.
      Piotr found that if the resulting alu_limit value is zero, then the
      BPF_MOV32_IMM() from the fixup_bpf_calls() rewrite will end up loading
      0xffffffff into AX instead of sign-extending to the full 64 bit range,
      and as a result, this allows abuse for executing speculatively out-of-
      bounds loads against 4GB window of address space and thus extracting the
      contents of kernel memory via side-channel.
      
      Fixes: 979d63d5 ("bpf: prevent out of bounds speculation on pointer arithmetic")
      Signed-off-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Co-developed-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Reviewed-by: default avatarJian Cheng <cj.chengjian@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      87d185f3
    • Piotr Krysiuk's avatar
      bpf: Prohibit alu ops for pointer types not defining ptr_limit · 25907492
      Piotr Krysiuk authored
      
      stable inclusion
      from linux-4.19.182
      commit bc49612a0e2c379a0d997375901c5371ba015518
      CVE: CVE-2020-27170
      
      --------------------------------
      
      commit f232326f6966cf2a1d1db7bc917a4ce5f9f55f76 upstream.
      
      The purpose of this patch is to streamline error propagation and in particular
      to propagate retrieve_ptr_limit() errors for pointer types that are not defining
      a ptr_limit such that register-based alu ops against these types can be rejected.
      
      The main rationale is that a gap has been identified by Piotr in the existing
      protection against speculatively out-of-bounds loads, for example, in case of
      ctx pointers, unprivileged programs can still perform pointer arithmetic. This
      can be abused to execute speculatively out-of-bounds loads without restrictions
      and thus extract contents of kernel memory.
      
      Fix this by rejecting unprivileged programs that attempt any pointer arithmetic
      on unprotected pointer types. The two affected ones are pointer to ctx as well
      as pointer to map. Field access to a modified ctx' pointer is rejected at a
      later point in time in the verifier, and 7c696732 ("bpf: Permit map_ptr
      arithmetic with opcode add and offset 0") only relevant for root-only use cases.
      Risk of unprivileged program breakage is considered very low.
      
      Fixes: 7c696732 ("bpf: Permit map_ptr arithmetic with opcode add and offset 0")
      Fixes: b2157399 ("bpf: prevent out-of-bounds speculation")
      Signed-off-by: default avatarPiotr Krysiuk <piotras@gmail.com>
      Co-developed-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Reviewed-by: default avatarJian Cheng <cj.chengjian@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      25907492
    • Dan Carpenter's avatar
      net/x25: prevent a couple of overflows · c082df7d
      Dan Carpenter authored
      
      stable inclusion
      from linux-4.19.162
      commit 304c080fc33258e3b177b6f0736b97d54e6fea3b
      CVE: CVE-2020-35519
      
      --------------------------------
      
      [ Upstream commit 6ee50c8e ]
      
      The .x25_addr[] address comes from the user and is not necessarily
      NUL terminated.  This leads to a couple problems.  The first problem is
      that the strlen() in x25_bind() can read beyond the end of the buffer.
      
      The second problem is more subtle and could result in memory corruption.
      The call tree is:
        x25_connect()
        --> x25_write_internal()
            --> x25_addr_aton()
      
      The .x25_addr[] buffers are copied to the "addresses" buffer from
      x25_write_internal() so it will lead to stack corruption.
      
      Verify that the strings are NUL terminated and return -EINVAL if they
      are not.
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Fixes: a9288525 ("X25: Dont let x25_bind use addresses containing characters")
      Reported-by: default avatar"kiyin(尹亮)" <kiyin@tencent.com>
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Acked-by: default avatarMartin Schiller <ms@dev.tdt.de>
      Link: https://lore.kernel.org/r/X8ZeAKm8FnFpN//B@mwanda
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      c082df7d
    • Dave Airlie's avatar
      drm/ttm/nouveau: don't call tt destroy callback on alloc failure. · 538290b5
      Dave Airlie authored
      
      stable inclusion
      from linux-4.19.140
      commit 10c8a526b2db1fcdf9e2d59d4885377b91939c55
      CVE: CVE-2021-20292
      
      --------------------------------
      
      commit 5de5b6ec upstream.
      
      This is confusing, and from my reading of all the drivers only
      nouveau got this right.
      
      Just make the API act under driver control of it's own allocation
      failing, and don't call destroy, if the page table fails to
      create there is nothing to cleanup here.
      
      (I'm willing to believe I've missed something here, so please
      review deeply).
      
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20200728041736.20689-1-airlied@gmail.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      538290b5
    • 卢佳琳's avatar
      cgroup: Fix kabi broken by files_cgroup introduced · 293d508e
      卢佳琳 authored
      hulk inclusion
      category: feature/cgroups
      bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=7
      
      
      CVE: NA
      
      --------
      
      The patch adds ifndef(__GENKSYMS__) into cgroup_subsys.h, and this
      change is more nasty than it looks. It hides the fact that that we change
      the layout of "struct cgroup" and "struct css_set", they both have the
      subsys[CGROUP_SUBSYS_COUNT] member. I hope this is fine, the modular code
      has no reasons to access the private members after ->subsys[], and the
      helpers like cgroup_sane_behavior() shouldn't be used by external modules.
      
      The patch also fixes the following compile warning caused by the fix kabi
      broken.
      
      Signed-off-by: default avatarLu Jialin <lujialin4@huawei.com>
      Reviewed-by: default avatarChen Zhou <chenzhou10@huawei.com>
      Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      293d508e
    • 张明's avatar
      arm64/mpam: fix a possible deadlock in mpam_enable · 207d25d6
      张明 authored
      openEuler inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I3D58V
      
      
      CVE: NA
      
      ----------------------------------
      
      No unlock operation is performed on the mpam_devices_lock
      before the return statement, which may lead to a deadlock.
      
      Signed-off-by: default avatarZhang Ming <154842638@qq.com>
      Reported-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      Suggested-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      Reviewed-by: default avatarWang ShaoBo <bobo.shaobowang@huawei.com>
      Reviewed-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      207d25d6
    • Zhen Lei's avatar
      config: arm64: build TCM driver to modules by default · 3dcef7a4
      Zhen Lei authored
      
      driver inclusion
      category: feature
      bugzilla: 50797
      CVE: NA
      
      -------------------------------------------------------------------------
      Set CONFIG_GMJS_TCM_CORE=m and CONFIG_GMJS_TCM_SPI=m, so that its ko can
      be distributed in ISO on arm64.
      
      Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Acked-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      3dcef7a4
    • Li ZhiGang's avatar
      staging: TCM: add GMJS(Nationz Tech) TCM driver. · 5ebbfc8c
      Li ZhiGang authored
      
      driver inclusion
      category: feature
      bugzilla: 50797
      CVE: NA
      
      -------------------------------------------------------------------------
      
      Nationz Tech TCM are used for trusted computing, the chip attached via SPI or LPC.
      We have a brief verify/test with this driver on KunPeng920 + openEuler system, with externally compiled module.
      
      Signed-off-by: default avatarLi ZhiGang <lizhigang@kylinos.cn>
      Acked-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      5ebbfc8c
    • Yang Yingliang's avatar
      config: enable config TXGBE by default · d1479e45
      Yang Yingliang authored
      
      driver inclusion
      category: feature
      bugzilla: 50777
      CVE: NA
      
      -------------------------------------------------------------------------
      enable config TXGBE by default on arm64 for compile test.
      
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      d1479e45
    • zhenpengzheng's avatar
      x86/config: Set CONFIG_TXGBE=m by default · dcac1cc1
      zhenpengzheng authored
      
      driver inclusion
      category: feature
      bugzilla: 50777
      CVE: NA
      
      -------------------------------------------------------------------------
      Set CONFIG_TXGBE=m, so that its ko can be distributed in ISO on X86.
      
      Signed-off-by: default avatarzhenpengzheng <zhenpengzheng@net-swift.com>
      Acked-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      dcac1cc1
    • zhenpengzheng's avatar
      net: txgbe: Add support for Netswift 10G NIC · e9f0b33c
      zhenpengzheng authored
      
      driver inclusion
      category: feature
      bugzilla: 50777
      CVE: NA
      
      -------------------------------------------------------------------------
      This driver is based on drivers/net/ethernet/intel/ixgbe/.
      
      Signed-off-by: default avatarzhenpengzheng <zhenpengzheng@net-swift.com>
      Acked-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
      Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarCheng Jian <cj.chengjian@huawei.com>
      e9f0b33c
  3. Mar 22, 2021