Skip to content
Snippets Groups Projects
  1. Oct 19, 2022
  2. Oct 18, 2022
  3. Oct 17, 2022
    • Qian Cai's avatar
      mm/hotplug: silence a lockdep splat with printk() · 988dd3e9
      Qian Cai authored
      mainline inclusion
      from mainline-v5.6-rc1
      commit 4a55c0474a92d5c418bcbbe122368de0910aeac2q
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I5T5DD
      CVE: NA
      
      --------------------------------
      
      It is not that hard to trigger lockdep splats by calling printk from
      under zone->lock.  Most of them are false positives caused by lock
      chains introduced early in the boot process and they do not cause any
      real problems (although most of the early boot lock dependencies could
      happen after boot as well).  There are some console drivers which do
      allocate from the printk context as well and those should be fixed.  In
      any case, false positives are not that trivial to workaround and it is
      far from optimal to lose lockdep functionality for something that is a
      non-issue.
      
      So change has_unmovable_pages() so that it no longer calls dump_page()
      itself - instead it returns a "struct page *" of the unmovable page back
      to the caller so that in the case of a has_u...
      988dd3e9
    • Xia Fukun's avatar
      init/Kconfig: Add SMP to the dependencies of QOS_SCHED · 72b3422d
      Xia Fukun authored
      hulk inclusion
      category: bugfix
      bugzilla: https://gitee.com/openeuler/kernel/issues/I5UPB0
      CVE: NA
      
      ------------------------------------------------------------
      
      After CONFIG_SMP is disabled during kernel compilation,
      CONFIG_QOS_SCHED is not disabled.
      As a result, the following error occurs:
      
      kernel/sched/fair.c: In function ‘check_qos_cfs_rq’:
      kernel/sched/fair.c:7324:4: error: implicit declaration of function
      ‘sched_idle_cpu’; did you mean ‘sched_idle_rq’?
      [-Werror=implicit-function-declaration]
       7324 |   !sched_idle_cpu(smp_processor_id()) &&
            |    ^~~~~~~~~~~~~~
      ./include/linux/compiler.h:78:42: note: in definition of macro ‘unlikely’
         78 | # define unlikely(x) __builtin_expect(!!(x), 0)
            |                                          ^
        CC      mm/highmem.o
      kernel/sched/fair.c: In function ‘pick_next_task_fair’:
      kernel/sched/fair.c:7599:43: error: ‘struct rq’ has no member named ‘online’
       7599 |   if (cfs_rq->...
      72b3422d
  4. Oct 14, 2022
    • Ma Wupeng's avatar
      mm/rmap: Fix kabi broken in anon_vma · 6d5d324d
      Ma Wupeng authored
      hulk inclusion
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I5USOP
      
      
      CVE: CVE-2022-42703
      
      --------------------------------
      
      In order to fix CVE-2022-42703, degree in struct anon_vma is splited into
      two variables(num_children, num_active_vmas) and this will lead to broken
      kabi.
      
      Since struct anon_vma is only used by mm module and referenced by other
      struct as pointers. So we can ignore this kabi change warning.
      
      For variable degree in struct anon_vma, previous patch has already
      delete this but this will lead to kabi change. Add it back at the same
      position. For variables(num_children, num_active_vmas), put them
      between macro __GENKSYMS__.
      
      Signed-off-by: default avatarMa Wupeng <mawupeng1@huawei.com>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
      6d5d324d
    • Jann Horn's avatar
      mm/rmap: Fix anon_vma->degree ambiguity leading to double-reuse · a3544c89
      Jann Horn authored
      stable inclusion
      from stable-v4.19.257
      commit 6dbfc25d68d922736381988d64156a649ccf7bf1
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I5USOP
      
      
      CVE: CVE-2022-42703
      
      --------------------------------
      
      commit 2555283eb40df89945557273121e9393ef9b542b upstream.
      
      anon_vma->degree tracks the combined number of child anon_vmas and VMAs
      that use the anon_vma as their ->anon_vma.
      
      anon_vma_clone() then assumes that for any anon_vma attached to
      src->anon_vma_chain other than src->anon_vma, it is impossible for it to
      be a leaf node of the VMA tree, meaning that for such VMAs ->degree is
      elevated by 1 because of a child anon_vma, meaning that if ->degree
      equals 1 there are no VMAs that use the anon_vma as their ->anon_vma.
      
      This assumption is wrong because the ->degree optimization leads to leaf
      nodes being abandoned on anon_vma_clone() - an existing anon_vma is
      reused and no new parent-child relationship is created.  So it is
      possible to reuse an anon_vma for one VMA while it is still tied to
      another VMA.
      
      This is an issue because is_mergeable_anon_vma() and its callers assume
      that if two VMAs have the same ->anon_vma, the list of anon_vmas
      attached to the VMAs is guaranteed to be the same.  When this assumption
      is violated, vma_merge() can merge pages into a VMA that is not attached
      to the corresponding anon_vma, leading to dangling page->mapping
      pointers that will be dereferenced during rmap walks.
      
      Fix it by separately tracking the number of child anon_vmas and the
      number of VMAs using the anon_vma as their ->anon_vma.
      
      Fixes: 7a3ef208 ("mm: prevent endless growth of anon_vma hierarchy")
      Cc: stable@kernel.org
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarMa Wupeng <mawupeng1@huawei.com>
      Reviewed-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
      a3544c89
    • Hyunwoo Kim's avatar
      HID: roccat: Fix use-after-free in roccat_read() · 4d870684
      Hyunwoo Kim authored
      mainline inclusion
      from mainline master
      commit cacdb14b1c8d3804a3a7d31773bc7569837b71a4
      category: bugfix
      bugzilla: https://gitee.com/src-openeuler/kernel/issues/I5U1PE
      
      
      CVE: CVE-2022-41850
      
      --------------------------------
      
      roccat_report_event() is responsible for registering
      roccat-related reports in struct roccat_device.
      
      int roccat_report_event(int minor, u8 const *data)
      {
      	struct roccat_device *device;
      	struct roccat_reader *reader;
      	struct roccat_report *report;
      	uint8_t *new_value;
      
      	device = devices[minor];
      
      	new_value = kmemdup(data, device->report_size, GFP_ATOMIC);
      	if (!new_value)
      		return -ENOMEM;
      
      	report = &device->cbuf[device->cbuf_end];
      
      	/* passing NULL is safe */
      	kfree(report->value);
      	...
      
      The registered report is stored in the struct roccat_device member
      "struct roccat_report cbuf[ROCCAT_CBUF_SIZE];".
      If more reports are received than the "ROCCAT_CBUF_SIZE" value,
      kfree() the saved report from cbuf[0] and allocates a new reprot.
      Since there is no lock when this kfree() is performed,
      kfree() can be performed even while reading the saved report.
      
      static ssize_t roccat_read(struct file *file, char __user *buffer,
      		size_t count, loff_t *ppos)
      {
      	struct roccat_reader *reader = file->private_data;
      	struct roccat_device *device = reader->device;
      	struct roccat_report *report;
      	ssize_t retval = 0, len;
      	DECLARE_WAITQUEUE(wait, current);
      
      	mutex_lock(&device->cbuf_lock);
      
      	...
      
      	report = &device->cbuf[reader->cbuf_start];
      	/*
      	 * If report is larger than requested amount of data, rest of report
      	 * is lost!
      	 */
      	len = device->report_size > count ? count : device->report_size;
      
      	if (copy_to_user(buffer, report->value, len)) {
      		retval = -EFAULT;
      		goto exit_unlock;
      	}
      	...
      
      The roccat_read() function receives the device->cbuf report and
      delivers it to the user through copy_to_user().
      If the N+ROCCAT_CBUF_SIZE th report is received while copying of
      the Nth report->value is in progress, the pointer that copy_to_user()
      is working on is kfree()ed and UAF read may occur. (race condition)
      
      Since the device node of this driver does not set separate permissions,
      this is not a security vulnerability, but because it is used for
      requesting screen display of profile or dpi settings,
      a user using the roccat device can apply udev to this device node or
      There is a possibility to use it by giving.
      
      Signed-off-by: default avatarHyunwoo Kim <imv4bel@gmail.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarCai Xinchen <caixinchen1@huawei.com>
      Reviewed-by: default avatarRuiqi Gong <gongruiqi1@huawei.com>
      Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
      4d870684
  5. Oct 11, 2022