Home  >  Q&A  >  body text

linux - 使用sk_buffer的data时指针无法访问?

平台

Linux kernel 3.0.5 for android 4.4.4
Exynos arm 4412

skb申请和获取

struct comm_msg *alloc_set_msg(struct comm_msg *msg,struct sk_buff *skb){
    //reserve header
    skb_reserve(skb,MAX_PTDMA_MSG_HEADER);
    //init header
    struct comm_msg_hdr tmp;
    tmp.station_type = 0;
    tmp.send_slot_index = 0;
    memcpy(skb_push(skb, sizeof(struct comm_msg_hdr)), &tmp, sizeof(struct comm_msg_hdr));
    //memcpy(skb_push(skb, sizeof(struct comm_msg_hdr)), &global_hdr, sizeof(struct comm_msg_hdr));
    //add data
    msg->hdr  = skb->data;
    msg->data = skb->data + sizeof(struct comm_msg_hdr);
    msg->data_len = 0;
    msg->skb = skb;
//    char printSkb1[msg->skb->len * 3];
//    log_dbg("[%s]:encode skb_len:%d  skb :%s  \n",__FUNCTION__,msg->skb->len,log_data(msg->skb->data,msg->skb->len,printSkb1));
//    log_inf("[%s]: msg_hdr:%p msg_data:%p \n", __FUNCTION__, msg->hdr, msg->data);
    return msg;
}

struct comm_msg *alloc_msg0(struct comm_msg *msg,int len){
    struct sk_buff *skb = (struct sk_buff *)alloc_skb(MAX_PTDMA_MSG_HEADER + len + 4,GFP_KERNEL);
    if(skb != NULL){
        return alloc_set_msg(msg,skb);
    }
    return NULL;
}

struct sk_buff *get_send_skb(struct comm_msg *msg){
    //add tail crc 32
//    char printSkb1[msg->skb->len * 3];
//    log_dbg("[%s]:encode bft  skb_len:%d  skb :%s  \n",__FUNCTION__,msg->skb->len,log_data(msg->skb->data,msg->skb->len,printSkb1));
    __u32 crc32_code = crc32_le(0,msg->skb->data,msg->skb->len);
//    __u32 crc32_code = 4;
    memcpy(skb_put(msg->skb,4),&crc32_code,4);
//    char printSkb2[msg->skb->len * 3];
//    log_dbg("[%s]:encode aft skb_len:%d  skb :%s  \n",__FUNCTION__,msg->skb->len,log_data(msg->skb->data,msg->skb->len,printSkb2));

//    log_inf("[%s]:skb_data:%p msg_data:%p \n", __FUNCTION__, msg->skb->data,msg->hdr);
//    log_inf("[%s]: msg_hdr:%p \n", __FUNCTION__, msg->hdr);

    return msg->skb;
}

struct comm_msg 的结构体

struct comm_msg_hdr {
    __u8  station_type;
    __u16 send_slot_index;
    __u16 recv_slot_index;/*priv*/
    __u8  slot_type;      /*ITDMA:0 SOTDMA:1*/
    __u16 slot_inf[2];    /*ITDMA:offset count  SOTDMA:offset timeout*/

    __u16 user_id;
    __u16 dst_user_id;
    __u8  msg_id;
    __u64 send_time_stamp;
    __u64 recv_time_stamp;/*priv*/
}__attribute__((packed));

struct comm_msg {
    struct comm_msg_hdr *hdr;
    __u8 *data;
    __u16 data_len;
    struct sk_buff *skb;
}__attribute__((packed));

static struct comm_msg_hdr global_hdr = {
        .station_type  = 0,
        .send_slot_index = 0
};

错误

when use the get_send_skb, it raise the linux kernel panic! just I can't use the skb->data.

