]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Jan 2025 16:32:36 +0000 (17:32 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Jan 2025 16:32:36 +0000 (17:32 +0100)
added patches:
dm-thin-make-get_first_thin-use-rcu-safe-list-first-function.patch
drm-amd-display-add-check-for-granularity-in-dml-ceil-floor-helpers.patch
sctp-sysctl-auth_enable-avoid-using-current-nsproxy.patch
sctp-sysctl-cookie_hmac_alg-avoid-using-current-nsproxy.patch

queue-5.4/dm-thin-make-get_first_thin-use-rcu-safe-list-first-function.patch [new file with mode: 0644]
queue-5.4/drm-amd-display-add-check-for-granularity-in-dml-ceil-floor-helpers.patch [new file with mode: 0644]
queue-5.4/sctp-sysctl-auth_enable-avoid-using-current-nsproxy.patch [new file with mode: 0644]
queue-5.4/sctp-sysctl-cookie_hmac_alg-avoid-using-current-nsproxy.patch [new file with mode: 0644]
queue-5.4/series

diff --git a/queue-5.4/dm-thin-make-get_first_thin-use-rcu-safe-list-first-function.patch b/queue-5.4/dm-thin-make-get_first_thin-use-rcu-safe-list-first-function.patch
new file mode 100644 (file)
index 0000000..2751755
--- /dev/null
@@ -0,0 +1,64 @@
+From 80f130bfad1dab93b95683fc39b87235682b8f72 Mon Sep 17 00:00:00 2001
+From: Krister Johansen <kjlx@templeofstupid.com>
+Date: Tue, 7 Jan 2025 15:24:58 -0800
+Subject: dm thin: make get_first_thin use rcu-safe list first function
+
+From: Krister Johansen <kjlx@templeofstupid.com>
+
+commit 80f130bfad1dab93b95683fc39b87235682b8f72 upstream.
+
+The documentation in rculist.h explains the absence of list_empty_rcu()
+and cautions programmers against relying on a list_empty() ->
+list_first() sequence in RCU safe code.  This is because each of these
+functions performs its own READ_ONCE() of the list head.  This can lead
+to a situation where the list_empty() sees a valid list entry, but the
+subsequent list_first() sees a different view of list head state after a
+modification.
+
+In the case of dm-thin, this author had a production box crash from a GP
+fault in the process_deferred_bios path.  This function saw a valid list
+head in get_first_thin() but when it subsequently dereferenced that and
+turned it into a thin_c, it got the inside of the struct pool, since the
+list was now empty and referring to itself.  The kernel on which this
+occurred printed both a warning about a refcount_t being saturated, and
+a UBSAN error for an out-of-bounds cpuid access in the queued spinlock,
+prior to the fault itself.  When the resulting kdump was examined, it
+was possible to see another thread patiently waiting in thin_dtr's
+synchronize_rcu.
+
+The thin_dtr call managed to pull the thin_c out of the active thins
+list (and have it be the last entry in the active_thins list) at just
+the wrong moment which lead to this crash.
+
+Fortunately, the fix here is straight forward.  Switch get_first_thin()
+function to use list_first_or_null_rcu() which performs just a single
+READ_ONCE() and returns NULL if the list is already empty.
+
+This was run against the devicemapper test suite's thin-provisioning
+suites for delete and suspend and no regressions were observed.
+
+Signed-off-by: Krister Johansen <kjlx@templeofstupid.com>
+Fixes: b10ebd34ccca ("dm thin: fix rcu_read_lock being held in code that can sleep")
+Cc: stable@vger.kernel.org
+Acked-by: Ming-Hung Tsai <mtsai@redhat.com>
+Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/md/dm-thin.c |    5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+--- a/drivers/md/dm-thin.c
++++ b/drivers/md/dm-thin.c
+@@ -2325,10 +2325,9 @@ static struct thin_c *get_first_thin(str
+       struct thin_c *tc = NULL;
+       rcu_read_lock();
+-      if (!list_empty(&pool->active_thins)) {
+-              tc = list_entry_rcu(pool->active_thins.next, struct thin_c, list);
++      tc = list_first_or_null_rcu(&pool->active_thins, struct thin_c, list);
++      if (tc)
+               thin_get(tc);
+-      }
+       rcu_read_unlock();
+       return tc;
diff --git a/queue-5.4/drm-amd-display-add-check-for-granularity-in-dml-ceil-floor-helpers.patch b/queue-5.4/drm-amd-display-add-check-for-granularity-in-dml-ceil-floor-helpers.patch
new file mode 100644 (file)
index 0000000..6f520f5
--- /dev/null
@@ -0,0 +1,63 @@
+From 0881fbc4fd62e00a2b8e102725f76d10351b2ea8 Mon Sep 17 00:00:00 2001
+From: Roman Li <Roman.Li@amd.com>
+Date: Fri, 13 Dec 2024 13:51:07 -0500
+Subject: drm/amd/display: Add check for granularity in dml ceil/floor helpers
+
+From: Roman Li <Roman.Li@amd.com>
+
+commit 0881fbc4fd62e00a2b8e102725f76d10351b2ea8 upstream.
+
+[Why]
+Wrapper functions for dcn_bw_ceil2() and dcn_bw_floor2()
+should check for granularity is non zero to avoid assert and
+divide-by-zero error in dcn_bw_ functions.
+
+[How]
+Add check for granularity 0.
+
+Cc: Mario Limonciello <mario.limonciello@amd.com>
+Reviewed-by: Alvin Lee <alvin.lee2@amd.com>
+Signed-off-by: Roman Li <Roman.Li@amd.com>
+Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
+Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
+(cherry picked from commit f6e09701c3eb2ccb8cb0518e0b67f1c69742a4ec)
+Cc: stable@vger.kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h |    8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+--- a/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
++++ b/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h
+@@ -67,11 +67,15 @@ static inline double dml_max5(double a,
+ static inline double dml_ceil(double a, double granularity)
+ {
++      if (granularity == 0)
++              return 0;
+       return (double) dcn_bw_ceil2(a, granularity);
+ }
+ static inline double dml_floor(double a, double granularity)
+ {
++      if (granularity == 0)
++              return 0;
+       return (double) dcn_bw_floor2(a, granularity);
+ }
+@@ -97,11 +101,15 @@ static inline double dml_ceil_2(double f
+ static inline double dml_ceil_ex(double x, double granularity)
+ {
++      if (granularity == 0)
++              return 0;
+       return (double) dcn_bw_ceil2(x, granularity);
+ }
+ static inline double dml_floor_ex(double x, double granularity)
+ {
++      if (granularity == 0)
++              return 0;
+       return (double) dcn_bw_floor2(x, granularity);
+ }
diff --git a/queue-5.4/sctp-sysctl-auth_enable-avoid-using-current-nsproxy.patch b/queue-5.4/sctp-sysctl-auth_enable-avoid-using-current-nsproxy.patch
new file mode 100644 (file)
index 0000000..e292d1a
--- /dev/null
@@ -0,0 +1,49 @@
+From 15649fd5415eda664ef35780c2013adeb5d9c695 Mon Sep 17 00:00:00 2001
+From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
+Date: Wed, 8 Jan 2025 16:34:34 +0100
+Subject: sctp: sysctl: auth_enable: avoid using current->nsproxy
+
+From: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+
+commit 15649fd5415eda664ef35780c2013adeb5d9c695 upstream.
+
+As mentioned in a previous commit of this series, using the 'net'
+structure via 'current' is not recommended for different reasons:
+
+- Inconsistency: getting info from the reader's/writer's netns vs only
+  from the opener's netns.
+
+- current->nsproxy can be NULL in some cases, resulting in an 'Oops'
+  (null-ptr-deref), e.g. when the current task is exiting, as spotted by
+  syzbot [1] using acct(2).
+
+The 'net' structure can be obtained from the table->data using
+container_of().
+
+Note that table->data could also be used directly, but that would
+increase the size of this fix, while 'sctp.ctl_sock' still needs to be
+retrieved from 'net' structure.
+
+Fixes: b14878ccb7fa ("net: sctp: cache auth_enable per endpoint")
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/67769ecb.050a0220.3a8527.003f.GAE@google.com [1]
+Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Link: https://patch.msgid.link/20250108-net-sysctl-current-nsproxy-v1-6-5df34b2083e8@kernel.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/sctp/sysctl.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/net/sctp/sysctl.c
++++ b/net/sctp/sysctl.c
+@@ -326,7 +326,7 @@ static int proc_sctp_do_hmac_alg(struct
+                               void __user *buffer, size_t *lenp,
+                               loff_t *ppos)
+ {
+-      struct net *net = current->nsproxy->net_ns;
++      struct net *net = container_of(ctl->data, struct net, sctp.auth_enable);
+       struct ctl_table tbl;
+       bool changed = false;
+       char *none = "none";
diff --git a/queue-5.4/sctp-sysctl-cookie_hmac_alg-avoid-using-current-nsproxy.patch b/queue-5.4/sctp-sysctl-cookie_hmac_alg-avoid-using-current-nsproxy.patch
new file mode 100644 (file)
index 0000000..c8a9b5e
--- /dev/null
@@ -0,0 +1,51 @@
+From ea62dd1383913b5999f3d16ae99d411f41b528d4 Mon Sep 17 00:00:00 2001
+From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
+Date: Wed, 8 Jan 2025 16:34:32 +0100
+Subject: sctp: sysctl: cookie_hmac_alg: avoid using current->nsproxy
+
+From: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+
+commit ea62dd1383913b5999f3d16ae99d411f41b528d4 upstream.
+
+As mentioned in a previous commit of this series, using the 'net'
+structure via 'current' is not recommended for different reasons:
+
+- Inconsistency: getting info from the reader's/writer's netns vs only
+  from the opener's netns.
+
+- current->nsproxy can be NULL in some cases, resulting in an 'Oops'
+  (null-ptr-deref), e.g. when the current task is exiting, as spotted by
+  syzbot [1] using acct(2).
+
+The 'net' structure can be obtained from the table->data using
+container_of().
+
+Note that table->data could also be used directly, as this is the only
+member needed from the 'net' structure, but that would increase the size
+of this fix, to use '*data' everywhere 'net->sctp.sctp_hmac_alg' is
+used.
+
+Fixes: 3c68198e7511 ("sctp: Make hmac algorithm selection for cookie generation dynamic")
+Cc: stable@vger.kernel.org
+Link: https://lore.kernel.org/67769ecb.050a0220.3a8527.003f.GAE@google.com [1]
+Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Link: https://patch.msgid.link/20250108-net-sysctl-current-nsproxy-v1-4-5df34b2083e8@kernel.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/sctp/sysctl.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/net/sctp/sysctl.c
++++ b/net/sctp/sysctl.c
+@@ -441,7 +441,8 @@ static int proc_sctp_do_auth(struct ctl_
+                            void __user *buffer, size_t *lenp,
+                            loff_t *ppos)
+ {
+-      struct net *net = current->nsproxy->net_ns;
++      struct net *net = container_of(ctl->data, struct net,
++                                     sctp.sctp_hmac_alg);
+       struct ctl_table tbl;
+       int new_value, ret;
index 91e2deaafe8e511f07100ebe26cdd9cb8ff16e77..c3abc7023cd31416ad2ddb31aec6ce4359b28f5c 100644 (file)
@@ -8,3 +8,7 @@ tcp-dccp-complete-lockless-accesses-to-sk-sk_max_ack.patch
 tcp-dccp-allow-a-connection-when-sk_max_ack_backlog-.patch
 net_sched-cls_flow-validate-tca_flow_rshift-attribut.patch
 tls-fix-tls_sw_sendmsg-error-handling.patch
+dm-thin-make-get_first_thin-use-rcu-safe-list-first-function.patch
+sctp-sysctl-cookie_hmac_alg-avoid-using-current-nsproxy.patch
+sctp-sysctl-auth_enable-avoid-using-current-nsproxy.patch
+drm-amd-display-add-check-for-granularity-in-dml-ceil-floor-helpers.patch