免费注册 查看新帖 |

Chinaunix

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

Kernel Bug-Vulnerability-Comment library [复制链接]

论坛徽章:
0
11 [报告]
发表于 2007-08-18 16:50 |只看该作者
after release lock, how to guarantee timer not  freed in other place.

论坛徽章:
0
12 [报告]
发表于 2007-08-18 17:00 |只看该作者

回复 #11 daemeon 的帖子

you won ¥1, congratulation.

but how can i get timer, say through /dev/mem after lunch?

[ 本帖最后由 sisi8408 于 2007-8-19 09:49 编辑 ]

论坛徽章:
0
13 [报告]
发表于 2007-08-19 10:12 |只看该作者

  1. /*
  2. * linux-2.6.20.7/kernel/time/clocksource.c
  3. */
  4. static ssize_t sysfs_show_available_clocksources(struct sys_device *dev, char *buf)
  5. {
  6.         struct list_head *tmp;
  7.         char *curr = buf;

  8.         spin_lock_irq(&clocksource_lock);
  9.         list_for_each(tmp, &clocksource_list) {
  10.                 struct clocksource *src;

  11.                 src = list_entry(tmp, struct clocksource, list);
  12.                 /*
  13.                  * no check of buf overflow
  14.                  */
  15.                 curr += sprintf(curr, "%s ", src->name);
  16.         }
  17.         spin_unlock_irq(&clocksource_lock);
  18.         curr += sprintf(curr, "\n");
  19.         return curr - buf;
  20. }
复制代码

论坛徽章:
0
14 [报告]
发表于 2007-08-19 10:18 |只看该作者

  1. /*
  2. * linux-2.6.20.7/kernel/time/clocksource.c
  3. */
  4. static int __init init_clocksource_sysfs(void)
  5. {
  6.         int error = sysdev_class_register(&clocksource_sysclass);

  7.         if (!error)
  8.                 error = sysdev_register(&device_clocksource);
  9.         if (!error)
  10.                 error = sysdev_create_file(
  11.                                 &device_clocksource,
  12.                                 &attr_current_clocksource);
  13.         /*
  14.          * lack of xxx_unregister to clean trash
  15.          */
  16.         if (!error)
  17.                 error = sysdev_create_file(
  18.                                 &device_clocksource,
  19.                                 &attr_available_clocksource);
  20.         return error;
  21. }
复制代码

论坛徽章:
0
15 [报告]
发表于 2007-08-19 11:32 |只看该作者
原帖由 sisi8408 于 2007-8-18 13:49 发表
这里搜集/整理/讨论 linux 八哥/漏洞,和解决方案

贴八哥/漏洞,一次性获得¥1,最多¥2。


贴解决方案,一次性获得¥1,最多¥9。


1,如果要求任何版权,sisi8408只承诺 版权归地球人,与GPLvx无关 ...



不明白你们为什么要这样做,不如直接提交bug给Linux社区,这样即贡献了社区,如果你自己理解有误,自己又学习东西了。我并不反对大家交流,希望交流以后,能提交bug给社区,甚至是提交patch给社区。



到今天为之我提交了过不少bug给Solaris,其中大多数是驱动/tcp-ip/内核相关的。一开始提交bug只是简单描述下问题,或者重现步骤,但后来有些bug就可以给出一些自己的分析,甚至指出那里可能有问题。

提交bug能学到很多东西,尤其是从修bug的人那里。

所以说,大家不要放弃通过提交bug和那些内核开发者的交流机会。

[ 本帖最后由 Solaris12 于 2007-8-19 11:37 编辑 ]

论坛徽章:
0
16 [报告]
发表于 2007-08-19 11:59 |只看该作者

回复 #15 Solaris12 的帖子

1,敬仰 提交了不少bug给Solaris。
     如果能在CU分享,俺看就是美事。

2,提交和搜集不矛盾,也不冲突。
     表达自己的想法,在LKML、bugzila、CU,可能没有本质区别,都是社区吗。

3,¥表示致敬和鼓励干涩的眼睛,是俺的心意,俺很乐意。

[ 本帖最后由 sisi8408 于 2007-8-23 10:27 编辑 ]

论坛徽章:
0
17 [报告]
发表于 2007-08-19 14:31 |只看该作者

  1. /*
  2. * linux-2.6.20.7/net/ipv4/netfilter/ip_conntrack_core.c
  3. */
  4. int __init ip_conntrack_init(void)
  5. {
  6.         unsigned int i;
  7.         int ret;

  8.         /* Idea from tcp.c: use 1/16384 of memory.  On i386: 32MB
  9.          * machine has 256 buckets.  >= 1GB machines have 8192 buckets. */
  10.         if (!ip_conntrack_htable_size) {
  11.                 ip_conntrack_htable_size
  12.                         = (((num_physpages << PAGE_SHIFT) / 16384)
  13.                            / sizeof(struct list_head));
  14.                 if (num_physpages > (1024 * 1024 * 1024 / PAGE_SIZE))
  15.                         ip_conntrack_htable_size = 8192;
  16.                 if (ip_conntrack_htable_size < 16)
  17.                         ip_conntrack_htable_size = 16;
  18.         }
  19.         ip_conntrack_max = 8 * ip_conntrack_htable_size;

  20.         printk("ip_conntrack version %s (%u buckets, %d max)"
  21.                " - %Zd bytes per conntrack\n", IP_CONNTRACK_VERSION,
  22.                ip_conntrack_htable_size, ip_conntrack_max,
  23.                sizeof(struct ip_conntrack));

  24.         ret = nf_register_sockopt(&so_getorigdst);
  25.         if (ret != 0) {
  26.                 printk(KERN_ERR "Unable to register netfilter socket option\n");
  27.                 return ret;
  28.         }

  29.         ip_conntrack_hash = alloc_hashtable(ip_conntrack_htable_size,
  30.                                             &ip_conntrack_vmalloc);
  31.         if (!ip_conntrack_hash) {
  32.                 printk(KERN_ERR "Unable to create ip_conntrack_hash\n");
  33.                 goto err_unreg_sockopt;
  34.         }

  35.         ip_conntrack_cachep = kmem_cache_create("ip_conntrack",
  36.                                                 sizeof(struct ip_conntrack), 0,
  37.                                                 0, NULL, NULL);
  38.         if (!ip_conntrack_cachep) {
  39.                 printk(KERN_ERR "Unable to create ip_conntrack slab cache\n");
  40.                 goto err_free_hash;
  41.         }

  42.         ip_conntrack_expect_cachep = kmem_cache_create("ip_conntrack_expect",
  43.                                         sizeof(struct ip_conntrack_expect),
  44.                                         0, 0, NULL, NULL);
  45.         if (!ip_conntrack_expect_cachep) {
  46.                 printk(KERN_ERR "Unable to create ip_expect slab cache\n");
  47.                 goto err_free_conntrack_slab;
  48.         }

  49.         /* Don't NEED lock here, but good form anyway. */
  50.         write_lock_bh(&ip_conntrack_lock);
  51.         for (i = 0; i < MAX_IP_CT_PROTO; i++)
  52.                 /*
  53.                  * potential base upon which issue
  54.                  * iph->protocol += 32 attack
  55.                  */
  56.                 ip_ct_protos[i] = &ip_conntrack_generic_protocol;
  57.        
  58.         /* Sew in builtin protocols. */
  59.         ip_ct_protos[IPPROTO_TCP] = &ip_conntrack_protocol_tcp;
  60.         ip_ct_protos[IPPROTO_UDP] = &ip_conntrack_protocol_udp;
  61.         ip_ct_protos[IPPROTO_ICMP] = &ip_conntrack_protocol_icmp;
  62.         write_unlock_bh(&ip_conntrack_lock);

  63.         /* For use by ipt_REJECT */
  64.         ip_ct_attach = ip_conntrack_attach;

  65.         /* Set up fake conntrack:
  66.             - to never be deleted, not in any hashes */
  67.         atomic_set(&ip_conntrack_untracked.ct_general.use, 1);
  68.         /*  - and look it like as a confirmed connection */
  69.         set_bit(IPS_CONFIRMED_BIT, &ip_conntrack_untracked.status);

  70.         return ret;

  71. err_free_conntrack_slab:
  72.         kmem_cache_destroy(ip_conntrack_cachep);
  73. err_free_hash:
  74.         free_conntrack_hash(ip_conntrack_hash, ip_conntrack_vmalloc,
  75.                             ip_conntrack_htable_size);
  76. err_unreg_sockopt:
  77.         nf_unregister_sockopt(&so_getorigdst);

  78.         return -ENOMEM;
  79. }
复制代码

[ 本帖最后由 sisi8408 于 2007-8-19 14:33 编辑 ]

论坛徽章:
0
18 [报告]
发表于 2007-08-19 14:46 |只看该作者

  1. /*
  2. * linux-2.6.20.7/net/ipv4/netfilter/ip_conntrack_core.c
  3. *
  4. * On success, returns conntrack ptr, sets skb->nfct and ctinfo
  5. */
  6. static inline struct ip_conntrack *
  7. resolve_normal_ct(struct sk_buff *skb,
  8.                   struct ip_conntrack_protocol *proto,
  9.                   int *set_reply,
  10.                   unsigned int hooknum,
  11.                   enum ip_conntrack_info *ctinfo)
  12. {
  13.         struct ip_conntrack_tuple tuple;
  14.         struct ip_conntrack_tuple_hash *h;
  15.         struct ip_conntrack *ct;

  16.         IP_NF_ASSERT((skb->nh.iph->frag_off & htons(IP_OFFSET)) == 0);

  17.         if (!ip_ct_get_tuple(skb->nh.iph, skb, skb->nh.iph->ihl*4,
  18.                                 &tuple,proto))
  19.                 return NULL;

  20.         /* look for tuple match */
  21.         h = ip_conntrack_find_get(&tuple, NULL);
  22.         if (!h) {
  23.                 /*
  24.                  * potential base upon which issue
  25.                  * pure tcp ack attack
  26.                  */
  27.                 h = init_conntrack(&tuple, proto, skb);
  28.                 if (!h)
  29.                         return NULL;
  30.                 if (IS_ERR(h))
  31.                         return (void *)h;
  32.         }
  33.         ct = tuplehash_to_ctrack(h);

  34.         /* It exists; we have (non-exclusive) reference. */
  35.         if (DIRECTION(h) == IP_CT_DIR_REPLY) {
  36.                 *ctinfo = IP_CT_ESTABLISHED + IP_CT_IS_REPLY;
  37.                 /* Please set reply bit if this packet OK */
  38.                 *set_reply = 1;
  39.         } else {
  40.                 /* Once we've had two way comms, always ESTABLISHED. */
  41.                 if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
  42.                         DEBUGP("ip_conntrack_in: normal packet for %p\n",
  43.                                ct);
  44.                         *ctinfo = IP_CT_ESTABLISHED;
  45.                 } else if (test_bit(IPS_EXPECTED_BIT, &ct->status)) {
  46.                         DEBUGP("ip_conntrack_in: related packet for %p\n",
  47.                                ct);
  48.                         *ctinfo = IP_CT_RELATED;
  49.                 } else {
  50.                         DEBUGP("ip_conntrack_in: new packet for %p\n",
  51.                                ct);
  52.                         *ctinfo = IP_CT_NEW;
  53.                 }
  54.                 *set_reply = 0;
  55.         }
  56.         skb->nfct = &ct->ct_general;
  57.         skb->nfctinfo = *ctinfo;
  58.         return ct;
  59. }
复制代码

