summaryrefslogtreecommitdiff
path: root/crypto/crypto_user_stat.c
diff options
context:
space:
mode:
authorOndrej Mosnacek <omosnace@redhat.com>2019-07-09 13:11:24 +0200
committerHerbert Xu <herbert@gondor.apana.org.au>2019-07-26 22:08:02 +1000
commit21ab11901c29e9b4fdbfe036f910ee5bd0f256e6 (patch)
treea3bef0e159058446ae979d173f3723ef61ac1afe /crypto/crypto_user_stat.c
parentf3b8e93c4d6ded77e3c1edf651a496f0323f5e39 (diff)
downloadlinux-crypto-21ab11901c29e9b4fdbfe036f910ee5bd0f256e6.tar.gz
linux-crypto-21ab11901c29e9b4fdbfe036f910ee5bd0f256e6.zip
crypto: user - make NETLINK_CRYPTO work inside netns
Currently, NETLINK_CRYPTO works only in the init network namespace. It doesn't make much sense to cut it out of the other network namespaces, so do the minor plumbing work necessary to make it work in any network namespace. Code inspired by net/core/sock_diag.c. Tested using kcapi-dgst from libkcapi [1]: Before: # unshare -n kcapi-dgst -c sha256 </dev/null | wc -c libkcapi - Error: Netlink error: sendmsg failed libkcapi - Error: Netlink error: sendmsg failed libkcapi - Error: NETLINK_CRYPTO: cannot obtain cipher information for hmac(sha512) (is required crypto_user.c patch missing? see documentation) 0 After: # unshare -n kcapi-dgst -c sha256 </dev/null | wc -c 32 [1] https://github.com/smuellerDD/libkcapi Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/crypto_user_stat.c')
-rw-r--r--crypto/crypto_user_stat.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/crypto_user_stat.c b/crypto/crypto_user_stat.c
index a03f326a..8bad8841 100644
--- a/crypto/crypto_user_stat.c
+++ b/crypto/crypto_user_stat.c
@@ -10,6 +10,7 @@
#include <linux/cryptouser.h>
#include <linux/sched.h>
#include <net/netlink.h>
+#include <net/sock.h>
#include <crypto/internal/skcipher.h>
#include <crypto/internal/rng.h>
#include <crypto/akcipher.h>
@@ -298,6 +299,7 @@ out:
int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
struct nlattr **attrs)
{
+ struct net *net = sock_net(in_skb->sk);
struct crypto_user_alg *p = nlmsg_data(in_nlh);
struct crypto_alg *alg;
struct sk_buff *skb;
@@ -329,7 +331,7 @@ drop_alg:
if (err)
return err;
- return nlmsg_unicast(crypto_nlsk, skb, NETLINK_CB(in_skb).portid);
+ return nlmsg_unicast(net->crypto_nlsk, skb, NETLINK_CB(in_skb).portid);
}
MODULE_LICENSE("GPL");