Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-28-2012, 11:16 AM   #1
LQ Newbie
Registered: Jan 2009
Distribution: Fedora
Posts: 29

Rep: Reputation: 0
Kernel Panic when netlink message is sent from User space to kernel space

Hi all,

The below code is w.r.t netlinks. I just ported the below code from 2.6.27 kernel to 2.6.34 kernel. And this code works fine in 2.6.27 kernel and when I run it in 2.6.34 it is giving kernel panic. When I debugged it "nlh" value is null i.e skb->data is pointing to some garbage value. What could be the reason. Please help me.

Kernel Code:
int nl_rcv_func (struct sk_buff *skb)
struct nlmsghdr *nlh;

if (!skb && !(struct nlmsghdr *)skb->data)
return FAILURE;

/* Get the Netlink message header from the buffer */
nlh = (struct nlmsghdr *)skb->data;

/* Kernel panic is happening here since nlh is NULL */
printk (KERN_INFO "%d:"nlh->nlmsg_len);


struct sock *nl_sock ()
struct sock *ns = NULL;
ns = netlink_kernel_create (&init_net, NETLINK_USERSOCK, 0,
nl_rcv_func, &rtnl_mutex,THIS_MODULE);
return ns;

UserSpace Code:

int init_module ( )
struct ctrl c;
struct sockaddr_nl nladdr;
struct nlmsghdr nlmh;
struct ctrl c;
int ns;

/* Initialize the socket */
ns = netlink_open ();
if (ns <= 0)
perror ("socket failed");
return -1;

pal_mem_set(&rq, 0, sizeof(rq));
pal_mem_set(&nladdr, 0, sizeof(nladdr));
void *data = NLMSG_DATA(&rq);
req.nlmh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ctrl));

pal_mem_cpy(data, 40, sizeof(struct ctrl));
nladdr.nl_family = AF_NETLINK;

return sendto(ns, (u_char *)&rq, 20, 0, (struct sockaddr *)&nladdr,
Old 11-28-2012, 11:56 AM   #2
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 8,610
Blog Entries: 4

Rep: Reputation: 2998Reputation: 2998Reputation: 2998Reputation: 2998Reputation: 2998Reputation: 2998Reputation: 2998Reputation: 2998Reputation: 2998Reputation: 2998Reputation: 2998
My immediate assumption is that the network support is being implemented by a loadable kernel-module that is somehow out-of-sync with the remainder of the system. If you have upgraded your kernel (package...), reinstall any additional packages that might be involved e.g. with device support.

I would be profoundly surprised if the API in question was changed for a minor-release ... naah, it simply wouldn't still be "2.6.xx." So, this fairly screams to me to be a "bullsh*t problem," probably quite external to the code that you're currently debugging. I would, in other words, very thoroughly eliminate all other possible "way out in left field" possibilities first.

Last edited by sundialsvcs; 11-28-2012 at 11:58 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Free user space pages of different user processes from inside kernel space trueskyte Linux - Kernel 1 10-22-2010 05:37 PM
Netlink Kernel User-space communication code for 2.6.33, 2.6.34+ Kernels kiran_cyberpro Programming 0 06-09-2010 04:19 AM
Division of Logical Memory Space in to User Space and Kernel Space shreshtha Linux - Newbie 2 01-14-2010 10:59 AM
Netlink sockets usage to communicate b/w user and kernel space. vinodkr83 Linux - Newbie 1 07-03-2009 04:22 AM
Kernel Module to send Message to User Space Application hnshashi Linux - Newbie 2 08-22-2008 01:48 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration