crypto: user - make NETLINK_CRYPTO work inside netns
authorOndrej Mosnacek <omosnace@redhat.com>
Tue, 9 Jul 2019 11:11:24 +0000 (13:11 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 26 Jul 2019 12:08:02 +0000 (22:08 +1000)
commit91b05a7e7d8033a90a64f5fc0e3808db423e420a
treeb883a067a751829e504a48127b80546e8e22efc6
parent31fb084c4eb556fac30115d99bc518c7944887d2
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>
crypto/crypto_user_base.c
crypto/crypto_user_stat.c
include/crypto/internal/cryptouser.h
include/net/net_namespace.h