Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kernelCTF CVE-2024-50264_lts_cos #145

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

qwerty-theori
Copy link

No description provided.

@koczkatamas koczkatamas force-pushed the master branch 3 times, most recently from 933028d to c111d81 Compare March 3, 2025 14:31
@koczkatamas koczkatamas force-pushed the master branch 4 times, most recently from a70683f to fe221aa Compare March 13, 2025 14:32
@koczkatamas koczkatamas force-pushed the master branch 9 times, most recently from 76d6b57 to bf0d68f Compare March 13, 2025 15:39
Copy link
Collaborator

@koczkatamas koczkatamas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey,

This is just a quick code quality review. We're planning to review the submissions more deeply (actually understanding what the exploit does) in two weeks.

In general, the code in its current form does not match the requirements to be reviewed or accepted. Please follow our (draft) style guide to fix your code: https://google.github.io/security-research/kernelctf/style_guide. Also make sure you are meeting the documentation requirements of the rules.

I've left a few explicit comments too, but it's not enough to only fix those.

Thanks for the submission and PR!

@@ -0,0 +1,851 @@
#define _GNU_SOURCE
#include <stdio.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the files are included twice, some of the three times. Please remove the unnecessary includes.

void *heap_spray_stack = NULL;
volatile int status_spray = SPRAY_ERROR;

int timefds[0x500000];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only allocate as many array items as you need, this uses ~20MB of RAM most of which are unnecessary.

See the related style guide entry.

void *heap_spray_stack = NULL;
volatile int status_spray = SPRAY_ERROR;

int timefds[0x500000];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following variables could've been local variables: timefds, epfds, buf, targetstr, move them into local functions. Read more here: https://google.github.io/security-research/kernelctf/style_guide#usage-of-global-variables-instead-of-local-ones

}
struct sock_filter filter[0x1000];
char buf[0x1000];
#define SYSCHK(x) \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put defines like this at the top of the file.


int timefds[0x500000];
int epfds[0x500000];
char buf[0x1000];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This global variable is too generic, its name conflicts & shadowed with local variables. Consider renaming it to a descriptive name which tells its purpose (e.g. thread_sync_buf).

Relevant style guide entries:

printf("[%lld.%lld] victim_slab_to_buddy end\n", tp.tv_sec, tp.tv_nsec);
}

#define SEQ_FILE_CNT 0x300
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code seems to be not used, please remove it: https://google.github.io/security-research/kernelctf/style_guide#unused-code

}

printf("inuse: %d\n", inuse);
usleep(10000);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment here what you are waiting for (which kernel function): https://google.github.io/security-research/kernelctf/style_guide#sleeping--waiting

}

while(true)
sleep(100);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment here what you are waiting for, would the kernel crash if you would not wait?

int main(int argc, void *argv[])
{

alarm(120);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment here what you are using the alarm for.

if((socks[i] = socket(AF_VSOCK, SOCK_SEQPACKET, 0)) < 0)
perror("socket");

unsigned long size = 0xeeff0011;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment here why you are doing this and how did you choose this specific size.

@koczkatamas
Copy link
Collaborator

Also the COS exploit failed to repro. Any chance of being able to improve stability?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants