android_kernel_xiaomi_sm7250/include/asm-arm
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
..
arch-aaec2000 [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-at91rm9200 [ARM] 3660/1: Remove legacy defines 2006-06-28 17:54:55 +01:00
arch-cl7500
arch-clps711x [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-ebsa110
arch-ebsa285 [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-ep93xx [ARM] 3634/1: ep93xx: initial implementation of the clk_* API 2006-06-24 10:33:02 +01:00
arch-h720x [ARM] 3660/1: Remove legacy defines 2006-06-28 17:54:55 +01:00
arch-imx [ARM] 3660/1: Remove legacy defines 2006-06-28 17:54:55 +01:00
arch-integrator [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-iop3xx [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-ixp4xx
arch-ixp23xx [ARM] 3662/1: ixp23xx: don't include asm/hardware.h in uncompress.h 2006-06-28 17:54:56 +01:00
arch-ixp2000
arch-l7200 [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-lh7a40x [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-netx [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-omap [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-pnx4008 [ARM] 3621/1: fix compilation breakage for pnx4008 2006-06-22 10:27:15 +01:00
arch-pxa [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-realview [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-rpc
arch-s3c2410 [ARM] 3661/1: S3C2412: Fix compilation if CPU_S3C2410 only 2006-06-28 17:54:54 +01:00
arch-sa1100 [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-shark
arch-versatile [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
hardware [PATCH] backlight: LOCOMO Backlight Driver updates 2006-06-26 09:58:28 -07:00
mach Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/pci-2.6 2006-06-29 10:49:17 -07:00
a.out.h
apm.h
assembler.h [ARM] Remove MODE_(SVC|IRQ|FIQ|USR) and DEFAULT_FIQ 2006-06-25 12:01:48 +01:00
atomic.h
auxvec.h
bitops.h
bug.h
bugs.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
byteorder.h
cache.h
cacheflush.h
checksum.h
cpu-multi32.h
cpu-single.h
cpu.h
cputime.h
current.h
delay.h
div64.h
dma-mapping.h
dma.h
domain.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
ecard.h
elf.h
emergency-restart.h
errno.h
fcntl.h
fiq.h
floppy.h [PATCH] random: remove SA_SAMPLE_RANDOM from floppy driver 2006-06-25 10:01:00 -07:00
fpstate.h [ARM] 3370/2: ep93xx: add crunch support 2006-06-28 17:55:01 +01:00
futex.h
glue.h
hardirq.h
hardware.h
ide.h
io.h
ioctl.h
ioctls.h
ipc.h
ipcbuf.h
irq.h [PATCH] adjust handle_IRR_event() return type 2006-06-23 07:43:08 -07:00
kmap_types.h
leds.h
limits.h
linkage.h
local.h
locks.h
mc146818rtc.h
memory.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
mman.h
mmu_context.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
mmu.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
mmzone.h
module.h
msgbuf.h
mtd-xip.h
mutex.h
namei.h
nwflash.h
page-nommu.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
page.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
param.h
parport.h
pci.h
percpu.h
pgalloc.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
pgtable-hwdef.h
pgtable-nommu.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
pgtable.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
poll.h
posix_types.h
proc-fns.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
processor.h
procinfo.h
ptrace.h [ARM] 3665/1: crunch: add ptrace support 2006-06-28 17:55:00 +01:00
resource.h
rtc.h
scatterlist.h
sections.h
segment.h
semaphore-helper.h
semaphore.h
sembuf.h
serial.h
setup.h
shmbuf.h
shmparam.h
sigcontext.h
siginfo.h
signal.h
sizes.h
smp.h
socket.h [AF_UNIX]: Datagram getpeersec 2006-06-29 16:58:06 -07:00
sockios.h
spinlock_types.h
spinlock.h
stat.h
statfs.h
string.h
suspend.h
system.h Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm 2006-06-20 17:52:36 -07:00
termbits.h
termios.h
therm.h
thread_info.h [ARM] 3370/2: ep93xx: add crunch support 2006-06-28 17:55:01 +01:00
thread_notify.h [ARM] Add thread_notify infrastructure 2006-06-22 10:24:18 +01:00
timex.h
tlb.h
tlbflush.h
topology.h
traps.h
types.h
uaccess.h [ARM] nommu: uaccess tweaks 2006-06-28 17:59:46 +01:00
ucontext.h [ARM] 3664/1: crunch: add signal frame save/restore 2006-06-28 17:54:59 +01:00
unaligned.h
unistd.h
user.h
vfp.h
vfpmacros.h
vga.h [PATCH] vgacon: make VGA_MAP_MEM take size, remove extra use 2006-06-22 15:05:58 -07:00
xor.h