Re: [PATCH linux] net/ipv4: ping_group_range: allow GID from 2147483648 to 4294967294

From: Akihiro Suda
Date: Fri Jun 02 2023 - 09:03:58 EST


2023年6月2日(金) 19:51 David Laight <David.Laight@xxxxxxxxxx>:
>
> From: Kuniyuki Iwashima
> > Sent: 01 June 2023 00:00
> ....
> > > > --- a/include/net/ping.h
> > > > +++ b/include/net/ping.h
> > > > @@ -20,7 +20,7 @@
> > > > * 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)
>
> Doesn't that comment need updating?
>
> I do wonder how much code breaks for gid > MAXINT.
> How much testing does it actually get??

It is fixed in v3:
https://patchwork.kernel.org/project/netdevbpf/patch/20230601031305.55901-1-akihiro.suda.cz@xxxxxxxxxxxxx/

```
-/*
- * 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)
```

Tested with 4294967294, 4294967295 (EINVAL), and 4294967296 (EINVAL), on x86_64.




> David
>
> -
> Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
> Registration No: 1397386 (Wales)