Re: [PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread Josef Bacik
On 8/13/20 5:10 PM, David Laight wrote: From: Josef Bacik Sent: 13 August 2020 18:19 ... We wouldn't even need the extra +1 part, since we're only copying in how much the user wants anyway, we could just go ahead and convert this to left -= snprintf(buffer, left, "0x%04x\n", *(unsigned int *)

RE: [PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread David Laight
From: Josef Bacik > Sent: 13 August 2020 18:19 ... > We wouldn't even need the extra +1 part, since we're only copying in how much > the user wants anyway, we could just go ahead and convert this to > > left -= snprintf(buffer, left, "0x%04x\n", *(unsigned int *) table->data); > > and be fine, ri

Re: [PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread Josef Bacik
On 8/13/20 1:31 PM, Al Viro wrote: On Thu, Aug 13, 2020 at 01:19:18PM -0400, Josef Bacik wrote: in sunrpc proc_dodebug() turns into left -= snprintf(buffer, left, "0x%04x\n", left + 1, that i

Re: [PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread Al Viro
On Thu, Aug 13, 2020 at 01:19:18PM -0400, Josef Bacik wrote: > > in sunrpc proc_dodebug() turns into > > left -= snprintf(buffer, left, "0x%04x\n", left + 1, that is. > >

Re: [PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread Josef Bacik
On 8/13/20 12:20 PM, Al Viro wrote: On Thu, Aug 13, 2020 at 05:41:17PM +0200, Christoph Hellwig wrote: On Thu, Aug 13, 2020 at 11:40:00AM -0400, Josef Bacik wrote: On 8/13/20 11:37 AM, Christoph Hellwig wrote: On Thu, Aug 13, 2020 at 11:33:56AM -0400, Josef Bacik wrote: Since sysctl: pas

Re: [PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread Al Viro
On Thu, Aug 13, 2020 at 05:41:17PM +0200, Christoph Hellwig wrote: > On Thu, Aug 13, 2020 at 11:40:00AM -0400, Josef Bacik wrote: > > On 8/13/20 11:37 AM, Christoph Hellwig wrote: > >> On Thu, Aug 13, 2020 at 11:33:56AM -0400, Josef Bacik wrote: > >>> Since > >>> > >>>sysctl: pass kernel pointe

Re: [PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread Christoph Hellwig
On Thu, Aug 13, 2020 at 11:40:00AM -0400, Josef Bacik wrote: > On 8/13/20 11:37 AM, Christoph Hellwig wrote: >> On Thu, Aug 13, 2020 at 11:33:56AM -0400, Josef Bacik wrote: >>> Since >>> >>>sysctl: pass kernel pointers to ->proc_handler >>> >>> we have been pre-allocating a buffer to copy the d

Re: [PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread Josef Bacik
On 8/13/20 11:37 AM, Christoph Hellwig wrote: On Thu, Aug 13, 2020 at 11:33:56AM -0400, Josef Bacik wrote: Since sysctl: pass kernel pointers to ->proc_handler we have been pre-allocating a buffer to copy the data from the proc handlers into, and then copying that to userspace. The problem

Re: [PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread Christoph Hellwig
On Thu, Aug 13, 2020 at 11:33:56AM -0400, Josef Bacik wrote: > Since > > sysctl: pass kernel pointers to ->proc_handler > > we have been pre-allocating a buffer to copy the data from the proc > handlers into, and then copying that to userspace. The problem is this > just blind kmalloc()'s the

[PATCH][v2] proc: use vmalloc for our kernel buffer

2020-08-13 Thread Josef Bacik
Since sysctl: pass kernel pointers to ->proc_handler we have been pre-allocating a buffer to copy the data from the proc handlers into, and then copying that to userspace. The problem is this just blind kmalloc()'s the buffer size passed in from the read, which in the case of our 'cat' binary