Skip to contentSkip to conversation

mptcp: options: avoid printing uninit data

PATCH In review Matthieu Baerts (NGI0) 3 participants 6 messages Sep 8 – Oct 9

Subsystems (2)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

cover mptcp: options: avoid printing uninit data

When parsing the MPTCP suboptions, some pr_debug() might read and print uninit values.

That's mostly harmless, but that's also confusing. Fixing that also avoids some tools to complain about accessing unint data.

So read these fields only if they have been set.

---
Matthieu Baerts (NGI0) (2):
mptcp: options: mpc: avoid printing uninit data
mptcp: options: dss: avoid printing uninit csum

 net/mptcp/options.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

---
base-commit: a59eb98e30b7db5fa1cc7cd5343ad387bced3ae0
change-id: 20260908-mptcp-opt-read-debug-d818ab97c05e

Best regards,

Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
author maintainer
#1 lore raw

PATCH 1/2 mptcp: options: mpc: avoid printing uninit data

When parsing the MP_CAPABLE suboption, this pr_debug() might read and print uninit values.

That's mostly harmless, but that's also confusing. Fixing that also avoids some tools to complain about accessing unint data.

So read these fields only if they have been set.

Fixes cc7972ea1932 ("mptcp: parse and emit MP_CAPABLE option according to v1 spec")
---
 net/mptcp/options.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/mptcp/options.c +5 -2
index f87707110c75..7f7ed4753100 100644
@@ -126,8 +126,11 @@ static void mptcp_parse_option(const struct sk_buff *skb,
 			ptr += 2;
 		}
 		pr_debug("MP_CAPABLE version=%x, flags=%x, optlen=%d sndr=%llu, rcvr=%llu len=%d csum=%u\n",
-			 version, flags, opsize, mp_opt->sndr_key,
-			 mp_opt->rcvr_key, mp_opt->data_len, mp_opt->csum);
+			 version, flags, opsize,
+			 opsize >= TCPOLEN_MPTCP_MPC_SYNACK ? mp_opt->sndr_key : 0,
+			 opsize >= TCPOLEN_MPTCP_MPC_ACK ? mp_opt->rcvr_key : 0,
+			 opsize >= TCPOLEN_MPTCP_MPC_ACK_DATA ? mp_opt->data_len : 0,
+			 opsize == TCPOLEN_MPTCP_MPC_ACK_DATA_CSUM ? mp_opt->csum : 0);
 		break;
 
 	case MPTCPOPT_MP_JOIN:
Signature · 1 line
2.55.0
author maintainer
#2 lore raw

PATCH 2/2 mptcp: options: dss: avoid printing uninit csum

In reply to Matthieu Baerts (NGI0)

When parsing the DSS suboption, this pr_debug() might read and print uninit checksum value.

That's mostly harmless, but that's also confusing. Fixing that also avoids some tools to complain about accessing unint data.

So read this csum field only if it has been set.

Fixes 390b95a5fb84 ("mptcp: receive checksum for DSS")
---
 net/mptcp/options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/options.c +1 -1
index 7f7ed4753100..20490410fa22 100644
@@ -259,7 +259,7 @@ static void mptcp_parse_option(const struct sk_buff *skb,
 			pr_debug("data_seq=%llu subflow_seq=%u data_len=%u csum=%d:%u\n",
 				 mp_opt->data_seq, mp_opt->subflow_seq,
 				 mp_opt->data_len, !!(mp_opt->suboptions & OPTION_MPTCP_CSUMREQD),
-				 mp_opt->csum);
+				 (mp_opt->suboptions & OPTION_MPTCP_CSUMREQD) ? mp_opt->csum : 0);
 		}
 
 		break;
Signature · 1 line
2.55.0
#3 lore raw
In reply to Matthieu Baerts (NGI0)

Hi Matthieu,

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! ✅
- Perf:
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/34255429754

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/9f6eed5cbeb2
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1160710

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-normal

For 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)

maintainer Reviewed-by on the v1 series
#4 lore raw
In reply to Matthieu Baerts (NGI0)
Quoted 14 lines · On Tue, 8 Sep 2026, Matthieu Baerts (NGI0) wrote:

When parsing the MPTCP suboptions, some pr_debug() might read and print uninit values.

That's mostly harmless, but that's also confusing. Fixing that also avoids some tools to complain about accessing unint data.

So read these fields only if they have been set.

---
Matthieu Baerts (NGI0) (2):
mptcp: options: mpc: avoid printing uninit data
mptcp: options: dss: avoid printing uninit csum

Quoted 5 lines

net/mptcp/options.c | 9 ++++++---

1 file changed, 6 insertions(+), 3 deletions(-)

---
base-commit: a59eb98e30b7db5fa1cc7cd5343ad387bced3ae0
change-id: 20260908-mptcp-opt-read-debug-d818ab97c05e

Thanks Matthieu, series LGTM:

author maintainer
#5 lore raw

Hi Mat,

Quoted 9 lines · Mat Martineau
Quoted 7 lines · On Tue, 8 Sep 2026, Matthieu Baerts (NGI0) wrote:

When parsing the MPTCP suboptions, some pr_debug() might read and print uninit values.

That's mostly harmless, but that's also confusing. Fixing that also avoids some tools to complain about accessing unint data.

So read these fields only if they have been set.

(...)

Quoted 1 line

Thanks Matthieu, series LGTM:

Thank you for the review! I'm lagging so much I even slow at applying my own patches :)

New patches for t/upstream-net and t/upstream:
- e83426516ebe: mptcp: options: mpc: avoid printing uninit data
- 55dcf92c5ff9: mptcp: options: dss: avoid printing uninit csum
- Results: 7e92f912c44e..77cb3db4e666 (export-net)
- Results: 45035345367c..fbeaa40c1480 (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/984504faff7251d01755ff9d5077c95929788472/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/c320b1b2220752a879c853142d2ce128985a6012/checks

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.