开发者

memcpy-- kernel crash after memcpy

i need help i am trying to use memcpy to copy a header at kernel space but the screen just goes black and it seems like it does not like my memcpy. pls somebody help me.

        remaining = ntohs(iphead->tot_len) - 20; //(remaining = total size of ip packet - size of meta header)
 while(remaining != 0) {
    currentHead = (struct iphdr *) pos; //save the first 'real' header
    if(currentHead == NULL)
        goto fail;
    nskb = dev_alloc_skb(ntohs(currentHead->tot_len) + MAC_LENGTH );
    if(nskb == NULL)
        goto fail; //We can't allocate that memory so we leave
    if(nskb->tail + MAC_LENGTH + ntohs(currentHead->tot_len) <= nskb->end){ 

        nskb->data = skb_put(nskb, (MAC_LENGTH + ntohs(currentHead->tot_len))); // allocated all the memory we need
        memcpy(nskb->data,(*skb)->mac_header, MAC_LENGTH); //Put the mac header in place
        nskb->mac_header = nskb->data; //Save the mac header location
        nskb->network_header = nskb->data + MAC_LENGTH; //Move the pointer to where the network header will be
        memcpy(nskb->network_header, pos, ntohs(currentHead->tot_len)); //save the ip + payload

        n开发者_JAVA百科skb->data = nskb->network_header;


Is pos truly valid? Which memcpy is giving you problems? Is this the Linux kernel I assume?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