]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
UBUNTU: SAUCE: NET: Store LSM netlabel data in a lsmblob
authorCasey Schaufler <casey@schaufler-ca.com>
Fri, 21 Aug 2020 17:54:15 +0000 (10:54 -0700)
committerAndrea Righi <andrea.righi@canonical.com>
Thu, 9 Mar 2023 14:57:24 +0000 (15:57 +0100)
Netlabel uses LSM interfaces requiring an lsmblob and
the internal storage is used to pass information between
these interfaces, so change the internal data from a secid
to a lsmblob. Update the netlabel interfaces and their
callers to accommodate the change. This requires that the
modules using netlabel use the lsm_id.slot to access the
correct secid when using netlabel.

Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: John Johansen <john.johansen@canonical.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Cc: netdev@vger.kernel.org
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
12 files changed:
include/net/netlabel.h
net/ipv4/cipso_ipv4.c
net/netlabel/netlabel_kapi.c
net/netlabel/netlabel_unlabeled.c
net/netlabel/netlabel_unlabeled.h
security/selinux/hooks.c
security/selinux/include/security.h
security/selinux/netlabel.c
security/selinux/ss/services.c
security/smack/smack.h
security/smack/smack_lsm.c
security/smack/smackfs.c

index 43ae503376851c5cf4311a1461fdb530dc3ade31..73fc25b4042bc4c33d483f4592d2a68e1e5f3ead 100644 (file)
@@ -166,7 +166,7 @@ struct netlbl_lsm_catmap {
  * @attr.mls: MLS sensitivity label
  * @attr.mls.cat: MLS category bitmap
  * @attr.mls.lvl: MLS sensitivity level
- * @attr.secid: LSM specific secid token
+ * @attr.lsmblob: LSM specific data
  *
  * Description:
  * This structure is used to pass security attributes between NetLabel and the
@@ -201,7 +201,7 @@ struct netlbl_lsm_secattr {
                        struct netlbl_lsm_catmap *cat;
                        u32 lvl;
                } mls;
-               u32 secid;
+               struct lsmblob lsmblob;
        } attr;
 };
 
