linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] firmware: Always initialize the fw_priv list object
@ 2018-09-20  1:09 Bjorn Andersson
  2018-09-20  5:22 ` Greg Kroah-Hartman
  2018-09-20  7:38 ` Rafael J. Wysocki
  0 siblings, 2 replies; 9+ messages in thread
From: Bjorn Andersson @ 2018-09-20  1:09 UTC (permalink / raw)
  To: Luis R. Rodriguez, Greg Kroah-Hartman
  Cc: Rafael J. Wysocki, linux-kernel, linux-arm-msm, stable,
	Rishabh Bhatnagar

When freeing the fw_priv the item is taken off the list. This causes an
oops in the FW_OPT_NOCACHE case as the list object is not initialized.

Make sure to initialize the list object regardless of this flag.

Fixes: 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
Cc: stable@vger.kernel.org
Cc: Rishabh Bhatnagar <rishabhb@codeaurora.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
 drivers/base/firmware_loader/main.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index b3c0498ee433..8e9213b36e31 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -226,8 +226,11 @@ static int alloc_lookup_fw_priv(const char *fw_name,
 	}
 
 	tmp = __allocate_fw_priv(fw_name, fwc, dbuf, size);
-	if (tmp && !(opt_flags & FW_OPT_NOCACHE))
-		list_add(&tmp->list, &fwc->head);
+	if (tmp) {
+		INIT_LIST_HEAD(&tmp->list);
+		if (!(opt_flags & FW_OPT_NOCACHE))
+			list_add(&tmp->list, &fwc->head);
+	}
 	spin_unlock(&fwc->lock);
 
 	*fw_priv = tmp;
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] firmware: Always initialize the fw_priv list object
  2018-09-20  1:09 [PATCH] firmware: Always initialize the fw_priv list object Bjorn Andersson
@ 2018-09-20  5:22 ` Greg Kroah-Hartman
  2018-09-20  7:34   ` Bjorn Andersson
  2018-09-20  7:38 ` Rafael J. Wysocki
  1 sibling, 1 reply; 9+ messages in thread
From: Greg Kroah-Hartman @ 2018-09-20  5:22 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Luis R. Rodriguez, Rafael J. Wysocki, linux-kernel,
	linux-arm-msm, stable, Rishabh Bhatnagar

On Wed, Sep 19, 2018 at 06:09:38PM -0700, Bjorn Andersson wrote:
> When freeing the fw_priv the item is taken off the list. This causes an
> oops in the FW_OPT_NOCACHE case as the list object is not initialized.
> 
> Make sure to initialize the list object regardless of this flag.
> 
> Fixes: 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
> Cc: stable@vger.kernel.org
> Cc: Rishabh Bhatnagar <rishabhb@codeaurora.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  drivers/base/firmware_loader/main.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Is this being triggered by some hardware somewhere today?  Or is this
just a fix found by code inspection?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] firmware: Always initialize the fw_priv list object
  2018-09-20  5:22 ` Greg Kroah-Hartman
@ 2018-09-20  7:34   ` Bjorn Andersson
  2018-10-01 13:27     ` Niklas Cassel
  0 siblings, 1 reply; 9+ messages in thread
From: Bjorn Andersson @ 2018-09-20  7:34 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Luis R. Rodriguez, Rafael J. Wysocki, linux-kernel,
	linux-arm-msm, stable, Rishabh Bhatnagar

On Wed 19 Sep 22:22 PDT 2018, Greg Kroah-Hartman wrote:

> On Wed, Sep 19, 2018 at 06:09:38PM -0700, Bjorn Andersson wrote:
> > When freeing the fw_priv the item is taken off the list. This causes an
> > oops in the FW_OPT_NOCACHE case as the list object is not initialized.
> > 
> > Make sure to initialize the list object regardless of this flag.
> > 
> > Fixes: 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
> > Cc: stable@vger.kernel.org
> > Cc: Rishabh Bhatnagar <rishabhb@codeaurora.org>
> > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > ---
> >  drivers/base/firmware_loader/main.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> Is this being triggered by some hardware somewhere today?  Or is this
> just a fix found by code inspection?
> 

Hi Greg,

Yes, I found this issue while attempting to load the firmware and boot
one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it
can be reproduced on the upstream Dragonboard 820c.

Regards,
Bjorn

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] firmware: Always initialize the fw_priv list object
  2018-09-20  1:09 [PATCH] firmware: Always initialize the fw_priv list object Bjorn Andersson
  2018-09-20  5:22 ` Greg Kroah-Hartman
@ 2018-09-20  7:38 ` Rafael J. Wysocki
  1 sibling, 0 replies; 9+ messages in thread
