CVS commit: src/libexec/httpd
Module Name:src Committed By: elric Date: Mon Feb 20 08:40:46 UTC 2012 Modified Files: src/libexec/httpd: ssl-bozo.c Log Message: Use a ``certificate chain file'' rather than a ``certificate file'' so that bozohttpd can be used with non-toplevel certs. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/libexec/httpd/ssl-bozo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/httpd/ssl-bozo.c diff -u src/libexec/httpd/ssl-bozo.c:1.13 src/libexec/httpd/ssl-bozo.c:1.14 --- src/libexec/httpd/ssl-bozo.c:1.13 Fri Nov 18 09:51:31 2011 +++ src/libexec/httpd/ssl-bozo.c Mon Feb 20 08:40:46 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ssl-bozo.c,v 1.13 2011/11/18 09:51:31 mrg Exp $ */ +/* $NetBSD: ssl-bozo.c,v 1.14 2012/02/20 08:40:46 elric Exp $ */ /* $eterna: ssl-bozo.c,v 1.15 2011/11/18 09:21:15 mrg Exp $ */ @@ -176,8 +176,8 @@ bozo_ssl_init(bozohttpd_t *httpd) bozo_ssl_err(httpd, EXIT_FAILURE, SSL context creation failed); - if (1 != SSL_CTX_use_certificate_file(sslinfo-ssl_context, - sslinfo-certificate_file, SSL_FILETYPE_PEM)) + if (1 != SSL_CTX_use_certificate_chain_file(sslinfo-ssl_context, + sslinfo-certificate_file)) bozo_ssl_err(httpd, EXIT_FAILURE, Unable to use certificate file '%s', sslinfo-certificate_file);
CVS commit: src/libexec/httpd
Module Name:src Committed By: elric Date: Mon Feb 20 09:26:56 UTC 2012 Modified Files: src/libexec/httpd: bozohttpd.8 bozohttpd.c bozohttpd.h Log Message: Check in very basic compressed file support. httpd will now serve a precompressed .gz file if it exists, the client claims to support gzip and the request is not ranged. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/libexec/httpd/bozohttpd.8 cvs rdiff -u -r1.30 -r1.31 src/libexec/httpd/bozohttpd.c cvs rdiff -u -r1.20 -r1.21 src/libexec/httpd/bozohttpd.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/httpd/bozohttpd.8 diff -u src/libexec/httpd/bozohttpd.8:1.32 src/libexec/httpd/bozohttpd.8:1.33 --- src/libexec/httpd/bozohttpd.8:1.32 Fri Nov 18 09:51:31 2011 +++ src/libexec/httpd/bozohttpd.8 Mon Feb 20 09:26:56 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: bozohttpd.8,v 1.32 2011/11/18 09:51:31 mrg Exp $ +.\ $NetBSD: bozohttpd.8,v 1.33 2012/02/20 09:26:56 elric Exp $ .\ .\ $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $ .\ @@ -408,6 +408,13 @@ To disable SSL SUPPORT compile with .Dq -DNO_SSL_SUPPORT on the compiler command line. +.Ss COMPRESSION +.Nm +supports a very basic form compression. +.Nm +will serve the requested file postpended with ``.gz'' if +it exists, it is readable, the client requested gzip compression, and +the client did not make a ranged request. .Sh FILES .Nm looks for a couple of special files in directories that allow certain features Index: src/libexec/httpd/bozohttpd.c diff -u src/libexec/httpd/bozohttpd.c:1.30 src/libexec/httpd/bozohttpd.c:1.31 --- src/libexec/httpd/bozohttpd.c:1.30 Fri Nov 18 09:51:31 2011 +++ src/libexec/httpd/bozohttpd.c Mon Feb 20 09:26:56 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: bozohttpd.c,v 1.30 2011/11/18 09:51:31 mrg Exp $ */ +/* $NetBSD: bozohttpd.c,v 1.31 2012/02/20 09:26:56 elric Exp $ */ /* $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $ */ @@ -696,6 +696,9 @@ bozo_read_request(bozohttpd_t *httpd) else if (strcasecmp(hdr-h_header, if-modified-since) == 0) request-hr_if_modified_since = hdr-h_value; + else if (strcasecmp(hdr-h_header, + accept-encoding) == 0) +request-hr_accept_encoding = hdr-h_value; debug((httpd, DEBUG_FAT, adding header %s: %s, hdr-h_header, hdr-h_value)); @@ -1350,6 +1353,53 @@ bad_done: } /* + * can_gzip checks if the request supports and prefers gzip encoding. + * + * XXX: we do not consider the associated q with gzip in making our + * decision which is broken. + */ + +static int +can_gzip(bozo_httpreq_t *request) +{ + const char *pos; + const char *tmp; + size_t len; + + /* First we decide if the request can be gzipped at all. */ + + /* not if we already are encoded... */ + tmp = bozo_content_encoding(request, request-hr_file); + if (tmp *tmp) + return 0; + + /* not if we are not asking for the whole file... */ + if (request-hr_last_byte_pos != -1 || request-hr_have_range) + return 0; + + /* Then we determine if gzip is on the cards. */ + + for (pos = request-hr_accept_encoding; pos *pos; pos += len) { + while (*pos == ' ') + pos++; + + len = strcspn(pos, ;,); + + if ((len == 4 strncasecmp(gzip, pos, 4) == 0) || + (len == 6 strncasecmp(x-gzip, pos, 6) == 0)) + return 1; + + if (pos[len] == ';') + len += strcspn(pos[len], ,); + + if (pos[len]) + len++; + } + + return 0; +} + +/* * bozo_process_request does the following: * - check the request is valid * - process cgi-bin if necessary @@ -1374,9 +1424,21 @@ bozo_process_request(bozo_httpreq_t *req if (transform_request(request, isindex) == 0) return; + fd = -1; + encoding = NULL; + if (can_gzip(request)) { + asprintf(file, %s.gz, request-hr_file); + fd = open(file, O_RDONLY); + if (fd = 0) + encoding = gzip; + free(file); + } + file = request-hr_file; - fd = open(file, O_RDONLY); + if (fd 0) + fd = open(file, O_RDONLY); + if (fd 0) { debug((httpd, DEBUG_FAT, open failed: %s, strerror(errno))); if (errno == EPERM) @@ -1432,7 +1494,8 @@ bozo_process_request(bozo_httpreq_t *req if (request-hr_proto != httpd-consts.http_09) { type = bozo_content_type(request, file); - encoding = bozo_content_encoding(request, file); + if (!encoding) + encoding = bozo_content_encoding(request, file); bozo_print_header(request, sb, type, encoding); bozo_printf(httpd, \r\n); Index: src/libexec/httpd/bozohttpd.h diff -u src/libexec/httpd/bozohttpd.h:1.20 src/libexec/httpd/bozohttpd.h:1.21 --- src/libexec/httpd/bozohttpd.h:1.20 Fri Nov 18 09:51:31 2011 +++ src/libexec/httpd/bozohttpd.h Mon Feb 20 09:26:56 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: bozohttpd.h,v 1.20 2011/11/18 09:51:31 mrg Exp $ */ +/* $NetBSD: bozohttpd.h,v 1.21 2012/02/20 09:26:56 elric Exp $ */ /* $eterna: bozohttpd.h,v 1.39 2011/11/18 09:21:15 mrg Exp $ */ @@ -128,6 +128,7 @@ typedef struct
CVS commit: src/include
Module Name:src Committed By: martin Date: Mon Feb 20 09:28:43 UTC 2012 Modified Files: src/include: spawn.h Log Message: Add missing __BEGIN_DECLS, from Henning Petersen in PR misc/46058. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/include/spawn.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/include/spawn.h diff -u src/include/spawn.h:1.1 src/include/spawn.h:1.2 --- src/include/spawn.h:1.1 Sat Feb 11 23:31:24 2012 +++ src/include/spawn.h Mon Feb 20 09:28:43 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: spawn.h,v 1.1 2012/02/11 23:31:24 martin Exp $ */ +/* $NetBSD: spawn.h,v 1.2 2012/02/20 09:28:43 martin Exp $ */ /*- * Copyright (c) 2008 Ed Schouten e...@freebsd.org @@ -33,6 +33,7 @@ #include sys/spawn.h +__BEGIN_DECLS /* * Spawn routines *
CVS commit: src/libexec/httpd
Module Name:src Committed By: wiz Date: Mon Feb 20 09:45:22 UTC 2012 Modified Files: src/libexec/httpd: bozohttpd.8 Log Message: Bump date for previous. Use more markup. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/libexec/httpd/bozohttpd.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/httpd/bozohttpd.8 diff -u src/libexec/httpd/bozohttpd.8:1.33 src/libexec/httpd/bozohttpd.8:1.34 --- src/libexec/httpd/bozohttpd.8:1.33 Mon Feb 20 09:26:56 2012 +++ src/libexec/httpd/bozohttpd.8 Mon Feb 20 09:45:22 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: bozohttpd.8,v 1.33 2012/02/20 09:26:56 elric Exp $ +.\ $NetBSD: bozohttpd.8,v 1.34 2012/02/20 09:45:22 wiz Exp $ .\ .\ $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $ .\ @@ -26,7 +26,7 @@ .\ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd November 17, 2011 +.Dd February 20, 2012 .Dt HTTPD 8 .Os .Sh NAME @@ -412,8 +412,9 @@ on the compiler command line. .Nm supports a very basic form compression. .Nm -will serve the requested file postpended with ``.gz'' if -it exists, it is readable, the client requested gzip compression, and +will serve the requested file postpended with +.Dq Pa .gz +if it exists, it is readable, the client requested gzip compression, and the client did not make a ranged request. .Sh FILES .Nm
CVS commit: src/sys/kern
Module Name:src Committed By: martin Date: Mon Feb 20 12:19:56 UTC 2012 Modified Files: src/sys/kern: kern_exec.c Log Message: More posix_spawn fallout: Fix a kmem_alloc() call with zero size (PR kern/46038), allow file actions to be passed, even if empty. Rearange p_reflock locking for the child, avoid a double free in an error case, avoid a memory leak in another error case - all pointed out by yamt. During blocking operations early in the child borrow the kernel vmspace (as suggested by yamt). To generate a diff of this commit: cvs rdiff -u -r1.340 -r1.341 src/sys/kern/kern_exec.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/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.340 src/sys/kern/kern_exec.c:1.341 --- src/sys/kern/kern_exec.c:1.340 Sun Feb 19 21:06:49 2012 +++ src/sys/kern/kern_exec.c Mon Feb 20 12:19:55 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.340 2012/02/19 21:06:49 rmind Exp $ */ +/* $NetBSD: kern_exec.c,v 1.341 2012/02/20 12:19:55 martin Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.340 2012/02/19 21:06:49 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.341 2012/02/20 12:19:55 martin Exp $); #include opt_exec.h #include opt_ktrace.h @@ -1312,8 +1312,7 @@ execve_runproc(struct lwp *l, struct exe ktremul(); /* Allow new references from the debugger/procfs. */ - if (!proc_is_new) - rw_exit(p-p_reflock); + rw_exit(p-p_reflock); rw_exit(exec_lock); mutex_enter(proc_lock); @@ -1738,6 +1737,20 @@ spawn_return(void *arg) size_t i; const struct posix_spawn_file_actions_entry *fae; register_t retval; + bool have_reflock; + + /* + * The following actions may block, so we need a temporary + * vmspace - borrow the kernel one + */ + KPREEMPT_DISABLE(l); + l-l_proc-p_vmspace = proc0.p_vmspace; + pmap_activate(l); + KPREEMPT_ENABLE(l); + + /* don't allow debugger access yet */ + rw_enter(l-l_proc-p_reflock, RW_WRITER); + have_reflock = true; error = 0; /* handle posix_spawn_file_actions */ @@ -1852,18 +1865,17 @@ spawn_return(void *arg) } } - if (spawn_data-sed_actions != NULL) { - for (i = 0; i spawn_data-sed_actions_len; i++) { - fae = spawn_data-sed_actions[i]; - if (fae-fae_action == FAE_OPEN) -kmem_free(fae-fae_path, -strlen(fae-fae_path)+1); - } - } + /* stop using kernel vmspace */ + KPREEMPT_DISABLE(l); + pmap_deactivate(l); + l-l_proc-p_vmspace = NULL; + KPREEMPT_ENABLE(l); + /* now do the real exec */ rw_enter(exec_lock, RW_READER); error = execve_runproc(l, spawn_data-sed_exec); + have_reflock = false; if (error == EJUSTRETURN) error = 0; else if (error) @@ -1881,13 +1893,15 @@ spawn_return(void *arg) return; report_error: - if (spawn_data-sed_actions != NULL) { - for (i = 0; i spawn_data-sed_actions_len; i++) { - fae = spawn_data-sed_actions[i]; - if (fae-fae_action == FAE_OPEN) -kmem_free(fae-fae_path, -strlen(fae-fae_path)+1); - } + if (have_reflock) + rw_exit(l-l_proc-p_reflock); + + /* stop using kernel vmspace (if we haven't already) */ + if (l-l_proc-p_vmspace) { + KPREEMPT_DISABLE(l); + pmap_deactivate(l); + l-l_proc-p_vmspace = NULL; + KPREEMPT_ENABLE(l); } /* @@ -1968,27 +1982,31 @@ sys_posix_spawn(struct lwp *l1, const st fa-fae = NULL; goto error_exit; } - ufa = fa-fae; - fa-fae = kmem_alloc(fa-len * - sizeof(struct posix_spawn_file_actions_entry), KM_SLEEP); - error = copyin(ufa, fa-fae, - fa-len * sizeof(struct posix_spawn_file_actions_entry)); - if (error) - goto error_exit; - for (i = 0; i fa-len; i++) { - if (fa-fae[i].fae_action == FAE_OPEN) { -char buf[PATH_MAX]; -error = copyinstr(fa-fae[i].fae_path, buf, - sizeof(buf), NULL); -if (error) - break; -fa-fae[i].fae_path = kmem_alloc(strlen(buf)+1, - KM_SLEEP); -if (fa-fae[i].fae_path == NULL) { - error = ENOMEM; - break; + if (fa-len) { + ufa = fa-fae; + fa-fae = kmem_alloc(fa-len * + sizeof(struct posix_spawn_file_actions_entry), + KM_SLEEP); + error = copyin(ufa, fa-fae, + fa-len * + sizeof(struct posix_spawn_file_actions_entry)); + if (error) +goto error_exit; + for (i = 0; i fa-len; i++) { +if (fa-fae[i].fae_action == FAE_OPEN) { + char buf[PATH_MAX]; + error = copyinstr(fa-fae[i].fae_path, + buf, sizeof(buf), NULL); + if (error) + break; + fa-fae[i].fae_path = kmem_alloc( + strlen(buf)+1, KM_SLEEP); + if (fa-fae[i].fae_path == NULL) { + error = ENOMEM; + break; + } + strcpy(fa-fae[i].fae_path, buf); } -strcpy(fa-fae[i].fae_path, buf); } } } @@ -2144,8 +2162,10 @@ sys_posix_spawn(struct lwp *l1, const st * Prepare remaining parts of spawn data */ if
CVS commit: src/sys/uvm
Module Name:src Committed By: martin Date: Mon Feb 20 12:21:24 UTC 2012 Modified Files: src/sys/uvm: uvm_glue.c Log Message: Solve previous fix (for early posix_spawn children exiting on error) differently. To generate a diff of this commit: cvs rdiff -u -r1.156 -r1.157 src/sys/uvm/uvm_glue.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/uvm/uvm_glue.c diff -u src/sys/uvm/uvm_glue.c:1.156 src/sys/uvm/uvm_glue.c:1.157 --- src/sys/uvm/uvm_glue.c:1.156 Sun Feb 12 11:18:04 2012 +++ src/sys/uvm/uvm_glue.c Mon Feb 20 12:21:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_glue.c,v 1.156 2012/02/12 11:18:04 martin Exp $ */ +/* $NetBSD: uvm_glue.c,v 1.157 2012/02/20 12:21:23 martin Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -62,7 +62,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: uvm_glue.c,v 1.156 2012/02/12 11:18:04 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: uvm_glue.c,v 1.157 2012/02/20 12:21:23 martin Exp $); #include opt_kgdb.h #include opt_kstack.h @@ -416,14 +416,13 @@ uvm_proc_exit(struct proc *p) KASSERT(p == l-l_proc); ovm = p-p_vmspace; - if (__predict_false(ovm == NULL)) - return; /* * borrow proc0's address space. */ KPREEMPT_DISABLE(l); - pmap_deactivate(l); + if (__predict_true(ovm != NULL)) + pmap_deactivate(l); p-p_vmspace = proc0.p_vmspace; pmap_activate(l); KPREEMPT_ENABLE(l);
CVS commit: src/tests/lib/libc/gen/posix_spawn
Module Name:src Committed By: martin Date: Mon Feb 20 12:22:40 UTC 2012 Modified Files: src/tests/lib/libc/gen/posix_spawn: t_fileactions.c Log Message: Add a test case to call posix_spawn with empty file actions, which reproduced the (now fixed) PR kern/46038. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/posix_spawn/t_fileactions.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/gen/posix_spawn/t_fileactions.c diff -u src/tests/lib/libc/gen/posix_spawn/t_fileactions.c:1.2 src/tests/lib/libc/gen/posix_spawn/t_fileactions.c:1.3 --- src/tests/lib/libc/gen/posix_spawn/t_fileactions.c:1.2 Tue Feb 14 00:13:54 2012 +++ src/tests/lib/libc/gen/posix_spawn/t_fileactions.c Mon Feb 20 12:22:40 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: t_fileactions.c,v 1.2 2012/02/14 00:13:54 martin Exp $ */ +/* $NetBSD: t_fileactions.c,v 1.3 2012/02/20 12:22:40 martin Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -279,12 +279,57 @@ ATF_TC_BODY(t_spawn_fileactions, tc) ATF_REQUIRE(WIFEXITED(status) WEXITSTATUS(status) == EXIT_SUCCESS); } +ATF_TC(t_spawn_empty_fileactions); + +ATF_TC_HEAD(t_spawn_empty_fileactions, tc) +{ + atf_tc_set_md_var(tc, descr, + posix_spawn with empty fileactions (PR kern/46038)); + atf_tc_set_md_var(tc, require.progs, /bin/cat); +} + +ATF_TC_BODY(t_spawn_empty_fileactions, tc) +{ + int status, err; + pid_t pid; + char * const args[2] = { __UNCONST(cat), NULL }; + posix_spawn_file_actions_t fa; + size_t insize, outsize; + + /* + * try a cat testfile checkfile, but set up stdin/stdout + * already in the parent and pass empty file actions to the child. + */ + make_testfile(TESTFILE); + unlink(CHECKFILE); + + freopen(TESTFILE, r, stdin); + freopen(CHECKFILE, w, stdout); + + posix_spawn_file_actions_init(fa); + err = posix_spawn(pid, /bin/cat, fa, NULL, args, NULL); + posix_spawn_file_actions_destroy(fa); + + ATF_REQUIRE(err == 0); + + /* ok, wait for the child to finish */ + waitpid(pid, status, 0); + ATF_REQUIRE(WIFEXITED(status) WEXITSTATUS(status) == EXIT_SUCCESS); + + /* now check that input and output have the same size */ + insize = filesize(TESTFILE); + outsize = filesize(CHECKFILE); + ATF_REQUIRE(insize == strlen(TESTCONTENT)); + ATF_REQUIRE(insize == outsize); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_spawn_fileactions); ATF_TP_ADD_TC(tp, t_spawn_open_nonexistent); ATF_TP_ADD_TC(tp, t_spawn_reopen); ATF_TP_ADD_TC(tp, t_spawn_openmode); + ATF_TP_ADD_TC(tp, t_spawn_empty_fileactions); return atf_no_error(); }
CVS commit: src/sys/kern
Module Name:src Committed By: christos Date: Mon Feb 20 18:18:30 UTC 2012 Modified Files: src/sys/kern: kern_exec.c Log Message: Posix spawn fixes: - split the file actions allocation and freeing into separate functions - use pnbuf - don't play games with pointers (partially freeing stuff etc), only check fa and sa and free as needed using the same code. - use copyinstr properly - KM_SLEEP allocation can't fail - if path allocation failed midway, we would be possibily freeing userland strings. - use sizeof(*var) instead sizeof(type) To generate a diff of this commit: cvs rdiff -u -r1.341 -r1.342 src/sys/kern/kern_exec.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/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.341 src/sys/kern/kern_exec.c:1.342 --- src/sys/kern/kern_exec.c:1.341 Mon Feb 20 07:19:55 2012 +++ src/sys/kern/kern_exec.c Mon Feb 20 13:18:30 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.341 2012/02/20 12:19:55 martin Exp $ */ +/* $NetBSD: kern_exec.c,v 1.342 2012/02/20 18:18:30 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.341 2012/02/20 12:19:55 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.342 2012/02/20 18:18:30 christos Exp $); #include opt_exec.h #include opt_ktrace.h @@ -1916,6 +1916,72 @@ spawn_return(void *arg) exit1(l, W_EXITCODE(error, SIGABRT)); } +static void +posix_spawn_fa_free(struct posix_spawn_file_actions *fa) +{ + + for (size_t i = 0; i fa-len; i++) { + struct posix_spawn_file_actions_entry *fae = fa-fae[i]; + if (fae-fae_action != FAE_OPEN) + continue; + kmem_free(fae-fae_path, strlen(fae-fae_path) + 1); + } + kmem_free(fa-fae, sizeof(*fa-fae)); + kmem_free(fa, sizeof(*fa)); +} + +static int +posix_spawn_fa_alloc(struct posix_spawn_file_actions **fap, +const struct posix_spawn_file_actions *ufa) +{ + struct posix_spawn_file_actions *fa; + struct posix_spawn_file_actions_entry *fae; + char *pbuf = NULL; + int error; + + fa = kmem_alloc(sizeof(*fa), KM_SLEEP); + error = copyin(ufa, fa, sizeof(*fa)); + if (error) { + fa-fae = NULL; + fa-len = 0; + goto out; + } + + if (fa-len == 0) + return 0; + + size_t fal = fa-len * sizeof(*fae); + fae = fa-fae; + fa-fae = kmem_alloc(fal, KM_SLEEP); + error = copyin(fae, fa-fae, fal); + if (error) { + fa-len = 0; + goto out; + } + + pbuf = PNBUF_GET(); + for (size_t i = 0; i fa-len; i++) { + fae = fa-fae[i]; + if (fae-fae_action != FAE_OPEN) + continue; + error = copyinstr(fae-fae_path, pbuf, MAXPATHLEN, fal); + if (error) { + fa-len = i; + goto out; + } + fae-fae_path = kmem_alloc(fal, KM_SLEEP); + memcpy(fae-fae_path, pbuf, fal); + } + PNBUF_PUT(pbuf); + *fap = fa; + return 0; +out: + if (pbuf) + PNBUF_PUT(pbuf); + posix_spawn_fa_free(fa); + return error; +} + int sys_posix_spawn(struct lwp *l1, const struct sys_posix_spawn_args *uap, register_t *retval) @@ -1932,10 +1998,9 @@ sys_posix_spawn(struct lwp *l1, const st struct proc *p1, *p2; struct plimit *p1_lim; struct lwp *l2; - int error = 0, tnprocs, count, i; + int error = 0, tnprocs, count; struct posix_spawn_file_actions *fa = NULL; struct posix_spawnattr *sa = NULL; - struct posix_spawn_file_actions_entry *ufa; struct spawn_exec_data *spawn_data; uid_t uid; vaddr_t uaddr; @@ -1974,53 +2039,18 @@ sys_posix_spawn(struct lwp *l1, const st /* copy in file_actions struct */ if (SCARG(uap, file_actions) != NULL) { - fa = kmem_alloc(sizeof(struct posix_spawn_file_actions), - KM_SLEEP); - error = copyin(SCARG(uap, file_actions), fa, - sizeof(struct posix_spawn_file_actions)); - if (error) { - fa-fae = NULL; + error = posix_spawn_fa_alloc(fa, SCARG(uap, file_actions)); + if (error) goto error_exit; - } - if (fa-len) { - ufa = fa-fae; - fa-fae = kmem_alloc(fa-len * - sizeof(struct posix_spawn_file_actions_entry), - KM_SLEEP); - error = copyin(ufa, fa-fae, - fa-len * - sizeof(struct posix_spawn_file_actions_entry)); - if (error) -goto error_exit; - for (i = 0; i fa-len; i++) { -if (fa-fae[i].fae_action == FAE_OPEN) { - char buf[PATH_MAX]; - error = copyinstr(fa-fae[i].fae_path, - buf, sizeof(buf), NULL); - if (error) - break; - fa-fae[i].fae_path = kmem_alloc( - strlen(buf)+1, KM_SLEEP); - if (fa-fae[i].fae_path == NULL) { - error = ENOMEM; - break; - } - strcpy(fa-fae[i].fae_path, buf); -} - } - } } - + /* copyin posix_spawnattr struct */ - sa = NULL; if (SCARG(uap, attrp) != NULL) { - sa = kmem_alloc(sizeof(struct posix_spawnattr), KM_SLEEP); - error = copyin(SCARG(uap, attrp), sa, - sizeof(struct posix_spawnattr)); + sa = kmem_alloc(sizeof(*sa), KM_SLEEP); + error = copyin(SCARG(uap, attrp), sa, sizeof(*sa));
CVS commit: src/share/mk
Module Name:src Committed By: matt Date: Mon Feb 20 18:23:50 UTC 2012 Modified Files: src/share/mk: bsd.prog.mk Log Message: Remove ${SIZE} To generate a diff of this commit: cvs rdiff -u -r1.271 -r1.272 src/share/mk/bsd.prog.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.prog.mk diff -u src/share/mk/bsd.prog.mk:1.271 src/share/mk/bsd.prog.mk:1.272 --- src/share/mk/bsd.prog.mk:1.271 Sun Feb 19 23:19:37 2012 +++ src/share/mk/bsd.prog.mk Mon Feb 20 18:23:50 2012 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.prog.mk,v 1.271 2012/02/19 23:19:37 matt Exp $ +# $NetBSD: bsd.prog.mk,v 1.272 2012/02/20 18:23:50 matt Exp $ # @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 .ifndef HOSTPROG @@ -450,7 +450,6 @@ ${_P}: .gdbinit ${LIBCRT0} ${XOBJS.${_P} ${XSRCS.${_P}:@.SRC.@${.ALLSRC:M*.c:M*${.SRC.}}@:O:u} ${XOBJS.${_P}} \ ${_LDADD.${_P}} .endif # defined(DESTDIR) - @${SIZE} ${_P} .if defined(CTFMERGE) ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS.${_P}} .endif
CVS commit: src/usr.sbin/makemandb
Module Name:src Committed By: joerg Date: Mon Feb 20 18:25:51 UTC 2012 Modified Files: src/usr.sbin/makemandb: apropos.1 makemandb.8 Log Message: Add reference to whatis(1). From Abhinav Upadhyay. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/makemandb/apropos.1 cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/makemandb/makemandb.8 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/makemandb/apropos.1 diff -u src/usr.sbin/makemandb/apropos.1:1.3 src/usr.sbin/makemandb/apropos.1:1.4 --- src/usr.sbin/makemandb/apropos.1:1.3 Wed Feb 15 23:53:13 2012 +++ src/usr.sbin/makemandb/apropos.1 Mon Feb 20 18:25:51 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: apropos.1,v 1.3 2012/02/15 23:53:13 joerg Exp $ +.\ $NetBSD: apropos.1,v 1.4 2012/02/20 18:25:51 joerg Exp $ .\ .\ Copyright (c) 2011 Abhinav Upadhyay er.abhinav.upadh...@gmail.com .\ All rights reserved. @@ -29,7 +29,7 @@ .\ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd February 15, 2012 +.Dd February 20, 2012 .Dt APROPOS 1 .Os .Sh NAME @@ -112,6 +112,7 @@ The Sqlite FTS database which contains a .El .Sh SEE ALSO .Xr man 1 , +.Xr whatis 1 , .Xr makemandb 8 .Sh AUTHORS .An Abhinav Upadhyay Index: src/usr.sbin/makemandb/makemandb.8 diff -u src/usr.sbin/makemandb/makemandb.8:1.1 src/usr.sbin/makemandb/makemandb.8:1.2 --- src/usr.sbin/makemandb/makemandb.8:1.1 Tue Feb 7 19:13:32 2012 +++ src/usr.sbin/makemandb/makemandb.8 Mon Feb 20 18:25:51 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: makemandb.8,v 1.1 2012/02/07 19:13:32 joerg Exp $ +.\ $NetBSD: makemandb.8,v 1.2 2012/02/20 18:25:51 joerg Exp $ .\ .\ Copyright (c) 2011 Abhinav Upadhyay er.abhinav.upadh...@gmail.com .\ All rights reserved. @@ -29,7 +29,7 @@ .\ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd February 4, 2012 +.Dd February 20, 2012 .Dt MAKEMANDB 8 .Os .Sh NAME @@ -104,6 +104,7 @@ The Sqlite FTS database which contains a .Sh SEE ALSO .Xr apropos 1 , .Xr man 1 , +.Xr whatis 1 , .Xr man.conf 5 .Sh AUTHORS .An Abhinav Upadhyay
CVS commit: src/usr.sbin/makemandb
Module Name:src Committed By: joerg Date: Mon Feb 20 18:27:30 UTC 2012 Modified Files: src/usr.sbin/makemandb: whatis.c Log Message: SQLite doesn't use the FTS index for equal ops, so force it to do a FTS search first. Drops run time by a factor of 6 for whatis man. Found by Abhinav Upadhyay. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makemandb/whatis.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/makemandb/whatis.c diff -u src/usr.sbin/makemandb/whatis.c:1.2 src/usr.sbin/makemandb/whatis.c:1.3 --- src/usr.sbin/makemandb/whatis.c:1.2 Tue Feb 7 19:17:16 2012 +++ src/usr.sbin/makemandb/whatis.c Mon Feb 20 18:27:30 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: whatis.c,v 1.2 2012/02/07 19:17:16 joerg Exp $ */ +/* $NetBSD: whatis.c,v 1.3 2012/02/20 18:27:30 joerg Exp $ */ /*- * Copyright (c) 2012 Joerg Sonnenberger jo...@netbsd.org * All rights reserved. @@ -29,7 +29,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: whatis.c,v 1.2 2012/02/07 19:17:16 joerg Exp $); +__RCSID($NetBSD: whatis.c,v 1.3 2012/02/20 18:27:30 joerg Exp $); #include err.h #include stdio.h @@ -49,7 +49,7 @@ static int whatis(sqlite3 *db, const char *cmd) { static const char sqlstr[] = SELECT name, section, name_desc - FROM mandb WHERE name=? + FROM mandb WHERE name MATCH ? AND name=? ORDER BY section, name; sqlite3_stmt *stmt = NULL; int retval; @@ -58,6 +58,8 @@ whatis(sqlite3 *db, const char *cmd) errx(EXIT_FAILURE, Unable to query database); if (sqlite3_bind_text(stmt, 1, cmd, -1, NULL) != SQLITE_OK) errx(EXIT_FAILURE, Unable to query database); + if (sqlite3_bind_text(stmt, 2, cmd, -1, NULL) != SQLITE_OK) + errx(EXIT_FAILURE, Unable to query database); retval = 1; while (sqlite3_step(stmt) == SQLITE_ROW) { printf(%s(%s) - %s\n, sqlite3_column_text(stmt, 0),
CVS commit: src/sys/uvm
Module Name:src Committed By: bouyer Date: Mon Feb 20 19:14:24 UTC 2012 Modified Files: src/sys/uvm: uvm_km.c uvm_kmguard.c uvm_map.c Log Message: When using uvm_km_pgremove_intrsafe() make sure mappings are removed before returning the pages to the free pool. Otherwise, under Xen, a page which still has a writable mapping could be allocated for a PDP by another CPU and the hypervisor would refuse it (this is PR port-xen/45975). For this, move the pmap_kremove() calls inside uvm_km_pgremove_intrsafe(), and do pmap_kremove()/uvm_pagefree() in batch of (at most) 16 entries (as suggested by Chuck Silvers on tech-kern@, see also http://mail-index.netbsd.org/tech-kern/2012/02/17/msg012727.html and followups). To generate a diff of this commit: cvs rdiff -u -r1.121 -r1.122 src/sys/uvm/uvm_km.c cvs rdiff -u -r1.9 -r1.10 src/sys/uvm/uvm_kmguard.c cvs rdiff -u -r1.314 -r1.315 src/sys/uvm/uvm_map.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/uvm/uvm_km.c diff -u src/sys/uvm/uvm_km.c:1.121 src/sys/uvm/uvm_km.c:1.122 --- src/sys/uvm/uvm_km.c:1.121 Sun Feb 19 00:05:56 2012 +++ src/sys/uvm/uvm_km.c Mon Feb 20 19:14:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_km.c,v 1.121 2012/02/19 00:05:56 rmind Exp $ */ +/* $NetBSD: uvm_km.c,v 1.122 2012/02/20 19:14:23 bouyer Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -120,7 +120,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: uvm_km.c,v 1.121 2012/02/19 00:05:56 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: uvm_km.c,v 1.122 2012/02/20 19:14:23 bouyer Exp $); #include opt_uvmhist.h @@ -459,8 +459,12 @@ uvm_km_pgremove(vaddr_t startva, vaddr_t void uvm_km_pgremove_intrsafe(struct vm_map *map, vaddr_t start, vaddr_t end) { +#define __PGRM_BATCH 16 struct vm_page *pg; - paddr_t pa; + paddr_t pa[__PGRM_BATCH]; + int npgrm, i; + vaddr_t va, batch_vastart; + UVMHIST_FUNC(__func__); UVMHIST_CALLED(maphist); KASSERT(VM_MAP_IS_KERNEL(map)); @@ -468,16 +472,30 @@ uvm_km_pgremove_intrsafe(struct vm_map * KASSERT(start end); KASSERT(end = vm_map_max(map)); - for (; start end; start += PAGE_SIZE) { - if (!pmap_extract(pmap_kernel(), start, pa)) { - continue; + for (va = start; va end;) { + batch_vastart = va; + /* create a batch of at most __PGRM_BATCH pages to free */ + for (i = 0; + i __PGRM_BATCH va end; + va += PAGE_SIZE) { + if (!pmap_extract(pmap_kernel(), va, pa[i])) { +continue; + } + i++; + } + npgrm = i; + /* now remove the mappings */ + pmap_kremove(batch_vastart, PAGE_SIZE * npgrm); + /* and free the pages */ + for (i = 0; i npgrm; i++) { + pg = PHYS_TO_VM_PAGE(pa[i]); + KASSERT(pg); + KASSERT(pg-uobject == NULL pg-uanon == NULL); + KASSERT((pg-flags PG_BUSY) == 0); + uvm_pagefree(pg); } - pg = PHYS_TO_VM_PAGE(pa); - KASSERT(pg); - KASSERT(pg-uobject == NULL pg-uanon == NULL); - KASSERT((pg-flags PG_BUSY) == 0); - uvm_pagefree(pg); } +#undef __PGRM_BATCH } #if defined(DEBUG) @@ -668,7 +686,6 @@ uvm_km_free(struct vm_map *map, vaddr_t * remove it after. See comment below about KVA visibility. */ uvm_km_pgremove_intrsafe(map, addr, addr + size); - pmap_kremove(addr, size); } /* @@ -745,7 +762,6 @@ again: } else { uvm_km_pgremove_intrsafe(kernel_map, va, va + size); -pmap_kremove(va, size); vmem_free(kmem_va_arena, va, size); return ENOMEM; } @@ -781,7 +797,6 @@ uvm_km_kmem_free(vmem_t *vm, vmem_addr_t } #endif /* PMAP_UNMAP_POOLPAGE */ uvm_km_pgremove_intrsafe(kernel_map, addr, addr + size); - pmap_kremove(addr, size); pmap_update(pmap_kernel()); vmem_free(vm, addr, size); Index: src/sys/uvm/uvm_kmguard.c diff -u src/sys/uvm/uvm_kmguard.c:1.9 src/sys/uvm/uvm_kmguard.c:1.10 --- src/sys/uvm/uvm_kmguard.c:1.9 Sun Feb 5 11:08:06 2012 +++ src/sys/uvm/uvm_kmguard.c Mon Feb 20 19:14:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_kmguard.c,v 1.9 2012/02/05 11:08:06 rmind Exp $ */ +/* $NetBSD: uvm_kmguard.c,v 1.10 2012/02/20 19:14:23 bouyer Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: uvm_kmguard.c,v 1.9 2012/02/05 11:08:06 rmind Exp $); +__KERNEL_RCSID(0, $NetBSD: uvm_kmguard.c,v 1.10 2012/02/20 19:14:23 bouyer Exp $); #include sys/param.h #include sys/systm.h @@ -180,7 +180,6 @@ uvm_kmguard_free(struct uvm_kmguard *kg, */ uvm_km_pgremove_intrsafe(kernel_map, va, va + PAGE_SIZE * 2); - pmap_kremove(va, PAGE_SIZE * 2); pmap_update(pmap_kernel()); /* Index: src/sys/uvm/uvm_map.c diff -u src/sys/uvm/uvm_map.c:1.314 src/sys/uvm/uvm_map.c:1.315 --- src/sys/uvm/uvm_map.c:1.314 Sun Feb 19 00:05:56 2012 +++ src/sys/uvm/uvm_map.c Mon Feb 20 19:14:23 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_map.c,v 1.314 2012/02/19 00:05:56 rmind Exp $ */ +/* $NetBSD: uvm_map.c,v
CVS commit: [jmcneill-usbmp] src/sys/dev
Module Name:src Committed By: mrg Date: Mon Feb 20 20:35:40 UTC 2012 Modified Files: src/sys/dev/scsipi [jmcneill-usbmp]: scsipi_base.c src/sys/dev/usb [jmcneill-usbmp]: umass_scsipi.c usscanner.c Log Message: pullup from -current: assert kernel lock is held in a few places in inside scsipi. lock the kernel when calling into scsipi from umass and usscanner. with these two in place on usbmp branch, umass appears stable. To generate a diff of this commit: cvs rdiff -u -r1.155 -r1.155.12.1 src/sys/dev/scsipi/scsipi_base.c cvs rdiff -u -r1.38 -r1.38.6.1 src/sys/dev/usb/umass_scsipi.c cvs rdiff -u -r1.30.12.1 -r1.30.12.2 src/sys/dev/usb/usscanner.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/dev/scsipi/scsipi_base.c diff -u src/sys/dev/scsipi/scsipi_base.c:1.155 src/sys/dev/scsipi/scsipi_base.c:1.155.12.1 --- src/sys/dev/scsipi/scsipi_base.c:1.155 Sat Nov 13 13:52:11 2010 +++ src/sys/dev/scsipi/scsipi_base.c Mon Feb 20 20:35:40 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: scsipi_base.c,v 1.155 2010/11/13 13:52:11 uebayasi Exp $ */ +/* $NetBSD: scsipi_base.c,v 1.155.12.1 2012/02/20 20:35:40 mrg Exp $ */ /*- * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: scsipi_base.c,v 1.155 2010/11/13 13:52:11 uebayasi Exp $); +__KERNEL_RCSID(0, $NetBSD: scsipi_base.c,v 1.155.12.1 2012/02/20 20:35:40 mrg Exp $); #include opt_scsi.h @@ -218,6 +218,8 @@ scsipi_lookup_periph(struct scsipi_chann uint32_t hash; int s; + KASSERT(KERNEL_LOCKED_P()); + if (target = chan-chan_ntargets || lun = chan-chan_nluns) return (NULL); @@ -1261,6 +1263,8 @@ scsipi_done(struct scsipi_xfer *xs) struct scsipi_channel *chan = periph-periph_channel; int s, freezecnt; + KASSERT(KERNEL_LOCKED_P()); + SC_DEBUG(periph, SCSIPI_DB2, (scsipi_done\n)); #ifdef SCSIPI_DEBUG if (periph-periph_dbflags SCSIPI_DB1) @@ -1860,6 +1864,7 @@ scsipi_execute_xs(struct scsipi_xfer *xs int oasync, async, poll, error, s; KASSERT(!cold); + KASSERT(KERNEL_LOCKED_P()); (chan-chan_bustype-bustype_cmd)(xs); Index: src/sys/dev/usb/umass_scsipi.c diff -u src/sys/dev/usb/umass_scsipi.c:1.38 src/sys/dev/usb/umass_scsipi.c:1.38.6.1 --- src/sys/dev/usb/umass_scsipi.c:1.38 Wed Aug 24 11:28:50 2011 +++ src/sys/dev/usb/umass_scsipi.c Mon Feb 20 20:35:40 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: umass_scsipi.c,v 1.38 2011/08/24 11:28:50 mbalmer Exp $ */ +/* $NetBSD: umass_scsipi.c,v 1.38.6.1 2012/02/20 20:35:40 mrg Exp $ */ /* * Copyright (c) 2001, 2003 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: umass_scsipi.c,v 1.38 2011/08/24 11:28:50 mbalmer Exp $); +__KERNEL_RCSID(0, $NetBSD: umass_scsipi.c,v 1.38.6.1 2012/02/20 20:35:40 mrg Exp $); #ifdef _KERNEL_OPT #include opt_umass.h @@ -317,7 +317,9 @@ umass_scsipi_request(struct scsipi_chann /* Return if command finishes early. */ done: + KERNEL_LOCK(1, curlwp); scsipi_done(xs); + KERNEL_UNLOCK_ONE(curlwp); return; default: /* Not supported, nothing to do. */ @@ -451,7 +453,9 @@ umass_scsipi_cb(struct umass_softc *sc, xs-error, xs-xs_status, xs-resid)); s = splbio(); + KERNEL_LOCK(1, curlwp); scsipi_done(xs); + KERNEL_UNLOCK_ONE(curlwp); splx(s); } @@ -490,7 +494,9 @@ umass_scsipi_sense_cb(struct umass_softc xs-resid)); s = splbio(); + KERNEL_LOCK(1, curlwp); scsipi_done(xs); + KERNEL_UNLOCK_ONE(curlwp); splx(s); } @@ -510,12 +516,17 @@ umass_atapi_probe_device(struct atapibus if (target != UMASS_ATAPI_DRIVE) /* only probe drive 0 */ return; + KERNEL_LOCK(1, curlwp); + /* skip if already attached */ - if (scsipi_lookup_periph(chan, target, 0) != NULL) + if (scsipi_lookup_periph(chan, target, 0) != NULL) { + KERNEL_UNLOCK_ONE(curlwp); return; + } periph = scsipi_alloc_periph(M_NOWAIT); if (periph == NULL) { + KERNEL_UNLOCK_ONE(curlwp); aprint_error_dev(atapi-sc_dev, can't allocate link for drive %d\n, target); return; @@ -531,6 +542,7 @@ umass_atapi_probe_device(struct atapibus /* Now go ask the device all about itself. */ memset(inqbuf, 0, sizeof(inqbuf)); if (scsipi_inquire(periph, inqbuf, XS_CTL_DISCOVERY) != 0) { + KERNEL_UNLOCK_ONE(curlwp); DPRINTF(UDMASS_SCSI, (umass_atapi_probe_device: scsipi_inquire failed\n)); free(periph, M_DEVBUF); @@ -556,5 +568,7 @@ umass_atapi_probe_device(struct atapibus '%s' '%s' '%s'\n, vendor, product, revision)); atapi_probe_device(atapi, target, periph, sa); /* atapi_probe_device() frees the periph when there is no device.*/ + + KERNEL_UNLOCK_ONE(curlwp); } #endif Index: src/sys/dev/usb/usscanner.c diff -u src/sys/dev/usb/usscanner.c:1.30.12.1 src/sys/dev/usb/usscanner.c:1.30.12.2 --- src/sys/dev/usb/usscanner.c:1.30.12.1 Sat Feb 18 07:35:12 2012
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: bouyer Date: Mon Feb 20 20:49:12 UTC 2012 Modified Files: src/sys/arch/x86/x86: pmap.c Log Message: - Make pmap_write_protect() work with pmap_kernel() too ((va L2_FRAME) strips the high bits of a LP64 address) - use pmap_protect() in pmap_pdp_ctor() to remap the PDP read-only instead of (ab)using pmap_kenter_pa(). No more mapping already present on console with DIAGNOSTIC kernels - make sure to zero the whole PDP (NTOPLEVEL_PDES doens't include high-level entries on i386 and i386PAE, reserved by Xen). Not sure how it has worked before - remove an always-true test ( pmap != pmap_kernel(); we KASSERT that at the function entry). To generate a diff of this commit: cvs rdiff -u -r1.165 -r1.166 src/sys/arch/x86/x86/pmap.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/x86/x86/pmap.c diff -u src/sys/arch/x86/x86/pmap.c:1.165 src/sys/arch/x86/x86/pmap.c:1.166 --- src/sys/arch/x86/x86/pmap.c:1.165 Fri Feb 17 18:40:19 2012 +++ src/sys/arch/x86/x86/pmap.c Mon Feb 20 20:49:12 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.165 2012/02/17 18:40:19 bouyer Exp $ */ +/* $NetBSD: pmap.c,v 1.166 2012/02/20 20:49:12 bouyer Exp $ */ /*- * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. @@ -171,7 +171,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.165 2012/02/17 18:40:19 bouyer Exp $); +__KERNEL_RCSID(0, $NetBSD: pmap.c,v 1.166 2012/02/20 20:49:12 bouyer Exp $); #include opt_user_ldt.h #include opt_lockdebug.h @@ -1979,7 +1979,7 @@ pmap_get_ptp(struct pmap *pmap, vaddr_t pmap_pte_set(pva[index], (pd_entry_t) (pmap_pa2pte(pa) | PG_u | PG_RW | PG_V)); #if defined(XEN) defined(__x86_64__) - if(i == PTP_LEVELS pmap != pmap_kernel()) { + if(i == PTP_LEVELS) { /* * Update the per-cpu PD on all cpus the current * pmap is active on @@ -2090,8 +2090,8 @@ pmap_pdp_ctor(void *arg, void *v, int fl npde * sizeof(pd_entry_t)); /* zero the rest */ - memset(pdir[PDIR_SLOT_KERN + npde], 0, - (NTOPLEVEL_PDES - (PDIR_SLOT_KERN + npde)) * sizeof(pd_entry_t)); + memset(pdir[PDIR_SLOT_KERN + npde], 0, (PAGE_SIZE * PDP_SIZE) - + (PDIR_SLOT_KERN + npde) * sizeof(pd_entry_t)); if (VM_MIN_KERNEL_ADDRESS != KERNBASE) { int idx = pl_i(KERNBASE, PTP_LEVELS); @@ -2107,11 +2107,10 @@ pmap_pdp_ctor(void *arg, void *v, int fl #ifdef XEN s = splvm(); object = (vaddr_t)v; + pmap_protect(pmap_kernel(), object, object + (PAGE_SIZE * PDP_SIZE), + VM_PROT_READ); + pmap_update(pmap_kernel()); for (i = 0; i PDP_SIZE; i++, object += PAGE_SIZE) { - (void) pmap_extract(pmap_kernel(), object, pdirpa); - /* FIXME: This should use pmap_protect() .. */ - pmap_kenter_pa(object, pdirpa, VM_PROT_READ, 0); - pmap_update(pmap_kernel()); /* * pin as L2/L4 page, we have to do the page with the * PDIR_SLOT_PTE entries last @@ -2121,6 +2120,7 @@ pmap_pdp_ctor(void *arg, void *v, int fl continue; #endif + (void) pmap_extract(pmap_kernel(), object, pdirpa); #ifdef __x86_64__ xpq_queue_pin_l4_table(xpmap_ptom_masked(pdirpa)); #else @@ -3779,7 +3779,7 @@ pmap_write_protect(struct pmap *pmap, va pt_entry_t *spte, *epte; int i; - blockend = (va L2_FRAME) + NBPD_L2; + blockend = x86_round_pdr(va + 1); if (blockend eva) blockend = eva;
CVS commit: [netbsd-6] src
Module Name:src Committed By: sborrill Date: Mon Feb 20 21:41:30 UTC 2012 Modified Files: src/doc [netbsd-6]: 3RDPARTY CHANGES src/external/bsd/pkg_install/dist/add [netbsd-6]: perform.c src/external/bsd/pkg_install/dist/delete [netbsd-6]: pkg_delete.c src/external/bsd/pkg_install/dist/lib [netbsd-6]: license.c opattern.c pkg_summary.5 version.h Log Message: Pull up the following revisions(s) (requested by tron in ticket #13): doc/3RDPARTY: patch doc/CHANGES:patch external/bsd/pkg_install/dist/add/perform.c:patch external/bsd/pkg_install/dist/delete/pkg_delete.c: patch external/bsd/pkg_install/dist/lib/license.c:patch external/bsd/pkg_install/dist/lib/opattern.c: patch external/bsd/pkg_install/dist/lib/pkg_summary.5:patch external/bsd/pkg_install/dist/lib/version.h:patch Update pkg_install to version 20120128: - pkg_install 20120128: - Explicitly stat(2) if mkdir failed. errno detection doesn't work e.g. on Solaris. - Provide a stable order for package names that only differe in the base name, not the version number. - pkg_install 20110805: - Fix for pkg_delete on NFS from Anthony Mallet. To generate a diff of this commit: cvs rdiff -u -r1.909.2.1 -r1.909.2.2 src/doc/3RDPARTY cvs rdiff -u -r1.1670.2.1 -r1.1670.2.2 src/doc/CHANGES cvs rdiff -u -r1.1.1.18 -r1.1.1.18.6.1 \ src/external/bsd/pkg_install/dist/add/perform.c cvs rdiff -u -r1.1.1.7 -r1.1.1.7.8.1 \ src/external/bsd/pkg_install/dist/delete/pkg_delete.c cvs rdiff -u -r1.2 -r1.2.6.1 src/external/bsd/pkg_install/dist/lib/license.c cvs rdiff -u -r1.1.1.2 -r1.1.1.2.14.1 \ src/external/bsd/pkg_install/dist/lib/opattern.c cvs rdiff -u -r1.3 -r1.3.12.1 \ src/external/bsd/pkg_install/dist/lib/pkg_summary.5 cvs rdiff -u -r1.7 -r1.7.6.1 src/external/bsd/pkg_install/dist/lib/version.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/3RDPARTY diff -u src/doc/3RDPARTY:1.909.2.1 src/doc/3RDPARTY:1.909.2.2 --- src/doc/3RDPARTY:1.909.2.1 Sun Feb 19 18:28:53 2012 +++ src/doc/3RDPARTY Mon Feb 20 21:41:28 2012 @@ -1,4 +1,4 @@ -# $NetBSD: 3RDPARTY,v 1.909.2.1 2012/02/19 18:28:53 riz Exp $ +# $NetBSD: 3RDPARTY,v 1.909.2.2 2012/02/20 21:41:28 sborrill Exp $ # # This file contains a list of the software that has been integrated into # NetBSD where we are not the primary maintainer. @@ -878,8 +878,8 @@ definition (files.pf). userland code is reachover Makefiles are in src/usr.sbin/pf. Package: pkg_install -Version: 20110215 -Current Vers: 20110805 +Version: 20120128 +Current Vers: 20120128 Maintainer: The pkgsrc developers Home Page: http://www.pkgsrc.org/ Mailing List: tech-...@netbsd.org Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.1670.2.1 src/doc/CHANGES:1.1670.2.2 --- src/doc/CHANGES:1.1670.2.1 Sun Feb 19 18:28:53 2012 +++ src/doc/CHANGES Mon Feb 20 21:41:28 2012 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: $Revision: 1.1670.2.1 $ +# LIST OF CHANGES FROM LAST RELEASE: $Revision: 1.1670.2.2 $ # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -1262,3 +1262,4 @@ Changes from NetBSD 5.0 to NetBSD 6.0: quotarestore(8): New quota tool quotarestore for loading backups created with quotadump. [dholland 20120212] postfix(1): Import version 2.8.8 [tron 20120217] + pkg_install(1): Import version 20120128 [tron 20120219] Index: src/external/bsd/pkg_install/dist/add/perform.c diff -u src/external/bsd/pkg_install/dist/add/perform.c:1.1.1.18 src/external/bsd/pkg_install/dist/add/perform.c:1.1.1.18.6.1 --- src/external/bsd/pkg_install/dist/add/perform.c:1.1.1.18 Fri Feb 18 22:32:28 2011 +++ src/external/bsd/pkg_install/dist/add/perform.c Mon Feb 20 21:41:29 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: perform.c,v 1.1.1.18 2011/02/18 22:32:28 aymeric Exp $ */ +/* $NetBSD: perform.c,v 1.1.1.18.6.1 2012/02/20 21:41:29 sborrill Exp $ */ #if HAVE_CONFIG_H #include config.h #endif @@ -6,7 +6,7 @@ #if HAVE_SYS_CDEFS_H #include sys/cdefs.h #endif -__RCSID($NetBSD: perform.c,v 1.1.1.18 2011/02/18 22:32:28 aymeric Exp $); +__RCSID($NetBSD: perform.c,v 1.1.1.18.6.1 2012/02/20 21:41:29 sborrill Exp $); /*- * Copyright (c) 2003 Grant Beattie gr...@netbsd.org @@ -42,6 +42,7 @@ __RCSID($NetBSD: perform.c,v 1.1.1.18 2 */ #include sys/utsname.h +#include sys/stat.h #if HAVE_ERR_H #include err.h #endif @@ -169,16 +170,21 @@ static int mkdir_p(const char *path) { char *p, *cur_end; - int done; + int done, saved_errno; + struct stat sb; /* * Handle the easy case of direct success or * pre-existing directory first. */ - if (mkdir(path, 0777) == 0 || errno == EEXIST) + if (mkdir(path, 0777) == 0) return 0; -
CVS commit: [netbsd-6] src/doc
Module Name:src Committed By: sborrill Date: Mon Feb 20 21:42:13 UTC 2012 Modified Files: src/doc [netbsd-6]: CHANGES-6.0 Log Message: Ticket #13 To generate a diff of this commit: cvs rdiff -u -r1.1.2.7 -r1.1.2.8 src/doc/CHANGES-6.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-6.0 diff -u src/doc/CHANGES-6.0:1.1.2.7 src/doc/CHANGES-6.0:1.1.2.8 --- src/doc/CHANGES-6.0:1.1.2.7 Mon Feb 20 21:17:22 2012 +++ src/doc/CHANGES-6.0 Mon Feb 20 21:42:13 2012 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-6.0,v 1.1.2.7 2012/02/20 21:17:22 sborrill Exp $ +# $NetBSD: CHANGES-6.0,v 1.1.2.8 2012/02/20 21:42:13 sborrill Exp $ A complete list of changes from the initial NetBSD 6.0 branch on 15 Feb 2012 until the 6.0 release: @@ -94,3 +94,22 @@ sys/dev/usb/umidi.c1.60 member introduced in the previous change. From PR 45909. [mrg, ticket #12] +doc/3RDPARTY patch +doc/CHANGES patch +external/bsd/pkg_install/dist/add/perform.c patch +external/bsd/pkg_install/dist/delete/pkg_delete.c patch +external/bsd/pkg_install/dist/lib/license.c patch +external/bsd/pkg_install/dist/lib/opattern.c patch +external/bsd/pkg_install/dist/lib/pkg_summary.5 patch +external/bsd/pkg_install/dist/lib/version.h patch + + Update pkg_install to version 20120128: + - pkg_install 20120128: + - Explicitly stat(2) if mkdir failed. errno detection + doesn't work e.g. on Solaris. + - Provide a stable order for package names that only differ + in the base name, not the version number. + - pkg_install 20110805: + - Fix for pkg_delete on NFS from Anthony Mallet. + [tron, ticket #13] +
CVS commit: [netbsd-6] src
Module Name:src Committed By: sborrill Date: Mon Feb 20 21:54:57 UTC 2012 Modified Files: src/include [netbsd-6]: spawn.h src/sys/kern [netbsd-6]: kern_exec.c src/sys/uvm [netbsd-6]: uvm_glue.c src/tests/lib/libc/gen/posix_spawn [netbsd-6]: t_fileactions.c Log Message: Pull up the following revisions(s) (requested by martin in ticket #14): include/spawn.h:revision 1.2 sys/kern/kern_exec.c: revision 1.341 sys/uvm/uvm_glue.c: revision 1.157 tests/lib/libc/gen/posix_spawn/t_fileactions.c: revision 1.3 posix_spawn: fix kernel bug when passing empty fileactions (PR kern/46038) and add a test case for this. Fix potential race condition, doublefreeing of memory and memory leaks in error cases. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.1.2.1 src/include/spawn.h cvs rdiff -u -r1.339 -r1.339.2.1 src/sys/kern/kern_exec.c cvs rdiff -u -r1.156 -r1.156.2.1 src/sys/uvm/uvm_glue.c cvs rdiff -u -r1.2 -r1.2.2.1 \ src/tests/lib/libc/gen/posix_spawn/t_fileactions.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/include/spawn.h diff -u src/include/spawn.h:1.1 src/include/spawn.h:1.1.2.1 --- src/include/spawn.h:1.1 Sat Feb 11 23:31:24 2012 +++ src/include/spawn.h Mon Feb 20 21:54:55 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: spawn.h,v 1.1 2012/02/11 23:31:24 martin Exp $ */ +/* $NetBSD: spawn.h,v 1.1.2.1 2012/02/20 21:54:55 sborrill Exp $ */ /*- * Copyright (c) 2008 Ed Schouten e...@freebsd.org @@ -33,6 +33,7 @@ #include sys/spawn.h +__BEGIN_DECLS /* * Spawn routines * Index: src/sys/kern/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.339 src/sys/kern/kern_exec.c:1.339.2.1 --- src/sys/kern/kern_exec.c:1.339 Sun Feb 12 20:11:03 2012 +++ src/sys/kern/kern_exec.c Mon Feb 20 21:54:56 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.339 2012/02/12 20:11:03 martin Exp $ */ +/* $NetBSD: kern_exec.c,v 1.339.2.1 2012/02/20 21:54:56 sborrill Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.339 2012/02/12 20:11:03 martin Exp $); +__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.339.2.1 2012/02/20 21:54:56 sborrill Exp $); #include opt_exec.h #include opt_ktrace.h @@ -1351,8 +1351,7 @@ execve_runproc(struct lwp *l, struct exe ktremul(); /* Allow new references from the debugger/procfs. */ - if (!proc_is_new) - rw_exit(p-p_reflock); + rw_exit(p-p_reflock); rw_exit(exec_lock); mutex_enter(proc_lock); @@ -1777,6 +1776,20 @@ spawn_return(void *arg) size_t i; const struct posix_spawn_file_actions_entry *fae; register_t retval; + bool have_reflock; + + /* + * The following actions may block, so we need a temporary + * vmspace - borrow the kernel one + */ + KPREEMPT_DISABLE(l); + l-l_proc-p_vmspace = proc0.p_vmspace; + pmap_activate(l); + KPREEMPT_ENABLE(l); + + /* don't allow debugger access yet */ + rw_enter(l-l_proc-p_reflock, RW_WRITER); + have_reflock = true; error = 0; /* handle posix_spawn_file_actions */ @@ -1891,18 +1904,17 @@ spawn_return(void *arg) } } - if (spawn_data-sed_actions != NULL) { - for (i = 0; i spawn_data-sed_actions_len; i++) { - fae = spawn_data-sed_actions[i]; - if (fae-fae_action == FAE_OPEN) -kmem_free(fae-fae_path, -strlen(fae-fae_path)+1); - } - } + /* stop using kernel vmspace */ + KPREEMPT_DISABLE(l); + pmap_deactivate(l); + l-l_proc-p_vmspace = NULL; + KPREEMPT_ENABLE(l); + /* now do the real exec */ rw_enter(exec_lock, RW_READER); error = execve_runproc(l, spawn_data-sed_exec); + have_reflock = false; if (error == EJUSTRETURN) error = 0; else if (error) @@ -1920,13 +1932,15 @@ spawn_return(void *arg) return; report_error: - if (spawn_data-sed_actions != NULL) { - for (i = 0; i spawn_data-sed_actions_len; i++) { - fae = spawn_data-sed_actions[i]; - if (fae-fae_action == FAE_OPEN) -kmem_free(fae-fae_path, -strlen(fae-fae_path)+1); - } + if (have_reflock) + rw_exit(l-l_proc-p_reflock); + + /* stop using kernel vmspace (if we haven't already) */ + if (l-l_proc-p_vmspace) { + KPREEMPT_DISABLE(l); + pmap_deactivate(l); + l-l_proc-p_vmspace = NULL; + KPREEMPT_ENABLE(l); } /* @@ -2007,27 +2021,31 @@ sys_posix_spawn(struct lwp *l1, const st fa-fae = NULL; goto error_exit; } - ufa = fa-fae; - fa-fae = kmem_alloc(fa-len * - sizeof(struct posix_spawn_file_actions_entry), KM_SLEEP); - error = copyin(ufa, fa-fae, - fa-len * sizeof(struct posix_spawn_file_actions_entry)); - if (error) - goto error_exit; - for (i = 0; i fa-len; i++) { - if (fa-fae[i].fae_action == FAE_OPEN) { -char buf[PATH_MAX]; -error = copyinstr(fa-fae[i].fae_path, buf, - sizeof(buf), NULL); -if (error) - break; -fa-fae[i].fae_path =
CVS commit: [netbsd-6] src/doc
Module Name:src Committed By: sborrill Date: Mon Feb 20 21:55:44 UTC 2012 Modified Files: src/doc [netbsd-6]: CHANGES-6.0 Log Message: Ticket #14 To generate a diff of this commit: cvs rdiff -u -r1.1.2.8 -r1.1.2.9 src/doc/CHANGES-6.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-6.0 diff -u src/doc/CHANGES-6.0:1.1.2.8 src/doc/CHANGES-6.0:1.1.2.9 --- src/doc/CHANGES-6.0:1.1.2.8 Mon Feb 20 21:42:13 2012 +++ src/doc/CHANGES-6.0 Mon Feb 20 21:55:44 2012 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-6.0,v 1.1.2.8 2012/02/20 21:42:13 sborrill Exp $ +# $NetBSD: CHANGES-6.0,v 1.1.2.9 2012/02/20 21:55:44 sborrill Exp $ A complete list of changes from the initial NetBSD 6.0 branch on 15 Feb 2012 until the 6.0 release: @@ -113,3 +113,14 @@ external/bsd/pkg_install/dist/lib/versio - Fix for pkg_delete on NFS from Anthony Mallet. [tron, ticket #13] +include/spawn.h 1.2 +sys/kern/kern_exec.c1.341 +sys/uvm/uvm_glue.c1.157 +tests/lib/libc/gen/posix_spawn/t_fileactions.c 1.3 + + posix_spawn: fix kernel bug when passing empty fileactions + (PR kern/46038) and add a test case for this. Fix potential + race condition, doublefreeing of memory and memory leaks in + error cases. + [martin, ticket #14] +
CVS commit: [netbsd-6] src/usr.sbin/makemandb
Module Name:src Committed By: sborrill Date: Mon Feb 20 22:04:30 UTC 2012 Modified Files: src/usr.sbin/makemandb [netbsd-6]: apropos.1 makemandb.8 whatis.c Log Message: Pull up the following revisions(s) (requested by joerg in ticket #15): usr.sbin/makemandb/apropos.1: revision 1.4 usr.sbin/makemandb/makemandb.8: revision 1.2 usr.sbin/makemandb/whatis.c:revision 1.3 Add reference to whatis(1). SQLite doesn't use the FTS index for equal ops, so force it to do a FTS search first. Drops run time by a factor of 6 for whatis man. To generate a diff of this commit: cvs rdiff -u -r1.2.2.1 -r1.2.2.2 src/usr.sbin/makemandb/apropos.1 cvs rdiff -u -r1.1 -r1.1.2.1 src/usr.sbin/makemandb/makemandb.8 cvs rdiff -u -r1.2 -r1.2.2.1 src/usr.sbin/makemandb/whatis.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/makemandb/apropos.1 diff -u src/usr.sbin/makemandb/apropos.1:1.2.2.1 src/usr.sbin/makemandb/apropos.1:1.2.2.2 --- src/usr.sbin/makemandb/apropos.1:1.2.2.1 Sat Feb 18 18:03:26 2012 +++ src/usr.sbin/makemandb/apropos.1 Mon Feb 20 22:04:30 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: apropos.1,v 1.2.2.1 2012/02/18 18:03:26 riz Exp $ +.\ $NetBSD: apropos.1,v 1.2.2.2 2012/02/20 22:04:30 sborrill Exp $ .\ .\ Copyright (c) 2011 Abhinav Upadhyay er.abhinav.upadh...@gmail.com .\ All rights reserved. @@ -29,7 +29,7 @@ .\ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd February 15, 2012 +.Dd February 20, 2012 .Dt APROPOS 1 .Os .Sh NAME @@ -112,6 +112,7 @@ The Sqlite FTS database which contains a .El .Sh SEE ALSO .Xr man 1 , +.Xr whatis 1 , .Xr makemandb 8 .Sh AUTHORS .An Abhinav Upadhyay Index: src/usr.sbin/makemandb/makemandb.8 diff -u src/usr.sbin/makemandb/makemandb.8:1.1 src/usr.sbin/makemandb/makemandb.8:1.1.2.1 --- src/usr.sbin/makemandb/makemandb.8:1.1 Tue Feb 7 19:13:32 2012 +++ src/usr.sbin/makemandb/makemandb.8 Mon Feb 20 22:04:30 2012 @@ -1,4 +1,4 @@ -.\ $NetBSD: makemandb.8,v 1.1 2012/02/07 19:13:32 joerg Exp $ +.\ $NetBSD: makemandb.8,v 1.1.2.1 2012/02/20 22:04:30 sborrill Exp $ .\ .\ Copyright (c) 2011 Abhinav Upadhyay er.abhinav.upadh...@gmail.com .\ All rights reserved. @@ -29,7 +29,7 @@ .\ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\ SUCH DAMAGE. .\ -.Dd February 4, 2012 +.Dd February 20, 2012 .Dt MAKEMANDB 8 .Os .Sh NAME @@ -104,6 +104,7 @@ The Sqlite FTS database which contains a .Sh SEE ALSO .Xr apropos 1 , .Xr man 1 , +.Xr whatis 1 , .Xr man.conf 5 .Sh AUTHORS .An Abhinav Upadhyay Index: src/usr.sbin/makemandb/whatis.c diff -u src/usr.sbin/makemandb/whatis.c:1.2 src/usr.sbin/makemandb/whatis.c:1.2.2.1 --- src/usr.sbin/makemandb/whatis.c:1.2 Tue Feb 7 19:17:16 2012 +++ src/usr.sbin/makemandb/whatis.c Mon Feb 20 22:04:30 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: whatis.c,v 1.2 2012/02/07 19:17:16 joerg Exp $ */ +/* $NetBSD: whatis.c,v 1.2.2.1 2012/02/20 22:04:30 sborrill Exp $ */ /*- * Copyright (c) 2012 Joerg Sonnenberger jo...@netbsd.org * All rights reserved. @@ -29,7 +29,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: whatis.c,v 1.2 2012/02/07 19:17:16 joerg Exp $); +__RCSID($NetBSD: whatis.c,v 1.2.2.1 2012/02/20 22:04:30 sborrill Exp $); #include err.h #include stdio.h @@ -49,7 +49,7 @@ static int whatis(sqlite3 *db, const char *cmd) { static const char sqlstr[] = SELECT name, section, name_desc - FROM mandb WHERE name=? + FROM mandb WHERE name MATCH ? AND name=? ORDER BY section, name; sqlite3_stmt *stmt = NULL; int retval; @@ -58,6 +58,8 @@ whatis(sqlite3 *db, const char *cmd) errx(EXIT_FAILURE, Unable to query database); if (sqlite3_bind_text(stmt, 1, cmd, -1, NULL) != SQLITE_OK) errx(EXIT_FAILURE, Unable to query database); + if (sqlite3_bind_text(stmt, 2, cmd, -1, NULL) != SQLITE_OK) + errx(EXIT_FAILURE, Unable to query database); retval = 1; while (sqlite3_step(stmt) == SQLITE_ROW) { printf(%s(%s) - %s\n, sqlite3_column_text(stmt, 0),
CVS commit: [netbsd-6] src/doc
Module Name:src Committed By: sborrill Date: Mon Feb 20 22:05:01 UTC 2012 Modified Files: src/doc [netbsd-6]: CHANGES-6.0 Log Message: Ticket #15 To generate a diff of this commit: cvs rdiff -u -r1.1.2.9 -r1.1.2.10 src/doc/CHANGES-6.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-6.0 diff -u src/doc/CHANGES-6.0:1.1.2.9 src/doc/CHANGES-6.0:1.1.2.10 --- src/doc/CHANGES-6.0:1.1.2.9 Mon Feb 20 21:55:44 2012 +++ src/doc/CHANGES-6.0 Mon Feb 20 22:05:01 2012 @@ -1,4 +1,4 @@ -# $NetBSD: CHANGES-6.0,v 1.1.2.9 2012/02/20 21:55:44 sborrill Exp $ +# $NetBSD: CHANGES-6.0,v 1.1.2.10 2012/02/20 22:05:01 sborrill Exp $ A complete list of changes from the initial NetBSD 6.0 branch on 15 Feb 2012 until the 6.0 release: @@ -124,3 +124,13 @@ tests/lib/libc/gen/posix_spawn/t_fileact error cases. [martin, ticket #14] +usr.sbin/makemandb/apropos.1 1.4 +usr.sbin/makemandb/makemandb.8 1.2 +usr.sbin/makemandb/whatis.c 1.3 + + Add reference to whatis(1). + SQLite doesn't use the FTS index for equal ops, so force it + to do a FTS search first. Drops run time by a factor of 6 + for whatis man. + [joerg, ticket #15] +
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: mrg Date: Mon Feb 20 22:35:15 UTC 2012 Modified Files: src/sys/rump/librump/rumpkern: klock.c Log Message: add a _kernel_locked_p(). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/rump/librump/rumpkern/klock.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/rump/librump/rumpkern/klock.c diff -u src/sys/rump/librump/rumpkern/klock.c:1.3 src/sys/rump/librump/rumpkern/klock.c:1.4 --- src/sys/rump/librump/rumpkern/klock.c:1.3 Wed Dec 1 14:59:38 2010 +++ src/sys/rump/librump/rumpkern/klock.c Mon Feb 20 22:35:14 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: klock.c,v 1.3 2010/12/01 14:59:38 pooka Exp $ */ +/* $NetBSD: klock.c,v 1.4 2012/02/20 22:35:14 mrg Exp $ */ /* * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: klock.c,v 1.3 2010/12/01 14:59:38 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: klock.c,v 1.4 2012/02/20 22:35:14 mrg Exp $); #include sys/param.h #include sys/systm.h @@ -117,6 +117,13 @@ _kernel_unlock(int nlocks, int *countp) } } +bool +_kernel_locked_p(void) +{ + + return giantowner == curlwp; +} + void rump_user_unschedule(int nlocks, int *countp, void *interlock) {
CVS commit: [jmcneill-usbmp] src/sys/rump/librump/rumpkern
Module Name:src Committed By: mrg Date: Mon Feb 20 22:36:11 UTC 2012 Modified Files: src/sys/rump/librump/rumpkern [jmcneill-usbmp]: klock.c Log Message: pull across from -current: add a _kernel_locked_p(). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.3.12.1 src/sys/rump/librump/rumpkern/klock.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/rump/librump/rumpkern/klock.c diff -u src/sys/rump/librump/rumpkern/klock.c:1.3 src/sys/rump/librump/rumpkern/klock.c:1.3.12.1 --- src/sys/rump/librump/rumpkern/klock.c:1.3 Wed Dec 1 14:59:38 2010 +++ src/sys/rump/librump/rumpkern/klock.c Mon Feb 20 22:36:11 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: klock.c,v 1.3 2010/12/01 14:59:38 pooka Exp $ */ +/* $NetBSD: klock.c,v 1.3.12.1 2012/02/20 22:36:11 mrg Exp $ */ /* * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved. @@ -29,7 +29,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: klock.c,v 1.3 2010/12/01 14:59:38 pooka Exp $); +__KERNEL_RCSID(0, $NetBSD: klock.c,v 1.3.12.1 2012/02/20 22:36:11 mrg Exp $); #include sys/param.h #include sys/systm.h @@ -117,6 +117,13 @@ _kernel_unlock(int nlocks, int *countp) } } +bool +_kernel_locked_p(void) +{ + + return giantowner == curlwp; +} + void rump_user_unschedule(int nlocks, int *countp, void *interlock) {
CVS commit: src/sys/dev/raidframe
Module Name:src Committed By: oster Date: Mon Feb 20 22:42:05 UTC 2012 Modified Files: src/sys/dev/raidframe: rf_reconmap.c Log Message: comment, and effectively remove, a DIAGNOSTIC check that is invalid for RAID5_RS. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/sys/dev/raidframe/rf_reconmap.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/dev/raidframe/rf_reconmap.c diff -u src/sys/dev/raidframe/rf_reconmap.c:1.33 src/sys/dev/raidframe/rf_reconmap.c:1.34 --- src/sys/dev/raidframe/rf_reconmap.c:1.33 Wed Aug 31 18:31:02 2011 +++ src/sys/dev/raidframe/rf_reconmap.c Mon Feb 20 22:42:05 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_reconmap.c,v 1.33 2011/08/31 18:31:02 plunky Exp $ */ +/* $NetBSD: rf_reconmap.c,v 1.34 2012/02/20 22:42:05 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -34,7 +34,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: rf_reconmap.c,v 1.33 2011/08/31 18:31:02 plunky Exp $); +__KERNEL_RCSID(0, $NetBSD: rf_reconmap.c,v 1.34 2012/02/20 22:42:05 oster Exp $); #include rf_raid.h #include sys/time.h @@ -157,7 +157,14 @@ rf_ReconMapUpdate(RF_Raid_t *raidPtr, RF /* do we need to move the queue? */ while (i mapPtr-high_ru) { +#if 0 #ifdef DIAGNOSTIC + /* XXX: The check below is not valid for + * RAID5_RS. It is valid for RAID 1 and RAID 5. + * The issue is that we can easily have + * RU_NOTHING entries here too, and those are + * quite correct. + */ if (mapPtr-status[mapPtr-head]!=RU_ALL) { printf(\nraid%d: reconmap incorrect -- working on i % PRIu64 \n, raidPtr-raidid, i); @@ -170,6 +177,7 @@ rf_ReconMapUpdate(RF_Raid_t *raidPtr, RF panic(reconmap incorrect); } #endif +#endif mapPtr-low_ru++; mapPtr-high_ru++; /* initialize highest RU status entry, which
CVS commit: [jmcneill-usbmp] src/sys/dev/usb
Module Name:src Committed By: mrg Date: Mon Feb 20 22:42:25 UTC 2012 Modified Files: src/sys/dev/usb [jmcneill-usbmp]: ehci.c Log Message: make sure we have the thread lock when calling usb_transfer_complete() To generate a diff of this commit: cvs rdiff -u -r1.181.6.9 -r1.181.6.10 src/sys/dev/usb/ehci.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/dev/usb/ehci.c diff -u src/sys/dev/usb/ehci.c:1.181.6.9 src/sys/dev/usb/ehci.c:1.181.6.10 --- src/sys/dev/usb/ehci.c:1.181.6.9 Mon Feb 20 06:50:20 2012 +++ src/sys/dev/usb/ehci.c Mon Feb 20 22:42:24 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ehci.c,v 1.181.6.9 2012/02/20 06:50:20 mrg Exp $ */ +/* $NetBSD: ehci.c,v 1.181.6.10 2012/02/20 22:42:24 mrg Exp $ */ /* * Copyright (c) 2004-2011 The NetBSD Foundation, Inc. @@ -53,7 +53,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ehci.c,v 1.181.6.9 2012/02/20 06:50:20 mrg Exp $); +__KERNEL_RCSID(0, $NetBSD: ehci.c,v 1.181.6.10 2012/02/20 22:42:24 mrg Exp $); #include ohci.h #include uhci.h @@ -3575,6 +3575,8 @@ ehci_device_bulk_start(usbd_xfer_handle panic(ehci_device_bulk_start: a request); #endif + mutex_enter(sc-sc_lock); + len = xfer-length; endpt = epipe-pipe.endpoint-edesc-bEndpointAddress; isread = UE_GET_DIR(endpt) == UE_DIR_IN; @@ -3588,6 +3590,7 @@ ehci_device_bulk_start(usbd_xfer_handle DPRINTFN(-1,(ehci_device_bulk_transfer: no memory\n)); xfer-status = err; usb_transfer_complete(xfer); + mutex_exit(sc-sc_lock); return (err); } @@ -3609,7 +3612,6 @@ ehci_device_bulk_start(usbd_xfer_handle exfer-isdone = 0; #endif - mutex_enter(sc-sc_lock); ehci_set_qh_qtd(sqh, data); /* also does usb_syncmem(sqh) */ if (xfer-timeout !sc-sc_bus.use_polling) { callout_reset(xfer-timeout_handle, mstohz(xfer-timeout), @@ -3759,6 +3761,8 @@ ehci_device_intr_start(usbd_xfer_handle panic(ehci_device_intr_start: a request); #endif + mutex_enter(sc-sc_lock); + len = xfer-length; endpt = epipe-pipe.endpoint-edesc-bEndpointAddress; isread = UE_GET_DIR(endpt) == UE_DIR_IN; @@ -3772,6 +3776,7 @@ ehci_device_intr_start(usbd_xfer_handle DPRINTFN(-1, (ehci_device_intr_start: no memory\n)); xfer-status = err; usb_transfer_complete(xfer); + mutex_exit(sc-sc_lock); return (err); } @@ -3793,7 +3798,6 @@ ehci_device_intr_start(usbd_xfer_handle exfer-isdone = 0; #endif - mutex_enter(sc-sc_lock); ehci_set_qh_qtd(sqh, data); /* also does usb_syncmem(sqh) */ if (xfer-timeout !sc-sc_bus.use_polling) { callout_reset(xfer-timeout_handle, mstohz(xfer-timeout),
CVS commit: [jmcneill-usbmp] src/sys/dev/usb
Module Name:src Committed By: mrg Date: Mon Feb 20 22:42:47 UTC 2012 Modified Files: src/sys/dev/usb [jmcneill-usbmp]: usbdi.c Log Message: keep the thread lock taken for the abort() callback. To generate a diff of this commit: cvs rdiff -u -r1.134.2.9 -r1.134.2.10 src/sys/dev/usb/usbdi.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/dev/usb/usbdi.c diff -u src/sys/dev/usb/usbdi.c:1.134.2.9 src/sys/dev/usb/usbdi.c:1.134.2.10 --- src/sys/dev/usb/usbdi.c:1.134.2.9 Mon Feb 20 06:50:21 2012 +++ src/sys/dev/usb/usbdi.c Mon Feb 20 22:42:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.134.2.9 2012/02/20 06:50:21 mrg Exp $ */ +/* $NetBSD: usbdi.c,v 1.134.2.10 2012/02/20 22:42:47 mrg Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: usbdi.c,v 1.134.2.9 2012/02/20 06:50:21 mrg Exp $); +__KERNEL_RCSID(0, $NetBSD: usbdi.c,v 1.134.2.10 2012/02/20 22:42:47 mrg Exp $); #include opt_compat_netbsd.h #include opt_usb.h @@ -749,11 +749,7 @@ usbd_ar_pipe(usbd_pipe_handle pipe) DPRINTFN(2,(usbd_ar_pipe: pipe=%p xfer=%p (methods=%p)\n, pipe, xfer, pipe-methods)); /* Make the HC abort it (and invoke the callback). */ - if (pipe-device-bus-lock) - mutex_exit(pipe-device-bus-lock); pipe-methods-abort(xfer); - if (pipe-device-bus-lock) - mutex_enter(pipe-device-bus-lock); /* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */ } pipe-aborting = 0;
CVS commit: src/sys/dev/raidframe
Module Name:src Committed By: oster Date: Mon Feb 20 22:42:52 UTC 2012 Modified Files: src/sys/dev/raidframe: rf_reconstruct.c Log Message: Add logic to the main reconstruction loop to handle RAID5 with rotated spares. While here, observe that we were actually doing one more stripe than we thought we were, and correct that too (it didn't matter for non-RAID5_RS, but it definitely does for RAID5_RS). Add some bounds-checking at the beginning to handle the case where the number of stripes in the set is smaller than the sliding reconstruction window. XXX: this problem likely needs to be fixed for PARITY_DECLUSTERING too. To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/sys/dev/raidframe/rf_reconstruct.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/dev/raidframe/rf_reconstruct.c diff -u src/sys/dev/raidframe/rf_reconstruct.c:1.117 src/sys/dev/raidframe/rf_reconstruct.c:1.118 --- src/sys/dev/raidframe/rf_reconstruct.c:1.117 Fri Oct 14 09:23:30 2011 +++ src/sys/dev/raidframe/rf_reconstruct.c Mon Feb 20 22:42:52 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: rf_reconstruct.c,v 1.117 2011/10/14 09:23:30 hannken Exp $ */ +/* $NetBSD: rf_reconstruct.c,v 1.118 2012/02/20 22:42:52 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -33,7 +33,7 @@ / #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: rf_reconstruct.c,v 1.117 2011/10/14 09:23:30 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: rf_reconstruct.c,v 1.118 2012/02/20 22:42:52 oster Exp $); #include sys/param.h #include sys/time.h @@ -570,6 +570,9 @@ rf_ContinueReconstructFailedDisk(RF_Raid RF_ReconCtrl_t *tmp_reconctrl; RF_ReconEvent_t *event; RF_StripeCount_t incPSID,lastPSID,num_writes,pending_writes,prev; +#if RF_INCLUDE_RAID5_RS 0 + RF_StripeCount_t startPSID,endPSID,aPSID,bPSID,offPSID; +#endif RF_ReconUnitCount_t RUsPerPU; struct timeval etime, elpsd; unsigned long xor_s, xor_resid_us; @@ -622,7 +625,17 @@ rf_ContinueReconstructFailedDisk(RF_Raid recon_error = 0; write_error = 0; pending_writes = incPSID; - raidPtr-reconControl-lastPSID = incPSID; + raidPtr-reconControl-lastPSID = incPSID - 1; + + /* bounds check raidPtr-reconControl-lastPSID and + pending_writes so that we don't attempt to wait for more IO + than can possibly happen */ + + if (raidPtr-reconControl-lastPSID lastPSID) + raidPtr-reconControl-lastPSID = lastPSID; + + if (pending_writes lastPSID) + pending_writes = lastPSID; /* start the actual reconstruction */ @@ -636,6 +649,49 @@ rf_ContinueReconstructFailedDisk(RF_Raid } num_writes = 0; + +#if RF_INCLUDE_RAID5_RS 0 + /* For RAID5 with Rotated Spares we will be 'short' + some number of writes since no writes will get + issued for stripes where the spare is on the + component being rebuilt. Account for the shortage + here so that we don't hang indefinitely below + waiting for writes to complete that were never + scheduled. + + XXX: Should be fixed for PARITY_DECLUSTERING and + others too! + + */ + + if (raidPtr-Layout.numDataCol + raidPtr-numCol - raidPtr-Layout.numParityCol) { + /* numDataCol is at least 2 less than numCol, so + should be RAID 5 with Rotated Spares */ + + /* XXX need to update for RAID 6 */ + + startPSID = raidPtr-reconControl-lastPSID - pending_writes + 1; + endPSID = raidPtr-reconControl-lastPSID; + + offPSID = raidPtr-numCol - col - 1; + + aPSID = startPSID - startPSID % raidPtr-numCol + offPSID; + if (aPSID startPSID) { +aPSID += raidPtr-numCol; + } + + bPSID = endPSID - ((endPSID - offPSID) % raidPtr-numCol); + + if (aPSID endPSID) { +num_writes = ((bPSID - aPSID) / raidPtr-numCol) + 1; + } + + if ((aPSID == endPSID) (bPSID == endPSID)) { +num_writes++; + } + } +#endif /* issue a read for each surviving disk */ @@ -714,7 +770,7 @@ rf_ContinueReconstructFailedDisk(RF_Raid #endif } - /* reads done, wakup any waiters, and then wait for writes */ + /* reads done, wakeup any waiters, and then wait for writes */ rf_WakeupHeadSepCBWaiters(raidPtr); @@ -1134,7 +1190,7 @@ IssueNextReadRequest(RF_Raid_t *raidPtr, ctrl-ru_count = 0; /* code left over from when head-sep was based on * parity stripe id */ - if (ctrl-curPSID = raidPtr-reconControl-lastPSID) { + if (ctrl-curPSID raidPtr-reconControl-lastPSID) { CheckForNewMinHeadSep(raidPtr, ++(ctrl-headSepCounter)); return (RF_RECON_DONE_READS); /* finito! */ }
CVS commit: [jmcneill-usbmp] src/sys/dev/usb
Module Name:src Committed By: mrg Date: Mon Feb 20 22:43:12 UTC 2012 Modified Files: src/sys/dev/usb [jmcneill-usbmp]: usbdivar.h Log Message: expand a command slightly To generate a diff of this commit: cvs rdiff -u -r1.93.8.6 -r1.93.8.7 src/sys/dev/usb/usbdivar.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdivar.h diff -u src/sys/dev/usb/usbdivar.h:1.93.8.6 src/sys/dev/usb/usbdivar.h:1.93.8.7 --- src/sys/dev/usb/usbdivar.h:1.93.8.6 Mon Feb 20 06:50:21 2012 +++ src/sys/dev/usb/usbdivar.h Mon Feb 20 22:43:12 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdivar.h,v 1.93.8.6 2012/02/20 06:50:21 mrg Exp $ */ +/* $NetBSD: usbdivar.h,v 1.93.8.7 2012/02/20 22:43:12 mrg Exp $ */ /* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */ /* @@ -66,7 +66,8 @@ * * The above semantics are likely to change. * - * USB functions known to expect the thread lock taken include: + * USB functions known to expect the thread lock taken include (this + * list is probably not exhaustive): *usb_transfer_complete() *usb_insert_transfer() *usb_start_next()
CVS commit: src/share/mk
Module Name:src Committed By: matt Date: Tue Feb 21 01:41:10 UTC 2012 Modified Files: src/share/mk: bsd.prog.mk Log Message: Remove another ${SIZE} To generate a diff of this commit: cvs rdiff -u -r1.272 -r1.273 src/share/mk/bsd.prog.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.prog.mk diff -u src/share/mk/bsd.prog.mk:1.272 src/share/mk/bsd.prog.mk:1.273 --- src/share/mk/bsd.prog.mk:1.272 Mon Feb 20 18:23:50 2012 +++ src/share/mk/bsd.prog.mk Tue Feb 21 01:41:09 2012 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.prog.mk,v 1.272 2012/02/20 18:23:50 matt Exp $ +# $NetBSD: bsd.prog.mk,v 1.273 2012/02/21 01:41:09 matt Exp $ # @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 .ifndef HOSTPROG @@ -475,7 +475,6 @@ ${_P}: .gdbinit ${LIBCRT0} ${OBJS.${_P}} ${_LDFLAGS.${_P}} ${_LDSTATIC.${_P}} -o ${.TARGET} \ ${OBJS.${_P}} ${_LDADD.${_P}} \ ${_PROGLDOPTS} - @${SIZE} ${_P} .if defined(CTFMERGE) ${CTFMERGE} ${CTFMFLAGS} -o ${.TARGET} ${OBJS.${_P}} .endif
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: jakllsch Date: Tue Feb 21 01:47:50 UTC 2012 Modified Files: src/sys/arch/xen/xen: xbd_xenbus.c Log Message: Add and use xbdminphys() to handle transfer segmentation/size limit. Should allow us to use a normal MAXPHYS in domU kernels. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/arch/xen/xen/xbd_xenbus.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/xen/xen/xbd_xenbus.c diff -u src/sys/arch/xen/xen/xbd_xenbus.c:1.53 src/sys/arch/xen/xen/xbd_xenbus.c:1.54 --- src/sys/arch/xen/xen/xbd_xenbus.c:1.53 Thu Feb 2 20:11:26 2012 +++ src/sys/arch/xen/xen/xbd_xenbus.c Tue Feb 21 01:47:50 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: xbd_xenbus.c,v 1.53 2012/02/02 20:11:26 para Exp $ */ +/* $NetBSD: xbd_xenbus.c,v 1.54 2012/02/21 01:47:50 jakllsch Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -50,7 +50,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: xbd_xenbus.c,v 1.53 2012/02/02 20:11:26 para Exp $); +__KERNEL_RCSID(0, $NetBSD: xbd_xenbus.c,v 1.54 2012/02/21 01:47:50 jakllsch Exp $); #include opt_xen.h @@ -176,6 +176,8 @@ static void xbd_connect(struct xbd_xenbu static int xbd_map_align(struct xbd_req *); static void xbd_unmap_align(struct xbd_req *); +static void xbdminphys(struct buf *); + CFATTACH_DECL3_NEW(xbd, sizeof(struct xbd_xenbus_softc), xbd_xenbus_match, xbd_xenbus_attach, xbd_xenbus_detach, NULL, NULL, NULL, DVF_DETACH_SHUTDOWN); @@ -213,7 +215,7 @@ static struct dk_intf dkintf_esdi = { static struct dkdriver xbddkdriver = { .d_strategy = xbdstrategy, - .d_minphys = minphys, + .d_minphys = xbdminphys, }; static int @@ -731,6 +733,15 @@ done: return 1; } +static void +xbdminphys(struct buf *bp) +{ + if (bp-b_bcount (PAGE_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST)) { + bp-b_bcount = PAGE_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST; + } + minphys(bp); +} + int xbdopen(dev_t dev, int flags, int fmt, struct lwp *l) { @@ -805,7 +816,7 @@ xbdread(dev_t dev, struct uio *uio, int if ((dksc-sc_flags DKF_INITED) == 0) return ENXIO; - return physio(xbdstrategy, NULL, dev, B_READ, minphys, uio); + return physio(xbdstrategy, NULL, dev, B_READ, xbdminphys, uio); } int @@ -819,7 +830,7 @@ xbdwrite(dev_t dev, struct uio *uio, int return ENXIO; if (__predict_false(sc-sc_info VDISK_READONLY)) return EROFS; - return physio(xbdstrategy, NULL, dev, B_WRITE, minphys, uio); + return physio(xbdstrategy, NULL, dev, B_WRITE, xbdminphys, uio); } int
CVS commit: src/bin/dd
Module Name:src Committed By: matt Date: Tue Feb 21 01:49:02 UTC 2012 Modified Files: src/bin/dd: dd.c Log Message: Fix a very old bug. When allocating the buffer and doing just a bs= transfer, hen we only need a single buffer equal to that blocksize in length. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/bin/dd/dd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/dd/dd.c diff -u src/bin/dd/dd.c:1.48 src/bin/dd/dd.c:1.49 --- src/bin/dd/dd.c:1.48 Sun Nov 6 21:22:23 2011 +++ src/bin/dd/dd.c Tue Feb 21 01:49:01 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: dd.c,v 1.48 2011/11/06 21:22:23 jym Exp $ */ +/* $NetBSD: dd.c,v 1.49 2012/02/21 01:49:01 matt Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -43,7 +43,7 @@ __COPYRIGHT(@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = @(#)dd.c 8.5 (Berkeley) 4/2/94; #else -__RCSID($NetBSD: dd.c,v 1.48 2011/11/06 21:22:23 jym Exp $); +__RCSID($NetBSD: dd.c,v 1.49 2012/02/21 01:49:01 matt Exp $); #endif #endif /* not lint */ @@ -212,7 +212,10 @@ setup(void) * record oriented I/O, only need a single buffer. */ if (!(ddflags (C_BLOCK|C_UNBLOCK))) { - if ((in.db = malloc(out.dbsz + in.dbsz - 1)) == NULL) { + size_t dbsz = out.dbsz; + if (!(ddflags C_BS)) + dbsz += in.dbsz - 1; + if ((in.db = malloc(dbsz)) == NULL) { err(EXIT_FAILURE, NULL); /* NOTREACHED */ }
CVS commit: src/sys/arch/powerpc/booke/dev
Module Name:src Committed By: matt Date: Tue Feb 21 02:08:55 UTC 2012 Modified Files: src/sys/arch/powerpc/booke/dev: pq3etsec.c Log Message: Don't rely on being able to allocate while in a softintr. So preallocate all the bus_dma maps in ifinit where we can sleep. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/powerpc/booke/dev/pq3etsec.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/powerpc/booke/dev/pq3etsec.c diff -u src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.9 src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.10 --- src/sys/arch/powerpc/booke/dev/pq3etsec.c:1.9 Thu Oct 13 19:53:30 2011 +++ src/sys/arch/powerpc/booke/dev/pq3etsec.c Tue Feb 21 02:08:55 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: pq3etsec.c,v 1.9 2011/10/13 19:53:30 matt Exp $ */ +/* $NetBSD: pq3etsec.c,v 1.10 2012/02/21 02:08:55 matt Exp $ */ /*- * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -38,7 +38,7 @@ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: pq3etsec.c,v 1.9 2011/10/13 19:53:30 matt Exp $); +__KERNEL_RCSID(0, $NetBSD: pq3etsec.c,v 1.10 2012/02/21 02:08:55 matt Exp $); #include sys/param.h #include sys/cpu.h @@ -240,7 +240,7 @@ static void pq3etsec_ifstop(struct ifnet static int pq3etsec_ifioctl(struct ifnet *, u_long, void *); static int pq3etsec_mapcache_create(struct pq3etsec_softc *, -struct pq3etsec_mapcache **, size_t, size_t, size_t, size_t); +struct pq3etsec_mapcache **, size_t, size_t, size_t); static void pq3etsec_mapcache_destroy(struct pq3etsec_softc *, struct pq3etsec_mapcache *); static bus_dmamap_t pq3etsec_mapcache_get(struct pq3etsec_softc *, @@ -544,14 +544,14 @@ pq3etsec_attach(device_t parent, device_ } error = pq3etsec_mapcache_create(sc, sc-sc_rx_mapcache, - ETSEC_MAXRXMBUFS, ETSEC_MINRXMBUFS, MCLBYTES, ETSEC_NRXSEGS); + ETSEC_MAXRXMBUFS, MCLBYTES, ETSEC_NRXSEGS); if (error) { aprint_error(: failed to allocate rx dmamaps: %d\n, error); return; } error = pq3etsec_mapcache_create(sc, sc-sc_tx_mapcache, - ETSEC_MAXTXMBUFS, ETSEC_MAXTXMBUFS, MCLBYTES, ETSEC_NTXSEGS); + ETSEC_MAXTXMBUFS, MCLBYTES, ETSEC_NTXSEGS); if (error) { aprint_error(: failed to allocate tx dmamaps: %d\n, error); return; @@ -691,6 +691,8 @@ pq3etsec_ifinit(struct ifnet *ifp) struct pq3etsec_softc * const sc = ifp-if_softc; int error = 0; + KASSERT(!cpu_softintr_p()); + sc-sc_maxfrm = max(ifp-if_mtu + 32, MCLBYTES); if (ifp-if_mtu ETHERMTU_JUMBO) return error; @@ -715,8 +717,7 @@ pq3etsec_ifinit(struct ifnet *ifp) if (sc-sc_tx_mapcache == NULL) { error = pq3etsec_mapcache_create(sc, sc-sc_tx_mapcache, - ETSEC_MAXTXMBUFS, ETSEC_MAXTXMBUFS, sc-sc_maxfrm, - ETSEC_NTXSEGS); + ETSEC_MAXTXMBUFS, sc-sc_maxfrm, ETSEC_NTXSEGS); if (error) return error; } @@ -1104,20 +1105,7 @@ pq3etsec_mapcache_get( struct pq3etsec_softc *sc, struct pq3etsec_mapcache *dmc) { - if (dmc-dmc_nmaps == 0) { - bus_dmamap_t map; - int error = bus_dmamap_create(sc-sc_dmat, dmc-dmc_maxmapsize, - dmc-dmc_maxseg, dmc-dmc_maxmapsize, 0, - BUS_DMA_WAITOK|BUS_DMA_ALLOCNOW, map); - if (error) { - aprint_error_dev(sc-sc_dev, - failed to allocate a %zuB map: %d\n, - dmc-dmc_maxmapsize, error); - return NULL; - } - return map; - } - + KASSERT(dmc-dmc_nmaps 0); KASSERT(dmc-dmc_maps[dmc-dmc_nmaps-1] != NULL); return dmc-dmc_maps[--dmc-dmc_nmaps]; } @@ -1152,7 +1140,6 @@ pq3etsec_mapcache_create( struct pq3etsec_softc *sc, struct pq3etsec_mapcache **dmc_p, size_t maxmaps, - size_t minmaps, size_t maxmapsize, size_t maxseg) { @@ -1161,19 +1148,19 @@ pq3etsec_mapcache_create( struct pq3etsec_mapcache * const dmc = kmem_zalloc(dmc_size, KM_SLEEP); dmc-dmc_maxmaps = maxmaps; - dmc-dmc_nmaps = minmaps; + dmc-dmc_nmaps = maxmaps; dmc-dmc_maxmapsize = maxmapsize; dmc-dmc_maxseg = maxseg; - for (u_int i = 0; i minmaps; i++) { + for (u_int i = 0; i maxmaps; i++) { int error = bus_dmamap_create(sc-sc_dmat, dmc-dmc_maxmapsize, dmc-dmc_maxseg, dmc-dmc_maxmapsize, 0, BUS_DMA_WAITOK|BUS_DMA_ALLOCNOW, dmc-dmc_maps[i]); if (error) { aprint_error_dev(sc-sc_dev, failed to creat dma map cache - entry %u of %zu (max %zu): %d\n, - i, minmaps, maxmaps, error); + entry %u of %zu: %d\n, + i, maxmaps, error); while (i-- 0) { bus_dmamap_destroy(sc-sc_dmat, dmc-dmc_maps[i]);
CVS commit: src/sys/arch/powerpc/include
Module Name:src Committed By: matt Date: Tue Feb 21 02:09:35 UTC 2012 Modified Files: src/sys/arch/powerpc/include: cdefs.h Log Message: Change ALIGNBYTES to be AltiVec savvy To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/powerpc/include/cdefs.h 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/powerpc/include/cdefs.h diff -u src/sys/arch/powerpc/include/cdefs.h:1.7 src/sys/arch/powerpc/include/cdefs.h:1.8 --- src/sys/arch/powerpc/include/cdefs.h:1.7 Fri Jan 20 14:08:06 2012 +++ src/sys/arch/powerpc/include/cdefs.h Tue Feb 21 02:09:35 2012 @@ -1,8 +1,8 @@ -/* $NetBSD: cdefs.h,v 1.7 2012/01/20 14:08:06 joerg Exp $ */ +/* $NetBSD: cdefs.h,v 1.8 2012/02/21 02:09:35 matt Exp $ */ #ifndef _POWERPC_CDEFS_H_ #define _POWERPC_CDEFS_H_ -#define __ALIGNBYTES (sizeof(double) - 1) +#define __ALIGNBYTES (16 - 1) /* AltiVec */ #endif /* !_POWERPC_CDEFS_H_ */
CVS commit: src/sys/arch/powerpc/include
Module Name:src Committed By: matt Date: Tue Feb 21 02:19:01 UTC 2012 Modified Files: src/sys/arch/powerpc/include: cdefs.h Log Message: Restore back to double alignment. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/powerpc/include/cdefs.h 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/powerpc/include/cdefs.h diff -u src/sys/arch/powerpc/include/cdefs.h:1.8 src/sys/arch/powerpc/include/cdefs.h:1.9 --- src/sys/arch/powerpc/include/cdefs.h:1.8 Tue Feb 21 02:09:35 2012 +++ src/sys/arch/powerpc/include/cdefs.h Tue Feb 21 02:19:01 2012 @@ -1,8 +1,8 @@ -/* $NetBSD: cdefs.h,v 1.8 2012/02/21 02:09:35 matt Exp $ */ +/* $NetBSD: cdefs.h,v 1.9 2012/02/21 02:19:01 matt Exp $ */ #ifndef _POWERPC_CDEFS_H_ #define _POWERPC_CDEFS_H_ -#define __ALIGNBYTES (16 - 1) /* AltiVec */ +#define __ALIGNBYTES (sizeof(double) - 1) #endif /* !_POWERPC_CDEFS_H_ */
CVS commit: src/sbin/scsictl
Module Name:src Committed By: jakllsch Date: Tue Feb 21 02:19:41 UTC 2012 Modified Files: src/sbin/scsictl: extern.h scsi_subr.c Log Message: constify command data argument to scsi_command(). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sbin/scsictl/extern.h cvs rdiff -u -r1.12 -r1.13 src/sbin/scsictl/scsi_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/scsictl/extern.h diff -u src/sbin/scsictl/extern.h:1.6 src/sbin/scsictl/extern.h:1.7 --- src/sbin/scsictl/extern.h:1.6 Mon Apr 28 20:23:09 2008 +++ src/sbin/scsictl/extern.h Tue Feb 21 02:19:41 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.6 2008/04/28 20:23:09 martin Exp $ */ +/* $NetBSD: extern.h,v 1.7 2012/02/21 02:19:41 jakllsch Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ char *scsi_decode_sense(const unsigned c void scsi_print_sense(const char *, const scsireq_t *, int); /* scsi_subr.c */ -void scsi_command(int, void *, size_t, void *, size_t, int, int); +void scsi_command(int, const void *, size_t, void *, size_t, int, int); void scsi_mode_sense(int, u_int8_t, u_int8_t, void *, size_t); void scsi_mode_select(int, u_int8_t, void *, size_t); void scsi_request_sense(int, void *, size_t); Index: src/sbin/scsictl/scsi_subr.c diff -u src/sbin/scsictl/scsi_subr.c:1.12 src/sbin/scsictl/scsi_subr.c:1.13 --- src/sbin/scsictl/scsi_subr.c:1.12 Mon Apr 28 20:23:09 2008 +++ src/sbin/scsictl/scsi_subr.c Tue Feb 21 02:19:41 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_subr.c,v 1.12 2008/04/28 20:23:09 martin Exp $ */ +/* $NetBSD: scsi_subr.c,v 1.13 2012/02/21 02:19:41 jakllsch Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: scsi_subr.c,v 1.12 2008/04/28 20:23:09 martin Exp $); +__RCSID($NetBSD: scsi_subr.c,v 1.13 2012/02/21 02:19:41 jakllsch Exp $); #endif @@ -59,8 +59,8 @@ __RCSID($NetBSD: scsi_subr.c,v 1.12 200 #define STRVIS_ISWHITE(x) ((x) == ' ' || (x) == '\0' || (x) == (u_char)'\377') void -scsi_command(int fd, void *cmd, size_t cmdlen, void *data, size_t datalen, - int timeout, int flags) +scsi_command(int fd, const void *cmd, size_t cmdlen, + void *data, size_t datalen, int timeout, int flags) { scsireq_t req;
CVS commit: src/sbin/scsictl
Module Name:src Committed By: jakllsch Date: Tue Feb 21 02:22:54 UTC 2012 Modified Files: src/sbin/scsictl: scsi_subr.c Log Message: Prevent stack buffer overflow when copying too-large-CDB into request. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sbin/scsictl/scsi_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/scsictl/scsi_subr.c diff -u src/sbin/scsictl/scsi_subr.c:1.13 src/sbin/scsictl/scsi_subr.c:1.14 --- src/sbin/scsictl/scsi_subr.c:1.13 Tue Feb 21 02:19:41 2012 +++ src/sbin/scsictl/scsi_subr.c Tue Feb 21 02:22:54 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: scsi_subr.c,v 1.13 2012/02/21 02:19:41 jakllsch Exp $ */ +/* $NetBSD: scsi_subr.c,v 1.14 2012/02/21 02:22:54 jakllsch Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: scsi_subr.c,v 1.13 2012/02/21 02:19:41 jakllsch Exp $); +__RCSID($NetBSD: scsi_subr.c,v 1.14 2012/02/21 02:22:54 jakllsch Exp $); #endif @@ -66,6 +66,7 @@ scsi_command(int fd, const void *cmd, si memset(req, 0, sizeof(req)); + cmdlen = MIN(cmdlen, sizeof(req.cmd)); memcpy(req.cmd, cmd, cmdlen); req.cmdlen = cmdlen; req.databuf = data;
CVS commit: src/sys/kern
Module Name:src Committed By: christos Date: Tue Feb 21 03:44:54 UTC 2012 Modified Files: src/sys/kern: kern_exec.c Log Message: fix fae free'ing, from enami. To generate a diff of this commit: cvs rdiff -u -r1.342 -r1.343 src/sys/kern/kern_exec.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/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.342 src/sys/kern/kern_exec.c:1.343 --- src/sys/kern/kern_exec.c:1.342 Mon Feb 20 13:18:30 2012 +++ src/sys/kern/kern_exec.c Mon Feb 20 22:44:54 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.342 2012/02/20 18:18:30 christos Exp $ */ +/* $NetBSD: kern_exec.c,v 1.343 2012/02/21 03:44:54 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.342 2012/02/20 18:18:30 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.343 2012/02/21 03:44:54 christos Exp $); #include opt_exec.h #include opt_ktrace.h @@ -1926,7 +1926,8 @@ posix_spawn_fa_free(struct posix_spawn_f continue; kmem_free(fae-fae_path, strlen(fae-fae_path) + 1); } - kmem_free(fa-fae, sizeof(*fa-fae)); + if (fa-len) + kmem_free(fa-fae, sizeof(*fa-fae) * fa-len); kmem_free(fa, sizeof(*fa)); }
CVS commit: src/sys/kern
Module Name:src Committed By: christos Date: Tue Feb 21 04:13:22 UTC 2012 Modified Files: src/sys/kern: kern_exec.c Log Message: keep track of the original array length so we can pass it to kmem_free, from enami To generate a diff of this commit: cvs rdiff -u -r1.343 -r1.344 src/sys/kern/kern_exec.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/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.343 src/sys/kern/kern_exec.c:1.344 --- src/sys/kern/kern_exec.c:1.343 Mon Feb 20 22:44:54 2012 +++ src/sys/kern/kern_exec.c Mon Feb 20 23:13:22 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.343 2012/02/21 03:44:54 christos Exp $ */ +/* $NetBSD: kern_exec.c,v 1.344 2012/02/21 04:13:22 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.343 2012/02/21 03:44:54 christos Exp $); +__KERNEL_RCSID(0, $NetBSD: kern_exec.c,v 1.344 2012/02/21 04:13:22 christos Exp $); #include opt_exec.h #include opt_ktrace.h @@ -1917,10 +1917,10 @@ spawn_return(void *arg) } static void -posix_spawn_fa_free(struct posix_spawn_file_actions *fa) +posix_spawn_fa_free(struct posix_spawn_file_actions *fa, size_t len) { - for (size_t i = 0; i fa-len; i++) { + for (size_t i = 0; i len; i++) { struct posix_spawn_file_actions_entry *fae = fa-fae[i]; if (fae-fae_action != FAE_OPEN) continue; @@ -1939,6 +1939,7 @@ posix_spawn_fa_alloc(struct posix_spawn_ struct posix_spawn_file_actions_entry *fae; char *pbuf = NULL; int error; + size_t i = 0; fa = kmem_alloc(sizeof(*fa), KM_SLEEP); error = copyin(ufa, fa, sizeof(*fa)); @@ -1955,21 +1956,17 @@ posix_spawn_fa_alloc(struct posix_spawn_ fae = fa-fae; fa-fae = kmem_alloc(fal, KM_SLEEP); error = copyin(fae, fa-fae, fal); - if (error) { - fa-len = 0; + if (error) goto out; - } pbuf = PNBUF_GET(); - for (size_t i = 0; i fa-len; i++) { + for (; i fa-len; i++) { fae = fa-fae[i]; if (fae-fae_action != FAE_OPEN) continue; error = copyinstr(fae-fae_path, pbuf, MAXPATHLEN, fal); - if (error) { - fa-len = i; + if (error) goto out; - } fae-fae_path = kmem_alloc(fal, KM_SLEEP); memcpy(fae-fae_path, pbuf, fal); } @@ -1979,7 +1976,7 @@ posix_spawn_fa_alloc(struct posix_spawn_ out: if (pbuf) PNBUF_PUT(pbuf); - posix_spawn_fa_free(fa); + posix_spawn_fa_free(fa, i); return error; } @@ -2281,7 +2278,7 @@ sys_posix_spawn(struct lwp *l1, const st have_exec_lock = false; if (fa) - posix_spawn_fa_free(fa); + posix_spawn_fa_free(fa, fa-len); if (sa) kmem_free(sa, sizeof(*sa)); @@ -2302,7 +2299,7 @@ sys_posix_spawn(struct lwp *l1, const st rw_exit(exec_lock); if (fa) - posix_spawn_fa_free(fa); + posix_spawn_fa_free(fa, fa-len); if (sa) kmem_free(sa, sizeof(*sa));
CVS commit: othersrc/crypto/external/bsd/ssss
Module Name:othersrc Committed By: agc Date: Tue Feb 21 05:25:42 UTC 2012 Modified Files: othersrc/crypto/external/bsd//dist/include: .h othersrc/crypto/external/bsd//dist/src/lib: secsplit.c othersrc/crypto/external/bsd//dist/src/: main.c othersrc/crypto/external/bsd//lib: Makefile Removed Files: othersrc/crypto/external/bsd//dist/src/lib: internal.h threshold.c Log Message: Numerous changes to (1) and lib(3): + don't use the threshold headers any more - just use our own header + is the only algorithm supported by (1) + add back (seamless) file I/O functionality, in the case that a memory mapping, or subsequent memory allocation, fails + don't store information in the share header which could be used as part of an attack (specifically the threshold and total number of shares). + size the extra memory required on a much better estimate of the size needed, rather than a constant size + get rid of unneeded files, now that everything has been cleaned up To generate a diff of this commit: cvs rdiff -u -r1.1.1.1 -r1.2 \ othersrc/crypto/external/bsd//dist/include/.h cvs rdiff -u -r1.1.1.1 -r0 \ othersrc/crypto/external/bsd//dist/src/lib/internal.h cvs rdiff -u -r1.5 -r1.6 \ othersrc/crypto/external/bsd//dist/src/lib/secsplit.c cvs rdiff -u -r1.3 -r0 \ othersrc/crypto/external/bsd//dist/src/lib/threshold.c cvs rdiff -u -r1.2 -r1.3 \ othersrc/crypto/external/bsd//dist/src//main.c cvs rdiff -u -r1.1.1.1 -r1.2 \ othersrc/crypto/external/bsd//lib/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: othersrc/crypto/external/bsd//dist/include/.h diff -u othersrc/crypto/external/bsd//dist/include/.h:1.1.1.1 othersrc/crypto/external/bsd//dist/include/.h:1.2 --- othersrc/crypto/external/bsd//dist/include/.h:1.1.1.1 Mon Mar 21 05:43:35 2011 +++ othersrc/crypto/external/bsd//dist/include/.h Tue Feb 21 05:25:42 2012 @@ -23,12 +23,12 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef _H_ -#define _H_ 20110320 +#define _H_ 20120220 #include sys/types.h #include inttypes.h -#include threshold.h +#include stdio.h #ifndef __BEGIN_DECLS # if defined(__cplusplus) @@ -42,30 +42,66 @@ __BEGIN_DECLS +enum { + _MAX_SHARES = 256, + + _MAGIC_LENGTH = 4, + + _SPLIT_SOURCE = _MAX_SHARES, + _JOIN_DEST = _MAX_SHARES +}; + +/* threshold header written to output file when splitting */ +typedef struct s4_head_t { + char magic[_MAGIC_LENGTH]; /* magic string */ + uint8_t coeff; /* coefficient of this share */ + uint8_t pad[3]; /* padding character */ + uint64_t size; /* size of original file */ +} s4_head_t; + +/* io vector - look familiar? */ +typedef struct _iovec_t { + size_t size; /* size of vector */ + uint8_t *base; /* its base */ +} _iovec_t; + +/* a threshold string */ +typedef struct _str_t { + unsigned iotype; /* type of input mechanism */ + size_t c; /* # of chars */ + _iovec_t io; /* iovec */ + FILE *fp; /* file descriptor */ +} _str_t; + +/* structure to hold threshold information */ +typedef struct _t { + void *handle; /* implementation internals */ + unsigned sharesc; /* total # of shares */ + unsigned threshold; /* # of shares in quorum */ + unsigned strsize; /* size of share */ + unsigned availc; /* # of shares we have added */ + _str_t shares[_MAX_SHARES + 1]; /* the shares themselves */ +} _t; + /* initialisation function */ -int _init(threshold_t *, const char *, unsigned, unsigned); +int _init(_t *, unsigned, unsigned); /* split functions */ -int _split(threshold_t *); +int _split(_t *); /* reconstruction functions */ -int _combine(threshold_t *); +int _combine(_t *); /* join function */ -int _join(threshold_t *); +int _join(_t *); /* functions to retrieve a share or the result of a join */ -int _add_share(threshold_t *, unsigned, const void *, ssize_t); -int _get_share(threshold_t *, unsigned, void **, size_t *); -int _write_share(threshold_t *, unsigned, const char *); - -/* header functions */ -int _sane_header(thresh_head_t *, thresh_head_t *); -int _get_header(thresh_head_t *, const uint8_t *); -int _fmt_header(thresh_head_t *, const char *, unsigned, unsigned, uint64_t); +int _add_share(_t *, unsigned, const void *, ssize_t); +int _get_share(_t *, unsigned, void **, size_t *); +int _write_share(_t *, unsigned, const char *); /* finalisation function */ -int _end(threshold_t *); +int _end(_t *); __END_DECLS Index: othersrc/crypto/external/bsd//dist/src/lib/secsplit.c diff -u othersrc/crypto