From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: Jessica Yu <jeyu@kernel.org>, Kees Cook <keescook@chromium.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] module: add in-kernel support for decompressing
Date: Fri, 10 Dec 2021 15:47:22 -0800 [thread overview]
Message-ID: <YbPnCo8ZZ6vrMASe@google.com> (raw)
In-Reply-To: <YbPkQrg4CRWkESFL@bombadil.infradead.org>
On Fri, Dec 10, 2021 at 03:35:30PM -0800, Luis Chamberlain wrote:
> On Fri, Dec 10, 2021 at 03:21:03PM -0800, Dmitry Torokhov wrote:
> > On Fri, Dec 10, 2021 at 02:05:17PM -0800, Luis Chamberlain wrote:
> > > On Thu, Dec 09, 2021 at 10:09:17PM -0800, Dmitry Torokhov wrote:
> > > > +static ssize_t module_xz_decompress(struct load_info *info,
> > > > + const void *buf, size_t size)
> > > > +{
> > > > + static const u8 signature[] = { 0xfd, '7', 'z', 'X', 'Z', 0 };
> > > > + struct xz_dec *xz_dec;
> > > > + struct xz_buf xz_buf;
> > > > + enum xz_ret xz_ret;
> > > > + size_t new_size = 0;
> > > > + ssize_t retval;
> > > > +
> > > > + if (size < sizeof(signature) ||
> > > > + memcmp(buf, signature, sizeof(signature))) {
> > > > + pr_err("not an xz compressed module\n");
> > > > + return -EINVAL;
> > > > + }
> > > > +
> > > > + xz_dec = xz_dec_init(XZ_DYNALLOC, (u32)-1);
> > > > + if (!xz_dec)
> > > > + return -ENOMEM;
> > > > +
> > > > + xz_buf.in_size = size;
> > > > + xz_buf.in = buf;
> > > > + xz_buf.in_pos = 0;
> > > > +
> > > > + do {
> > > > + struct page *page = module_get_next_page(info);
> > > > + if (!page) {
> > > > + retval = -ENOMEM;
> > > > + goto out;
> > > > + }
> > >
> > > This looks very similar to fw_decompress_xz_pages() on
> > > drivers/base/firmware_loader/main.c
> > >
> > > Is there any sharing possible with decompression between the two?
> >
> > Ideally we'd get proper crypto API allowing this (page by page)
> > decompression and then we can switch to it in both places and stop
> > calling into particular algorithms directly. Unfortunately this is not
> > something I can sign up for at this time.
> >
> > As it is I am not sure if it worth to try to split out XZ code and share
> > it between module and firmware loader.
>
> Got it, makes sense.
>
> What type of tests have you implemented for this ? kmod has quite a bit
> of tests. Can you add some for this?
OK, will do.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2021-12-10 23:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-10 6:09 [PATCH v3] module: add in-kernel support for decompressing Dmitry Torokhov
2021-12-10 22:05 ` Luis Chamberlain
2021-12-10 23:21 ` Dmitry Torokhov
2021-12-10 23:35 ` Luis Chamberlain
2021-12-10 23:47 ` Dmitry Torokhov [this message]
2021-12-11 0:11 ` Luis Chamberlain
2021-12-11 1:09 ` Dmitry Torokhov
2021-12-20 16:52 ` Luis Chamberlain
2021-12-21 3:17 ` Dmitry Torokhov
2021-12-21 21:59 ` Luis Chamberlain
2022-01-03 2:58 ` Dmitry Torokhov
2022-01-11 15:42 ` Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YbPnCo8ZZ6vrMASe@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=jeyu@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox