0
点赞
收藏
分享

微信扫一扫

Kernel: 编译配置:GCC_PLUGIN_RANDSTRUCT

兵部尚输 2022-02-08 阅读 80

文章目录

参考

https://lwn.net/Articles/722293/
arch/Kconfig
https://grsecurity.net/
https://pax.grsecurity.net/
https://www.openwall.com/lists/kernel-hardening/2017/04/06/14

说明

bool “Randomize layout of sensitive kernel structures” depends on GCC_PLUGINS
select MODVERSIONS if MODULES
帮助:如果选择Y,编译时会对只含有函数指针的结构体(没有显示声明__no_randomize_layout),还有显示声明__randomize_layout的结构体,做布局上的随机化。这样会对漏洞攻击,带来额外麻烦,因为需要的信息更多。
同时,会带来性能的影响,和些许的内存损耗,而且会影响法律/开源验证相关工具的使用,例如Volatility。(除非在内核安装之后不对源代码目录做删除)。
编译时用到的种子在文件:scripts/gcc-plgins/randomize_layout_seed.h. make clean 不会删除这个文件,这样的话外部模块就可以根据这个种子文件进行同步编译。make mrproper 和 make distclean会清除这个文件。
Note that the implementation requires gcc 4.7 or newer.

例子

struct signal_struct {
} __randomize_layout;

实现

include/linux/compiler-gcc.h
#define __randomize_layout attribute((randomize_layout))
scripts/gcc-plugins/randomize_layout_plugin.c
实现机制是怎么样的?

举报

相关推荐

0 条评论