From: Rafael J. Wysocki @ 2018-09-20  7:38 UTC (permalink / raw)
  To: bjorn.andersson
  Cc: Luis R. Rodriguez, Greg Kroah-Hartman, Rafael J. Wysocki,
	Linux Kernel Mailing List, linux-arm-msm, Stable,
	Rishabh Bhatnagar

On Thu, Sep 20, 2018 at 3:07 AM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
>
> When freeing the fw_priv the item is taken off the list. This causes an
> oops in the FW_OPT_NOCACHE case as the list object is not initialized.
>
> Make sure to initialize the list object regardless of this flag.
>
> Fixes: 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
> Cc: stable@vger.kernel.org
> Cc: Rishabh Bhatnagar <rishabhb@codeaurora.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>  drivers/base/firmware_loader/main.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
> index b3c0498ee433..8e9213b36e31 100644
> --- a/drivers/base/firmware_loader/main.c
> +++ b/drivers/base/firmware_loader/main.c
> @@ -226,8 +226,11 @@ static int alloc_lookup_fw_priv(const char *fw_name,
>         }
>
>         tmp = __allocate_fw_priv(fw_name, fwc, dbuf, size);
> -       if (tmp && !(opt_flags & FW_OPT_NOCACHE))
> -               list_add(&tmp->list, &fwc->head);
> +       if (tmp) {
> +               INIT_LIST_HEAD(&tmp->list);
> +               if (!(opt_flags & FW_OPT_NOCACHE))
> +                       list_add(&tmp->list, &fwc->head);
> +       }
>         spin_unlock(&fwc->lock);
>
>         *fw_priv = tmp;
> --

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] firmware: Always initialize the fw_priv list object
  2018-09-20  7:34   ` Bjorn Andersson
@ 2018-10-01 13:27     ` Niklas Cassel
  2018-10-01 18:18       ` Luis Chamberlain
  0 siblings, 1 reply; 9+ messages in thread
From: Niklas Cassel @ 2018-10-01 13:27 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Greg Kroah-Hartman, Luis R. Rodriguez, Rafael J. Wysocki,
	linux-kernel, linux-arm-msm, stable, Rishabh Bhatnagar

On Thu, Sep 20, 2018 at 12:34:15AM -0700, Bjorn Andersson wrote:
> On Wed 19 Sep 22:22 PDT 2018, Greg Kroah-Hartman wrote:
> 
> > On Wed, Sep 19, 2018 at 06:09:38PM -0700, Bjorn Andersson wrote:
> > > When freeing the fw_priv the item is taken off the list. This causes an
> > > oops in the FW_OPT_NOCACHE case as the list object is not initialized.
> > > 
> > > Make sure to initialize the list object regardless of this flag.
> > > 
> > > Fixes: 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
> > > Cc: stable@vger.kernel.org
> > > Cc: Rishabh Bhatnagar <rishabhb@codeaurora.org>
> > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > > ---
> > >  drivers/base/firmware_loader/main.c | 7 +++++--
> > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > Is this being triggered by some hardware somewhere today?  Or is this
> > just a fix found by code inspection?
> > 
> 
> Hi Greg,
> 
> Yes, I found this issue while attempting to load the firmware and boot
> one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it
> can be reproduced on the upstream Dragonboard 820c.

I still see this issue on v4.19-rc6.

It would be nice if this fix gets merged before v4.19 gets released.

Kind regards,
Niklas

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] firmware: Always initialize the fw_priv list object
  2018-10-01 13:27     ` Niklas Cassel
@ 2018-10-01 18:18       ` Luis Chamberlain
  2018-10-01 18:32         ` Bjorn Andersson
  0 siblings, 1 reply; 9+ messages in thread
From: Luis Chamberlain @ 2018-10-01 18:18 UTC (permalink / raw)
  To: Niklas Cassel
  Cc: Bjorn Andersson, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-kernel, linux-arm-msm, stable, Rishabh Bhatnagar

On Mon, Oct 01, 2018 at 03:27:03PM +0200, Niklas Cassel wrote:
> On Thu, Sep 20, 2018 at 12:34:15AM -0700, Bjorn Andersson wrote:
> > On Wed 19 Sep 22:22 PDT 2018, Greg Kroah-Hartman wrote:
> > 
> > > On Wed, Sep 19, 2018 at 06:09:38PM -0700, Bjorn Andersson wrote:
> > > > When freeing the fw_priv the item is taken off the list. This causes an
> > > > oops in the FW_OPT_NOCACHE case as the list object is not initialized.
> > > > 
> > > > Make sure to initialize the list object regardless of this flag.
> > > > 
> > > > Fixes: 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
> > > > Cc: stable@vger.kernel.org
> > > > Cc: Rishabh Bhatnagar <rishabhb@codeaurora.org>
> > > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > > > ---
> > > >  drivers/base/firmware_loader/main.c | 7 +++++--
> > > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > > 
> > > Is this being triggered by some hardware somewhere today?  Or is this
> > > just a fix found by code inspection?
> > > 
> > 
> > Hi Greg,
> > 
> > Yes, I found this issue while attempting to load the firmware and boot
> > one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it
> > can be reproduced on the upstream Dragonboard 820c.
> 
> I still see this issue on v4.19-rc6.
> 
> It would be nice if this fix gets merged before v4.19 gets released.

