[Openswan Users] openswan 2.6.33 rmmod ipsec cause kernel oops of null pointer

Zhiping Liu flyingzpl at gmail.com
Tue Mar 29 21:33:26 EDT 2011


Hi all:

I don't know if anyone have found out this before,but it's obviously a bug
in file: linux/net/ipsec/ipsec_mast.c


1085 int
1086 ipsec_mast_init_devices(void)
1087 {
1088         /*
1089          * mast0 is used for transport mode stuff, and generally is
1090          * the default unless the user decides to create more.
1091          */
1092         ipsec_mast_createnum(0);
1093
1094         return 0;
1095 }

line 1092 set mast device num (mastdevices_max) to 0.

if we do a rmmod ipsec now ,in ipsec_mast_cleanup_devices

1098 int
1099 ipsec_mast_cleanup_devices(void)
1100 {
1101         int error = 0;
1102         int i;
1103         struct net_device *dev_mast;
1104
1105         for(i = 0; i <= mastdevices_max; i++) {
1106                 if(mastdevices[i]!=NULL) {
1107                         dev_mast = mastdevices[i];
1108                         //lzp add
1109                         if (!dev_mast)
1110                                 printk(KERN_WARNING "dev_mast null");
1111                         ipsec_dev_put(dev_mast);
1112                         unregister_netdev(dev_mast);
1113 #ifndef alloc_netdev
1114                         kfree(dev_mast->priv);
1115                         dev_mast->priv=NULL;
1116 #endif
1117                         ipsec_dev_put(mastdevices[i]);
1118                         mastdevices[i]=NULL;
1119                 }
1120         }
1121         return error;
1122 }

we will clean up mastdevices[0],which is not initialize yet.

change to this fix the problem
1085 int
1086 ipsec_mast_init_devices(void)
1087 {
1088         /*
1089          * mast0 is used for transport mode stuff, and generally is
1090          * the default unless the user decides to create more.
1091          */
1092         ipsec_mast_createnum(-1);
1093
1094         return 0;
1095 }

-- 
--ROMEO
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openswan.org/pipermail/users/attachments/20110330/23bfa2ef/attachment.html 


More information about the Users mailing list