Netdev List
 help / color / mirror / Atom feed
* [PATCH] mptcp: reject negative MPTCP_INFO lengths
@ 2026-12-05  5:42 Shawn Shao
  2026-12-05  5:48 ` netdev-bot+sinfo
  2026-12-05  6:48 ` Matthieu Baerts
  0 siblings, 2 replies; 3+ messages in thread
From: Shawn Shao @ 2026-12-05  5:42 UTC (permalink / raw)
  To: matttbe, martineau
  Cc: geliang, davem, edumazet, kuba, pabeni, willemb, horms, netdev,
	mptcp


mptcp_getsockopt_info() reads optlen as a signed int but converts it to
unsigned int in min_t(). A negative value therefore selects the full
MPTCP_INFO structure instead of being rejected.

Reject negative lengths before the zero-length check and unsigned
conversion.

Tested on x86_64 with QEMU TCG. Negative lengths return -EINVAL without
changing optlen or the output buffer; nonnegative length controls pass.

Link: https://gist.github.com/shaos26/a719048f273e0e3bd14b1fb9feee1e4a
Fixes: 55c42fa7fa33 ("mptcp: add MPTCP_INFO getsockopt")
Signed-off-by: Shawn Shao <shawnq1@163.com>
---
 net/mptcp/sockopt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
index fcf6feb2a9eb5..84d9ce2a9ba81 100644
--- a/net/mptcp/sockopt.c
+++ b/net/mptcp/sockopt.c
@@ -1038,6 +1038,8 @@ static int mptcp_getsockopt_info(struct mptcp_sock *msk, char __user *optval, in
 
 	if (get_user(len, optlen))
 		return -EFAULT;
+	if (len < 0)
+		return -EINVAL;
 
 	/* When used only to check if a fallback to TCP happened. */
 	if (len == 0)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-05  6:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05  5:42 [PATCH] mptcp: reject negative MPTCP_INFO lengths Shawn Shao
2026-12-05  5:48 ` netdev-bot+sinfo
2026-12-05  6:48 ` Matthieu Baerts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox