mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Kees Cook <keescook@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	James Morris <james.l.morris@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Ming Lei <ming.lei@canonical.com>,
	linux-security-module <linux-security-module@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] firmware_class: perform new LSM checks
Date: Wed, 23 Jul 2014 12:11:06 +0200	[thread overview]
Message-ID: <s5hvbqojsg5.wl%tiwai@suse.de> (raw)
In-Reply-To: <CAGXu5j+H4_f0FmEh9=zZnisDu-xB1dGo6c6oDOTV-=LDD1-gtw@mail.gmail.com>

At Tue, 22 Jul 2014 10:39:00 -0700,
Kees Cook wrote:
> 
> On Mon, Jul 21, 2014 at 11:55 PM, Takashi Iwai <tiwai@suse.de> wrote:
> > At Mon, 21 Jul 2014 12:06:41 -0700,
> > Kees Cook wrote:
> >>
> >> This attaches LSM hooks to the existing firmware loading interfaces:
> >> filesystem-found firmware and demand-loaded blobs.
> >>
> >> Signed-off-by: Kees Cook <keescook@chromium.org>
> >> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >> ---
> >>  drivers/base/firmware_class.c |   16 ++++++++++++++--
> >>  1 file changed, 14 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> >> index d276e33880be..7399bab71ced 100644
> >> --- a/drivers/base/firmware_class.c
> >> +++ b/drivers/base/firmware_class.c
> >> @@ -28,6 +28,7 @@
> >>  #include <linux/suspend.h>
> >>  #include <linux/syscore_ops.h>
> >>  #include <linux/reboot.h>
> >> +#include <linux/security.h>
> >>
> >>  #include <generated/utsrelease.h>
> >>
> >> @@ -308,12 +309,17 @@ static int fw_read_file_contents(struct file *file, struct firmware_buf *fw_buf)
> >>       if (rc != size) {
> >>               if (rc > 0)
> >>                       rc = -EIO;
> >> -             vfree(buf);
> >> -             return rc;
> >> +             goto fail;
> >>       }
> >> +     rc = security_kernel_fw_from_file(file, buf, size);
> >> +     if (rc)
> >> +             goto fail;
> >>       fw_buf->data = buf;
> >>       fw_buf->size = size;
> >>       return 0;
> >> +fail:
> >> +     vfree(buf);
> >> +     return rc;
> >>  }
> >>
> >>  static int fw_get_filesystem_firmware(struct device *device,
> >> @@ -640,6 +646,12 @@ static ssize_t firmware_loading_store(struct device *dev,
> >>               break;
> >>       case 0:
> >>               if (test_bit(FW_STATUS_LOADING, &fw_buf->status)) {
> >> +                     if (security_kernel_fw_from_file(NULL, fw_buf->data,
> >> +                                                      fw_buf->size)) {
> >> +                             fw_load_abort(fw_priv);
> >> +                             break;
> >> +                     }
> >>                       set_bit(FW_STATUS_DONE, &fw_buf->status);
> >>                       clear_bit(FW_STATUS_LOADING, &fw_buf->status);
> >
> > security_kernel_fw_from_file() should be called after
> > fw_map_pages_buf() call (that is found after these lines).
> > Otherwise fw_buf->buf won't contain a valid buffer pointer.
> 
> Ah! Good to know. I guess I was getting lucky in my testing. Is this a
> race condition?

This is the code path where direct f/w loading fails but the
user-space helper feeds the data.  Did you test that scenario?


Takashi

  reply	other threads:[~2014-07-23 10:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-21 19:06 [PATCH v2 0/2] security: introduce kernel_fw_from_file hook Kees Cook
2014-07-21 19:06 ` [PATCH v2 1/2] " Kees Cook
2014-07-21 19:06 ` [PATCH v2 2/2] firmware_class: perform new LSM checks Kees Cook
2014-07-22  2:19   ` Ming Lei
2014-07-22  6:55   ` Takashi Iwai
2014-07-22 17:39     ` Kees Cook
2014-07-23 10:11       ` Takashi Iwai [this message]
2014-07-22 14:36 ` [PATCH v2 0/2] security: introduce kernel_fw_from_file hook Mimi Zohar

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=s5hvbqojsg5.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=james.l.morris@oracle.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=ming.lei@canonical.com \
    /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

all inboxes | Powered by JetHome®