免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2420 | 回复: 0
打印 上一主题 下一主题

[ALARM] buffer overflow in netfilter conntrack-0.5.0 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-12-24 21:56 |只看该作者 |倒序浏览

  1. buffer overflow is discovered in parsing TCP options,
  2. in both tcp_sack() and tcp_options() functions,
  3. implemented in nf_conntrack_proto_tcp.c of linux-2.6.22/23.x

  4. /* in linux-2.6.23.8/net/netfilter/nf_conntrack_proto_tcp.c */

  5. static void tcp_options(const struct sk_buff *skb,
  6.                         unsigned int dataoff,
  7.                         struct tcphdr *tcph,
  8.                         struct ip_ct_tcp_state *state)
  9. {
  10.         unsigned char buff[(15 *4) - sizeof(struct tcphdr)];
  11.         unsigned char *ptr;
  12.         int length = (tcph->doff *4) - sizeof(struct tcphdr);

  13.         if (!length)
  14.                 return;

  15. /*
  16.   If 108-byte TCP SYN packet is received in
  17.   the manner of two frags:
  18.   farg-I, 20-byte-IP + 20-byte-TCP + 24-byte-TCP_OPT
  19.            and tcp->doff assigned to 0xf

  20.   farg-II, 20-byte-IP + 16-byte-TCP_OPT + 28-byte-TRASH

  21.   then the `ptr' is forcedly assigned to `buff',
  22.   and sizeof(buff) is 40-byte.
  23. */

  24.         ptr = skb_header_pointer(skb, dataoff + sizeof(struct tcphdr),
  25.                                  length, buff);
  26.         BUG_ON(ptr == NULL);

  27.         state->td_scale = state->flags = 0;

  28. /*
  29.   the 40-byte-TCP_OPT is simply filled, and
  30.   copied into `buff' by skb_header_pointer(),
  31.   buff[0 ... 38] = TCPOPT_NOP ;
  32.   buff[39] = TCPOPT_WINDOW ;
  33. */

  34.         while (length > 0) {
  35.                 int opcode = *ptr++;
  36.                 int opsize;

  37.                 switch (opcode) {
  38.                 case TCPOPT_EOL:
  39.                         return;

  40.                 case TCPOPT_NOP:        /* Ref: RFC 793 section 3.1 */
  41.                         length--;
  42.                         continue;
  43.                 default:
  44. /*
  45.   if (opcode == TCPOPT_WINDOW)
  46.         buff overflow ;/
  47. */
  48.                         opsize = *ptr++;
  49.                         if (opsize < 2)                /* silly options */
  50.                                 return;
  51.                         if (opsize > length)
  52.                                 break;                /* don't parse partial options */

  53.                         if (opcode == TCPOPT_SACK_PERM
  54.                             && opsize == TCPOLEN_SACK_PERM)
  55.                                 state->flags |= IP_CT_TCP_FLAG_SACK_PERM;
  56.                         else if (opcode == TCPOPT_WINDOW
  57.                                  && opsize == TCPOLEN_WINDOW) {
  58.                                 state->td_scale = *(u_int8_t *)ptr;

  59.                                 if (state->td_scale > 14) {
  60.                                         /* See RFC1323 */
  61.                                         state->td_scale = 14;
  62.                                 }
  63.                                 state->flags |= IP_CT_TCP_FLAG_WINDOW_SCALE;
  64.                         }
  65.                         ptr += opsize - 2;
  66.                         length -= opsize;
  67.                 }
  68.         }
  69. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP