Skip to contentSkip to conversation

What can i do ? When i rmmod the modules .

DISCUSSION cyberyam 2 participants 4 messages May 9, 2003 netfilter

lore
Share & tools
lore

cyberyam

author
#0 lore raw

unable to handle kernel NULL pointer dereference at virtual address 000004a0
printing eip:
c689a16e
*pde = 00000000

Oops: 0000
myfirewall ipt_MASQUERADE iptable_nat ip_conntrack autofs pcnet32 mii ipt_REJE
CPU:    0
EIP:    0010:[<c689a16e>]    Tainted: P
EFLAGS: 00000296

EIP is at fini [myfirewall] 0x1e (2.4.18-14)
eax: 00000000 ebx: c689a000 ecx: c0305480 edx: c03861a8
esi: fffffff0 edi: 00000000 ebp: c3387f8c esp: c3387f78
ds: 0018 es: 0018 ss: 0018
Process rmmod (pid: 1033, stackpage=c3387000)

Stack: 0000001d c0305480 c1038030 c03054dc 00000203 bfffeb18 c011ce2a c689a000
       c689a000 fffffff0 c32eb000 c011c1a7 c689a000 00000000 00001000 c3386000
       00000001 08073ad8 c010910f bffffc9a bffffba4 0805cb7e 00000001 08073ad8
Call Trace: [<c011ce2a>] free_module [kernel] 0xba (0xc3387f90))

[<c011c1a7>] sys_delete_module [kernel] 0xa7 (0xc3387fa4)) [<c010910f>] system_call [kernel] 0x33 (0xc3387fc0))

Code: ff b0 a0 04 00 00 e8 37 ed 94 f9 83 c4 10 c9 c3 55 89 e5 83
 ./k: line 1:  1033 Segmentation fault      rmmod myfirewall
#1 lore raw
Quoted 11 lines · cyberyam

unable to handle kernel NULL pointer dereference at virtual address 000004a0
printing eip:
c689a16e
*pde = 00000000

Oops: 0000
myfirewall ipt_MASQUERADE iptable_nat ip_conntrack autofs pcnet32 mii ipt_REJE
CPU:    0
EIP:    0010:[<c689a16e>]    Tainted: P
EFLAGS: 00000296

EIP is at fini [myfirewall] 0x1e (2.4.18-14)

Unfortunately we don't have telepathy capabilities and cannot read out the source code of myfirewall from your hard disk.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary
author
#2 lore raw

Hello ,Jozsef
Thanks for your answer.
The source is is the next .I t is just a test program.

---------------------------------------------------------------------------------------------------
#ifndef __KERNEL__
#define __KERNEL__
#endif

#ifndef MODULE
#define MODULE
#endif
#ifndef NETLINK_MYLOG
#define NETLINK_MYLOG 66
#endif

#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/socket.h>
#include <linux/netlink.h>
#include <linux/config.h>
#include <linux/ip.h>
#include <linux/mm.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/spinlock.h>
#include <asm-i386/segment.h>
#include <asm-i386/uaccess.h>
#include <linux/netfilter_ipv4.h>
#include <linux/sched.h>
#include <net/sock.h>
#include <linux/bitops.h>
#include <linux/netfilter_ipv4/ip_tables.h>
static struct sock *nfmylog ;

static size_t qlen ;
#define BUFFERSIZE 65535
static void mylog_send(struct sk_buff* skb) {
netlink_broadcast(nfmylog,skb,0,~0,GFP_ATOMIC) ;
}

static unsigned int myfirewall(unsigned int hooknum,struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,int (*okfn)(struct sk_buff*))
{
struct sk_buff *newskb ;
int len ;
len = (*skb)->truesize ;

newskb = alloc_skb(len,GFP_ATOMIC);
if(!newskb) {
printk("can't alloc whole buffer \n");
}

newskb = skb_copy(*skb,GFP_ATOMIC);

netlink_broadcast(nfmylog,skb,0 , 1,GFP_ATOMIC) ; kfree_skb(newskb) ;

return NF_ACCEPT;
}

static struct nf_hook_ops iplimitfilter=
{
{NULL,NULL},
myfirewall,
PF_INET,
NF_IP_PRE_ROUTING,
NF_IP_PRI_FILTER
};

int init_module(void)
{
nfmylog = netlink_kernel_create(NETLINK_MYLOG,NULL); return nf_register_hook(&iplimitfilter);
}

static void cleanup_module(void)
{
nf_unregister_hook(&iplimitfilter);
sock_release(nfmylog->socket);
}

#3 lore raw

On Fri, 9 May 2003, cyberyam wrote:

Just scanning, there might be other bugs as well:

Quoted 8 lines

static unsigned int myfirewall(unsigned int hooknum,struct sk_buff **skb,
const struct net_device *in,
const struct net_device *out,int (*okfn)(struct sk_buff*))
{
struct sk_buff *newskb ;
int len ;
len = (*skb)->truesize ;

Quoted 4 lines

newskb = alloc_skb(len,GFP_ATOMIC);
if(!newskb) {
printk("can't alloc whole buffer \n");
}

You continue to work even when the system could not allocate the memory, and then try to copy to the nonexistent space:

Quoted 17 lines

newskb = skb_copy(*skb,GFP_ATOMIC);

netlink_broadcast(nfmylog,skb,0 , 1,GFP_ATOMIC) ; kfree_skb(newskb) ;

return NF_ACCEPT;
}

static struct nf_hook_ops iplimitfilter=
{
{NULL,NULL},
myfirewall,
PF_INET,
NF_IP_PRE_ROUTING,
NF_IP_PRI_FILTER
};

Quoted 3 lines

int init_module(void)
{
nfmylog = netlink_kernel_create(NETLINK_MYLOG,NULL);

You does not check wether you could create the netlink. NULL is not a protocol indentifier.

Quoted 8 lines

return nf_register_hook(&iplimitfilter);
}

static void cleanup_module(void)
{
nf_unregister_hook(&iplimitfilter);
sock_release(nfmylog->socket);
}

sock_release is not appropriare to release a netlink.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics

          H-1525 Budapest 114, POB. 49, Hungary