linux/include/net
Venkat Yekkirala 5b368e61c2 IPsec: correct semantics for SELinux policy matching
Currently when an IPSec policy rule doesn't specify a security
context, it is assumed to be "unlabeled" by SELinux, and so
the IPSec policy rule fails to match to a flow that it would
otherwise match to, unless one has explicitly added an SELinux
policy rule allowing the flow to "polmatch" to the "unlabeled"
IPSec policy rules. In the absence of such an explicitly added
SELinux policy rule, the IPSec policy rule fails to match and
so the packet(s) flow in clear text without the otherwise applicable
xfrm(s) applied.

The above SELinux behavior violates the SELinux security notion of
"deny by default" which should actually translate to "encrypt by
default" in the above case.

This was first reported by Evgeniy Polyakov and the way James Morris
was seeing the problem was when connecting via IPsec to a
confined service on an SELinux box (vsftpd), which did not have the
appropriate SELinux policy permissions to send packets via IPsec.

With this patch applied, SELinux "polmatching" of flows Vs. IPSec
policy rules will only come into play when there's a explicit context
specified for the IPSec policy rule (which also means there's corresponding
SELinux policy allowing appropriate domains/flows to polmatch to this context).

Secondly, when a security module is loaded (in this case, SELinux), the
security_xfrm_policy_lookup() hook can return errors other than access denied,
such as -EINVAL.  We were not handling that correctly, and in fact
inverting the return logic and propagating a false "ok" back up to
xfrm_lookup(), which then allowed packets to pass as if they were not
associated with an xfrm policy.

The solution for this is to first ensure that errno values are
correctly propagated all the way back up through the various call chains
from security_xfrm_policy_lookup(), and handled correctly.

Then, flow_cache_lookup() is modified, so that if the policy resolver
fails (typically a permission denied via the security module), the flow
cache entry is killed rather than having a null policy assigned (which
indicates that the packet can pass freely).  This also forces any future
lookups for the same flow to consult the security module (e.g. SELinux)
for current security policy (rather than, say, caching the error on the
flow cache entry).

This patch: Fix the selinux side of things.

This makes sure SELinux polmatching of flow contexts to IPSec policy
rules comes into play only when an explicit context is associated
with the IPSec policy rule.

Also, this no longer defaults the context of a socket policy to
the context of the socket since the "no explicit context" case
is now handled properly.

