[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wjOZQ1yvG+FvP-sDgGaDzmXoxC7KjDMUerw_Z2QYyAHmA@mail.gmail.com>
Date: Wed, 21 Jul 2021 13:46:09 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: "Matthew Wilcox (Oracle)" <willy@...radead.org>
Cc: Al Viro <viro@...iv.linux.org.uk>,
Qualys Security Advisory <qsa@...lys.com>,
Eric Sandeen <sandeen@...hat.com>,
Linux-MM <linux-mm@...ck.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm: Make kvmalloc refuse to allocate more than 2GB
On Wed, Jul 21, 2021 at 11:42 AM Matthew Wilcox (Oracle)
<willy@...radead.org> wrote:
>
> It's generally dangerous to allocate such large quantities of memory
> within the kernel owing to our propensity to use 'int' to represent
> a length. If somebody really needs it, we can add a kvmalloc_large()
> later, but let's default to "You can't allocate that much memory".
I really think that without the WARN_ON_ONCE(), this is just moving
that failure point from a known good place ("we know this must not
succeed") to a possibly bad place ("this might cause silent and
hard-to-understand failures elsewhere").
IOW, in seq_buf_alloc() there's no need to warn. It's clear that a
bigger allocation can never be valid.
But in kvmalloc(), it needs to warn, because if it ever triggers we
need to check what triggered it.
So this is not just moving code from one place to another equivalent one.
Linus
Powered by blists - more mailing lists