0

I am writing a kernel module that hooks some system calls (e.g. tcp_send() ) using jprobes and sends some information to the userspace using netlink sockets. netlink_unicast(nlsk, skb, pid, MSG_DONTWAIT);

my callback call is:

void nl_recv(struct sk_buff *skb) {
    struct nlmsghdr *nlh;
    if (skb == NULL) {
        return;
    }
    nlh = (struct nlmsghdr *) skb->data;
    pid = nlh->nlmsg_pid;
    debug(KERN_NOTICE "Kernel Module: Received pid from %u\n", pid);         
}

I'd like to pause the execution of my kernel module after every send. relaunch on receive. I have tried using completions and wait queues, but it seems that they push the session into a GPF.

Wheatley
  • 153
  • 1
  • 12
  • `I'd like to pause the execution of my kernel module after every send. relaunch on receive.` - What you mean by **pausing**? Kernel module's code is executed only as reaction on *outer events* (for which the module is signed up). In absence of outer events kernel module doesn't execute its code. – Tsyvarev Mar 27 '16 at 21:18
  • I mean that the kernel module should wait for the userspace application (that it contacts through a netlink socket) to continue its execution – Wheatley Mar 28 '16 at 02:39
  • I am not sure that undestand you correctly, but *jprobes* by themselves doesn't forbid waiting. So, until hooked function is disallowed to wait, waiting should work. Probably, you should include code (into your question post), which you have tried for implement waiting. – Tsyvarev Mar 28 '16 at 07:33
  • Apparently that is a bad idea. Freezing applications when executing in Kernel mode can render the operating System unstable and cause GPF.. learned that after implementing a couple of synchronization mechanisms (Completions / Wait Queues). Thank you anyway – Wheatley Aug 26 '16 at 19:07

0 Answers0