Skip to content

Commit de9c486

Browse files
edumazetkuba-moo
authored andcommitted
pptp: ensure minimal skb length in pptp_xmit()
Commit aabc659 ("net: ppp: Add bound checking for skb data on ppp_sync_txmung") fixed ppp_sync_txmunge() We need a similar fix in pptp_xmit(), otherwise we might read uninit data as reported by syzbot. BUG: KMSAN: uninit-value in pptp_xmit+0xc34/0x2720 drivers/net/ppp/pptp.c:193 pptp_xmit+0xc34/0x2720 drivers/net/ppp/pptp.c:193 ppp_channel_bridge_input drivers/net/ppp/ppp_generic.c:2290 [inline] ppp_input+0x1d6/0xe60 drivers/net/ppp/ppp_generic.c:2314 pppoe_rcv_core+0x1e8/0x760 drivers/net/ppp/pppoe.c:379 sk_backlog_rcv+0x142/0x420 include/net/sock.h:1148 __release_sock+0x1d3/0x330 net/core/sock.c:3213 release_sock+0x6b/0x270 net/core/sock.c:3767 pppoe_sendmsg+0x15d/0xcb0 drivers/net/ppp/pppoe.c:904 sock_sendmsg_nosec net/socket.c:712 [inline] __sock_sendmsg+0x330/0x3d0 net/socket.c:727 ____sys_sendmsg+0x893/0xd80 net/socket.c:2566 ___sys_sendmsg+0x271/0x3b0 net/socket.c:2620 __sys_sendmmsg+0x2d9/0x7c0 net/socket.c:2709 Fixes: 1da177e ("Linux-2.6.12-rc2") Reported-by: [email protected] Closes: https://lore.kernel.org/netdev/[email protected]/T/#u Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Dawid Osuchowski <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3b98c93 commit de9c486

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/net/ppp/pptp.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
159159
int len;
160160
unsigned char *data;
161161
__u32 seq_recv;
162-
163-
164-
struct rtable *rt;
162+
struct rtable *rt = NULL;
165163
struct net_device *tdev;
166164
struct iphdr *iph;
167165
int max_headroom;
@@ -179,16 +177,20 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
179177

180178
if (skb_headroom(skb) < max_headroom || skb_cloned(skb) || skb_shared(skb)) {
181179
struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom);
182-
if (!new_skb) {
183-
ip_rt_put(rt);
180+
181+
if (!new_skb)
184182
goto tx_error;
185-
}
183+
186184
if (skb->sk)
187185
skb_set_owner_w(new_skb, skb->sk);
188186
consume_skb(skb);
189187
skb = new_skb;
190188
}
191189

190+
/* Ensure we can safely access protocol field and LCP code */
191+
if (!pskb_may_pull(skb, 3))
192+
goto tx_error;
193+
192194
data = skb->data;
193195
islcp = ((data[0] << 8) + data[1]) == PPP_LCP && 1 <= data[2] && data[2] <= 7;
194196

@@ -262,6 +264,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)
262264
return 1;
263265

264266
tx_error:
267+
ip_rt_put(rt);
265268
kfree_skb(skb);
266269
return 1;
267270
}

0 commit comments

Comments
 (0)