Commit 70ba5b6d authored by Tyler Hicks's avatar Tyler Hicks Committed by David S. Miller

ipv4: Return EINVAL when ping_group_range sysctl doesn't map to user ns

The low and high values of the net.ipv4.ping_group_range sysctl were
being silently forced to the default disabled state when a write to the
sysctl contained GIDs that didn't map to the associated user namespace.
Confusingly, the sysctl's write operation would return success and then
a subsequent read of the sysctl would indicate that the low and high
values are the overflowgid.

This patch changes the behavior by clearly returning an error when the
sysctl write operation receives a GID range that doesn't map to the
associated user namespace. In such a situation, the previous value of
the sysctl is preserved and that range will be returned in a subsequent
read of the sysctl.
Signed-off-by: default avatarTyler Hicks <tyhicks@canonical.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 94b3b542
...@@ -189,8 +189,9 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write, ...@@ -189,8 +189,9 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
if (write && ret == 0) { if (write && ret == 0) {
low = make_kgid(user_ns, urange[0]); low = make_kgid(user_ns, urange[0]);
high = make_kgid(user_ns, urange[1]); high = make_kgid(user_ns, urange[1]);
if (!gid_valid(low) || !gid_valid(high) || if (!gid_valid(low) || !gid_valid(high))
(urange[1] < urange[0]) || gid_lt(high, low)) { return -EINVAL;
if (urange[1] < urange[0] || gid_lt(high, low)) {
low = make_kgid(&init_user_ns, 1); low = make_kgid(&init_user_ns, 1);
high = make_kgid(&init_user_ns, 0); high = make_kgid(&init_user_ns, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment