CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Sun Sep 10 00:49:40 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Fix a typo, and some wording improvements. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/devname.3 diff -u src/lib/libc/gen/devname.3:1.14 src/lib/libc/gen/devname.3:1.15 --- src/lib/libc/gen/devname.3:1.14 Sat Sep 9 18:45:04 2017 +++ src/lib/libc/gen/devname.3 Sun Sep 10 00:49:40 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: devname.3,v 1.14 2017/09/09 18:45:04 kamil Exp $ +.\" $NetBSD: devname.3,v 1.15 2017/09/10 00:49:40 kre Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -48,8 +48,8 @@ .Sh DESCRIPTION The .Fn devname -function returns a pointer to the static buffer with the name of the block or character -device in +function returns a pointer to the static buffer with the name of the +block or character device in .Dq Pa /dev with a device number of .Fa dev , @@ -63,7 +63,7 @@ is returned. .Pp The .Fn devname_r -function is a reentrand and thread-safe version of +function is a reentrant and thread-safe version of .Fn devname . This function returns the device name by copying it into the .Fa path @@ -88,10 +88,15 @@ will return .Pp If successful, .Fn devname_r -places a nul-terminated string containing the name of the device and returns 0. -If error occurs +places a nul-terminated string containing the name of the device in +the buffer pointed to by +.Ar path +and returns 0. +If an error occurs .Fn devname_r -will return error number indicating what went wrong. +will return an error number from +.In sys/errno.h +indicating what went wrong. .Sh ERRORS The .Fn devname_r
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kre Date: Sun Sep 10 00:49:40 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Fix a typo, and some wording improvements. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/iostat
Module Name:src Committed By: mrg Date: Sat Sep 9 23:51:58 UTC 2017 Modified Files: src/usr.sbin/iostat: iostat.c Log Message: two minor fixes for -x and -y mode: - the header is only 1 line not 2, account for this when calculating when to display the next header. - when ndrives > 1, don't display the header every time, but only when the previous one disappears. now i don't feel the need to run "iostat -x wd0 1 & iostat -c wd1 1" to get less repeated header output on my display. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/iostat/iostat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/iostat
Module Name:src Committed By: mrg Date: Sat Sep 9 23:51:58 UTC 2017 Modified Files: src/usr.sbin/iostat: iostat.c Log Message: two minor fixes for -x and -y mode: - the header is only 1 line not 2, account for this when calculating when to display the next header. - when ndrives > 1, don't display the header every time, but only when the previous one disappears. now i don't feel the need to run "iostat -x wd0 1 & iostat -c wd1 1" to get less repeated header output on my display. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/iostat/iostat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/iostat/iostat.c diff -u src/usr.sbin/iostat/iostat.c:1.65 src/usr.sbin/iostat/iostat.c:1.66 --- src/usr.sbin/iostat/iostat.c:1.65 Tue Jul 4 21:19:33 2017 +++ src/usr.sbin/iostat/iostat.c Sat Sep 9 23:51:58 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: iostat.c,v 1.65 2017/07/04 21:19:33 mlelstv Exp $ */ +/* $NetBSD: iostat.c,v 1.66 2017/09/09 23:51:58 mrg Exp $ */ /* * Copyright (c) 1996 John M. Vinopal @@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1986, 19 #if 0 static char sccsid[] = "@(#)iostat.c 8.3 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: iostat.c,v 1.65 2017/07/04 21:19:33 mlelstv Exp $"); +__RCSID("$NetBSD: iostat.c,v 1.66 2017/09/09 23:51:58 mrg Exp $"); #endif #endif /* not lint */ @@ -129,7 +129,7 @@ static int selectdrives(int, char *[]); int main(int argc, char *argv[]) { - int ch, hdrcnt, ndrives, lines; + int ch, hdrcnt, hdroffset, ndrives, lines; struct timespec tv; struct ttysize ts; @@ -210,10 +210,13 @@ main(int argc, char *argv[]) if (todo == 0) errx(1, "no drives"); } - if (ISSET(todo, SHOW_STATS_X | SHOW_STATS_Y)) + if (ISSET(todo, SHOW_STATS_X | SHOW_STATS_Y)) { lines = ndrives; - else + hdroffset = 3; + } else { lines = 1; + hdroffset = 4; + } tv.tv_sec = interval; tv.tv_nsec = 0; @@ -222,10 +225,10 @@ main(int argc, char *argv[]) (void)signal(SIGCONT, sig_header); for (hdrcnt = 1;;) { - if (do_header || lines > 1 || (hdrcnt -= lines) <= 0) { + if (do_header || (hdrcnt -= lines) <= 0) { do_header = 0; header(); - hdrcnt = winlines - 4; + hdrcnt = winlines - hdroffset; } if (!ISSET(todo, SHOW_TOTALS)) {
CVS commit: src/lib/libpthread
Module Name:src Committed By: kamil Date: Sat Sep 9 23:21:45 UTC 2017 Modified Files: src/lib/libpthread: pthread_types.h Log Message: Support on C89 compilers Clang 5.0.0(svn) reports warnings on for C99 constructs when used with strict -std=c89. Restrict designated initializers usage to C99 or newer code. C89 and C++ will share the same code without extension of designated initializers. PR 52285 To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libpthread/pthread_types.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpthread/pthread_types.h diff -u src/lib/libpthread/pthread_types.h:1.22 src/lib/libpthread/pthread_types.h:1.23 --- src/lib/libpthread/pthread_types.h:1.22 Wed Jul 20 21:02:04 2016 +++ src/lib/libpthread/pthread_types.h Sat Sep 9 23:21:45 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_types.h,v 1.22 2016/07/20 21:02:04 christos Exp $ */ +/* $NetBSD: pthread_types.h,v 1.23 2017/09/09 23:21:45 kamil Exp $ */ /*- * Copyright (c) 2001, 2008 The NetBSD Foundation, Inc. @@ -114,10 +114,10 @@ struct __pthread_mutex_st { __pthread_spin_t ptm_errorcheck; #ifdef __CPU_SIMPLE_LOCK_PAD uint8_t ptm_pad1[3]; -#ifdef __cplusplus -#define _PTHREAD_MUTEX_PAD(a) { 0, 0, 0 }, -#else +#if (__STDC_VERSION__ - 0) >= 199901L #define _PTHREAD_MUTEX_PAD(a) .a = { 0, 0, 0 }, +#else +#define _PTHREAD_MUTEX_PAD(a) { 0, 0, 0 }, #endif #else #define _PTHREAD_MUTEX_PAD(a) @@ -138,12 +138,12 @@ struct __pthread_mutex_st { #define _PT_MUTEX_MAGIC 0x0003 #define _PT_MUTEX_DEAD 0xDEAD0003 -#ifdef __cplusplus -#define _PTHREAD_MUTEX_INI(a, b) b -#define _PTHREAD_MUTEX_UNI(a) { 0 } -#else +#if (__STDC_VERSION__ - 0) >= 199901L #define _PTHREAD_MUTEX_INI(a, b) .a = b #define _PTHREAD_MUTEX_UNI(a) .a = 0 +#else +#define _PTHREAD_MUTEX_INI(a, b) b +#define _PTHREAD_MUTEX_UNI(a) { 0 } #endif #define _PTHREAD_MUTEX_INITIALIZER { \
CVS commit: src/lib/libpthread
Module Name:src Committed By: kamil Date: Sat Sep 9 23:21:45 UTC 2017 Modified Files: src/lib/libpthread: pthread_types.h Log Message: Support on C89 compilers Clang 5.0.0(svn) reports warnings on for C99 constructs when used with strict -std=c89. Restrict designated initializers usage to C99 or newer code. C89 and C++ will share the same code without extension of designated initializers. PR 52285 To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/lib/libpthread/pthread_types.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: sevan Date: Sat Sep 9 21:34:07 UTC 2017 Modified Files: src/doc: CHANGES Log Message: Note veriexecgen change To generate a diff of this commit: cvs rdiff -u -r1.2311 -r1.2312 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2311 src/doc/CHANGES:1.2312 --- src/doc/CHANGES:1.2311 Fri Sep 8 14:01:46 2017 +++ src/doc/CHANGES Sat Sep 9 21:34:07 2017 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2311 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2312 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -55,3 +55,4 @@ Changes from NetBSD 8.0 to NetBSD 9.0: bypass adapters. [msaitoh 20170830] file(1): Upgraded to 5.32. [christos 20170908] tcpdump(8): Import 4.9.2. [christos 20170908] + veriexecgen(8): drop support for MD5, SHA1, RMD160. [sevan 20170909]
CVS commit: src/doc
Module Name:src Committed By: sevan Date: Sat Sep 9 21:34:07 UTC 2017 Modified Files: src/doc: CHANGES Log Message: Note veriexecgen change To generate a diff of this commit: cvs rdiff -u -r1.2311 -r1.2312 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/veriexecgen
Module Name:src Committed By: sevan Date: Sat Sep 9 21:27:23 UTC 2017 Modified Files: src/usr.sbin/veriexecgen: veriexecgen.8 veriexecgen.c Log Message: Remove the ability to generate a signature database with the hash algorithms MD5, SHA1 & RMD160 which are either broken or on their way to being broken. Discussed on tech-security http://mail-index.netbsd.org/tech-security/2017/08/21/msg000936.html ok riastradh To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/veriexecgen/veriexecgen.8 \ src/usr.sbin/veriexecgen/veriexecgen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/veriexecgen
Module Name:src Committed By: sevan Date: Sat Sep 9 21:27:23 UTC 2017 Modified Files: src/usr.sbin/veriexecgen: veriexecgen.8 veriexecgen.c Log Message: Remove the ability to generate a signature database with the hash algorithms MD5, SHA1 & RMD160 which are either broken or on their way to being broken. Discussed on tech-security http://mail-index.netbsd.org/tech-security/2017/08/21/msg000936.html ok riastradh To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/veriexecgen/veriexecgen.8 \ src/usr.sbin/veriexecgen/veriexecgen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/veriexecgen/veriexecgen.8 diff -u src/usr.sbin/veriexecgen/veriexecgen.8:1.17 src/usr.sbin/veriexecgen/veriexecgen.8:1.18 --- src/usr.sbin/veriexecgen/veriexecgen.8:1.17 Thu Apr 28 11:24:28 2011 +++ src/usr.sbin/veriexecgen/veriexecgen.8 Sat Sep 9 21:27:23 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: veriexecgen.8,v 1.17 2011/04/28 11:24:28 wiz Exp $ +.\" $NetBSD: veriexecgen.8,v 1.18 2017/09/09 21:27:23 sevan Exp $ .\" .\" Copyright (c) 2006 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 18, 2008 +.Dd September 9, 2017 .Dt VERIEXECGEN 8 .Os .Sh NAME @@ -102,13 +102,9 @@ Use .Ar algorithm for the fingerprints. Must be one of -.Dq md5 , -.Dq sha1 , .Dq sha256 , .Dq sha384 , .Dq sha512 , -or -.Dq rmd160 . .It Fl v Verbose mode. Print messages describing what operations are being done. @@ -147,11 +143,11 @@ appending to the default fingerprint dat .Pp Fingerprint files in .Pa /path/to/somewhere using -.Dq rmd160 +.Dq sha512 as the hashing algorithm, saving to .Pa /etc/somewhere.fp : .Bd -literal -offset indent -# veriexecgen -d /path/to/somewhere -t rmd160 -o /etc/somewhere.fp +# veriexecgen -d /path/to/somewhere -t sha512 -o /etc/somewhere.fp .Ed .Sh SEE ALSO .Xr veriexec 4 , Index: src/usr.sbin/veriexecgen/veriexecgen.c diff -u src/usr.sbin/veriexecgen/veriexecgen.c:1.17 src/usr.sbin/veriexecgen/veriexecgen.c:1.18 --- src/usr.sbin/veriexecgen/veriexecgen.c:1.17 Fri Aug 21 04:09:41 2009 +++ src/usr.sbin/veriexecgen/veriexecgen.c Sat Sep 9 21:27:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: veriexecgen.c,v 1.17 2009/08/21 04:09:41 elad Exp $ */ +/* $NetBSD: veriexecgen.c,v 1.18 2017/09/09 21:27:23 sevan Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #ifndef lint #ifdef __RCSID -__RCSID("$NetBSD: veriexecgen.c,v 1.17 2009/08/21 04:09:41 elad Exp $"); +__RCSID("$NetBSD: veriexecgen.c,v 1.18 2017/09/09 21:27:23 sevan Exp $"); #endif #endif /* not lint */ @@ -57,10 +57,7 @@ __RCSID("$NetBSD: veriexecgen.c,v 1.17 2 #include #include -#include -#include #include -#include #define IS_EXEC(mode) ((mode) & (S_IXUSR | S_IXGRP | S_IXOTH)) @@ -100,12 +97,9 @@ TAILQ_HEAD(, fentry) fehead; /* define the possible hash algorithms */ static hash_t hashes[] = { - { "MD5", MD5File }, - { "SHA1", SHA1File }, { "SHA256", SHA256_File }, { "SHA384", SHA384_File }, { "SHA512", SHA512_File }, - { "RMD160", RMD160File }, { NULL, NULL }, };
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kamil Date: Sat Sep 9 18:45:04 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Remove the BUGS section from devname(3) devname(3) does not report type of error on purpose. Suggested by To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/devname.3 diff -u src/lib/libc/gen/devname.3:1.13 src/lib/libc/gen/devname.3:1.14 --- src/lib/libc/gen/devname.3:1.13 Sat Sep 9 18:00:39 2017 +++ src/lib/libc/gen/devname.3 Sat Sep 9 18:45:04 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: devname.3,v 1.13 2017/09/09 18:00:39 kamil Exp $ +.\" $NetBSD: devname.3,v 1.14 2017/09/09 18:45:04 kamil Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -94,10 +94,8 @@ If error occurs will return error number indicating what went wrong. .Sh ERRORS The -.Fn devname -and .Fn devname_r -functions my fail if: +function my fail if: .Bl -tag -width Er .It Bq Er ENOENT the corresponding device does not exist @@ -122,7 +120,3 @@ The .Fn devname_r function first appeared in .Nx 6.0 . -.Sh BUGS -The -.Fn devname -function does not set errno on failure.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kamil Date: Sat Sep 9 18:45:04 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Remove the BUGS section from devname(3) devname(3) does not report type of error on purpose. Suggested by To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/lib/libc/gen
Date:Sat, 9 Sep 2017 18:00:40 + From:"Kamil Rytarowski"Message-ID: <20170909180040.222c2f...@cvs.netbsd.org> | Not that devname(3) does not set errno on failure and document it as a bug. Not everything in libc is expected to set errno on failure - in fact most functions don't (though they may alter it) and shouldn't. errno is (mostly) intended for sys calls - the values defined for it are chosen with that (mostly) in mind - there are a few other functions that have no other reasonable way to indicate errors, and so also use errno, but those are decidedly in the minority. devname() is in neither set, having it return errors through errno would be a mistake. kre
CVS commit: src
Module Name:src Committed By: kamil Date: Sat Sep 9 18:18:28 UTC 2017 Modified Files: src/distrib/sets/lists/comp: mi src/lib/libc/gen: Makefile.inc Log Message: Install new man-page devname_r(3). This is a link to devname(3). To generate a diff of this commit: cvs rdiff -u -r1.2145 -r1.2146 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.199 -r1.200 src/lib/libc/gen/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2145 src/distrib/sets/lists/comp/mi:1.2146 --- src/distrib/sets/lists/comp/mi:1.2145 Sat Aug 12 08:21:30 2017 +++ src/distrib/sets/lists/comp/mi Sat Sep 9 18:18:27 2017 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2145 2017/08/12 08:21:30 maxv Exp $ +# $NetBSD: mi,v 1.2146 2017/09/09 18:18:27 kamil Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -5977,6 +5977,7 @@ ./usr/share/man/cat3/des_string_to_key.0 comp-c-catman .cat ./usr/share/man/cat3/des_xcbc_encrypt.0 comp-c-catman .cat ./usr/share/man/cat3/devname.0 comp-c-catman .cat +./usr/share/man/cat3/devname_r.0 comp-c-catman .cat ./usr/share/man/cat3/dgettext.0 comp-c-catman .cat ./usr/share/man/cat3/dh.0 comp-obsolete obsolete ./usr/share/man/cat3/difftime.0 comp-c-catman .cat @@ -13565,6 +13566,7 @@ ./usr/share/man/html3/des_string_to_key.html comp-c-htmlman html ./usr/share/man/html3/des_xcbc_encrypt.html comp-c-htmlman html ./usr/share/man/html3/devname.html comp-c-htmlman html +./usr/share/man/html3/devname_r.html comp-c-htmlman html ./usr/share/man/html3/dgettext.html comp-c-htmlman html ./usr/share/man/html3/difftime.html comp-c-htmlman html ./usr/share/man/html3/dir.html comp-c-htmlman html @@ -21060,6 +21062,7 @@ ./usr/share/man/man3/des_string_to_key.3 comp-c-man .man ./usr/share/man/man3/des_xcbc_encrypt.3 comp-c-man .man ./usr/share/man/man3/devname.3 comp-c-man .man +./usr/share/man/man3/devname_r.3 comp-c-man .man ./usr/share/man/man3/dgettext.3 comp-c-man .man ./usr/share/man/man3/dh.3 comp-obsolete obsolete ./usr/share/man/man3/difftime.3 comp-c-man .man Index: src/lib/libc/gen/Makefile.inc diff -u src/lib/libc/gen/Makefile.inc:1.199 src/lib/libc/gen/Makefile.inc:1.200 --- src/lib/libc/gen/Makefile.inc:1.199 Tue May 9 11:14:16 2017 +++ src/lib/libc/gen/Makefile.inc Sat Sep 9 18:18:28 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.199 2017/05/09 11:14:16 kre Exp $ +# $NetBSD: Makefile.inc,v 1.200 2017/09/09 18:18:28 kamil Exp $ # from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 # gen sources @@ -90,6 +90,7 @@ MLINKS+=bswap.3 bswap16.3 bswap.3 bswap3 MLINKS+=cpuset.3 cpuset_create.3 cpuset.3 cpuset_destroy.3 \ cpuset.3 cpuset_zero.3 cpuset.3 cpuset_set.3 cpuset.3 cpuset_clr.3 \ cpuset.3 cpuset_isset.3 cpuset.3 cpuset_size.3 +MLINKS+=devname.3 devname_r.3 MLINKS+=directory.3 closedir.3 directory.3 dirfd.3 directory.3 opendir.3 \ directory.3 readdir.3 directory.3 readdir_r.3 directory.3 \ rewinddir.3 directory.3 seekdir.3 directory.3 telldir.3 \
CVS commit: src
Module Name:src Committed By: kamil Date: Sat Sep 9 18:18:28 UTC 2017 Modified Files: src/distrib/sets/lists/comp: mi src/lib/libc/gen: Makefile.inc Log Message: Install new man-page devname_r(3). This is a link to devname(3). To generate a diff of this commit: cvs rdiff -u -r1.2145 -r1.2146 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.199 -r1.200 src/lib/libc/gen/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kamil Date: Sat Sep 9 18:00:40 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Document devname_r(3) in devname(3). Improve clarity of devname(3) mentioning that it returns a pointer to the buffer pointer. This approach is not thread-safe and not reentrant. Not that devname(3) does not set errno on failure and document it as a bug. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/devname.3 diff -u src/lib/libc/gen/devname.3:1.12 src/lib/libc/gen/devname.3:1.13 --- src/lib/libc/gen/devname.3:1.12 Sun Jun 3 21:42:46 2012 +++ src/lib/libc/gen/devname.3 Sat Sep 9 18:00:39 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: devname.3,v 1.12 2012/06/03 21:42:46 joerg Exp $ +.\" $NetBSD: devname.3,v 1.13 2017/09/09 18:00:39 kamil Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,11 +29,12 @@ .\" .\" @(#)devname.3 8.2 (Berkeley) 4/29/95 .\" -.Dd June 3, 2012 +.Dd September 9, 2017 .Dt DEVNAME 3 .Os .Sh NAME -.Nm devname +.Nm devname , +.Nm devname_r .Nd get device name .Sh LIBRARY .Lb libc @@ -42,10 +43,12 @@ .In sys/stat.h .Ft char * .Fn devname "dev_t dev" "mode_t type" +.Ft int +.Fn devname_r "dev_t dev" "mode_t type" "char *path" "size_t len" .Sh DESCRIPTION The .Fn devname -function returns a pointer to the name of the block or character +function returns a pointer to the static buffer with the name of the block or character device in .Dq Pa /dev with a device number of @@ -58,9 +61,49 @@ available, .Dv NULL is returned. .Pp +The +.Fn devname_r +function is a reentrand and thread-safe version of +.Fn devname . +This function returns the device name by copying it into the +.Fa path +argument with up to +.Fa len +characters. +The +.Fa path +argument is always nul-terminated. +.Pp The traditional display for applications when no device is found is the string .Dq ?? . +.Sh RETURN VALUES +If successful, +.Fn devname +returns a pointer to a nul-terminated string containing the name of the device. +If an error occurs +.Fa devname +will return +.Dv NULL . +.Pp +If successful, +.Fn devname_r +places a nul-terminated string containing the name of the device and returns 0. +If error occurs +.Fn devname_r +will return error number indicating what went wrong. +.Sh ERRORS +The +.Fn devname +and +.Fn devname_r +functions my fail if: +.Bl -tag -width Er +.It Bq Er ENOENT +the corresponding device does not exist +.It Bq Er ERANGE +the passed buffer length is too short +.El .Sh FILES .Bl -tag -width /var/run/dev.cdb -compact .It Pa /var/run/dev.cdb @@ -74,3 +117,12 @@ The .Nm devname function call appeared in .Bx 4.4 . +.Pp +The +.Fn devname_r +function first appeared in +.Nx 6.0 . +.Sh BUGS +The +.Fn devname +function does not set errno on failure.
CVS commit: src/lib/libc/gen
Module Name:src Committed By: kamil Date: Sat Sep 9 18:00:40 UTC 2017 Modified Files: src/lib/libc/gen: devname.3 Log Message: Document devname_r(3) in devname(3). Improve clarity of devname(3) mentioning that it returns a pointer to the buffer pointer. This approach is not thread-safe and not reentrant. Not that devname(3) does not set errno on failure and document it as a bug. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libc/gen/devname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 17:38:24 UTC 2017 Modified Files: src/doc [netbsd-8]: CHANGES-8.0 Log Message: 258, 270 To generate a diff of this commit: cvs rdiff -u -r1.1.2.56 -r1.1.2.57 src/doc/CHANGES-8.0 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 17:38:24 UTC 2017 Modified Files: src/doc [netbsd-8]: CHANGES-8.0 Log Message: 258, 270 To generate a diff of this commit: cvs rdiff -u -r1.1.2.56 -r1.1.2.57 src/doc/CHANGES-8.0 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-8.0 diff -u src/doc/CHANGES-8.0:1.1.2.56 src/doc/CHANGES-8.0:1.1.2.57 --- src/doc/CHANGES-8.0:1.1.2.56 Mon Sep 4 20:47:59 2017 +++ src/doc/CHANGES-8.0 Sat Sep 9 17:38:24 2017 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-8.0,v 1.1.2.56 2017/09/04 20:47:59 snj Exp $ +# $NetBSD: CHANGES-8.0,v 1.1.2.57 2017/09/09 17:38:24 snj Exp $ A complete list of changes from the initial NetBSD 8.0 branch on 2017-06-04 until the 8.0 release: @@ -5787,3 +5787,22 @@ sys/compat/linux/arch/amd64/linux_machde reduce the diff with SMAP. [maxv, ticket #257] +sys/compat/linux32/arch/amd64/linux32_machdep.c 1.39 + + Fix a ring0 escalation vulnerability in compat_linux32 where the + index of %cs is controlled by userland, making it easy to trigger + the page fault and get kernel privileges. + [maxv, ticket #270] + +sys/arch/amd64/conf/ALL1.68 +sys/arch/i386/conf/ALL1.428 +sys/arch/i386/i386/i386_trap.S 1.12 +sys/arch/i386/i386/locore.S 1.149-1.150 +sys/arch/x86/x86/sys_machdep.c 1.38 + + i386: + - use a proper stack for multiboot + - use %ss instead of %ds in trap06 + - reject call gates in the LDT, and remove LDT_DEBUG + [maxv, ticket #258] +
CVS commit: [netbsd-8] src/sys/arch
Module Name:src Committed By: snj Date: Sat Sep 9 17:29:41 UTC 2017 Modified Files: src/sys/arch/amd64/conf [netbsd-8]: ALL src/sys/arch/i386/conf [netbsd-8]: ALL src/sys/arch/i386/i386 [netbsd-8]: i386_trap.S locore.S src/sys/arch/x86/x86 [netbsd-8]: sys_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #258): sys/arch/amd64/conf/ALL: 1.68 sys/arch/i386/conf/ALL: 1.428 sys/arch/i386/i386/i386_trap.S: 1.12 sys/arch/i386/i386/locore.S: 1.149-1.150 sys/arch/x86/x86/sys_machdep.c: 1.38 Remove undocumented hack. -- Switch to the temporary stack right away when booted via multiboot. GRUB happens to give a correct stack, but it is not guaranteed by the spec. This temporary stack will be reset later, which is fine. Fixes PR/50245. -- Pfff, use %ss and not %ds. The latter is controlled by userland, the former contains the kernel value (flat); FreeBSD fixed this too a few weeks ago. As I said earlier, this dtrace code is complete bullshit. -- Don't allow userland to create 286/386 call gates anymore - they are not used by Wine. While here, don't allow it to overwrite the static entries either, don't allow unknown entry types, remove LDT_DEBUG, and style. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.59.2.1 src/sys/arch/amd64/conf/ALL cvs rdiff -u -r1.419.2.1 -r1.419.2.2 src/sys/arch/i386/conf/ALL cvs rdiff -u -r1.6.6.1 -r1.6.6.2 src/sys/arch/i386/i386/i386_trap.S cvs rdiff -u -r1.145.6.1 -r1.145.6.2 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.35.6.1 -r1.35.6.2 src/sys/arch/x86/x86/sys_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/arch
Module Name:src Committed By: snj Date: Sat Sep 9 17:29:41 UTC 2017 Modified Files: src/sys/arch/amd64/conf [netbsd-8]: ALL src/sys/arch/i386/conf [netbsd-8]: ALL src/sys/arch/i386/i386 [netbsd-8]: i386_trap.S locore.S src/sys/arch/x86/x86 [netbsd-8]: sys_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #258): sys/arch/amd64/conf/ALL: 1.68 sys/arch/i386/conf/ALL: 1.428 sys/arch/i386/i386/i386_trap.S: 1.12 sys/arch/i386/i386/locore.S: 1.149-1.150 sys/arch/x86/x86/sys_machdep.c: 1.38 Remove undocumented hack. -- Switch to the temporary stack right away when booted via multiboot. GRUB happens to give a correct stack, but it is not guaranteed by the spec. This temporary stack will be reset later, which is fine. Fixes PR/50245. -- Pfff, use %ss and not %ds. The latter is controlled by userland, the former contains the kernel value (flat); FreeBSD fixed this too a few weeks ago. As I said earlier, this dtrace code is complete bullshit. -- Don't allow userland to create 286/386 call gates anymore - they are not used by Wine. While here, don't allow it to overwrite the static entries either, don't allow unknown entry types, remove LDT_DEBUG, and style. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.59.2.1 src/sys/arch/amd64/conf/ALL cvs rdiff -u -r1.419.2.1 -r1.419.2.2 src/sys/arch/i386/conf/ALL cvs rdiff -u -r1.6.6.1 -r1.6.6.2 src/sys/arch/i386/i386/i386_trap.S cvs rdiff -u -r1.145.6.1 -r1.145.6.2 src/sys/arch/i386/i386/locore.S cvs rdiff -u -r1.35.6.1 -r1.35.6.2 src/sys/arch/x86/x86/sys_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/conf/ALL diff -u src/sys/arch/amd64/conf/ALL:1.59 src/sys/arch/amd64/conf/ALL:1.59.2.1 --- src/sys/arch/amd64/conf/ALL:1.59 Sat May 27 22:53:29 2017 +++ src/sys/arch/amd64/conf/ALL Sat Sep 9 17:29:40 2017 @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.59 2017/05/27 22:53:29 bouyer Exp $ +# $NetBSD: ALL,v 1.59.2.1 2017/09/09 17:29:40 snj Exp $ # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # # ALL machine description file @@ -17,7 +17,7 @@ include "arch/amd64/conf/std.amd64" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "ALL-$Revision: 1.59 $" +#ident "ALL-$Revision: 1.59.2.1 $" maxusers 64 # estimated number of users @@ -2076,7 +2076,6 @@ options KSYMS_DEBUG options KUE_DEBUG options LANA_DEBUG options LCD_DEBUG -options LDT_DEBUG options LEDEBUG options LE_DEBUG options LIFDEBUG Index: src/sys/arch/i386/conf/ALL diff -u src/sys/arch/i386/conf/ALL:1.419.2.1 src/sys/arch/i386/conf/ALL:1.419.2.2 --- src/sys/arch/i386/conf/ALL:1.419.2.1 Thu Aug 31 08:41:33 2017 +++ src/sys/arch/i386/conf/ALL Sat Sep 9 17:29:40 2017 @@ -1,4 +1,4 @@ -# $NetBSD: ALL,v 1.419.2.1 2017/08/31 08:41:33 bouyer Exp $ +# $NetBSD: ALL,v 1.419.2.2 2017/09/09 17:29:40 snj Exp $ # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp # # ALL machine description file @@ -17,7 +17,7 @@ include "arch/i386/conf/std.i386" options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "ALL-$Revision: 1.419.2.1 $" +#ident "ALL-$Revision: 1.419.2.2 $" maxusers 64 # estimated number of users @@ -2230,7 +2230,6 @@ options KSYMS_DEBUG options KUE_DEBUG options LANA_DEBUG options LCD_DEBUG -options LDT_DEBUG options LEDEBUG options LE_DEBUG options LIFDEBUG Index: src/sys/arch/i386/i386/i386_trap.S diff -u src/sys/arch/i386/i386/i386_trap.S:1.6.6.1 src/sys/arch/i386/i386/i386_trap.S:1.6.6.2 --- src/sys/arch/i386/i386/i386_trap.S:1.6.6.1 Tue Aug 1 23:18:30 2017 +++ src/sys/arch/i386/i386/i386_trap.S Sat Sep 9 17:29:40 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: i386_trap.S,v 1.6.6.1 2017/08/01 23:18:30 snj Exp $ */ +/* $NetBSD: i386_trap.S,v 1.6.6.2 2017/09/09 17:29:40 snj Exp $ */ /* * Copyright 2002 (c) Wasabi Systems, Inc. @@ -66,7 +66,7 @@ #if 0 #include -__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.6.6.1 2017/08/01 23:18:30 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: i386_trap.S,v 1.6.6.2 2017/09/09 17:29:40 snj Exp $"); #endif /* @@ -139,7 +139,7 @@ IDTVEC_END(trap05) SUPERALIGN_TEXT IDTVEC(trap06) /* Check if there is no DTrace hook registered. */ - cmpl $0,dtrace_invop_jump_addr + cmpl $0,%ss:dtrace_invop_jump_addr je norm_ill /* Check if this is a user fault. */ Index: src/sys/arch/i386/i386/locore.S diff -u src/sys/arch/i386/i386/locore.S:1.145.6.1 src/sys/arch/i386/i386/locore.S:1.145.6.2 --- src/sys/arch/i386/i386/locore.S:1.145.6.1 Wed Jul 5 19:59:29 2017 +++ src/sys/arch/i386/i386/locore.S Sat Sep 9 17:29:40 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.145.6.1 2017/07/05 19:59:29 snj Exp $ */ +/* $NetBSD: locore.S,v 1.145.6.2 2017/09/09 17:29:40 snj Exp $ */ /* * Copyright-o-rama! @@ -128,7 +128,7 @@ */ #include -__KERNEL_RCSID(0,
CVS commit: [netbsd-8] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 17:01:23 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-8]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #270): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.38.6.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-8] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 17:01:23 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-8]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #270): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.38.6.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux32/arch/amd64/linux32_machdep.c diff -u src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.38 src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.38.6.1 --- src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.38 Sun Feb 5 08:52:11 2017 +++ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Sat Sep 9 17:01:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_machdep.c,v 1.38 2017/02/05 08:52:11 maxv Exp $ */ +/* $NetBSD: linux32_machdep.c,v 1.38.6.1 2017/09/09 17:01:23 snj Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.38 2017/02/05 08:52:11 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.38.6.1 2017/09/09 17:01:23 snj Exp $"); #include #include @@ -417,8 +417,9 @@ linux32_restore_sigcontext(struct lwp *l /* * Check for security violations. */ - if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 || - !USERMODE(scp->sc_cs, scp->sc_eflags)) + if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0) + return EINVAL; + if (!VALID_USER_CSEL32(scp->sc_cs)) return EINVAL; if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) &&
CVS commit: [netbsd-7-0] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:58:10 UTC 2017 Modified Files: src/doc [netbsd-7-0]: CHANGES-7.0.3 Log Message: 1507 To generate a diff of this commit: cvs rdiff -u -r1.1.2.62 -r1.1.2.63 src/doc/CHANGES-7.0.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-7.0.3 diff -u src/doc/CHANGES-7.0.3:1.1.2.62 src/doc/CHANGES-7.0.3:1.1.2.63 --- src/doc/CHANGES-7.0.3:1.1.2.62 Mon Sep 4 16:07:50 2017 +++ src/doc/CHANGES-7.0.3 Sat Sep 9 16:58:10 2017 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-7.0.3,v 1.1.2.62 2017/09/04 16:07:50 snj Exp $ +# $NetBSD: CHANGES-7.0.3,v 1.1.2.63 2017/09/09 16:58:10 snj Exp $ A complete list of changes from the NetBSD 7.0.2 release to the NetBSD 7.0.3 release: @@ -4941,3 +4941,10 @@ sys/arch/sparc64/sparc64/compat_13_machd in %pstate and get kernel privileges on the hardware. [maxv, ticket #1504] +sys/compat/linux32/arch/amd64/linux32_machdep.c 1.39 + + Fix a ring0 escalation vulnerability in compat_linux32 where the + index of %cs is controlled by userland, making it easy to trigger + the page fault and get kernel privileges. + [maxv, ticket #1507] +
CVS commit: [netbsd-7] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:57:48 UTC 2017 Modified Files: src/doc [netbsd-7]: CHANGES-7.2 Log Message: 1507 To generate a diff of this commit: cvs rdiff -u -r1.1.2.44 -r1.1.2.45 src/doc/CHANGES-7.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-7-1] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:57:58 UTC 2017 Modified Files: src/doc [netbsd-7-1]: CHANGES-7.1.1 Log Message: 1507 To generate a diff of this commit: cvs rdiff -u -r1.1.2.30 -r1.1.2.31 src/doc/CHANGES-7.1.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-7-0] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:58:10 UTC 2017 Modified Files: src/doc [netbsd-7-0]: CHANGES-7.0.3 Log Message: 1507 To generate a diff of this commit: cvs rdiff -u -r1.1.2.62 -r1.1.2.63 src/doc/CHANGES-7.0.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-7-1] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:57:58 UTC 2017 Modified Files: src/doc [netbsd-7-1]: CHANGES-7.1.1 Log Message: 1507 To generate a diff of this commit: cvs rdiff -u -r1.1.2.30 -r1.1.2.31 src/doc/CHANGES-7.1.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-7.1.1 diff -u src/doc/CHANGES-7.1.1:1.1.2.30 src/doc/CHANGES-7.1.1:1.1.2.31 --- src/doc/CHANGES-7.1.1:1.1.2.30 Mon Sep 4 16:08:52 2017 +++ src/doc/CHANGES-7.1.1 Sat Sep 9 16:57:58 2017 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-7.1.1,v 1.1.2.30 2017/09/04 16:08:52 snj Exp $ +# $NetBSD: CHANGES-7.1.1,v 1.1.2.31 2017/09/09 16:57:58 snj Exp $ A complete list of changes from the NetBSD 7.1 release to the NetBSD 7.1.1 release: @@ -3639,3 +3639,10 @@ sys/arch/sparc64/sparc64/compat_13_machd in %pstate and get kernel privileges on the hardware. [maxv, ticket #1504] +sys/compat/linux32/arch/amd64/linux32_machdep.c 1.39 + + Fix a ring0 escalation vulnerability in compat_linux32 where the + index of %cs is controlled by userland, making it easy to trigger + the page fault and get kernel privileges. + [maxv, ticket #1507] +
CVS commit: [netbsd-7] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:57:48 UTC 2017 Modified Files: src/doc [netbsd-7]: CHANGES-7.2 Log Message: 1507 To generate a diff of this commit: cvs rdiff -u -r1.1.2.44 -r1.1.2.45 src/doc/CHANGES-7.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-7.2 diff -u src/doc/CHANGES-7.2:1.1.2.44 src/doc/CHANGES-7.2:1.1.2.45 --- src/doc/CHANGES-7.2:1.1.2.44 Mon Sep 4 16:09:34 2017 +++ src/doc/CHANGES-7.2 Sat Sep 9 16:57:48 2017 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-7.2,v 1.1.2.44 2017/09/04 16:09:34 snj Exp $ +# $NetBSD: CHANGES-7.2,v 1.1.2.45 2017/09/09 16:57:48 snj Exp $ A complete list of changes from the NetBSD 7.1 release to the NetBSD 7.2 release: @@ -4630,3 +4630,10 @@ sys/arch/sparc64/sparc64/compat_13_machd in %pstate and get kernel privileges on the hardware. [maxv, ticket #1504] +sys/compat/linux32/arch/amd64/linux32_machdep.c 1.39 + + Fix a ring0 escalation vulnerability in compat_linux32 where the + index of %cs is controlled by userland, making it easy to trigger + the page fault and get kernel privileges. + [maxv, ticket #1507] +
CVS commit: [netbsd-7-1] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:57:36 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-7-1]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1507): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.36.14.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-7] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:57:38 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-7]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1507): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.36.4.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux32/arch/amd64/linux32_machdep.c diff -u src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.36 src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.36.4.1 --- src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.36 Wed Feb 19 21:45:01 2014 +++ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Sat Sep 9 16:57:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_machdep.c,v 1.36 2014/02/19 21:45:01 dsl Exp $ */ +/* $NetBSD: linux32_machdep.c,v 1.36.4.1 2017/09/09 16:57:37 snj Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.36 2014/02/19 21:45:01 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.36.4.1 2017/09/09 16:57:37 snj Exp $"); #include #include @@ -417,8 +417,9 @@ linux32_restore_sigcontext(struct lwp *l /* * Check for security violations. */ - if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 || - !USERMODE(scp->sc_cs, scp->sc_eflags)) + if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0) + return EINVAL; + if (!VALID_USER_CSEL32(scp->sc_cs)) return EINVAL; if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) &&
CVS commit: [netbsd-7-0] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:57:34 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-7-0]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1507): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.36.8.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux32/arch/amd64/linux32_machdep.c diff -u src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.36 src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.36.8.1 --- src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.36 Wed Feb 19 21:45:01 2014 +++ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Sat Sep 9 16:57:34 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_machdep.c,v 1.36 2014/02/19 21:45:01 dsl Exp $ */ +/* $NetBSD: linux32_machdep.c,v 1.36.8.1 2017/09/09 16:57:34 snj Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.36 2014/02/19 21:45:01 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.36.8.1 2017/09/09 16:57:34 snj Exp $"); #include #include @@ -417,8 +417,9 @@ linux32_restore_sigcontext(struct lwp *l /* * Check for security violations. */ - if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 || - !USERMODE(scp->sc_cs, scp->sc_eflags)) + if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0) + return EINVAL; + if (!VALID_USER_CSEL32(scp->sc_cs)) return EINVAL; if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) &&
CVS commit: [netbsd-7-1] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:57:36 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-7-1]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1507): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.36.14.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux32/arch/amd64/linux32_machdep.c diff -u src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.36 src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.36.14.1 --- src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.36 Wed Feb 19 21:45:01 2014 +++ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Sat Sep 9 16:57:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_machdep.c,v 1.36 2014/02/19 21:45:01 dsl Exp $ */ +/* $NetBSD: linux32_machdep.c,v 1.36.14.1 2017/09/09 16:57:36 snj Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.36 2014/02/19 21:45:01 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.36.14.1 2017/09/09 16:57:36 snj Exp $"); #include #include @@ -417,8 +417,9 @@ linux32_restore_sigcontext(struct lwp *l /* * Check for security violations. */ - if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 || - !USERMODE(scp->sc_cs, scp->sc_eflags)) + if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0) + return EINVAL; + if (!VALID_USER_CSEL32(scp->sc_cs)) return EINVAL; if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) &&
CVS commit: [netbsd-7-0] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:57:34 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-7-0]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1507): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.36.8.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-7] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:57:38 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-7]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1507): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.36.4.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-6] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:54:40 UTC 2017 Modified Files: src/doc [netbsd-6]: CHANGES-6.2 Log Message: 1502 To generate a diff of this commit: cvs rdiff -u -r1.1.2.308 -r1.1.2.309 src/doc/CHANGES-6.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-6.2 diff -u src/doc/CHANGES-6.2:1.1.2.308 src/doc/CHANGES-6.2:1.1.2.309 --- src/doc/CHANGES-6.2:1.1.2.308 Mon Sep 4 16:05:39 2017 +++ src/doc/CHANGES-6.2 Sat Sep 9 16:54:40 2017 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-6.2,v 1.1.2.308 2017/09/04 16:05:39 snj Exp $ +# $NetBSD: CHANGES-6.2,v 1.1.2.309 2017/09/09 16:54:40 snj Exp $ A complete list of changes from the 6.1 release until the 6.2 release: @@ -20900,3 +20900,11 @@ sys/arch/sparc64/sparc64/compat_13_machd in %pstate and get kernel privileges on the hardware. [maxv, ticket #1501] +sys/compat/linux32/arch/amd64/linux32_machdep.c 1.39 + + + Fix a ring0 escalation vulnerability in compat_linux32 where the + index of %cs is controlled by userland, making it easy to trigger + the page fault and get kernel privileges. + [maxv, ticket #1502] +
CVS commit: [netbsd-6-1] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:54:15 UTC 2017 Modified Files: src/doc [netbsd-6-1]: CHANGES-6.1.6 Log Message: 1502 To generate a diff of this commit: cvs rdiff -u -r1.1.2.112 -r1.1.2.113 src/doc/CHANGES-6.1.6 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-6.1.6 diff -u src/doc/CHANGES-6.1.6:1.1.2.112 src/doc/CHANGES-6.1.6:1.1.2.113 --- src/doc/CHANGES-6.1.6:1.1.2.112 Mon Sep 4 16:04:59 2017 +++ src/doc/CHANGES-6.1.6 Sat Sep 9 16:54:15 2017 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-6.1.6,v 1.1.2.112 2017/09/04 16:04:59 snj Exp $ +# $NetBSD: CHANGES-6.1.6,v 1.1.2.113 2017/09/09 16:54:15 snj Exp $ A complete list of changes from the NetBSD 6.1.5 release to the NetBSD 6.1.6 release: @@ -14805,3 +14805,11 @@ sys/arch/sparc64/sparc64/compat_13_machd in %pstate and get kernel privileges on the hardware. [maxv, ticket #1501] +sys/compat/linux32/arch/amd64/linux32_machdep.c 1.39 + + + Fix a ring0 escalation vulnerability in compat_linux32 where the + index of %cs is controlled by userland, making it easy to trigger + the page fault and get kernel privileges. + [maxv, ticket #1502] +
CVS commit: [netbsd-6-1] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:54:15 UTC 2017 Modified Files: src/doc [netbsd-6-1]: CHANGES-6.1.6 Log Message: 1502 To generate a diff of this commit: cvs rdiff -u -r1.1.2.112 -r1.1.2.113 src/doc/CHANGES-6.1.6 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-6] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:54:40 UTC 2017 Modified Files: src/doc [netbsd-6]: CHANGES-6.2 Log Message: 1502 To generate a diff of this commit: cvs rdiff -u -r1.1.2.308 -r1.1.2.309 src/doc/CHANGES-6.2 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-6-0] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:53:33 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-6-0]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1502): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.29.14.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-6-1] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:53:35 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-6-1]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1502): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.29.16.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux32/arch/amd64/linux32_machdep.c diff -u src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.29 src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.29.16.1 --- src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.29 Fri Mar 4 22:25:31 2011 +++ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Sat Sep 9 16:53:34 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_machdep.c,v 1.29 2011/03/04 22:25:31 joerg Exp $ */ +/* $NetBSD: linux32_machdep.c,v 1.29.16.1 2017/09/09 16:53:34 snj Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.29 2011/03/04 22:25:31 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.29.16.1 2017/09/09 16:53:34 snj Exp $"); #include #include @@ -428,8 +428,9 @@ linux32_restore_sigcontext(struct lwp *l /* * Check for security violations. */ - if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 || - !USERMODE(scp->sc_cs, scp->sc_eflags)) + if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0) + return EINVAL; + if (!VALID_USER_CSEL32(scp->sc_cs)) return EINVAL; if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) &&
CVS commit: [netbsd-6-0] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:53:55 UTC 2017 Modified Files: src/doc [netbsd-6-0]: CHANGES-6.0.7 Log Message: 1502 To generate a diff of this commit: cvs rdiff -u -r1.1.2.115 -r1.1.2.116 src/doc/CHANGES-6.0.7 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-6] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:53:36 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-6]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1502): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.29.10.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-6-1] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:53:35 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-6-1]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1502): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.29.16.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-6-0] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:53:33 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-6-0]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1502): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.29.14.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux32/arch/amd64/linux32_machdep.c diff -u src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.29 src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.29.14.1 --- src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.29 Fri Mar 4 22:25:31 2011 +++ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Sat Sep 9 16:53:33 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_machdep.c,v 1.29 2011/03/04 22:25:31 joerg Exp $ */ +/* $NetBSD: linux32_machdep.c,v 1.29.14.1 2017/09/09 16:53:33 snj Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.29 2011/03/04 22:25:31 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.29.14.1 2017/09/09 16:53:33 snj Exp $"); #include #include @@ -428,8 +428,9 @@ linux32_restore_sigcontext(struct lwp *l /* * Check for security violations. */ - if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 || - !USERMODE(scp->sc_cs, scp->sc_eflags)) + if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0) + return EINVAL; + if (!VALID_USER_CSEL32(scp->sc_cs)) return EINVAL; if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) &&
CVS commit: [netbsd-6-0] src/doc
Module Name:src Committed By: snj Date: Sat Sep 9 16:53:55 UTC 2017 Modified Files: src/doc [netbsd-6-0]: CHANGES-6.0.7 Log Message: 1502 To generate a diff of this commit: cvs rdiff -u -r1.1.2.115 -r1.1.2.116 src/doc/CHANGES-6.0.7 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES-6.0.7 diff -u src/doc/CHANGES-6.0.7:1.1.2.115 src/doc/CHANGES-6.0.7:1.1.2.116 --- src/doc/CHANGES-6.0.7:1.1.2.115 Mon Sep 4 16:04:06 2017 +++ src/doc/CHANGES-6.0.7 Sat Sep 9 16:53:55 2017 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-6.0.7,v 1.1.2.115 2017/09/04 16:04:06 snj Exp $ +# $NetBSD: CHANGES-6.0.7,v 1.1.2.116 2017/09/09 16:53:55 snj Exp $ A complete list of changes from the NetBSD 6.0.6 release to the NetBSD 6.0.7 release: @@ -15132,3 +15132,11 @@ sys/arch/sparc64/sparc64/compat_13_machd in %pstate and get kernel privileges on the hardware. [maxv, ticket #1501] +sys/compat/linux32/arch/amd64/linux32_machdep.c 1.39 + + + Fix a ring0 escalation vulnerability in compat_linux32 where the + index of %cs is controlled by userland, making it easy to trigger + the page fault and get kernel privileges. + [maxv, ticket #1502] +
CVS commit: [netbsd-6] src/sys/compat/linux32/arch/amd64
Module Name:src Committed By: snj Date: Sat Sep 9 16:53:36 UTC 2017 Modified Files: src/sys/compat/linux32/arch/amd64 [netbsd-6]: linux32_machdep.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1502): sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.39 Fix a ring0 escalation vulnerability in compat_linux32 where the index of %cs is controlled by userland, making it easy to trigger the page fault and get kernel privileges. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.29.10.1 \ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux32/arch/amd64/linux32_machdep.c diff -u src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.29 src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.29.10.1 --- src/sys/compat/linux32/arch/amd64/linux32_machdep.c:1.29 Fri Mar 4 22:25:31 2011 +++ src/sys/compat/linux32/arch/amd64/linux32_machdep.c Sat Sep 9 16:53:36 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_machdep.c,v 1.29 2011/03/04 22:25:31 joerg Exp $ */ +/* $NetBSD: linux32_machdep.c,v 1.29.10.1 2017/09/09 16:53:36 snj Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -31,7 +31,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.29 2011/03/04 22:25:31 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_machdep.c,v 1.29.10.1 2017/09/09 16:53:36 snj Exp $"); #include #include @@ -428,8 +428,9 @@ linux32_restore_sigcontext(struct lwp *l /* * Check for security violations. */ - if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 || - !USERMODE(scp->sc_cs, scp->sc_eflags)) + if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0) + return EINVAL; + if (!VALID_USER_CSEL32(scp->sc_cs)) return EINVAL; if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) &&
CVS commit: src/sys/kern
Module Name:src Committed By: joerg Date: Sat Sep 9 14:41:20 UTC 2017 Modified Files: src/sys/kern: uipc_domain.c Log Message: Fix a race between sysctl_unpcblist and closef. To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/sys/kern/uipc_domain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/uipc_domain.c diff -u src/sys/kern/uipc_domain.c:1.99 src/sys/kern/uipc_domain.c:1.100 --- src/sys/kern/uipc_domain.c:1.99 Wed Jul 5 17:54:46 2017 +++ src/sys/kern/uipc_domain.c Sat Sep 9 14:41:19 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_domain.c,v 1.99 2017/07/05 17:54:46 christos Exp $ */ +/* $NetBSD: uipc_domain.c,v 1.100 2017/09/09 14:41:19 joerg Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.99 2017/07/05 17:54:46 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_domain.c,v 1.100 2017/09/09 14:41:19 joerg Exp $"); #include #include @@ -575,6 +575,16 @@ sysctl_unpcblist(SYSCTLFN_ARGS) continue; if (len >= elem_size && elem_count > 0) { mutex_enter(>f_lock); + /* + * Do not add references, if the count reached 0. + * Since the check above has been performed without + * locking, it must be rechecked here as a concurrent + * closef could have reduced it. + */ + if (fp->f_count == 0) { +mutex_exit(>f_lock); +continue; + } fp->f_count++; mutex_exit(>f_lock); LIST_INSERT_AFTER(fp, dfp, f_list);
CVS commit: src/sys/kern
Module Name:src Committed By: joerg Date: Sat Sep 9 14:41:20 UTC 2017 Modified Files: src/sys/kern: uipc_domain.c Log Message: Fix a race between sysctl_unpcblist and closef. To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/sys/kern/uipc_domain.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/sys_info
Module Name:src Committed By: jmcneill Date: Sat Sep 9 14:12:09 UTC 2017 Modified Files: src/usr.bin/sys_info: sys_info.sh Log Message: add dtc (Device Tree Compiler) version info To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.bin/sys_info/sys_info.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/sys_info/sys_info.sh diff -u src/usr.bin/sys_info/sys_info.sh:1.13 src/usr.bin/sys_info/sys_info.sh:1.14 --- src/usr.bin/sys_info/sys_info.sh:1.13 Sun Aug 27 20:40:22 2017 +++ src/usr.bin/sys_info/sys_info.sh Sat Sep 9 14:12:09 2017 @@ -1,6 +1,6 @@ #! /bin/sh -# $NetBSD: sys_info.sh,v 1.13 2017/08/27 20:40:22 wiz Exp $ +# $NetBSD: sys_info.sh,v 1.14 2017/09/09 14:12:09 jmcneill Exp $ # Copyright (c) 2016 Alistair Crooks <a...@netbsd.org> # All rights reserved. @@ -26,7 +26,7 @@ # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -SYS_INFO_VERSION=20170824 +SYS_INFO_VERSION=20170909 PATH=$(sysctl -n user.cs_path) export PATH @@ -133,6 +133,9 @@ getversion() { dhcpcd) run "dhcpcd --version | sed -e 's/ /-/g' -e 1q" $all || return 0 ;& + dtc) + run "dtc --version | sed 's/Version: DTC /dtc-/'" + $all || return 0 ;& ftpd) run "strings -a /usr/libexec/ftpd | awk '\$1 == \"NetBSD-ftpd\" { print \"ftpd-\" \$2 }'" $all || return 0 ;&
CVS commit: src/usr.bin/sys_info
Module Name:src Committed By: jmcneill Date: Sat Sep 9 14:12:09 UTC 2017 Modified Files: src/usr.bin/sys_info: sys_info.sh Log Message: add dtc (Device Tree Compiler) version info To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.bin/sys_info/sys_info.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/cortex
Module Name:src Committed By: jmcneill Date: Sat Sep 9 13:14:30 UTC 2017 Modified Files: src/sys/arch/arm/cortex: gtmr.c Log Message: gtmr_intr: If the ISTATUS bit is 0, timer condition is not met. In this case, just return 0. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/cortex/gtmr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/cortex/gtmr.c diff -u src/sys/arch/arm/cortex/gtmr.c:1.19 src/sys/arch/arm/cortex/gtmr.c:1.20 --- src/sys/arch/arm/cortex/gtmr.c:1.19 Thu Aug 24 13:06:23 2017 +++ src/sys/arch/arm/cortex/gtmr.c Sat Sep 9 13:14:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: gtmr.c,v 1.19 2017/08/24 13:06:23 jmcneill Exp $ */ +/* $NetBSD: gtmr.c,v 1.20 2017/09/09 13:14:30 jmcneill Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.19 2017/08/24 13:06:23 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: gtmr.c,v 1.20 2017/09/09 13:14:30 jmcneill Exp $"); #include #include @@ -292,6 +292,10 @@ gtmr_intr(void *arg) arm_isb(); + const uint32_t ctl = armreg_cntv_ctl_read(); + if ((ctl & ARM_CNTCTL_ISTATUS) == 0) + return 0; + const uint64_t now = armreg_cntv_ct_read(); uint64_t delta = now - ci->ci_lastintr;
CVS commit: src/sys/arch/arm/cortex
Module Name:src Committed By: jmcneill Date: Sat Sep 9 13:14:30 UTC 2017 Modified Files: src/sys/arch/arm/cortex: gtmr.c Log Message: gtmr_intr: If the ISTATUS bit is 0, timer condition is not met. In this case, just return 0. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/cortex/gtmr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libc/stdlib
Module Name:src Committed By: kamil Date: Sat Sep 9 12:28:19 UTC 2017 Modified Files: src/lib/libc/stdlib: ptsname.3 Log Message: Correct the documentatin of ptsname_r(3) This function returns "int" not "char *": errno on failure, 0 on success. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/libc/stdlib/ptsname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/stdlib/ptsname.3 diff -u src/lib/libc/stdlib/ptsname.3:1.10 src/lib/libc/stdlib/ptsname.3:1.11 --- src/lib/libc/stdlib/ptsname.3:1.10 Mon Jul 3 21:32:50 2017 +++ src/lib/libc/stdlib/ptsname.3 Sat Sep 9 12:28:19 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: ptsname.3,v 1.10 2017/07/03 21:32:50 wiz Exp $ +.\" $NetBSD: ptsname.3,v 1.11 2017/09/09 12:28:19 kamil Exp $ .\" .\" Copyright (c) 2004 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 7, 2014 +.Dd September 9, 2017 .Dt PTSNAME 3 .Os .Sh NAME @@ -40,7 +40,7 @@ .In stdlib.h .Ft char * .Fn ptsname "int masterfd" -.Ft char * +.Ft int .Fn ptsname_r "int masterfd" "char *buf" "size_t buflen" .Sh DESCRIPTION The
CVS commit: src/lib/libc/stdlib
Module Name:src Committed By: kamil Date: Sat Sep 9 12:28:19 UTC 2017 Modified Files: src/lib/libc/stdlib: ptsname.3 Log Message: Correct the documentatin of ptsname_r(3) This function returns "int" not "char *": errno on failure, 0 on success. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/libc/stdlib/ptsname.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/dts
Module Name:src Committed By: jmcneill Date: Sat Sep 9 12:05:29 UTC 2017 Modified Files: src/sys/arch/arm/dts: sun50i-a64-pine64-plus.dts sun50i-a64.dtsi Log Message: Enable USB-OTG-EHCI and USB-OTG-OHCI controllers on Pine64+. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/dts/sun50i-a64.dtsi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts diff -u src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts:1.1 src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts:1.2 --- src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts:1.1 Thu Sep 7 21:37:56 2017 +++ src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts Sat Sep 9 12:05:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i-a64-pine64-plus.dts,v 1.1 2017/09/07 21:37:56 jmcneill Exp $ */ +/* $NetBSD: sun50i-a64-pine64-plus.dts,v 1.2 2017/09/09 12:05:28 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill@@ -41,3 +41,11 @@ reg = <1>; }; }; + + { + status = "okay"; +}; + + { + status = "okay"; +}; Index: src/sys/arch/arm/dts/sun50i-a64.dtsi diff -u src/sys/arch/arm/dts/sun50i-a64.dtsi:1.2 src/sys/arch/arm/dts/sun50i-a64.dtsi:1.3 --- src/sys/arch/arm/dts/sun50i-a64.dtsi:1.2 Thu Sep 7 21:46:42 2017 +++ src/sys/arch/arm/dts/sun50i-a64.dtsi Sat Sep 9 12:05:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sun50i-a64.dtsi,v 1.2 2017/09/07 21:46:42 jmcneill Exp $ */ +/* $NetBSD: sun50i-a64.dtsi,v 1.3 2017/09/09 12:05:28 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill @@ -75,3 +75,33 @@ drive-strength = <40>; }; }; + +/ { + soc { + ehci0: usb@01c1a000 { + compatible = "allwinner,sun50i-a64-ehci", "generic-ehci"; + reg = <0x01c1a000 0x100>; + interrupts = ; + clocks = < CLK_BUS_OHCI0>, + < CLK_BUS_EHCI0>, + < CLK_USB_OHCI0>; + resets = < RST_BUS_OHCI0>, + < RST_BUS_EHCI0>; + phys = < 0>; + phy-names = "usb"; + status = "disabled"; + }; + + ohci0: usb@01c1a400 { + compatible = "allwinner,sun50i-a64-ohci", "generic-ohci"; + reg = <0x01c1a400 0x100>; + interrupts = ; + clocks = < CLK_BUS_OHCI0>, + < CLK_USB_OHCI0>; + resets = < RST_BUS_OHCI0>; + phys = < 0>; + phy-names = "usb"; + status = "disabled"; + }; + }; +};
CVS commit: src/sys/arch/arm/dts
Module Name:src Committed By: jmcneill Date: Sat Sep 9 12:05:29 UTC 2017 Modified Files: src/sys/arch/arm/dts: sun50i-a64-pine64-plus.dts sun50i-a64.dtsi Log Message: Enable USB-OTG-EHCI and USB-OTG-OHCI controllers on Pine64+. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/dts/sun50i-a64-pine64-plus.dts cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/dts/sun50i-a64.dtsi Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sat Sep 9 12:02:58 UTC 2017 Modified Files: src/sys/arch/evbarm/conf: SUNXI Log Message: add motg To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/arch/evbarm/conf/SUNXI Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/evbarm/conf
Module Name:src Committed By: jmcneill Date: Sat Sep 9 12:02:58 UTC 2017 Modified Files: src/sys/arch/evbarm/conf: SUNXI Log Message: add motg To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/arch/evbarm/conf/SUNXI Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/conf/SUNXI diff -u src/sys/arch/evbarm/conf/SUNXI:1.28 src/sys/arch/evbarm/conf/SUNXI:1.29 --- src/sys/arch/evbarm/conf/SUNXI:1.28 Thu Sep 7 21:22:51 2017 +++ src/sys/arch/evbarm/conf/SUNXI Sat Sep 9 12:02:57 2017 @@ -1,5 +1,5 @@ # -# $NetBSD: SUNXI,v 1.28 2017/09/07 21:22:51 jmcneill Exp $ +# $NetBSD: SUNXI,v 1.29 2017/09/09 12:02:57 jmcneill Exp $ # # Allwinner sunxi family # @@ -197,8 +197,11 @@ pseudo-device wsmux sunxiusbphy* at fdt? pass 9 # USB PHY ehci* at fdt? # EHCI ohci* at fdt? # OHCI +motg* at fdt? # USB OTG +options MOTG_ALLWINNER # XXX this should be a driver flag usb* at ehci? usb* at ohci? +usb* at motg? include "dev/usb/usbdevices.config" midi* at midibus?
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Sep 9 12:01:04 UTC 2017 Modified Files: src/sys/arch/arm/sunxi: files.sunxi Added Files: src/sys/arch/arm/sunxi: sunxi_musb.c Log Message: Add support for USB OTG controllers in "host" mode. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/sunxi/files.sunxi cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sunxi_musb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Sep 9 12:01:04 UTC 2017 Modified Files: src/sys/arch/arm/sunxi: files.sunxi Added Files: src/sys/arch/arm/sunxi: sunxi_musb.c Log Message: Add support for USB OTG controllers in "host" mode. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/sunxi/files.sunxi cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sunxi/sunxi_musb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/files.sunxi diff -u src/sys/arch/arm/sunxi/files.sunxi:1.22 src/sys/arch/arm/sunxi/files.sunxi:1.23 --- src/sys/arch/arm/sunxi/files.sunxi:1.22 Thu Sep 7 01:07:04 2017 +++ src/sys/arch/arm/sunxi/files.sunxi Sat Sep 9 12:01:04 2017 @@ -1,4 +1,4 @@ -# $NetBSD: files.sunxi,v 1.22 2017/09/07 01:07:04 jmcneill Exp $ +# $NetBSD: files.sunxi,v 1.23 2017/09/09 12:01:04 jmcneill Exp $ # # Configuration info for Allwinner sunxi family SoCs # @@ -159,6 +159,10 @@ device sunxits: wsmousedev, tpcalib attach sunxits at fdt with sunxi_ts file arch/arm/sunxi/sunxi_ts.c sunxi_ts +# USB OTG +attach motg at fdt with sunxi_musb +file arch/arm/sunxi/sunxi_musb.c sunxi_musb + # SOC parameters defflag opt_soc.h SOC_SUNXI defflag opt_soc.h SOC_SUN5I: SOC_SUNXI Added files: Index: src/sys/arch/arm/sunxi/sunxi_musb.c diff -u /dev/null src/sys/arch/arm/sunxi/sunxi_musb.c:1.1 --- /dev/null Sat Sep 9 12:01:04 2017 +++ src/sys/arch/arm/sunxi/sunxi_musb.c Sat Sep 9 12:01:04 2017 @@ -0,0 +1,195 @@ +/* $NetBSD: sunxi_musb.c,v 1.1 2017/09/09 12:01:04 jmcneill Exp $ */ + +/*- + * Copyright (c) 2017 Jared McNeill+ * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: sunxi_musb.c,v 1.1 2017/09/09 12:01:04 jmcneill Exp $"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include + +#define MUSB2_REG_AWIN_VEND0 0x43 +#define MUSB2_REG_INTTX 0x44 +#define MUSB2_REG_INTRX 0x46 +#define MUSB2_REG_INTUSB 0x4c + +static int sunxi_musb_match(device_t, cfdata_t, void *); +static void sunxi_musb_attach(device_t, device_t, void *); + +CFATTACH_DECL_NEW(sunxi_musb, sizeof(struct motg_softc), + sunxi_musb_match, sunxi_musb_attach, NULL, NULL); + +static const struct of_compat_data compat_data[] = { + { "allwinner,sun4i-a10-musb", 5 }, + { "allwinner,sun6i-a13-musb", 5 }, + { "allwinner,sun8i-h3-musb", 4 }, + { "allwinner,sun8i-a33-musb", 5 }, + { NULL } +}; + +static int +sunxi_musb_intr(void *priv) +{ + struct motg_softc * const sc = priv; + uint16_t inttx, intrx; + uint8_t intusb; + + mutex_enter(>sc_intr_lock); + + intusb = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MUSB2_REG_INTUSB); + inttx = bus_space_read_2(sc->sc_iot, sc->sc_ioh, MUSB2_REG_INTTX); + intrx = bus_space_read_2(sc->sc_iot, sc->sc_ioh, MUSB2_REG_INTRX); + if (!intusb && !inttx && !intrx) { + mutex_exit(>sc_intr_lock); + return 0; + } + + if (intusb) + bus_space_write_1(sc->sc_iot, sc->sc_ioh, MUSB2_REG_INTUSB, intusb); + if (inttx) + bus_space_write_2(sc->sc_iot, sc->sc_ioh, MUSB2_REG_INTTX, inttx); + if (intrx) + bus_space_write_2(sc->sc_iot, sc->sc_ioh, MUSB2_REG_INTRX, intrx); + + motg_intr(sc, intrx, inttx, intusb); + + mutex_exit(>sc_intr_lock); + + return 1; +} + +static void +sunxi_musb_poll(void *priv) +{ + sunxi_musb_intr(priv); +} + +static int +sunxi_musb_match(device_t parent, cfdata_t cf, void *aux) +{ + struct fdt_attach_args * const faa = aux; + + return of_match_compat_data(faa->faa_phandle, compat_data); +} + +static void +sunxi_musb_attach(device_t parent, device_t self, void *aux) +{
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Sep 9 11:58:34 UTC 2017 Modified Files: src/sys/arch/arm/sunxi: sunxi_usbphy.c Log Message: Add PHY init for OTG ports in host mode. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_usbphy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sunxi/sunxi_usbphy.c diff -u src/sys/arch/arm/sunxi/sunxi_usbphy.c:1.7 src/sys/arch/arm/sunxi/sunxi_usbphy.c:1.8 --- src/sys/arch/arm/sunxi/sunxi_usbphy.c:1.7 Thu Sep 7 10:30:46 2017 +++ src/sys/arch/arm/sunxi/sunxi_usbphy.c Sat Sep 9 11:58:34 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: sunxi_usbphy.c,v 1.7 2017/09/07 10:30:46 jmcneill Exp $ */ +/* $NetBSD: sunxi_usbphy.c,v 1.8 2017/09/09 11:58:34 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill@@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: sunxi_usbphy.c,v 1.7 2017/09/07 10:30:46 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sunxi_usbphy.c,v 1.8 2017/09/09 11:58:34 jmcneill Exp $"); #include #include @@ -39,14 +39,34 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_usbphy #include -#define OTG_PHY_CFG 0x20 -#define OTG_PHY_ROUTE_OTG __BIT(0) - -#define HCI_ICR 0x00 -#define HCI_AHB_INCR8 __BIT(10) -#define HCI_AHB_INCR4 __BIT(9) -#define HCI_AHB_INCRX_ALIGN __BIT(8) -#define HCI_ULPI_BYPASS __BIT(0) +/* PHY control registers */ +#define PHYCTL_ICR 0x00 +#define PHYCTL_ICR_ID_PULLUP __BIT(17) +#define PHYCTL_ICR_DPDM_PULLUP __BIT(16) +#define PHYCTL_ICR_FORCE_ID __BITS(15,14) +#define PHYCTL_ICR_FORCE_ID_LOW 2 +#define PHYCTL_ICR_FORCE_ID_HIGH 3 +#define PHYCTL_ICR_FORCE_VBUS __BITS(13,12) +#define PHYCTL_ICR_FORCE_VBUS_LOW 2 +#define PHYCTL_ICR_FORCE_VBUS_HIGH 3 +#define PHYCTL_A10 0x04 +#define PHYCTL_A33 0x10 +#define PHYCTL_ADDR __BITS(15,8) +#define PHYCTL_DATA __BIT(7) +#define PHYCTL_OTG_CFG 0x20 +#define PHYCTL_OTG_ROUTE_OTG __BIT(0) + +/* PHY registers */ +#define PHY_RES45_CAL_EN 0x0c +#define PHY_TX_AMPLITUDE_TUNE 0x20 +#define PHY_DISCON_TH_SEL 0x2a + +/* PMU registers */ +#define PMU_CFG 0x00 +#define AHB_INCR8 __BIT(10) +#define AHB_INCR4 __BIT(9) +#define AHB_INCRX_ALIGN __BIT(8) +#define ULPI_BYPASS __BIT(0) #define PMU_UNK_H3 0x10 #define PMU_UNK_H3_CLR __BIT(1) @@ -89,16 +109,68 @@ struct sunxi_usbphy_softc { struct fdtbus_gpio_pin *sc_gpio_vbus_det; }; -#define USBPHY_READ(sc, id, reg) \ +#define PHYCTL_READ(sc, reg)\ + bus_space_read_4((sc)->sc_bst, \ + (sc)->sc_bsh_phy_ctrl, (reg)) +#define PHYCTL_WRITE(sc, reg, val) \ + bus_space_write_4((sc)->sc_bst, \ + (sc)->sc_bsh_phy_ctrl, (reg), (val)) +#define PMU_READ(sc, id, reg) \ bus_space_read_4((sc)->sc_bst, \ (sc)->sc_phys[(id)].phy_bsh, (reg)) -#define USBPHY_WRITE(sc, id, reg, val) \ +#define PMU_WRITE(sc, id, reg, val) \ bus_space_write_4((sc)->sc_bst, \ (sc)->sc_phys[(id)].phy_bsh, (reg), (val)) CFATTACH_DECL_NEW(sunxi_usbphy, sizeof(struct sunxi_usbphy_softc), sunxi_usbphy_match, sunxi_usbphy_attach, NULL, NULL); +static void +sunxi_usbphy_write(struct sunxi_usbphy_softc *sc, +struct sunxi_usbphy *phy, u_int bit_addr, u_int bits, +u_int len) +{ + const uint32_t usbc_mask = __BIT(phy->phy_index * 2);; + bus_size_t reg; + uint32_t val; + + switch (sc->sc_type) { + case USBPHY_A13: + case USBPHY_A31: + reg = PHYCTL_A10; + break; + case USBPHY_H3: + case USBPHY_A64: + reg = PHYCTL_A33; + break; + default: + panic("unsupported phy type"); + } + + if (reg == PHYCTL_A33) + PHYCTL_WRITE(sc, reg, 0); + + for (; len > 0; bit_addr++, bits >>= 1, len--) { + val = PHYCTL_READ(sc, reg); + val &= ~PHYCTL_ADDR; + val |= __SHIFTIN(bit_addr, PHYCTL_ADDR); + PHYCTL_WRITE(sc, reg, val); + + val = PHYCTL_READ(sc, reg); + val &= ~PHYCTL_DATA; + val |= __SHIFTIN(bits & 1, PHYCTL_DATA); + PHYCTL_WRITE(sc, reg, val); + + PHYCTL_READ(sc, reg); + val |= usbc_mask; + PHYCTL_WRITE(sc, reg, val); + + PHYCTL_READ(sc, reg); + val &= ~usbc_mask; + PHYCTL_WRITE(sc, reg, val); + } +} + static bool sunxi_usbphy_vbus_detect(struct sunxi_usbphy_softc *sc) { @@ -132,29 +204,83 @@ sunxi_usbphy_enable(device_t dev, void * { struct sunxi_usbphy_softc * const sc = device_private(dev); struct sunxi_usbphy * const phy = priv; + u_int disc_thresh; + bool phy0_reroute; uint32_t val; - if (phy->phy_index > 0) { - /* Enable passby */ - val = USBPHY_READ(sc, phy->phy_index, HCI_ICR); - val |= HCI_ULPI_BYPASS; - val |= HCI_AHB_INCR8; - val |= HCI_AHB_INCR4; - val |= HCI_AHB_INCRX_ALIGN; - USBPHY_WRITE(sc, phy->phy_index, HCI_ICR, val); + switch (sc->sc_type) { + case USBPHY_A13: + disc_thresh = 0x2; + phy0_reroute = false; + break; + case USBPHY_A31: + disc_thresh = 0x3; + phy0_reroute = false; + break; + case USBPHY_A64: + case USBPHY_H3: + disc_thresh = 0x3; + phy0_reroute
CVS commit: src/sys/arch/arm/sunxi
Module Name:src Committed By: jmcneill Date: Sat Sep 9 11:58:34 UTC 2017 Modified Files: src/sys/arch/arm/sunxi: sunxi_usbphy.c Log Message: Add PHY init for OTG ports in host mode. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sunxi/sunxi_usbphy.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.