论坛徽章:
0
19 [报告]
发表于 2007-08-19 14:58 |只看该作者

  1. /*
  2. * linux-2.6.20.7/net/ipv4/netfilter/ip_conntrack_proto_tcp.c
  3. */
  4. static int tcp_in_window(struct ip_ct_tcp *state,
  5.                          enum ip_conntrack_dir dir,
  6.                          unsigned int index,
  7.                          const struct sk_buff *skb,
  8.                          struct iphdr *iph,
  9.                          struct tcphdr *tcph)
  10. {
  11.         struct ip_ct_tcp_state *sender = &state->seen[dir];
  12.         struct ip_ct_tcp_state *receiver = &state->seen[!dir];
  13.         __u32 seq, ack, sack, end, win, swin;
  14.         int res;
  15.        
  16.         /*
  17.          * Get the required data from the packet.
  18.          */
  19.         seq = ntohl(tcph->seq);
  20.         ack = sack = ntohl(tcph->ack_seq);
  21.         win = ntohs(tcph->window);
  22.         end = segment_seq_plus_len(seq, skb->len, iph, tcph);
  23.        
  24.         if (receiver->flags & IP_CT_TCP_FLAG_SACK_PERM)
  25.                 tcp_sack(skb, iph, tcph, &sack);
  26.                
  27.         DEBUGP("tcp_in_window: START\n");
  28.         DEBUGP("tcp_in_window: src=%u.%u.%u.%u:%hu dst=%u.%u.%u.%u:%hu "
  29.                "seq=%u ack=%u sack=%u win=%u end=%u\n",
  30.                 NIPQUAD(iph->saddr), ntohs(tcph->source),
  31.                 NIPQUAD(iph->daddr), ntohs(tcph->dest),
  32.                 seq, ack, sack, win, end);
  33.         DEBUGP("tcp_in_window: sender end=%u maxend=%u maxwin=%u scale=%i "
  34.                "receiver end=%u maxend=%u maxwin=%u scale=%i\n",
  35.                 sender->td_end, sender->td_maxend, sender->td_maxwin,
  36.                 sender->td_scale,
  37.                 receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
  38.                 receiver->td_scale);
  39.                
  40.         if (sender->td_end == 0) {
  41.                 /*
  42.                  * Initialize sender data.
  43.                  */
  44.                 if (tcph->syn && tcph->ack) {
  45.                         /*
  46.                          * Outgoing SYN-ACK in reply to a SYN.
  47.                          */
  48.                         sender->td_end =
  49.                         sender->td_maxend = end;
  50.                         sender->td_maxwin = (win == 0 ? 1 : win);

  51.                         tcp_options(skb, iph, tcph, sender);
  52.                         /*
  53.                          * RFC 1323:
  54.                          * Both sides must send the Window Scale option
  55.                          * to enable window scaling in either direction.
  56.                          */
  57.                         if (!(sender->flags & IP_CT_TCP_FLAG_WINDOW_SCALE
  58.                               && receiver->flags & IP_CT_TCP_FLAG_WINDOW_SCALE))
  59.                                 sender->td_scale =
  60.                                 receiver->td_scale = 0;
  61.                 } else {
  62.                         /*
  63.                          * We are in the middle of a connection,
  64.                          * its history is lost for us.
  65.                          * Let's try to use the data from the packet.
  66.                           */
  67.                          /*
  68.                           * why not drop/reject pure tcp ack????
  69.                           */
  70.                         sender->td_end = end;
  71.                         sender->td_maxwin = (win == 0 ? 1 : win);
  72.                         sender->td_maxend = end + sender->td_maxwin;
  73.                 }
  74.         } else if (((state->state == TCP_CONNTRACK_SYN_SENT
  75.                      && dir == IP_CT_DIR_ORIGINAL)
  76.                     || (state->state == TCP_CONNTRACK_SYN_RECV
  77.                         && dir == IP_CT_DIR_REPLY))
  78.                     && after(end, sender->td_end)) {
  79.                 /*
  80.                  * RFC 793: "if a TCP is reinitialized ... then it need
  81.                  * not wait at all; it must only be sure to use sequence
  82.                  * numbers larger than those recently used."
  83.                  */
  84.                 sender->td_end =
  85.                 sender->td_maxend = end;
  86.                 sender->td_maxwin = (win == 0 ? 1 : win);

  87.                 tcp_options(skb, iph, tcph, sender);
  88.         }
  89.        
  90.         if (!(tcph->ack)) {
  91.                 /*
  92.                  * If there is no ACK, just pretend it was set and OK.
  93.                  */
  94.                 ack = sack = receiver->td_end;
  95.         } else if (((tcp_flag_word(tcph) & (TCP_FLAG_ACK|TCP_FLAG_RST)) ==
  96.                     (TCP_FLAG_ACK|TCP_FLAG_RST))
  97.                    && (ack == 0)) {
  98.                 /*
  99.                  * Broken TCP stacks, that set ACK in RST packets as well
  100.                  * with zero ack value.
  101.                  */
  102.                 ack = sack = receiver->td_end;
  103.         }

  104.         if (seq == end
  105.             && (!tcph->rst
  106.                 || (seq == 0 && state->state == TCP_CONNTRACK_SYN_SENT)))
  107.                 /*
  108.                  * Packets contains no data: we assume it is valid
  109.                  * and check the ack value only.
  110.                  * However RST segments are always validated by their
  111.                  * SEQ number, except when seq == 0 (reset sent answering
  112.                  * SYN.
  113.                  */
  114.                 seq = end = sender->td_end;
  115.                
  116.         DEBUGP("tcp_in_window: src=%u.%u.%u.%u:%hu dst=%u.%u.%u.%u:%hu "
  117.                "seq=%u ack=%u sack =%u win=%u end=%u\n",
  118.                 NIPQUAD(iph->saddr), ntohs(tcph->source),
  119.                 NIPQUAD(iph->daddr), ntohs(tcph->dest),
  120.                 seq, ack, sack, win, end);
  121.         DEBUGP("tcp_in_window: sender end=%u maxend=%u maxwin=%u scale=%i "
  122.                "receiver end=%u maxend=%u maxwin=%u scale=%i\n",
  123.                 sender->td_end, sender->td_maxend, sender->td_maxwin,
  124.                 sender->td_scale,
  125.                 receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
  126.                 receiver->td_scale);
  127.        
  128.         DEBUGP("tcp_in_window: I=%i II=%i III=%i IV=%i\n",
  129.                 before(seq, sender->td_maxend + 1),
  130.                     after(end, sender->td_end - receiver->td_maxwin - 1),
  131.                     before(sack, receiver->td_end + 1),
  132.                     after(ack, receiver->td_end - MAXACKWINDOW(sender)));
  133.        
  134.         if (sender->loose || receiver->loose ||
  135.             (before(seq, sender->td_maxend + 1) &&
  136.              after(end, sender->td_end - receiver->td_maxwin - 1) &&
  137.              before(sack, receiver->td_end + 1) &&
  138.              after(ack, receiver->td_end - MAXACKWINDOW(sender)))) {
  139.                     /*
  140.                  * Take into account window scaling (RFC 1323).
  141.                  */
  142.                 if (!tcph->syn)
  143.                         win <<= sender->td_scale;
  144.                
  145.                 /*
  146.                  * Update sender data.
  147.                  */
  148.                 swin = win + (sack - ack);
  149.                 if (sender->td_maxwin < swin)
  150.                         sender->td_maxwin = swin;
  151.                 if (after(end, sender->td_end))
  152.                         sender->td_end = end;
  153.                 /*
  154.                  * Update receiver data.
  155.                  */
  156.                 if (after(end, sender->td_maxend))
  157.                         receiver->td_maxwin += end - sender->td_maxend;
  158.                 if (after(sack + win, receiver->td_maxend - 1)) {
  159.                         receiver->td_maxend = sack + win;
  160.                         if (win == 0)
  161.                                 receiver->td_maxend++;
  162.                 }

  163.                 /*
  164.                  * Check retransmissions.
  165.                  */
  166.                 if (index == TCP_ACK_SET) {
  167.                         if (state->last_dir == dir
  168.                             && state->last_seq == seq
  169.                             && state->last_ack == ack
  170.                             && state->last_end == end
  171.                             && state->last_win == win)
  172.                                 state->retrans++;
  173.                         else {
  174.                                 state->last_dir = dir;
  175.                                 state->last_seq = seq;
  176.                                 state->last_ack = ack;
  177.                                 state->last_end = end;
  178.                                 state->last_win = win;
  179.                                 state->retrans = 0;
  180.                         }
  181.                 }
  182.                 /*
  183.                  * Close the window of disabled window tracking :-)
  184.                  */
  185.                 if (sender->loose)
  186.                         sender->loose--;
  187.                
  188.                 res = 1;
  189.         } else {
  190.                 if (LOG_INVALID(IPPROTO_TCP))
  191.                         nf_log_packet(PF_INET, 0, skb, NULL, NULL, NULL,
  192.                         "ip_ct_tcp: %s ",
  193.                         before(seq, sender->td_maxend + 1) ?
  194.                         after(end, sender->td_end - receiver->td_maxwin - 1) ?
  195.                         before(sack, receiver->td_end + 1) ?
  196.                         after(ack, receiver->td_end - MAXACKWINDOW(sender)) ? "BUG"
  197.                         : "ACK is under the lower bound (possible overly delayed ACK)"
  198.                         : "ACK is over the upper bound (ACKed data not seen yet)"
  199.                         : "SEQ is under the lower bound (already ACKed data retransmitted)"
  200.                         : "SEQ is over the upper bound (over the window of the receiver)");

  201.                 res = ip_ct_tcp_be_liberal;
  202.           }
  203.   
  204.         DEBUGP("tcp_in_window: res=%i sender end=%u maxend=%u maxwin=%u "
  205.                "receiver end=%u maxend=%u maxwin=%u\n",
  206.                 res, sender->td_end, sender->td_maxend, sender->td_maxwin,
  207.                 receiver->td_end, receiver->td_maxend, receiver->td_maxwin);

  208.         return res;
  209. }
复制代码

论坛徽章:
0
20 [报告]
发表于 2007-08-19 15:34 |只看该作者
原帖由 sisi8408 于 2007-8-19 11:59 发表
1,敬仰 提交了不少bug给Solaris。
     如果能在CU分享,俺看就是美事。
     还是那句话,您能来发贴,俺就欢迎、知足。呵呵,满意的笑容。

2,提交和搜集不矛盾,也不冲突。 区别只在于GPL。
     想贴 ...

如果对licence有异议,可以考虑换个kernel,这样做,给人的感觉不是太好。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP