13 }
14
15
16 int main (int argc, char *argv[])
17 {
18 key_t mykey = 12345678;
19
20 const size_t region_size = sysconf(_SC_PAGE_SIZE);
21 int smid = shmget(mykey, region_size, IPC_CREAT|0600);
22 if(smid == -1)
23 error_out("shmget");
24
25 void *ptr;
26 ptr = shmat(smid, NULL, 0);
27 if (ptr == (void *) -1)
28 error_out("shmat");
29 u_long *d = (u_long *)ptr;
30 *d = 0xdeadbeef;
31 printf("ipc mem %#lx\n", *(u_long *)ptr);
32
33 return 0;
34 }
gcc test.c -o test -lrt
我们用root用户来执行本程序,创建共享内存,如下:
/tmp/test
ipc mem 0xdeadbeef
查看当前的共享内存
ipcs -m
------ Shared Memory Segments --------
key shmid owner perms bytes nattch
0x00bc614e 458752 root 600 4096 0
修改程序,将*d = 0xdeadbeef;改为*d = 0xffffffff;
再编译,用普通用户运行程序,如下:
gcc test.c -o test -lrt
su - test
/tmp/test
shmget: Permission denied
我们看到没有权限更改共享内存.
用root用户把CAP_IPC_OWNER能力授权给test程序,如下:
setcap cap_ipc_owner=eip /tmp/test
再次用普通用户运行程序test,更改共享内存,如下:
/tmp/test
ipc mem 0xffffffff status
linux/binfmts.h 146 include/linux/capability.h 147 include/linux/elf.h ...旋转锁将在第 10 章进行深入介绍。 如果你对 flags 在传送给 spin_lock_...
linux/binfmts.h 146 include/linux/capability.h 147 include/linux/elf.h ...内核体系结构的深入了解 442 3.4 Linux 内核的类型 444 3.5 设计和实现的...
下面,在具体深入 linux 内核分析研究之前,需要 对内核中进程相关的几个概念做...具体的实现:Processors typically provide this capability with a mode bit in ...
(HHARM9-EDU实验6中断、 14GPIO/key、AD/DA、I2C等) 进一步深入学习其它的...<linux/major.h> #include <linux/blkdev.h> #include <linux/capability.h...
capability of Linux.Based on the SMP support of Linux,the kernel of Linux...随着对中间件研究的深入,相关的技 术会越来越多,所设计的中间件产品性能会更好...
.c 功能:initializes some of the processor’s interrupt handling capability. ...2005-12-30 28 内容 Linux启动函数分析 X86下的Linux启动分析 ARM下的Linux...
amongallthemethodsofimprovingLinuxrealtimecapability,theprimarywayincludesthinning...本课题针对Linux实时调度策略单一性限帛lJLinux实时应用的情况,深入研 究和分析...
Linux下的Capabilities安全机制分析_IT/计算机_专业资料。Linux下的Capabilities...即将 r00t的特权分割成不同的capabIlIty(本文译为权能),每种 权能代表一定的...
(2008)03—0109—04 ResearchofReaI—TimeCapabilityofEmbeddedLinux0SZHANGZi—qiang...开发难度等方面对两者进行一些深入 的对比,以及分析:3.1实时性能 合前面提到的...
capability.h 147 /linux/elf.h 150 /linux/elfcore.h 156 /linux/errupt.h...(spin-lock)来控制对控制台访问旋转锁将在第10章进行深入介绍 如果你对 flags...
热门文档