Skip to content

Commit

Permalink
crypto: user - Allow CRYPTO_MSG_GETALG without CAP_NET_ADMIN
Browse files Browse the repository at this point in the history
CRYPTO_USER requires CAP_NET_ADMIN for all operations. Most information
provided by CRYPTO_MSG_GETALG is also accessible through /proc/modules
and AF_ALG. CRYPTO_MSG_GETALG should not require CAP_NET_ADMIN so that
processes without CAP_NET_ADMIN can use CRYPTO_MSG_GETALG to get cipher
details, such as cipher priorities, for AF_ALG.

Signed-off-by: Matthias-Christian Ott <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
ott authored and herbertx committed May 8, 2014
1 parent da37503 commit c568398
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions crypto/crypto_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
LIST_HEAD(list);

if (!capable(CAP_NET_ADMIN))
return -EPERM;

if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
return -EINVAL;

Expand Down Expand Up @@ -295,6 +298,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
struct crypto_alg *alg;
struct crypto_user_alg *p = nlmsg_data(nlh);

if (!capable(CAP_NET_ADMIN))
return -EPERM;

if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
return -EINVAL;

Expand Down Expand Up @@ -379,6 +385,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
struct crypto_user_alg *p = nlmsg_data(nlh);
struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];

if (!capable(CAP_NET_ADMIN))
return -EPERM;

if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
return -EINVAL;

Expand Down Expand Up @@ -466,9 +475,6 @@ static int crypto_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
type -= CRYPTO_MSG_BASE;
link = &crypto_dispatch[type];

if (!capable(CAP_NET_ADMIN))
return -EPERM;

if ((type == (CRYPTO_MSG_GETALG - CRYPTO_MSG_BASE) &&
(nlh->nlmsg_flags & NLM_F_DUMP))) {
struct crypto_alg *alg;
Expand Down

0 comments on commit c568398

Please sign in to comment.