免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
123
最近访问板块 发新帖
楼主: sisi8408
打印 上一主题 下一主题

请补上漏洞,付¥5 [复制链接]

论坛徽章:
0
21 [报告]
发表于 2007-08-10 14:08 |只看该作者
有点跑题

  1. /*
  2. * whynot kmem_cache ?
  3. * sisi 2007-8-10 01:57pm
  4. *
  5. * linux-2.6.22.1\net\xfrm\xfrm_state.c
  6. */
  7. static void xfrm_state_gc_destroy(struct xfrm_state *x)
  8. {
  9.         del_timer_sync(&x->timer);
  10.         del_timer_sync(&x->rtimer);
  11.         kfree(x->aalg);
  12.         kfree(x->ealg);
  13.         kfree(x->calg);
  14.         kfree(x->encap);
  15.         kfree(x->coaddr);        /* care of addr */
  16.         if (x->mode)
  17.                 xfrm_put_mode(x->mode);
  18.         if (x->type) {
  19.                 x->type->destructor(x);
  20.                 xfrm_put_type(x->type);
  21.         }
  22.         security_xfrm_state_free(x);
  23.         //kfree(x);
  24.         kmem_cache_free(xfrm_state_cache, x);
  25. }

  26. static struct kmem_cache *xfrm_state_cache __read_mostly;

  27. static int __init xfrm_state_slab_init(void)
  28. {
  29.         xfrm_state_cache =
  30.                 kmem_cache_create("xfrm_state_cache",
  31.                         sizeof(struct xfrm_state), 0,
  32.                         SLAB_HWCACHE_ALIGN|SLAB_PANIC,
  33.                         NULL, NULL);
  34.         return xfrm_state_cache ? 0 : -ENOMEM;
  35. }

  36. struct xfrm_state * xfrm_state_alloc(void)
  37. {
  38.         struct xfrm_state *x;

  39.         x = //kzalloc(sizeof(struct xfrm_state), GFP_ATOMIC);
  40.                 kmem_cache_alloc(xfrm_state_cache, GFP_ATOMIC);
  41.         if (x) {
  42.                 atomic_set(&x->refcnt, 1);
  43.                 atomic_set(&x->tunnel_users, 0);
  44.                 INIT_HLIST_NODE(&x->bydst);
  45.                 INIT_HLIST_NODE(&x->bysrc);
  46.                 INIT_HLIST_NODE(&x->byspi);
  47.                
  48.                 init_timer(&x->timer);
  49.                 x->timer.function = xfrm_timer_handler;
  50.                 x->timer.data          = (unsigned long)x;
  51.                
  52.                 init_timer(&x->rtimer);
  53.                 x->rtimer.function = xfrm_replay_timer_handler;
  54.                 x->rtimer.data     = (unsigned long)x;
  55.                
  56.                 x->curlft.add_time = get_seconds();
  57.                 x->lft.soft_byte_limit = XFRM_INF;
  58.                 x->lft.soft_packet_limit = XFRM_INF;
  59.                 x->lft.hard_byte_limit = XFRM_INF;
  60.                 x->lft.hard_packet_limit = XFRM_INF;
  61.                 x->replay_maxage = 0;
  62.                 x->replay_maxdiff = 0;
  63.                 spin_lock_init(&x->lock);
  64.         }
  65.         return x;
  66. }
  67. EXPORT_SYMBOL(xfrm_state_alloc);

复制代码

论坛徽章:
0
22 [报告]
发表于 2007-08-10 16:17 |只看该作者
xfrm 好像看不到 rcu 的影子
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP