All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhixing Chen <running910@gmail.com>
To: Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, Zhixing Chen <running910@gmail.com>
Subject: [PATCH net-next] pptp: validate payload length before parsing PPP fields
Date: Thu, 13 Aug 2026 16:22:47 +0800	[thread overview]
Message-ID: <20260813082247.31499-1-running910@gmail.com> (raw)

pptp_rcv_core() pulls the PPTP GRE header together with the payload length
advertised by the header, then looks into the PPP payload for two special
cases: allowing old-sequence LCP Echo packets and stripping the PPP
address/control fields.

Both checks read fixed PPP fields from the payload. Make sure the
advertised payload length covers those fields before reading them, so
malformed short payloads are rejected before their PPP contents are
evaluated.

This keeps the receive path within the declared PPTP payload boundary.

Signed-off-by: Zhixing Chen <running910@gmail.com>
---

While testing PPTP stability and reviewing the PPTP driver code, I noticed
that the receive path can reach the old-sequence LCP Echo check and the
address/control field handling with an advertised payload length shorter
than the PPP fields being inspected.

I exercised this path with malformed short PPTP GRE packets and confirmed
that such packets can reach both checks. The test packets did not trigger a
KASAN report in my setup, but my understanding is that the parser should
not inspect bytes outside the declared PPTP payload when deciding how to
handle PPP fields.

This is intended as a small robustness improvement for malformed PPTP GRE
packets.

---
 drivers/net/ppp/pptp.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c
index a797a0606f6b..708d8fb3a900 100644
--- a/drivers/net/ppp/pptp.c
+++ b/drivers/net/ppp/pptp.c
@@ -317,16 +317,18 @@ static int pptp_rcv_core(struct sock *sk, struct sk_buff *skb)
 	payload = skb->data + headersize;
 	/* check for expected sequence number */
 	if (seq < opt->seq_recv + 1 || WRAPPED(opt->seq_recv, seq)) {
-		if ((payload[0] == PPP_ALLSTATIONS) && (payload[1] == PPP_UI) &&
-				(PPP_PROTOCOL(payload) == PPP_LCP) &&
-				((payload[4] == PPP_LCP_ECHOREQ) || (payload[4] == PPP_LCP_ECHOREP)))
+		if (payload_len >= PPP_HDRLEN + 1 &&
+		    payload[0] == PPP_ALLSTATIONS && payload[1] == PPP_UI &&
+		    PPP_PROTOCOL(payload) == PPP_LCP &&
+		    (payload[4] == PPP_LCP_ECHOREQ || payload[4] == PPP_LCP_ECHOREP))
 			goto allow_packet;
 	} else {
 		opt->seq_recv = seq;
 allow_packet:
 		skb_pull(skb, headersize);
 
-		if (payload[0] == PPP_ALLSTATIONS && payload[1] == PPP_UI) {
+		if (payload_len >= 2 &&
+		    payload[0] == PPP_ALLSTATIONS && payload[1] == PPP_UI) {
 			/* chop off address/control */
 			if (skb->len < 3)
 				goto drop;

base-commit: f6057f06ef7afa9893ed33603f7917fa39d237b5
-- 
2.34.1


                 reply	other threads:[~2026-08-13  8:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260813082247.31499-1-running910@gmail.com \
    --to=running910@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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.