linux/include/net
Catherine Zhang 877ce7c1b3 [AF_UNIX]: Datagram getpeersec
This patch implements an API whereby an application can determine the
label of its peer's Unix datagram sockets via the auxiliary data mechanism of
recvmsg.

Patch purpose:

This patch enables a security-aware application to retrieve the
security context of the peer of a Unix datagram socket.  The application
can then use this security context to determine the security context for
processing on behalf of the peer who sent the packet.

Patch design and implementation:

The design and implementation is very similar to the UDP case for INET
sockets.  Basically we build upon the existing Unix domain socket API for
retrieving user credentials.  Linux offers the API for obtaining user
credentials via ancillary messages (i.e., out of band/control messages
that are bundled together with a normal message).  To retrieve the security
context, the application first indicates to the kernel such desire by
setting the SO_PASSSEC option via getsockopt.  Then the application
retrieves the security context using the auxiliary data mechanism.

An example server application for Unix datagram socket should look like this:

toggle = 1;
toggle_len = sizeof(toggle);

setsockopt(sockfd, SOL_SOCKET, SO_PASSSEC, &toggle, &toggle_len);
recvmsg(sockfd, &msg_hdr, 0);
if (msg_hdr.msg_controllen > sizeof(struct cmsghdr)) {
    cmsg_hdr = CMSG_FIRSTHDR(&msg_hdr);
    if (cmsg_hdr->cmsg_len <= CMSG_LEN(sizeof(scontext)) &&
        cmsg_hdr->cmsg_level == SOL_SOCKET &&
        cmsg_hdr->cmsg_type == SCM_SECURITY) {
        memcpy(&scontext, CMSG_DATA(cmsg_hdr), sizeof(scontext));
    }
}

sock_setsockopt is enhanced with a new socket option SOCK_PASSSEC to allow
a server socket to receive security context of the peer.

Testing:

We have tested the patch by setting up Unix datagram client and server
applications.  We verified that the server can retrieve the security context
using the auxiliary data mechanism of recvmsg.

Signed-off-by: Catherine Zhang <cxzhang@watson.ibm.com>
Acked-by: Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2006-06-29 16:58:06 -07:00
..
bluetooth [Bluetooth] Reduce L2CAP MTU for RFCOMM connections 2006-02-13 11:39:57 +01:00
irda Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 2006-05-24 09:22:21 +01:00
netfilter Merge git://git.infradead.org/hdrcleanup-2.6 2006-06-20 15:10:08 -07:00
sctp Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2006-06-20 17:39:53 -07:00
tc_act [NETFILTER]: futher {ip,ip6,arp}_tables unification 2006-03-22 13:56:56 -08:00
tipc [TIPC]: Corrected potential misuse of tipc_media_addr structure. 2006-06-25 23:38:29 -07:00
act_api.h [PKT_SCHED]: Convert tc action functions to single skb pointers 2006-01-09 14:16:08 -08:00
act_generic.h [PKT_SCHED]: Fixup simple action define. 2005-05-19 12:42:39 -07:00
addrconf.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
af_unix.h [AF_UNIX]: Datagram getpeersec 2006-06-29 16:58:06 -07:00
ah.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
arp.h [IPV4]: Possible cleanups. 2006-04-14 15:00:20 -07:00
atmclip.h [INET_SOCK]: Move struct inet_sock & helper functions to net/inet_sock.h 2006-01-03 13:11:21 -08:00
ax25.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 2006-05-06 19:59:18 +01:00
checksum.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
compat.h Merge git://git.infradead.org/hdrcleanup-2.6 2006-06-20 15:10:08 -07:00
datalink.h [NET]: Kill skb->real_dev 2005-08-29 15:32:25 -07:00
dn.h [DECnet]: Endian annotation and fixes for DECnet. 2006-03-20 22:42:39 -08:00
dn_dev.h [DECnet]: Endian annotation and fixes for DECnet. 2006-03-20 22:42:39 -08:00
dn_fib.h [DECnet]: Endian annotation and fixes for DECnet. 2006-03-20 22:42:39 -08:00
dn_neigh.h [DECnet]: Endian annotation and fixes for DECnet. 2006-03-20 22:42:39 -08:00
dn_nsp.h [DECnet]: Endian annotation and fixes for DECnet. 2006-03-20 22:42:39 -08:00
dn_route.h [DECnet]: Endian annotation and fixes for DECnet. 2006-03-20 22:42:39 -08:00
dsfield.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
dst.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
esp.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
flow.h [DECnet]: Endian annotation and fixes for DECnet. 2006-03-20 22:42:39 -08:00
gen_stats.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
genetlink.h [PATCH] genetlink: don't touch module ref count 2006-01-13 13:06:40 -08:00
icmp.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
ieee80211.h [PATCH] wireless: Changes to ieee80211.h for user space regulatory daemon 2006-06-15 15:48:13 -04:00
ieee80211_crypt.h [PATCH] ieee80211: Add TKIP crypt->build_iv 2006-01-27 17:08:07 -05:00
ieee80211_radiotap.h [PATCH] ieee80211: Added ieee80211_radiotap.h 2005-09-21 23:03:55 -04:00
ieee80211softmac.h [PATCH] softmac: Fix handling of authentication failure 2006-06-05 15:51:30 -04:00
ieee80211softmac_wx.h [PATCH] softmac: add SIOCSIWMLME 2006-04-24 16:15:58 -04:00
if_inet6.h [IPV6]: ADDRCONF: Use our standard algorithm for randomized ifid. 2006-03-20 16:54:09 -08:00
inet6_connection_sock.h [IPV6]: Generalise some functions 2006-01-03 13:10:46 -08:00
inet6_hashtables.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
inet_common.h [NET]: move struct proto_ops to const 2006-01-03 13:11:15 -08:00
inet_connection_sock.h [ICSK] compat: Introduce inet_csk_compat_[gs]etsockopt 2006-03-20 22:46:16 -08:00
inet_ecn.h [INET_SOCK]: Move struct inet_sock & helper functions to net/inet_sock.h 2006-01-03 13:11:21 -08:00
inet_hashtables.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
inet_sock.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
inet_timewait_sock.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 2006-05-06 19:59:18 +01:00
inetpeer.h [IPV4]: Safer reassembly 2006-01-03 13:10:31 -08:00
ip.h Merge git://git.infradead.org/hdrcleanup-2.6 2006-06-20 15:10:08 -07:00
ip6_checksum.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ip6_fib.h [IPV6]: V6 route events reported with wrong netlink PID and seq number 2005-06-21 13:51:04 -07:00
ip6_route.h [IPV6]: ROUTE: Add experimental support for Route Information Option in RA (RFC4191). 2006-03-20 17:06:24 -08:00
ip6_tunnel.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ip_fib.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
ip_mp_alg.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
ip_vs.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
ipcomp.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ipconfig.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ipip.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
ipv6.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
ipx.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
iw_handler.h [PATCH] WE-20 for kernel 2.6.16 2006-03-23 07:12:57 -05:00
lapb.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
llc.h [LLC]: llc_mac_hdr_init const arguments 2006-03-20 22:59:36 -08:00
llc_c_ac.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
llc_c_ev.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
llc_c_st.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
llc_conn.h [PATCH] gfp flags annotations - part 1 2005-10-08 15:00:57 -07:00
llc_if.h [LLC]: add multicast support for datagrams 2006-06-17 21:26:08 -07:00
llc_pdu.h [LLC]: Fix typo 2005-11-14 21:58:18 -08:00
llc_s_ac.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
llc_s_ev.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
llc_s_st.h Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
llc_sap.h [LLC]: Fix the accept path 2005-09-22 07:57:21 -03:00
ndisc.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
neighbour.h [NEIGH]: Fix IP-over-ATM and ARP interaction. 2006-05-12 14:56:08 -07:00
netdma.h [I/OAT]: Utility functions for offloading sk_buff to iovec copies 2006-06-17 21:25:46 -07:00
netlink.h [NETLINK]: Generic netlink receive queue processor 2005-11-10 02:26:40 +01:00
netrom.h [NETROM]: Eleminate HZ from NET/ROM kernel interfaces 2006-05-03 23:27:47 -07:00
p8022.h [NET]: Fix sparse warnings 2005-08-29 16:01:32 -07:00
pkt_act.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
pkt_cls.h [NET]: Remove explicit initializations of skb->input_dev 2005-08-29 15:33:26 -07:00
pkt_sched.h [PKT_SCHED]: PSCHED_TADD() and PSCHED_TADD2() can result,tv_usec >= 1000000 2006-06-29 16:58:01 -07:00
protocol.h [NET]: Added GSO header verification 2006-06-29 16:57:53 -07:00
psnap.h [NET]: Kill skb->real_dev 2005-08-29 15:32:25 -07:00
raw.h Merge git://git.infradead.org/hdrcleanup-2.6 2006-06-20 15:10:08 -07:00
rawv6.h [IPV4/6]: Check if packet was actually delivered to a raw socket to decide whether to send an ICMP unreachable 2005-08-29 15:37:22 -07:00
red.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
request_sock.h [NET]: drop duplicate assignment in request_sock 2006-03-26 17:39:55 -08:00
rose.h [ROSE]: Eleminate HZ from ROSE kernel interfaces 2006-05-03 23:28:20 -07:00
route.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
sch_generic.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
scm.h [AF_UNIX]: Datagram getpeersec 2006-06-29 16:58:06 -07:00
slhc_vj.h [NET]: Remove __ARGS from include/net/slhc_vj.h 2005-07-05 15:12:04 -07:00
snmp.h [PATCH] smp_processor_id() cleanup 2005-06-21 18:46:13 -07:00
sock.h [NET]: fix net-core kernel-doc 2006-06-23 02:07:42 -07:00
syncppp.h [PATCH] drivers/net/wan/: possible cleanups 2005-09-14 08:36:54 -04:00
tcp.h [NET]: Added GSO header verification 2006-06-29 16:57:53 -07:00
tcp_ecn.h [NET]: Introduce inet_connection_sock 2005-08-29 15:43:19 -07:00
tcp_states.h [TCP]: Move the TCPF_ enum to tcp_states.h 2006-01-03 13:10:57 -08:00
timewait_sock.h [TWSK]: Introduce struct timewait_sock_ops 2006-01-03 13:10:54 -08:00
transp_v6.h [ICSK]: Rename struct tcp_func to struct inet_connection_sock_af_ops 2006-01-03 13:10:38 -08:00
udp.h [INET_SOCK]: Move struct inet_sock & helper functions to net/inet_sock.h 2006-01-03 13:11:21 -08:00
x25.h [X25]: allow ITU-T DTE facilities for x25 2006-03-22 00:01:31 -08:00
x25device.h [X25]: Restore skb->dev setting in x25_type_trans(). 2006-04-09 22:37:18 -07:00
xfrm.h [IPSEC] xfrm: Use IPPROTO_MAX instead of 256 2006-06-17 21:28:43 -07:00