From: Greg Kroah-Hartman Date: Wed, 29 Jan 2025 09:23:07 +0000 (+0100) Subject: 5.15-stable patches X-Git-Tag: v6.13.1~42 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=de332bf098571424cc5763b2ce5268a414542d96;p=thirdparty%2Fkernel%2Fstable-queue.git 5.15-stable patches added patches: mptcp-don-t-always-assume-copied-data-in-mptcp_cleanup_rbuf.patch regmap-detach-regmap-from-dev-on-regmap_exit.patch --- 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 index 0000000000..9fb334e739 --- /dev/null +++ b/queue-5.15/mptcp-don-t-always-assume-copied-data-in-mptcp_cleanup_rbuf.patch @@ -0,0 +1,102 @@ +From 551844f26da2a9f76c0a698baaffa631d1178645 Mon Sep 17 00:00:00 2001 +From: Paolo Abeni +Date: Mon, 30 Dec 2024 19:12:31 +0100 +Subject: mptcp: don't always assume copied data in mptcp_cleanup_rbuf() + +From: Paolo Abeni + +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 +Reviewed-by: Mat Martineau +Signed-off-by: Matthieu Baerts (NGI0) +Link: https://patch.msgid.link/20241230-net-mptcp-rbuf-fixes-v1-2-8608af434ceb@kernel.org +Signed-off-by: Jakub Kicinski +[ 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) +Signed-off-by: Greg Kroah-Hartman +--- + 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 index 0000000000..7a58f2152e --- /dev/null +++ b/queue-5.15/regmap-detach-regmap-from-dev-on-regmap_exit.patch @@ -0,0 +1,62 @@ +From 3061e170381af96d1e66799d34264e6414d428a7 Mon Sep 17 00:00:00 2001 +From: Cosmin Tanislav +Date: Thu, 28 Nov 2024 15:16:23 +0200 +Subject: regmap: detach regmap from dev on regmap_exit + +From: Cosmin Tanislav + +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 +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 +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 +Signed-off-by: Greg Kroah-Hartman +--- + 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); diff --git a/queue-5.15/series b/queue-5.15/series index b119ccf010..ea94ec6ca1 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -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