#!/usr/bin/env -S stap -g --runtime=bpf global cve_name = "CVE-2026-31431" // Work around CVE-2026-31431 by blocking AF_ALG AEAD socket bind operations // using BPF LSM hooks. This prevents userspace from binding to the vulnerable // AEAD cipher interface that could trigger the kernel vulnerability. // // Requires kernel 5.7+ with CONFIG_BPF_LSM=y and kernel headers. // // Based on the core algorithm in: // https://github.com/atgreen/block-copyfail/blob/main/block-copyfail.lisp global hit_count probe lsm.socket_bind { // socket_bind(struct socket *sock, struct sockaddr *address, int addrlen) // $ctx points to the LSM hook context containing the parameters // The second parameter (address) is at ctx + 8 bytes (second u64) sockaddr_ptr = user_long($ctx + 8) // Read sa_family (first 2 bytes of sockaddr_alg) sa_family = @cast(sockaddr_ptr, "sockaddr_alg", "kernel")->salg_family // Check if this is AF_ALG (38) binding if (sa_family == 38) { // AF_ALG // Read the type field - check if it starts with "aead" type0 = @cast(sockaddr_ptr, "sockaddr_alg", "kernel")->salg_type[0] type1 = @cast(sockaddr_ptr, "sockaddr_alg", "kernel")->salg_type[1] type2 = @cast(sockaddr_ptr, "sockaddr_alg", "kernel")->salg_type[2] type3 = @cast(sockaddr_ptr, "sockaddr_alg", "kernel")->salg_type[3] type4 = @cast(sockaddr_ptr, "sockaddr_alg", "kernel")->salg_type[4] if (type0 == 97 && // 'a' type1 == 101 && // 'e' type2 == 97 && // 'a' type3 == 100 && // 'd' type4 == 0) { // '\0' hit_count++ printf("BLOCKED AF_ALG AEAD bind from %s[%d]\n", execname(), pid()) $return = -1 // EPERM - block the bind } } } probe begin { println("Blocking AF_ALG AEAD socket binds (CVE-2026-31431)") }