public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [tests/selinux] main: kernel/CVE-2026-99064: add test
@ 2026-11-09 15:54
0 siblings, 0 replies; only message in thread
From: @ 2026-11-09 15:54 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : tests/selinux
Branch : main
Commit : a68c7c035147505cdaa64d945d5835219625f12c
Author : Ondrej Mosnáček <omosnacek@gmail.com>
Date : 2026-11-09T14:29:40+01:00
Stats : +180/-0 in 4 file(s)
URL : https://src.fedoraproject.org/tests/selinux/c/a68c7c035147505cdaa64d945d5835219625f12c?branch=main
Log:
kernel/CVE-2026-99064: add test
Signed-off-by: Ondrej Mosnáček <omosnacek@gmail.com>
---
diff --git a/kernel/CVE-2026-99064/generate_test_packet.py b/kernel/CVE-2026-99064/generate_test_packet.py
new file mode 100755
index 0000000..c9b8386
--- /dev/null
+++ b/kernel/CVE-2026-99064/generate_test_packet.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+# A simple Python 3 script to generate the testing packet
+#
+# ./generate_test_packet.py >test_packet.data
+
+from scapy.all import IP, UDP, Raw
+
+import sys
+
+# Crafted IP options that will cause the vulnerable kernel to overwrite
+# the first 4 bytes of the UDP header with an IP address.
+opts = bytes([
+ 134, # option type - CIPSO
+ 13, # option length
+ 0, 0, 0, 16, # DOI
+ 1, # tag type 1
+ 7, # tag length
+ 0, # alignment octet
+ 0, # sensitivity
+ 0xff, 0xff, 0xff, # bitmap of categories
+ 7, # option type - RR
+ 11, # option length
+ 4, # RR pointer
+ 0, 0, 0, 0, # RR data
+ 0, 0, 0, 0, # RR data
+ 158, # option type - Experimental (contents should be ignored)
+ 13, # option length
+ 7, # [FAKE] option type - RR
+ 11, # [FAKE] option length
+ 16, # [FAKE] bogus RR pointer to triger OOB write into the payload
+ 0, 0, 0, 0, # [FAKE] RR data
+ 0, 0, 0, 0, # [FAKE] RR data
+])
+pkt = (
+ IP(src='10.0.1.2', dst='10.0.2.2', ttl=64, options=opts) /
+ UDP(sport=12345, dport=9999) /
+ Raw(load=b"success\n")
+)
+
+sys.stdout.buffer.write(bytes(pkt))
diff --git a/kernel/CVE-2026-99064/main.fmf b/kernel/CVE-2026-99064/main.fmf
new file mode 100644
index 0000000..ebd464f
--- /dev/null
+++ b/kernel/CVE-2026-99064/main.fmf
@@ -0,0 +1,41 @@
+summary: Test for CVE-2026-99064
+description: |
+ Verifies that setting up NetLabel to remove CIPSO options from packets
+ doesn't cause an unexpected write when processing the RR option in
+ ip_forward.
+contact: Ondrej Mosnacek <omosnace@redhat.com>
+component:
+ - kernel
+framework: beakerlib
+duration: 5m
+tier: 2
+require:
+ - iproute
+ - socat
+ - nmap-ncat
+ - netlabel_tools
+enabled: true
+environment:
+ AVC_ERROR: +no_avc_check
+check:
+ - how: avc
+ result: xfail
+link:
+ - relates:
+ https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6d25ffca055a77787c21a36b66c253f76239411b
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292432
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292433
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292435
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292437
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292439
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292441
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292443
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292446
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292447
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292449
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292450
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292451
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292453
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292455
+ - verifies: https://redhat.atlassian.net/browse/RHEL-292457
+ - verifies: https://bugzilla.redhat.com/show_bug.cgi?id=2559696
diff --git a/kernel/CVE-2026-99064/runtest.sh b/kernel/CVE-2026-99064/runtest.sh
new file mode 100755
index 0000000..cddd2ca
--- /dev/null
+++ b/kernel/CVE-2026-99064/runtest.sh
@@ -0,0 +1,99 @@
+#!/bin/bash
+# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Red Hat, Inc.
+# Author: Ondrej Mosnacek <omosnacek@gmail.com>
+
+# Include Beakerlib environment
+. /usr/share/beakerlib/beakerlib.sh || exit 1
+
+rlJournalStart
+ rlPhaseStartSetup
+ rlRun "uname -r" 0 "Print kernel version"
+
+ # Need to switch SELinux to permissive mode to avoid denials
+ # due to unlabeled network traffic.
+ selinux_status="$(getenforce)"
+ if [ "$selinux_status" = "Enforcing" ]; then
+ rlRun "setenforce 0" 0 "Switch to permissive mode"
+ fi
+
+ rlLogInfo "Set up two network namespaces used to trigger IPv4 routing scenario"
+ rlRun "ip netns add ingress"
+ rlRun "ip netns add destination"
+
+ rlLogInfo "Connect the two namespaces with a veth link"
+ rlRun "ip link add veth-out type veth peer name veth-in"
+ rlRun "ip link set veth-out netns ingress"
+ rlRun "ip link set veth-in netns destination"
+
+ rlLogInfo "Set up addresses and routes"
+ rlRun "ip -n ingress addr add 10.0.2.1/24 dev veth-out"
+ rlRun "ip -n ingress link set veth-out up"
+ rlRun "ip -n ingress link set lo up"
+
+ rlRun "ip -n destination addr add 10.0.2.2/24 dev veth-in"
+ rlRun "ip -n destination link set veth-in up"
+ rlRun "ip -n destination link set lo up"
+ # Needed to pass reverse-path validation
+ rlRun "ip -n destination route add 10.0.1.0/24 via 10.0.2.1"
+
+ rlLogInfo "Enable forwarding in the \"ingress\" namespace"
+ rlRun "ip netns exec ingress sysctl -w net.ipv4.ip_forward=1"
+
+ rlLogInfo "Set up netlabel to strip CIPSO options at packet level"
+ # NOTE: NetLabel configuration can only be set globally
+ rlRun "netlabelctl cipsov4 add pass doi:16 tags:1"
+ rlRun "netlabelctl map del default"
+ rlRun "netlabelctl map add default address:10.0.2.2/0 protocol:unlbl"
+ rlRun "netlabelctl map add default address:::/0 protocol:unlbl"
+ rlPhaseEnd
+
+ rlPhaseStartTest
+ rlRun "ip netns exec destination socat -u UDP-RECV:9999,reuseaddr CREAT:out.txt &" \
+ 0 "Run a simple UDP server in the destination namespace"
+ rlRun "while ! ip netns exec destination ncat --send-only -uzw 10 10.0.2.2 9999; do sleep 0.05; done" \
+ 0 "Wait for the server to start receiving"
+
+ # Inject a crafted packet into the 'ingress' namespace to trigger
+ # the bug. Note that we can't send the packet normally through a
+ # socket, because then netlabel would remove the CIPSO option too
+ # early, so the buggy scenario wouldn't trigger.
+ #
+ # When the bug is present, the UDP header of the packet will get
+ # corrupted when it's being routed through the 'ingress' namespace.
+ # If it's fixed, the packet will go through successfully and will
+ # be received by the server.
+ #
+ # To re-generate test_packet.data, run:
+ # ./generate_test_packet.py >test_packet.data
+ rlRun "ip netns exec ingress socat -u STDIN TUN:10.0.1.1/24,iff-up,tun-name=tun-in,iff-no-pi <test_packet.data" \
+ 0 "Send a crafted packet to trigger the bug"
+
+ rlRun "sleep 2" 0 "Wait to make sure the packet had a chance to be delivered"
+ rlRun "kill %1; wait" 0 "Terminate the server"
+
+ rlRun "cat out.txt" 0 "Dump the test output"
+
+ rlAssertGrep "success" out.txt -F
+ rlPhaseEnd
+
+ rlPhaseStartCleanup
+ rlRun "rm -f out.txt" 0 "Remove test output file"
+
+ rlLogInfo "Reset netlabel configuration"
+ rlRun "netlabelctl map del default"
+ rlRun "netlabelctl cipsov4 del doi:16"
+ rlRun "netlabelctl map add default protocol:unlbl"
+
+ rlLogInfo "Clean up the testing network namespaces"
+ # NOTE: This removes the associated veth interfaces as well
+ rlRun "ip netns del ingress"
+ rlRun "ip netns del destination"
+
+ if [ "$selinux_status" = "Enforcing" ]; then
+ rlRun "setenforce 1" 0 "Switch back to enforcing"
+ fi
+ rlPhaseEnd
+rlJournalPrintText
+rlJournalEnd
diff --git a/kernel/CVE-2026-99064/test_packet.data b/kernel/CVE-2026-99064/test_packet.data
new file mode 100644
index 0000000..4b551a6
Binary files /dev/null and b/kernel/CVE-2026-99064/test_packet.data differ
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-09 15:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-09 15:54 [tests/selinux] main: kernel/CVE-2026-99064: add test
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox