Linux.ChinaUnix.net
ChinaUnix | Linux首页 | 新闻 | 博客 | 文章 | 专栏 | 新手 | 方案 | 图书 | 下载 | 人才 | 手册 | wiki | 搜索     
Linux论坛
  会员: 密码: 免费注册 | 忘记密码 | 会员登录 | 搜索 | 帮助 


Kernel Bug-Vulnerability-Comment library
首页 » CU论坛 » Linux » 汇总贴列表 » 内核源码 »  
[打印] [订阅] [收藏] [本帖文本页] [推荐此主题给朋友,立即获积分]
版主 platinum (何时才能飞)
广告杀手-老法王
人生的转折



UID:26424
注册:2002-11-2
最后登录: 2008-10-13
帖子:20249
精华:22

可用积分:24315 (巨富豪门)
信誉积分:105
专家积分:454 (本版:100)
空间积分:0
推广积分:0

状态:...保密...

[资料] [站内短信] [Blog]


71楼 发表于 2007-12-22 13:27 
两个问题
1、sisi8408 大哥做过实验吗?
2、根据对 sisi8408 大哥的了解,含有中文注释并带有 color=red 的贴子更像是从哪里转过来的,文章来源是哪里呢?



您对本贴的看法:鲜花[0] 臭蛋[0]

__________________________________

当我们在为生活而疲惫奔波的时候
生活却渐渐离我们远去
find our way, find our style
积分兑换专区 | IT节能和TPC-E活动获奖名单 | 致电800-858-2903,了解DELL如何为你量身订制笔记本 | 送2G U盘 | 站长如何获得资金?
sisi8408 (linux八哥)
风云使者




UID:509266
注册:2006-12-22
最后登录: 2008-09-21
帖子:617
精华:0

可用积分:567 (稍有积蓄)
信誉积分:100
专家积分:0 (本版:0)
空间积分:0
推广积分:0

状态:...离线...

[资料] [站内短信] [Blog]


72楼 发表于 2007-12-22 14:33 
回复 #71 platinum 的帖子

1、sisi8408 大哥做过实验吗?
//实验的没有,道理上说得通,就应该关注了

2、根据对 sisi8408 大哥的了解,含有中文注释并带有 color=red 的贴子更像是从哪里转过来的,
文章来源是哪里呢?
//没了解好,俺抄谁呐?给大家提个兴而已。



您对本贴的看法:鲜花[0] 臭蛋[0]

__________________________________

东直门外大街
张字85号
丁字96号

积分兑换专区 | IT节能和TPC-E活动获奖名单 | 致电800-858-2903,了解DELL如何为你量身订制笔记本 | 送2G U盘 | 站长如何获得资金?
sisi8408 (linux八哥)
风云使者




UID:509266
注册:2006-12-22
最后登录: 2008-09-21
帖子:617
精华:0

可用积分:567 (稍有积蓄)
信誉积分:100
专家积分:0 (本版:0)
空间积分:0
推广积分:0

状态:...离线...

[资料] [站内短信] [Blog]


73楼 发表于 2007-12-22 14:55 


struct tcphdr {
        __be16        source;
        __be16        dest;
        __be32        seq;
        __be32        ack_seq;
#if defined(__LITTLE_ENDIAN_BITFIELD)
        __u16        res1:4,
                doff:4,        /* 正解 doff *4 <= 60, 逗你玩 */
                fin:1,
                syn:1,
                rst:1,
                psh:1,
                ack:1,
                urg:1,
                ece:1,
                cwr:1;
#elif defined(__BIG_ENDIAN_BITFIELD)
        __u16        doff:4,
                res1:4,
                cwr:1,
                ece:1,
                urg:1,
                ack:1,
                psh:1,
                rst:1,
                syn:1,
                fin:1;
#else
#error        "Adjust your <asm/byteorder.h> defines"
#endif       
        __be16        window;
        __sum16        check;
        __be16        urg_ptr;
};




您对本贴的看法:鲜花[0] 臭蛋[0]

__________________________________

东直门外大街
张字85号
丁字96号

积分兑换专区 | IT节能和TPC-E活动获奖名单 | 致电800-858-2903,了解DELL如何为你量身订制笔记本 | 送2G U盘 | 站长如何获得资金?
sisi8408 (linux八哥)
风云使者




UID:509266
注册:2006-12-22
最后登录: 2008-09-21
帖子:617
精华:0

可用积分:567 (稍有积蓄)
信誉积分:100
专家积分:0 (本版:0)
空间积分:0
推广积分:0

状态:...离线...

[资料] [站内短信] [Blog]


74楼 发表于 2007-12-22 20:52 


/* 2007-12-22 20:47 */
static void tcp_options(const struct sk_buff *skb,
                        unsigned int dataoff,
                        struct tcphdr *tcph,
                        struct ip_ct_tcp_state *state)
{
        unsigned char buff[(15 * 4) - sizeof(struct tcphdr)];
        unsigned char *ptr;
        int length = (tcph->doff*4) - sizeof(struct tcphdr);
        /*
         * sizeof(buff) = 40
         * length 只能 <= 40 ;)
         */
        if (!length)
                return;

        ptr = skb_header_pointer(skb, dataoff + sizeof(struct tcphdr),
                                 length, buff);
       
        /*108byte(20byte<IP>  +
         *          20byte<TCP>  +
         *          40byte<TCP opt> +
         *          28byte<trash>)SYN 包拆成两个碎片:
         * 第一个包:20byte<IP> + 20byte<TCP> + 24byte<TCP opt>
         *           and tcp->doff = 0xf
         * 第二个包:20byte<IP> + 16byte<TCP opt> + 28byte<trash>
         *
         * 这样会迫使 ptr = buff ;/
         * =========================
         * 40byte<TCP opt>这样填充,使得:
         * buff[0 ... 38] = TCPOPT_NOP ;
         * buff[39] = 非 TCPOPT_NOP and TCPOPT_EOL
         */
        BUG_ON(ptr == NULL);

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

        while (length > 0) {
                /*
                 * when length = 1, ptr = &buff[39], and
                 * while-loop progress...
                 */
                int opcode = *ptr++;
                /*
                 * after opcode is read,
                 * ptr = &buff[40]
                 * still ok,
                 */
                int opsize;

                switch (opcode) {
                case TCPOPT_EOL:
                        return;
                case TCPOPT_NOP:        /* Ref: RFC 793 section 3.1 */
                        length--;
                        continue;
                default:
                        /*
                         * but when opsize is reading,
                         * buff overflow :?/
                         */
                        opsize = *ptr++;
                       
                        if (opsize < 2) /* "silly options" */
                                return;
                       
                        if (opsize > length)
                                break;        /* don't parse partial options */

                        if (opcode == TCPOPT_SACK_PERM
                            && opsize == TCPOLEN_SACK_PERM) {
                                state->flags |= IP_CT_TCP_FLAG_SACK_PERM;
                        }
                        else if (opcode == TCPOPT_WINDOW
                                 && opsize == TCPOLEN_WINDOW) {
                                state->td_scale = *(u_int8_t *)ptr;

                                if (state->td_scale > 14) {
                                        /* See RFC1323 */
                                        state->td_scale = 14;
                                }
                                state->flags |= IP_CT_TCP_FLAG_WINDOW_SCALE;
                        }
                        ptr += opsize - 2;
                        length -= opsize;
                }
        }
}

[ 本帖最后由 sisi8408 于 2007-12-22 20:59 编辑 ]



您对本贴的看法:鲜花[0] 臭蛋[0]

__________________________________

东直门外大街
张字85号
丁字96号

积分兑换专区 | IT节能和TPC-E活动获奖名单 | 致电800-858-2903,了解DELL如何为你量身订制笔记本 | 送2G U盘 | 站长如何获得资金?
版主 platinum (何时才能飞)
广告杀手-老法王
人生的转折



UID:26424
注册:2002-11-2
最后登录: 2008-10-13
帖子:20249
精华:22

可用积分:24315 (巨富豪门)
信誉积分:105
专家积分:454 (本版:100)
空间积分:0
推广积分:0

状态:...保密...

[资料] [站内短信] [Blog]


75楼 发表于 2007-12-25 01:10 
我也来凑个热闹,这也是一个 BUG 吗?(能力有限,让大家笑话了)

/usr/src/linux/net/ipv4/netfilter/ip_conntrack_proto_tcp.c

/* Print out the private part of the conntrack. */
static int tcp_print_conntrack(struct seq_file *s,
                               const struct ip_conntrack *conntrack)
{
        enum tcp_conntrack state;
        read_lock_bh(&tcp_lock);

        /* 这里 state 可能取到很多值 */
        state = conntrack->proto.tcp.state;
        read_unlock_bh(&tcp_lock);

        /* 这里显示具体的 state */
        return seq_printf(s, "%s ", tcp_conntrack_names[state]);
}



static const char *tcp_conntrack_names[] = {
        "NONE",
        "SYN_SENT",
        "SYN_RECV",
        "ESTABLISHED",
        "FIN_WAIT",
        "CLOSE_WAIT",
        "LAST_ACK",
        "TIME_WAIT",
        "CLOSE",
        "LISTEN"
};



/* This is exposed to userspace (ctnetlink) */
enum tcp_conntrack {
        TCP_CONNTRACK_NONE,
        TCP_CONNTRACK_SYN_SENT,
        TCP_CONNTRACK_SYN_RECV,
        TCP_CONNTRACK_ESTABLISHED,
        TCP_CONNTRACK_FIN_WAIT,
        TCP_CONNTRACK_CLOSE_WAIT,
        TCP_CONNTRACK_LAST_ACK,
        TCP_CONNTRACK_TIME_WAIT,
        TCP_CONNTRACK_CLOSE,
        TCP_CONNTRACK_LISTEN,
        TCP_CONNTRACK_MAX,          /* 这个没有出现在 tcp_conntrack_names 中 */
        TCP_CONNTRACK_IGNORE     /* 同上 */
};



struct ip_ct_tcp
{
        struct ip_ct_tcp_state seen[2]; /* connection parameters per direction */
        u_int8_t        state;          /* state of the connection (enum tcp_conntrack) */
                                                /* 这里取的可是 enum tcp_conntrack 的值啊? */
        /* For detecting stale connections */
        u_int8_t        last_dir;       /* Direction of the last packet (enum ip_conntrack_dir) */
        u_int8_t        retrans;        /* Number of retransmitted packets */
        u_int8_t        last_index;     /* Index of the last packet */
        u_int32_t       last_seq;       /* Last sequence number seen in dir */
        u_int32_t       last_ack;       /* Last sequence number seen in opposite dir */
        u_int32_t       last_end;       /* Last seq + len */
        u_int16_t       last_win;       /* Last window advertisement seen in dir */
};

state = conntrack->proto.tcp.state; 可能取到 TCP_CONNTRACK_MAX 或 TCP_CONNTRACK_IGNORE 吗?
return seq_printf(s, "%s ", tcp_conntrack_names[state]); 会不会溢出?

[ 本帖最后由 platinum 于 2007-12-25 13:28 编辑 ]



您对本贴的看法:鲜花[0] 臭蛋[0]

__________________________________

当我们在为生活而疲惫奔波的时候
生活却渐渐离我们远去
find our way, find our style
积分兑换专区 | IT节能和TPC-E活动获奖名单 | 致电800-858-2903,了解DELL如何为你量身订制笔记本 | 送2G U盘 | 站长如何获得资金?
sisi8408 (linux八哥)
风云使者




UID:509266
注册:2006-12-22
最后登录: 2008-09-21
帖子:617
精华:0

可用积分:567 (稍有积蓄)
信誉积分:100
专家积分:0 (本版:0)
空间积分:0
推广积分:0

状态:...离线...

[资料] [站内短信] [Blog]


76楼 发表于 2007-12-29 22:15 


#include <net/snmp.h>
#include <net/ip.h>
#include <net/protocol.h>
#include <net/route.h>
#include <net/xfrm.h>
#include <linux/skbuff.h>
#include <net/sock.h>
#include <net/arp.h>
#include <net/icmp.h>
/* why so much men? linux-2.6.22.5/net/ipv4/ip_output.c
#include <net/checksum.h> */
#include <net/inetpeer.h>
#include <net/checksum.h>
#include <linux/igmp.h>




您对本贴的看法:鲜花[0] 臭蛋[0]

__________________________________

东直门外大街
张字85号
丁字96号

积分兑换专区 | IT节能和TPC-E活动获奖名单 | 致电800-858-2903,了解DELL如何为你量身订制笔记本 | 送2G U盘 | 站长如何获得资金?
sisi8408 (linux八哥)
风云使者




UID:509266
注册:2006-12-22
最后登录: 2008-09-21
帖子:617
精华:0

可用积分:567 (稍有积蓄)
信誉积分:100
专家积分:0 (本版:0)
空间积分:0
推广积分:0

状态:...离线...

[资料] [站内短信] [Blog]


77楼 发表于 2008-1-11 23:00 


Hi, Jozsef

Though functions in nf_conntrack_proto_tcp.c never see fragmented packets,
the implementation of the function, ip_frag_reasm() in linux/net/ipv4/ip_fragment.c,
does not make sure that the skb seen in nf_conntrack_proto_tcp.c is linearized,
at least in the case of linux-2.6.22.5 from kernel.org.

Therefore buff overflow is still a problem, if not a vulnerability,
in the function of tcp_options(),
as shown in the following code,

static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev)
{
[...]
    /*
     * head is not linearized,
     * 2008-1-11 22:48 by sisi
     */
    skb_shinfo(head)->frag_list = head->next;

    skb_push(head, head->data - skb_network_header(head));
    atomic_sub(head->truesize, &ip_frag_mem);

    for (fp=head->next; fp; fp = fp->next) {
        head->data_len += fp->len;
        head->len += fp->len;
        if (head->ip_summed != fp->ip_summed)
            head->ip_summed = CHECKSUM_NONE;
        else if (head->ip_summed == CHECKSUM_COMPLETE)
            head->csum = csum_add(head->csum, fp->csum);
        head->truesize += fp->truesize;
        atomic_sub(fp->truesize, &ip_frag_mem);
    }

    head->next = NULL;
    head->dev = dev;
    head->tstamp = qp->stamp;

    iph = ip_hdr(head);
    iph->frag_off = 0;
    iph->tot_len = htons(len);
    IP_INC_STATS_BH(IPSTATS_MIB_REASMOKS);
    qp->fragments = NULL;
    return head;
[...]
}


Best regards,
Jing



2008/1/4, Jozsef Kadlecsik <[email]kadlec@blackhole.kfki.hu[/email]>:

    Hi,

    On Mon, 24 Dec 2007, jing zhang wrote:

    > buffer overflow is discovered in parsing TCP options,
    > in both tcp_sack() and tcp_options() functions,
    > implemented in nf_conntrack_proto_tcp.c of linux-2.6.22/23.x
    >
    > I think it is possible to crash a netfilter-based firewall box with simply
    > constructed TCP SYN packet.
    [...]
    > /*
    >   If 108-byte TCP SYN packet is received in
    >   the manner of two frags:
    >   farg-I,  20-byte-IP + 20-byte-TCP + 24-byte-TCP_OPT
    >             and tcp->doff assigned to 0xf
    >
    >   farg-II,  20-byte-IP + 16-byte-TCP_OPT + 28-byte-TRASH
    >
    >   then the `ptr' is forcedly assigned to `buff',
    >   and sizeof(buff) is 40-byte.
    > */
    [...]

    Please note, defragmenting happens before conntrack is called. In other
    words these functions never see fragmented packets. Therefore I think
    there is no such problem in nf_conntrack_proto_tcp.c.

    Best regards,
    Jozsef
    -
    E-mail  : [email]kadlec@blackhole.kfki.hu[/email], [email]kadlec@sunserv.kfki.hu[/email]
    PGP key : [url]http://www.kfki.hu/~kadlec/pgp_public_key.txt[/url]
    Address : KFKI Research Institute for Particle and Nuclear Physics
              H-1525 Budapest 114, POB. 49, Hungary

though attended, not understood enough yet.

[ 本帖最后由 sisi8408 于 2008-1-13 15:44 编辑 ]



您对本贴的看法:鲜花[0] 臭蛋[0]

