Re: [PATCH 1/2] sysctl: add overflow detection to proc_get_long()

2018-10-14 Thread Christian Brauner
On October 15, 2018 2:03:10 AM GMT+02:00, Al Viro wrote: >On Sun, Oct 14, 2018 at 08:53:46PM +0200, Christian Brauner wrote: > >> > Yecchh... First of all, the cast back to unsigned long long is >completely >> > pointless. What's more, >> >> Sorry, seriously asking: why? This was meant to hand

Re: [PATCH 1/2] sysctl: add overflow detection to proc_get_long()

2018-10-14 Thread Al Viro
On Sun, Oct 14, 2018 at 08:53:46PM +0200, Christian Brauner wrote: > > Yecchh... First of all, the cast back to unsigned long long is completely > > pointless. What's more, > > Sorry, seriously asking: why? This was meant to handle the case where > sizeof(unsigned long long) != sizeof(unsigned

Re: [PATCH 1/2] sysctl: add overflow detection to proc_get_long()

2018-10-14 Thread Christian Brauner
On October 15, 2018 12:13:25 AM GMT+02:00, Alexey Dobriyan wrote: >> > Yecchh... First of all, the cast back to unsigned long long is >completely >> > pointless. What's more, >> >> Sorry, seriously asking: why? > >In C everything is casted to the same type before doing an operation, Oh, ok th

Re: [PATCH 1/2] sysctl: add overflow detection to proc_get_long()

2018-10-14 Thread Alexey Dobriyan
> > Yecchh... First of all, the cast back to unsigned long long is completely > > pointless. What's more, > > Sorry, seriously asking: why? In C everything is casted to the same type before doing an operation, in this case comparison > This was meant to handle the case where > sizeof(unsigned

Re: [PATCH 1/2] sysctl: add overflow detection to proc_get_long()

2018-10-14 Thread Christian Brauner
On Sun, Oct 14, 2018 at 06:18:55PM +0100, Al Viro wrote: > On Sun, Oct 14, 2018 at 03:25:09PM +0200, Christian Brauner wrote: > > > +static unsigned long sysctl_strtoul_lenient(const char *cp, char **endp, > > + unsigned int base, bool *overflow) > > +{ > > +

Re: [PATCH 1/2] sysctl: add overflow detection to proc_get_long()

2018-10-14 Thread Al Viro
On Sun, Oct 14, 2018 at 03:25:09PM +0200, Christian Brauner wrote: > +static unsigned long sysctl_strtoul_lenient(const char *cp, char **endp, > + unsigned int base, bool *overflow) > +{ > + unsigned long long result; > + unsigned int rv; > + > +

[PATCH 1/2] sysctl: add overflow detection to proc_get_long()

2018-10-14 Thread Christian Brauner
proc_get_long() is a funny function. It uses simple_strtoul() and for a good reason. proc_get_long() wants to always succeed the parse and return the maybe incorrect value and the trailing characters to check against a pre-defined list of acceptable trailing values. However, simple_strtoul() doesn