Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-18 Thread Greg Kroah-Hartman
On Thu, Mar 18, 2021 at 08:51:45AM -0700, Kees Cook wrote: > On Thu, Mar 18, 2021 at 09:07:45AM +0100, Greg Kroah-Hartman wrote: > > On Wed, Mar 17, 2021 at 02:30:47PM -0700, Kees Cook wrote: > > > On Wed, Mar 17, 2021 at 04:38:57PM +0100, Greg Kroah-Hartman wrote: > > > > On Wed, Mar 17, 2021 at 0

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-18 Thread Kees Cook
On Thu, Mar 18, 2021 at 09:07:45AM +0100, Greg Kroah-Hartman wrote: > On Wed, Mar 17, 2021 at 02:30:47PM -0700, Kees Cook wrote: > > On Wed, Mar 17, 2021 at 04:38:57PM +0100, Greg Kroah-Hartman wrote: > > > On Wed, Mar 17, 2021 at 04:20:52PM +0100, Michal Hocko wrote: > > > > On Wed 17-03-21 15:56:

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-18 Thread Greg Kroah-Hartman
On Wed, Mar 17, 2021 at 02:30:47PM -0700, Kees Cook wrote: > On Wed, Mar 17, 2021 at 04:38:57PM +0100, Greg Kroah-Hartman wrote: > > On Wed, Mar 17, 2021 at 04:20:52PM +0100, Michal Hocko wrote: > > > On Wed 17-03-21 15:56:44, Greg KH wrote: > > > > On Wed, Mar 17, 2021 at 03:44:16PM +0100, Michal

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-17 Thread Kees Cook
On Wed, Mar 17, 2021 at 04:38:57PM +0100, Greg Kroah-Hartman wrote: > On Wed, Mar 17, 2021 at 04:20:52PM +0100, Michal Hocko wrote: > > On Wed 17-03-21 15:56:44, Greg KH wrote: > > > On Wed, Mar 17, 2021 at 03:44:16PM +0100, Michal Hocko wrote: > > > > On Wed 17-03-21 14:34:27, Greg KH wrote: > > >

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-17 Thread Greg Kroah-Hartman
On Wed, Mar 17, 2021 at 03:44:16PM +0100, Michal Hocko wrote: > On Wed 17-03-21 14:34:27, Greg KH wrote: > > On Wed, Mar 17, 2021 at 01:08:21PM +0100, Michal Hocko wrote: > > > Btw. I still have problems with the approach. seq_file is intended to > > > provide safe way to dump values to the userspa

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-17 Thread Greg Kroah-Hartman
On Wed, Mar 17, 2021 at 04:20:52PM +0100, Michal Hocko wrote: > On Wed 17-03-21 15:56:44, Greg KH wrote: > > On Wed, Mar 17, 2021 at 03:44:16PM +0100, Michal Hocko wrote: > > > On Wed 17-03-21 14:34:27, Greg KH wrote: > > > > On Wed, Mar 17, 2021 at 01:08:21PM +0100, Michal Hocko wrote: > > > > > B

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-17 Thread Michal Hocko
On Wed 17-03-21 16:38:57, Greg KH wrote: > On Wed, Mar 17, 2021 at 04:20:52PM +0100, Michal Hocko wrote: > > On Wed 17-03-21 15:56:44, Greg KH wrote: > > > On Wed, Mar 17, 2021 at 03:44:16PM +0100, Michal Hocko wrote: > > > > On Wed 17-03-21 14:34:27, Greg KH wrote: > > > > > On Wed, Mar 17, 2021 a

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-17 Thread Michal Hocko
On Wed 17-03-21 15:56:44, Greg KH wrote: > On Wed, Mar 17, 2021 at 03:44:16PM +0100, Michal Hocko wrote: > > On Wed 17-03-21 14:34:27, Greg KH wrote: > > > On Wed, Mar 17, 2021 at 01:08:21PM +0100, Michal Hocko wrote: > > > > Btw. I still have problems with the approach. seq_file is intended to > >

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-17 Thread Michal Hocko
On Wed 17-03-21 14:34:27, Greg KH wrote: > On Wed, Mar 17, 2021 at 01:08:21PM +0100, Michal Hocko wrote: > > Btw. I still have problems with the approach. seq_file is intended to > > provide safe way to dump values to the userspace. Sacrificing > > performance just because of some abuser seems like

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-17 Thread Greg Kroah-Hartman
On Wed, Mar 17, 2021 at 01:08:21PM +0100, Michal Hocko wrote: > Btw. I still have problems with the approach. seq_file is intended to > provide safe way to dump values to the userspace. Sacrificing > performance just because of some abuser seems like a wrong way to go as > Al pointed out earlier. C

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-17 Thread Michal Hocko
On Tue 16-03-21 12:08:02, Kees Cook wrote: > On Tue, Mar 16, 2021 at 09:31:23AM +0100, Michal Hocko wrote: [...] > > Also this cannot really be done for configurations with a very limited > > vmalloc space (32b for example). Those systems are more and more rare > > but you shouldn't really allow us

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-17 Thread Greg Kroah-Hartman
On Tue, Mar 16, 2021 at 12:18:33PM -0700, Kees Cook wrote: > On Tue, Mar 16, 2021 at 12:43:12PM +, Al Viro wrote: > > On Tue, Mar 16, 2021 at 08:24:50AM +0100, Greg Kroah-Hartman wrote: > > > > > > Completely agreed. seq_get_buf() should be totally ripped out. > > > > Unfortunately, this is go

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-16 Thread Kees Cook
On Tue, Mar 16, 2021 at 12:43:12PM +, Al Viro wrote: > On Tue, Mar 16, 2021 at 08:24:50AM +0100, Greg Kroah-Hartman wrote: > > > > Completely agreed. seq_get_buf() should be totally ripped out. > > > Unfortunately, this is going to be a long road because of sysfs's ATTR > > > stuff, there are

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-16 Thread Kees Cook
On Tue, Mar 16, 2021 at 09:31:23AM +0100, Michal Hocko wrote: > On Mon 15-03-21 10:48:51, Kees Cook wrote: > > The sysfs interface to seq_file continues to be rather fragile, as seen > > with some recent exploits[1]. Move the seq_file buffer to the vmap area > > (while retaining the accounting flag

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-16 Thread Michal Hocko
On Tue 16-03-21 12:43:12, Al Viro wrote: [...] > AFAICS, Kees wants to protect against ->show() instances stomping beyond > the page size. What I don't get is what do you get from using seq_file > if you insist on doing raw access to the buffer rather than using > seq_printf() and friends. What's

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-16 Thread Greg Kroah-Hartman
On Tue, Mar 16, 2021 at 12:43:12PM +, Al Viro wrote: > On Tue, Mar 16, 2021 at 08:24:50AM +0100, Greg Kroah-Hartman wrote: > > > > Completely agreed. seq_get_buf() should be totally ripped out. > > > Unfortunately, this is going to be a long road because of sysfs's ATTR > > > stuff, there are

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-16 Thread Al Viro
On Tue, Mar 16, 2021 at 08:24:50AM +0100, Greg Kroah-Hartman wrote: > > Completely agreed. seq_get_buf() should be totally ripped out. > > Unfortunately, this is going to be a long road because of sysfs's ATTR > > stuff, there are something like 5000 callers, and the entire API was > > designed to

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-16 Thread Michal Hocko
On Mon 15-03-21 10:48:51, Kees Cook wrote: > The sysfs interface to seq_file continues to be rather fragile, as seen > with some recent exploits[1]. Move the seq_file buffer to the vmap area > (while retaining the accounting flag), since it has guard pages that > will catch and stop linear overflow

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-16 Thread Greg Kroah-Hartman
On Mon, Mar 15, 2021 at 01:43:59PM -0700, Kees Cook wrote: > On Mon, Mar 15, 2021 at 06:33:10PM +, Al Viro wrote: > > On Mon, Mar 15, 2021 at 10:48:51AM -0700, Kees Cook wrote: > > > The sysfs interface to seq_file continues to be rather fragile, as seen > > > with some recent exploits[1]. Move

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-15 Thread Kees Cook
On Mon, Mar 15, 2021 at 06:33:10PM +, Al Viro wrote: > On Mon, Mar 15, 2021 at 10:48:51AM -0700, Kees Cook wrote: > > The sysfs interface to seq_file continues to be rather fragile, as seen > > with some recent exploits[1]. Move the seq_file buffer to the vmap area > > (while retaining the acco

Re: [PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-15 Thread Al Viro
On Mon, Mar 15, 2021 at 10:48:51AM -0700, Kees Cook wrote: > The sysfs interface to seq_file continues to be rather fragile, as seen > with some recent exploits[1]. Move the seq_file buffer to the vmap area > (while retaining the accounting flag), since it has guard pages that > will catch and stop

[PATCH v2] seq_file: Unconditionally use vmalloc for buffer

2021-03-15 Thread Kees Cook
The sysfs interface to seq_file continues to be rather fragile, as seen with some recent exploits[1]. Move the seq_file buffer to the vmap area (while retaining the accounting flag), since it has guard pages that will catch and stop linear overflows. This seems justified given that seq_file already