1 / 44

Linux 内核分析和应用技术

Linux 内核分析和应用技术. 林丰波 linfb@sdu.edu.cn 2003,8. ToC. 推荐讨论主题 推荐小题目 题目: fork 和 signal 题目: shell 编程关键函数 题目:关于线程 题目: Hello 内核模块 题目:使用汇编或特权指令 题目:试验一个 timer 题目: gcc 和 glibc 题目:键盘支持 题目:扩充一个系统调用 题目:截获一个系统调用 题目:审计或识别某种动作 题目: Linux 主要发行版介绍 题目: Linux in VMWare 题目: Gentoo 安装

amos-young
Download Presentation

Linux 内核分析和应用技术

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linux内核分析和应用技术 林丰波 linfb@sdu.edu.cn 2003,8

  2. ToC • 推荐讨论主题 • 推荐小题目 • 题目:fork和signal • 题目:shell编程关键函数 • 题目:关于线程 • 题目:Hello内核模块 • 题目:使用汇编或特权指令 • 题目:试验一个timer • 题目:gcc和glibc • 题目:键盘支持 • 题目:扩充一个系统调用 • 题目:截获一个系统调用 • 题目:审计或识别某种动作 • 题目:Linux主要发行版介绍 • 题目:Linux in VMWare • 题目:Gentoo安装 • 题目:试用报告knoppix等

  3. 了解RTOS • 试用wine等 • 题目:诸许可比较 • 题目:Computing和Linux • 题目: VPN in Linux • 题目:Samba试验 • 题目:使用/proc • 题目:配置LXR • 题目:xinetd • 题目:wrapper • EMACS • TeX • 读书报告 • 综合设计 • User-mode linux • uClinux • FaQ

  4. 推荐讨论主题 • Linux编程概论 • make • make,cvs,autoconf/automake, • C/C++ • gcc特性,调试gdb • Assembly • as gcc nasm • Java

  5. - • 硬件 • IA32:体系、内存管理、特权级、中断机制、指令手册 • IA64:新的体系和区别 • Linux on IA64 • http://www.linuxia64.org/

  6. - • Linux网络程序设计 • socket • 后台守护进程daemon • “Linux 守护进程的编程方法” • fork、inittab • 被xinetd调用的进程的编程方法 • packet capture (promiscuous mode) • libpcap/winpcap,tcpdump/windump/ethereal • Linux模块 • 内核增强 • 设备驱动

  7. - • 文件系统 • 分区加密 • 网络实现 • IPv4/IPv6 • ipchain, iptable • http://www.netfilter.org/ • 内核新方向新进展 • 汉化问题见解 • 内核之争 • 内核变量调控 • /proc • /proc/sys/kernel • sysctl -a • 系统调用 • 窜改/监视 • 增强 • 调度 • 一般原理 • 多CPU支持

  8. - • 其他有意义主题 • Linux公司的经营模式 • Free/Open软件的再应用 • 积极参与题目,可以作业报告形式提交,也可在课堂大家讨论。

  9. 推荐小题目 从小处着手,由浅入深出 • 访问内核变量和函数 • 比如访问jiffies

  10. 题目:fork和signal • 体会fork和signal函数使用 • 设计一个程序,fork出一个子进程 • 子进程可以睡眠或死循环 • 子进程接收到USR1信号则退出 • 打印提示信息先 • 父进程用wait等待子进程退出 • 或者waitpid • fork和singal在服务器程序设计方面的应用 • 结合socket的ClientServer体制

  11. 题目:shell编程关键函数 • 写一个简单的shell • fork() • exec*() • wait/waitpid() • signal() • pipe() • 够了吗?还需要耐心 • 若要看bash的源代码,在 • http://www.gnu.org/software/bash/bash.html

  12. 题目:关于线程 • 写示例程序演示在windows/linux/unix中关于线程的编程接口 • beginthread()/CreateThread() • pthread_create()/… • 请看 #man pthread_create • 分析和讨论linux中是如何支持线程的 • 和fork的实现比较 • Links • 见备注行

  13. 题目:Hello内核模块 • 做一个HelloWorld内核模块 • 类似printf(“hello,world!”); • 用两个函数即可 • init_module() • printk(…) • cleanup_module() • 这个例子是后续很多小题目的基础,作业上也有实现

  14. 题目:使用汇编或特权指令 • 使用rdtsc指令获取CPU主频计数器 unsigned long low, high; asm ("rdtsc" : "=a" (low), "=d" (high)); printf("rdtsc=%lu,%lu\n", high, low); • 使用IO指令 • 在用户空间不能执行in/out指令,在内核里可以 • “segmentation fault” • 尝试在模块里用in/out指令读取开机CMOS信息 • (如果有的说) • 也可以破坏CMOS校验和,从而绕过开机口令 asm(“inb $0x70”)

  15. 题目:试验一个timer • ./include/linux/timer.h 23 extern void add_timer(struct timer_list * timer); 24 extern int del_timer(struct timer_list * timer); • 添加计时器,在动作函数中打印hello信息 • 如果不删除计时器,或者还没到时间就卸载模块会怎样? • 注意可能会死机,要注意文件存盘先

  16. 题目:gcc和glibc • glibc • gcc

  17. - • C Run-Time Libraries in Windows • printf(), memcpy(), fopen(), … • .h • stdio.h, stdlib.h, string.h, • .lib • .dll • Standard C++ Library

  18. 题目:键盘支持 • 键盘是最基本的输入支持设备 • 分析内核中是如何管理键盘设备的 • 键盘是字符设备 • ./drivers/char/keyboard.c • handle_scancode() • ctrl_alt_del是怎样实现的?

  19. 题目:扩充一个系统调用 • 找一个空闲的调用号k • 查看你的内核源代码的源程序 • 得针对你正所用的内核版本 • 把syscall表中的k位置指向你的调用函数 • 不必编译完整的内核 • 在模块初始化中做即可 • 在用户程序发起一个对k的调用 • 使用int80h,调用号放在?中 • 如果模块卸载了,用户还调用会怎样?

  20. 题目:截获一个系统调用 • 截获谁有意思呢? • open • read • … • 写一个自己的sys_myopen()函数 把syscall表中的OPEN项指向自己 • 可以在该函数中隐藏某种后门 • 在该函数中,做了额外的相关处理之后,不要忘了还得调用旧的sys_open函数 • 记得卸载模块时恢复旧的调用

  21. 题目:审计或识别某种动作 • 用户正在访问哪些文件 • 是否存在某个进程是个病毒进程(类似等等) • 用户正在访问哪些站点 • 网络接口正在接收或处理哪些异常的包? • 有网络入侵的尝试在发生吗? • 尝试做一个方面就行 • 或仅仅是设想或论述一下也可

  22. 题目:Linux主要发行版介绍 • Redhat • Debian • SuSE • Mandrake • …

  23. 题目:Linux in VMWare • 两个题目: • Linux in VMWare • Solaris in VMWare • 另:推荐Virtual PC

  24. 题目:Gentoo安装 • Gentoo的安装真原始,倒是挺锻炼基本功的。

  25. 题目:试用报告knoppix等 (1)Knoppix (2)Lindows (3)BeOS • 下载 • 安装 • 试用 • 报告 • 比较、评价

  26. 了解RTOS • Realtime Linux • QNX • VxWorks • DOS • Windows CE .NET • Windows XP embed • 试用报告

  27. 试用wine等 • WINE • CrossOver • WineX • ? • 试用报告

  28. 题目:诸许可比较 • GPL • BSD • … • 商业模式

  29. 题目:Computing和Linux • Computing • Super Computing • Parallel Computing • Cluster Computing • Distributed Computing • Grid Computing • NUMA vs. SMP vs. others • Linux在Computing中的地位和关系 • PVM / MPI

  30. • Linux集群技术 • Beowulf • Legion • Giganet cLAN • Cplant • MOSIX

  31. 题目: VPN in Linux • OpenVPN • Free S/WAN • OpenVPN较好操作,建议以OpenVPN为主,并和swan简单比较 • 以OpenVPN为工具组件虚拟私有网

  32. 题目:Samba试验 • 配置samba in Linux • 从linux中访问windows的共享目录 • 从windows中访问linux的共享目录 • 报告

  33. 题目:使用/proc • 使用/proc调整内核运行参数

  34. 题目:配置LXR • 用LXR建立一个Linux内核源代码阅读站点

  35. 题目:xinetd • xindet的原理和机制 • xindet中服务程序设计规范 • 举例

  36. 题目:wrapper • TCP Wrapper • hosts.deny hosts.allow

  37. EMACS

  38. TeX

  39. 读书报告 • 选择某本相关书籍 • 系统阅读 • 读书笔记 • 关键内容、实例运行、问题解决 • 章节选讲 • 就某个较典型的问题及其相关内容报告

  40. 综合设计 • 例子

  41. User-mode linux • 主站 • http://user-mode-linux.sourceforge.net/ • 介绍短文 • 在 http://www-900.ibm.com/cn/ • 查”user mode linux”

  42. uClinux • ARM+uClinux

  43. 开发工具 • GCC • Sun ONE Studio • NetBeans • Kylix • Eclipse • Google(“年度最受用户喜欢开发的工具”)

  44. FaQ

More Related