Kernel goes in infinite loop after intercepting write() system call in linux kernel
I intercepted write() system call in a kernel module. Due to this, the kernel is getting into infinite loop because of the printk's present in my module i.e:

    int my_sys_write( fd, ... ) {
          orig_sys_write( fd, ... );
          printk( "DBUG" );    => this printk is taking me to infinite loop
    }

I thought of using conditions like:

    int my_sys_write( fd, ... ) {
          orig_sys_write( fd, ... );
    
          if( ( fd > 2 ) && ( current->real_cred->uid ) ) {
                printk( "DBUG" );
          }
    }

But it is not helping either as the printks are anyways writing to fds > 2. Also, the context of printk() still belows to user process.

So, is there any another way by which I can avoid kernel getting into infinite loop?


Kernel goes in infinite loop after intercepting write() system call in linux kernel
===

I intercepted write() system call in a kernel module. Due to this, the kernel is getting into infinite loop because of the printk's present in my module i.e:

    int my_sys_write( fd, ... ) {
          orig_sys_write( fd, ... );
          printk( "DBUG" );    => this printk is taking me to infinite loop
    }

I thought of using conditions like:

    int my_sys_write( fd, ... ) {
          orig_sys_write( fd, ... );
    
          if( ( fd > 2 ) && ( current->real_cred->uid ) ) {
                printk( "DBUG" );
          }
    }

But it is not helping either as the printks are anyways writing to fds > 2. Also, the context of printk() still belows to user process.

So, is there any another way by which I can avoid kernel getting into infinite loop?

