All of lore.kernel.org
 help / color / mirror / Atom feed
From: rishabhb@codeaurora.org
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	ard.biesheuvel@linaro.org, vbabka@suse.cz, riel@surriel.com,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	ckadabi@codeaurora.org, tsoni@codeaurora.org,
	psodagud@codeaurora.org,
	Vikram Mulukutla <markivx@codeaurora.org>
Subject: Re: [PATCH] firmware: Fix security issue with request_firmware_into_buf()
Date: Tue, 07 Aug 2018 15:41:41 -0700	[thread overview]
Message-ID: <aad4d3d0a66f00e429fcc08604c4ed0a@codeaurora.org> (raw)
In-Reply-To: <CAB=NE6XfwMOMgZK9YrE=kq0++wT109bNQQ0QYcu=0vfuuDyF3g@mail.gmail.com>

On 2018-08-02 14:58, Luis Chamberlain wrote:
> On Wed, Aug 1, 2018, 4:26 PM Rishabh Bhatnagar
> <rishabhb@codeaurora.org> wrote:
> 
>> When calling request_firmware_into_buf() with the FW_OPT_NOCACHE
>> flag
>> it is expected that firmware is loaded into buffer from memory.
>> But inside alloc_lookup_fw_priv every new firmware that is loaded is
>> added to the firmware cache (fwc) list head. So if any driver
>> requests
>> a firmware that is already loaded the code iterates over the above
>> mentioned list and it can end up giving a pointer to other device
>> driver's
>> firmware buffer.
>> Also the existing copy may either be modified by drivers, remote
>> processors
>> or even freed. This causes a potential security issue with batched
>> requests
>> when using request_firmware_into_buf.
>> 
>> Fix alloc_lookup_fw_priv to not add to the fwc head list if
>> FW_OPT_NOCACHE
>> is set, and also don't do the lookup in the list.
>> 
>> Fixes: 0e742e9275 ("firmware: provide infrastructure to make fw
>> caching optional")
>> 
>> Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
>> Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org>
>> ---
> 
> Did you test with the tools/testing/selftests/firmware/ scripts? If
> not please do so and report back and confirm no regressions are found.
> 
> Brownie points for you to add a test case to show the issue
> highlighted in this patch, and which it fixes. I believe this fix
> should be pushed to stable, so I'll do that after you confirm no
> regressions were found.
> 
> The new selftests changed you'd make would not go to stable, however
> there are Linux distributions and 0day that test the latest tools
> directory against older kernels. So this test would help capture gaps
> later.
> 
>   Luis

I ran the selftests and observed no regressions with this change.
I'm still working on adding a test case though.

-Rishabh

  parent reply	other threads:[~2018-08-07 22:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-01 23:25 [PATCH] firmware: Fix security issue with request_firmware_into_buf() Rishabh Bhatnagar
     [not found] ` <CAB=NE6XfwMOMgZK9YrE=kq0++wT109bNQQ0QYcu=0vfuuDyF3g@mail.gmail.com>
2018-08-07 22:41   ` rishabhb [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-08-31 15:43 Luis R. Rodriguez

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=aad4d3d0a66f00e429fcc08604c4ed0a@codeaurora.org \
    --to=rishabhb@codeaurora.org \
    --cc=akpm@linux-foundation.org \
    --cc=ard.biesheuvel@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=ckadabi@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markivx@codeaurora.org \
    --cc=mcgrof@kernel.org \
    --cc=psodagud@codeaurora.org \
    --cc=riel@surriel.com \
    --cc=tsoni@codeaurora.org \
    --cc=vbabka@suse.cz \
    --cc=zohar@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.