From e3840cf31625925af574e38cf5a8841fb51a6648 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Fri, 12 May 2023 04:16:21 +0200 Subject: [PATCH 1/2] linux: patch to fix MAP_32BIT crashes, e.g. Haskell (cherry picked from commit 17d26e4c7fc1ab8697d63523daf2d2742f432d2a) --- pkgs/os-specific/linux/kernel/patches.nix | 9 +++++++++ pkgs/top-level/linux-kernels.nix | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix index f2225096dd5c..3a76ed2d0882 100644 --- a/pkgs/os-specific/linux/kernel/patches.nix +++ b/pkgs/os-specific/linux/kernel/patches.nix @@ -58,6 +58,15 @@ patch = ./export-rt-sched-migrate.patch; }; + make-maple-state-reusable-after-mas_empty_area = rec { + name = "make-maple-state-reusable-after-mas_empty_area"; + patch = fetchpatch { + name = name + ".patch"; + url = "https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/patch/?id=39bf07d812b888b23983a9443ad967ca9b61551d"; + hash = "sha256-JHEFq+Gw8Dtl0M8pXcKXpwkaHhbbl5NwTSzvV5qP4hk="; + }; + }; + fix-em-ice-bonding = { name = "fix-em-ice-bonding"; patch = ./fix-em-ice-bonding.patch; diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix index dacbbd44208d..0a562f07b046 100644 --- a/pkgs/top-level/linux-kernels.nix +++ b/pkgs/top-level/linux-kernels.nix @@ -168,6 +168,7 @@ in { kernelPatches = [ kernelPatches.bridge_stp_helper kernelPatches.request_key_helper + kernelPatches.make-maple-state-reusable-after-mas_empty_area kernelPatches.fix-em-ice-bonding kernelPatches.CVE-2023-32233 ]; @@ -177,6 +178,7 @@ in { kernelPatches = [ kernelPatches.bridge_stp_helper kernelPatches.request_key_helper + kernelPatches.make-maple-state-reusable-after-mas_empty_area kernelPatches.fix-em-ice-bonding kernelPatches.CVE-2023-32233 ]; @@ -186,6 +188,7 @@ in { kernelPatches = [ kernelPatches.bridge_stp_helper kernelPatches.request_key_helper + kernelPatches.make-maple-state-reusable-after-mas_empty_area kernelPatches.fix-em-ice-bonding kernelPatches.CVE-2023-32233 ]; @@ -196,6 +199,7 @@ in { kernelPatches = [ kernelPatches.bridge_stp_helper kernelPatches.request_key_helper + kernelPatches.make-maple-state-reusable-after-mas_empty_area ]; }; latest = packageAliases.linux_latest.kernel; From bbea464886951f2987501fa095dff2708c2a64d0 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 15 May 2023 20:29:07 +0200 Subject: [PATCH 2/2] pkgs/linux: Vendor maple tree patch Fetching from a maintainer tree can be unreliable as commits or even repos may be removed. (cherry picked from commit 81bc5f3db8f9ba812836036d5d3e54e933ca2cd6) --- ...-state-reusable-after-mas_empty_area.patch | 21 +++++++++++++++++++ pkgs/os-specific/linux/kernel/patches.nix | 9 +++----- 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 pkgs/os-specific/linux/kernel/make-maple-state-reusable-after-mas_empty_area.patch diff --git a/pkgs/os-specific/linux/kernel/make-maple-state-reusable-after-mas_empty_area.patch b/pkgs/os-specific/linux/kernel/make-maple-state-reusable-after-mas_empty_area.patch new file mode 100644 index 000000000000..47e1bbbd5a68 --- /dev/null +++ b/pkgs/os-specific/linux/kernel/make-maple-state-reusable-after-mas_empty_area.patch @@ -0,0 +1,21 @@ +--- a/lib/maple_tree.c ++++ b/lib/maple_tree.c +@@ -5317,15 +5317,9 @@ + + mt = mte_node_type(mas->node); + pivots = ma_pivots(mas_mn(mas), mt); +- if (offset) +- mas->min = pivots[offset - 1] + 1; +- +- if (offset < mt_pivots[mt]) +- mas->max = pivots[offset]; +- +- if (mas->index < mas->min) +- mas->index = mas->min; +- ++ min = mas_safe_min(mas, pivots, offset); ++ if (mas->index < min) ++ mas->index = min; + mas->last = mas->index + size - 1; + return 0; + } diff --git a/pkgs/os-specific/linux/kernel/patches.nix b/pkgs/os-specific/linux/kernel/patches.nix index 3a76ed2d0882..2330db4e68c3 100644 --- a/pkgs/os-specific/linux/kernel/patches.nix +++ b/pkgs/os-specific/linux/kernel/patches.nix @@ -58,13 +58,10 @@ patch = ./export-rt-sched-migrate.patch; }; - make-maple-state-reusable-after-mas_empty_area = rec { + # https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/patch/?id=39bf07d812b888b23983a9443ad967ca9b61551d + make-maple-state-reusable-after-mas_empty_area = { name = "make-maple-state-reusable-after-mas_empty_area"; - patch = fetchpatch { - name = name + ".patch"; - url = "https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git/patch/?id=39bf07d812b888b23983a9443ad967ca9b61551d"; - hash = "sha256-JHEFq+Gw8Dtl0M8pXcKXpwkaHhbbl5NwTSzvV5qP4hk="; - }; + patch = ./make-maple-state-reusable-after-mas_empty_area.patch; }; fix-em-ice-bonding = {