net/mlx4_en: Fix mixed PFC and Global pause user control requests
[pandora-kernel.git] / crypto / crypto_user.c
index 0605a2b..a1d5866 100644 (file)
@@ -71,7 +71,7 @@ static int crypto_report_cipher(struct sk_buff *skb, struct crypto_alg *alg)
 {
        struct crypto_report_cipher rcipher;
 
-       snprintf(rcipher.type, CRYPTO_MAX_ALG_NAME, "%s", "cipher");
+       strncpy(rcipher.type, "cipher", sizeof(rcipher.type));
 
        rcipher.blocksize = alg->cra_blocksize;
        rcipher.min_keysize = alg->cra_cipher.cia_min_keysize;
@@ -90,8 +90,7 @@ static int crypto_report_comp(struct sk_buff *skb, struct crypto_alg *alg)
 {
        struct crypto_report_comp rcomp;
 
-       snprintf(rcomp.type, CRYPTO_MAX_ALG_NAME, "%s", "compression");
-
+       strncpy(rcomp.type, "compression", sizeof(rcomp.type));
        NLA_PUT(skb, CRYPTOCFGA_REPORT_COMPRESS,
                sizeof(struct crypto_report_comp), &rcomp);
 
@@ -104,12 +103,14 @@ nla_put_failure:
 static int crypto_report_one(struct crypto_alg *alg,
                             struct crypto_user_alg *ualg, struct sk_buff *skb)
 {
-       memcpy(&ualg->cru_name, &alg->cra_name, sizeof(ualg->cru_name));
-       memcpy(&ualg->cru_driver_name, &alg->cra_driver_name,
-              sizeof(ualg->cru_driver_name));
-       memcpy(&ualg->cru_module_name, module_name(alg->cra_module),
-              CRYPTO_MAX_ALG_NAME);
-
+       strncpy(ualg->cru_name, alg->cra_name, sizeof(ualg->cru_name));
+       strncpy(ualg->cru_driver_name, alg->cra_driver_name,
+               sizeof(ualg->cru_driver_name));
+       strncpy(ualg->cru_module_name, module_name(alg->cra_module),
+               sizeof(ualg->cru_module_name));
+
+       ualg->cru_type = 0;
+       ualg->cru_mask = 0;
        ualg->cru_flags = alg->cra_flags;
        ualg->cru_refcnt = atomic_read(&alg->cra_refcnt);
 
@@ -118,8 +119,7 @@ static int crypto_report_one(struct crypto_alg *alg,
        if (alg->cra_flags & CRYPTO_ALG_LARVAL) {
                struct crypto_report_larval rl;
 
-               snprintf(rl.type, CRYPTO_MAX_ALG_NAME, "%s", "larval");
-
+               strncpy(rl.type, "larval", sizeof(rl.type));
                NLA_PUT(skb, CRYPTOCFGA_REPORT_LARVAL,
                        sizeof(struct crypto_report_larval), &rl);
 
@@ -390,8 +390,12 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
                if (link->dump == NULL)
                        return -EINVAL;
 
-               return netlink_dump_start(crypto_nlsk, skb, nlh,
+               down_read(&crypto_alg_sem);
+               err = netlink_dump_start(crypto_nlsk, skb, nlh,
                                          link->dump, link->done, 0);
+               up_read(&crypto_alg_sem);
+
+               return err;
        }
 
        err = nlmsg_parse(nlh, crypto_msg_min[type], attrs, CRYPTOCFGA_MAX,