linux/include/asm-sparc
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
..
a.out.h
apc.h
asi.h
asmmacro.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
atomic.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
auxio.h
auxvec.h
bitext.h
bitops.h
bpp.h
bsderrno.h
btfixup.h
bug.h
bugs.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
byteorder.h
cache.h
cacheflush.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
checksum.h
clock.h
contregs.h
cpudata.h
cputime.h
current.h
cypress.h
delay.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
div64.h
dma-mapping.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
dma.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
ebus.h [SPARC]: Port of_device layer and make ebus use it. 2006-06-23 23:15:47 -07:00
ecc.h
eeprom.h
elf.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
emergency-restart.h
errno.h
fbio.h
fcntl.h
fixmap.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
floppy.h
futex.h
hardirq.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
head.h
highmem.h
hw_irq.h
ide.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
idprom.h
io-unit.h
io.h [SPARC]: Add iomap interfaces. 2006-06-25 23:24:24 -07:00
ioctl.h
ioctls.h
iommu.h
ipc.h
ipcbuf.h
irq.h [PATCH] adjust handle_IRR_event() return type 2006-06-23 07:43:08 -07:00
jsflash.h
kdebug.h
kgdb.h
kmap_types.h
linkage.h
local.h
machines.h
mbus.h
mc146818rtc.h
memreg.h
mman.h
mmu.h
mmu_context.h
module.h
mostek.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
mpmbox.h
msgbuf.h
msi.h
mutex.h
mxcc.h
namei.h
obio.h
of_device.h [SPARC]: Port of_device layer and make ebus use it. 2006-06-23 23:15:47 -07:00
openprom.h
openpromio.h
oplib.h
page.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
param.h
pbm.h [SPARC]: Port sparc64 in-kernel device tree code to sparc32. 2006-06-23 23:15:45 -07:00
pci.h
pcic.h
pconf.h
percpu.h
perfctr.h
pgalloc.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
pgtable.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
pgtsrmmu.h
pgtsun4.h
pgtsun4c.h
poll.h
posix_types.h
processor.h
prom.h [SPARC]: Add unique device_node IDs and a ".node" property. 2006-06-25 23:18:57 -07:00
psr.h
ptrace.h
reg.h
resource.h
ross.h
rtc.h
sbi.h
sbus.h [SBUS]: Rewrite and plug into of_device framework. 2006-06-23 23:15:50 -07:00
scatterlist.h
sections.h
semaphore.h
sembuf.h
setup.h
sfp-machine.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
shmbuf.h
shmparam.h
sigcontext.h
siginfo.h
signal.h
smp.h Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/sparc-2.6 2006-06-20 17:39:28 -07:00
smpprim.h
socket.h [AF_UNIX]: Datagram getpeersec 2006-06-29 16:58:06 -07:00
sockios.h
solerrno.h
spinlock.h [SPARC]: Add missing rw can_lock macros 2006-06-20 00:35:13 -07:00
spinlock_types.h
stat.h
statfs.h
string.h
sun4paddr.h
sun4prom.h
sunbpp.h
svr4.h
swift.h
sysen.h
system.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
termbits.h
termios.h
thread_info.h
timer.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
timex.h
tlb.h
tlbflush.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
topology.h
traps.h
tsunami.h
turbosparc.h
types.h
uaccess.h
unaligned.h
unistd.h 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
user.h
vac-ops.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
vaddrs.h
vfc_ioctls.h
vga.h
viking.h
winmacro.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
xor.h