Skip to content

Instantly share code, notes, and snippets.

@hj91
Created February 23, 2013 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hj91/5020146 to your computer and use it in GitHub Desktop.
Save hj91/5020146 to your computer and use it in GitHub Desktop.
generating segfault and logging it in kern.log
/* this code is meant to run on MS DOS machines and uses bios bit setting to turn CAPS LOCK on or off */
/* it contains far keyword, which is not used in gcc */
#include <stdio.h>
void main()
{
char *kb;
kb = (char *)0x417;
*kb = 64;
}
/* use gcc lockcap.c -o lockcap.c; ./lockcap */
/*
output of dmesg after segmentation fault
[14938.955220] lockcap[8323]: segfault at 417 ip 080483d4 sp bfd6b2f8 error 6 in lockcap[8048000+1000]
[14973.194071] lockcap[8336]: segfault at 417 ip 080483a4 sp bfd6ba68 error 6 in lockcap[8048000+1000]
[14994.645856] lockcap[8339]: segfault at 417 ip 080483a4 sp bfc076a8 error 6 in lockcap[8048000+1000]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment