The HyperNews Linux KHG Discussion Pages

## It's true, but ...

  Forum: Supporting Functions
  Re: Bug in printk description! (Theodore Ts'o)
  Re: printk description bug? (Chris Arena)
  Keywords: printk description bug
  Date: Tue, 27 Jan 1998 13:13:48 GMT
  From: Miran Miksic <mmiksic@hni.uni-paderborn.de>

Hi, Yes, it's true that I can pass the pointer to something from the user-space to the printk() function, what will probably cause it to crash. But, who wants to do that? Note that we want to write some debug info to the output with the printk() function from my interrupt handler. In the intterupt handler we don't have access to user-space, anyway, and we should NOT search for the means of doing it, because it is opposite to the kernel's architecture and phylosophy. The printk() function uses the following block to protect it's code: save_flags(); cli(); ... restore_flags(); So, the interrupts are disabled. If somewhere in the code the printk() function would like to sleep, it would of course crash the system if called from an interrupt handler (I didn't have time to trace it all way down). But I think it doesn't sleep, because which interrupt would wake it up, if the interrupts are disabled? However, seems to be safe using printk() from an interrupt handler, at least in the newest versions of kernel (2.0.30 and newer). But, due to it's control block, your driver may not work properly if the hardware expects fast I/O. Of course, we want only to display data from the kernel space... Miran