]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.15-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jan 2025 09:23:07 +0000 (10:23 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jan 2025 09:23:07 +0000 (10:23 +0100)
added patches:
mptcp-don-t-always-assume-copied-data-in-mptcp_cleanup_rbuf.patch
regmap-detach-regmap-from-dev-on-regmap_exit.patch

queue-5.15/mptcp-don-t-always-assume-copied-data-in-mptcp_cleanup_rbuf.patch [new file with mode: 0644]
queue-5.15/regmap-detach-regmap-from-dev-on-regmap_exit.patch [new file with mode: 0644]
queue-5.15/series

diff --git a/queue-5.15/mptcp-don-t-always-assume-copied-data-in-mptcp_cleanup_rbuf.patch b/queue-5.15/mptcp-don-t-always-assume-copied-data-in-mptcp_cleanup_rbuf.patch
new file mode 100644 (file)
index 0000000..9fb334e
--- /dev/null
@@ -0,0 +1,102 @@
+From 551844f26da2a9f76c0a698baaffa631d1178645 Mon Sep 17 00:00:00 2001
+From: Paolo Abeni <pabeni@redhat.com>
+Date: Mon, 30 Dec 2024 19:12:31 +0100
+Subject: mptcp: don't always assume copied data in mptcp_cleanup_rbuf()
+
+From: Paolo Abeni <pabeni@redhat.com>
+
+commit 551844f26da2a9f76c0a698baaffa631d1178645 upstream.
+
+Under some corner cases the MPTCP protocol can end-up invoking
+mptcp_cleanup_rbuf() when no data has been copied, but such helper
+assumes the opposite condition.
+
+Explicitly drop such assumption and performs the costly call only
+when strictly needed - before releasing the msk socket lock.
+
+Fixes: fd8976790a6c ("mptcp: be careful on MPTCP-level ack.")
+Cc: stable@vger.kernel.org
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Reviewed-by: Mat Martineau <martineau@kernel.org>
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Link: https://patch.msgid.link/20241230-net-mptcp-rbuf-fixes-v1-2-8608af434ceb@kernel.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+[ Conflicts in this version, because commit 581302298524 ("mptcp: error
+  out earlier on disconnect") has not been backported to this version,
+  and there was no need to do so. The only conflict was in protocol.c,
+  and easy to resolve: the context was different, but the same addition
+  can still be made at the same spot in mptcp_recvmsg(). ]
+Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/mptcp/protocol.c |   18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+--- a/net/mptcp/protocol.c
++++ b/net/mptcp/protocol.c
+@@ -462,13 +462,13 @@ static void mptcp_send_ack(struct mptcp_
+               mptcp_subflow_send_ack(mptcp_subflow_tcp_sock(subflow));
+ }
+-static void mptcp_subflow_cleanup_rbuf(struct sock *ssk)
++static void mptcp_subflow_cleanup_rbuf(struct sock *ssk, int copied)
+ {
+       bool slow;
+       slow = lock_sock_fast(ssk);
+       if (tcp_can_send_ack(ssk))
+-              tcp_cleanup_rbuf(ssk, 1);
++              tcp_cleanup_rbuf(ssk, copied);
+       unlock_sock_fast(ssk, slow);
+ }
+@@ -485,7 +485,7 @@ static bool mptcp_subflow_could_cleanup(
+                             (ICSK_ACK_PUSHED2 | ICSK_ACK_PUSHED)));
+ }
+-static void mptcp_cleanup_rbuf(struct mptcp_sock *msk)
++static void mptcp_cleanup_rbuf(struct mptcp_sock *msk, int copied)
+ {
+       int old_space = READ_ONCE(msk->old_wspace);
+       struct mptcp_subflow_context *subflow;
+@@ -493,14 +493,14 @@ static void mptcp_cleanup_rbuf(struct mp
+       int space =  __mptcp_space(sk);
+       bool cleanup, rx_empty;
+-      cleanup = (space > 0) && (space >= (old_space << 1));
+-      rx_empty = !__mptcp_rmem(sk);
++      cleanup = (space > 0) && (space >= (old_space << 1)) && copied;
++      rx_empty = !__mptcp_rmem(sk) && copied;
+       mptcp_for_each_subflow(msk, subflow) {
+               struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+               if (cleanup || mptcp_subflow_could_cleanup(ssk, rx_empty))
+-                      mptcp_subflow_cleanup_rbuf(ssk);
++                      mptcp_subflow_cleanup_rbuf(ssk, copied);
+       }
+ }
+@@ -2098,9 +2098,6 @@ static int mptcp_recvmsg(struct sock *sk
+               copied += bytes_read;
+-              /* be sure to advertise window change */
+-              mptcp_cleanup_rbuf(msk);
+-
+               if (skb_queue_empty(&msk->receive_queue) && __mptcp_move_skbs(msk))
+                       continue;
+@@ -2152,9 +2149,12 @@ static int mptcp_recvmsg(struct sock *sk
+               }
+               pr_debug("block timeout %ld\n", timeo);
++              mptcp_cleanup_rbuf(msk, copied);
+               sk_wait_data(sk, &timeo, NULL);
+       }
++      mptcp_cleanup_rbuf(msk, copied);
++
+ out_err:
+       if (cmsg_flags && copied >= 0) {
+               if (cmsg_flags & MPTCP_CMSG_TS)
diff --git a/queue-5.15/regmap-detach-regmap-from-dev-on-regmap_exit.patch b/queue-5.15/regmap-detach-regmap-from-dev-on-regmap_exit.patch
new file mode 100644 (file)
index 0000000..7a58f21
--- /dev/null
@@ -0,0 +1,62 @@
+From 3061e170381af96d1e66799d34264e6414d428a7 Mon Sep 17 00:00:00 2001
+From: Cosmin Tanislav <demonsingur@gmail.com>
+Date: Thu, 28 Nov 2024 15:16:23 +0200
+Subject: regmap: detach regmap from dev on regmap_exit
+
+From: Cosmin Tanislav <demonsingur@gmail.com>
+
+commit 3061e170381af96d1e66799d34264e6414d428a7 upstream.
+
+At the end of __regmap_init(), if dev is not NULL, regmap_attach_dev()
+is called, which adds a devres reference to the regmap, to be able to
+retrieve a dev's regmap by name using dev_get_regmap().
+
+When calling regmap_exit, the opposite does not happen, and the
+reference is kept until the dev is detached.
+
+Add a regmap_detach_dev() function and call it in regmap_exit() to make
+sure that the devres reference is not kept.
+
+Cc: stable@vger.kernel.org
+Fixes: 72b39f6f2b5a ("regmap: Implement dev_get_regmap()")
+Signed-off-by: Cosmin Tanislav <demonsingur@gmail.com>
+Rule: add
+Link: https://lore.kernel.org/stable/20241128130554.362486-1-demonsingur%40gmail.com
+Link: https://patch.msgid.link/20241128131625.363835-1-demonsingur@gmail.com
+Signed-off-by: Mark Brown <broonie@kernel.org>
+Link: https://lore.kernel.org/r/20250115033314.2540588-1-tzungbi@kernel.org
+Link: https://lore.kernel.org/r/20250115033244.2540522-1-tzungbi@kernel.org
+Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/base/regmap/regmap.c |   12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+--- a/drivers/base/regmap/regmap.c
++++ b/drivers/base/regmap/regmap.c
+@@ -663,6 +663,17 @@ int regmap_attach_dev(struct device *dev
+ }
+ EXPORT_SYMBOL_GPL(regmap_attach_dev);
++static int dev_get_regmap_match(struct device *dev, void *res, void *data);
++
++static int regmap_detach_dev(struct device *dev, struct regmap *map)
++{
++      if (!dev)
++              return 0;
++
++      return devres_release(dev, dev_get_regmap_release,
++                            dev_get_regmap_match, (void *)map->name);
++}
++
+ static enum regmap_endian regmap_get_reg_endian(const struct regmap_bus *bus,
+                                       const struct regmap_config *config)
+ {
+@@ -1531,6 +1542,7 @@ void regmap_exit(struct regmap *map)
+ {
+       struct regmap_async *async;
++      regmap_detach_dev(map->dev, map);
+       regcache_exit(map);
+       regmap_debugfs_exit(map);
+       regmap_range_exit(map);
index b119ccf01019e8be9828f699fcf6e3ac8a45a316..ea94ec6ca165fa877b7e6c36599f6220e4b8ec98 100644 (file)
@@ -4,3 +4,5 @@ seccomp-stub-for-config_seccomp.patch
 scsi-iscsi-fix-redundant-response-for-iscsi_uevent_g.patch
 irqchip-sunxi-nmi-add-missing-skip_wake-flag.patch
 asoc-samsung-add-missing-depends-on-i2c.patch
+regmap-detach-regmap-from-dev-on-regmap_exit.patch
+mptcp-don-t-always-assume-copied-data-in-mptcp_cleanup_rbuf.patch