Re: [PATCH v2 1/3] overflow.h: Add arithmetic shift helper

2018-08-01 Thread Jason Gunthorpe
On Wed, Aug 01, 2018 at 11:07:24AM +0300, Dan Carpenter wrote: > On Wed, Aug 01, 2018 at 10:57:44AM +0300, Dan Carpenter wrote: > > The idea is nice, but I don't like the API. The "_overflow" feels too > > specific because maybe we could check for other things in the future. > > Normally boolean m

Re: [PATCH v2 1/3] overflow.h: Add arithmetic shift helper

2018-08-01 Thread Kees Cook
On Wed, Aug 1, 2018 at 1:07 AM, Dan Carpenter wrote: > On Wed, Aug 01, 2018 at 10:57:44AM +0300, Dan Carpenter wrote: >> The idea is nice, but I don't like the API. The "_overflow" feels too >> specific because maybe we could check for other things in the future. >> Normally boolean macros should

Re: [PATCH v2 1/3] overflow.h: Add arithmetic shift helper

2018-08-01 Thread Dan Carpenter
On Wed, Aug 01, 2018 at 10:57:44AM +0300, Dan Carpenter wrote: > The idea is nice, but I don't like the API. The "_overflow" feels too > specific because maybe we could check for other things in the future. > Normally boolean macros should say they are boolean in the name and I > would prefer if i

Re: [PATCH v2 1/3] overflow.h: Add arithmetic shift helper

2018-08-01 Thread Dan Carpenter
The idea is nice, but I don't like the API. The "_overflow" feels too specific because maybe we could check for other things in the future. Normally boolean macros should say they are boolean in the name and I would prefer if it returned zero on failure. if (!checked_shift(dest, mask, shi

Re: [PATCH v2 1/3] overflow.h: Add arithmetic shift helper

2018-07-31 Thread Kees Cook
On Tue, Jul 31, 2018 at 7:15 PM, Jason Gunthorpe wrote: > On Tue, Jul 31, 2018 at 05:00:37PM -0700, Kees Cook wrote: >> From: Jason Gunthorpe >> >> Add shift_overflow() helper to assist driver authors in ensuring that >> shift operations don't cause overflows or other odd conditions. >> >> Signed

Re: [PATCH v2 1/3] overflow.h: Add arithmetic shift helper

2018-07-31 Thread Jason Gunthorpe
On Tue, Jul 31, 2018 at 05:00:37PM -0700, Kees Cook wrote: > From: Jason Gunthorpe > > Add shift_overflow() helper to assist driver authors in ensuring that > shift operations don't cause overflows or other odd conditions. > > Signed-off-by: Jason Gunthorpe > Signed-off-by: Leon Romanovsky > [

Re: [PATCH v2 1/3] overflow.h: Add arithmetic shift helper

2018-07-31 Thread Randy Dunlap
On 07/31/2018 05:00 PM, Kees Cook wrote: > From: Jason Gunthorpe > > Add shift_overflow() helper to assist driver authors in ensuring that > shift operations don't cause overflows or other odd conditions. > > Signed-off-by: Jason Gunthorpe > Signed-off-by: Leon Romanovsky > [kees: tweaked comm