diff options
author | Jeka | 2023-01-05 00:58:14 +0300 |
---|---|---|
committer | Jeka | 2023-01-05 00:58:14 +0300 |
commit | 6b31a18443f906049c26bbe9cb66da064b26afc0 (patch) | |
tree | 6cb9c97fcb30b0f4fe993b1d8f7ea1b31ff13b37 | |
parent | 4ba3faed80b011d09e76babb53ea74bfcb096de8 (diff) | |
download | aur-6b31a18443f906049c26bbe9cb66da064b26afc0.tar.gz |
fix patches
-rw-r--r-- | .SRCINFO | 4 | ||||
-rw-r--r-- | 0101-ZEN_Add_sysctl_and_CONFIG_to_disallow_unprivileged_CLONE_NEWUSER.patch | 42 | ||||
-rw-r--r-- | 0102-drmi915_Improve_the_catch_all-evict_to_handle_lock_contention.patch | 249 | ||||
-rw-r--r-- | PKGBUILD | 4 |
4 files changed, 275 insertions, 24 deletions
@@ -23,6 +23,7 @@ pkgbase = linux-jcore source = https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.1.3.tar.xz source = config source = 0101-ZEN_Add_sysctl_and_CONFIG_to_disallow_unprivileged_CLONE_NEWUSER.patch + source = 0102-drmi915_Improve_the_catch_all-evict_to_handle_lock_contention.patch source = 0301-revert-fbcon-remove-now-unusued-softback_lines-cursor-argument.patch source = 0302-revert-fbcon-remove-no-op-fbcon_set_origin.patch source = 0303-revert-fbcon-remove-soft-scrollback-code.patch @@ -42,7 +43,8 @@ pkgbase = linux-jcore source = 0999-acs.gitpatch sha256sums = 6dc89ae7a7513e433c597c7346ed7ff4bfd115ea43a3b5e27a6bdb38c5580317 sha256sums = 3e4cb5dbde61b7f1600255cb17859e6bf433f017e2bf30296a1d4e702973159c - sha256sums = 05f04019d4a2ee072238c32860fa80d673687d84d78ef436ae9332b6fb788467 + sha256sums = de35604b1337f3d7cd7ce8dc02a741bfdde05709f22f4dfd29d065b20b517e4c + sha256sums = 431ac870eacba9719f3e241fd3bd80573c99bb51b821029fb7a2232e862d935e sha256sums = 2b11905b63b05b25807dd64757c779da74dd4c37e36d3f7a46485b1ee5a9d326 sha256sums = 94a8538251ad148f1025cc3de446ce64f73dc32b01815426fb159c722e8fa5bc sha256sums = 50f4ccc4aeb0ffb8ec648b90a84ff188dbfed5364075cf0c6045c5696caf6ca9 diff --git a/0101-ZEN_Add_sysctl_and_CONFIG_to_disallow_unprivileged_CLONE_NEWUSER.patch b/0101-ZEN_Add_sysctl_and_CONFIG_to_disallow_unprivileged_CLONE_NEWUSER.patch index cd00074a76f0..8779cf9d3a18 100644 --- a/0101-ZEN_Add_sysctl_and_CONFIG_to_disallow_unprivileged_CLONE_NEWUSER.patch +++ b/0101-ZEN_Add_sysctl_and_CONFIG_to_disallow_unprivileged_CLONE_NEWUSER.patch @@ -1,4 +1,4 @@ -From 733ffb2a9d89395ab3124bb3ab9298a2e6f2ef21 Mon Sep 17 00:00:00 2001 +From d93b3bdc50f2d4a69e1abc900a588d6cf3b4b75b Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com> Date: Mon, 16 Sep 2019 04:53:20 +0200 Subject: [PATCH] ZEN: Add sysctl and CONFIG to disallow unprivileged @@ -14,10 +14,10 @@ Our default behavior continues to match the vanilla kernel. 5 files changed, 53 insertions(+) diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h -index 33a4240e6a6f17..82213f9c4c17fb 100644 +index 45f09bec02c485..87b20e2ee27445 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h -@@ -139,6 +139,8 @@ static inline void set_rlimit_ucount_max(struct user_namespace *ns, +@@ -148,6 +148,8 @@ static inline void set_userns_rlimit_max(struct user_namespace *ns, #ifdef CONFIG_USER_NS @@ -26,7 +26,7 @@ index 33a4240e6a6f17..82213f9c4c17fb 100644 static inline struct user_namespace *get_user_ns(struct user_namespace *ns) { if (ns) -@@ -172,6 +174,8 @@ extern bool current_in_userns(const struct user_namespace *target_ns); +@@ -181,6 +183,8 @@ extern bool current_in_userns(const struct user_namespace *target_ns); struct ns_common *ns_get_owner(struct ns_common *ns); #else @@ -36,10 +36,10 @@ index 33a4240e6a6f17..82213f9c4c17fb 100644 { return &init_user_ns; diff --git a/init/Kconfig b/init/Kconfig -index ddcbefe535e9e7..f05715cf89afa6 100644 +index 94125d3b6893c7..9f7139b536f638 100644 --- a/init/Kconfig +++ b/init/Kconfig -@@ -1235,6 +1235,22 @@ config USER_NS +@@ -1247,6 +1247,22 @@ config USER_NS If unsure, say N. @@ -63,12 +63,12 @@ index ddcbefe535e9e7..f05715cf89afa6 100644 bool "PID Namespaces" default y diff --git a/kernel/fork.c b/kernel/fork.c -index 35a3beff140b6d..b013ab5ee88fe3 100644 +index 844dfdc8c639c3..31d41db3f84d74 100644 --- a/kernel/fork.c +++ b/kernel/fork.c -@@ -99,6 +99,10 @@ +@@ -98,6 +98,10 @@ + #include <linux/io_uring.h> #include <linux/bpf.h> - #include <linux/sched/mm.h> +#ifdef CONFIG_USER_NS +#include <linux/user_namespace.h> @@ -77,7 +77,7 @@ index 35a3beff140b6d..b013ab5ee88fe3 100644 #include <asm/pgalloc.h> #include <linux/uaccess.h> #include <asm/mmu_context.h> -@@ -1992,6 +1996,10 @@ static __latent_entropy struct task_struct *copy_process( +@@ -2011,6 +2015,10 @@ static __latent_entropy struct task_struct *copy_process( if ((clone_flags & (CLONE_NEWUSER|CLONE_FS)) == (CLONE_NEWUSER|CLONE_FS)) return ERR_PTR(-EINVAL); @@ -88,7 +88,7 @@ index 35a3beff140b6d..b013ab5ee88fe3 100644 /* * Thread groups must share signals as well, and detached threads * can only be started up within the thread group. -@@ -3110,6 +3118,12 @@ int ksys_unshare(unsigned long unshare_flags) +@@ -3171,6 +3179,12 @@ int ksys_unshare(unsigned long unshare_flags) if (unshare_flags & CLONE_NEWNS) unshare_flags |= CLONE_FS; @@ -102,20 +102,20 @@ index 35a3beff140b6d..b013ab5ee88fe3 100644 if (err) goto bad_unshare_out; diff --git a/kernel/sysctl.c b/kernel/sysctl.c -index 830aaf8ca08ee0..af4c0806bd8e84 100644 +index c6d9dec11b749d..9a4514ad481b21 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c -@@ -91,6 +91,9 @@ - #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT) - #include <linux/lockdep.h> +@@ -81,6 +81,9 @@ + #ifdef CONFIG_RT_MUTEXES + #include <linux/rtmutex.h> #endif +#ifdef CONFIG_USER_NS +#include <linux/user_namespace.h> +#endif - #if defined(CONFIG_SYSCTL) - -@@ -1803,6 +1806,15 @@ static struct ctl_table kern_table[] = { + /* shared constants to be used in various sysctls */ + const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 }; +@@ -1659,6 +1662,15 @@ static struct ctl_table kern_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, @@ -132,10 +132,10 @@ index 830aaf8ca08ee0..af4c0806bd8e84 100644 { .procname = "tainted", diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c -index 5481ba44a8d684..423ab2563ad757 100644 +index 54211dbd516c57..16ca0c1516298d 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c -@@ -21,6 +21,13 @@ +@@ -22,6 +22,13 @@ #include <linux/bsearch.h> #include <linux/sort.h> @@ -148,5 +148,3 @@ index 5481ba44a8d684..423ab2563ad757 100644 + static struct kmem_cache *user_ns_cachep __read_mostly; static DEFINE_MUTEX(userns_state_mutex); - - diff --git a/0102-drmi915_Improve_the_catch_all-evict_to_handle_lock_contention.patch b/0102-drmi915_Improve_the_catch_all-evict_to_handle_lock_contention.patch new file mode 100644 index 000000000000..e4c68655db51 --- /dev/null +++ b/0102-drmi915_Improve_the_catch_all-evict_to_handle_lock_contention.patch @@ -0,0 +1,249 @@ +From e3bf21dfa982692c41ec68c656f024863b0313d2 Mon Sep 17 00:00:00 2001 +From: Matthew Auld <matthew.auld@intel.com> +Date: Tue, 6 Dec 2022 16:11:41 +0000 +Subject: [PATCH] drm/i915: improve the catch-all evict to handle lock + contention +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +The catch-all evict can fail due to object lock contention, since it +only goes as far as trylocking the object, due to us already holding the +vm->mutex. Doing a full object lock here can deadlock, since the +vm->mutex is always our inner lock. Add another execbuf pass which drops +the vm->mutex and then tries to grab the object will the full lock, +before then retrying the eviction. This should be good enough for now to +fix the immediate regression with userspace seeing -ENOSPC from execbuf +due to contended object locks during GTT eviction. + +Testcase: igt@gem_ppgtt@shrink-vs-evict-* +Fixes: 7e00897be8bf ("drm/i915: Add object locking to i915_gem_evict_for_node and i915_gem_evict_something, v2.") +References: https://gitlab.freedesktop.org/drm/intel/-/issues/7627 +References: https://gitlab.freedesktop.org/drm/intel/-/issues/7570 +References: https://bugzilla.mozilla.org/show_bug.cgi?id=1779558 +Signed-off-by: Matthew Auld <matthew.auld@intel.com> +Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> +Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> +Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> +Cc: Andrzej Hajda <andrzej.hajda@intel.com> +Cc: Mani Milani <mani@chromium.org> +Cc: <stable@vger.kernel.org> # v5.18+ + +Revision 1 of https://patchwork.freedesktop.org/series/111686/ +--- + .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 25 +++++++++++-- + drivers/gpu/drm/i915/gem/i915_gem_mman.c | 2 +- + drivers/gpu/drm/i915/i915_gem_evict.c | 37 ++++++++++++++----- + drivers/gpu/drm/i915/i915_gem_evict.h | 4 +- + drivers/gpu/drm/i915/i915_vma.c | 2 +- + .../gpu/drm/i915/selftests/i915_gem_evict.c | 4 +- + 6 files changed, 56 insertions(+), 18 deletions(-) + +diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +index 845023c14eb36f..094e92ed28db4f 100644 +--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c ++++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +@@ -741,25 +741,44 @@ static int eb_reserve(struct i915_execbuffer *eb) + * + * Defragmenting is skipped if all objects are pinned at a fixed location. + */ +- for (pass = 0; pass <= 2; pass++) { ++ for (pass = 0; pass <= 3; pass++) { + int pin_flags = PIN_USER | PIN_VALIDATE; + + if (pass == 0) + pin_flags |= PIN_NONBLOCK; + + if (pass >= 1) +- unpinned = eb_unbind(eb, pass == 2); ++ unpinned = eb_unbind(eb, pass >= 2); + + if (pass == 2) { + err = mutex_lock_interruptible(&eb->context->vm->mutex); + if (!err) { +- err = i915_gem_evict_vm(eb->context->vm, &eb->ww); ++ err = i915_gem_evict_vm(eb->context->vm, &eb->ww, NULL); + mutex_unlock(&eb->context->vm->mutex); + } + if (err) + return err; + } + ++ if (pass == 3) { ++retry: ++ err = mutex_lock_interruptible(&eb->context->vm->mutex); ++ if (!err) { ++ struct drm_i915_gem_object *busy_bo = NULL; ++ ++ err = i915_gem_evict_vm(eb->context->vm, &eb->ww, &busy_bo); ++ mutex_unlock(&eb->context->vm->mutex); ++ if (err && busy_bo) { ++ err = i915_gem_object_lock(busy_bo, &eb->ww); ++ i915_gem_object_put(busy_bo); ++ if (!err) ++ goto retry; ++ } ++ } ++ if (err) ++ return err; ++ } ++ + list_for_each_entry(ev, &eb->unbound, bind_link) { + err = eb_reserve_vma(eb, ev, pin_flags); + if (err) +diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c +index e63329bc80659c..354c1d6dab8462 100644 +--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c ++++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c +@@ -369,7 +369,7 @@ static vm_fault_t vm_fault_gtt(struct vm_fault *vmf) + if (vma == ERR_PTR(-ENOSPC)) { + ret = mutex_lock_interruptible(&ggtt->vm.mutex); + if (!ret) { +- ret = i915_gem_evict_vm(&ggtt->vm, &ww); ++ ret = i915_gem_evict_vm(&ggtt->vm, &ww, NULL); + mutex_unlock(&ggtt->vm.mutex); + } + if (ret) +diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c +index f025ee4fa52618..a4b4d9b7d26c7a 100644 +--- a/drivers/gpu/drm/i915/i915_gem_evict.c ++++ b/drivers/gpu/drm/i915/i915_gem_evict.c +@@ -416,6 +416,11 @@ int i915_gem_evict_for_node(struct i915_address_space *vm, + * @vm: Address space to cleanse + * @ww: An optional struct i915_gem_ww_ctx. If not NULL, i915_gem_evict_vm + * will be able to evict vma's locked by the ww as well. ++ * @busy_bo: Optional pointer to struct drm_i915_gem_object. If not NULL, then ++ * in the event i915_gem_evict_vm() is unable to trylock an object for eviction, ++ * then @busy_bo will point to it. -EBUSY is also returned. The caller must drop ++ * the vm->mutex, before trying again to acquire the contended lock. The caller ++ * also owns a reference to the object. + * + * This function evicts all vmas from a vm. + * +@@ -425,7 +430,8 @@ int i915_gem_evict_for_node(struct i915_address_space *vm, + * To clarify: This is for freeing up virtual address space, not for freeing + * memory in e.g. the shrinker. + */ +-int i915_gem_evict_vm(struct i915_address_space *vm, struct i915_gem_ww_ctx *ww) ++int i915_gem_evict_vm(struct i915_address_space *vm, struct i915_gem_ww_ctx *ww, ++ struct drm_i915_gem_object **busy_bo) + { + int ret = 0; + +@@ -457,15 +463,22 @@ int i915_gem_evict_vm(struct i915_address_space *vm, struct i915_gem_ww_ctx *ww) + * the resv is shared among multiple objects, we still + * need the object ref. + */ +- if (dying_vma(vma) || ++ if (!i915_gem_object_get_rcu(vma->obj) || + (ww && (dma_resv_locking_ctx(vma->obj->base.resv) == &ww->ctx))) { + __i915_vma_pin(vma); + list_add(&vma->evict_link, &locked_eviction_list); + continue; + } + +- if (!i915_gem_object_trylock(vma->obj, ww)) ++ if (!i915_gem_object_trylock(vma->obj, ww)) { ++ if (busy_bo) { ++ *busy_bo = vma->obj; /* holds ref */ ++ ret = -EBUSY; ++ break; ++ } ++ i915_gem_object_put(vma->obj); + continue; ++ } + + __i915_vma_pin(vma); + list_add(&vma->evict_link, &eviction_list); +@@ -473,25 +486,29 @@ int i915_gem_evict_vm(struct i915_address_space *vm, struct i915_gem_ww_ctx *ww) + if (list_empty(&eviction_list) && list_empty(&locked_eviction_list)) + break; + +- ret = 0; + /* Unbind locked objects first, before unlocking the eviction_list */ + list_for_each_entry_safe(vma, vn, &locked_eviction_list, evict_link) { + __i915_vma_unpin(vma); + +- if (ret == 0) ++ if (ret == 0) { + ret = __i915_vma_unbind(vma); +- if (ret != -EINTR) /* "Get me out of here!" */ +- ret = 0; ++ if (ret != -EINTR) /* "Get me out of here!" */ ++ ret = 0; ++ } ++ if (!dying_vma(vma)) ++ i915_gem_object_put(vma->obj); + } + + list_for_each_entry_safe(vma, vn, &eviction_list, evict_link) { + __i915_vma_unpin(vma); +- if (ret == 0) ++ if (ret == 0) { + ret = __i915_vma_unbind(vma); +- if (ret != -EINTR) /* "Get me out of here!" */ +- ret = 0; ++ if (ret != -EINTR) /* "Get me out of here!" */ ++ ret = 0; ++ } + + i915_gem_object_unlock(vma->obj); ++ i915_gem_object_put(vma->obj); + } + } while (ret == 0); + +diff --git a/drivers/gpu/drm/i915/i915_gem_evict.h b/drivers/gpu/drm/i915/i915_gem_evict.h +index e593c530f9bd7a..bf0ee0e4fe6088 100644 +--- a/drivers/gpu/drm/i915/i915_gem_evict.h ++++ b/drivers/gpu/drm/i915/i915_gem_evict.h +@@ -11,6 +11,7 @@ + struct drm_mm_node; + struct i915_address_space; + struct i915_gem_ww_ctx; ++struct drm_i915_gem_object; + + int __must_check i915_gem_evict_something(struct i915_address_space *vm, + struct i915_gem_ww_ctx *ww, +@@ -23,6 +24,7 @@ int __must_check i915_gem_evict_for_node(struct i915_address_space *vm, + struct drm_mm_node *node, + unsigned int flags); + int i915_gem_evict_vm(struct i915_address_space *vm, +- struct i915_gem_ww_ctx *ww); ++ struct i915_gem_ww_ctx *ww, ++ struct drm_i915_gem_object **busy_bo); + + #endif /* __I915_GEM_EVICT_H__ */ +diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c +index f17c09ead7d778..4d06875de14a14 100644 +--- a/drivers/gpu/drm/i915/i915_vma.c ++++ b/drivers/gpu/drm/i915/i915_vma.c +@@ -1569,7 +1569,7 @@ static int __i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww, + * locked objects when called from execbuf when pinning + * is removed. This would probably regress badly. + */ +- i915_gem_evict_vm(vm, NULL); ++ i915_gem_evict_vm(vm, NULL, NULL); + mutex_unlock(&vm->mutex); + } + } while (1); +diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c +index 8c6517d29b8e0c..37068542aafe7f 100644 +--- a/drivers/gpu/drm/i915/selftests/i915_gem_evict.c ++++ b/drivers/gpu/drm/i915/selftests/i915_gem_evict.c +@@ -344,7 +344,7 @@ static int igt_evict_vm(void *arg) + + /* Everything is pinned, nothing should happen */ + mutex_lock(&ggtt->vm.mutex); +- err = i915_gem_evict_vm(&ggtt->vm, NULL); ++ err = i915_gem_evict_vm(&ggtt->vm, NULL, NULL); + mutex_unlock(&ggtt->vm.mutex); + if (err) { + pr_err("i915_gem_evict_vm on a full GGTT returned err=%d]\n", +@@ -356,7 +356,7 @@ static int igt_evict_vm(void *arg) + + for_i915_gem_ww(&ww, err, false) { + mutex_lock(&ggtt->vm.mutex); +- err = i915_gem_evict_vm(&ggtt->vm, &ww); ++ err = i915_gem_evict_vm(&ggtt->vm, &ww, NULL); + mutex_unlock(&ggtt->vm.mutex); + } @@ -26,6 +26,7 @@ source=("https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-$pkgver.tar.xz" 'config' # ARCH Patches '0101-ZEN_Add_sysctl_and_CONFIG_to_disallow_unprivileged_CLONE_NEWUSER.patch' + '0102-drmi915_Improve_the_catch_all-evict_to_handle_lock_contention.patch' # MANJARO Patches # Bootsplash @@ -49,7 +50,8 @@ source=("https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-$pkgver.tar.xz" '0999-acs.gitpatch') sha256sums=('6dc89ae7a7513e433c597c7346ed7ff4bfd115ea43a3b5e27a6bdb38c5580317' '3e4cb5dbde61b7f1600255cb17859e6bf433f017e2bf30296a1d4e702973159c' - '05f04019d4a2ee072238c32860fa80d673687d84d78ef436ae9332b6fb788467' + 'de35604b1337f3d7cd7ce8dc02a741bfdde05709f22f4dfd29d065b20b517e4c' + '431ac870eacba9719f3e241fd3bd80573c99bb51b821029fb7a2232e862d935e' '2b11905b63b05b25807dd64757c779da74dd4c37e36d3f7a46485b1ee5a9d326' '94a8538251ad148f1025cc3de446ce64f73dc32b01815426fb159c722e8fa5bc' '50f4ccc4aeb0ffb8ec648b90a84ff188dbfed5364075cf0c6045c5696caf6ca9' |