This is the first I hear of this and this patch, so you should re-send
it and I can review it. Also please Cc Rishabh.

Rishabh, had you heard of this and can you confirm as well as
422b3db2a503 was your commit?

  Luis

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] firmware: Always initialize the fw_priv list object
  2018-10-01 18:18       ` Luis Chamberlain
@ 2018-10-01 18:32         ` Bjorn Andersson
  2018-10-01 18:53           ` Luis Chamberlain
  2018-10-01 20:58           ` Greg Kroah-Hartman
  0 siblings, 2 replies; 9+ messages in thread
From: Bjorn Andersson @ 2018-10-01 18:32 UTC (permalink / raw)
  To: Luis Chamberlain, Niklas Cassel
  Cc: Greg Kroah-Hartman, Rafael J. Wysocki, linux-kernel,
	linux-arm-msm, stable, Rishabh Bhatnagar

On Mon 01 Oct 11:18 PDT 2018, Luis Chamberlain wrote:

> On Mon, Oct 01, 2018 at 03:27:03PM +0200, Niklas Cassel wrote:
> > On Thu, Sep 20, 2018 at 12:34:15AM -0700, Bjorn Andersson wrote:
> > > On Wed 19 Sep 22:22 PDT 2018, Greg Kroah-Hartman wrote:
> > > 
> > > > On Wed, Sep 19, 2018 at 06:09:38PM -0700, Bjorn Andersson wrote:
> > > > > When freeing the fw_priv the item is taken off the list. This causes an
> > > > > oops in the FW_OPT_NOCACHE case as the list object is not initialized.
> > > > > 
> > > > > Make sure to initialize the list object regardless of this flag.
> > > > > 
> > > > > Fixes: 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
> > > > > Cc: stable@vger.kernel.org
> > > > > Cc: Rishabh Bhatnagar <rishabhb@codeaurora.org>
> > > > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > > > > ---
> > > > >  drivers/base/firmware_loader/main.c | 7 +++++--
> > > > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > > > 
> > > > Is this being triggered by some hardware somewhere today?  Or is this
> > > > just a fix found by code inspection?
> > > > 
> > > 
> > > Hi Greg,
> > > 
> > > Yes, I found this issue while attempting to load the firmware and boot
> > > one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it
> > > can be reproduced on the upstream Dragonboard 820c.
> > 
> > I still see this issue on v4.19-rc6.
> > 
> > It would be nice if this fix gets merged before v4.19 gets released.
> 
> This is the first I hear of this and this patch, so you should re-send
> it and I can review it. Also please Cc Rishabh.
> 
> Rishabh, had you heard of this and can you confirm as well as
> 422b3db2a503 was your commit?
> 

Thanks Luis,

It seems like Greg did pick the patch yesterday [1], so hopefully he
sends himself a pull request this week for inclusion in v4.19-rc7.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/log/?h=char-misc-linus

