[PATCH] all crashes from kerneloops_regression_test() in kernel-crasher

manoj.iyer at canonical.com manoj.iyer at canonical.com
Fri Mar 27 20:58:05 GMT 2009


oops my bad that removing sysfs bit in the patch is noise, I inserted 
one of the patches I was testing..... attached the correct one.

diff -Naurp kernel-crasher/crasher.c kernel-crasher.new/crasher.c
--- kernel-crasher/crasher.c	2009-02-03 07:34:18.000000000 -0600
+++ kernel-crasher.new/crasher.c	2009-03-27 15:55:53.000000000 -0500
@@ -27,7 +27,8 @@
   * Changelog:
   *
   * 1 September 2006 - Jim Lieb <lieb at infoblox.com>
- *   V0.01 release
+ * 2 March 2009 - Manoj Iyer <manoj.iyer at canonical.com>
+ *   V0.02 release
   */

  #include <linux/types.h>
@@ -48,6 +49,8 @@ MODULE_DESCRIPTION("Crasher kernel OOPS/
  MODULE_LICENSE("GPL");
  MODULE_VERSION(CRASHER_VERSION);

+static void kerneloops_regression_test(int mode);
+
  /* expose the triggers via /sys/kernel/crash  */


@@ -55,6 +58,34 @@ MODULE_VERSION(CRASHER_VERSION);
  static struct kobj_attribute _name##_attr = \
  	__ATTR(_name, 0644, _name##_show, _name##_store)

+enum {
+	CRASH_BUG,
+	CRASH_OOPS,
+	CRASH_PANIC,
+	CRASH_WARN,
+	__DUMMY_CRASH_LAST,
+};
+
+void kerneloops_regression_test(int mode)
+{
+	switch(mode) {
+	case CRASH_OOPS:
+		*((int *) 0) = 0;
+		break;
+	case CRASH_BUG:
+		BUG(); 
+		break;
+	case CRASH_WARN:
+		WARN(1, "Crasher caused a WARN dump! pid=%u\n",
+		       current->pid);
+		break;
+	case CRASH_PANIC:
+		panic("Crasher caused a panic! pid=%u\n",
+		      current->pid);
+		break;
+	}
+}
+
  /* arm the crasher */

  static int crash_arm;
@@ -89,14 +120,11 @@ static ssize_t oops_store(struct kobject
  			 struct kobj_attribute *attr,
  			 const char *buf, size_t count)
  {
-	int *page0 = 0x0L;
-	int tmp = 0xDEADBEEF;
-
  	crash_oops = simple_strtoul(buf, NULL, 0);
  	if(crash_arm && crash_oops) {
  		printk(KERN_WARNING "Crasher caused a a segfault! pid=%u\n",
  		       current->pid);
-		*page0 = tmp; /* this is as far as we go... */
+		kerneloops_regression_test(CRASH_OOPS);
  	}
  	return count;
  }
@@ -121,7 +149,7 @@ static ssize_t bug_store(struct kobject
  	if(crash_arm && crash_bug) {
  		printk(KERN_WARNING "Crasher caused a BUG dump! pid=%u\n",
  		       current->pid);
-		BUG(); /* this is as far as we go... */
+		kerneloops_regression_test(CRASH_BUG);
  	}
  	return count;
  }
@@ -144,8 +172,7 @@ static ssize_t warn_store(struct kobject
  {
  	crash_warn = simple_strtoul(buf, NULL, 0);
  	if(crash_arm && crash_warn) {
-		WARN(1, "Crasher caused a WARN dump! pid=%u\n",
-		       current->pid);
+		kerneloops_regression_test(CRASH_WARN);
  	}
  	return count;
  }
@@ -168,8 +195,7 @@ static ssize_t panic_store(struct kobjec
  {
  	crash_panic = simple_strtoul(buf, NULL, 0);
  	if(crash_arm && crash_panic) {
-		panic("Crasher caused a panic! pid=%u\n",
-		      current->pid);
+		kerneloops_regression_test(CRASH_PANIC);
  	}
  	return count;
  }


--- manjo

On Fri, 27 Mar 2009, Jim Lieb wrote:

> On Friday 27 March 2009 13:13:59 Manoj Iyer wrote:
>> According to Arjan, all crashes that comes from function
>> kerneloops_regression_test() will be filtered and removed from
>> kernelopps.org. I modified crasher so that EIP points to
>> kerneloops_regression_test(). I tested this on my samsung netbook.
>>
>> [  416.394346] EIP is at kerneloops_regression_test+0x80/0x90 [crasher]
>> [  416.394356] EAX: 00000001 EBX: f7e792a0 ECX: ffffffff EDX: 05042000
>> [  416.394366] ESI: f6f127c0 EDI: f338de00 EBP: ee955f24 ESP: ee955f14
>> [  416.394376]  DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
>> [  416.394387] Process bash (pid: 4712, ti=ee954000 task=ee8fe480
>> task.ti=ee954000)
>> [  416.394396] Stack:
>> [  416.394402]  ee955f24 c0500ae1 f7e793cc ee955f30 ee955f34 f7e792ef
>> f7e793cc 00001268
>> [  416.394427]  ee955f48 c02c6f24 00000002 f3342a50 c06ad780 ee955f74
>> c020a962 00000002
>> [  416.394453]  08aff808 ee878e40 f338de14 c06ad780 f6f127c0 00000002
>> ee878e40 08aff808
>> [  416.394481] Call Trace:
>> [  416.394488]  [<c0500ae1>] ? printk+0x18/0x1f
>> [  416.394513]  [<f7e792ef>] ? oops_store+0x4f/0x54 [crasher]
>> [  416.394533]  [<c02c6f24>] ? kobj_attr_store+0x24/0x30
>> [  416.394551]  [<c020a962>] ? sysfs_write_file+0x92/0xf0
>> [  416.394568]  [<c01bd998>] ? vfs_write+0x98/0x110
>> [  416.394583]  [<c020a8d0>] ? sysfs_write_file+0x0/0xf0
>> [  416.394597]  [<c01bdacd>] ? sys_write+0x3d/0x70
>> [  416.394610]  [<c0103f6b>] ? sysenter_do_call+0x12/0x2f
>> [  416.394626]  [<c0500000>] ? relay_hotcpu_callback+0x4d/0xbd
>> [  416.394643] Code: c3 66 90 64 a1 00 40 7b c0 8b 80 f0 01 00 00 c7 04 24
>> 84 93 e7 f7 89 44 24 04 e8 29 79 68 c8 8d 74 26 00 85 c0 75 9e 0f 0b eb fe
>> <c7> 05 00 00 00 00 00 00 00 00 c9 c3 8d 74 26 00 55 31 d2 89 c8
>> [  416.394776] EIP: [<f7e790b0>] kerneloops_regression_test+0x80/0x90
>> [crasher] SS:ESP 0068:ee955f14
>> [  416.394800] ---[ end trace 9686a7c0863fa516 ]---
>>
>> Here is the patch to kernel-crasher:
>>
>> diff -Naurp kernel-crasher/crasher.c kernel-crasher.new/crasher.c
>> --- kernel-crasher/crasher.c	2009-02-03 07:34:18.000000000 -0600
>> +++ kernel-crasher.new/crasher.c	2009-03-27 15:08:24.000000000 -0500
>> @@ -27,7 +27,8 @@
>>    * Changelog:
>>    *
>>    * 1 September 2006 - Jim Lieb <lieb at infoblox.com>
>> - *   V0.01 release
>> + * 2 March 2009 - Manoj Iyer <manoj.iyer at canonical.com>
>> + *   V0.02 release
>>    */
>>
>>   #include <linux/types.h>
>> @@ -48,6 +49,8 @@ MODULE_DESCRIPTION("Crasher kernel OOPS/
>>   MODULE_LICENSE("GPL");
>>   MODULE_VERSION(CRASHER_VERSION);
>>
>> +static void kerneloops_regression_test(int mode);
>> +
>>   /* expose the triggers via /sys/kernel/crash  */
>>
>>
>> @@ -55,6 +58,34 @@ MODULE_VERSION(CRASHER_VERSION);
>>   static struct kobj_attribute _name##_attr = \
>>   	__ATTR(_name, 0644, _name##_show, _name##_store)
>>
>> +enum {
>> +	CRASH_BUG,
>> +	CRASH_OOPS,
>> +	CRASH_PANIC,
>> +	CRASH_WARN,
>> +	__DUMMY_CRASH_LAST,
>> +};
>> +
>> +void kerneloops_regression_test(int mode)
>> +{
>> +	switch(mode) {
>> +	case CRASH_OOPS:
>> +		*((int *) 0) = 0;
>> +		break;
>> +	case CRASH_BUG:
>> +		BUG();
>> +		break;
>> +	case CRASH_WARN:
>> +		WARN(1, "Crasher caused a WARN dump! pid=%u\n",
>> +		       current->pid);
>> +		break;
>> +	case CRASH_PANIC:
>> +		panic("Crasher caused a panic! pid=%u\n",
>> +		      current->pid);
>> +		break;
>> +	}
>> +}
>> +
>>   /* arm the crasher */
>>
>>   static int crash_arm;
>> @@ -70,6 +101,10 @@ static ssize_t arm_store(struct kobject
>>   			 const char *buf, size_t count)
>>   {
>>   	crash_arm = simple_strtoul(buf, NULL, 0);
>> +
>> +	if (!crash_arm)
>> +		sysfs_remove_group(kernel_kobj, &crash_attr_group);
>> +
>>   	return count;
>>   }
>>
>> @@ -89,14 +124,11 @@ static ssize_t oops_store(struct kobject
>>   			 struct kobj_attribute *attr,
>>   			 const char *buf, size_t count)
>>   {
>> -	int *page0 = 0x0L;
>> -	int tmp = 0xDEADBEEF;
>> -
>>   	crash_oops = simple_strtoul(buf, NULL, 0);
>>   	if(crash_arm && crash_oops) {
>>   		printk(KERN_WARNING "Crasher caused a a segfault! pid=%u\n",
>>   		       current->pid);
>> -		*page0 = tmp; /* this is as far as we go... */
>> +		kerneloops_regression_test(CRASH_OOPS);
>>   	}
>>   	return count;
>>   }
>> @@ -121,7 +153,7 @@ static ssize_t bug_store(struct kobject
>>   	if(crash_arm && crash_bug) {
>>   		printk(KERN_WARNING "Crasher caused a BUG dump! pid=%u\n",
>>   		       current->pid);
>> -		BUG(); /* this is as far as we go... */
>> +		kerneloops_regression_test(CRASH_BUG);
>>   	}
>>   	return count;
>>   }
>> @@ -144,8 +176,7 @@ static ssize_t warn_store(struct kobject
>>   {
>>   	crash_warn = simple_strtoul(buf, NULL, 0);
>>   	if(crash_arm && crash_warn) {
>> -		WARN(1, "Crasher caused a WARN dump! pid=%u\n",
>> -		       current->pid);
>> +		kerneloops_regression_test(CRASH_WARN);
>>   	}
>>   	return count;
>>   }
>> @@ -168,8 +199,7 @@ static ssize_t panic_store(struct kobjec
>>   {
>>   	crash_panic = simple_strtoul(buf, NULL, 0);
>>   	if(crash_arm && crash_panic) {
>> -		panic("Crasher caused a panic! pid=%u\n",
>> -		      current->pid);
>> +		kerneloops_regression_test(CRASH_PANIC);
>>   	}
>>   	return count;
>>   }
>>
>>
>> --- manjo
> kerneloops_regression_test is a good idea.
> The change removing the sysfs group in arm_store is a nak.
>
> There is another issue in that the module cannot be rmmod'd once
> it processes an oops.  I'll take these patches, keeping the kerneloops
> regression bit and update the module.
>
> Jim
> -- 
> Jim Lieb
> Ubuntu Kernel Team
> Canonical Ltd.
>



More information about the kernel-team mailing list