Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-31 Thread Andy Shevchenko
On Thu, Aug 31, 2023 at 4:16 PM Andy Shevchenko wrote: > On Thu, Aug 31, 2023 at 3:22 PM Philipp Stanner wrote: > > On Wed, 2023-08-30 at 17:11 +0300, Andy Shevchenko wrote: > > > On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner > > > wrote: ... > > > I'm wondering if this has no side-effects a

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-31 Thread Andy Shevchenko
On Thu, Aug 31, 2023 at 3:22 PM Philipp Stanner wrote: > On Wed, 2023-08-30 at 17:11 +0300, Andy Shevchenko wrote: > > On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner > > wrote: ... > > I'm wondering if this has no side-effects as string.h/string.c IIRC > > is used also for early stages where s

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-31 Thread Philipp Stanner
On Wed, 2023-08-30 at 17:11 +0300, Andy Shevchenko wrote: > On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner > wrote: > > > > Currently, user array duplications are sometimes done without an > > overflow check. Sometimes the checks are done manually; sometimes > > the > > array size is calculated

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-31 Thread Philipp Stanner
On Thu, 2023-08-31 at 11:59 +0300, Andy Shevchenko wrote: > On Wed, Aug 30, 2023 at 10:15 PM wrote: > > On Wed, 2023-08-30 at 17:29 +0300, Andy Shevchenko wrote: > > > On Wed, Aug 30, 2023 at 5:19 PM wrote: > > > > On Wed, 2023-08-30 at 17:11 +0300, Andy Shevchenko wrote: > > > > > On Wed, Aug 30

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-31 Thread Andy Shevchenko
On Wed, Aug 30, 2023 at 10:15 PM wrote: > On Wed, 2023-08-30 at 17:29 +0300, Andy Shevchenko wrote: > > On Wed, Aug 30, 2023 at 5:19 PM wrote: > > > On Wed, 2023-08-30 at 17:11 +0300, Andy Shevchenko wrote: > > > > On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner > > > > > > > > wrote: ... > >

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-30 Thread pstanner
On Wed, 2023-08-30 at 17:29 +0300, Andy Shevchenko wrote: > On Wed, Aug 30, 2023 at 5:19 PM wrote: > > On Wed, 2023-08-30 at 17:11 +0300, Andy Shevchenko wrote: > > > On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner > > > > > > wrote: > > > > > --- a/include/linux/string.h > > > > +++ b/include/l

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-30 Thread Andy Shevchenko
On Wed, Aug 30, 2023 at 5:19 PM wrote: > On Wed, 2023-08-30 at 17:11 +0300, Andy Shevchenko wrote: > > On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner > > wrote: > > > --- a/include/linux/string.h > > > +++ b/include/linux/string.h > > > > I'm wondering if this has no side-effects as string.h/st

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-30 Thread pstanner
On Wed, 2023-08-30 at 17:15 +0300, Andy Shevchenko wrote: > On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner > wrote: > > > +   if (unlikely(check_mul_overflow(n, size, &nbytes))) > > +   return ERR_PTR(-EINVAL); > > > +   if (unlikely(check_mul_overflow(n, size, &nbytes))) >

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-30 Thread pstanner
On Wed, 2023-08-30 at 17:11 +0300, Andy Shevchenko wrote: > On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner > wrote: > > > > Currently, user array duplications are sometimes done without an > > overflow check. Sometimes the checks are done manually; sometimes > > the > > array size is calculated

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-30 Thread Andy Shevchenko
On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner wrote: > + if (unlikely(check_mul_overflow(n, size, &nbytes))) > + return ERR_PTR(-EINVAL); > + if (unlikely(check_mul_overflow(n, size, &nbytes))) > + return ERR_PTR(-EINVAL); Btw, why not -EOVERFLOW ? --

Re: [PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-30 Thread Andy Shevchenko
On Wed, Aug 30, 2023 at 4:46 PM Philipp Stanner wrote: > > Currently, user array duplications are sometimes done without an > overflow check. Sometimes the checks are done manually; sometimes the > array size is calculated with array_size() and sometimes by calculating > n * size directly in code.

[PATCH 1/5] string.h: add array-wrappers for (v)memdup_user()

2023-08-30 Thread Philipp Stanner
Currently, user array duplications are sometimes done without an overflow check. Sometimes the checks are done manually; sometimes the array size is calculated with array_size() and sometimes by calculating n * size directly in code. Introduce wrappers for arrays for memdup_user() and vmemdup_user