Skip to content

Commit f729a1b

Browse files
arndbdtor
authored andcommitted
Input: input_event - fix struct padding on sparc64
Going through all uses of timeval, I noticed that we screwed up input_event in the previous attempts to fix it: The time fields now match between kernel and user space, but all following fields are in the wrong place. Add the required padding that is implied by the glibc timeval definition to fix the layout, and use a struct initializer to avoid leaking kernel stack data. Fixes: 141e5dc ("Input: input_event - fix the CONFIG_SPARC64 mixup") Fixes: 2e74694 ("Input: input_event - provide override for sparc64") Signed-off-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent add2180 commit f729a1b

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

drivers/input/evdev.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,13 @@ static void __pass_event(struct evdev_client *client,
224224
*/
225225
client->tail = (client->head - 2) & (client->bufsize - 1);
226226

227-
client->buffer[client->tail].input_event_sec =
228-
event->input_event_sec;
229-
client->buffer[client->tail].input_event_usec =
230-
event->input_event_usec;
231-
client->buffer[client->tail].type = EV_SYN;
232-
client->buffer[client->tail].code = SYN_DROPPED;
233-
client->buffer[client->tail].value = 0;
227+
client->buffer[client->tail] = (struct input_event) {
228+
.input_event_sec = event->input_event_sec,
229+
.input_event_usec = event->input_event_usec,
230+
.type = EV_SYN,
231+
.code = SYN_DROPPED,
232+
.value = 0,
233+
};
234234

235235
client->packet_head = client->tail;
236236
}

drivers/input/misc/uinput.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,16 @@ static int uinput_dev_event(struct input_dev *dev,
7474
struct uinput_device *udev = input_get_drvdata(dev);
7575
struct timespec64 ts;
7676

77-
udev->buff[udev->head].type = type;
78-
udev->buff[udev->head].code = code;
79-
udev->buff[udev->head].value = value;
8077
ktime_get_ts64(&ts);
81-
udev->buff[udev->head].input_event_sec = ts.tv_sec;
82-
udev->buff[udev->head].input_event_usec = ts.tv_nsec / NSEC_PER_USEC;
78+
79+
udev->buff[udev->head] = (struct input_event) {
80+
.input_event_sec = ts.tv_sec,
81+
.input_event_usec = ts.tv_nsec / NSEC_PER_USEC,
82+
.type = type,
83+
.code = code,
84+
.value = value,
85+
};
86+
8387
udev->head = (udev->head + 1) % UINPUT_BUFFER_SIZE;
8488

8589
wake_up_interruptible(&udev->waitq);

include/uapi/linux/input.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct input_event {
3434
__kernel_ulong_t __sec;
3535
#if defined(__sparc__) && defined(__arch64__)
3636
unsigned int __usec;
37+
unsigned int __pad;
3738
#else
3839
__kernel_ulong_t __usec;
3940
#endif

0 commit comments

Comments
 (0)