Skip to content

eBPF-based security platform

638 B
Raw Blame
// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
/*
 * Copyright (c) 2026 Authors of shirudo
 *
 * CVE-2026-31431 mitigation: refuse every AF_ALG socket, which takes the
 * algif_aead code the CVE is in out of reach, and with it all other use
 * of the kernel's crypto algorithms through sockets.
 */

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

#define AF_ALG	38
#define EPERM	1

char _license[] SEC("license") = "Dual BSD/GPL";

SEC("lsm/socket_create")
int BPF_PROG(cve_2026_31431_af_alg, int family, int type, int protocol,
	     int kern)
{
	if (family == AF_ALG)
		return -EPERM;
	return 0;
}