Skip to content
Snippets Groups Projects
  • Jeff Vander Stoep's avatar
    Further restrict socket ioctls available to apps · 32333536
    Jeff Vander Stoep authored
    (cherry picked from commit 6ba383c5)
    
    Restrict unix_dgram_socket and unix_stream_socket to a whitelist.
    Disallow all ioctls for netlink_selinux_socket and netlink_route_socket.
    
    Neverallow third party app use of all ioctls other than
    unix_dgram_socket, unix_stream_socket, netlink_selinux_socket,
    netlink_route_socket, tcp_socket, udp_socket and rawip_socket.
    
    Bug: 28171804
    Change-Id: Icfe3486a62fc2fc2d2abd8d4030a5fbdd0ab30ab
    32333536
net.te 914 B
# Network types
type node, node_type;
type netif, netif_type;
type port, port_type;

# Use network sockets.
allow netdomain self:tcp_socket create_stream_socket_perms;
allow netdomain self:{ udp_socket rawip_socket } create_socket_perms;
# Connect to ports.
allow netdomain port_type:tcp_socket name_connect;
# Bind to ports.
allow netdomain node_type:{ tcp_socket udp_socket } node_bind;
allow netdomain port_type:udp_socket name_bind;
allow netdomain port_type:tcp_socket name_bind;
# See changes to the routing table.
allow netdomain self:netlink_route_socket { create read getattr write setattr lock append bind connect getopt setopt shutdown nlmsg_read };

# Talks to netd via dnsproxyd socket.
unix_socket_connect(netdomain, dnsproxyd, netd)

# Talks to netd via fwmarkd socket.
unix_socket_connect(netdomain, fwmarkd, netd)

# Connect to mdnsd via mdnsd socket.
unix_socket_connect(netdomain, mdnsd, mdnsd)