[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f84a9da7-bb0f-7538-fa00-968c9625335b@suse.cz>
Date: Wed, 20 May 2020 10:59:15 +0200
From: Jiri Slaby <jslaby@...e.cz>
To: Raghavendra Rao Ananta <rananta@...eaurora.org>,
gregkh@...uxfoundation.org, andrew@...nix.com
Cc: linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH v2] tty: hvc: Fix data abort due to race in hvc_open
On 20. 05. 20, 8:47, Raghavendra Rao Ananta wrote:
> Potentially, hvc_open() can be called in parallel when two tasks calls
> open() on /dev/hvcX. In such a scenario, if the hp->ops->notifier_add()
> callback in the function fails, where it sets the tty->driver_data to
> NULL, the parallel hvc_open() can see this NULL and cause a memory abort.
> Hence, do a NULL check at the beginning, before proceeding ahead.
>
> The issue can be easily reproduced by launching two tasks simultaneously
> that does an open() call on /dev/hvcX.
> For example:
> $ cat /dev/hvc0 & cat /dev/hvc0 &
>
> Cc: stable@...r.kernel.org
> Signed-off-by: Raghavendra Rao Ananta <rananta@...eaurora.org>
> ---
> drivers/tty/hvc/hvc_console.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
> index 436cc51c92c3..80709f754cc8 100644
> --- a/drivers/tty/hvc/hvc_console.c
> +++ b/drivers/tty/hvc/hvc_console.c
> @@ -350,6 +350,9 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
> unsigned long flags;
> int rc = 0;
>
> + if (!hp)
> + return -ENODEV;
> +
This is still not fixing the bug properly. See:
https://lore.kernel.org/linuxppc-dev/0f7791f5-0a53-59f6-7277-247a789f30c2@suse.cz/
In particular, the paragraph starting "IOW".
thanks,
--
js
suse labs
Powered by blists - more mailing lists