mptcp: only honor zero-length DATA_FIN when a mapping is present
Subsystems (3)
PATCH 1/1 mptcp: only honor zero-length DATA_FIN when a mapping is present
mptcp_get_options() initializes only the status group of struct mptcp_options_received; data_seq, subflow_seq and data_len are set by mptcp_parse_option() only inside the DSS mapping block, which runs when the DSS M (mapping present) bit is set.
A peer can send a DSS option with DATA_FIN set but the mapping bit clear. The parser then sets mp_opt.data_fin while leaving data_len and data_seq uninitialized, and for a zero-length segment mptcp_incoming_options() reads them; KMSAN reports an uninit-value in mptcp_incoming_options().
Impact: a remote peer that has completed the MPTCP handshake makes mptcp_incoming_options() read uninitialized data_len and data_seq (KMSAN uninit-value) by sending a DSS option with DATA_FIN set and the mapping bit clear.
A DATA_FIN is always sent with a mapping (mptcp_write_data_fin()), so gating this path on the mapping bit drops only the malformed no-map case and leaves valid DATA_FIN handling unchanged.
---
The stale data_seq then reaches mptcp_update_rcv_data_fin(); no further consequence is demonstrated, so this is a robustness fix. The read site for a zero-length segment is:
if (mp_opt.data_fin && mp_opt.data_len == 1 && mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64))
Reproduced under KMSAN: a no-map DSS DATA_FIN crafted on the wire and
injected over a TUN device into a real MPTCP listener produces twelve
"uninit-value in mptcp_incoming_options" reports on stock and none on the patched build (the unrelated mm-side KMSAN boot noise present on both trees is not affected); a well-formed mapped DATA_FIN (control) drives the same branch with no report. Harness on request.
net/mptcp/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/options.c +1 -1
@@ -1227,7 +1227,7 @@ bool mptcp_incoming_options(struct sock *sk, struct sk_buff *skb)* present, needs to be updated here before the skb is freed. */ if (TCP_SKB_CB (skb)->seq ==TCP_SKB_CB (skb)->end_seq) { -if (mp_opt.data_fin && mp_opt.data_len ==1 && +if (mp_opt.use_map && mp_opt.data_fin && mp_opt.data_len ==1 &&mptcp_update_rcv_data_fin (msk, mp_opt.data_seq, mp_opt.dsn64))mptcp_schedule_work ((struct sock *)msk);
Signature · 1 line
2.53.0
Hi Michael,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/27723068868
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/41f92d8643fc
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1113137
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Paolo Abeni
maintainerQuoted 15 lines · Michael Bommarito
mptcp_get_options()initializes only the status group of structmptcp_options_received;data_seq,subflow_seqanddata_lenare set bymptcp_parse_option()only inside the DSS mapping block, which runs when the DSS M (mapping present) bit is set.A peer can send a DSS option with
DATA_FINset but the mapping bit clear. The parser then sets mp_opt.data_fin while leavingdata_lenanddata_sequninitialized, and for a zero-length segmentmptcp_incoming_options()reads them; KMSAN reports an uninit-value inmptcp_incoming_options().Impact: a remote peer that has completed the MPTCP handshake makes
mptcp_incoming_options()read uninitializeddata_lenanddata_seq(KMSAN uninit-value) by sending a DSS option withDATA_FINset and the mapping bit clear.
Quoted 8 lines
A
DATA_FINis always sent with a mapping (mptcp_write_data_fin()), so gating this path on the mapping bit drops only the malformed no-map case and leaves validDATA_FINhandling unchanged.Fixes 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine")Assisted-by Claude:claude-opus-4-8Signed-off-by Michael Bommarito <[email protected]>
Isn't this fixed by commit 5e939544f9d2 ("mptcp: fix uninit-value in mptcp_established_options") ?
/P
Quoted 2 lines · Paolo Abeni
Isn't this fixed by commit
5e939544f9d2("mptcp: fix uninit-value inmptcp_established_options") ?
I did the reproduction ~10 days ago on linus's latest, so definitely still reproducing. I think 5e939544f9d2 was on the TX side and this is about the RX option path, so they don't overlap on flows either.
Thanks,
Mike
Paolo Abeni
maintainerQuoted 7 lines · Michael Bommarito
Quoted 2 lines · Paolo Abeni
Isn't this fixed by commit
5e939544f9d2("mptcp: fix uninit-value inmptcp_established_options") ?I did the reproduction ~10 days ago on linus's latest, so definitely still reproducing. I think
5e939544f9d2was on the TX side and this is about the RX option path, so they don't overlap on flows either.
Right.
AFAICS the RFC is a little vague about enforcing meaningful flags combination.
I think it would be better to avoid another conditional while processing incoming ack. Does the following solve the issue?
Thanks!
---
net/mptcp/options.c +1 -1
@@ -157,7 +157,6 @@ static void mptcp_parse_option(const struct sk_buff *skb, ptr++; flags = (*ptr++) &MPTCP_DSS_FLAG_MASK ; - mp_opt->data_fin = (flags &MPTCP_DSS_DATA_FIN ) !=0 ; mp_opt->dsn64 = (flags &MPTCP_DSS_DSN64 ) !=0 ; mp_opt->use_map = (flags &MPTCP_DSS_HAS_MAP ) !=0 ; mp_opt->ack64 = (flags &MPTCP_DSS_ACK64 ) !=0 ;
@@ -178,6 +177,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, }if (mp_opt->use_map) { + mp_opt->data_fin = (flags &MPTCP_DSS_DATA_FIN ) !=0 ;if (mp_opt->dsn64) expected_opsize +=TCPOLEN_MPTCP_DSS_MAP64 ;else
PATCH v2 1/1 mptcp: only set DATA_FIN when a mapping is present
mptcp_get_options() clears only the status group of struct mptcp_options_received; data_seq, subflow_seq and data_len are filled in by mptcp_parse_option() exclusively inside the DSS mapping block, which runs only when the DSS M (mapping present) bit is set.
A peer can send a DSS option with the DATA_FIN flag set but the mapping bit clear. The parser then records mp_opt->data_fin while leaving data_len and data_seq uninitialized. For a zero-length segment mptcp_incoming_options() evaluates
if (mp_opt.data_fin && mp_opt.data_len == 1 && mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64))
which reads the uninitialized data_len and data_seq; KMSAN reports an uninit-value in mptcp_incoming_options(). The stale data_seq can also be fed into the receive-side DATA_FIN sequence tracking.
Record the DATA_FIN flag only when the DSS option carries a mapping, so data_fin is never set without data_seq and data_len also being present. data_fin is part of the status group that mptcp_get_options() clears up front, so on the no-map path it stays zero and the zero-length DATA_FIN branch is simply skipped. A DATA_FIN is always transmitted together with a mapping (mptcp_write_data_fin() sets use_map along with data_seq and data_len), so legitimate DATA_FIN handling is unaffected.
---
v2: adopt Paolo Abeni's suggested approach - do not set mp_opt->data_fin
at all unless a mapping is present, rather than gating the consumer in mptcp_incoming_options() (v1). data_fin then defaults to the value mptcp_get_options() already clears it to (0) on the no-map path, so the uninitialized data_len/data_seq are never read.
net/mptcp/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/options.c +1 -1
@@ -157,7 +157,6 @@ static void mptcp_parse_option(const struct sk_buff *skb, ptr++; flags = (*ptr++) &MPTCP_DSS_FLAG_MASK ; - mp_opt->data_fin = (flags &MPTCP_DSS_DATA_FIN ) !=0 ; mp_opt->dsn64 = (flags &MPTCP_DSS_DSN64 ) !=0 ; mp_opt->use_map = (flags &MPTCP_DSS_HAS_MAP ) !=0 ; mp_opt->ack64 = (flags &MPTCP_DSS_ACK64 ) !=0 ;
@@ -178,6 +177,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, }if (mp_opt->use_map) { + mp_opt->data_fin = (flags &MPTCP_DSS_DATA_FIN ) !=0 ;if (mp_opt->dsn64) expected_opsize +=TCPOLEN_MPTCP_DSS_MAP64 ;else
--
2.53.0
Re: [PATCH v2] mptcp: only set DATA_FIN when a mapping is present
Hi Michael,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/28886089429
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/cdeb2105da80
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1123264
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Re: [PATCH v2] mptcp: only set DATA_FIN when a mapping is present
In reply to Michael BommaritoJuly 8, 2026 at 1:17 AM, "Michael Bommarito" <[email protected] mailto:[email protected]?to=%22Michael%20Bommarito%22%20%3Cmichael.bommarito%40gmail.com%3E > wrote:
Hi Michael
Thanks for the patch.
Quoted 54 lines
mptcp_get_options()clears only the status group of structmptcp_options_received;data_seq,subflow_seqanddata_lenare filled in bymptcp_parse_option()exclusively inside the DSS mapping block, which runs only when the DSS M (mapping present) bit is set.A peer can send a DSS option with the
DATA_FINflag set but the mapping bit clear. The parser then recordsmp_opt->data_finwhile leavingdata_lenanddata_sequninitialized. For a zero-length segmentmptcp_incoming_options()evaluatesif (mp_opt.data_fin && mp_opt.data_len == 1 &&
mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64))which reads the uninitialized
data_lenanddata_seq; KMSAN reports an uninit-value inmptcp_incoming_options(). The staledata_seqcan also be fed into the receive-sideDATA_FINsequence tracking.Record the
DATA_FINflag only when the DSS option carries a mapping, sodata_finis never set withoutdata_seqanddata_lenalso being present.data_finis part of the status group thatmptcp_get_options()clears up front, so on the no-map path it stays zero and the zero-lengthDATA_FINbranch is simply skipped. ADATA_FINis always transmitted together with a mapping (mptcp_write_data_fin()setsuse_mapalong withdata_seqanddata_len), so legitimateDATA_FINhandling is unaffected.Fixes 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine")Suggested-by Paolo Abeni <[email protected]>Assisted-by Claude:claude-opus-4-8Signed-off-by Michael Bommarito <[email protected]>---
v2: adopt Paolo Abeni's suggested approach - do not setmp_opt->data_fin
at all unless a mapping is present, rather than gating the consumer inmptcp_incoming_options()(v1).data_finthen defaults to the valuemptcp_get_options()already clears it to (0) on the no-map path, so the uninitialized data_len/data_seq are never read.net/mptcp/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/mptcp/options.c +0
-1@@ -157,7 +157,6 @@ static void mptcp_parse_option(const struct sk_buff *skb, ptr++; flags = (*ptr++) &MPTCP_DSS_FLAG_MASK ; - mp_opt->data_fin = (flags &MPTCP_DSS_DATA_FIN ) !=0 ; mp_opt->dsn64 = (flags &MPTCP_DSS_DSN64 ) !=0 ; mp_opt->use_map = (flags &MPTCP_DSS_HAS_MAP ) !=0 ; mp_opt->ack64 = (flags &MPTCP_DSS_ACK64 ) !=0 ;
net/mptcp/options.c static void mptcp_parse_option(const struct sk_buff *skb, · line 183
Quoted 7 lines
net/mptcp/options.c +1
-0@@ -178,6 +177,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, }if (mp_opt->use_map) { + mp_opt->data_fin = (flags &MPTCP_DSS_DATA_FIN ) !=0 ;if (mp_opt->dsn64) expected_opsize +=TCPOLEN_MPTCP_DSS_MAP64 ;else
One minor thing I noticed while reviewing: Sashiko previously pointed out in a comment that the 'pr_debug' logging 'mp_opt->data_fin' might be problematic because it's printed before data_fin is actually assigned (since data_fin is now set only inside the if (mp_opt->use_map) block).
I think it would be cleaner to move the pr_debug call after the data_fin assignment, so the logged value is always meaningful and consistent with the actual parsed state, like:
'''
net/mptcp/options.c +5 -5
@@ -162,11 +162,6 @@ static void mptcp_parse_option(const struct sk_buff *skb, mp_opt->ack64 = (flags &MPTCP_DSS_ACK64 ) !=0 ; mp_opt->use_ack = (flags &MPTCP_DSS_HAS_ACK ); -pr_debug ("data_fin=%d dsn64=%d use_map=%d ack64=%d use_ack=%d\n" , - mp_opt->data_fin, mp_opt->dsn64, - mp_opt->use_map, mp_opt->ack64, - mp_opt->use_ack); - expected_opsize =TCPOLEN_MPTCP_DSS_BASE ;if (mp_opt->use_ack) {
@@ -184,6 +179,11 @@ static void mptcp_parse_option(const struct sk_buff *skb, expected_opsize +=TCPOLEN_MPTCP_DSS_MAP32 ; } +pr_debug ("data_fin=%d dsn64=%d use_map=%d ack64=%d use_ack=%d\n" , + mp_opt->data_fin, mp_opt->dsn64, + mp_opt->use_map, mp_opt->ack64, + mp_opt->use_ack); +/* Always parse any csum presence combination, we will enforce * RFC 8684 Section 3.3.0 checks later in subflow_data_ready */
'''
This change isn't critical to the fix itself, so feel free to let Paolo/Matt and other Maintainers decide if it should go in now, later, or not at all.
A couple of additional notes for future submissions (just friendly reminders):
- The subject-prefix convention for MPTCP patches is typically [PATCH mptcp-net] for bug fixes targeting the net tree, or [PATCH mptcp-next] for new features. Since this is a fix, something like [PATCH mptcp-net v2] would be more appropriate.
- It's also helpful to include a Link: to the previous version (v1) in the changelog, so reviewers can easily track the discussion history.
Looking forward to seeing more of your work on the MPTCP mailing list!
Thanks,
Gang
Quoted 3 lines
--
2.53.0
Matthieu Baerts
maintainerRe: [PATCH v2] mptcp: only set DATA_FIN when a mapping is present
Hi Michael, Gang,
Quoted 1 line · On 09/07/2026 07:43, [email protected] wrote:
July 8, 2026 at 1:17 AM, "Michael Bommarito" <[email protected]> wrote:
Thank you for this patch and the review!
Quoted 9 lines
Quoted 9 lines
mptcp_get_options()clears only the status group of structmptcp_options_received;data_seq,subflow_seqanddata_lenare filled in bymptcp_parse_option()exclusively inside the DSS mapping block, which runs only when the DSS M (mapping present) bit is set.A peer can send a DSS option with the
DATA_FINflag set but the mapping bit clear. The parser then recordsmp_opt->data_finwhile leavingdata_lenanddata_sequninitialized. For a zero-length segmentmptcp_incoming_options()evaluates
By chance, do you have a reproducer? Maybe using Packetdrill with MPTCP support? [1]
If not, how did you discover this issue?
[1] https://github.com/multipath-tcp/packetdrill/
Quoted 59 lines
Quoted 43 lines
if (mp_opt.data_fin && mp_opt.data_len == 1 &&
mptcp_update_rcv_data_fin(msk, mp_opt.data_seq, mp_opt.dsn64))which reads the uninitialized
data_lenanddata_seq; KMSAN reports an uninit-value inmptcp_incoming_options(). The staledata_seqcan also be fed into the receive-sideDATA_FINsequence tracking.Record the
DATA_FINflag only when the DSS option carries a mapping, sodata_finis never set withoutdata_seqanddata_lenalso being present.data_finis part of the status group thatmptcp_get_options()clears up front, so on the no-map path it stays zero and the zero-lengthDATA_FINbranch is simply skipped. ADATA_FINis always transmitted together with a mapping (mptcp_write_data_fin()setsuse_mapalong withdata_seqanddata_len), so legitimateDATA_FINhandling is unaffected.Fixes 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine")Suggested-by Paolo Abeni <[email protected]>Assisted-by Claude:claude-opus-4-8Signed-off-by Michael Bommarito <[email protected]>---
v2: adopt Paolo Abeni's suggested approach - do not setmp_opt->data_fin
at all unless a mapping is present, rather than gating the consumer inmptcp_incoming_options()(v1).data_finthen defaults to the valuemptcp_get_options()already clears it to (0) on the no-map path, so the uninitialized data_len/data_seq are never read.net/mptcp/options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/mptcp/options.c +0
-1@@ -157,7 +157,6 @@ static void mptcp_parse_option(const struct sk_buff *skb, ptr++; flags = (*ptr++) &MPTCP_DSS_FLAG_MASK ; - mp_opt->data_fin = (flags &MPTCP_DSS_DATA_FIN ) !=0 ; mp_opt->dsn64 = (flags &MPTCP_DSS_DSN64 ) !=0 ; mp_opt->use_map = (flags &MPTCP_DSS_HAS_MAP ) !=0 ; mp_opt->ack64 = (flags &MPTCP_DSS_ACK64 ) !=0 ;net/mptcp/options.c static void mptcp_parse_option(const struct sk_buff *skb, · line 183
Quoted 7 lines
net/mptcp/options.c +1
-0@@ -178,6 +177,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, }if (mp_opt->use_map) { + mp_opt->data_fin = (flags &MPTCP_DSS_DATA_FIN ) !=0 ;if (mp_opt->dsn64) expected_opsize +=TCPOLEN_MPTCP_DSS_MAP64 ;else One minor thing I noticed while reviewing: Sashiko previously pointed out in a comment that the '
pr_debug' logging 'mp_opt->data_fin' might be problematic because it's printed beforedata_finis actually assigned (sincedata_finis now set only inside the if (mp_opt->use_map) block).I think it would be cleaner to move the
pr_debugcall after thedata_finassignment, so the logged value is always meaningful and consistent with the actual parsed state, like:
(...)
Quoted 2 lines
This change isn't critical to the fix itself, so feel free to let Paolo/Matt and other Maintainers decide if it should go in now, later, or not at all.
Probably best to fix that now, to avoid getting confused when looking at debug info. Do you mind doing that in a v3, please?
pw-bot: changes-requested
Quoted 5 lines
A couple of additional notes for future submissions (just friendly reminders):
- The subject-prefix convention for MPTCP patches is typically [PATCH mptcp-net] for bug fixes targeting the net tree, or [PATCH mptcp-next] for new features. Since this is a fix, something like [PATCH mptcp-net v2] would be more appropriate.
For a "one-off" or urgent fix for MPTCP, that's OK to send patches to the netdev ML directly. In this case, please use the "net" prefix, see:
https://docs.kernel.org/process/maintainer-netdev.html
For other kind of patches specific to MPTCP, please send them only to the MPTCP ML with the 'mptcp-net' or 'mptcp-next' prefixes. Just to be
clear: here you can send the v3 to the same people and lists -- you missed Simon apparently, did you not use get_maintainer.pl script? -- with the 'net' prefix ([PATCH net v3]).
Quoted 2 lines
- It's also helpful to include a Link: to the previous version (v1) in the changelog, so reviewers can easily track the discussion history.
If I may add, please also send new version in a separate thread, not as a reply, not to confuse various tools, as mentioned in the same doc.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Re: [PATCH v2] mptcp: only set DATA_FIN when a mapping is present
Quoted 3 lines · Matthieu Baerts
By chance, do you have a reproducer? Maybe using Packetdrill with MPTCP support? [1]
If not, how did you discover this issue?
Yup, I'll send to you offlist. It's a custom Python/TUN/qemu setup, not Packetdrill, but I'm guessing it could be ported or extended for testing/fuzzing.
I discovered it with my homegrown agentic stack, which is a Rube Goldberg machine full of various tools (like cocci, semgrep) and knowledge graphs (built with libclang). The agent logs suggest that it came from a family of rules that surfaces suspicious struct init candidates, which I can share too.
Quoted 2 lines
If I may add, please also send new version in a separate thread, not as a reply, not to confuse various tools, as mentioned in the same doc.
Sure, thanks to both you and Gang for the feedback. I'll send a v3 based on your suggestions later today.
Thanks,
Mike
Matthieu Baerts
maintainerRe: [PATCH v2] mptcp: only set DATA_FIN when a mapping is present
Quoted 9 lines · Michael Bommarito
Quoted 3 lines · Matthieu Baerts
By chance, do you have a reproducer? Maybe using Packetdrill with MPTCP support? [1]
If not, how did you discover this issue?Yup, I'll send to you offlist. It's a custom Python/TUN/qemu setup, not Packetdrill, but I'm guessing it could be ported or extended for testing/fuzzing.
Interesting. Yes, it could be useful for various protocols.
Quoted 5 lines
I discovered it with my homegrown agentic stack, which is a Rube Goldberg machine full of various tools (like cocci, semgrep) and knowledge graphs (built with libclang). The agent logs suggest that it came from a family of rules that surfaces suspicious struct init candidates, which I can share too.
Is it also based on crafted traffic? It could also be useful!
Quoted 5 lines
Quoted 2 lines
If I may add, please also send new version in a separate thread, not as a reply, not to confuse various tools, as mentioned in the same doc.
Sure, thanks to both you and Gang for the feedback. I'll send a v3 based on your suggestions later today.
Thanks!
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.