All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
To: MPTCP Linux <mptcp@lists.linux.dev>
Cc: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Subject: [PATCH mptcp-net 1/2] mptcp: options: mpc: avoid printing uninit data
Date: Tue, 08 Sep 2026 19:07:11 +0200	[thread overview]
Message-ID: <20260908-mptcp-opt-read-debug-v1-1-b3e74549b6f6@kernel.org> (raw)
In-Reply-To: <20260908-mptcp-opt-read-debug-v1-0-b3e74549b6f6@kernel.org>

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")
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/options.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/mptcp/options.c b/net/mptcp/options.c
index f87707110c75..7f7ed4753100 100644
--- a/net/mptcp/options.c
+++ b/net/mptcp/options.c
@@ -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:

-- 
2.55.0


  reply	other threads:[~2026-09-08 17:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 17:07 [PATCH mptcp-net 0/2] mptcp: options: avoid printing uninit data Matthieu Baerts (NGI0)
2026-09-08 17:07 ` Matthieu Baerts (NGI0) [this message]
2026-09-08 17:07 ` [PATCH mptcp-net 2/2] mptcp: options: dss: avoid printing uninit csum Matthieu Baerts (NGI0)
2026-09-08 18:00 ` [PATCH mptcp-net 0/2] mptcp: options: avoid printing uninit data MPTCP CI
2026-09-09 15:51 ` Mat Martineau

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=20260908-mptcp-opt-read-debug-v1-1-b3e74549b6f6@kernel.org \
    --to=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    /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.