Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2018 12:44:38 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r342190 - in head/sys: compat/freebsd32 kern sys
Message-ID:  <201812181244.wBICicbo099769@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Tue Dec 18 12:44:38 2018
New Revision: 342190
URL: https://svnweb.freebsd.org/changeset/base/342190

Log:
  const poison the `new` pointer of __sysctl.
  
  Reviewed by:	kib
  Obtained from:	CheriBSD
  Sponsored by:	DARPA, AFRL
  Differential Revision:	https://reviews.freebsd.org/D18444

Modified:
  head/sys/compat/freebsd32/syscalls.master
  head/sys/kern/kern_sysctl.c
  head/sys/kern/syscalls.master
  head/sys/sys/sysctl.h

Modified: head/sys/compat/freebsd32/syscalls.master
==============================================================================
--- head/sys/compat/freebsd32/syscalls.master	Tue Dec 18 09:16:04 2018	(r342189)
+++ head/sys/compat/freebsd32/syscalls.master	Tue Dec 18 12:44:38 2018	(r342190)
@@ -388,7 +388,7 @@
 				    uint32_t length1, uint32_t length2); }
 202	AUE_SYSCTL	STD	{ int freebsd32___sysctl(int *name, \
 				    u_int namelen, void *old, \
-				    uint32_t *oldlenp, void *new, \
+				    uint32_t *oldlenp, const void *new, \
 				    uint32_t newlen); }
 203	AUE_MLOCK	NOPROTO	{ int mlock(const void *addr, \
 				    size_t len); }

Modified: head/sys/kern/kern_sysctl.c
==============================================================================
--- head/sys/kern/kern_sysctl.c	Tue Dec 18 09:16:04 2018	(r342189)
+++ head/sys/kern/kern_sysctl.c	Tue Dec 18 12:44:38 2018	(r342190)
@@ -1772,7 +1772,7 @@ sysctl_new_kernel(struct sysctl_req *req, void *p, siz
 		return (0);
 	if (req->newlen - req->newidx < l)
 		return (EINVAL);
-	bcopy((char *)req->newptr + req->newidx, p, l);
+	bcopy((const char *)req->newptr + req->newidx, p, l);
 	req->newidx += l;
 	return (0);
 }
@@ -1898,7 +1898,7 @@ sysctl_new_user(struct sysctl_req *req, void *p, size_
 		return (EINVAL);
 	WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
 	    "sysctl_new_user()");
-	error = copyin((char *)req->newptr + req->newidx, p, l);
+	error = copyin((const char *)req->newptr + req->newidx, p, l);
 	req->newidx += l;
 	return (error);
 }
@@ -2126,8 +2126,8 @@ sys___sysctl(struct thread *td, struct sysctl_args *ua
  */
 int
 userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
-    size_t *oldlenp, int inkernel, void *new, size_t newlen, size_t *retval,
-    int flags)
+    size_t *oldlenp, int inkernel, const void *new, size_t newlen,
+    size_t *retval, int flags)
 {
 	int error = 0, memlocked;
 	struct sysctl_req req;

Modified: head/sys/kern/syscalls.master
==============================================================================
--- head/sys/kern/syscalls.master	Tue Dec 18 09:16:04 2018	(r342189)
+++ head/sys/kern/syscalls.master	Tue Dec 18 12:44:38 2018	(r342190)
@@ -1209,7 +1209,7 @@
 		    u_int namelen,
 		    _Out_writes_bytes_opt_(*oldlenp) void *old,
 		    _Inout_opt_ size_t *oldlenp,
-		    _In_reads_bytes_opt_(newlen) void *new,
+		    _In_reads_bytes_opt_(newlen) const void *new,
 		    size_t newlen
 		);
 	} __sysctl sysctl_args int

Modified: head/sys/sys/sysctl.h
==============================================================================
--- head/sys/sys/sysctl.h	Tue Dec 18 09:16:04 2018	(r342189)
+++ head/sys/sys/sysctl.h	Tue Dec 18 12:44:38 2018	(r342190)
@@ -165,7 +165,7 @@ struct sysctl_req {
 	size_t		 oldlen;
 	size_t		 oldidx;
 	int		(*oldfunc)(struct sysctl_req *, const void *, size_t);
-	void		*newptr;
+	const void		*newptr;
 	size_t		 newlen;
 	size_t		 newidx;
 	int		(*newfunc)(struct sysctl_req *, void *, size_t);
@@ -1083,7 +1083,7 @@ int	kernel_sysctlbyname(struct thread *td, char *name,
 	    size_t *oldlenp, void *new, size_t newlen, size_t *retval,
 	    int flags);
 int	userland_sysctl(struct thread *td, int *name, u_int namelen, void *old,
-	    size_t *oldlenp, int inkernel, void *new, size_t newlen,
+	    size_t *oldlenp, int inkernel, const void *new, size_t newlen,
 	    size_t *retval, int flags);
 int	sysctl_find_oid(int *name, u_int namelen, struct sysctl_oid **noid,
 	    int *nindx, struct sysctl_req *req);



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