]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - security/smack/smack_lsm.c
Smack: check for 'struct socket' with NULL sk
[mv-sheeva.git] / security / smack / smack_lsm.c
index 1c11e42458592b78b5dab388e76746a4d8885c4b..5b690482f8cb31d019595080eb1a76dfea5558c9 100644 (file)
@@ -701,7 +701,7 @@ static int smack_inode_getsecurity(const struct inode *inode,
                return -EOPNOTSUPP;
 
        sock = SOCKET_I(ip);
-       if (sock == NULL)
+       if (sock == NULL || sock->sk == NULL)
                return -EOPNOTSUPP;
 
        ssp = sock->sk->sk_security;
@@ -1280,10 +1280,11 @@ static void smack_to_secattr(char *smack, struct netlbl_lsm_secattr *nlsp)
  */
 static int smack_netlabel(struct sock *sk)
 {
-       struct socket_smack *ssp = sk->sk_security;
+       struct socket_smack *ssp;
        struct netlbl_lsm_secattr secattr;
        int rc = 0;
 
+       ssp = sk->sk_security;
        netlbl_secattr_init(&secattr);
        smack_to_secattr(ssp->smk_out, &secattr);
        if (secattr.flags != NETLBL_SECATTR_NONE)
@@ -1331,7 +1332,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
                return -EOPNOTSUPP;
 
        sock = SOCKET_I(inode);
-       if (sock == NULL)
+       if (sock == NULL || sock->sk == NULL)
                return -EOPNOTSUPP;
 
        ssp = sock->sk->sk_security;
@@ -1362,7 +1363,7 @@ static int smack_inode_setsecurity(struct inode *inode, const char *name,
 static int smack_socket_post_create(struct socket *sock, int family,
                                    int type, int protocol, int kern)
 {
-       if (family != PF_INET)
+       if (family != PF_INET || sock->sk == NULL)
                return 0;
        /*
         * Set the outbound netlbl.