Skip to content

Add kernelCTF CVE-2025-39946_lts_cos#304

Open
d4em0n wants to merge 5 commits intogoogle:masterfrom
star-sg:CVE-2025-39946_lts_cos_2
Open

Add kernelCTF CVE-2025-39946_lts_cos#304
d4em0n wants to merge 5 commits intogoogle:masterfrom
star-sg:CVE-2025-39946_lts_cos_2

Conversation

@d4em0n
Copy link
Contributor

@d4em0n d4em0n commented Dec 14, 2025

No description provided.

@koczkatamas koczkatamas added the kCTF: vuln OK The submission exploits the claims vulnerability (passed manual verification) label Jan 16, 2026
@koczkatamas koczkatamas changed the title Add CVE-2025-39946_lts_cos Add kernelCTF CVE-2025-39946_lts_cos Jan 16, 2026
Copy link
Collaborator

@matrizzo matrizzo left a comment

Choose a reason for hiding this comment

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

Hi, this PR has a lot of style issues. I've left comments on some of them. Please read our style guide (https://google.github.io/security-research/kernelctf/style_guide) and fix them. Thanks.

@matrizzo matrizzo self-assigned this Feb 25, 2026
d4em0n added a commit to star-sg/security-research that referenced this pull request Feb 26, 2026
- Replace magic numbers with named constants (#defines with comments)
- Break monolithic main() into descriptive functions
- Remove all unused code (DumpHex, PAUSE, commented-out blocks)
- Add @sleep(desc=...) annotations on all sleep() calls
- Add ROP gadget instruction comments and KERNEL_DEFAULT_BASE
- Add struct definitions for pipe_buffer layout offsets
- Move globals to local/function scope where appropriate
- Add MODULE_SYSFS_OPS JOP chain explanation in exploit.md and code comments
- Add KASLR bypass to COS exploit (was missing)
- Fix exploit.md grammar and restructure into numbered steps
- Replace magic numbers with named constants (#defines with comments)
- Break monolithic main() into descriptive functions
- Remove all unused code (DumpHex, PAUSE, commented-out blocks)
- Add @sleep(desc=...) annotations on all sleep() calls
- Add ROP gadget instruction comments and KERNEL_DEFAULT_BASE
- Add struct definitions for pipe_buffer layout offsets
- Move globals to local/function scope where appropriate
- Add MODULE_SYSFS_OPS JOP chain explanation in exploit.md and code comments
- Add KASLR bypass to COS exploit (was missing)
- Fix exploit.md grammar and restructure into numbered steps
@d4em0n d4em0n force-pushed the CVE-2025-39946_lts_cos_2 branch from fb7c22e to f2712dc Compare February 26, 2026 05:49
The 0x180 value is arbitrary, not specifically chosen to match
the kmalloc cache of skb_shinfo->frags. Clarify that AIO pages
are simply freed and later reclaimed by kmalloc allocations.
@matrizzo matrizzo added the recheck Triggers kernelCTF PR verification again label Feb 26, 2026
Copy link
Collaborator

@matrizzo matrizzo left a comment

Choose a reason for hiding this comment

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

Hi, thanks for your changes. This looks much better now but there are still a few issues to fix. Please take a look.


void build_and_send_payload(int conn)
{
char payload[1 << 16];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please define a constant PAYLOAD_SIZE for the size of this array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +495 to +496
fcntl(pfds[pipe_idx++][1], F_SETPIPE_SZ, PIPE_EXPAND_SIZE);
fcntl(pfds[pipe_idx++][1], F_SETPIPE_SZ, PIPE_EXPAND_SIZE);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is the same fcntl called twice on the same pipe here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are called on two different pipes — pipe_idx is post-incremented on each call (pipe_idx++), so the first fcntl expands pipe N and the second expands pipe N+1. This is intentional: we insert 2 pipe_buffer allocations per batch of MSGS_PER_PIPE_ALLOC msg_msgseg objects to ensure at least one pipe_buffer lands on each slab page. Added a clarifying comment.

/* Step 2: Allocate AIO pages, unix socketpair, memfd, and splice pipe
* (must be before msg queue/pipe allocation for correct slab ordering) */
int unix_fd[2];
SYSCHK(socketpair(AF_UNIX, SOCK_STREAM, 0, unix_fd));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This socket pair is seemingly never used. What is it for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed the unused socketpair.

typedef short i16;
typedef int i32;
typedef long long i64;
#define ARRAY_LEN(x) (sizeof(x) / sizeof(x[0]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This macro is never used, please remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

* Total size: 0x28 bytes, but allocated in 0xc0 (192) byte slab objects.
*/
#define PIPE_BUF_OPS_OFFSET 16 /* offset of ops pointer within pipe_buffer */
#define PIPE_BUF_PRIVATE_OFFSET 24 /* offset of private field within pipe_buffer */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Private is at offset 0x20, either this is supposed to be the offset of flags or the offset is wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +165 to +167
#define PIPE_BUF_OPS_OFFSET 16
#define PIPE_BUF_PRIVATE_OFFSET 24
#define PIPE_BUF_SLAB_SIZE 0xc0
Copy link
Collaborator

Choose a reason for hiding this comment

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

These names should follow our style guide (https://google.github.io/security-research/kernelctf/style_guide#approach-2) and be named <struct_name>_OFFS_<field_name>. For example: #define PIPE_BUFFER_OFFS_OPS 16

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

* KASLR bypass via EntryBleed-style prefetch timing side-channel
* ======================================================================== */

// #define KASLR_BYPASS_INTEL
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove all commented out code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

typedef short i16;
typedef int i32;
typedef long long i64;
#define ARRAY_LEN(x) (sizeof(x) / sizeof(x[0]))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This macro is never used, please remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment on lines +154 to +155
#define PIPE_BUF_OPS_OFFSET 16 /* offset of ops pointer within pipe_buffer */
#define PIPE_BUF_PRIVATE_OFFSET 24 /* offset of private field within pipe_buffer */
Copy link
Collaborator

Choose a reason for hiding this comment

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

These names should follow our style guide (https://google.github.io/security-research/kernelctf/style_guide#approach-2) and be named <struct_name>_OFFS_<field_name>. For example: #define PIPE_BUFFER_OFFS_OPS 16

In addition to that, the offset of private is wrong (should be 32) or it's supposed to be the offset of flags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

* KASLR bypass (EntryBleed-style prefetch timing side-channel)
* ======================================================================== */

// #define KASLR_BYPASS_INTEL
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove all commented out code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

- Remove unused typedefs (keep only u64) and ARRAY_LEN macro
- Rename pipe_buffer offset defines to follow style guide (PIPE_BUFFER_OFFS_OPS, PIPE_BUFFER_OFFS_FLAGS)
- Fix PIPE_BUF_PRIVATE_OFFSET: value 24 (0x18) is flags, not private (0x20)
- Make ktext local in main() and pass to build_and_send_payload()
- Move listen_vsockfd/listen_vsock_addr to static locals in vsock_pair()
- Rename puaf -> aio_ctx
- Add PAYLOAD_SIZE define
- Remove commented-out code (// #define KASLR_BYPASS_INTEL)
- COS: remove unused unix_fd socketpair, fix outdated header comment
- Add clarifying comment on two-pipe fcntl expansion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kCTF: vuln OK The submission exploits the claims vulnerability (passed manual verification) recheck Triggers kernelCTF PR verification again

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants