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]
Date:   Thu, 25 Jul 2019 08:27:28 +0300
From:   Dmitry Torokhov <dmitry.torokhov@...il.com>
To:     Atif Niyaz <atifniyaz@...gle.com>
Cc:     Atif Niyaz <atifniyaz11@...il.com>,
        Siarhei Vishniakou <svv@...gle.com>,
        linux-input@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] input: API for Setting a Timestamp from a Driver

Hi Atif,

On Thu, Jul 18, 2019 at 12:41:33PM -0700, Atif Niyaz wrote:
> @@ -150,16 +143,19 @@ static void __evdev_flush_queue(struct evdev_client *client, unsigned int type)
>  static void __evdev_queue_syn_dropped(struct evdev_client *client)
>  {
>  	struct input_event ev;
> -	ktime_t time;
>  	struct timespec64 ts;
> +	ktime_t *time = input_get_timestamp(client->evdev->handle.dev);
>  
> -	time = client->clk_type == EV_CLK_REAL ?
> -			ktime_get_real() :
> -			client->clk_type == EV_CLK_MONO ?
> -				ktime_get() :
> -				ktime_get_boottime();
> +	switch (client->clk_type) {
> +	case INPUT_CLK_REAL:
> +	case INPUT_CLK_MONO:
> +		ts = ktime_to_timespec64(time[client->clk_type]);
> +		break;
> +	default:
> +		ts = ktime_to_timespec64(time[INPUT_CLK_BOOT]);
> +		break;

Since we trust client->clk_type be valid in evdev_event() we can also
trust it here. I replaced the switch statement with:

	ts = ktime_to_timespec64(ev_time[client->clkk_type]);

> +	}
>  
> -	ts = ktime_to_timespec64(time);
>  	ev.input_event_sec = ts.tv_sec;
>  	ev.input_event_usec = ts.tv_nsec / NSEC_PER_USEC;
>  	ev.type = EV_SYN;
> @@ -185,21 +181,21 @@ static void evdev_queue_syn_dropped(struct evdev_client *client)
>  	spin_unlock_irqrestore(&client->buffer_lock, flags);
>  }
>  
> -static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
> +static int evdev_set_clk_type(struct evdev_client *client, clockid_t clkid)

The data passed to evdev_set_clk_type() is an integer with values that
coincide with the enum's values, so I kept the type of parameter as it
was.

> +/**
> + * input_set_timestamp - set timestamp for input events
> + * @dev: input device to set timestamp for
> + * @timestamp: the time at which the event has occurred
> + *   in CLOCK_MONOTONIC
> + *
> + * This function is intended to provide to the input system a more
> + * accurate time of when an event actually occurred. The driver should
> + * call this function as soon as a timestamp is acquired ensuring
> + * clock conversions in input_set_timestamp are done correctly.
> + *
> + * The system entering a suspend between timestamp acquisition and
> + * calling input_set_timestamp can result in inaccurate conversions.
> + *
> + */
> +static inline void input_set_timestamp(struct input_dev *dev,
> +	ktime_t timestamp)
> +{
> +	dev->timestamp[INPUT_CLK_MONO] = timestamp;
> +	dev->timestamp[INPUT_CLK_REAL] = ktime_mono_to_real(timestamp);
> +	dev->timestamp[INPUT_CLK_BOOT] = ktime_mono_to_any(
> +		timestamp, TK_OFFS_BOOT);
> +}

I moved this input input.c, together with input_get_timestamp().

Applied, thank you.

-- 
Dmitry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