public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294
@ 2023-06-01  3:13 Akihiro Suda
  2023-06-02  9:00 ` patchwork-bot+netdevbpf
  2023-06-03  7:35 ` [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294 - manual merge Matthieu Baerts
  0 siblings, 2 replies; 4+ messages in thread
From: Akihiro Suda @ 2023-06-01  3:13 UTC (permalink / raw)
  To: linux-kernel, netdev, davem, edumazet, kuba, pabeni, segoon,
	kuniyu
  Cc: Akihiro Suda, suda.kyoto

With this commit, all the GIDs ("0 4294967294") can be written to the
"net.ipv4.ping_group_range" sysctl.

Note that 4294967295 (0xffffffff) is an invalid GID (see gid_valid() in
include/linux/uidgid.h), and an attempt to register this number will cause
-EINVAL.

Prior to this commit, only up to GID 2147483647 could be covered.
Documentation/networking/ip-sysctl.rst had "0 4294967295" as an example
value, but this example was wrong and causing -EINVAL.

Fixes: c319b4d76b9e ("net: ipv4: add IPPROTO_ICMP socket kind")
Co-developed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
---
v3: Fixed a couple of nits
v2: Simplified the patch (Thanks to Kuniyuki Iwashima for suggestion)
---
 Documentation/networking/ip-sysctl.rst | 4 ++--
 include/net/ping.h                     | 6 +-----
 net/ipv4/sysctl_net_ipv4.c             | 8 ++++----
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
index 6ec06a33688a..80b8f73a0244 100644
--- a/Documentation/networking/ip-sysctl.rst
+++ b/Documentation/networking/ip-sysctl.rst
@@ -1352,8 +1352,8 @@ ping_group_range - 2 INTEGERS
 	Restrict ICMP_PROTO datagram sockets to users in the group range.
 	The default is "1 0", meaning, that nobody (not even root) may
 	create ping sockets.  Setting it to "100 100" would grant permissions
-	to the single group. "0 4294967295" would enable it for the world, "100
-	4294967295" would enable it for the users, but not daemons.
+	to the single group. "0 4294967294" would enable it for the world, "100
+	4294967294" would enable it for the users, but not daemons.
 
 tcp_early_demux - BOOLEAN
 	Enable early demux for established TCP sockets.
diff --git a/include/net/ping.h b/include/net/ping.h
index 9233ad3de0ad..bc7779262e60 100644
--- a/include/net/ping.h
+++ b/include/net/ping.h
@@ -16,11 +16,7 @@
 #define PING_HTABLE_SIZE 	64
 #define PING_HTABLE_MASK 	(PING_HTABLE_SIZE-1)
 
-/*
- * gid_t is either uint or ushort.  We want to pass it to
- * proc_dointvec_minmax(), so it must not be larger than MAX_INT
- */
-#define GID_T_MAX (((gid_t)~0U) >> 1)
+#define GID_T_MAX (((gid_t)~0U) - 1)
 
 /* Compatibility glue so we can support IPv6 when it's compiled as a module */
 struct pingv6_ops {
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 40fe70fc2015..88dfe51e68f3 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -34,8 +34,8 @@ static int ip_ttl_min = 1;
 static int ip_ttl_max = 255;
 static int tcp_syn_retries_min = 1;
 static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
-static int ip_ping_group_range_min[] = { 0, 0 };
-static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
+static unsigned long ip_ping_group_range_min[] = { 0, 0 };
+static unsigned long ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
 static u32 u32_max_div_HZ = UINT_MAX / HZ;
 static int one_day_secs = 24 * 3600;
 static u32 fib_multipath_hash_fields_all_mask __maybe_unused =
@@ -165,7 +165,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
 {
 	struct user_namespace *user_ns = current_user_ns();
 	int ret;
-	gid_t urange[2];
+	unsigned long urange[2];
 	kgid_t low, high;
 	struct ctl_table tmp = {
 		.data = &urange,
@@ -178,7 +178,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
 	inet_get_ping_group_range_table(table, &low, &high);
 	urange[0] = from_kgid_munged(user_ns, low);
 	urange[1] = from_kgid_munged(user_ns, high);
-	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
+	ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
 
 	if (write && ret == 0) {
 		low = make_kgid(user_ns, urange[0]);
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294
  2023-06-01  3:13 [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294 Akihiro Suda
@ 2023-06-02  9:00 ` patchwork-bot+netdevbpf
  2023-06-03  7:35 ` [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294 - manual merge Matthieu Baerts
  1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-02  9:00 UTC (permalink / raw)
  To: Akihiro Suda
  Cc: linux-kernel, netdev, davem, edumazet, kuba, pabeni, segoon,
	kuniyu, akihiro.suda.cz, suda.kyoto

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu,  1 Jun 2023 12:13:05 +0900 you wrote:
> With this commit, all the GIDs ("0 4294967294") can be written to the
> "net.ipv4.ping_group_range" sysctl.
> 
> Note that 4294967295 (0xffffffff) is an invalid GID (see gid_valid() in
> include/linux/uidgid.h), and an attempt to register this number will cause
> -EINVAL.
> 
> [...]

Here is the summary with links:
  - [net,v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294
    https://git.kernel.org/netdev/net/c/e209fee4118f

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294 - manual merge
  2023-06-01  3:13 [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294 Akihiro Suda
  2023-06-02  9:00 ` patchwork-bot+netdevbpf
@ 2023-06-03  7:35 ` Matthieu Baerts
  2023-06-03 10:49   ` Akihiro Suda
  1 sibling, 1 reply; 4+ messages in thread
From: Matthieu Baerts @ 2023-06-03  7:35 UTC (permalink / raw)
  To: Akihiro Suda, linux-kernel, netdev, davem, edumazet, kuba, pabeni,
	segoon, kuniyu
  Cc: Akihiro Suda, suda.kyoto, Stephen Rothwell

[-- Attachment #1: Type: text/plain, Size: 1565 bytes --]

Hello,

On 01/06/2023 05:13, Akihiro Suda wrote:
> With this commit, all the GIDs ("0 4294967294") can be written to the
> "net.ipv4.ping_group_range" sysctl.
> 
> Note that 4294967295 (0xffffffff) is an invalid GID (see gid_valid() in
> include/linux/uidgid.h), and an attempt to register this number will cause
> -EINVAL.
> 
> Prior to this commit, only up to GID 2147483647 could be covered.
> Documentation/networking/ip-sysctl.rst had "0 4294967295" as an example
> value, but this example was wrong and causing -EINVAL.

FYI, we got a small conflict when merging 'net' in 'net-next' in the
MPTCP tree due to this patch applied in 'net':

  e209fee4118f ("net/ipv4: ping_group_range: allow GID from 2147483648
to 4294967294")

and this one from 'net-next':

  ccce324dabfe ("tcp: make the first N SYN RTO backoffs linear")

----- Generic Message -----
The best is to avoid conflicts between 'net' and 'net-next' trees but if
they cannot be avoided when preparing patches, a note about how to fix
them is much appreciated.

The conflict has been resolved on our side[1] and the resolution we
suggest is attached to this email. Please report any issues linked to
this conflict resolution as it might be used by others. If you worked on
the mentioned patches, don't hesitate to ACK this conflict resolution.
---------------------------

Regarding this conflict, I simply took the modifications from both sides.

Cheers,
Matt

[1] https://github.com/multipath-tcp/mptcp_net-next/commit/f170c423f567
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net

[-- Attachment #2: f170c423f56781e5957cd5b3c4de781515ed2c2c.patch --]
[-- Type: text/x-patch, Size: 785 bytes --]

diff --cc net/ipv4/sysctl_net_ipv4.c
index 6ae3345a3bdf,88dfe51e68f3..0bb5b03088e7
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@@ -34,9 -34,8 +34,9 @@@ static int ip_ttl_min = 1
  static int ip_ttl_max = 255;
  static int tcp_syn_retries_min = 1;
  static int tcp_syn_retries_max = MAX_TCP_SYNCNT;
 +static int tcp_syn_linear_timeouts_max = MAX_TCP_SYNCNT;
- static int ip_ping_group_range_min[] = { 0, 0 };
- static int ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
+ static unsigned long ip_ping_group_range_min[] = { 0, 0 };
+ static unsigned long ip_ping_group_range_max[] = { GID_T_MAX, GID_T_MAX };
  static u32 u32_max_div_HZ = UINT_MAX / HZ;
  static int one_day_secs = 24 * 3600;
  static u32 fib_multipath_hash_fields_all_mask __maybe_unused =

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294 - manual merge
  2023-06-03  7:35 ` [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294 - manual merge Matthieu Baerts
@ 2023-06-03 10:49   ` Akihiro Suda
  0 siblings, 0 replies; 4+ messages in thread
From: Akihiro Suda @ 2023-06-03 10:49 UTC (permalink / raw)
  To: Matthieu Baerts
  Cc: Akihiro Suda, linux-kernel, netdev, davem, edumazet, kuba, pabeni,
	segoon, kuniyu, Akihiro Suda, Stephen Rothwell

> The conflict has been resolved on our side

Thank you

2023年6月3日(土) 16:35 Matthieu Baerts <matthieu.baerts@tessares.net>:
>
> Hello,
>
> On 01/06/2023 05:13, Akihiro Suda wrote:
> > With this commit, all the GIDs ("0 4294967294") can be written to the
> > "net.ipv4.ping_group_range" sysctl.
> >
> > Note that 4294967295 (0xffffffff) is an invalid GID (see gid_valid() in
> > include/linux/uidgid.h), and an attempt to register this number will cause
> > -EINVAL.
> >
> > Prior to this commit, only up to GID 2147483647 could be covered.
> > Documentation/networking/ip-sysctl.rst had "0 4294967295" as an example
> > value, but this example was wrong and causing -EINVAL.
>
> FYI, we got a small conflict when merging 'net' in 'net-next' in the
> MPTCP tree due to this patch applied in 'net':
>
>   e209fee4118f ("net/ipv4: ping_group_range: allow GID from 2147483648
> to 4294967294")
>
> and this one from 'net-next':
>
>   ccce324dabfe ("tcp: make the first N SYN RTO backoffs linear")
>
> ----- Generic Message -----
> The best is to avoid conflicts between 'net' and 'net-next' trees but if
> they cannot be avoided when preparing patches, a note about how to fix
> them is much appreciated.
>
> The conflict has been resolved on our side[1] and the resolution we
> suggest is attached to this email. Please report any issues linked to
> this conflict resolution as it might be used by others. If you worked on
> the mentioned patches, don't hesitate to ACK this conflict resolution.
> ---------------------------
>
> Regarding this conflict, I simply took the modifications from both sides.
>
> Cheers,
> Matt
>
> [1] https://github.com/multipath-tcp/mptcp_net-next/commit/f170c423f567
> --
> Tessares | Belgium | Hybrid Access Solutions
> www.tessares.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-03 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-01  3:13 [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294 Akihiro Suda
2023-06-02  9:00 ` patchwork-bot+netdevbpf
2023-06-03  7:35 ` [PATCH net v3] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294 - manual merge Matthieu Baerts
2023-06-03 10:49   ` Akihiro Suda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox