From: david.laight.linux@gmail.com
To: linux-kernel@vger.kernel.org, mptcp@lists.linux.dev,
netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Mat Martineau <martineau@kernel.org>,
Matthieu Baerts <matttbe@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
David Laight <david.laight.linux@gmail.com>
Subject: [PATCH 44/44] net/mptcp: Change some dubious min_t(int, ...) to min()
Date: Wed, 19 Nov 2025 22:41:40 +0000 [thread overview]
Message-ID: <20251119224140.8616-45-david.laight.linux@gmail.com> (raw)
In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com>
From: David Laight <david.laight.linux@gmail.com>
There are two:
min_t(int, xxx, mptcp_wnd_end(msk) - msk->snd_nxt);
Both mptcp_wnd_end(msk) and msk->snd_nxt are u64, their difference
(aka the window size) might be limited to 32 bits - but that isn't
knowable from this code.
So checks being added to min_t() detect the potential discard of
significant bits.
Provided the 'avail_size' and return of mptcp_check_allowed_size()
are changed to an unsigned type (size_t matches the type the caller
uses) both min_t() can be changed to min().
Signed-off-by: David Laight <david.laight.linux@gmail.com>
---
net/mptcp/protocol.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 2d6b8de35c44..d57c3659462f 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1123,8 +1123,8 @@ struct mptcp_sendmsg_info {
bool data_lock_held;
};
-static int mptcp_check_allowed_size(const struct mptcp_sock *msk, struct sock *ssk,
- u64 data_seq, int avail_size)
+static size_t mptcp_check_allowed_size(const struct mptcp_sock *msk, struct sock *ssk,
+ u64 data_seq, size_t avail_size)
{
u64 window_end = mptcp_wnd_end(msk);
u64 mptcp_snd_wnd;
@@ -1133,7 +1133,7 @@ static int mptcp_check_allowed_size(const struct mptcp_sock *msk, struct sock *s
return avail_size;
mptcp_snd_wnd = window_end - data_seq;
- avail_size = min_t(unsigned int, mptcp_snd_wnd, avail_size);
+ avail_size = min(mptcp_snd_wnd, avail_size);
if (unlikely(tcp_sk(ssk)->snd_wnd < mptcp_snd_wnd)) {
tcp_sk(ssk)->snd_wnd = min_t(u64, U32_MAX, mptcp_snd_wnd);
@@ -1477,7 +1477,7 @@ struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk)
if (!ssk || !sk_stream_memory_free(ssk))
return NULL;
- burst = min_t(int, MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd_nxt);
+ burst = min(MPTCP_SEND_BURST_SIZE, mptcp_wnd_end(msk) - msk->snd_nxt);
wmem = READ_ONCE(ssk->sk_wmem_queued);
if (!burst)
return ssk;
--
2.39.5
next prev parent reply other threads:[~2025-11-19 22:42 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-19 22:40 [PATCH 00/44] Change a lot of min_t() that might mask high bits david.laight.linux
2025-11-19 22:41 ` [PATCH 07/44] net/core/flow_dissector: Fix cap of __skb_flow_dissect() return value david.laight.linux
2025-11-19 22:41 ` [PATCH 08/44] net: ethtool: Use min3() instead of nested min_t(u16,...) david.laight.linux
2025-11-19 22:41 ` [PATCH 09/44] ipv6: __ip6_append_data() don't abuse max_t() casts david.laight.linux
2025-11-20 0:32 ` bot+bpf-ci
2025-11-20 11:16 ` David Laight
2025-11-20 13:50 ` Chris Mason
2025-11-19 22:41 ` [PATCH 21/44] drivers/net/ethernet/realtek: use min() instead of min_t() david.laight.linux
2025-11-19 22:41 ` [PATCH 40/44] net: Don't pass bitfields to max_t() david.laight.linux
2025-11-19 22:41 ` [PATCH 41/44] net/core: Change loop conditions so min() can be used david.laight.linux
2025-11-19 22:41 ` [PATCH 42/44] net: use min() instead of min_t() david.laight.linux
2025-11-19 22:41 ` [PATCH 43/44] net/netlink: Use umin() to avoid min_t(int, ...) discarding high bits david.laight.linux
2025-11-19 22:41 ` david.laight.linux [this message]
2025-12-18 17:33 ` [PATCH 44/44] net/mptcp: Change some dubious min_t(int, ...) to min() Matthieu Baerts
2025-12-18 20:15 ` David Laight
2025-12-19 10:48 ` Matthieu Baerts
2025-11-20 1:47 ` [PATCH 00/44] Change a lot of min_t() that might mask high bits Jakub Kicinski
2025-11-20 9:38 ` Lorenzo Stoakes
2025-11-20 14:52 ` (subset) " Jens Axboe
2025-11-24 9:49 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251119224140.8616-45-david.laight.linux@gmail.com \
--to=david.laight.linux@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).