From: Arnd Bergmann <arnd@arndb.de> To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Dmitry Torokhov <dmitry.torokhov@gmail.com>, Deepa Dinamani <deepa.kernel@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de>, sparclinux@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, stable@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>, Lubomir Rintel <lkundrak@v3.sk>, Thomas Gleixner <tglx@linutronix.de>, linux-input@vger.kernel.org Subject: [PATCH v2 01/24] Input: input_event: fix struct padding on sparc64 Date: Fri, 13 Dec 2019 21:49:10 +0100 [thread overview] Message-ID: <20191213204936.3643476-2-arnd@arndb.de> (raw) In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> 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. Cc: sparclinux@vger.kernel.org Cc: "David S. Miller" <davem@davemloft.net> Fixes: 141e5dcaa735 ("Input: input_event - fix the CONFIG_SPARC64 mixup") Fixes: 2e746942ebac ("Input: input_event - provide override for sparc64") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/input/evdev.c | 14 +++++++------- drivers/input/misc/uinput.c | 14 +++++++++----- include/uapi/linux/input.h | 1 + 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index d7dd6fcf2db0..f918fca9ada3 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -224,13 +224,13 @@ static void __pass_event(struct evdev_client *client, */ client->tail = (client->head - 2) & (client->bufsize - 1); - client->buffer[client->tail].input_event_sec = - event->input_event_sec; - client->buffer[client->tail].input_event_usec = - event->input_event_usec; - client->buffer[client->tail].type = EV_SYN; - client->buffer[client->tail].code = SYN_DROPPED; - client->buffer[client->tail].value = 0; + client->buffer[client->tail] = (struct input_event) { + .input_event_sec = event->input_event_sec, + .input_event_usec = event->input_event_usec, + .type = EV_SYN, + .code = SYN_DROPPED, + .value = 0, + }; client->packet_head = client->tail; } diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index fd253781be71..2dabbe47d43e 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -74,12 +74,16 @@ static int uinput_dev_event(struct input_dev *dev, struct uinput_device *udev = input_get_drvdata(dev); struct timespec64 ts; - udev->buff[udev->head].type = type; - udev->buff[udev->head].code = code; - udev->buff[udev->head].value = value; ktime_get_ts64(&ts); - udev->buff[udev->head].input_event_sec = ts.tv_sec; - udev->buff[udev->head].input_event_usec = ts.tv_nsec / NSEC_PER_USEC; + + udev->buff[udev->head] = (struct input_event) { + .input_event_sec = ts.tv_sec, + .input_event_usec = ts.tv_nsec / NSEC_PER_USEC, + .type = type, + .code = code, + .value = value, + }; + udev->head = (udev->head + 1) % UINPUT_BUFFER_SIZE; wake_up_interruptible(&udev->waitq); diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index f056b2a00d5c..9a61c28ed3ae 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h @@ -34,6 +34,7 @@ struct input_event { __kernel_ulong_t __sec; #if defined(__sparc__) && defined(__arch64__) unsigned int __usec; + unsigned int __pad; #else __kernel_ulong_t __usec; #endif -- 2.20.0
WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@arndb.de> To: y2038@lists.linaro.org, linux-kernel@vger.kernel.org, Dmitry Torokhov <dmitry.torokhov@gmail.com>, Deepa Dinamani <deepa.kernel@gmail.com> Cc: Arnd Bergmann <arnd@arndb.de>, sparclinux@vger.kernel.org, "David S. Miller" <davem@davemloft.net>, stable@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>, Lubomir Rintel <lkundrak@v3.sk>, Thomas Gleixner <tglx@linutronix.de>, linux-input@vger.kernel.org Subject: [PATCH v2 01/24] Input: input_event: fix struct padding on sparc64 Date: Fri, 13 Dec 2019 20:49:10 +0000 [thread overview] Message-ID: <20191213204936.3643476-2-arnd@arndb.de> (raw) In-Reply-To: <20191213204936.3643476-1-arnd@arndb.de> 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. Cc: sparclinux@vger.kernel.org Cc: "David S. Miller" <davem@davemloft.net> Fixes: 141e5dcaa735 ("Input: input_event - fix the CONFIG_SPARC64 mixup") Fixes: 2e746942ebac ("Input: input_event - provide override for sparc64") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/input/evdev.c | 14 +++++++------- drivers/input/misc/uinput.c | 14 +++++++++----- include/uapi/linux/input.h | 1 + 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index d7dd6fcf2db0..f918fca9ada3 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -224,13 +224,13 @@ static void __pass_event(struct evdev_client *client, */ client->tail = (client->head - 2) & (client->bufsize - 1); - client->buffer[client->tail].input_event_sec - event->input_event_sec; - client->buffer[client->tail].input_event_usec - event->input_event_usec; - client->buffer[client->tail].type = EV_SYN; - client->buffer[client->tail].code = SYN_DROPPED; - client->buffer[client->tail].value = 0; + client->buffer[client->tail] = (struct input_event) { + .input_event_sec = event->input_event_sec, + .input_event_usec = event->input_event_usec, + .type = EV_SYN, + .code = SYN_DROPPED, + .value = 0, + }; client->packet_head = client->tail; } diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index fd253781be71..2dabbe47d43e 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -74,12 +74,16 @@ static int uinput_dev_event(struct input_dev *dev, struct uinput_device *udev = input_get_drvdata(dev); struct timespec64 ts; - udev->buff[udev->head].type = type; - udev->buff[udev->head].code = code; - udev->buff[udev->head].value = value; ktime_get_ts64(&ts); - udev->buff[udev->head].input_event_sec = ts.tv_sec; - udev->buff[udev->head].input_event_usec = ts.tv_nsec / NSEC_PER_USEC; + + udev->buff[udev->head] = (struct input_event) { + .input_event_sec = ts.tv_sec, + .input_event_usec = ts.tv_nsec / NSEC_PER_USEC, + .type = type, + .code = code, + .value = value, + }; + udev->head = (udev->head + 1) % UINPUT_BUFFER_SIZE; wake_up_interruptible(&udev->waitq); diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h index f056b2a00d5c..9a61c28ed3ae 100644 --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h @@ -34,6 +34,7 @@ struct input_event { __kernel_ulong_t __sec; #if defined(__sparc__) && defined(__arch64__) unsigned int __usec; + unsigned int __pad; #else __kernel_ulong_t __usec; #endif -- 2.20.0
next prev parent reply other threads:[~2019-12-13 20:51 UTC|newest] Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-13 20:49 [PATCH v2 00/24] drivers, fs: y2038 updates Arnd Bergmann 2019-12-13 20:49 ` [Cluster-devel] " Arnd Bergmann 2019-12-13 20:49 ` Arnd Bergmann 2019-12-13 20:49 ` Arnd Bergmann 2019-12-13 20:49 ` Arnd Bergmann 2019-12-13 20:49 ` Arnd Bergmann 2019-12-13 20:49 ` Arnd Bergmann [this message] 2019-12-13 20:49 ` [PATCH v2 01/24] Input: input_event: fix struct padding on sparc64 Arnd Bergmann 2019-12-13 22:08 ` Dmitry Torokhov 2019-12-13 22:08 ` Dmitry Torokhov 2019-12-13 20:49 ` [PATCH v2 02/24] fat: use prandom_u32() for i_generation Arnd Bergmann 2019-12-13 20:49 ` [PATCH v2 03/24] dlm: use SO_SNDTIMEO_NEW instead of SO_SNDTIMEO_OLD Arnd Bergmann 2019-12-13 20:49 ` [Cluster-devel] " Arnd Bergmann 2019-12-13 20:52 ` [PATCH v2 04/24] xtensa: ISS: avoid struct timeval Arnd Bergmann 2019-12-13 20:52 ` [PATCH v2 05/24] um: ubd: use 64-bit time_t where possible Arnd Bergmann 2019-12-13 20:52 ` Arnd Bergmann 2019-12-13 20:52 ` [PATCH v2 06/24] acct: stop using get_seconds() Arnd Bergmann 2019-12-13 20:52 ` [PATCH v2 07/24] tsacct: add 64-bit btime field Arnd Bergmann 2019-12-13 20:52 ` [PATCH v2 08/24] packet: clarify timestamp overflow Arnd Bergmann 2019-12-13 20:52 ` [PATCH v2 09/24] quota: avoid time_t in v1_disk_dqblk definition Arnd Bergmann 2019-12-16 13:14 ` Jan Kara 2019-12-13 20:53 ` [PATCH v2 10/24] hostfs: pass 64-bit timestamps to/from user space Arnd Bergmann 2019-12-13 20:53 ` Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 11/24] hfs/hfsplus: use 64-bit inode timestamps Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 12/24] drm/msm: avoid using 'timespec' Arnd Bergmann 2019-12-13 20:53 ` Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 13/24] drm/etnaviv: reject timeouts with tv_nsec >= NSEC_PER_SEC Arnd Bergmann 2019-12-13 20:53 ` Arnd Bergmann 2020-01-08 1:16 ` [Y2038] " Ben Hutchings 2020-01-08 1:16 ` Ben Hutchings 2020-01-17 15:47 ` Guido Günther 2020-01-17 15:47 ` Guido Günther 2020-01-20 17:47 ` Lucas Stach 2020-01-20 17:47 ` Lucas Stach 2020-01-20 18:47 ` Arnd Bergmann 2020-01-20 18:47 ` Arnd Bergmann 2020-01-21 10:21 ` Lucas Stach 2020-01-21 10:21 ` Lucas Stach 2020-01-21 11:46 ` Arnd Bergmann 2020-01-21 11:46 ` Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 14/24] drm/etnaviv: avoid deprecated timespec Arnd Bergmann 2019-12-13 20:53 ` Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 15/24] sunrpc: convert to time64_t for expiry Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 16/24] nfs: use time64_t internally Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 17/24] nfs: fix timstamp debug prints Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 18/24] nfs: fscache: use timespec64 in inode auxdata Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 19/24] xfs: rename compat_time_t to old_time32_t Arnd Bergmann 2019-12-13 21:18 ` Darrick J. Wong 2019-12-16 16:31 ` Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 20/24] xfs: disallow broken ioctls without compat-32-bit-time Arnd Bergmann 2019-12-13 21:05 ` Darrick J. Wong 2019-12-16 16:45 ` Arnd Bergmann 2019-12-16 16:52 ` Darrick J. Wong 2019-12-17 15:06 ` Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 21/24] xfs: quota: move to time64_t interfaces Arnd Bergmann 2019-12-13 21:17 ` Darrick J. Wong 2019-12-16 16:52 ` Arnd Bergmann 2019-12-17 15:02 ` Arnd Bergmann 2019-12-17 22:15 ` Darrick J. Wong 2019-12-18 16:44 ` Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 22/24] y2038: remove obsolete jiffies conversion functions Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 23/24] y2038: rename itimerval to __kernel_old_itimerval Arnd Bergmann 2019-12-13 20:53 ` [PATCH v2 24/24] y2038: sparc: remove use of struct timex Arnd Bergmann 2019-12-13 20:53 ` Arnd Bergmann 2019-12-14 1:37 ` Julian Calaby 2019-12-14 1:37 ` Julian Calaby 2019-12-14 14:44 ` [Y2038] " Arnd Bergmann 2019-12-14 14:44 ` Arnd Bergmann
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191213204936.3643476-2-arnd@arndb.de \ --to=arnd@arndb.de \ --cc=bhelgaas@google.com \ --cc=davem@davemloft.net \ --cc=deepa.kernel@gmail.com \ --cc=dmitry.torokhov@gmail.com \ --cc=linux-input@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=lkundrak@v3.sk \ --cc=sparclinux@vger.kernel.org \ --cc=stable@vger.kernel.org \ --cc=tglx@linutronix.de \ --cc=y2038@lists.linaro.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.