Re: [PATCH] module: Remove module size limit

From: Sasha Levin
Date: Tue Jan 31 2012 - 10:28:29 EST


On Tue, 2012-01-31 at 09:07 -0500, Josh Boyer wrote:
> On Mon, Jan 30, 2012 at 11:07 PM, Sasha Levin <levinsasha928@xxxxxxxxx> wrote:
> > Module size was limited to 64MB, this was legacy limitation due to vmalloc()
> > which was removed a while ago.
> >
> > Limiting module size to 64MB is both pointless and affects real world use
> > cases.
> >
> > Cc: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
> > Cc: Tim Abbott <tim.abbott@xxxxxxxxxx>
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Sasha Levin <sasha.levin@xxxxxxxxxx>
> > ---
> > kernel/module.c | 3 +--
> > 1 files changed, 1 insertions(+), 2 deletions(-)
> >
> > diff --git a/kernel/module.c b/kernel/module.c
> > index 2c93276..3d56b6f 100644
> > --- a/kernel/module.c
> > +++ b/kernel/module.c
> > @@ -2380,8 +2380,7 @@ static int copy_and_check(struct load_info *info,
> > return -ENOEXEC;
> >
> > /* Suck in entire file: we'll want most of it. */
> > - /* vmalloc barfs on "unusual" numbers. Check here */
> > - if (len > 64 * 1024 * 1024 || (hdr = vmalloc(len)) == NULL)
> > + if ((hdr = vmalloc(len)) == NULL)
> > return -ENOMEM;
> >
> > if (copy_from_user(hdr, umod, len) != 0) {
>
> I could be missing something somewhere, but this is the only upper bounds
> check that is in place on the overall module size. If we remove this without
> putting some other kind of sanity check, wouldn't it be possible for someone
> to exhaust the entire vmalloc space for the kernel by loading a bloated module?

That someone needs CAP_SYS_MODULE to load a module in the first place,
it means that the user has to be privileged enough to load modules at
all.
Right now he can exhaust the vmalloc space simply by loading multiple
64MB modules, I don't think it matters much if we allow him to load one
module with over 64MB.
Also, if a malicious user can get a privileged user to load a kernel
module of his choice there are bigger things to worry about than the
vmalloc space.

> I would think we still want to have some form of upper bounds check to prevent
> that, but maybe I'm paranoid.

If there is a valid technical limit it would make sense, but just
scaling the 64MB limit up arbitrarily is pointless.

> As an aside, which real world use cases are blocked by having a 64MB limit?
> That is already HUGE.

When using KSplice, there is a debug option which allows you to generate
debug modules which weigh just a bit over 64MB. We currently patched the
64MB check out using a different KSplice patch, and everything works
quite well.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/