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  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAGXu5jKaOuh_TXQV3gA4pbzORUjNNMh1-4MvzkLcp3AQDvhwjA@mail.gmail.com>
Date:   Tue, 12 Feb 2019 12:16:33 -0800
From:   Kees Cook <keescook@...omium.org>
To:     Yue Hu <huyue2@...ong.com>
Cc:     Anton Vorontsov <anton@...msg.org>,
        Colin Cross <ccross@...roid.com>,
        Tony Luck <tony.luck@...el.com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] pstore/ram: Avoid possible failure of dummy device unregister

On Mon, Jan 21, 2019 at 11:19 PM Yue Hu <huyue2@...ong.com> wrote:
>
> From 7c1f672a2d7b7c2cfef313060bd429afc4af995b Mon Sep 17 00:00:00 2001
> From: Yue Hu <huyue2@...ong.com>
> Date: Tue, 22 Jan 2019 14:47:00 +0800
> Subject: [PATCH] pstore/ram: Avoid possible failure of dummy device unregister
>
> In ramoops_register_dummy() if create platform device of dummy
> failed, the problem is following code called:
>
>     dummy = NULL;
>     ramoops_unregister_dummy();
>
> However platform_device_unregister() will check the pointer:
>
>     void platform_device_del(struct platform_device *pdev)
>     {
>             int i;
>
>             if (pdev) {
>                     ...
>             }
>     }
>     void platform_device_put(struct platform_device *pdev)
>     {
>             if (pdev)
>                     put_device(&pdev->dev);
>     }
>     void platform_device_unregister(struct platform_device *pdev)
>     {
>             platform_device_del(pdev);
>             platform_device_put(pdev);
>     }
>
> So the dummy device maybe always exists in the system, this is bad
> case, we need to avoid it.
>
> Signed-off-by: Yue Hu <huyue2@...ong.com>
> ---
>  fs/pstore/ram.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
> index 8db1f7f..1d56a20 100644
> --- a/fs/pstore/ram.c
> +++ b/fs/pstore/ram.c
> @@ -932,7 +932,6 @@ static void __init ramoops_register_dummy(void)
>         if (IS_ERR(dummy)) {
>                 pr_info("could not create platform device: %ld\n",
>                         PTR_ERR(dummy));
> -               dummy = NULL;
>                 ramoops_unregister_dummy();

No, this needs to be cleared to NULL to avoid leaving a ERR_PTR (which
are non-NULL, see IS_ERR() above it), so that it can be safe to
unconditionally call platform_device_unregister().

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