From: gang.yan@linux.dev
To: "Matthieu Baerts" <matttbe@kernel.org>
Cc: mptcp@lists.linux.dev, "Gang Yan" <yangang@kylinos.cn>
Subject: Re: [PATCH mptcp-net] selftests: mptcp: fix an UAF in mptcp_connect.c
Date: Fri, 14 Aug 2026 09:20:41 +0000 [thread overview]
Message-ID: <42532178906ea8ce9bd4b8550144719356c69671@linux.dev> (raw)
In-Reply-To: <90d727ed-9c4c-4107-a283-1e9a0245d09b@kernel.org>
August 14, 2026 at 4:54 PM, "Matthieu Baerts" <matttbe@kernel.org mailto:matttbe@kernel.org?to=%22Matthieu%20Baerts%22%20%3Cmatttbe%40kernel.org%3E > wrote:
> >
> This assumes peer == addr. It is certainly the case but it looks wrong,
> and I guess sashiko will complain like it did here.
>
> We could add something on the commit message to say that it is always an IP address that is given, but maybe we should also just
> handle that correctly: either peer here is not a pointer, and the content
> is copied,
I prefer this, because it is smaller, like:
'''
static int sock_connect_mptcp(const char * const remoteaddr,
const char * const port, int proto,
- struct addrinfo **peer,
+ struct sockaddr_storage *peer, socklen_t *peer_len,
int infd, struct wstate *winfo)
{
...
- *peer = a;
break;
...
- *peer = a;
break;
...
+ if (sock != -1) {
+ memcpy(peer, a->ai_addr, a->ai_addrlen);
+ *peer_len = a->ai_addrlen;
+ }
freeaddrinfo(addr);
...
- struct addrinfo *peer = NULL;
+ struct sockaddr_storage peer;
+ socklen_t peer_len;
...
- fd = sock_connect_mptcp(..., &peer, fd_in, &winfo);
+ fd = sock_connect_mptcp(..., &peer, &peer_len, fd_in, &winfo);
...
- if (connect(fd, peer->ai_addr, peer->ai_addrlen))
+ if (connect(fd, (struct sockaddr *)&peer, peer_len))
'''
> or you pass &addr to sock_connect_mptcp, and you do the free here.
This needs a refactor of sock_connect_mptcp – I used to do it that way. But I
worry that backporting could be tricky. If you're fine with it, I'm okay with this plan
as well.
WDYT?
Thanks
Gang
next prev parent reply other threads:[~2026-08-14 9:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 5:06 [PATCH mptcp-net] selftests: mptcp: fix an UAF in mptcp_connect.c Gang Yan
2026-08-14 5:14 ` sashiko-bot
2026-08-14 6:18 ` MPTCP CI
2026-08-14 6:42 ` gang.yan
2026-08-14 8:54 ` Matthieu Baerts
2026-08-14 9:20 ` gang.yan [this message]
2026-08-14 9:35 ` Matthieu Baerts
2026-08-14 10:50 ` Paolo Abeni
2026-08-14 14:20 ` gang.yan
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=42532178906ea8ce9bd4b8550144719356c69671@linux.dev \
--to=gang.yan@linux.dev \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=yangang@kylinos.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.