lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3c9697611e214d089f7a04086635c5a8@AcuMS.aculab.com>
Date:   Tue, 2 Apr 2019 09:55:43 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Jann Horn' <jannh@...gle.com>, Borislav Petkov <bp@...en8.de>
CC:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        the arch/x86 maintainers <x86@...nel.org>,
        kernel list <linux-kernel@...r.kernel.org>,
        Qiaowei Ren <qiaowei.ren@...el.com>,
        Mukesh Ojha <mojha@...eaurora.org>
Subject: RE: [PATCH v3 2/4] x86/microcode: Fix __user annotations around
 generic_load_microcode()

From: Jann Horn
> Sent: 01 April 2019 18:54
...
> > This ->get_ucode_data() BIOS-code-like contraption has always bugged me
> > for being too ugly to live.
> >
> > How about we vmalloc() a properly sized buffer - both
> > generic_load_microcode() callers have the size - and then hand that
> > buffer into generic_load_microcode() ?
> >
> > That solves the __user annotation fun immediately and would simplify
> > generic_load_microcode() additionally.
> >
> > The disadvantage would be having to vmalloc() a couple of... , I think
> > it is megabytes, with that old loading method request_microcode_user()
> > but then if vmalloc() fails, then it was clearly too big. I don't think
> > the blob can ever be that big though, to fail vmalloc(), but I'm not
> > going to bet on it...
> 
> Hm. request_microcode_fw() gets that buffer from
> request_firmware_direct(), which does this:
> 
>         __module_get(THIS_MODULE);
>         ret = _request_firmware(firmware_p, name, device, NULL, 0,
>                                 FW_OPT_UEVENT | FW_OPT_NO_WARN |
>                                 FW_OPT_NOFALLBACK);
>         module_put(THIS_MODULE);
>         return ret;
> 
> What is that module_get()/module_put() supposed to be good for? Are we
> expecting that caller to do something ridiculous like calling
> module_put() on us? This doesn't seem to make any sense.

At least it isn't doing a try_module_get(THIS_MODULE) :-)

> And then _request_firmware() goes and ends up in places like
> kernel_read_file(), which already use vmalloc().
> 
> 
> Anyway, isn't this kind of thing exactly why we have that iov_iter
> stuff? request_microcode_fw() can build an ITER_KVEC,
> request_microcode_user() can build an ITER_IOVEC. And then
> generic_load_microcode() can use something like copy_from_iter(). Does
> that sound reasonable?

That ought to allow the microcode be copied in chunks - removing the
need for a massive buffer?

The largest file we ever copy to PCIe cards is a 6MB fpga image.
But we do that by mmapping the PCIe registers directly into userspace.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