* [PATCH] ipv4: Return EINVAL when ping_group_range sysctl doesn't map to user ns
@ 2018-07-05 18:49 Tyler Hicks
2018-07-06 2:52 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Tyler Hicks @ 2018-07-05 18:49 UTC (permalink / raw)
To: David S . Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI
Cc: Eric Biederman, Vasiliy Kulikov, netdev, containers, linux-kernel
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>
---
This patch stems from triaging the following report from a LXD user:
https://discuss.linuxcontainers.org/t/setting-net-ipv4-ping-group-range-inside-an-lxd-container/2162
net/ipv4/sysctl_net_ipv4.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index af0a857d8352..5fa335fd3852 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -189,8 +189,9 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
if (write && ret == 0) {
low = make_kgid(user_ns, urange[0]);
high = make_kgid(user_ns, urange[1]);
- if (!gid_valid(low) || !gid_valid(high) ||
- (urange[1] < urange[0]) || gid_lt(high, low)) {
+ if (!gid_valid(low) || !gid_valid(high))
+ return -EINVAL;
+ if (urange[1] < urange[0] || gid_lt(high, low)) {
low = make_kgid(&init_user_ns, 1);
high = make_kgid(&init_user_ns, 0);
}
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] ipv4: Return EINVAL when ping_group_range sysctl doesn't map to user ns
2018-07-05 18:49 [PATCH] ipv4: Return EINVAL when ping_group_range sysctl doesn't map to user ns Tyler Hicks
@ 2018-07-06 2:52 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-06 2:52 UTC (permalink / raw)
To: tyhicks
Cc: kuznet, yoshfuji, ebiederm, segoon, netdev, containers,
linux-kernel
From: Tyler Hicks <tyhicks@canonical.com>
Date: Thu, 5 Jul 2018 18:49:23 +0000
> 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>
Looks good to me, applied and queued up for -stable.
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-06 2:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-05 18:49 [PATCH] ipv4: Return EINVAL when ping_group_range sysctl doesn't map to user ns Tyler Hicks
2018-07-06 2:52 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox