From owner-p4-projects@FreeBSD.ORG Tue Jul 22 21:33:51 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D818E1065674; Tue, 22 Jul 2008 21:33:50 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B2B21065670 for ; Tue, 22 Jul 2008 21:33:50 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 930BF8FC16 for ; Tue, 22 Jul 2008 21:33:50 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m6MLXoLK042454 for ; Tue, 22 Jul 2008 21:33:50 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m6MLXoX8042452 for perforce@freebsd.org; Tue, 22 Jul 2008 21:33:50 GMT (envelope-from ed@FreeBSD.org) Date: Tue, 22 Jul 2008 21:33:50 GMT Message-Id: <200807222133.m6MLXoX8042452@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 145659 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jul 2008 21:33:51 -0000 http://perforce.freebsd.org/chv.cgi?CH=145659 Change 145659 by ed@ed_dull on 2008/07/22 21:33:23 IFC. Affected files ... .. //depot/projects/mpsafetty/contrib/tcsh/tc.func.c#2 integrate .. //depot/projects/mpsafetty/etc/rc.resume#2 integrate .. //depot/projects/mpsafetty/etc/remote#3 integrate .. //depot/projects/mpsafetty/games/fortune/datfiles/fortunes#3 integrate .. //depot/projects/mpsafetty/include/stdlib.h#2 integrate .. //depot/projects/mpsafetty/lib/libc/gen/Makefile.inc#2 integrate .. //depot/projects/mpsafetty/lib/libc/gen/Symbol.map#2 integrate .. //depot/projects/mpsafetty/lib/libc/gen/arc4random.3#2 integrate .. //depot/projects/mpsafetty/lib/libc/gen/arc4random.c#2 integrate .. //depot/projects/mpsafetty/lib/libc/stdio/mktemp.c#2 integrate .. //depot/projects/mpsafetty/release/doc/en_US.ISO8859-1/relnotes/article.sgml#2 integrate .. //depot/projects/mpsafetty/share/man/man4/ddb.4#4 integrate .. //depot/projects/mpsafetty/share/man/man9/sysctl.9#2 integrate .. //depot/projects/mpsafetty/share/man/man9/sysctl_add_oid.9#2 integrate .. //depot/projects/mpsafetty/share/misc/committers-src.dot#3 integrate .. //depot/projects/mpsafetty/sys/arm/at91/at91_pmc.c#2 integrate .. //depot/projects/mpsafetty/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c#2 integrate .. //depot/projects/mpsafetty/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c#2 integrate .. //depot/projects/mpsafetty/sys/conf/kern.mk#2 integrate .. //depot/projects/mpsafetty/sys/dev/amr/amr.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#3 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/cxgb/ulp/tom/cxgb_tcp_offload.h#2 integrate .. //depot/projects/mpsafetty/sys/dev/esp/esp_sbus.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/esp/ncr53c9x.c#2 integrate .. //depot/projects/mpsafetty/sys/dev/esp/ncr53c9xvar.h#2 integrate .. //depot/projects/mpsafetty/sys/dev/mpt/mpt_raid.c#2 integrate .. //depot/projects/mpsafetty/sys/geom/eli/g_eli.c#2 integrate .. //depot/projects/mpsafetty/sys/geom/part/g_part_apm.c#2 integrate .. //depot/projects/mpsafetty/sys/gnu/fs/xfs/FreeBSD/xfs_mountops.c#2 integrate .. //depot/projects/mpsafetty/sys/gnu/fs/xfs/FreeBSD/xfs_vnode.c#2 integrate .. //depot/projects/mpsafetty/sys/kern/kern_environment.c#2 integrate .. //depot/projects/mpsafetty/sys/kern/subr_autoconf.c#4 integrate .. //depot/projects/mpsafetty/sys/kern/uipc_socket.c#2 integrate .. //depot/projects/mpsafetty/sys/kern/vfs_subr.c#2 integrate .. //depot/projects/mpsafetty/sys/libkern/arc4random.c#2 integrate .. //depot/projects/mpsafetty/sys/modules/mem/Makefile#2 integrate .. //depot/projects/mpsafetty/sys/net/if_gre.c#2 integrate .. //depot/projects/mpsafetty/sys/netinet/in_pcb.c#4 integrate .. //depot/projects/mpsafetty/sys/netinet/in_pcb.h#5 integrate .. //depot/projects/mpsafetty/sys/netinet/tcp_offload.c#2 integrate .. //depot/projects/mpsafetty/sys/netinet/tcp_offload.h#2 integrate .. //depot/projects/mpsafetty/sys/netinet/tcp_syncache.c#2 integrate .. //depot/projects/mpsafetty/sys/netinet/tcp_syncache.h#2 integrate .. //depot/projects/mpsafetty/sys/netinet/tcp_timer.c#2 integrate .. //depot/projects/mpsafetty/sys/netinet/udp_usrreq.c#6 integrate .. //depot/projects/mpsafetty/sys/netipsec/ipsec.c#2 integrate .. //depot/projects/mpsafetty/sys/netipsec/ipsec6.h#2 integrate .. //depot/projects/mpsafetty/sys/netipx/ipx_input.c#2 integrate .. //depot/projects/mpsafetty/sys/netipx/ipx_usrreq.c#2 integrate .. //depot/projects/mpsafetty/sys/nfs4client/nfs4_socket.c#2 integrate .. //depot/projects/mpsafetty/sys/nfs4client/nfs4_vfsops.c#2 integrate .. //depot/projects/mpsafetty/sys/nfsclient/nfs_socket.c#2 integrate .. //depot/projects/mpsafetty/sys/nfsclient/nfs_vfsops.c#2 integrate .. //depot/projects/mpsafetty/sys/rpc/rpcclnt.c#2 integrate .. //depot/projects/mpsafetty/sys/security/audit/audit.c#2 integrate .. //depot/projects/mpsafetty/sys/security/audit/audit.h#2 integrate .. //depot/projects/mpsafetty/sys/security/audit/audit_arg.c#2 integrate .. //depot/projects/mpsafetty/sys/security/audit/audit_bsm.c#2 integrate .. //depot/projects/mpsafetty/sys/security/audit/audit_bsm_klib.c#2 integrate .. //depot/projects/mpsafetty/sys/security/audit/audit_bsm_token.c#2 integrate .. //depot/projects/mpsafetty/sys/security/audit/audit_private.h#2 integrate .. //depot/projects/mpsafetty/sys/security/audit/audit_syscalls.c#2 integrate .. //depot/projects/mpsafetty/sys/security/audit/audit_trigger.c#2 integrate .. //depot/projects/mpsafetty/sys/security/audit/audit_worker.c#2 integrate .. //depot/projects/mpsafetty/sys/sparc64/sparc64/autoconf.c#2 integrate .. //depot/projects/mpsafetty/sys/sparc64/sparc64/mem.c#2 integrate .. //depot/projects/mpsafetty/sys/sys/kernel.h#2 integrate .. //depot/projects/mpsafetty/sys/sys/param.h#2 integrate .. //depot/projects/mpsafetty/sys/sys/socket.h#2 integrate .. //depot/projects/mpsafetty/sys/sys/sysctl.h#2 integrate .. //depot/projects/mpsafetty/usr.bin/ldd/ldd.c#2 integrate Differences ... ==== //depot/projects/mpsafetty/contrib/tcsh/tc.func.c#2 (text+ko) ==== @@ -632,7 +632,7 @@ } strbuf_terminate(&pass); - cleanup_until(&sa); + cleanup_until(&osa); return pass.s; } ==== //depot/projects/mpsafetty/etc/rc.resume#2 (text+ko) ==== @@ -24,7 +24,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD: src/etc/rc.resume,v 1.8 2007/06/21 22:50:36 njl Exp $ +# $FreeBSD: src/etc/rc.resume,v 1.9 2008/07/21 22:55:40 thompsa Exp $ # # sample run command file for APM Resume Event @@ -50,7 +50,7 @@ # If a device driver has problems resuming, try unloading it before # suspend and reloading it on resume. Example: -# kldunload usb +# kldload usb # wpa_supplicant(8) doesn't seem to reassociate during resume. Uncomment # the following to signal it to reassociate. ==== //depot/projects/mpsafetty/etc/remote#3 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/etc/remote,v 1.17 2008/07/19 19:08:22 marcel Exp $ +# $FreeBSD: src/etc/remote,v 1.18 2008/07/21 22:38:00 marcel Exp $ # # @(#)remote 5.2 (Berkeley) 6/30/90 # @@ -58,11 +58,11 @@ cuau0c|cua0c:dv=/dev/cuau0:br#9600:pa=none: # Finger friendly shortcuts -uart0|sio0|com1:dv=/dev/cuau0:br#9600:pa=none: -uart1|sio1|com2:dv=/dev/cuau1:br#9600:pa=none: -uart2|sio2|com3:dv=/dev/cuau2:br#9600:pa=none: -uart3|sio3|com4:dv=/dev/cuau3:br#9600:pa=none: -uart4|sio4|com5:dv=/dev/cuau4:br#9600:pa=none: -uart5|sio5|com6:dv=/dev/cuau5:br#9600:pa=none: -uart6|sio6|com7:dv=/dev/cuau6:br#9600:pa=none: -uart7|sio7|com8:dv=/dev/cuau7:br#9600:pa=none: +uart0|com1:dv=/dev/cuau0:br#9600:pa=none: +uart1|com2:dv=/dev/cuau1:br#9600:pa=none: +uart2|com3:dv=/dev/cuau2:br#9600:pa=none: +uart3|com4:dv=/dev/cuau3:br#9600:pa=none: +uart4|com5:dv=/dev/cuau4:br#9600:pa=none: +uart5|com6:dv=/dev/cuau5:br#9600:pa=none: +uart6|com7:dv=/dev/cuau6:br#9600:pa=none: +uart7|com8:dv=/dev/cuau7:br#9600:pa=none: ==== //depot/projects/mpsafetty/games/fortune/datfiles/fortunes#3 (text+ko) ==== @@ -1,5 +1,5 @@ This fortune brought to you by: -$FreeBSD: src/games/fortune/datfiles/fortunes,v 1.268 2008/07/14 18:45:06 phk Exp $ +$FreeBSD: src/games/fortune/datfiles/fortunes,v 1.269 2008/07/22 14:21:56 maxim Exp $ % ======================================================================= || || @@ -56688,7 +56688,7 @@ -- The Best of Will Rogers % Why don't you fix your little problem... and light this candle? - -- Alan Shepherd, the first man into space, Gemini program + -- Alan Shepard, the first American into space, Gemini program % Why, every one as they like; as the good woman said when she kissed her cow. ==== //depot/projects/mpsafetty/include/stdlib.h#2 (text+ko) ==== @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 - * $FreeBSD: src/include/stdlib.h,v 1.65 2007/07/04 00:00:38 scf Exp $ + * $FreeBSD: src/include/stdlib.h,v 1.67 2008/07/22 11:40:42 ache Exp $ */ #ifndef _STDLIB_H_ @@ -235,8 +235,11 @@ __uint32_t arc4random(void); -void arc4random_addrandom(unsigned char *dat, int datlen); +void arc4random_addrandom(unsigned char *, int); +void arc4random_buf(void *, size_t); void arc4random_stir(void); +__uint32_t + arc4random_uniform(__uint32_t); char *getbsize(int *, long *); /* getcap(3) functions */ char *cgetcap(char *, const char *, int); ==== //depot/projects/mpsafetty/lib/libc/gen/Makefile.inc#2 (text+ko) ==== @@ -1,5 +1,5 @@ # @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 -# $FreeBSD: src/lib/libc/gen/Makefile.inc,v 1.137 2008/06/23 05:22:06 ed Exp $ +# $FreeBSD: src/lib/libc/gen/Makefile.inc,v 1.139 2008/07/22 11:33:49 ache Exp $ # machine-independent gen sources .PATH: ${.CURDIR}/${MACHINE_ARCH}/gen ${.CURDIR}/gen @@ -68,7 +68,8 @@ ttyname.3 tzset.3 ualarm.3 ucontext.3 ulimit.3 uname.3 \ unvis.3 usleep.3 utime.3 valloc.3 vis.3 wordexp.3 -MLINKS+=arc4random.3 arc4random_addrandom.3 arc4random.3 arc4random_stir.3 +MLINKS+=arc4random.3 arc4random_addrandom.3 arc4random.3 arc4random_stir.3 \ + arc4random.3 arc4random_buf.3 arc4random.3 arc4random_uniform.3 MLINKS+=ctermid.3 ctermid_r.3 MLINKS+=devname.3 devname_r.3 MLINKS+=directory.3 closedir.3 directory.3 dirfd.3 directory.3 opendir.3 \ ==== //depot/projects/mpsafetty/lib/libc/gen/Symbol.map#2 (text) ==== @@ -1,5 +1,5 @@ /* - * $FreeBSD: src/lib/libc/gen/Symbol.map,v 1.12 2008/06/23 05:22:06 ed Exp $ + * $FreeBSD: src/lib/libc/gen/Symbol.map,v 1.15 2008/07/22 11:33:49 ache Exp $ */ FBSD_1.0 { @@ -329,7 +329,10 @@ }; FBSD_1.1 { + arc4random_buf; + arc4random_uniform; fdopendir; + feature_present; fts_open; fts_close; fts_read; ==== //depot/projects/mpsafetty/lib/libc/gen/arc4random.3#2 (text+ko) ==== @@ -28,13 +28,15 @@ .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" Manual page, using -mandoc macros -.\" $FreeBSD: src/lib/libc/gen/arc4random.3,v 1.16 2003/07/31 06:18:24 das Exp $ +.\" $FreeBSD: src/lib/libc/gen/arc4random.3,v 1.18 2008/07/22 11:33:49 ache Exp $ .\" .Dd April 15, 1997 .Dt ARC4RANDOM 3 .Os .Sh NAME .Nm arc4random , +.Nm arc4random_buf , +.Nm arc4random_uniform , .Nm arc4random_stir , .Nm arc4random_addrandom .Nd arc4 random number generator @@ -45,6 +47,10 @@ .Ft u_int32_t .Fn arc4random "void" .Ft void +.Fn arc4random_buf "void *buf" "size_t nbytes" +.Ft u_int32_t +.Fn arc4random_uniform "u_int32_t upper_bound" +.Ft void .Fn arc4random_stir "void" .Ft void .Fn arc4random_addrandom "unsigned char *dat" "int datlen" @@ -68,6 +74,21 @@ and .Xr random 3 . .Pp +.Fn arc4random_buf +function fills the region +.Fa buf +of length +.Fa nbytes +with ARC4-derived random data. +.Pp +.Fn arc4random_uniform +will return a uniformly distributed random number less than +.Fa upper_bound . +.Fn arc4random_uniform +is recommended over constructions like +.Dq Li arc4random() % upper_bound +as it avoids "modulo bias" when the upper bound is not a power of two. +.Pp The .Fn arc4random_stir function reads data from @@ -78,10 +99,9 @@ There is no need to call .Fn arc4random_stir before using -.Fn arc4random , -since .Fn arc4random -automatically initializes itself. +functions family, since +they automatically initialize themselves. .Sh EXAMPLES The following produces a drop-in replacement for the traditional .Fn rand ==== //depot/projects/mpsafetty/lib/libc/gen/arc4random.c#2 (text+ko) ==== @@ -1,14 +1,23 @@ /* - * Arc4 random number generator for OpenBSD. - * Copyright 1996 David Mazieres . + * Copyright (c) 1996, David Mazieres + * Copyright (c) 2008, Damien Miller + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * Modification and redistribution in source and binary forms is - * permitted provided that due credit is given to the author and the - * OpenBSD project (for instance by leaving this copyright notice - * intact). + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ /* + * Arc4 random number generator for OpenBSD. + * * This code is derived from section 17.1 of Applied Cryptography, * second edition, which describes a stream cipher allegedly * compatible with RSA Labs "RC4" cipher (the actual description of @@ -24,7 +33,7 @@ */ #include -__FBSDID("$FreeBSD: src/lib/libc/gen/arc4random.c,v 1.12 2007/05/25 10:40:33 delphij Exp $"); +__FBSDID("$FreeBSD: src/lib/libc/gen/arc4random.c,v 1.22 2008/07/22 17:10:18 ache Exp $"); #include "namespace.h" #include @@ -45,7 +54,8 @@ static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; -#define RANDOMDEV "/dev/urandom" +#define RANDOMDEV "/dev/random" +#define KEYSIZE 128 #define THREAD_LOCK() \ do { \ if (__isthreaded) \ @@ -63,94 +73,101 @@ static int rs_stired; static int arc4_count; -static inline u_int8_t arc4_getbyte(struct arc4_stream *); -static void arc4_stir(struct arc4_stream *); +static inline u_int8_t arc4_getbyte(void); +static void arc4_stir(void); static inline void -arc4_init(struct arc4_stream *as) +arc4_init(void) { int n; for (n = 0; n < 256; n++) - as->s[n] = n; - as->i = 0; - as->j = 0; + rs.s[n] = n; + rs.i = 0; + rs.j = 0; } static inline void -arc4_addrandom(struct arc4_stream *as, u_char *dat, int datlen) +arc4_addrandom(u_char *dat, int datlen) { int n; u_int8_t si; - as->i--; + rs.i--; for (n = 0; n < 256; n++) { - as->i = (as->i + 1); - si = as->s[as->i]; - as->j = (as->j + si + dat[n % datlen]); - as->s[as->i] = as->s[as->j]; - as->s[as->j] = si; + rs.i = (rs.i + 1); + si = rs.s[rs.i]; + rs.j = (rs.j + si + dat[n % datlen]); + rs.s[rs.i] = rs.s[rs.j]; + rs.s[rs.j] = si; } + rs.j = rs.i; } static void -arc4_stir(struct arc4_stream *as) +arc4_stir(void) { - int fd, n; + int done, fd, n; struct { - struct timeval tv; - pid_t pid; - u_int8_t rnd[128 - sizeof(struct timeval) - sizeof(pid_t)]; - } rdat; + struct timeval tv; + pid_t pid; + u_int8_t rnd[KEYSIZE]; + } rdat; - gettimeofday(&rdat.tv, NULL); - rdat.pid = getpid(); fd = _open(RANDOMDEV, O_RDONLY, 0); + done = 0; if (fd >= 0) { - (void) _read(fd, rdat.rnd, sizeof(rdat.rnd)); - _close(fd); + if (_read(fd, &rdat, KEYSIZE) == KEYSIZE) + done = 1; + (void)_close(fd); } - /* fd < 0? Ah, what the heck. We'll just take whatever was on the - * stack... */ + if (!done) { + (void)gettimeofday(&rdat.tv, NULL); + rdat.pid = getpid(); + /* We'll just take whatever was on the stack too... */ + } - arc4_addrandom(as, (void *) &rdat, sizeof(rdat)); + arc4_addrandom((u_char *)&rdat, KEYSIZE); /* * Throw away the first N bytes of output, as suggested in the * paper "Weaknesses in the Key Scheduling Algorithm of RC4" - * by Fluher, Mantin, and Shamir. N=1024 is based on + * by Fluher, Mantin, and Shamir. N=768 is based on * suggestions in the paper "(Not So) Random Shuffles of RC4" * by Ilya Mironov. */ - for (n = 0; n < 1024; n++) - (void) arc4_getbyte(as); - arc4_count = 400000; + if (rs_initialized != 1) { + for (n = 0; n < 768; n++) + (void)arc4_getbyte(); + rs_initialized = 1; + } + arc4_count = 1600000; } static inline u_int8_t -arc4_getbyte(struct arc4_stream *as) +arc4_getbyte(void) { u_int8_t si, sj; - as->i = (as->i + 1); - si = as->s[as->i]; - as->j = (as->j + si); - sj = as->s[as->j]; - as->s[as->i] = sj; - as->s[as->j] = si; + rs.i = (rs.i + 1); + si = rs.s[rs.i]; + rs.j = (rs.j + si); + sj = rs.s[rs.j]; + rs.s[rs.i] = sj; + rs.s[rs.j] = si; - return (as->s[(si + sj) & 0xff]); + return (rs.s[(si + sj) & 0xff]); } static inline u_int32_t -arc4_getword(struct arc4_stream *as) +arc4_getword(void) { u_int32_t val; - val = arc4_getbyte(as) << 24; - val |= arc4_getbyte(as) << 16; - val |= arc4_getbyte(as) << 8; - val |= arc4_getbyte(as); + val = arc4_getbyte() << 24; + val |= arc4_getbyte() << 16; + val |= arc4_getbyte() << 8; + val |= arc4_getbyte(); return (val); } @@ -159,16 +176,16 @@ arc4_check_init(void) { if (!rs_initialized) { - arc4_init(&rs); - rs_initialized = 1; + arc4_init(); + rs_initialized = 2; } } -static void +static inline void arc4_check_stir(void) { - if (!rs_stired || --arc4_count == 0) { - arc4_stir(&rs); + if (!rs_stired || arc4_count <= 0) { + arc4_stir(); rs_stired = 1; } } @@ -178,7 +195,8 @@ { THREAD_LOCK(); arc4_check_init(); - arc4_stir(&rs); + arc4_stir(); + rs_stired = 1; THREAD_UNLOCK(); } @@ -188,7 +206,7 @@ THREAD_LOCK(); arc4_check_init(); arc4_check_stir(); - arc4_addrandom(&rs, dat, datlen); + arc4_addrandom(dat, datlen); THREAD_UNLOCK(); } @@ -200,12 +218,77 @@ THREAD_LOCK(); arc4_check_init(); arc4_check_stir(); - rnd = arc4_getword(&rs); + rnd = arc4_getword(); + arc4_count -= 4; THREAD_UNLOCK(); return (rnd); } +void +arc4random_buf(void *_buf, size_t n) +{ + u_char *buf = (u_char *)_buf; + + THREAD_LOCK(); + arc4_check_init(); + while (n--) { + arc4_check_stir(); + buf[n] = arc4_getbyte(); + arc4_count--; + } + THREAD_UNLOCK(); +} + +/* + * Calculate a uniformly distributed random number less than upper_bound + * avoiding "modulo bias". + * + * Uniformity is achieved by generating new random numbers until the one + * returned is outside the range [0, 2**32 % upper_bound). This + * guarantees the selected random number will be inside + * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound) + * after reduction modulo upper_bound. + */ +u_int32_t +arc4random_uniform(u_int32_t upper_bound) +{ + u_int32_t r, min; + + if (upper_bound < 2) + return (0); + + /* Detect simple power of two case */ + if ((upper_bound & -upper_bound) == upper_bound) + return (arc4random() % upper_bound); + +#if (ULONG_MAX > 0xffffffffUL) + min = 0x100000000UL % upper_bound; +#else + /* Calculate (2**32 % upper_bound) avoiding 64-bit math */ + if (upper_bound > 0x80000000) + min = 1 + ~upper_bound; /* 2**32 - upper_bound */ + else { + /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */ + min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound; + } +#endif + + /* + * This could theoretically loop forever but each retry has + * p > 0.5 (worst case, usually far better) of selecting a + * number inside the range we need, so it should rarely need + * to re-roll. + */ + for (;;) { + r = arc4random(); + if (r >= min) + break; + } + + return (r % upper_bound); +} + #if 0 /*-------- Test code for i386 --------*/ #include ==== //depot/projects/mpsafetty/lib/libc/stdio/mktemp.c#2 (text+ko) ==== @@ -31,7 +31,7 @@ static char sccsid[] = "@(#)mktemp.c 8.1 (Berkeley) 6/4/93"; #endif /* LIBC_SCCS and not lint */ #include -__FBSDID("$FreeBSD: src/lib/libc/stdio/mktemp.c,v 1.29 2007/01/09 00:28:07 imp Exp $"); +__FBSDID("$FreeBSD: src/lib/libc/stdio/mktemp.c,v 1.30 2008/07/22 15:08:50 ache Exp $"); #include "namespace.h" #include @@ -125,7 +125,7 @@ /* Fill space with random characters */ while (trv >= path && *trv == 'X') { - rand = arc4random() % (sizeof(padchar) - 1); + rand = arc4random_uniform(sizeof(padchar) - 1); *trv-- = padchar[rand]; } start = trv + 1; ==== //depot/projects/mpsafetty/release/doc/en_US.ISO8859-1/relnotes/article.sgml#2 (text+ko) ==== @@ -17,7 +17,7 @@ The &os; Project - $FreeBSD: src/release/doc/en_US.ISO8859-1/relnotes/article.sgml,v 1.1090 2008/06/05 13:37:40 rafan Exp $ + $FreeBSD: src/release/doc/en_US.ISO8859-1/relnotes/article.sgml,v 1.1091 2008/07/22 05:02:46 bmah Exp $ 2000 @@ -170,7 +170,8 @@ kse library was never developed to its full potential. Backwards compatibility for applications using KSE threading will be provided via &man.libmap.conf.5; for dynamically linked - binaries. + binaries. The &os; Project greatly appreciates the work of + &a.julian; and &a.deischen; on KSE support. The &os; kernel now exports information about certain kernel features via the kern.features sysctl tree. ==== //depot/projects/mpsafetty/share/man/man4/ddb.4#4 (text+ko) ==== @@ -58,9 +58,9 @@ .\" Created. .\" [90/08/30 dbg] .\" -.\" $FreeBSD: src/share/man/man4/ddb.4,v 1.54 2008/07/07 21:32:02 bz Exp $ +.\" $FreeBSD: src/share/man/man4/ddb.4,v 1.55 2008/07/21 10:03:02 maxim Exp $ .\" -.Dd July 7, 2008 +.Dd July 21, 2008 .Dt DDB 4 .Os .Sh NAME @@ -584,6 +584,11 @@ Show brief information about the TTY subsystem. .\" .Pp +.It Ic show Cm conifhk +Lists hooks currently waiting for completion in +run_interrupt_driven_config_hooks(). +.\" +.Pp .It Ic show Cm cpusets Print numbered root and assigned CPU affinity sets. See ==== //depot/projects/mpsafetty/share/man/man9/sysctl.9#2 (text) ==== @@ -23,7 +23,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/share/man/man9/sysctl.9,v 1.8 2006/12/14 14:33:13 mpp Exp $ +.\" $FreeBSD: src/share/man/man9/sysctl.9,v 1.9 2008/07/21 15:05:25 pjd Exp $ .\" .Dd November 23, 2006 .Dt SYSCTL 9 @@ -40,7 +40,8 @@ .Nm SYSCTL_UINT , .Nm SYSCTL_ULONG , .Nm SYSCTL_XINT , -.Nm SYSCTL_XLONG +.Nm SYSCTL_XLONG , +.Nm SYSCTL_QUAD .Nd Static sysctl declaration functions .Sh SYNOPSIS .In sys/types.h @@ -57,6 +58,7 @@ .Fn SYSCTL_ULONG parent nbr name access ptr val descr .Fn SYSCTL_XINT parent nbr name access ptr val descr .Fn SYSCTL_XLONG parent nbr name access ptr val descr +.Fn SYSCTL_QUAD parent nbr name access ptr val descr .Sh DESCRIPTION The .Nm SYSCTL @@ -83,8 +85,9 @@ .Fn SYSCTL_UINT , .Fn SYSCTL_ULONG , .Fn SYSCTL_XINT , +.Fn SYSCTL_XLONG , and -.Fn SYSCTL_XLONG . +.Fn SYSCTL_QUAD . Each macro accepts a parent name, as declared using .Fn SYSCTL_DECL , an OID number, typically ==== //depot/projects/mpsafetty/share/man/man9/sysctl_add_oid.9#2 (text+ko) ==== @@ -25,7 +25,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD: src/share/man/man9/sysctl_add_oid.9,v 1.21 2006/04/28 10:45:27 rwatson Exp $ +.\" $FreeBSD: src/share/man/man9/sysctl_add_oid.9,v 1.22 2008/07/21 15:05:25 pjd Exp $ .\" .Dd July 15, 2000 .Dt SYSCTL_ADD_OID 9 @@ -147,6 +147,16 @@ .Fa "const char *descr" .Fc .Ft struct sysctl_oid * +.Fo SYSCTL_ADD_QUAD +.Fa "struct sysctl_ctx_list *ctx" +.Fa "struct sysctl_oid_list *parent" +.Fa "int number" +.Fa "const char *name" +.Fa "int access" +.Fa "int64_t *arg" +.Fa "const char *descr" +.Fc +.Ft struct sysctl_oid * .Fo SYSCTL_ADD_OPAQUE .Fa "struct sysctl_ctx_list *ctx" .Fa "struct sysctl_oid_list *parent" @@ -430,6 +440,10 @@ creates an oid that handles an .Li unsigned long variable. +.It Fn SYSCTL_ADD_QUAD +creates an oid that handles an +.Li int64_t +variable. .It Fn SYSCTL_ADD_OPAQUE creates an oid that handles any chunk of opaque data of the size specified by the ==== //depot/projects/mpsafetty/share/misc/committers-src.dot#3 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/share/misc/committers-src.dot,v 1.80 2008/07/08 15:36:44 sson Exp $ +# $FreeBSD: src/share/misc/committers-src.dot,v 1.81 2008/07/22 16:01:57 vanhu Exp $ # This file is meant to list all FreeBSD src committers and describe the # mentor-mentee relationships between them. @@ -168,6 +168,7 @@ ticso [label="Bernd Walter\nticso@FreeBSD.org\n2002/01/31"] trhodes [label="Tom Rhodes\ntrhodes@FreeBSD.org\n2002/05/28"] ume [label="Hajimu UMEMOTO\nume@FreeBSD.org\n2000/02/26"] +vanhu [label="Yvan Vanhullebus\nvanhu@FreeBSD.org\n2008/07/21"] weongyo [label="Weongyo Jeong\nweongyo@FreeBSD.org\n2007/12/21"] wes [label="Wes Peters\nwes@FreeBSD.org\n1998/11/25"] wilko [label="Wilko Bulte\nwilko@FreeBSD.org\n2000/01/13"] @@ -244,6 +245,7 @@ gnn -> jinmei gnn -> rrs gnn -> ivoras +gnn -> vanhu grog -> edwin grog -> le ==== //depot/projects/mpsafetty/sys/arm/at91/at91_pmc.c#2 (text) ==== @@ -25,7 +25,7 @@ #include "opt_at91.h" #include -__FBSDID("$FreeBSD: src/sys/arm/at91/at91_pmc.c,v 1.5 2007/09/16 07:51:02 imp Exp $"); +__FBSDID("$FreeBSD: src/sys/arm/at91/at91_pmc.c,v 1.6 2008/07/22 14:04:06 stas Exp $"); #include #include @@ -259,44 +259,44 @@ static uint32_t at91_pmc_pll_calc(uint32_t main_freq, uint32_t out_freq) { - uint32_t i, div = 0, mul = 0, diff = 1 << 30; - unsigned ret = (out_freq > PMC_PLL_FAST_THRESH) ? 0xbe00 : 0x3e00; + uint32_t i, div = 0, mul = 0, diff = 1 << 30; + unsigned ret = (out_freq > PMC_PLL_FAST_THRESH) ? 0xbe00 : 0x3e00; - if (out_freq > PMC_PLL_MAX_OUT_FREQ) - goto fail; + if (out_freq > PMC_PLL_MAX_OUT_FREQ) + goto fail; - for (i = 1; i < 256; i++) { - int32_t diff1; - uint32_t input, mul1; + for (i = 1; i < 256; i++) { + int32_t diff1; + uint32_t input, mul1; - input = main_freq / i; - if (input < PMC_PLL_MIN_IN_FREQ) - break; - if (input > PMC_PLL_MAX_IN_FREQ) - continue; + input = main_freq / i; + if (input < PMC_PLL_MIN_IN_FREQ) + break; + if (input > PMC_PLL_MAX_IN_FREQ) + continue; - mul1 = out_freq / input; - if (mul1 > PMC_PLL_MULT_MAX) - continue; - if (mul1 < PMC_PLL_MULT_MIN) - break; + mul1 = out_freq / input; + if (mul1 > PMC_PLL_MULT_MAX) + continue; + if (mul1 < PMC_PLL_MULT_MIN) + break; - diff1 = out_freq - input * mul1; + diff1 = out_freq - input * mul1; if (diff1 < 0) - diff1 = -diff1; - if (diff > diff1) { - diff = diff1; - div = i; - mul = mul1; - if (diff == 0) - break; - } - } - if (diff > (out_freq >> PMC_PLL_SHIFT_TOL)) + diff1 = -diff1; + if (diff > diff1) { + diff = diff1; + div = i; + mul = mul1; + if (diff == 0) + break; + } + } + if (diff > (out_freq >> PMC_PLL_SHIFT_TOL)) goto fail; return ret | ((mul - 1) << 16) | div; fail: - return 0; + return 0; } static void @@ -313,12 +313,12 @@ * Initialize the usb clock. This sets up pllb, but disables the * actual clock. */ - sc->pllb_init = at91_pmc_pll_calc(main_clock, 48000000 * 2) |0x10000000; - pllb.hz = at91_pmc_pll_rate(main_clock, sc->pllb_init, 1); - WR4(sc, PMC_PCDR, (1 << AT91RM92_IRQ_UHP) | (1 << AT91RM92_IRQ_UDP)); - WR4(sc, PMC_SCDR, PMC_SCER_UHP | PMC_SCER_UDP); - WR4(sc, CKGR_PLLBR, 0); - WR4(sc, PMC_SCER, PMC_SCER_MCKUDP); + sc->pllb_init = at91_pmc_pll_calc(main_clock, 48000000 * 2) |0x10000000; + pllb.hz = at91_pmc_pll_rate(main_clock, sc->pllb_init, 1); + WR4(sc, PMC_PCDR, (1 << AT91RM92_IRQ_UHP) | (1 << AT91RM92_IRQ_UDP)); + WR4(sc, PMC_SCDR, PMC_SCER_UHP | PMC_SCER_UDP); + WR4(sc, CKGR_PLLBR, 0); + WR4(sc, PMC_SCER, PMC_SCER_MCKUDP); /* * MCK and PCU derive from one of the primary clocks. Initialize ==== //depot/projects/mpsafetty/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c#2 (text+ko) ==== @@ -25,7 +25,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c,v 1.10 2008/03/28 22:16:05 jb Exp $"); +__FBSDID("$FreeBSD: src/sys/cddl/compat/opensolaris/kern/opensolaris_vfs.c,v 1.11 2008/07/21 09:45:44 pjd Exp $"); #include #include @@ -100,7 +100,7 @@ int vfs_optionisset(const vfs_t *vfsp, const char *opt, char **argp) { - struct vfsoptlist *opts = vfsp->mnt_opt; + struct vfsoptlist *opts = vfsp->mnt_optnew; int error; if (opts == NULL) ==== //depot/projects/mpsafetty/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_zfetch.c#2 (text+ko) ==== @@ -196,7 +196,7 @@ break; } zs->zst_ph_offset = prefetch_tail; - zs->zst_last = lbolt; + zs->zst_last = LBOLT; } /* @@ -517,7 +517,7 @@ for (zs = list_head(&zf->zf_stream); zs; zs = list_next(&zf->zf_stream, zs)) { - if (((lbolt - zs->zst_last) / hz) > zfetch_min_sec_reap) + if (((LBOLT - zs->zst_last) / hz) > zfetch_min_sec_reap) break; } @@ -639,7 +639,7 @@ newstream->zst_ph_offset = zst.zst_len + zst.zst_offset; newstream->zst_cap = zst.zst_len; newstream->zst_direction = ZFETCH_FORWARD; - newstream->zst_last = lbolt; + newstream->zst_last = LBOLT; mutex_init(&newstream->zst_lock, NULL, MUTEX_DEFAULT, NULL); ==== //depot/projects/mpsafetty/sys/conf/kern.mk#2 (text+ko) ==== @@ -1,4 +1,4 @@ -# $FreeBSD: src/sys/conf/kern.mk,v 1.55 2008/06/25 21:33:28 ru Exp $ +# $FreeBSD: src/sys/conf/kern.mk,v 1.56 2008/07/22 09:38:12 cognet Exp $ # # Warning flags for compiling the kernel and components of the kernel. @@ -110,6 +110,7 @@ # # GCC SSP support. # -.if ${MK_SSP} != "no" && ${CC} != "icc" && ${MACHINE_ARCH} != "ia64" +.if ${MK_SSP} != "no" && ${CC} != "icc" && ${MACHINE_ARCH} != "ia64" && \ + ${MACHINE_ARCH} != "arm" CFLAGS+= -fstack-protector .endif ==== //depot/projects/mpsafetty/sys/dev/amr/amr.c#2 (text+ko) ==== @@ -56,7 +56,7 @@ */ #include -__FBSDID("$FreeBSD: src/sys/dev/amr/amr.c,v 1.85 2008/01/24 07:26:53 scottl Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/amr/amr.c,v 1.86 2008/07/20 16:50:14 scottl Exp $"); /* * Driver for the AMI MegaRaid family of controllers. @@ -2082,8 +2082,11 @@ int i = 0; mtx_lock(&sc->amr_hw_lock); - while (sc->amr_mailbox->mb_busy && (i++ < 10)) + while (sc->amr_mailbox->mb_busy && (i++ < 10)) { DELAY(1); + /* This is a no-op read that flushes pending mailbox updates */ + AMR_QGET_ODB(sc); + } if (sc->amr_mailbox->mb_busy) { mtx_unlock(&sc->amr_hw_lock); if (ac->ac_retries++ > 1000) { ==== //depot/projects/mpsafetty/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c#3 (text+ko) ==== @@ -28,7 +28,7 @@ ***************************************************************************/ #include -__FBSDID("$FreeBSD: src/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c,v 1.12 2008/07/18 06:12:31 kmacy Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c,v 1.15 2008/07/21 21:23:43 kmacy Exp $"); #include #include @@ -414,13 +414,18 @@ snd->sb_sndptroff += bytes; total_bytes += bytes; >>> TRUNCATED FOR MAIL (1000 lines) <<<