Skip to content

Commit 8cd8517

Browse files
committed
Merge: ppp: reject claimed-as-LCP but actually malformed packets
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4946 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 Signed-off-by: Guillaume Nault <gnault@redhat.com> Approved-by: Florian Westphal <fwestpha@redhat.com> Approved-by: Antoine Tenart <atenart@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents 1d99d9a + 98237e6 commit 8cd8517

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)