android_kernel_xiaomi_sm8350/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 Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
arch-clps711x [ARM] 3631/1: Remove legacy __mem_isa() definitions 2006-06-24 10:34:48 +01:00
arch-ebsa110 [ARM] ebsa110: Fix incorrect serial port address 2006-04-07 13:23:48 +01:00
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 Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 2006-05-06 19:59:18 +01:00
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 [ARM] Fix decompressor serial IO to give CRLF not LFCR 2006-03-28 10:24:33 +01:00
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 [ARM] Move FLUSH_BASE macros to asm/arch/memory.h 2006-04-07 13:22:21 +01:00
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 [ARM] Move FLUSH_BASE macros to asm/arch/memory.h 2006-04-07 13:22:21 +01:00
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 Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
assembler.h [ARM] Remove MODE_(SVC|IRQ|FIQ|USR) and DEFAULT_FIQ 2006-06-25 12:01:48 +01:00
atomic.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
auxvec.h
bitops.h [PATCH] bitops: arm: use generic bitops 2006-03-26 08:57:12 -08:00
bug.h Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 2006-05-06 19:59:18 +01:00
bugs.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
byteorder.h [ARM] Fix byte order macros for Thumb 2006-06-19 15:35:36 +01:00
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 [ARM] 3292/1: Fix memory corruption in asm-arm/checksum.h: ip_fast_csum() 2006-02-01 19:26:00 +00:00
cpu-multi32.h
cpu-single.h
cpu.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
cputime.h
current.h
delay.h [ARM] 3346/1: Fix udelay() for HZ values different from 100 2006-03-21 22:06:07 +00: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
domain.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
ecard.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
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 Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
hardirq.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
hardware.h
ide.h
io.h [PATCH] remove ISA legacy functions: remove the helpers 2006-03-24 07:33:19 -08:00
ioctl.h [PATCH] Generic ioctl.h 2006-01-10 08:01:34 -08:00
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 Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
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 [PATCH] add asm-generic/mman.h 2006-02-15 15:32:22 -08:00
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 [ARM] 3311/1: clean up include/asm-arm/mutex.h 2006-02-08 21:19:38 +00:00
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 [ARM] Move HZ definition into Kconfig 2006-03-21 22:05:45 +00:00
parport.h
pci.h Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
percpu.h
pgalloc.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
pgtable-hwdef.h [ARM] 3439/2: xsc3: add I/O coherency support 2006-04-02 00:07:39 +01:00
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 [PATCH] POLLRDHUP/EPOLLRDHUP handling for half-closed devices notifications 2006-03-25 08:22:56 -08:00
posix_types.h
proc-fns.h [ARM] nommu: adjust headers for !MMU ARM systems 2006-06-28 17:59:45 +01:00
processor.h [ARM] start_thread fixup for nommu mode 2006-01-13 21:04:17 +00:00
procinfo.h [ARM] 3517/1: move definition of PROC_INFO_SZ from procinfo.h to asm-offsets.h 2006-05-16 11:39:30 +01:00
ptrace.h [ARM] 3665/1: crunch: add ptrace support 2006-06-28 17:55:00 +01:00
resource.h
rtc.h [PATCH] RTC subsystem: ARM cleanup 2006-03-27 08:44:50 -08:00
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 Don't include linux/config.h from anywhere else in include/ 2006-04-26 12:56:16 +01:00
socket.h [AF_UNIX]: Datagram getpeersec 2006-06-29 16:58:06 -07:00
sockios.h
spinlock_types.h
spinlock.h [ARM] 3533/1: Implement the __raw_(read|write)_can_lock functions on ARM 2006-05-19 21:55:35 +01:00
stat.h [ARM] 3106/2: ARM EABI: some syscall adjustments 2006-01-14 16:32:12 +00:00
statfs.h [ARM] 3108/2: old ABI compat: statfs64 and fstatfs64 2006-01-14 16:35:03 +00:00
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 [ARM] noMMU: removes TLB codes in nommu mode 2006-03-21 22:03:20 +00:00
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
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 Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 2006-05-06 19:59:18 +01:00
user.h
vfp.h
vfpmacros.h [ARM] 3472/1: Use the D variants of FLDMIA/FSTMIA on ARMv6 2006-04-10 21:32:42 +01:00
vga.h [PATCH] vgacon: make VGA_MAP_MEM take size, remove extra use 2006-06-22 15:05:58 -07:00
xor.h