Skip to content

Commit 0348dcd

Browse files
tyhicksgregkh
authored andcommitted
ipv4: Return EINVAL when ping_group_range sysctl doesn't map to user ns
[ Upstream commit 70ba5b6 ] 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: Tyler Hicks <tyhicks@canonical.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c8347d9 commit 0348dcd

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎net/ipv4/sysctl_net_ipv4.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,9 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
186186
if (write && ret == 0) {
187187
low = make_kgid(user_ns, urange[0]);
188188
high = make_kgid(user_ns, urange[1]);
189-
if (!gid_valid(low) || !gid_valid(high) ||
190-
(urange[1] < urange[0]) || gid_lt(high, low)) {
189+
if (!gid_valid(low) || !gid_valid(high))
190+
return -EINVAL;
191+
if (urange[1] < urange[0] || gid_lt(high, low)) {
191192
low = make_kgid(&init_user_ns, 1);
192193
high = make_kgid(&init_user_ns, 0);
193194
}

0 commit comments

Comments
 (0)