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] [thread-next>] [day] [month] [year] [list]
Message-ID: <2791498.1bf6TGcxHc@wuerfel>
Date:   Tue, 13 Sep 2016 17:07:56 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     Deepa Dinamani <deepa.kernel@...il.com>
Cc:     Dmitry Torokhov <dmitry.torokhov@...il.com>,
        linux-input@...r.kernel.org, linux-kernel@...r.kernel.org,
        y2038@...ts.linaro.org
Subject: Re: [PATCH 1/4] uinput: Add ioctl for using monotonic/ boot times

On Tuesday, September 13, 2016 7:10:02 AM CEST Deepa Dinamani wrote:
> --- a/drivers/input/misc/uinput.c
> +++ b/drivers/input/misc/uinput.c
> @@ -46,11 +46,28 @@ static int uinput_dev_event(struct input_dev *dev,
>                             unsigned int type, unsigned int code, int value)
>  {
>         struct uinput_device    *udev = input_get_drvdata(dev);
> +       struct timespec64       ts;
> +       ktime_t kt;
>  
>         udev->buff[udev->head].type = type;
>         udev->buff[udev->head].code = code;
>         udev->buff[udev->head].value = value;
> -       do_gettimeofday(&udev->buff[udev->head].time);
> +
> +       kt = ktime_get();
> +       switch (udev->clk_type) {
> +       case CLOCK_REALTIME:
> +               ts = ktime_to_timespec64(ktime_mono_to_real(kt));
> +               break;
> +       case CLOCK_MONOTONIC:
> +               ts = ktime_to_timespec64(kt);
> +               break;
> +       case CLOCK_BOOTTIME:
> +               ts = ktime_to_timespec64(ktime_mono_to_any(kt, TK_OFFS_BOOT));
> +               break;
> +       }
> +
> +       udev->buff[udev->head].time.tv_sec = ts.tv_sec;
> +       udev->buff[udev->head].time.tv_usec = ts.tv_nsec / NSEC_PER_USEC;
> 

This is a bit inefficient. I think it's better to use
ktime_get_real_ts64(), ktime_get_ts64() and get_monotonic_boottime64().

I see that we do the same thing in evdev_events(), so maybe that isn't
overly critical though. Or we might want to change both.

The last one of these also uses the slow ktime_to_timespec64(), but
that is something we can improve later in the common code.

	Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