[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202104021421.97A06AE@keescook>
Date: Fri, 2 Apr 2021 14:23:48 -0700
From: Kees Cook <keescook@...omium.org>
To: Christoph Hellwig <hch@....de>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Nathan Chancellor <natechancellor@...il.com>,
Arnd Bergmann <arnd@...db.de>, Tejun Heo <tj@...nel.org>,
Alexander Viro <viro@...iv.linux.org.uk>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Shuah Khan <shuah@...nel.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Kefeng Wang <wangkefeng.wang@...wei.com>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-kselftest@...r.kernel.org,
clang-built-linux@...glegroups.com, Michal Hocko <mhocko@...e.com>,
Alexey Dobriyan <adobriyan@...il.com>,
Lee Duncan <lduncan@...e.com>, Chris Leech <cleech@...hat.com>,
Adam Nichols <adam@...mm-co.com>,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH v4 3/3] sysfs: Unconditionally use vmalloc for buffer
On Fri, Apr 02, 2021 at 08:32:21AM +0200, Christoph Hellwig wrote:
> On Thu, Apr 01, 2021 at 03:13:20PM -0700, Kees Cook wrote:
> > The sysfs interface to seq_file continues to be rather fragile
> > (seq_get_buf() should not be used outside of seq_file), 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 sysfs's
> > use of seq_file almost always already uses PAGE_SIZE allocations, has
> > normally short-lived allocations, and is not normally on a performance
> > critical path.
>
> This looks completely weird to me. In the end sysfs uses nothing
> of the seq_file infrastructure, so why do we even pretend to use it?
> Just switch sysfs_file_kfops_ro and sysfs_file_kfops_rw from using
> ->seq_show to ->read and do the vmalloc there instead of pretending
> this is a seq_file.
As far as I can tell it's a result of kernfs using seq_file, but sysfs
never converted all its callbacks to use seq_file.
> > Once seq_get_buf() has been removed (and all sysfs callbacks using
> > seq_file directly), this change can also be removed.
>
> And with sysfs out of the way I think kiling off the other few users
> should be pretty easy as well.
Let me look at switching to "read" ... it is a twisty maze. :)
--
Kees Cook
Powered by blists - more mailing lists