附oops介绍(网上搜的,感谢作者):
Oops Messages
Oops 消息
Most bugs show themselves in NULL pointer dereferences or by the use of other incorrect pointer values. The usual outcome of such bugs is an oops message.
大多数bug通常是因为废弃了一个NULL指针或者使用了错误的指针值。这类bug导致的结果通常是一条oops消息。
Almost any address used by the processor is a virtual address and is mapped to physical addresses through a complex structure of page tables (the exceptions are physical addresses used with the memory management subsystem itself). When an invalid pointer is dereferenced, the paging mechanism fails to map the pointer to a physical address, and the processor signals a page fault to the operating system. If the address is not valid, the kernel is not able to “page in” the missing address; it (usually) generates an oops if this happens while the processor is in supervisor mode.
处理器使用的所有地址几乎都是通过一个复杂的页表结构对物理地址映射而得到的虚拟地址(除了内存管理子系统自己所使用的物理地址)。当一个非法的指针被废弃时,内存分页机制将不能为指针映射一个物理地址,处理器就会向操作系统发出一个页故障信号。如果地址不合法,那么内核将不能在该地址“布页”;;这时如果处理器处于超级用户模式,内核就会生成一条oops消息。
An oops displays the processor status at the time of the fault, including the contents of the CPU registers and other seemingly incomprehensible information. The message is generated by printk statements in the fault handler (arch/*/kernel/traps.c) and is dispatched as described earlier in Section 4.2.1).
一条oops消息能够显示发生故障时处理器的状态,以及CPU寄存器的内容和其他从表面难以理解的信息。该消息是由容错处理中的printk语句产生的(arch/*kernel/traps.c)并按照4.2.1小节中描述的方式进行分派。
Let’s look at one such message. Here’s what results from dereferencing a NULL pointer on a PC running Version 2.6 of the kernel. The most relevant information here is the instruction pointer (EIP), the address of the faulty instruction.
下面我们来看一条这样的消息。这是通过在一台运行着2.6内核的PC机上废弃一个NULL指针所引起的。其中最有关的信息是指令指针(EIP),就是故障指令的地址。
Unable to handle kernel NULL pointer dereference at virtual address 00000000 printing eip: d083a064 Oops: 0002 [#1] SMP CPU: 0 EIP: 0060:[] Not tainted EFLAGS: 00010246 (2.6.6) EIP is at faulty_write+0x4/0x10 [faulty] eax: 00000000 ebx: 00000000 ecx: 00000000 edx: 00000000 esi: cf8b2460 edi: cf8b2480 ebp: 00000005 esp: c31c5f74 ds: 007b es: 007b ss: 0068 Process bash (pid: 2086, threadinfo=c31c4000 task=cfa0a6c0) Stack: c0150558 cf8b2460 080e9408 00000005 cf8b2480 00000000 cf8b2460 cf8b2460 fffffff7 080e9408 c31c4000 c0150682 cf8b2460 080e9408 00000005 cf8b2480 00000000 00000001 00000005 c0103f8f 00000001 080e9408 00000005 00000005 Call Trace: [] vfs_write+0xb8/0x130 [] sys_write+0x42/0x70 [] syscall_call+0x7/0xb Code: 89 15 00 00 00 00 c3 90 8d 74 26 00 83 ec 0c b8 00 a6 83 d0

This message was generated by writing to a device owned by the faulty module, a module built deliberately to demonstrate failures. The implementation of the write method of faulty.c is trivial:
这条消息是由一个问题模块向其设备执行写操作时引起的,该模块是特意为示范故障而构建的。faulty.c中的write函数很普通:

ssize_t faulty_write (struct file *filp, const char _ _user *buf, size_t count, loff_t pos)
{
/
make a simple fault by dereferencing a NULL pointer */
*(int *)0 = 0;
return 0;
}
As you can see, what we do here is dereference a NULL pointer. Since 0 is never a valid pointer value, a fault occurs, which the kernel turns into the oops message shown earlier. The calling process is then killed.
如你所见,我们在这里做的就是废弃一个NULL指针。因为0从来都不是一个可用的指针值,所以会引发一个故障,内核会简单地将其转换为oops消息并显示。然后其调用进程会被杀死。

