All of lore.kernel.org
 help / color / mirror / Atom feed
From: Todd Kjos <tkjos@android.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Russell King <linux@armlinux.org.uk>,
	Antonios Motakis <a.motakis@virtualopensystems.com>,
	Adrian Salido <salidoa@google.com>,
	Sasha Levin <sasha.levin@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH 2/4] ARM: amba: Fix race condition with driver_override
Date: Fri, 2 Mar 2018 10:23:10 -0800	[thread overview]
Message-ID: <CAD0t5oMGrJu_9D_8wvLoQPPs-fJ7Qot4W-P_qYE7ikJQGKRSOA@mail.gmail.com> (raw)
In-Reply-To: <1516375450-30575-3-git-send-email-geert+renesas@glider.be>

+stable

what is the status of this patch? We'd like to get it into the android
common branches to fix possible double free.

On Fri, Jan 19, 2018 at 7:24 AM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> The driver_override implementation is susceptible to a race condition
> when different threads are reading vs storing a different driver
> override.  Add locking to avoid this race condition.
>
> Cfr. commits 6265539776a0810b ("driver core: platform: fix race
> condition with driver_override") and 9561475db680f714 ("PCI: Fix race
> condition with driver_override").
>
> Fixes: 3cf385713460eb2b ("ARM: 8256/1: driver coamba: add device binding path 'driver_override'")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/amba/bus.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
> index 6ffd778352e6d953..36c5653ced5742b7 100644
> --- a/drivers/amba/bus.c
> +++ b/drivers/amba/bus.c
> @@ -69,8 +69,12 @@ static ssize_t driver_override_show(struct device *_dev,
>                                     struct device_attribute *attr, char *buf)
>  {
>         struct amba_device *dev = to_amba_device(_dev);
> +       ssize_t len;
>
> -       return sprintf(buf, "%s\n", dev->driver_override);
> +       device_lock(_dev);
> +       len = sprintf(buf, "%s\n", dev->driver_override);
> +       device_unlock(_dev);
> +       return len;
>  }
>
>  static ssize_t driver_override_store(struct device *_dev,
> @@ -78,7 +82,7 @@ static ssize_t driver_override_store(struct device *_dev,
>                                      const char *buf, size_t count)
>  {
>         struct amba_device *dev = to_amba_device(_dev);
> -       char *driver_override, *old = dev->driver_override, *cp;
> +       char *driver_override, *old, *cp;
>
>         if (count > PATH_MAX)
>                 return -EINVAL;
> @@ -91,12 +95,15 @@ static ssize_t driver_override_store(struct device *_dev,
>         if (cp)
>                 *cp = '\0';
>
> +       device_lock(_dev);
> +       old = dev->driver_override;
>         if (strlen(driver_override)) {
>                 dev->driver_override = driver_override;
>         } else {
>                kfree(driver_override);
>                dev->driver_override = NULL;
>         }
> +       device_unlock(_dev);
>
>         kfree(old);
>
> --
> 2.7.4
>

  reply	other threads:[~2018-03-02 18:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19 15:24 [PATCH 0/4] ARM: amba: driver_override improvements Geert Uytterhoeven
2018-01-19 15:24 ` [PATCH 1/4] ARM: amba: Make driver_override output consistent with other buses Geert Uytterhoeven
2018-01-19 15:24 ` [PATCH 2/4] ARM: amba: Fix race condition with driver_override Geert Uytterhoeven
2018-03-02 18:23   ` Todd Kjos [this message]
2018-03-05  8:08     ` Geert Uytterhoeven
2018-01-19 15:24 ` [PATCH 3/4] ARM: amba: Don't read past the end of sysfs "driver_override" buffer Geert Uytterhoeven
2018-01-19 15:24 ` [PATCH 4/4] ARM: amba: Fix wrong indentation in driver_override_store() Geert Uytterhoeven

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=CAD0t5oMGrJu_9D_8wvLoQPPs-fJ7Qot4W-P_qYE7ikJQGKRSOA@mail.gmail.com \
    --to=tkjos@android.com \
    --cc=a.motakis@virtualopensystems.com \
    --cc=geert+renesas@glider.be \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=salidoa@google.com \
    --cc=sasha.levin@oracle.com \
    --cc=stable@vger.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 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.