LSM 启动过程

要使能一个 LSM 有两个步骤: 1、该 LSM 的编译选项被打开 各 LSM 代码中都会使用 DEFINE_LSM() 在内核中创建该模块。这个宏的定义如下: 1// include/linux/lsm_hooks.h 2 3#define DEFINE_LSM(lsm) \ 4 static struct lsm_info __lsm_##lsm \ 5 __used __section(".lsm_info.init") \ 6 __aligned(sizeof(unsigned long)) 其实就是创建了一个 struct lsm_info 的实例, …

Git Relevant Operations

Oh My Zsh’s git plugin responds slowly in big repo Add following lines into (local) .git/config or (global) ~/.gitconfig: link 1git config --add oh-my-zsh.hide-status 1 2git config --add oh-my-zsh.hide-dirty 1 Recover from shallow clone 1git fetch --unshallow https://stackoverflow.com/a/6802238 Shallow clone …

动态加载过程与 PLT、GOT 表

(TODO 补充关于编译时重定位、运行时重定位、PLT/GOT 表的背景知识) 本文将展示动态加载的过程,相关函数的地址如何在运行时被重定位,以及 PLT/GOT 表在其中的发挥的作用。以下面这段代码为例: 1#include <stdio.h> 2 3int main() 4{ 5 printf("Hey man!\n"); 6 return 0; 7} 编译 之前着实没想到,为了更好地展现 PLT/GOT 的过程,要在编译这块做这么多额外工作。 首先要添加 -fno-pie 和 -no-pie 两个选项,否则 GOT 里的函数地址会在 main() 执行前就被调整好,原本的过程就体现不出来了。这是从这 …

LSM 的 Security Blob 机制

Linux 内核主线相关补丁: 1ecd5f82e05dd LSM: Infrastructure management of the ipc security blob 2019bcca4626a Smack: Abstract use of ipc security blobs 37c6538280ae9 SELinux: Abstract use of ipc security blobs 4f4ad8f2c4076 LSM: Infrastructure management of the task security 5afb1cbe37440 LSM: Infrastructure management of the …

CVE-2021-43057 分析

0x00 基本信息 信息总览:NVD 链接 漏洞披露:bugs.chromium.org 漏洞评估:CVSS 7.8 上游补丁:链接 0x01 详细描述 在 selinux_ptrace_traceme 函数(即 SELinux 对 PTRACE_TRACEME 的 LSM 接口的实现)中发现一个 Use-After-Free 问题,该问题是由于错误地尝试获取其他内核任务的*主体凭证(Subjective Credential)*而导致的。具体情况如下: 原先在 SELinux 中,有个函数 task_sid() 可以获取一个内核任务的*客体凭证(Objective Credential)*所对应的 SID,但却被用在了一些应该使用 …