Getting netlink socket creation returns NULL in the kernel

Irfan Ullah (울라 이르판) irfan at dke.khu.ac.kr
Wed Oct 16 00:54:08 EDT 2019


Dear All,
I am trying to implement prefetching using machine learning in the kernel.
I need some data from the kernel directly. In this regard I have got very
useful comment that

> Don't do that (directly).  Pass the data to userspace via netlink or
debugfs or shared
memory or other means, and have userspace handle it.

      I am trying to pass data to the kernel space using netlink.
Following this
link <https://gist.github.com/arunk-s/c897bb9d75a6c98733d6>, I have
developed kernel space, and user space programs.  Kernel and user space
programs working perfectly when I load and run these modules from the
terminal using “sudo insmod kernelmodule.ko”, and “./userspaceApp”
respectively.  But, when I try to use kernel program  (directly as a header
file #include "kernelmodule.h") with the kernel original file that is
“vmx.c” then it returns “NULL” while creating socket (nl_sk = NULL in nl_sk
= netlink_kernel_create(&init_net, NETLINK_USER, &cfg);) .  I call  user
defined function, i.e., create_socket(unsigned long int addr) of
kernelmodule.h from handle_ept_voilation() in vmx.c.
handle_ept_voilation()  is called when ept fault occurs in case of virtual
machine.
Furthermore,  I have observed one weird behaviour: if I put 1-3 seconds
sleep just before the socket creating statement , then it works just during
booting of my virtual machine, after successful boot I get the same socket
NULL error.
Thank you for your help.



-- 
*Best Regards,*


*Mr. Irfan Ullah*
PhD Candidate
Data and Knowledge Engineering(DKE) Lab
Department of Computer Science and Engineering
Kyung Hee University, South Korea.
 +82-010-591-51651 <+82%2010-3877-8867>
  sahibzada.iu at gmail.com
 sahibzada_irfanullah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20191016/bf839021/attachment.html>


More information about the Kernelnewbies mailing list