why the skb->lsm_security is NULL inskb_free_security after skb_alloc_security ???

From: Yuan ChunYang (cyyuanml@private)
Date: Tue Sep 23 2003 - 18:12:19 PDT

  • Next message: Yuan ChunYang: "Re: about security_skb_alloc??"

    HI, now i find a strange problem about skb_alloc_security hook.
      After i allocated security struct for a sk_buff, i find its
    skb->lsm_security is NULL when calling skb_free_security hook. I test it
    in kernel 2.5.72 with LSM and write codes only two hooks about sk_buff.
    
      It can not free memory of sk_buff security struct. So my computer is
    often halted.  
    .
      Can somebody tell me why the skb->lsm_security is NULL in
    skb_free_security after skb_alloc_security ???
      Is there some functions in kernel set skb->lsm_security NULL ???
      
      Why hooks about sk_buff is deleter in kernel 2.6???
    
    My codes are followed:
    ====================================================================
    static inline int smos_skb_alloc_security(struct sk_buff * skb, int
    gfp_mask)
    {
            sk_buff_security_t *sksec;
            int rc = 0;
    
            sksec = skb->lsm_security;
            if (sksec && sksec->magic == SECOPT_MAGIC) {
                    return rc;
            }
    
            sksec = (sk_buff_security_t *)
    kmalloc(sizeof(sk_buff_security_t,GFA_ATOMIC);
            if (!sksec) {
                    rc = -ENOMEM;
                    return rc;
            }
            memset(sksec, 0, sizeof (sk_buff_security_t));
            sksec->magic = SECOPT_MAGIC;
            sksec->skb = skb;
            skb->lsm_security = sksec;
    
            printk(KERN_INFO "smos_skb_alloc_security........skb=%p
    ,skb->lsm_security=%p ..[1-1]\n",skb,skb->lsm_security);
            return rc;
    }
    
    static inline void smos_skb_free_security(struct sk_buff * skb)
    {
            sk_buff_security_t *ssec = skb->lsm_security;
    
            printk(KERN_INFO "smos_skb_free_security........skb=%p
    ,skb->lsm_security=%p ..[2-1]\n",skb,ssec);
            if (!ssec || ssec->magic != SECOPT_MAGIC) return;
            
            skb->lsm_security = NULL;
            kfree(ssec);
            printk(KERN_INFO "smos_skb_free_security........skb=%p ,ssec=%p
    ...[2-2]\n",skb,ssec);
            return;
    }
    
    =========================================================================
    DEBUG print info:
    kernel: smos_skb_alloc_security........skb=c3305b80
    ,skb->lsm_security=c2eedea0 ..[1-1]
    kernel: smos_skb_free_security........skb=c3305b80
    ,skb->lsm_security=00000000 ..[2-1]
    
    =========================================================================
    



    This archive was generated by hypermail 2b30 : Tue Sep 23 2003 - 18:12:38 PDT