Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Jun 2017 14:40:33 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r320471 - head/sys/kern
Message-ID:  <201706291440.v5TEeX2q042496@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Jun 29 14:40:33 2017
New Revision: 320471
URL: https://svnweb.freebsd.org/changeset/base/320471

Log:
  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

Modified:
  head/sys/kern/kern_event.c

Modified: head/sys/kern/kern_event.c
==============================================================================
--- head/sys/kern/kern_event.c	Thu Jun 29 14:00:05 2017	(r320470)
+++ head/sys/kern/kern_event.c	Thu Jun 29 14:40:33 2017	(r320471)
@@ -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_k
 		.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
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706291440.v5TEeX2q042496>