Skip to content

Commit 1e9da97

Browse files
systemcrashhauke
authored andcommitted
ppp: add memmove fortify and remove MRU patch
memcpy() with overlapping src and dest buffers is an undefined behavior in C. In the current code, a ConfRej response is generated by copying input data in-place, where the dest address is lower than the src. This happens to work in practice because memcpy() forward-copies data, matching the behavior of memmove() in this case. However, if FORTIFY_SOURCE or Address Sanitizer is enabled, memcpy() will detect the overlap at run time and abort the program. Replace the memcpy() with memmove() to ensure a well-defined behavior. Reported-by: Filippo Carletti <filippo.carletti@gmail.com> MRU patch ppp-project/ppp#573 Signed-off-by: Paul Donald <newtwen+github@gmail.com> Link: openwrt#22286 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
1 parent d09041e commit 1e9da97

3 files changed

Lines changed: 66 additions & 1 deletion

File tree

package/network/services/ppp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
1010

1111
PKG_NAME:=ppp
1212
PKG_VERSION:=2.5.2
13-
PKG_RELEASE:=2
13+
PKG_RELEASE:=3
1414

1515
PKG_SOURCE_PROTO:=git
1616
PKG_SOURCE_URL:=https://github.com/ppp-project/ppp
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From f8d994052e3858848ce11318085e04fe7a1cfb28 Mon Sep 17 00:00:00 2001
2+
From: LGA1150 <9155358+LGA1150@users.noreply.github.com>
3+
Date: Thu, 5 Mar 2026 05:41:30 +0800
4+
Subject: [PATCH] pppd: fix memcpy overlap (#579)
5+
6+
memcpy() with overlapping src and dest buffers is an undefined behavior
7+
in C. In the current code, a ConfRej response is generated by copying
8+
input data in-place, where the dest address is lower than the src.
9+
This happens to work in practice because memcpy() forward-copies data,
10+
matching the behavior of memmove() in this case.
11+
12+
However, if FORTIFY_SOURCE or Address Sanitizer is enabled, memcpy()
13+
will detect the overlap at run time and abort the program.
14+
15+
Replace the memcpy() with memmove() to ensure a well-defined behavior.
16+
17+
Reported-by: Filippo Carletti <filippo.carletti@gmail.com>
18+
Closes: #576
19+
20+
Signed-off-by: Qingfang Deng <dqfext@gmail.com>
21+
---
22+
pppd/pppd-private.h | 2 +-
23+
1 file changed, 1 insertion(+), 1 deletion(-)
24+
25+
diff --git a/pppd/pppd-private.h b/pppd/pppd-private.h
26+
index 5f841824..29ea940c 100644
27+
--- a/pppd/pppd-private.h
28+
+++ b/pppd/pppd-private.h
29+
@@ -525,7 +525,7 @@ int parse_dotted_ip(char *, u_int32_t *)
30+
#define TIMEOUT(r, f, t) ppp_timeout((r), (f), (t), 0)
31+
#define UNTIMEOUT(r, f) ppp_untimeout((r), (f))
32+
33+
-#define BCOPY(s, d, l) memcpy(d, s, l)
34+
+#define BCOPY(s, d, l) memmove(d, s, l)
35+
#define BZERO(s, n) memset(s, 0, n)
36+
#define BCMP(s1, s2, l) memcmp(s1, s2, l)
37+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From f691c224e12ee13a1b317a1838d150f1ffef14a1 Mon Sep 17 00:00:00 2001
2+
From: Mateusz Poliwczak <mpoliwczak34@gmail.com>
3+
Date: Wed, 11 Feb 2026 00:40:14 +0100
4+
Subject: [PATCH] Remove MRU limit on PPPoE (#573)
5+
6+
Fixes #331
7+
8+
Signed-off-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
9+
---
10+
pppd/plugins/pppoe/plugin.c | 5 -----
11+
1 file changed, 5 deletions(-)
12+
13+
diff --git a/pppd/plugins/pppoe/plugin.c b/pppd/plugins/pppoe/plugin.c
14+
index b429a2fd..0f672166 100644
15+
--- a/pppd/plugins/pppoe/plugin.c
16+
+++ b/pppd/plugins/pppoe/plugin.c
17+
@@ -446,11 +446,6 @@ void pppoe_check_options(void)
18+
lcp_allowoptions[0].neg_pcompression = 0;
19+
lcp_wantoptions[0].neg_pcompression = 0;
20+
21+
- if (lcp_allowoptions[0].mru > MAX_PPPOE_MTU)
22+
- lcp_allowoptions[0].mru = MAX_PPPOE_MTU;
23+
- if (lcp_wantoptions[0].mru > MAX_PPPOE_MTU)
24+
- lcp_wantoptions[0].mru = MAX_PPPOE_MTU;
25+
-
26+
/* Save configuration */
27+
conn->storedmtu = lcp_allowoptions[0].mru;
28+
conn->storedmru = lcp_wantoptions[0].mru;

0 commit comments

Comments
 (0)