From f855d50bc829217ffabbf9919a3b8e8f426bbc7d Mon Sep 17 00:00:00 2001 From: kib Date: Thu, 29 Jun 2017 14:40:33 +0000 Subject: [PATCH] Do not cast struct kevent_args or struct freebsd11_kevent_args to struct g_kevent_args. On some architectures, e.g. PowerPC, there is additional padding in uap. Reported and tested by: andreast Sponsored by: The FreeBSD Foundation --- sys/kern/kern_event.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index da2026d8fec8..7700e34f0372 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -935,8 +935,16 @@ sys_kevent(struct thread *td, struct kevent_args *uap) .k_copyin = kevent_copyin, .kevent_size = sizeof(struct kevent), }; + struct g_kevent_args gk_args = { + .fd = uap->fd, + .changelist = uap->changelist, + .nchanges = uap->nchanges, + .eventlist = uap->eventlist, + .nevents = uap->nevents, + .timeout = uap->timeout, + }; - return (kern_kevent_generic(td, (struct g_kevent_args *)uap, &k_ops)); + return (kern_kevent_generic(td, &gk_args, &k_ops)); } static int @@ -1107,8 +1115,16 @@ freebsd11_kevent(struct thread *td, struct freebsd11_kevent_args *uap) .k_copyin = kevent11_copyin, .kevent_size = sizeof(struct kevent_freebsd11), }; + struct g_kevent_args gk_args = { + .fd = uap->fd, + .changelist = uap->changelist, + .nchanges = uap->nchanges, + .eventlist = uap->eventlist, + .nevents = uap->nevents, + .timeout = uap->timeout, + }; - return (kern_kevent_generic(td, (struct g_kevent_args *)uap, &k_ops)); + return (kern_kevent_generic(td, &gk_args, &k_ops)); } #endif