Re: [PATCH] selinux: don't label bridged packets in selinux_ip_forward()
From: Stephen Smalley
Date: Fri Oct 16 2026 - 15:12:42 EST
On Fri, Oct 16, 2026 at 10:37 AM Joas Antonio dos Santos
<joasantonio108@xxxxxxxxx> wrote:
>
> With br_netfilter and bridge-nf-call-ip{,6}tables enabled, bridged IP
> packets go through the NF_INET_FORWARD hook, where selinux_ip_forward()
> calls selinux_netlbl_skbuff_setsid() and NetLabel may add or remove a
> CIPSO or CALIPSO option. cipso_v4_skbuff_setattr(),
> calipso_skbuff_setattr() and calipso_skbuff_delattr() move the IP
> header and reset the network header, but the Ethernet header stays
> where it was; when the bridge pushes it back in front of the packet it
> picks up stale bytes and the frame goes out with a garbage destination
> MAC and EtherType.
>
> Labeling a bridged packet based on its IP addresses is not what we want
> here anyway, so leave bridged packets alone. Add a stub of
> nf_bridge_info_exists() for CONFIG_BRIDGE_NETFILTER=n.
>
> Tested with QEMU, two veths enslaved to a bridge with br_netfilter in
> the middle, SELinux and a NetLabel DOI 16 configuration, 5 UDP packets
> per case:
>
> case before after
> CALIPSO packet, unlabeled destination MAC garbage 5/5
> unlabeled IPv6, CALIPSO destination MAC garbage 5/5
> unlabeled IPv4, CIPSO destination MAC garbage 5/5
>
> Routed packets are still labeled (an unlabeled packet forwarded towards
> a CALIPSO destination gets the option, 5/5).
>
> Fixes: 948bf85c1bc9 ("netlabel: Add functionality to set the security attributes of a packet")
> Link: https://lore.kernel.org/netdev/CAHC9VhS+bdL_YnLQtd0sPmKKfy9BvS-LWV_6EhAuu4qfUFe_mw@xxxxxxxxxxxxxx/
> Suggested-by: Paul Moore <paul@xxxxxxxxxxxxxx>
> Signed-off-by: Joas Antonio dos Santos <joasantonio108@xxxxxxxxx>
> Assisted-by: Claude:claude-opus-5-5
Acked-by: Stephen Smalley <stephen.smalley.work@xxxxxxxxx>