堆栈报错信息

   Unable to handle kernel paging request at virtual address 0066cec8
    [  419.486036] pgd = c0004000
    [  419.488727] [0066cec8] *pgd=00000000
    [  419.492291] Internal error: Oops: 5 [#1] PREEMPT SMP
    [  419.497232] Modules linked in: ptdma ath9k ath9k_htc ath9k_common ath9k_hw ath mac80211 cfg80211 rfkill_gpio rfkill_regulator rfkill sch_fq_codel sch_codel compat bt_uhid mtk_hif_sdio [last unloaded: ptdma]
    [  419.515554] CPU: 0    Not tainted  (3.0.15 #5)
    [  419.520024] PC is at get_send_skb+0x34/0xd4 [ptdma]
    [  419.524838] LR is at 0x66ce78
    [  419.527794] pc : [<bf077720>]    lr : [<0066ce78>]    psr: 000d0193
    [  419.527804] sp : c08a1d60  ip : 00000000  fp : c08a1d7c
    [  419.539246] r10: bf07a4d0  r9 : 00000000  r8 : 0001bfae
    [  419.544455] r7 : 00000000  r6 : 00014efa  r5 : 0066ce78  r4 : ce661110
    [  419.550965] r3 : 0000ce78  r2 : 00000066  r1 : 00000078  r0 : 00000000
    [  419.557479] Flags: nzcv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
    [  419.564853] Control: 10c5387d  Table: 5135c04a  DAC: 00000015
    [  419.570579] 
    [  419.570585] SP: 0xc08a1ce0:
    [  419.574830] 1ce0  00000000 c08a1cf0 dcaef79c 00000009 0000001c bf07b89c ffffffff c08a1d4c
    [  419.582989] 1d00  00014efa 00000000 c08a1d7c c08a1d18 c00452ec c003e52c 00000000 00000078
    [  419.591148] 1d20  00000066 0000ce78 ce661110 0066ce78 00014efa 00000000 0001bfae 00000000
    [  419.599307] 1d40  bf07a4d0 c08a1d7c 00000000 c08a1d60 0066ce78 bf077720 000d0193 ffffffff
    [  419.607466] 1d60  ce65fb20 d0f116f0 d27e9b00 00000000 c08a1dbc c08a1d80 bf073a3c bf0776f8
    [  419.615625] 1d80  c08a1da4 c08a1d90 c00a1c94 c00a1c5c 0065fac0 ce6610c0 c08a1dbc c08a1da8
    [  419.623784] 1da0  0001bfae 00000000 00014efa 00000000 c08a1de4 c08a1dc0 bf073c1c bf073a2c
    [  419.631943] 1dc0  d27e9b00 ce65faa6 ce65fb20 d0f116f0 c0d8a700 00000001 c08a1e04 c08a1de8
    [  419.640105] 
    [  419.640111] FP: 0xc08a1cfc:
    [  419.644356] 1cfc  c08a1d4c 00014efa 00000000 c08a1d7c c08a1d18 c00452ec c003e52c 00000000
    [  419.652515] 1d1c  00000078 00000066 0000ce78 ce661110 0066ce78 00014efa 00000000 0001bfae
    [  419.660674] 1d3c  00000000 bf07a4d0 c08a1d7c 00000000 c08a1d60 0066ce78 bf077720 000d0193
    [  419.668834] 1d5c  ffffffff ce65fb20 d0f116f0 d27e9b00 00000000 c08a1dbc c08a1d80 bf073a3c
    [  419.676993] 1d7c  bf0776f8 c08a1da4 c08a1d90 c00a1c94 c00a1c5c 0065fac0 ce6610c0 c08a1dbc
    [  419.685152] 1d9c  c08a1da8 0001bfae 00000000 00014efa 00000000 c08a1de4 c08a1dc0 bf073c1c
    [  419.693311] 1dbc  bf073a2c d27e9b00 ce65faa6 ce65fb20 d0f116f0 c0d8a700 00000001 c08a1e04
    [  419.701470] 1ddc  c08a1de8 bf0746f0 bf073acc d12452c0 c08a1e70 c0d8a738 00000000 c08a1e14
    [  419.709632] 
    [  419.709637] R4: 0xce661090:
    [  419.713883] 1090  00000000 00000000 00000000 00000000 d0f3c400 d0f3c40c 000000f0 00000001
    [  419.722042] 10b0  c12172e0 c12142e0 c123c700 c0b551a0 ce65fac0 ce65fae0 d1245000 000000c8
    [  419.730201] 10d0  000001f4 77359400 00000000 00000032 00000320 ce792095 ce7920b4 23c00202
    [  419.738360] 10f0  a367ce12 0061a2f9 c0950000 c0b4ce79 00d4ce79 ce12c3c0 847f3b39 00000061
    [  419.746519] 1110  ce131495 ce787095 ce7870b4 37800066 ae2ace12 00004d9d c042ecbc 00000000
    [  419.754679] 1130  00000000 00000000 00000000 00000000 00000000 00000000 00000000 ce5f9000
    [  419.762838] 1150  00000000 00000000 ce5f9050 ce5f9060 ce5f9000 ce5f9000 00000110 00000001
    [  419.770997] 1170  00000000 00000000 00000000 00000000 c0825298 00000124 c00bb3ac 00000000
    [  419.779162] Process swapper (pid: 0, stack limit = 0xc08a02f0)
    [  419.784977] Stack: (0xc08a1d60 to 0xc08a2000)
    [  419.789328] 1d60: ce65fb20 d0f116f0 d27e9b00 00000000 c08a1dbc c08a1d80 bf073a3c bf0776f8
    [  419.797486] 1d80: c08a1da4 c08a1d90 c00a1c94 c00a1c5c 0065fac0 ce6610c0 c08a1dbc c08a1da8
    [  419.805644] 1da0: 0001bfae 00000000 00014efa 00000000 c08a1de4 c08a1dc0 bf073c1c bf073a2c
    [  419.813803] 1dc0: d27e9b00 ce65faa6 ce65fb20 d0f116f0 c0d8a700 00000001 c08a1e04 c08a1de8
    [  419.821962] 1de0: bf0746f0 bf073acc d12452c0 c08a1e70 c0d8a738 00000000 c08a1e14 c08a1e08
    [  419.830122] 1e00: bf07a4e8 bf074378 c08a1e3c c08a1e18 c00a50e4 bf07a4dc c08a1e70 c0d8a700
    [  419.838280] 1e20: c0d8a700 00000000 ffffffff 7fffffff c08a1ea4 c08a1e40 c00a56a0 c00a5080
    [  419.846440] 1e40: aa606a36 00000061 c00b3858 7fffffff ffffffff 00000001 aae320c6 00000061
    [  419.854600] 1e60: ffffffff 7fffffff aae320c6 00000061 aae320c6 00000061 c0087d4c c003c040
    [  419.862759] 1e80: 00d4e000 c0d8a040 c09672e0 00000001 c08a0000 c0d8a0b8 c08a1ec4 c08a1ea8
    [  419.870917] 1ea0: c004b244 c00a558c c09672e0 c08b08f0 c003cdec 00000000 c08a1ee4 c08a1ec8
    [  419.879077] 1ec0: c003e460 c004b20c ffffffff f8810000 0000001c 00000002 c08a1f54 c08a1ee8
    [  419.887236] 1ee0: c0045380 c003e404 bdcd4462 00000000 18bf32d6 000655cf c09447dc c0944144
    [  419.895395] 1f00: 00000000 c0977840 00000000 c0942b1c c0d8a0b8 c08a1f54 019573e4 c08a1f30
    [  419.903555] 1f20: 18701b48 c005b884 800d0013 ffffffff 4f083bf2 000655cf 4f083bf2 00065080
    [  419.911714] 1f40: c0d8a0a8 c0944144 c08a1f8c c08a1f58 c03bb670 c005b850 aa4b323f 00000000
    [  419.919872] 1f60: c00a7c60 c08a0000 c0944144 c0574cbc c08b85ac 4000406a 413fc090 00000000
    [  419.928032] 1f80: c08a1fac c08a1f90 c0047240 c03bb5a0 c08a0000 00000002 c003784c 7fffffff
    [  419.936191] 1fa0: c08a1fc4 c08a1fb0 c05634c8 c004717c c08b07b4 c0944080 c08a1ff4 c08a1fc8
    [  419.944350] 1fc0: c0008b3c c0563430 c000851c 00000000 00000000 c003784c 10c5387d c08b0690
    [  419.952509] 1fe0: c0037848 c08b85a4 00000000 c08a1ff8 40008044 c0008790 00000000 00000000
    [  419.960655] Backtrace: 
    [  419.963152] [<bf0776ec>] (get_send_skb+0x0/0xd4 [ptdma]) from [<bf073a3c>] (send_msg+0x1c/0xa0 [ptdma])
    [  419.972463]  r5:00000000 r4:d27e9b00
    [  419.976070] [<bf073a20>] (send_msg+0x0/0xa0 [ptdma]) from [<bf073c1c>] (send_sotdma_msg+0x15c/0x168 [ptdma])
    [  419.985829]  r7:00000000 r6:00014efa r5:00000000 r4:0001bfae
    [  419.991521] [<bf073ac0>] (send_sotdma_msg+0x0/0x168 [ptdma]) from [<bf0746f0>] (trans_data_task+0x384/0x3c0 [ptdma])
    [  420.001974]  r9:00000001 r8:c0d8a700 r7:d0f116f0 r6:ce65fb20 r5:ce65faa6
    [  420.008484] r4:d27e9b00
    [  420.011149] [<bf07436c>] (trans_data_task+0x0/0x3c0 [ptdma]) from [<bf07a4e8>] (task_manage_timer_func+0x18/0x20 [ptdma])
    [  420.022025]  r7:00000000 r6:c0d8a738 r5:c08a1e70 r4:d12452c0
    [  420.027722] [<bf07a4d0>] (task_manage_timer_func+0x0/0x20 [ptdma]) from [<c00a50e4>] (__run_hrtimer+0x70/0x27c)
    [  420.037756] [<c00a5074>] (__run_hrtimer+0x0/0x27c) from [<c00a56a0>] (hrtimer_interrupt+0x120/0x33c)
    [  420.046875] [<c00a5580>] (hrtimer_interrupt+0x0/0x33c) from [<c004b244>] (ipi_timer+0x44/0x4c)
    [  420.055467] [<c004b200>] (ipi_timer+0x0/0x4c) from [<c003e460>] (do_local_timer+0x68/0x84)
    [  420.063689]  r6:00000000 r5:c003cdec r4:c08b08f0 r3:c09672e0
    [  420.069346] [<c003e3f8>] (do_local_timer+0x0/0x84) from [<c0045380>] (__irq_svc+0x80/0x14c)
    [  420.077667] Exception stack(0xc08a1ee8 to 0xc08a1f30)
    [  420.082708] 1ee0:                   bdcd4462 00000000 18bf32d6 000655cf c09447dc c0944144
    [  420.090870] 1f00: 00000000 c0977840 00000000 c0942b1c c0d8a0b8 c08a1f54 019573e4 c08a1f30
    [  420.099022] 1f20: 18701b48 c005b884 800d0013 ffffffff
    [  420.104051]  r7:00000002 r6:0000001c r5:f8810000 r4:ffffffff
    [  420.109715] [<c005b844>] (exynos4_enter_idle+0x0/0x17c) from [<c03bb670>] (cpuidle_idle_call+0xdc/0x264)
    [  420.119154]  r5:c0944144 r4:c0d8a0a8
    [  420.122728] [<c03bb594>] (cpuidle_idle_call+0x0/0x264) from [<c0047240>] (cpu_idle+0xd0/0x104)
    [  420.131326] [<c0047170>] (cpu_idle+0x0/0x104) from [<c05634c8>] (rest_init+0xa4/0xa8)
    [  420.139118]  r7:7fffffff r6:c003784c r5:00000002 r4:c08a0000
    [  420.144777] [<c0563424>] (rest_init+0x0/0xa8) from [<c0008b3c>] (start_kernel+0x3b8/0x3c4)
    [  420.153007]  r5:c0944080 r4:c08b07b4
    [  420.156578] [<c0008784>] (start_kernel+0x0/0x3c4) from [<40008044>] (0x40008044)
    [  420.163954] Code: e1813405 e5d4c00d e183e802 e18e5c0c (e5952050) 
    [  420.171544] ---[ end trace 3a12492137e16169 ]---
    [  420.174714] ***********enter  Panic*********
    [  420.178951] panic_dump_info_set: 0x 0
    [  420.182595] first 0xe4120001
    [  420.185462] info is : 0xe4120001 
    [  420.188760] Kernel panic - not syncing: Fatal exception in interrupt
    [  420.195093] Backtrace: 
    [  420.197552] [<c0049e70>] (dump_backtrace+0x0/0x11c) from [<c056e534>] (dump_stack+0x18/0x1c)
    [  420.205946]  r6:0000000f r5:c08a1b90 r4:c0946980 r3:c08a0000
    [  420.211604] [<c056e51c>] (dump_stack+0x0/0x1c) from [<c056e5d0>] (panic+0x98/0x144)
    [  420.219243] [<c056e538>] (panic+0x0/0x144) from [<c004a3f8>] (die+0x1d4/0x1d8)
    [  420.226431]  r3:00010002 r2:c08a1bb8 r1:c08a0000 r0:c081a8c4
    [  420.232090] [<c004a224>] (die+0x0/0x1d8) from [<c004e7d0>] (__do_kernel_fault+0x7c/0x8c)
    [  420.240145]  r8:00000000 r7:00000005 r6:00000000 r5:0066cec8 r4:c08a1d18
    [  420.246843] [<c004e754>] (__do_kernel_fault+0x0/0x8c) from [<c004e91c>] (do_page_fault+0x13c/0x1f0)
    [  420.255856]  r8:0001bfae r7:c08a1d18 r6:0066cec8 r5:00000005 r4:00000000
    [  420.262643] r3:c08a1d18
    [  420.264985] [<c004e7e0>] (do_page_fault+0x0/0x1f0) from [<c004eae8>] (do_translation_fault+0xa4/0xa8)
    [  420.274190] [<c004ea44>] (do_translation_fault+0x0/0xa8) from [<c003e55c>] (do_DataAbort+0x3c/0xa4)
    [  420.283198]  r8:0001bfae r7:c08a1d18 r6:0066cec8 r5:c08b89d0 r4:00000005
    [  420.289707] r3:c08b8980
    [  420.292328] [<c003e520>] (do_DataAbort+0x0/0xa4) from [<c00452ec>] (__dabt_svc+0x4c/0x60)
    [  420.300473] Exception stack(0xc08a1d18 to 0xc08a1d60)
    [  420.305698] 1d00:                                                       00000000 00000078
    [  420.313677] 1d20: 00000066 0000ce78 ce661110 0066ce78 00014efa 00000000 0001bfae 00000000
    [  420.321835] 1d40: bf07a4d0 c08a1d7c 00000000 c08a1d60 0066ce78 bf077720 000d0193 ffffffff
    [  420.329983]  r7:00000000 r6:00014efa r5:c08a1d4c r4:ffffffff
    [  420.335696] [<bf0776ec>] (get_send_skb+0x0/0xd4 [ptdma]) from [<bf073a3c>] (send_msg+0x1c/0xa0 [ptdma])
    [  420.345000]  r5:00000000 r4:d27e9b00
    [  420.348610] [<bf073a20>] (send_msg+0x0/0xa0 [ptdma]) from [<bf073c1c>] (send_sotdma_msg+0x15c/0x168 [ptdma])
    [  420.358366]  r7:00000000 r6:00014efa r5:00000000 r4:0001bfae
    [  420.364058] [<bf073ac0>] (send_sotdma_msg+0x0/0x168 [ptdma]) from [<bf0746f0>] (trans_data_task+0x384/0x3c0 [ptdma])
    [  420.374511]  r9:00000001 r8:c0d8a700 r7:d0f116f0 r6:ce65fb20 r5:ce65faa6
    [  420.381021] r4:d27e9b00
    [  420.383687] [<bf07436c>] (trans_data_task+0x0/0x3c0 [ptdma]) from [<bf07a4e8>] (task_manage_timer_func+0x18/0x20 [ptdma])
    [  420.394828]  r7:00000000 r6:c0d8a738 r5:c08a1e70 r4:d12452c0
    [  420.400255] [<bf07a4d0>] (task_manage_timer_func+0x0/0x20 [ptdma]) from [<c00a50e4>] (__run_hrtimer+0x70/0x27c)
    [  420.410424] [<c00a5074>] (__run_hrtimer+0x0/0x27c) from [<c00a56a0>] (hrtimer_interrupt+0x120/0x33c)
    [  420.419408] [<c00a5580>] (hrtimer_interrupt+0x0/0x33c) from [<c004b244>] (ipi_timer+0x44/0x4c)
    [  420.427999] [<c004b200>] (ipi_timer+0x0/0x4c) from [<c003e460>] (do_local_timer+0x68/0x84)
    [  420.436226]  r6:00000000 r5:c003cdec r4:c08b08f0 r3:c09672e0
    [  420.441884] [<c003e3f8>] (do_local_timer+0x0/0x84) from [<c0045380>] (__irq_svc+0x80/0x14c)
    [  420.450203] Exception stack(0xc08a1ee8 to 0xc08a1f30)
    [  420.455245] 1ee0:                   bdcd4462 00000000 18bf32d6 000655cf c09447dc c0944144
    [  420.463406] 1f00: 00000000 c0977840 00000000 c0942b1c c0d8a0b8 c08a1f54 019573e4 c08a1f30
    [  420.471559] 1f20: 18701b48 c005b884 800d0013 ffffffff
    [  420.476588]  r7:00000002 r6:0000001c r5:f8810000 r4:ffffffff
    [  420.482248] [<c005b844>] (exynos4_enter_idle+0x0/0x17c) from [<c03bb670>] (cpuidle_idle_call+0xdc/0x264)
    [  420.491949]  r5:c0944144 r4:c0d8a0a8
    [  420.495266] [<c03bb594>] (cpuidle_idle_call+0x0/0x264) from [<c0047240>] (cpu_idle+0xd0/0x104)
    [  420.503859] [<c0047170>] (cpu_idle+0x0/0x104) from [<c05634c8>] (rest_init+0xa4/0xa8)
    [  420.511797]  r7:7fffffff r6:c003784c r5:00000002 r4:c08a0000
    [  420.517314] [<c0563424>] (rest_init+0x0/0xa8) from [<c0008b3c>] (start_kernel+0x3b8/0x3c4)
    [  420.525544]  r5:c0944080 r4:c08b07b4
    [  420.529116] [<c0008784>] (start_kernel+0x0/0x3c4) from [<40008044>] (0x40008044)
    [  420.536483] Rebooting 
PHPzPHPz2763 days ago353

reply all(0)I'll reply

No reply
  • Cancelreply