Skip to content

Commit

Permalink
kernel: deny swconfig set requests for unprivileged users
Browse files Browse the repository at this point in the history
The swconfig kernel infrastructure fails to do any permissions checks when
changing settings. As such an ordinary user account on a device with a
switch can change switch settings without any special permissions.
Routers generally have few non-admin users so this isn't a big hole, but it
is a security hole. Likely the greatest danger is for multifunction devices
which have a lot of extra daemons, compromising a low-security daemon would
allow one to modify switch settings and cause the router/switch to appear to
lock-up (or cause other sorts of troublesome nyetwork behavior).

Implement a check for CAP_NET_ADMIN in swconfig_set_attr() and deny any
requests originating from user contexts lacking this capability.

Reported-by: Elliott Mitchell <[email protected]>
Signed-off-by: Jo-Philipp Wich <[email protected]>
  • Loading branch information
jow- authored and wigyori committed Jul 4, 2016
1 parent 8207cd3 commit 94a986d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions target/linux/generic/files/drivers/net/phy/swconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,9 @@ swconfig_set_attr(struct sk_buff *skb, struct genl_info *info)
struct switch_val val;
int err = -EINVAL;

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

dev = swconfig_get_dev(info);
if (!dev)
return -EINVAL;
Expand Down

0 comments on commit 94a986d

Please sign in to comment.