]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Jul 2023 06:31:04 +0000 (08:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Jul 2023 06:31:04 +0000 (08:31 +0200)
added patches:
drm-ttm-fix-bulk_move-corruption-when-adding-a-entry.patch
kbuild-rust-avoid-creating-temporary-files.patch
tracing-histograms-return-an-error-if-we-fail-to-add-histogram-to-hist_vars-list.patch

queue-6.4/drm-ttm-fix-bulk_move-corruption-when-adding-a-entry.patch [new file with mode: 0644]
queue-6.4/kbuild-rust-avoid-creating-temporary-files.patch [new file with mode: 0644]
queue-6.4/series
queue-6.4/tracing-histograms-return-an-error-if-we-fail-to-add-histogram-to-hist_vars-list.patch [new file with mode: 0644]

diff --git a/queue-6.4/drm-ttm-fix-bulk_move-corruption-when-adding-a-entry.patch b/queue-6.4/drm-ttm-fix-bulk_move-corruption-when-adding-a-entry.patch
new file mode 100644 (file)
index 0000000..ec7d02a
--- /dev/null
@@ -0,0 +1,49 @@
+From 4481913607e58196c48a4fef5e6f45350684ec3c Mon Sep 17 00:00:00 2001
+From: Yunxiang Li <Yunxiang.Li@amd.com>
+Date: Thu, 22 Jun 2023 10:18:03 -0400
+Subject: drm/ttm: fix bulk_move corruption when adding a entry
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Yunxiang Li <Yunxiang.Li@amd.com>
+
+commit 4481913607e58196c48a4fef5e6f45350684ec3c upstream.
+
+When the resource is the first in the bulk_move range, adding it again
+(thus moving it to the tail) will corrupt the list since the first
+pointer is not moved. This eventually lead to null pointer deref in
+ttm_lru_bulk_move_del()
+
+Fixes: fee2ede15542 ("drm/ttm: rework bulk move handling v5")
+Signed-off-by: Yunxiang Li <Yunxiang.Li@amd.com>
+Reviewed-by: Christian König <christian.koenig@amd.com>
+CC: stable@vger.kernel.org
+Link: https://patchwork.freedesktop.org/patch/msgid/20230622141902.28718-3-Yunxiang.Li@amd.com
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/ttm/ttm_resource.c |    5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/drivers/gpu/drm/ttm/ttm_resource.c
++++ b/drivers/gpu/drm/ttm/ttm_resource.c
+@@ -86,6 +86,8 @@ static void ttm_lru_bulk_move_pos_tail(s
+                                      struct ttm_resource *res)
+ {
+       if (pos->last != res) {
++              if (pos->first == res)
++                      pos->first = list_next_entry(res, lru);
+               list_move(&res->lru, &pos->last->lru);
+               pos->last = res;
+       }
+@@ -111,7 +113,8 @@ static void ttm_lru_bulk_move_del(struct
+ {
+       struct ttm_lru_bulk_move_pos *pos = ttm_lru_bulk_move_pos(bulk, res);
+-      if (unlikely(pos->first == res && pos->last == res)) {
++      if (unlikely(WARN_ON(!pos->first || !pos->last) ||
++                   (pos->first == res && pos->last == res))) {
+               pos->first = NULL;
+               pos->last = NULL;
+       } else if (pos->first == res) {
diff --git a/queue-6.4/kbuild-rust-avoid-creating-temporary-files.patch b/queue-6.4/kbuild-rust-avoid-creating-temporary-files.patch
new file mode 100644 (file)
index 0000000..8780702
--- /dev/null
@@ -0,0 +1,74 @@
+From df01b7cfcef08bf3fdcac2909d0e1910781d6bfd Mon Sep 17 00:00:00 2001
+From: Miguel Ojeda <ojeda@kernel.org>
+Date: Sun, 23 Jul 2023 16:21:28 +0200
+Subject: kbuild: rust: avoid creating temporary files
+
+From: Miguel Ojeda <ojeda@kernel.org>
+
+commit df01b7cfcef08bf3fdcac2909d0e1910781d6bfd upstream.
+
+`rustc` outputs by default the temporary files (i.e. the ones saved
+by `-Csave-temps`, such as `*.rcgu*` files) in the current working
+directory when `-o` and `--out-dir` are not given (even if
+`--emit=x=path` is given, i.e. it does not use those for temporaries).
+
+Since out-of-tree modules are compiled from the `linux` tree,
+`rustc` then tries to create them there, which may not be accessible.
+
+Thus pass `--out-dir` explicitly, even if it is just for the temporary
+files.
+
+Similarly, do so for Rust host programs too.
+
+Reported-by: Raphael Nestler <raphael.nestler@gmail.com>
+Closes: https://github.com/Rust-for-Linux/linux/issues/1015
+Reported-by: Andrea Righi <andrea.righi@canonical.com>
+Tested-by: Raphael Nestler <raphael.nestler@gmail.com> # non-hostprogs
+Tested-by: Andrea Righi <andrea.righi@canonical.com> # non-hostprogs
+Fixes: 295d8398c67e ("kbuild: specify output names separately for each emission type from rustc")
+Cc: stable@vger.kernel.org
+Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
+Tested-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
+Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ scripts/Makefile.build |    5 ++++-
+ scripts/Makefile.host  |    6 +++++-
+ 2 files changed, 9 insertions(+), 2 deletions(-)
+
+--- a/scripts/Makefile.build
++++ b/scripts/Makefile.build
+@@ -279,6 +279,9 @@ $(obj)/%.lst: $(src)/%.c FORCE
+ rust_allowed_features := core_ffi_c,explicit_generic_args_with_impl_trait,new_uninit,pin_macro
++# `--out-dir` is required to avoid temporaries being created by `rustc` in the
++# current working directory, which may be not accessible in the out-of-tree
++# modules case.
+ rust_common_cmd = \
+       RUST_MODFILE=$(modfile) $(RUSTC_OR_CLIPPY) $(rust_flags) \
+       -Zallow-features=$(rust_allowed_features) \
+@@ -287,7 +290,7 @@ rust_common_cmd = \
+       --extern alloc --extern kernel \
+       --crate-type rlib -L $(objtree)/rust/ \
+       --crate-name $(basename $(notdir $@)) \
+-      --emit=dep-info=$(depfile)
++      --out-dir $(dir $@) --emit=dep-info=$(depfile)
+ # `--emit=obj`, `--emit=asm` and `--emit=llvm-ir` imply a single codegen unit
+ # will be used. We explicitly request `-Ccodegen-units=1` in any case, and
+--- a/scripts/Makefile.host
++++ b/scripts/Makefile.host
+@@ -86,7 +86,11 @@ hostc_flags    = -Wp,-MMD,$(depfile) \
+ hostcxx_flags  = -Wp,-MMD,$(depfile) \
+                  $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
+                  $(HOSTCXXFLAGS_$(target-stem).o)
+-hostrust_flags = --emit=dep-info=$(depfile) \
++
++# `--out-dir` is required to avoid temporaries being created by `rustc` in the
++# current working directory, which may be not accessible in the out-of-tree
++# modules case.
++hostrust_flags = --out-dir $(dir $@) --emit=dep-info=$(depfile) \
+                  $(KBUILD_HOSTRUSTFLAGS) $(HOST_EXTRARUSTFLAGS) \
+                  $(HOSTRUSTFLAGS_$(target-stem))
index 7469d103fa071016a86dd9cc487763b155721368..62f2826a89bc6731042bb63aa1e7ba763175d434 100644 (file)
@@ -218,3 +218,6 @@ tcp-annotate-data-races-around-icsk-icsk_user_timeou.patch
 tcp-annotate-data-races-around-fastopenq.max_qlen.patch
 net-phy-prevent-stale-pointer-dereference-in-phy_ini.patch
 jbd2-recheck-chechpointing-non-dirty-buffer.patch
+kbuild-rust-avoid-creating-temporary-files.patch
+tracing-histograms-return-an-error-if-we-fail-to-add-histogram-to-hist_vars-list.patch
+drm-ttm-fix-bulk_move-corruption-when-adding-a-entry.patch
diff --git a/queue-6.4/tracing-histograms-return-an-error-if-we-fail-to-add-histogram-to-hist_vars-list.patch b/queue-6.4/tracing-histograms-return-an-error-if-we-fail-to-add-histogram-to-hist_vars-list.patch
new file mode 100644 (file)
index 0000000..7db4ebf
--- /dev/null
@@ -0,0 +1,38 @@
+From 4b8b3905165ef98386a3c06f196c85d21292d029 Mon Sep 17 00:00:00 2001
+From: Mohamed Khalfella <mkhalfella@purestorage.com>
+Date: Fri, 14 Jul 2023 20:33:41 +0000
+Subject: tracing/histograms: Return an error if we fail to add histogram to hist_vars list
+
+From: Mohamed Khalfella <mkhalfella@purestorage.com>
+
+commit 4b8b3905165ef98386a3c06f196c85d21292d029 upstream.
+
+Commit 6018b585e8c6 ("tracing/histograms: Add histograms to hist_vars if
+they have referenced variables") added a check to fail histogram creation
+if save_hist_vars() failed to add histogram to hist_vars list. But the
+commit failed to set ret to failed return code before jumping to
+unregister histogram, fix it.
+
+Link: https://lore.kernel.org/linux-trace-kernel/20230714203341.51396-1-mkhalfella@purestorage.com
+
+Cc: stable@vger.kernel.org
+Fixes: 6018b585e8c6 ("tracing/histograms: Add histograms to hist_vars if they have referenced variables")
+Signed-off-by: Mohamed Khalfella <mkhalfella@purestorage.com>
+Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/trace/trace_events_hist.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/kernel/trace/trace_events_hist.c
++++ b/kernel/trace/trace_events_hist.c
+@@ -6668,7 +6668,8 @@ static int event_hist_trigger_parse(stru
+               goto out_unreg;
+       if (has_hist_vars(hist_data) || hist_data->n_var_refs) {
+-              if (save_hist_vars(hist_data))
++              ret = save_hist_vars(hist_data);
++              if (ret)
+                       goto out_unreg;
+       }