The faulty module has a different fault condition in its read implementation: faulty
该示例模块在其read函数中则有着不同的故障条件:
ssize_t faulty_read(struct file *filp, char _ _user *buf, size_t count, loff_t pos)
{
int ret;
char stack_buf[4];
/
Let’s try a buffer overflow /
memset(stack_buf, 0xff, 20);
if (count > 4)
count = 4;
/
copy 4 bytes to the user */
ret = copy_to_user(buf, stack_buf, count);
if (!ret)
return count;
return ret;
}
This method copies a string into a local variable; unfortunately, the string is longer than the destination array. The resulting buffer overflow causes an oops when the function returns. Since the return instruction brings the instruction pointer to nowhere land, this kind of fault is much harder to trace, and you can get something such as the following:
该函数将一个字符串赋给一个局部变量;不幸的是,字符串的长度超出了目标数组的范围。当函数返回时就会导致缓冲区溢出而引起一条oops消息。由于返回指令会带来指向空地址的指针,因此这类故障更加难以跟踪,你将会看到下面这样的信息:
EIP: 0010:[<00000000>] Unable to handle kernel paging request at virtual address ffffffff printing eip: ffffffff Oops: 0000 [#5] SMP CPU: 0 EIP: 0060:[] Not tainted EFLAGS: 00010296 (2.6.6) EIP is at 0xffffffff eax: 0000000c ebx: ffffffff ecx: 00000000 edx: bfffda7c esi: cf434f00 edi: ffffffff ebp: 00002000 esp: c27fff78 ds: 007b es: 007b ss: 0068 Process head (pid: 2331, threadinfo=c27fe000 task=c3226150) Stack: ffffffff bfffda70 00002000 cf434f20 00000001 00000286 cf434f00 fffffff7 bfffda70 c27fe000 c0150612 cf434f00 bfffda70 00002000 cf434f20 00000000 00000003 00002000 c0103f8f 00000003 bfffda70 00002000 00002000 bfffda70 Call Trace: [] sys_read+0x42/0x70 [] syscall_call+0x7/0xb Code: Bad EIP value.
In this case, we see only part of the call stack (vfs_read and faulty_read are missing), and the kernel complains about a “bad EIP value.” That complaint, and the offending address (ffffffff) listed at the beginning are both hints that the kernel stack has been corrupted.
这种情况下,你只能看到部分函数调用的堆栈情况(vfs_read和faulty_read丢失了),而且内核会为了一个“不可用的EIP值”而抱怨。这种抱怨以及开始部分列出的讨厌地址(ffffffff)都暗示了内核堆栈已经坍塌。
In general, when you are confronted with an oops, the first thing to do is to look at the location where the problem happened, which is usually listed separately from the call stack. In the first oops shown above, the relevant line is:
通常,当你面临一个oops时,首要问题就是查看故障的发生位置,它通常会与函数调用的堆栈信息分开列出。对于上面第一个oops,与此相关的信息是:
EIP is at faulty_write+0x4/0x10 [faulty]

Here we see that we were in the function faulty_write , which is located in the faulty module (which is listed in square brackets). The hex numbers indicate that the instruction pointer was 4 bytes into the function, which appears to be 10 (hex) bytes long. Often that is enough to figure out what the problem is.
这里可以看出我们正位于faulty模块(方括号中的是模块名称)的faulty_write函数中。十六进制的数字指明了该函数中的指令指针长度为4字节,而现在看起来则有10(十六进制)字节长。通常这足以查明问题的所在了。

If you need more information, the call stack shows you how you got to where things fell apart. The stack itself is printed in hex form; with a bit of work, you can often determine the values of local variables and function parameters from the stack listing. Experienced kernel developers can benefit from a certain amount of pattern recognition here; for example, if we look at the stack listing from the faulty_read oops:

如果你需要更多信息,函数调用的堆栈信息将会告诉你怎样找到已崩溃的东西。堆栈信息会以十六进制列出;稍加分析,你就能从中辨别出局部变量以及函数参数。有经验的内核开发者会从中获得很大的帮助;例如,faulty_read函数的堆栈信息如下所示:

Stack: ffffffff bfffda70 00002000 cf434f20 00000001 00000286 cf434f00 fffffff7 bfffda70 c27fe000 c0150612 cf434f00 bfffda70 00002000 cf434f20 00000000 00000003 00002000 c0103f8f 00000003 bfffda70 00002000 00002000 bfffda70

The ffffffff at the top of the stack is part of our string that broke things. On the x86 architecture, by default, the user-space stack starts just below 0xc0000000; thus, the recurring value 0xbfffda70 is probably a user-space stack address; it is, in fact, the address of the buffer passed to the read system call, replicated each time it is passed down the kernel call chain. On the x86 (again, by default), kernel space starts at 0xc0000000, so values above that are almost certainly kernel-space addresses, and so on.

位于堆栈顶部的ffffffff是引发故障的字符串的一部分。在x86体系中,默认用户空间中的堆栈地址是小于0xc00000000的;因此,其中0xbfffda70很有可能是一个用户空间的堆栈地址;实际上它就是传递给read系统调用的缓冲区的地址,它在内核调用链中每次被下传时都会被复制。在x86中(再次说明,缺省的),内核空间地址起始自0xc00000000,所以可以基本确定凡是大于该值的地址都是属于内核空间的地址。

Finally, when looking at oops listings, always be on the lookout for the “slab poisoning” values discussed at the beginning of this chapter. Thus, for example, if you get a kernel oops where the offending address is 0xa5a5a5a5, you are almost certainly forgetting to initialize dynamic memory somewhere.

最后要注意的一点是,当你查看oops信息时,始终要留意本章开始时讨论的“slab poisoning”的值。因此,如果一条内核oops中出现了讨厌的地址值0xa5a5a5a5,那么你肯定是在什么地方忘记初始化动态分配的内存了。

Please note that you see a symbolic call stack (as shown above) only if your kernel is built with the CONFIG_KALLSYMS option turned on. Otherwise, you see a bare, hexadecimal listing, which is far less useful until you have decoded it in other ways.

请注意要想看到一条可读的调用堆栈信息(如上所示),你必须要在构建内核时启用CONFIG_KALLSYMS选项。否则你将会看到一个原始的十六进制列表,在你使用其他方法译解它之前它几乎没什么用处。

来自linux设备驱动程序原文

linux上oops介绍相关推荐

  1. 在linux安装java过程_挑战Java在Linux上安装过程分享

    java是一种可以撰写跨平台应用软件的面向对象的程序设计语言,之前大部分用户都是在Windows平台上进行搭建的,对于在Linux环境上进行安装也会比较陌生,可见是一种挑战,下面一起来看看豆豆系统给大 ...

  2. linux上添加下载源的时候报错:无法添加 PPA:“‘此 PPA 不支持 bionic‘”,以及关于linuxPPA的介绍,如何查找软件包的PPA源,并添加PPA

    1 介绍LInux PPA 在介绍问题之前,首先来说明一下什么是PPA,清楚问题的本质,追根溯源,这样才能更明确问题,然后针对性的去解决这个问题! 1.1 为什么需要PPA PPA:Personal ...

  3. linux上很方便的上传下载文件工具rz和sz使用介绍

    简单说就是,可以很方便地用这两个sz/rz工具,实现Linux下和Windows之间的文件传输(发送和接收),速度大概为10KB/s,适合中小文件.rz/sz 通过Zmodem协议传输数据 一般来说, ...

  4. linux用sz下载文件夹,linux上很方便的上传下载文件工具rz和sz使用介绍

    一般来说,linux服务器大多是通过ssh客户端来进行远程的登陆和管理的,使用ssh登陆linux主机以后,如何能够快速的和本地机器进行文件的交互呢,也就是上传和下载文件到服务器和本地: 与ssh有关 ...

  5. linux自动登出时间,Linux 上让一段时间不活动的用户自动登出方法介绍

    让我们想象这么一个场景.你有一台服务器经常被网络中各系统的很多个用户访问.有可能出现某些用户忘记登出会话让会话保持会话处于连接状态.我们都知道留下一个处于连接状态的用户会话是一件多么危险的事情.有些用 ...

  6. 介绍linux上两种rootkits检测工具: Rootkit Hunter和Chkrootkit

    原贴:http://blog.csdn.net/linkboy2004/archive/2007/03/22/1537890.aspx 介绍linux上两种rootkits检测工具: Rootkit ...

  7. 【linux】在linux上生成SSH-key 简单原理介绍+生成步骤

    1.首先什么是SSH Secure Shell (SSH) 是一个允许两台电脑之间通过安全的连接进行数据交换的网络协议.通过加密保证了数据的保密性和完整性.SSH采用公钥加密技术来验证远程主机,以及( ...

  8. 怎么测试linux丢包率,linux上测试丢包率的工具iperf介绍

    今天要测试一下linux上udp的丢包率,查了一下,有个iperf的可以做这个,分别在发送端和接收端安装命令,然后运行一下就行了, 首先在服务端设置 iperf -p 80 -s -u -i 1 参数 ...

  9. 如何借助vsftpd在Linux上构建安全的FTP服务?

    FTP(文件传输协议)是互联网上广泛使用的服务之一,主要用于将文件从一个主机传输到另一个主机.FTP本身当初不是作为一种安全协议而设计的;正因为如此,典型的FTP服务很容易遭受诸如中间人***和蛮力* ...

最新文章

  1. Linux内核网络数据包发送(一)
  2. PyQt5 技术篇-调用文件对话框获取文件、文件夹路径。文件对话框返回选中的多个文件路径
  3. 分析linux系统的运行性能,Linux系统如何分析CPU的性能瓶颈
  4. Hadoop学习笔记—1.基本介绍与环境配置
  5. [ERROR] org.testng.TestNGException:Cannot find class in classpath:
  6. 集合习题之列出有限集合所有子集
  7. 图片保存到数据库和从数据库读取图片并显示(C#)
  8. 如何修改tomcat项目的图标
  9. 对多个有规律表进行更新剔重复操作的存储过程(up8000)
  10. linux查看系统后台,求助,如何查看后台服务
  11. headfirst设计模式(2)—观察者模式
  12. 【NOIP2012】【Luogu1080】国王游戏(贪心,邻项交换)
  13. jquery文档就绪的三种书写方式
  14. 火星时代室内效果图风暴10CD B
  15. 波特率、比特率和通信速率
  16. 电梯实时智能监测与诊断:应用人工智能的案例研究和解决方案
  17. 同时合并多个视频,并添加转场特效
  18. Windows 禁用U盘
  19. 有些梦想任时光侵袭也无法忘记,社科院杜兰金融管理硕士项目助你圆梦
  20. ASP.NET 安全认证(三)—— 用Form 表单认证实现单点登录(Single Sign On)

热门文章

  1. OpenGL矩阵学习
  2. 异常JasperException
  3. 【FPGA教程案例56】深度学习案例3——基于FPGA的CNN卷积神经网络之池化层verilog实现
  4. 如何做好新品牌的品牌宣传?
  5. 【金猿案例展】某保险公司——亚信科技大数据产品,助其数据管理 高效运营...
  6. Hadoop 3.0纠删码简单调研
  7. C#上位机开发源码 采用基于RS485通讯总线的ModbusRtu协议,支持用户权限管理
  8. 开源爱好者Sugar:从兴趣使然到不懈努力
  9. 深入理解深度学习——BERT派生模型:XLM(Cross-lingual Language Model)
  10. 使用注解对手机号及卡号加验工具类