diff options
Diffstat (limited to 'sys-kernel/linux-sources-redcore')
-rw-r--r-- | sys-kernel/linux-sources-redcore/files/5.1-0001-uksm-apply-52d1e606ee733.patch | 75 | ||||
-rw-r--r-- | sys-kernel/linux-sources-redcore/files/5.1-0001-uksm-initial-submission-linux-hardened.patch (renamed from sys-kernel/linux-sources-redcore/files/5.1-uksm-linux-hardened.patch) | 99 | ||||
-rw-r--r-- | sys-kernel/linux-sources-redcore/linux-sources-redcore-5.1.15.ebuild | 3 |
3 files changed, 137 insertions, 40 deletions
diff --git a/sys-kernel/linux-sources-redcore/files/5.1-0001-uksm-apply-52d1e606ee733.patch b/sys-kernel/linux-sources-redcore/files/5.1-0001-uksm-apply-52d1e606ee733.patch new file mode 100644 index 00000000..dbc5357c --- /dev/null +++ b/sys-kernel/linux-sources-redcore/files/5.1-0001-uksm-apply-52d1e606ee733.patch @@ -0,0 +1,75 @@ +From ea0c9d768bade0bc87046841a3e667f477d90668 Mon Sep 17 00:00:00 2001 +From: Oleksandr Natalenko <oleksandr@natalenko.name> +Date: Mon, 6 May 2019 22:02:49 +0200 +Subject: [PATCH] uksm-5.1: apply 52d1e606ee733 + +Signed-off-by: Oleksandr Natalenko <oleksandr@natalenko.name> +--- + mm/uksm.c | 36 +++++++++++++++++++++++++++++++----- + 1 file changed, 31 insertions(+), 5 deletions(-) + +diff --git a/mm/uksm.c b/mm/uksm.c +index 174e1921eade..2531599038b8 100644 +--- a/mm/uksm.c ++++ b/mm/uksm.c +@@ -875,8 +875,8 @@ static void remove_node_from_stable_tree(struct stable_node *stable_node, + * to keep the page_count protocol described with page_cache_get_speculative. + * + * Note: it is possible that get_uksm_page() will return NULL one moment, +- * then page the next, if the page is in between page_freeze_refs() and +- * page_unfreeze_refs(): this shouldn't be a problem anywhere, the page ++ * then page the next, if the page is in between page_ref_freeze() and ++ * page_ref_unfreeze(): this shouldn't be a problem anywhere, the page + * is on its way to being freed; but it is an anomaly to bear in mind. + * + * @unlink_rb: if the removal of this node will firstly unlink from +@@ -914,10 +914,11 @@ static struct page *get_uksm_page(struct stable_node *stable_node, + * We cannot do anything with the page while its refcount is 0. + * Usually 0 means free, or tail of a higher-order page: in which + * case this node is no longer referenced, and should be freed; +- * however, it might mean that the page is under page_freeze_refs(). ++ * however, it might mean that the page is under page_ref_freeze(). + * The __remove_mapping() case is easy, again the node is now stale; +- * but if page is swapcache in migrate_page_move_mapping(), it might +- * still be our page, in which case it's essential to keep the node. ++ * the same is in reuse_ksm_page() case; but if page is swapcache ++ * in migrate_page_move_mapping(), it might still be our page, ++ * in which case it's essential to keep the node. + */ + while (!get_page_unless_zero(page)) { + /* +@@ -4749,6 +4750,31 @@ void rmap_walk_ksm(struct page *page, struct rmap_walk_control *rwc) + goto again; + } + ++bool reuse_ksm_page(struct page *page, ++ struct vm_area_struct *vma, ++ unsigned long address) ++{ ++#ifdef CONFIG_DEBUG_VM ++ if (WARN_ON(is_zero_pfn(page_to_pfn(page))) || ++ WARN_ON(!page_mapped(page)) || ++ WARN_ON(!PageLocked(page))) { ++ dump_page(page, "reuse_ksm_page"); ++ return false; ++ } ++#endif ++ ++ if (PageSwapCache(page) || !page_stable_node(page)) ++ return false; ++ /* Prohibit parallel get_ksm_page() */ ++ if (!page_ref_freeze(page, 1)) ++ return false; ++ ++ page_move_anon_rmap(page, vma); ++ page->index = linear_page_index(vma, address); ++ page_ref_unfreeze(page, 1); ++ ++ return true; ++} + #ifdef CONFIG_MIGRATION + /* Common ksm interface but may be specific to uksm */ + void ksm_migrate_page(struct page *newpage, struct page *oldpage) +-- +2.21.0.777.g83232e3864 + diff --git a/sys-kernel/linux-sources-redcore/files/5.1-uksm-linux-hardened.patch b/sys-kernel/linux-sources-redcore/files/5.1-0001-uksm-initial-submission-linux-hardened.patch index a79cb3d5..d2f3a41f 100644 --- a/sys-kernel/linux-sources-redcore/files/5.1-uksm-linux-hardened.patch +++ b/sys-kernel/linux-sources-redcore/files/5.1-0001-uksm-initial-submission-linux-hardened.patch @@ -1,6 +1,6 @@ diff -Nur a/Documentation/vm/uksm.txt b/Documentation/vm/uksm.txt --- a/Documentation/vm/uksm.txt 1970-01-01 01:00:00.000000000 +0100 -+++ b/Documentation/vm/uksm.txt 2019-07-07 09:32:50.451840235 +0100 ++++ b/Documentation/vm/uksm.txt 2019-07-07 11:43:00.138836975 +0100 @@ -0,0 +1,61 @@ +The Ultra Kernel Samepage Merging feature +---------------------------------------------- @@ -64,17 +64,18 @@ diff -Nur a/Documentation/vm/uksm.txt b/Documentation/vm/uksm.txt +2016-09-10 UKSM 0.1.2.5 Fix a bug in dedup ratio calculation. +2017-02-26 UKSM 0.1.2.6 Fix a bug in hugetlbpage handling and a race bug with page migration. diff -Nur a/fs/exec.c b/fs/exec.c ---- a/fs/exec.c 2019-07-07 09:08:19.132347946 +0100 -+++ b/fs/exec.c 2019-07-07 09:33:47.653770486 +0100 -@@ -63,6 +63,7 @@ +--- a/fs/exec.c 2019-07-07 11:39:06.860827790 +0100 ++++ b/fs/exec.c 2019-07-07 11:44:01.830966115 +0100 +@@ -63,6 +63,8 @@ #include <linux/compat.h> #include <linux/vmalloc.h> #include <linux/random.h> ++#include <linux/freezer.h> +#include <linux/ksm.h> #include <linux/uaccess.h> #include <asm/mmu_context.h> -@@ -1385,6 +1386,7 @@ +@@ -1385,6 +1387,7 @@ /* An exec changes our domain. We are no longer part of the thread group */ current->self_exec_id++; @@ -84,7 +85,7 @@ diff -Nur a/fs/exec.c b/fs/exec.c EXPORT_SYMBOL(setup_new_exec); diff -Nur a/fs/proc/meminfo.c b/fs/proc/meminfo.c --- a/fs/proc/meminfo.c 2019-06-25 04:34:56.000000000 +0100 -+++ b/fs/proc/meminfo.c 2019-07-07 09:32:50.451840235 +0100 ++++ b/fs/proc/meminfo.c 2019-07-07 11:43:00.138836975 +0100 @@ -106,6 +106,10 @@ global_zone_page_state(NR_KERNEL_STACK_KB)); show_val_kb(m, "PageTables: ", @@ -98,7 +99,7 @@ diff -Nur a/fs/proc/meminfo.c b/fs/proc/meminfo.c #endif diff -Nur a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h --- a/include/asm-generic/pgtable.h 2019-06-25 04:34:56.000000000 +0100 -+++ b/include/asm-generic/pgtable.h 2019-07-07 09:32:50.451840235 +0100 ++++ b/include/asm-generic/pgtable.h 2019-07-07 11:43:00.138836975 +0100 @@ -855,12 +855,25 @@ extern void untrack_pfn_moved(struct vm_area_struct *vma); #endif @@ -137,13 +138,7 @@ diff -Nur a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h static inline unsigned long my_zero_pfn(unsigned long addr) diff -Nur a/include/linux/ksm.h b/include/linux/ksm.h --- a/include/linux/ksm.h 2019-06-25 04:34:56.000000000 +0100 -+++ b/include/linux/ksm.h 2019-07-07 09:32:50.451840235 +0100 -@@ -1,4 +1,4 @@ --/* SPDX-License-Identifier: GPL-2.0 */ -+/* SPDX-License-Identifier: GPL-3.0 */ - #ifndef __LINUX_KSM_H - #define __LINUX_KSM_H - /* ++++ b/include/linux/ksm.h 2019-07-07 11:43:00.138836975 +0100 @@ -21,20 +21,16 @@ #ifdef CONFIG_KSM int ksm_madvise(struct vm_area_struct *vma, unsigned long start, @@ -213,7 +208,7 @@ diff -Nur a/include/linux/ksm.h b/include/linux/ksm.h #endif /* __LINUX_KSM_H */ diff -Nur a/include/linux/mm_types.h b/include/linux/mm_types.h --- a/include/linux/mm_types.h 2019-06-25 04:34:56.000000000 +0100 -+++ b/include/linux/mm_types.h 2019-07-07 09:32:50.451840235 +0100 ++++ b/include/linux/mm_types.h 2019-07-07 11:43:00.138836975 +0100 @@ -334,6 +334,9 @@ struct mempolicy *vm_policy; /* NUMA policy for the VMA */ #endif @@ -226,7 +221,7 @@ diff -Nur a/include/linux/mm_types.h b/include/linux/mm_types.h struct core_thread { diff -Nur a/include/linux/mmzone.h b/include/linux/mmzone.h --- a/include/linux/mmzone.h 2019-06-25 04:34:56.000000000 +0100 -+++ b/include/linux/mmzone.h 2019-07-07 09:32:50.451840235 +0100 ++++ b/include/linux/mmzone.h 2019-07-07 11:43:00.138836975 +0100 @@ -148,6 +148,9 @@ NR_ZSPAGES, /* allocated in zsmalloc */ #endif @@ -239,7 +234,7 @@ diff -Nur a/include/linux/mmzone.h b/include/linux/mmzone.h enum node_stat_item { diff -Nur a/include/linux/sradix-tree.h b/include/linux/sradix-tree.h --- a/include/linux/sradix-tree.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/include/linux/sradix-tree.h 2019-07-07 09:32:50.451840235 +0100 ++++ b/include/linux/sradix-tree.h 2019-07-07 11:43:00.148837320 +0100 @@ -0,0 +1,77 @@ +#ifndef _LINUX_SRADIX_TREE_H +#define _LINUX_SRADIX_TREE_H @@ -320,7 +315,7 @@ diff -Nur a/include/linux/sradix-tree.h b/include/linux/sradix-tree.h +#endif /* _LINUX_SRADIX_TREE_H */ diff -Nur a/include/linux/uksm.h b/include/linux/uksm.h --- a/include/linux/uksm.h 1970-01-01 01:00:00.000000000 +0100 -+++ b/include/linux/uksm.h 2019-07-07 09:32:50.451840235 +0100 ++++ b/include/linux/uksm.h 2019-07-07 11:43:00.148837320 +0100 @@ -0,0 +1,149 @@ +#ifndef __LINUX_UKSM_H +#define __LINUX_UKSM_H @@ -472,8 +467,8 @@ diff -Nur a/include/linux/uksm.h b/include/linux/uksm.h +#endif /* !CONFIG_UKSM */ +#endif /* __LINUX_UKSM_H */ diff -Nur a/kernel/fork.c b/kernel/fork.c ---- a/kernel/fork.c 2019-07-07 09:08:19.152348621 +0100 -+++ b/kernel/fork.c 2019-07-07 09:32:50.451840235 +0100 +--- a/kernel/fork.c 2019-07-07 11:39:06.870828132 +0100 ++++ b/kernel/fork.c 2019-07-07 11:43:00.148837320 +0100 @@ -584,7 +584,7 @@ __vma_link_rb(mm, tmp, rb_link, rb_parent); rb_link = &tmp->vm_rb.rb_right; @@ -485,7 +480,7 @@ diff -Nur a/kernel/fork.c b/kernel/fork.c retval = copy_page_range(mm, oldmm, mpnt); diff -Nur a/lib/Makefile b/lib/Makefile --- a/lib/Makefile 2019-06-25 04:34:56.000000000 +0100 -+++ b/lib/Makefile 2019-07-07 09:32:50.451840235 +0100 ++++ b/lib/Makefile 2019-07-07 11:43:00.148837320 +0100 @@ -29,7 +29,7 @@ endif @@ -497,7 +492,7 @@ diff -Nur a/lib/Makefile b/lib/Makefile flex_proportions.o ratelimit.o show_mem.o \ diff -Nur a/lib/sradix-tree.c b/lib/sradix-tree.c --- a/lib/sradix-tree.c 1970-01-01 01:00:00.000000000 +0100 -+++ b/lib/sradix-tree.c 2019-07-07 09:32:50.451840235 +0100 ++++ b/lib/sradix-tree.c 2019-07-07 11:43:00.148837320 +0100 @@ -0,0 +1,476 @@ +#include <linux/errno.h> +#include <linux/mm.h> @@ -976,8 +971,8 @@ diff -Nur a/lib/sradix-tree.c b/lib/sradix-tree.c + return 0; +} diff -Nur a/mm/Kconfig b/mm/Kconfig ---- a/mm/Kconfig 2019-07-07 09:08:19.162348955 +0100 -+++ b/mm/Kconfig 2019-07-07 09:32:50.451840235 +0100 +--- a/mm/Kconfig 2019-07-07 11:39:06.880828472 +0100 ++++ b/mm/Kconfig 2019-07-07 11:43:00.148837320 +0100 @@ -302,6 +302,32 @@ See Documentation/vm/ksm.rst for more information: KSM is inactive until a program has madvised that an area is MADV_MERGEABLE, and @@ -1013,7 +1008,7 @@ diff -Nur a/mm/Kconfig b/mm/Kconfig int "Low address space to protect from user allocation" diff -Nur a/mm/ksm.c b/mm/ksm.c --- a/mm/ksm.c 2019-06-25 04:34:56.000000000 +0100 -+++ b/mm/ksm.c 2019-07-07 09:32:50.461840572 +0100 ++++ b/mm/ksm.c 2019-07-07 11:43:00.148837320 +0100 @@ -858,17 +858,6 @@ return err; } @@ -1034,7 +1029,7 @@ diff -Nur a/mm/ksm.c b/mm/ksm.c * Only called through the sysfs control interface: diff -Nur a/mm/Makefile b/mm/Makefile --- a/mm/Makefile 2019-06-25 04:34:56.000000000 +0100 -+++ b/mm/Makefile 2019-07-07 09:32:50.451840235 +0100 ++++ b/mm/Makefile 2019-07-07 11:43:00.148837320 +0100 @@ -58,7 +58,8 @@ obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o obj-$(CONFIG_SLOB) += slob.o @@ -1047,7 +1042,7 @@ diff -Nur a/mm/Makefile b/mm/Makefile obj-$(CONFIG_SLUB) += slub.o diff -Nur a/mm/memory.c b/mm/memory.c --- a/mm/memory.c 2019-06-25 04:34:56.000000000 +0100 -+++ b/mm/memory.c 2019-07-07 09:32:50.461840572 +0100 ++++ b/mm/memory.c 2019-07-07 11:43:00.148837320 +0100 @@ -129,6 +129,25 @@ unsigned long highest_memmap_pfn __read_mostly; @@ -1144,8 +1139,8 @@ diff -Nur a/mm/memory.c b/mm/memory.c } flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte)); diff -Nur a/mm/mmap.c b/mm/mmap.c ---- a/mm/mmap.c 2019-07-07 09:08:19.162348955 +0100 -+++ b/mm/mmap.c 2019-07-07 09:34:22.544947675 +0100 +--- a/mm/mmap.c 2019-07-07 11:39:06.880828472 +0100 ++++ b/mm/mmap.c 2019-07-07 11:43:00.148837320 +0100 @@ -46,6 +46,7 @@ #include <linux/pkeys.h> #include <linux/oom.h> @@ -1158,7 +1153,7 @@ diff -Nur a/mm/mmap.c b/mm/mmap.c if (vma->vm_file) fput(vma->vm_file); mpol_put(vma_policy(vma)); -+ uksm_remove_vma(vma); ++ uksm_remove_vma(vma); vm_area_free(vma); return next; } @@ -1274,7 +1269,21 @@ diff -Nur a/mm/mmap.c b/mm/mmap.c if (mm->locked_vm) { vma = mm->mmap; while (vma) { -@@ -3162,6 +3192,11 @@ +@@ -3140,8 +3170,12 @@ + arch_exit_mmap(mm); + + vma = mm->mmap; +- if (!vma) /* Can happen if dup_mmap() received an OOM */ ++ /* Can happen if dup_mmap() received an OOM */ ++ if (!vma) { ++ /* Release write lock previously taken for UKSM */ ++ up_write(&mm->mmap_sem); + return; ++ } + + lru_add_drain(); + flush_cache_mm(mm); +@@ -3162,6 +3196,11 @@ vma = remove_vma(vma); } vm_unacct_memory(nr_accounted); @@ -1286,7 +1295,7 @@ diff -Nur a/mm/mmap.c b/mm/mmap.c } /* Insert vm structure into process list sorted by address -@@ -3269,6 +3304,7 @@ +@@ -3269,6 +3308,7 @@ new_vma->vm_ops->open(new_vma); vma_link(mm, new_vma, prev, rb_link, rb_parent); *need_rmap_locks = false; @@ -1294,7 +1303,7 @@ diff -Nur a/mm/mmap.c b/mm/mmap.c } return new_vma; -@@ -3419,6 +3455,7 @@ +@@ -3419,6 +3459,7 @@ vm_stat_account(mm, vma->vm_flags, len >> PAGE_SHIFT); perf_event_mmap(vma); @@ -1302,9 +1311,21 @@ diff -Nur a/mm/mmap.c b/mm/mmap.c return vma; +diff -Nur a/mm/rmap.c b/mm/rmap.c +--- a/mm/rmap.c 2019-06-25 04:34:56.000000000 +0100 ++++ b/mm/rmap.c 2019-07-07 11:43:00.148837320 +0100 +@@ -1021,7 +1021,7 @@ + * __page_set_anon_rmap - set up new anonymous rmap + * @page: Page or Hugepage to add to rmap + * @vma: VM area to add page to. +- * @address: User virtual address of the mapping ++ * @address: User virtual address of the mapping + * @exclusive: the page is exclusively owned by the current process + */ + static void __page_set_anon_rmap(struct page *page, diff -Nur a/mm/uksm.c b/mm/uksm.c --- a/mm/uksm.c 1970-01-01 01:00:00.000000000 +0100 -+++ b/mm/uksm.c 2019-07-07 09:32:50.461840572 +0100 ++++ b/mm/uksm.c 2019-07-07 11:43:00.148837320 +0100 @@ -0,0 +1,5580 @@ +/* + * Ultra KSM. Copyright (C) 2011-2012 Nai Xia @@ -2801,9 +2822,9 @@ diff -Nur a/mm/uksm.c b/mm/uksm.c + .page = page, + .vma = vma, + }; -+ struct mmu_notifier_range range; + int swapped; + int err = -EFAULT; ++ struct mmu_notifier_range range; + + pvmw.address = page_address_in_vma(page, vma); + if (pvmw.address == -EFAULT) @@ -2811,7 +2832,7 @@ diff -Nur a/mm/uksm.c b/mm/uksm.c + + BUG_ON(PageTransCompound(page)); + -+ mmu_notifier_range_init(&range, mm, pvmw.address, pvmw.address + PAGE_SIZE); ++ mmu_notifier_range_init(&range, mm, pvmw.address, pvmw.address + PAGE_SIZE); + mmu_notifier_invalidate_range_start(&range); + + if (!page_vma_mapped_walk(&pvmw)) @@ -2886,7 +2907,6 @@ diff -Nur a/mm/uksm.c b/mm/uksm.c + struct page *kpage, pte_t orig_pte) +{ + struct mm_struct *mm = vma->vm_mm; -+ struct mmu_notifier_range range; + pgd_t *pgd; + p4d_t *p4d; + pud_t *pud; @@ -2897,6 +2917,7 @@ diff -Nur a/mm/uksm.c b/mm/uksm.c + + unsigned long addr; + int err = MERGE_ERR_PGERR; ++ struct mmu_notifier_range range; + + addr = page_address_in_vma(page, vma); + if (addr == -EFAULT) @@ -2916,7 +2937,7 @@ diff -Nur a/mm/uksm.c b/mm/uksm.c + if (!pmd_present(*pmd)) + goto out; + -+ mmu_notifier_range_init(&range, mm, addr, addr + PAGE_SIZE); ++ mmu_notifier_range_init(&range, mm, addr, addr + PAGE_SIZE); + mmu_notifier_invalidate_range_start(&range); + + ptep = pte_offset_map_lock(mm, pmd, addr, &ptl); @@ -6888,7 +6909,7 @@ diff -Nur a/mm/uksm.c b/mm/uksm.c + diff -Nur a/mm/vmstat.c b/mm/vmstat.c --- a/mm/vmstat.c 2019-06-25 04:34:56.000000000 +0100 -+++ b/mm/vmstat.c 2019-07-07 09:32:50.461840572 +0100 ++++ b/mm/vmstat.c 2019-07-07 11:43:00.148837320 +0100 @@ -1165,6 +1165,9 @@ "nr_written", "nr_kernel_misc_reclaimable", diff --git a/sys-kernel/linux-sources-redcore/linux-sources-redcore-5.1.15.ebuild b/sys-kernel/linux-sources-redcore/linux-sources-redcore-5.1.15.ebuild index 585459a0..3d644b85 100644 --- a/sys-kernel/linux-sources-redcore/linux-sources-redcore-5.1.15.ebuild +++ b/sys-kernel/linux-sources-redcore/linux-sources-redcore-5.1.15.ebuild @@ -36,7 +36,8 @@ PATCHES=( "${FILESDIR}"/"${KV_MAJOR}"-fix-acpi_dbg_level.patch "${FILESDIR}"/"${KV_MAJOR}"-radeon_dp_aux_transfer_native-no-ratelimited_debug.patch "${FILESDIR}"/"${KV_MAJOR}"-Unknow-SSD-HFM128GDHTNG-8310B-QUIRK_NO_APST.patch - "${FILESDIR}"/"${KV_MAJOR}"-linux-hardened.patch + "${FILESDIR}"/"${KV_MAJOR}"-0001-uksm-initial-submission-linux-hardened.patch + "${FILESDIR}"/"${KV_MAJOR}"-0001-uksm-apply-52d1e606ee733.patch "${FILESDIR}"/"${KV_MAJOR}"-uksm-linux-hardened.patch "${FILESDIR}"/"${KV_MAJOR}"-0001-MultiQueue-Skiplist-Scheduler-version-0.192-linux-hardened.patch "${FILESDIR}"/"${KV_MAJOR}"-0002-Fix-Werror-build-failure-in-tools.patch |