Hi,
I am trying to log information from within the kernel with the use of a unix socket (/dev/log). My code is a kprobe handler, so while executing I am atomic and uninterrupted. The crashes begin when I do stress tests against my module, so i.e. more than 50 logs per second. The crash messages I get every time are different (from NULL reference, unable to handle page request etc), so I suppose that something is overwritten and this leads to the crash. I don't want to post the code here because it ~100 LOC but these are my steps: Initialization: call sock_create_kern, with PF_UNIX, SOCK_DGRAM, 0 and the address of my socket, then I memset to 0 my sockaddr_un variable and then I set its sun_family to PF_UNIX and copy the "/dev/log" string to sun_path Logging: I have the message that I want to log in variable called buffer and its length in variable called message_length, I set the msg_name of the msghdr to the address of my sockaddr_un variable, than the msn_namelen to sizeof(sockadrr_un), the msg_iov to an iovec variable which contains the buffer and the message_length values, msg_iovlen to 1 and msg_control, msg_controllen to 0. Then I set the fs to KERNEL_DS, call sock_sendmsg with parameters my socket, the address of my msghdr and the message_length and then I restore the fs that there was before setting it to KERNEL_DS. Please note that my socket, sockadd_un and my buffer are static variables. Also I always use the socket which is initialized once in the Initialization state (function). Do you see any "bad practice" or something that could lead to crashes when stressing with a lot of messages the socket? Thank you in advance!
Panos
-- http://www.cern.ch/psakkos |
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies