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>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACT4Y+a0=RxugZyD_HZN7nOjxOY2zkKugHfUfnDBkVv3k_WdKQ@mail.gmail.com>
Date:   Tue, 7 Aug 2018 16:26:54 +0200
From:   Dmitry Vyukov <dvyukov@...gle.com>
To:     Dmitry Torokhov <dmitry.torokhov@...il.com>
Cc:     linux-input@...r.kernel.org, Henrik Rydberg <rydberg@...math.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] Input: do not use WARN() in input_alloc_absinfo()

On Tue, Aug 7, 2018 at 12:18 AM, Dmitry Torokhov
<dmitry.torokhov@...il.com> wrote:
> Some of fuzzers set panic_on_warn=1 so that they can handle WARN()ings
> the same way they handle full-blown kernel crashes. We used WARN() in
> input_alloc_absinfo() to get a better idea where memory allocation
> failed, but since then kmalloc() and friends started dumping call stack
> on memory allocation failures anyway, so we are not getting anything
> extra from WARN().
>
> Because of the above, let's replace WARN with dev_err(). We use dev_err()
> instead of simply removing message and relying on kcalloc() to give us
> stack dump so that we'd know the instance of hardware device to which we
> were trying to attach input device.
>
> Reported-by: Dmitry Vyukov <dvyukov@...gle.com>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@...il.com>
> ---
>  drivers/input/input.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/input/input.c b/drivers/input/input.c
> index 90453e2ab6cf..260f00ebe34d 100644
> --- a/drivers/input/input.c
> +++ b/drivers/input/input.c
> @@ -481,11 +481,19 @@ EXPORT_SYMBOL(input_inject_event);
>   */
>  void input_alloc_absinfo(struct input_dev *dev)
>  {
> -       if (!dev->absinfo)
> -               dev->absinfo = kcalloc(ABS_CNT, sizeof(*dev->absinfo),
> -                                       GFP_KERNEL);
> +       if (dev->absinfo)
> +               return;
>
> -       WARN(!dev->absinfo, "%s(): kcalloc() failed?\n", __func__);
> +       dev->absinfo = kcalloc(ABS_CNT, sizeof(*dev->absinfo), GFP_KERNEL);
> +       if (!dev->absinfo) {
> +               dev_err(dev->dev.parent ?: &dev->dev,
> +                       "%s: unable to allocate memory\n", __func__);
> +               /*
> +                * We will handle this allocation failure in
> +                * input_register_device() when we refuse to register input
> +                * device with ABS bits but without absinfo.
> +                */
> +       }
>  }
>  EXPORT_SYMBOL(input_alloc_absinfo);

Thanks!

Acked-by: Dmitry Vyukov <dvyukov@...gle.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