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  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]
Date:	Sun, 20 Jul 2014 11:06:55 +0800
From:	Ming Lei <ming.lei@...onical.com>
To:	Kees Cook <keescook@...omium.org>
Cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	"Luis R. Rodriguez" <mcgrof@...e.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	James Morris <james.l.morris@...cle.com>,
	David Howells <dhowells@...hat.com>, linux-doc@...r.kernel.org,
	linux-security-module@...r.kernel.org, linux-firmware@...nel.org,
	linux-wireless <linux-wireless@...r.kernel.org>
Subject: Re: [PATCH 5/7] firmware_class: extract start loading logic

On Tue, Jul 15, 2014 at 5:38 AM, Kees Cook <keescook@...omium.org> wrote:
> Extract the logic performed when starting a new firmware load.
>
> Signed-off-by: Kees Cook <keescook@...omium.org>

Acked-by: Ming Lei <ming.lei@...onical.com>

> ---
>  drivers/base/firmware_class.c |   29 ++++++++++++++++++-----------
>  1 file changed, 18 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> index 7399bab71ced..b38cbcd6ebb1 100644
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -604,6 +604,23 @@ static int fw_map_pages_buf(struct firmware_buf *buf)
>         return 0;
>  }
>
> +/* fw_lock must be held */
> +static void fw_load_start(struct firmware_buf *fw_buf)
> +{
> +       /* discarding any previous partial load */
> +       if (!test_bit(FW_STATUS_DONE, &fw_buf->status)) {
> +               int i;
> +
> +               for (i = 0; i < fw_buf->nr_pages; i++)
> +                       __free_page(fw_buf->pages[i]);
> +               kfree(fw_buf->pages);
> +               fw_buf->pages = NULL;
> +               fw_buf->page_array_size = 0;
> +               fw_buf->nr_pages = 0;
> +               set_bit(FW_STATUS_LOADING, &fw_buf->status);
> +       }
> +}
> +
>  /**
>   * firmware_loading_store - set value in the 'loading' control file
>   * @dev: device pointer
> @@ -624,7 +641,6 @@ static ssize_t firmware_loading_store(struct device *dev,
>         struct firmware_priv *fw_priv = to_firmware_priv(dev);
>         struct firmware_buf *fw_buf;
>         int loading = simple_strtol(buf, NULL, 10);
> -       int i;
>
>         mutex_lock(&fw_lock);
>         fw_buf = fw_priv->buf;
> @@ -633,16 +649,7 @@ static ssize_t firmware_loading_store(struct device *dev,
>
>         switch (loading) {
>         case 1:
> -               /* discarding any previous partial load */
> -               if (!test_bit(FW_STATUS_DONE, &fw_buf->status)) {
> -                       for (i = 0; i < fw_buf->nr_pages; i++)
> -                               __free_page(fw_buf->pages[i]);
> -                       kfree(fw_buf->pages);
> -                       fw_buf->pages = NULL;
> -                       fw_buf->page_array_size = 0;
> -                       fw_buf->nr_pages = 0;
> -                       set_bit(FW_STATUS_LOADING, &fw_buf->status);
> -               }
> +               fw_load_start(fw_buf);
>                 break;
>         case 0:
>                 if (test_bit(FW_STATUS_LOADING, &fw_buf->status)) {
> --
> 1.7.9.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists