Skip to content

Commit 98237e6

Browse files
author
Guillaume Nault
committed
ppp: reject claimed-as-LCP but actually malformed packets
JIRA: https://issues.redhat.com/browse/RHEL-51059 Upstream Status: linux.git CVE: CVE-2024-41044 commit f2aeb73 Author: Dmitry Antipov <dmantipov@yandex.ru> Date: Mon Jul 8 14:56:15 2024 +0300 ppp: reject claimed-as-LCP but actually malformed packets Since 'ppp_async_encode()' assumes valid LCP packets (with code from 1 to 7 inclusive), add 'ppp_check_packet()' to ensure that LCP packet has an actual body beyond PPP_LCP header bytes, and reject claimed-as-LCP but actually malformed data otherwise. Reported-by: syzbot+ec0723ba9605678b14bf@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=ec0723ba9605678b14bf Fixes: 1da177e ("Linux-2.6.12-rc2") Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Guillaume Nault <gnault@redhat.com>
1 parent 60da98e commit 98237e6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

drivers/net/ppp/ppp_generic.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
#define MPHDRLEN_SSN 4 /* ditto with short sequence numbers */
7171

7272
#define PPP_PROTO_LEN 2
73+
#define PPP_LCP_HDRLEN 4
7374

7475
/*
7576
* An instance of /dev/ppp can be associated with either a ppp
@@ -491,6 +492,15 @@ static ssize_t ppp_read(struct file *file, char __user *buf,
491492
return ret;
492493
}
493494

495+
static bool ppp_check_packet(struct sk_buff *skb, size_t count)
496+
{
497+
/* LCP packets must include LCP header which 4 bytes long:
498+
* 1-byte code, 1-byte identifier, and 2-byte length.
499+
*/
500+
return get_unaligned_be16(skb->data) != PPP_LCP ||
501+
count >= PPP_PROTO_LEN + PPP_LCP_HDRLEN;
502+
}
503+
494504
static ssize_t ppp_write(struct file *file, const char __user *buf,
495505
size_t count, loff_t *ppos)
496506
{
@@ -513,6 +523,11 @@ static ssize_t ppp_write(struct file *file, const char __user *buf,
513523
kfree_skb(skb);
514524
goto out;
515525
}
526+
ret = -EINVAL;
527+
if (unlikely(!ppp_check_packet(skb, count))) {
528+
kfree_skb(skb);
529+
goto out;
530+
}
516531

517532
switch (pf->kind) {
518533
case INTERFACE:

0 commit comments

Comments
 (0)