@@ -415,7 +415,7 @@ int netlbl_cfg_unlbl_static_add(struct net *net,
                                const void *addr,
                                const void *mask,
                                u16 family,
-                               u32 secid,
+                               struct lsmblob *lsmblob,
                                struct netlbl_audit *audit_info);
 int netlbl_cfg_unlbl_static_del(struct net *net,
                                const char *dev_name,
@@ -523,7 +523,7 @@ static inline int netlbl_cfg_unlbl_static_add(struct net *net,
                                              const void *addr,
                                              const void *mask,
                                              u16 family,
-                                             u32 secid,
+                                             struct lsmblob *lsmblob,
                                              struct netlbl_audit *audit_info)
 {
        return -ENOSYS;
index 6cd3b6c559f0586961bbb3a254e108cf8130573e..ea65d90b1947a7485a798adbdb82d09fd239d5fb 100644 (file)
@@ -106,15 +106,17 @@ int cipso_v4_rbm_strictvalid = 1;
 /* Base length of the local tag (non-standard tag).
  *  Tag definition (may change between kernel versions)
  *
- * 0          8          16         24         32
- * +----------+----------+----------+----------+
- * | 10000000 | 00000110 | 32-bit secid value  |
- * +----------+----------+----------+----------+
- * | in (host byte order)|
- * +----------+----------+
- *
+ * 0          8          16                    16 + sizeof(struct lsmblob)
+ * +----------+----------+---------------------+
+ * | 10000000 | 00000110 | LSM blob data       |
+ * +----------+----------+---------------------+
+ *
+ * All secid and flag fields are in host byte order.
+ * The lsmblob structure size varies depending on which
+ * Linux security modules are built in the kernel.
+ * The data is opaque.
  */
-#define CIPSO_V4_TAG_LOC_BLEN         6
+#define CIPSO_V4_TAG_LOC_BLEN         (2 + sizeof(struct lsmblob))
 
 /*
  * Helper Functions
@@ -1462,7 +1464,12 @@ static int cipso_v4_gentag_loc(const struct cipso_v4_doi *doi_def,
 
        buffer[0] = CIPSO_V4_TAG_LOCAL;
        buffer[1] = CIPSO_V4_TAG_LOC_BLEN;
-       *(u32 *)&buffer[2] = secattr->attr.secid;
+       /* Ensure that there is sufficient space in the CIPSO header
+        * for the LSM data. This should never become an issue.
+        * The check is made from an abundance of caution. */
+       BUILD_BUG_ON(CIPSO_V4_TAG_LOC_BLEN > CIPSO_V4_OPT_LEN_MAX);
+       memcpy(&buffer[2], &secattr->attr.lsmblob,
+              sizeof(secattr->attr.lsmblob));
 
        return CIPSO_V4_TAG_LOC_BLEN;
 }
@@ -1482,7 +1489,7 @@ static int cipso_v4_parsetag_loc(const struct cipso_v4_doi *doi_def,
                                 const unsigned char *tag,
                                 struct netlbl_lsm_secattr *secattr)
 {
-       secattr->attr.secid = *(u32 *)&tag[2];
+       memcpy(&secattr->attr.lsmblob, &tag[2], sizeof(secattr->attr.lsmblob));
        secattr->flags |= NETLBL_SECATTR_SECID;
 
        return 0;
index 54c08300394705a47212a5b3da0c4658709988c0..14ebe04248110dc04f5bf4f1acbe456348e7d943 100644 (file)
@@ -196,7 +196,7 @@ cfg_unlbl_map_add_failure:
  * @addr: IP address in network byte order (struct in[6]_addr)
  * @mask: address mask in network byte order (struct in[6]_addr)
  * @family: address family
- * @secid: LSM secid value for the entry
+ * @lsmblob: LSM data value for the entry
  * @audit_info: NetLabel audit information
  *
  * Description:
@@ -210,7 +210,7 @@ int netlbl_cfg_unlbl_static_add(struct net *net,
                                const void *addr,
                                const void *mask,
                                u16 family,
-                               u32 secid,
+                               struct lsmblob *lsmblob,
                                struct netlbl_audit *audit_info)
 {
        u32 addr_len;
@@ -230,7 +230,7 @@ int netlbl_cfg_unlbl_static_add(struct net *net,
 
        return netlbl_unlhsh_add(net,
                                 dev_name, addr, mask, addr_len,
-                                secid, audit_info);
+                                lsmblob, audit_info);
 }
 
 /**
index 04c2a4251741fa1ba88f89691b5283d5b2c46851..dab28bd18035481b7205cdd04c78b263801d6632 100644 (file)
@@ -66,7 +66,7 @@ struct netlbl_unlhsh_tbl {
 #define netlbl_unlhsh_addr4_entry(iter) \
        container_of(iter, struct netlbl_unlhsh_addr4, list)
 struct netlbl_unlhsh_addr4 {
-       u32 secid;
+       struct lsmblob lsmblob;
 
        struct netlbl_af4list list;
        struct rcu_head rcu;
@@ -74,7 +74,7 @@ struct netlbl_unlhsh_addr4 {
 #define netlbl_unlhsh_addr6_entry(iter) \
        container_of(iter, struct netlbl_unlhsh_addr6, list)
 struct netlbl_unlhsh_addr6 {
-       u32 secid;
+       struct lsmblob lsmblob;
 
        struct netlbl_af6list list;
        struct rcu_head rcu;
@@ -220,7 +220,7 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex)
  * @iface: the associated interface entry
  * @addr: IPv4 address in network byte order
  * @mask: IPv4 address mask in network byte order
- * @secid: LSM secid value for entry
+ * @lsmblob: LSM data value for entry
  *
  * Description:
  * Add a new address entry into the unlabeled connection hash table using the
@@ -231,7 +231,7 @@ static struct netlbl_unlhsh_iface *netlbl_unlhsh_search_iface(int ifindex)
 static int netlbl_unlhsh_add_addr4(struct netlbl_unlhsh_iface *iface,
                                   const struct in_addr *addr,
                                   const struct in_addr *mask,
-                                  u32 secid)
+                                  struct lsmblob *lsmblob)
 {
        int ret_val;
        struct netlbl_unlhsh_addr4 *entry;
@@ -243,7 +243,7 @@ static int netlbl_unlhsh_add_addr4(struct netlbl_unlhsh_iface *iface,
        entry->list.addr = addr->s_addr & mask->s_addr;
        entry->list.mask = mask->s_addr;
        entry->list.valid = 1;
-       entry->secid = secid;
+       entry->lsmblob = *lsmblob;
 
        spin_lock(&netlbl_unlhsh_lock);
        ret_val = netlbl_af4list_add(&entry->list, &iface->addr4_list);
@@ -260,7 +260,7 @@ static int netlbl_unlhsh_add_addr4(struct netlbl_unlhsh_iface *iface,
  * @iface: the associated interface entry
  * @addr: IPv6 address in network byte order
  * @mask: IPv6 address mask in network byte order
- * @secid: LSM secid value for entry
+ * @lsmblob: LSM data value for entry
  *
  * Description:
  * Add a new address entry into the unlabeled connection hash table using the
@@ -271,7 +271,7 @@ static int netlbl_unlhsh_add_addr4(struct netlbl_unlhsh_iface *iface,
 static int netlbl_unlhsh_add_addr6(struct netlbl_unlhsh_iface *iface,
                                   const struct in6_addr *addr,
                                   const struct in6_addr *mask,
-                                  u32 secid)
+                                  struct lsmblob *lsmblob)
 {
        int ret_val;
        struct netlbl_unlhsh_addr6 *entry;
@@ -287,7 +287,7 @@ static int netlbl_unlhsh_add_addr6(struct netlbl_unlhsh_iface *iface,
        entry->list.addr.s6_addr32[3] &= mask->s6_addr32[3];
        entry->list.mask = *mask;
        entry->list.valid = 1;
-       entry->secid = secid;
+       entry->lsmblob = *lsmblob;
 
        spin_lock(&netlbl_unlhsh_lock);
        ret_val = netlbl_af6list_add(&entry->list, &iface->addr6_list);
@@ -366,7 +366,7 @@ int netlbl_unlhsh_add(struct net *net,
                      const void *addr,
                      const void *mask,
                      u32 addr_len,
-                     u32 secid,
+                     struct lsmblob *lsmblob,
                      struct netlbl_audit *audit_info)
 {
        int ret_val;
@@ -375,7 +375,6 @@ int netlbl_unlhsh_add(struct net *net,
        struct netlbl_unlhsh_iface *iface;
        struct audit_buffer *audit_buf = NULL;
        struct lsmcontext context;
-       struct lsmblob blob;
 
        if (addr_len != sizeof(struct in_addr) &&
            addr_len != sizeof(struct in6_addr))
@@ -408,7 +407,7 @@ int netlbl_unlhsh_add(struct net *net,
                const struct in_addr *addr4 = addr;
                const struct in_addr *mask4 = mask;
 
-               ret_val = netlbl_unlhsh_add_addr4(iface, addr4, mask4, secid);
+               ret_val = netlbl_unlhsh_add_addr4(iface, addr4, mask4, lsmblob);
                if (audit_buf != NULL)
                        netlbl_af4list_audit_addr(audit_buf, 1,
                                                  dev_name,
@@ -421,7 +420,7 @@ int netlbl_unlhsh_add(struct net *net,
                const struct in6_addr *addr6 = addr;
                const struct in6_addr *mask6 = mask;
 
-               ret_val = netlbl_unlhsh_add_addr6(iface, addr6, mask6, secid);
+               ret_val = netlbl_unlhsh_add_addr6(iface, addr6, mask6, lsmblob);
                if (audit_buf != NULL)
                        netlbl_af6list_audit_addr(audit_buf, 1,
                                                  dev_name,
@@ -438,11 +437,7 @@ int netlbl_unlhsh_add(struct net *net,
 unlhsh_add_return:
        rcu_read_unlock();
        if (audit_buf != NULL) {
-               /* lsmblob_init() puts secid into all of the secids in blob.
-                * security_secid_to_secctx() will know which security module
-                * to use to create the secctx.  */
-               lsmblob_init(&blob, secid);
-               if (security_secid_to_secctx(&blob, &context) == 0) {
+               if (security_secid_to_secctx(lsmblob, &context) == 0) {
                        audit_log_format(audit_buf, " sec_obj=%s",
                                         context.context);
                        security_release_secctx(&context);
@@ -477,7 +472,6 @@ static int netlbl_unlhsh_remove_addr4(struct net *net,
        struct audit_buffer *audit_buf;
        struct net_device *dev;
        struct lsmcontext context;
-       struct lsmblob blob;
 
        spin_lock(&netlbl_unlhsh_lock);
        list_entry = netlbl_af4list_remove(addr->s_addr, mask->s_addr,
@@ -496,13 +490,8 @@ static int netlbl_unlhsh_remove_addr4(struct net *net,
                                          (dev != NULL ? dev->name : NULL),
                                          addr->s_addr, mask->s_addr);
                dev_put(dev);
-               /* lsmblob_init() puts entry->secid into all of the secids
-                * in blob. security_secid_to_secctx() will know which
-                * security module to use to create the secctx.  */
-               if (entry != NULL)
-                       lsmblob_init(&blob, entry->secid);
                if (entry != NULL &&
-                   security_secid_to_secctx(&blob, &context) == 0) {
+                   security_secid_to_secctx(&entry->lsmblob, &context) == 0) {
                        audit_log_format(audit_buf, " sec_obj=%s",
                                         context.context);
                        security_release_secctx(&context);
@@ -543,7 +532,6 @@ static int netlbl_unlhsh_remove_addr6(struct net *net,
        struct audit_buffer *audit_buf;
        struct net_device *dev;
        struct lsmcontext context;
-       struct lsmblob blob;
 
        spin_lock(&netlbl_unlhsh_lock);
        list_entry = netlbl_af6list_remove(addr, mask, &iface->addr6_list);
@@ -561,13 +549,8 @@ static int netlbl_unlhsh_remove_addr6(struct net *net,
                                          (dev != NULL ? dev->name : NULL),
                                          addr, mask);
                dev_put(dev);
-               /* lsmblob_init() puts entry->secid into all of the secids
-                * in blob. security_secid_to_secctx() will know which
-                * security module to use to create the secctx.  */
-               if (entry != NULL)
-                       lsmblob_init(&blob, entry->secid);
                if (entry != NULL &&
-                   security_secid_to_secctx(&blob, &context) == 0) {
+                   security_secid_to_secctx(&entry->lsmblob, &context) == 0) {
                        audit_log_format(audit_buf, " sec_obj=%s",
                                         context.context);
                        security_release_secctx(&context);
@@ -921,14 +904,8 @@ static int netlbl_unlabel_staticadd(struct sk_buff *skb,
        if (ret_val != 0)
                return ret_val;
 
-       /* netlbl_unlhsh_add will be changed to pass a struct lsmblob *
-        * instead of a u32 later in this patch set. security_secctx_to_secid()
-        * will only be setting one entry in the lsmblob struct, so it is
-        * safe to use lsmblob_value() to get that one value. */
-
-       return netlbl_unlhsh_add(&init_net,
-                                dev_name, addr, mask, addr_len,
-                                lsmblob_value(&blob), &audit_info);
+       return netlbl_unlhsh_add(&init_net, dev_name, addr, mask, addr_len,
+                                &blob, &audit_info);
 }
 
 /**
@@ -975,11 +952,8 @@ static int netlbl_unlabel_staticadddef(struct sk_buff *skb,
        if (ret_val != 0)
                return ret_val;
 
-       /* security_secctx_to_secid() will only put one secid into the lsmblob
-        * so it's safe to use lsmblob_value() to get the secid. */
-       return netlbl_unlhsh_add(&init_net,
-                                NULL, addr, mask, addr_len,
-                                lsmblob_value(&blob), &audit_info);
+       return netlbl_unlhsh_add(&init_net, NULL, addr, mask, addr_len, &blob,
+                                &audit_info);
 }
 
 /**
@@ -1091,8 +1065,7 @@ static int netlbl_unlabel_staticlist_gen(u32 cmd,
        struct net_device *dev;
        struct lsmcontext context;
        void *data;
-       u32 secid;
-       struct lsmblob blob;
+       struct lsmblob *lsmb;
 
        data = genlmsg_put(cb_arg->skb, NETLINK_CB(cb_arg->nl_cb->skb).portid,
                           cb_arg->seq, &netlbl_unlabel_gnl_family,
@@ -1130,7 +1103,7 @@ static int netlbl_unlabel_staticlist_gen(u32 cmd,
                if (ret_val != 0)
                        goto list_cb_failure;
 
-               secid = addr4->secid;
+               lsmb = (struct lsmblob *)&addr4->lsmblob;
        } else {
                ret_val = nla_put_in6_addr(cb_arg->skb,
                                           NLBL_UNLABEL_A_IPV6ADDR,
@@ -1144,14 +1117,10 @@ static int netlbl_unlabel_staticlist_gen(u32 cmd,
                if (ret_val != 0)
                        goto list_cb_failure;
 
-               secid = addr6->secid;
+               lsmb = (struct lsmblob *)&addr6->lsmblob;
        }
 
-        /* lsmblob_init() secid into all of the secids in blob.
-         * security_secid_to_secctx() will know which security module
-         * to use to create the secctx.  */
-       lsmblob_init(&blob, secid);
-       ret_val = security_secid_to_secctx(&blob, &context);
+       ret_val = security_secid_to_secctx(lsmb, &context);
        if (ret_val != 0)
                goto list_cb_failure;
        ret_val = nla_put(cb_arg->skb,
@@ -1511,7 +1480,7 @@ int netlbl_unlabel_getattr(const struct sk_buff *skb,
                                              &iface->addr4_list);
                if (addr4 == NULL)
                        goto unlabel_getattr_nolabel;
-               secattr->attr.secid = netlbl_unlhsh_addr4_entry(addr4)->secid;
+               secattr->attr.lsmblob = netlbl_unlhsh_addr4_entry(addr4)->lsmblob;
                break;
        }
 #if IS_ENABLED(CONFIG_IPV6)
@@ -1524,7 +1493,7 @@ int netlbl_unlabel_getattr(const struct sk_buff *skb,
                                              &iface->addr6_list);
                if (addr6 == NULL)
                        goto unlabel_getattr_nolabel;
-               secattr->attr.secid = netlbl_unlhsh_addr6_entry(addr6)->secid;
+               secattr->attr.lsmblob = netlbl_unlhsh_addr6_entry(addr6)->lsmblob;
                break;
        }
 #endif /* IPv6 */
index 058e3a285d56d3016e383e1e7518c9401b59fd4a..16892078099485f0fa1a6407bc7825db6bf0a16f 100644 (file)
@@ -211,7 +211,7 @@ int netlbl_unlhsh_add(struct net *net,
                      const void *addr,
                      const void *mask,
                      u32 addr_len,
-                     u32 secid,
+                     struct lsmblob *lsmblob,
                      struct netlbl_audit *audit_info);
 int netlbl_unlhsh_remove(struct net *net,
                         const char *dev_name,
index 59af3b2ef67161c00f8a14e616cc40271fb142ce..8b9f3f8e413a451049bc9a93f06819fed7694b01 100644 (file)
@@ -7037,7 +7037,7 @@ static int selinux_uring_cmd(struct io_uring_cmd *ioucmd)
 }
 #endif /* CONFIG_IO_URING */
 
-static struct lsm_id selinux_lsmid __lsm_ro_after_init = {
+struct lsm_id selinux_lsmid __lsm_ro_after_init = {
        .lsm  = "selinux",
        .slot = LSMBLOB_NEEDED
 };
index 393aff41d3ef89db689738b45b17f9d8c5958fb4..cfd6c1075b16a1c54796e85a730b722187ac7f79 100644 (file)
@@ -75,6 +75,7 @@
 struct netlbl_lsm_secattr;
 
 extern int selinux_enabled_boot;
+extern struct lsm_id selinux_lsmid;
 
 /*
  * type_datum properties
index 800ab4b4239eb885e12728d843357941bc9b345b..0b8f99703462087f4f4fd97da309a28a300da07c 100644 (file)
@@ -109,7 +109,7 @@ static struct netlbl_lsm_secattr *selinux_netlbl_sock_getattr(
                return NULL;
 
        if ((secattr->flags & NETLBL_SECATTR_SECID) &&
-           (secattr->attr.secid == sid))
+           (secattr->attr.lsmblob.secid[selinux_lsmid.slot] == sid))
                return secattr;
 
        return NULL;
index 0092b29022f5e46c2d29193c1a8d35e1941d6001..429f435bf1bd5e75637eebf8c54f6649f4936b00 100644 (file)
@@ -3889,7 +3889,7 @@ retry:
        if (secattr->flags & NETLBL_SECATTR_CACHE)
                *sid = *(u32 *)secattr->cache->data;
        else if (secattr->flags & NETLBL_SECATTR_SECID)
-               *sid = secattr->attr.secid;
+               *sid = secattr->attr.lsmblob.secid[selinux_lsmid.slot];
        else if (secattr->flags & NETLBL_SECATTR_MLS_LVL) {
                rc = -EIDRM;
                ctx = sidtab_search(sidtab, SECINITSID_NETMSG);
@@ -3967,7 +3967,7 @@ int security_netlbl_sid_to_secattr(struct selinux_state *state,
        if (secattr->domain == NULL)
                goto out;
 
-       secattr->attr.secid = sid;
+       secattr->attr.lsmblob.secid[selinux_lsmid.slot] = sid;
        secattr->flags |= NETLBL_SECATTR_DOMAIN_CPY | NETLBL_SECATTR_SECID;
        mls_export_netlbl_lvl(policydb, ctx, secattr);
        rc = mls_export_netlbl_cat(policydb, ctx, secattr);
index 6cb73aae01678011401a92f6aa0bae766f568251..6d5b9d965db52dab07f0838898967f9966540507 100644 (file)
@@ -294,6 +294,7 @@ int smack_populate_secattr(struct smack_known *skp);
  * Shared data.
  */
 extern int smack_enabled __initdata;
+extern struct lsm_id smack_lsmid;
 extern int smack_cipso_direct;
 extern int smack_cipso_mapped;
 extern struct smack_known *smack_net_ambient;
index 6b2cf80aacacaa8362c53ff3171fc0bf4cad6705..9391f2cfea940564be80475f071fbbd68452a65d 100644 (file)
@@ -3807,7 +3807,7 @@ static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap,
                /*
                 * Looks like a fallback, which gives us a secid.
                 */
-               return smack_from_secid(sap->attr.secid);
+               return smack_from_secid(sap->attr.lsmblob.secid[smack_lsmid.slot]);
 
        if ((sap->flags & NETLBL_SECATTR_MLS_LVL) != 0) {
                /*
@@ -3856,6 +3856,7 @@ static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap,
                        return &smack_known_web;
                return &smack_known_star;
        }
+
        /*
         * Without guidance regarding the smack value
         * for the packet fall back on the network
@@ -4857,7 +4858,7 @@ struct lsm_blob_sizes smack_blob_sizes __lsm_ro_after_init = {
        .lbs_sock = sizeof(struct socket_smack),
 };
 
-static struct lsm_id smack_lsmid __lsm_ro_after_init = {
+struct lsm_id smack_lsmid __lsm_ro_after_init = {
        .lsm  = "smack",
        .slot = LSMBLOB_NEEDED
 };
index 4b58526450d492fc0ce8b8af6388b96e0bbe782d..314336463111d6e3239bc71b5e2cd30ea5b94238 100644 (file)
@@ -1144,6 +1144,7 @@ static void smk_net4addr_insert(struct smk_net4addr *new)
 static ssize_t smk_write_net4addr(struct file *file, const char __user *buf,
                                size_t count, loff_t *ppos)
 {
+       struct lsmblob lsmblob;
        struct smk_net4addr *snp;
        struct sockaddr_in newname;
        char *smack;
@@ -1274,10 +1275,13 @@ static ssize_t smk_write_net4addr(struct file *file, const char __user *buf,
         * this host so that incoming packets get labeled.
         * but only if we didn't get the special CIPSO option
         */
-       if (rc == 0 && skp != NULL)
+       if (rc == 0 && skp != NULL) {
+               lsmblob_init(&lsmblob, 0);
+               lsmblob.secid[smack_lsmid.slot] = snp->smk_label->smk_secid;
                rc = netlbl_cfg_unlbl_static_add(&init_net, NULL,
-                       &snp->smk_host, &snp->smk_mask, PF_INET,
-                       snp->smk_label->smk_secid, &audit_info);
+                       &snp->smk_host, &snp->smk_mask, PF_INET, &lsmblob,
+                       &audit_info);
+       }
 
        if (rc == 0)
                rc = count;