Signed-off-by: Venkat Yekkirala <vyekkirala@TrustedCS.com>
Signed-off-by: James Morris <jmorris@namei.org>
2006-10-11 23:59:37 -07:00
..
bluetooth [Bluetooth] Support create connection cancel command 2006-09-28 18:01:33 -07:00
irda [IrDA]: Memory allocations cleanups 2006-09-28 18:02:48 -07:00
netfilter
sctp [SCTP]: Cleanups 2006-09-22 15:19:03 -07:00
tc_act
tipc
act_api.h
addrconf.h [IPV6] ADDRCONF: Mobile IPv6 Home Address support. 2006-09-22 15:20:29 -07:00
af_unix.h
ah.h
arp.h [IPV4] net/ipv4/arp.c: trivial annotations 2006-09-28 18:02:14 -07:00
atmclip.h
ax25.h
checksum.h
cipso_ipv4.h [NetLabel]: audit fixups due to delayed feedback 2006-09-29 17:05:05 -07:00
compat.h
datalink.h
dn.h
dn_dev.h
dn_fib.h
dn_neigh.h
dn_nsp.h
dn_route.h
dsfield.h
dst.h [NET]: Annotate dst_ops protocol 2006-09-28 18:02:58 -07:00
esp.h [IPSEC] esp: Defer output IV initialization to first use. 2006-09-22 15:17:35 -07:00
fib_rules.h
flow.h IPsec: propagate security module errors up from flow_cache_lookup 2006-10-11 23:59:34 -07:00
gen_stats.h
genetlink.h [PATCH] Add genetlink utilities for payload length calculation 2006-10-01 00:39:29 -07:00
icmp.h [IPV4]: icmp_send() annotation 2006-09-28 18:01:06 -07:00
ieee80211.h
ieee80211_crypt.h
ieee80211_radiotap.h
ieee80211softmac.h
ieee80211softmac_wx.h
if_inet6.h [IPV6] ADDRCONF: Convert addrconf_lock to RCU. 2006-09-22 15:20:26 -07:00
inet6_connection_sock.h
inet6_hashtables.h
inet_common.h
inet_connection_sock.h [IPV4]: inet_csk_search_req() annotations 2006-09-28 18:02:15 -07:00
inet_ecn.h
inet_hashtables.h [IPV4]: annotate inet_lookup() and friends 2006-09-28 18:02:26 -07:00
inet_sock.h [IPV4]: annotate inet_lookup() and friends 2006-09-28 18:02:26 -07:00
inet_timewait_sock.h [IPV4]: inet_rcv_saddr() annotations 2006-09-28 18:02:28 -07:00
inetpeer.h [IPV4]: inetpeer annotations 2006-09-28 18:01:09 -07:00
ip.h [IPV4]: ip_icmp_error() annotations 2006-09-28 18:02:09 -07:00
ip6_checksum.h
ip6_fib.h [IPV6] ROUTE: Unify RT6_F_xxx and RT6_SELECT_F_xxx flags 2006-09-22 14:55:56 -07:00
ip6_route.h [NETFILTER]: ip6table_mangle: reroute when nfmark changes in NF_IP6_LOCAL_OUT 2006-09-22 15:19:51 -07:00
ip6_tunnel.h
ip_fib.h [IPV4]: net/ipv4/fib annotations 2006-09-28 18:02:23 -07:00
ip_mp_alg.h [IPV4]: multipath_set_nhinfo() annotations 2006-09-28 18:01:15 -07:00
ip_vs.h [IPVS]: ipvs annotations 2006-09-28 18:03:04 -07:00
ipcomp.h
ipconfig.h
ipip.h
ipv6.h [IPV6]: struct in6_addr annotations 2006-09-28 18:02:30 -07:00
ipx.h
iw_handler.h
lapb.h
llc.h
llc_c_ac.h
llc_c_ev.h
llc_c_st.h
llc_conn.h
llc_if.h
llc_pdu.h
llc_s_ac.h
llc_s_ev.h
llc_s_st.h
llc_sap.h
mip6.h [IPV6] MIP6: Add receiving mobility header functions through raw socket. 2006-09-22 15:07:01 -07:00
ndisc.h
neighbour.h [IPV6] NDISC: Set per-entry is_router flag in Proxy NA. 2006-09-22 15:20:24 -07:00
netdma.h Remove all inclusions of <linux/config.h> 2006-10-04 03:38:54 -04:00
netevent.h
netlabel.h NetLabel: fix a cache race condition 2006-10-11 23:59:29 -07:00
netlink.h [IPV4]: introduce nla_get_be32()/NLA_PUT_BE32() 2006-09-28 17:54:14 -07:00
netrom.h
nexthop.h
p8022.h
pkt_cls.h
pkt_sched.h
protocol.h
psnap.h
raw.h
rawv6.h
red.h
request_sock.h
rose.h
route.h [IPV4]: route.h annotations 2006-09-28 18:02:10 -07:00
sch_generic.h
scm.h
slhc_vj.h
snmp.h
sock.h [PATCH] Vectorize aio_read/aio_write fileop methods 2006-10-01 00:39:28 -07:00
syncppp.h
tcp.h
tcp_ecn.h
tcp_states.h
timewait_sock.h
transp_v6.h
udp.h [UDP]: saddr_cmp function should take const socket pointers 2006-09-22 15:18:23 -07:00
x25.h
x25device.h
xfrm.h IPsec: correct semantics for SELinux policy matching 2006-10-11 23:59:37 -07:00