Regards,
Bjorn

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] firmware: Always initialize the fw_priv list object
  2018-10-01 18:32         ` Bjorn Andersson
@ 2018-10-01 18:53           ` Luis Chamberlain
  2018-10-01 20:58           ` Greg Kroah-Hartman
  1 sibling, 0 replies; 9+ messages in thread
From: Luis Chamberlain @ 2018-10-01 18:53 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Niklas Cassel, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-kernel, linux-arm-msm, stable, Rishabh Bhatnagar

On Mon, Oct 01, 2018 at 11:32:16AM -0700, Bjorn Andersson wrote:
> On Mon 01 Oct 11:18 PDT 2018, Luis Chamberlain wrote:
> 
> > On Mon, Oct 01, 2018 at 03:27:03PM +0200, Niklas Cassel wrote:
> > > On Thu, Sep 20, 2018 at 12:34:15AM -0700, Bjorn Andersson wrote:
> > > > On Wed 19 Sep 22:22 PDT 2018, Greg Kroah-Hartman wrote:
> > > > 
> > > > > On Wed, Sep 19, 2018 at 06:09:38PM -0700, Bjorn Andersson wrote:
> > > > > > When freeing the fw_priv the item is taken off the list. This causes an
> > > > > > oops in the FW_OPT_NOCACHE case as the list object is not initialized.
> > > > > > 
> > > > > > Make sure to initialize the list object regardless of this flag.
> > > > > > 
> > > > > > Fixes: 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
> > > > > > Cc: stable@vger.kernel.org
> > > > > > Cc: Rishabh Bhatnagar <rishabhb@codeaurora.org>
> > > > > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > > > > > ---
> > > > > >  drivers/base/firmware_loader/main.c | 7 +++++--
> > > > > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > > > > 
> > > > > Is this being triggered by some hardware somewhere today?  Or is this
> > > > > just a fix found by code inspection?
> > > > > 
> > > > 
> > > > Hi Greg,
> > > > 
> > > > Yes, I found this issue while attempting to load the firmware and boot
> > > > one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it
> > > > can be reproduced on the upstream Dragonboard 820c.
> > > 
> > > I still see this issue on v4.19-rc6.
> > > 
> > > It would be nice if this fix gets merged before v4.19 gets released.
> > 
> > This is the first I hear of this and this patch, so you should re-send
> > it and I can review it. Also please Cc Rishabh.
> > 
> > Rishabh, had you heard of this and can you confirm as well as
> > 422b3db2a503 was your commit?
> > 
> 
> Thanks Luis,
> 
> It seems like Greg did pick the patch yesterday [1], so hopefully he
> sends himself a pull request this week for inclusion in v4.19-rc7.
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/log/?h=char-misc-linus

The patch looks good. Next time please send patches to the maintainer as
well.

  Luis

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] firmware: Always initialize the fw_priv list object
  2018-10-01 18:32         ` Bjorn Andersson
  2018-10-01 18:53           ` Luis Chamberlain
@ 2018-10-01 20:58           ` Greg Kroah-Hartman
  1 sibling, 0 replies; 9+ messages in thread
From: Greg Kroah-Hartman @ 2018-10-01 20:58 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Luis Chamberlain, Niklas Cassel, Rafael J. Wysocki, linux-kernel,
	linux-arm-msm, stable, Rishabh Bhatnagar

On Mon, Oct 01, 2018 at 11:32:16AM -0700, Bjorn Andersson wrote:
> On Mon 01 Oct 11:18 PDT 2018, Luis Chamberlain wrote:
> 
> > On Mon, Oct 01, 2018 at 03:27:03PM +0200, Niklas Cassel wrote:
> > > On Thu, Sep 20, 2018 at 12:34:15AM -0700, Bjorn Andersson wrote:
> > > > On Wed 19 Sep 22:22 PDT 2018, Greg Kroah-Hartman wrote:
> > > > 
> > > > > On Wed, Sep 19, 2018 at 06:09:38PM -0700, Bjorn Andersson wrote:
> > > > > > When freeing the fw_priv the item is taken off the list. This causes an
> > > > > > oops in the FW_OPT_NOCACHE case as the list object is not initialized.
> > > > > > 
> > > > > > Make sure to initialize the list object regardless of this flag.
> > > > > > 
> > > > > > Fixes: 422b3db2a503 ("firmware: Fix security issue with request_firmware_into_buf()")
> > > > > > Cc: stable@vger.kernel.org
> > > > > > Cc: Rishabh Bhatnagar <rishabhb@codeaurora.org>
> > > > > > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> > > > > > ---
> > > > > >  drivers/base/firmware_loader/main.c | 7 +++++--
> > > > > >  1 file changed, 5 insertions(+), 2 deletions(-)
> > > > > 
> > > > > Is this being triggered by some hardware somewhere today?  Or is this
> > > > > just a fix found by code inspection?
> > > > > 
> > > > 
> > > > Hi Greg,
> > > > 
> > > > Yes, I found this issue while attempting to load the firmware and boot
> > > > one of the DSPs on one of my Qualcomm dev boards after v4.19-rc4 and it
> > > > can be reproduced on the upstream Dragonboard 820c.
> > > 
> > > I still see this issue on v4.19-rc6.
> > > 
> > > It would be nice if this fix gets merged before v4.19 gets released.
> > 
> > This is the first I hear of this and this patch, so you should re-send
> > it and I can review it. Also please Cc Rishabh.
> > 
> > Rishabh, had you heard of this and can you confirm as well as
> > 422b3db2a503 was your commit?
> > 
> 
> Thanks Luis,
> 
> It seems like Greg did pick the patch yesterday [1], so hopefully he
> sends himself a pull request this week for inclusion in v4.19-rc7.

That was going to be my plan :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-10-02  1:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-20  1:09 [PATCH] firmware: Always initialize the fw_priv list object Bjorn Andersson
2018-09-20  5:22 ` Greg Kroah-Hartman
2018-09-20  7:34   ` Bjorn Andersson
2018-10-01 13:27     ` Niklas Cassel
2018-10-01 18:18       ` Luis Chamberlain
2018-10-01 18:32         ` Bjorn Andersson
2018-10-01 18:53           ` Luis Chamberlain
2018-10-01 20:58           ` Greg Kroah-Hartman
2018-09-20  7:38 ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).