提交 8292d7f6 编写于 作者: Y Yang Yang 提交者: David S. Miller

net: ipv4: add capability check for net administration

Root in init user namespace can modify /proc/sys/net/ipv4/ip_forward
without CAP_NET_ADMIN, this doesn't follow the principle of
capabilities. For example, let's take a look at netdev_store(),
root can't modify netdev attribute without CAP_NET_ADMIN.
So let's keep the consistency of permission check logic.
Reported-by: NZeal Robot <zealci@zte.com.cn>
Signed-off-by: NYang Yang <yang.yang29@zte.com.cn>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b79c6fba
......@@ -2424,11 +2424,15 @@ static int devinet_sysctl_forward(struct ctl_table *ctl, int write,
int *valp = ctl->data;
int val = *valp;
loff_t pos = *ppos;
int ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
struct net *net = ctl->extra2;
int ret;
if (write && *valp != val) {
struct net *net = ctl->extra2;
if (write && !ns_capable(net->user_ns, CAP_NET_ADMIN))
return -EPERM;
ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
if (write && *valp != val) {
if (valp != &IPV4_DEVCONF_DFLT(net, FORWARDING)) {
if (!rtnl_trylock()) {
/* Restore the original values before restarting */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册