kernel

内核审计系统初步分析(1)

最近一段时间在看内核关于审计的东西,今天作一点最近看的整理,内核的审计系统也算是比较新的东西了,还有内核跟踪一类的动西,也是在2。6。30中才看到有独立的目录了。

其实内核的审计还是没有跳出对进程的管理,也主要是是对每个进程的活动情况进行记录。在struct thread_info结构中的flags项中有增加了许多的内容,其中就有几个标志就是关于是否启用内核审计的。如下面的几项:

继续阅读

系统调用简单分析

#define CFI_STARTPROC .cfi_startproc //用在每个函数的开始,用于初始化一些内部数据结构 #define CFI_ENDPROC .cfi_endproc //在函数结束的时候使用与.cfi_startproc相配套使用 #define CFI_DEF_CFA .cfi_def_cfa //定义

继续阅读

内核的同步和互斥实例学习

#include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/mutex.h> #include <linux/semaphore.h> #include <linux/sched.h> static DEFINE_MUTEX(mut1); struct semaphore sem1,sem2; int test1(void *p) { down(&sem2); mutex_lock(&mut1); printk("get out test1\n"); mutex_unlock(&mut1); up(&sem1); return 0; } int test2(void *p) { down(&sem1); mutex_lock(&mut1); printk("get out test2\n"); mutex_unlock(&mut1); up(&sem2); return 0; } static int __init mutex_init_test() { init_MUTEX(&sem1); init_MUTEX_LOCKED(&sem2); printk("get out \n"); kernel_thread(test1, test1, CLONE_KERNEL); kernel_thread(test2, test2, CLONE_KERNEL); return 0; } static void __exit mutex_exit_test() { printk("get

继续阅读

使用proc来写GPIO驱动

这是写的一个gpio的驱动,测试完,提好的。

继续阅读

截获Linux系统调用

#include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/unistd.h> #include <linux/init.h> #include <asm/ptrace.h> #define NRB 2 typedef asmlinkage int (*__routine)(struct pt_regs); __routine old, new; unsigned long *sys_call_table = 0; static int counts = 0; unsigned long* find_sys_call_table(void) { struct { unsigned short limit; unsigned int base; } __attribute__ ( ( packed ) ) idtr; struct { unsigned short offset_low; unsigned short segment_select; unsigned char reserved, flags; unsigned short offset_high; } __attribute__

继续阅读

Linux内核中的P,V操作之P

最近作辅导讲到了P,V操作,我就在内核中看了一下Linux中的P,V操作的实现。很真是,理解比本科学习的时候深多了。操作系统中的P操作在Linux内核中对应的是down函数,V操作对用up函数。

继续阅读

Linux内核中的P,V操作之V

最近作辅导讲到了P,V操作,我就在内核中看了一下Linux中的P,V操作的实现。很真是,理解比本科学习的时候深多了。操作系统中的P操作在Linux内核中对应的是down函数,V操作对用up函数。

继续阅读

源代码中的中断分析(一)

(代码版本2.6.26) 中断描述符数组:irq_desc[]

继续阅读

2.6.22下基于Netfilter的网络监听程序

在2.6.22中skbuff发生了变化,使得我以前的防火墙程序在新内核中无法使用了,主要是可以当作一个网络数据监视,当然还是不完善的。目前只能监听数据报的源ip和目的ip,还有tcp报的原端口和目的端口。

继续阅读