__________________________________

东直门外大街
张字85号
丁字96号

积分兑换专区 | IT节能和TPC-E活动获奖名单 | 致电800-858-2903,了解DELL如何为你量身订制笔记本 | 送2G U盘 | 站长如何获得资金?
sisi8408 (linux八哥)
风云使者




UID:509266
注册:2006-12-22
最后登录: 2008-09-21
帖子:617
精华:0

可用积分:567 (稍有积蓄)
信誉积分:100
专家积分:0 (本版:0)
空间积分:0
推广积分:0

状态:...离线...

[资料] [站内短信] [Blog]


78楼 发表于 2008-1-13 15:45 


static int ksoftirqd(void * __bind_cpu)
{
        set_current_state(TASK_INTERRUPTIBLE);
        /*
         * linux-2.6.23.12
         * set_user_nice(current, 1);
         */
[...]
}




您对本贴的看法:鲜花[0] 臭蛋[0]

__________________________________

东直门外大街
张字85号
丁字96号

积分兑换专区 | IT节能和TPC-E活动获奖名单 | 致电800-858-2903,了解DELL如何为你量身订制笔记本 | 送2G U盘 | 站长如何获得资金?
版主 platinum (何时才能飞)
广告杀手-老法王
人生的转折



UID:26424
注册:2002-11-2
最后登录: 2008-10-13
帖子:20249
精华:22

可用积分:24315 (巨富豪门)
信誉积分:105
专家积分:454 (本版:100)
空间积分:0
推广积分:0

状态:...保密...

[资料] [站内短信] [Blog]


79楼 发表于 2008-1-13 19:11 
sisi8408 大哥帮我看看 75 楼的问题,究竟是怎么一回事呢?



您对本贴的看法:鲜花[0] 臭蛋[0]

__________________________________

当我们在为生活而疲惫奔波的时候
生活却渐渐离我们远去
find our way, find our style
积分兑换专区 | IT节能和TPC-E活动获奖名单 | 致电800-858-2903,了解DELL如何为你量身订制笔记本 | 送2G U盘 | 站长如何获得资金?
sisi8408 (linux八哥)
风云使者




UID:509266
注册:2006-12-22
最后登录: 2008-09-21
帖子:617
精华:0

可用积分:567 (稍有积蓄)
信誉积分:100
专家积分:0 (本版:0)
空间积分:0
推广积分:0

状态:...离线...

[资料] [站内短信] [Blog]


80楼 发表于 2008-1-14 20:26 
to platinum

$
$ mkdir /home/platin
$ vim /home/platin/show_buflow.c

#include <linux/module.h>
#include <linux/kernel.h>

#define SHOW_BUF_MAX 3
static char *buff[] = {
        [0 ... SHOW_BUF_MAX -2] = "aaa",
        [SHOW_BUF_MAX -1] = "and what?",
};

static int __init show_buflow_start(void)
{
        int j;
        for (j = 0; j < SHOW_BUF_MAX; j++)
                printk("%s\n", buff[j]);
        printk("%s\n", buff[j+3]);
        return 0;
}
static void __exit show_buflow_finish(void) {}
module_init(show_buflow_start);
module_exit(show_buflow_finish);

$ echo obj-m=show_buflow.o >>  /home/platin/Makefile
$ make -C /usr/src/linux-2.6.23.12 M=/home/platin modules
$ insmod  /home/platin/show_buflow.ko
$




您对本贴的看法:鲜花[0] 臭蛋[0]

__________________________________

东直门外大街
张字85号
丁字96号

积分兑换专区 | IT节能和TPC-E活动获奖名单 | 致电800-858-2903,了解DELL如何为你量身订制笔记本 | 送2G U盘 | 站长如何获得资金?

首页 » CU论坛 » Linux » 汇总贴列表 » 内核源码 »

 


Copyright © 2001-2008 ChinaUnix.net All Rights Reserved     联系我们:

感谢所有关心和支持过ChinaUnix的朋友们    转载本站内容请注明原作者名及出处

京ICP证041476号


清除 Cookies - Linux时代 - Archiver - WAP - TOP

Processed in 0.168226 second(s), 5 queries , Gzip enabled