Re: malloc flags: even more strict 'S'
On Tue, Jul 12, 2011 at 08:37:16PM +0200, Otto Moerbeek wrote: > On Tue, Jul 12, 2011 at 08:24:34PM +0200, Ariane van der Steldt wrote: > > On Tue, Jul 12, 2011 at 01:23:52PM +0200, Otto Moerbeek wrote: > > > at the cost of some speed, reduce the malloc cache size to 0 with > > > flag 'S'. This means that pages that become free will be unmapped asap. > > > This detects more use-after-free bugs. The slowdown is because of more > > > unmap/mmap calls. > > > > > > ok? > > > > I like it. Any reason not to do this with the F (freeguard) option? > > Originally the freeguard just set the protection to NONE. But > come to think of it, setting cache size to 0 has a very similar effect. > So freeguard could only do the small chunks and let the rest to > cachesize 0. > > I am wondering: how expensieve are mprotect calls compared to mmap/munmap? mprotect is slightly less expensive, since it doesn't have to teardown and rebuild an amap. For the remainder, the algorithms have the same cost: O(log N) lookup with O(M log N) treewalk (where N is the size of the map, and M is the number of pages visited). If I understand the malloc code correct, then M=1. No idea really what the real overhead of amaps is, but if people turn on Freeguard, I doubt that performance is not at the top of their priorities anyway. -- Ariane
Re: Shouldn't call munmap(2) if mmap(2) failed in catopen(3)
On Tue, Jul 12, 2011 at 02:10:07PM -0700, Matthew Dempsky wrote: > ok? ok ariane@ > Index: catopen.c > === > RCS file: /home/mdempsky/anoncvs/cvs/src/lib/libc/nls/catopen.c,v > retrieving revision 1.13 > diff -U5 -p -r1.13 catopen.c > --- catopen.c 26 Jun 2008 05:42:05 - 1.13 > +++ catopen.c 12 Jul 2011 21:05:47 - > @@ -131,11 +131,10 @@ load_msgcat(const char *path) > > data = mmap(0, (size_t) st.st_size, PROT_READ, MAP_SHARED, fd, > (off_t)0); > close (fd); > > if (data == MAP_FAILED) { > - munmap(data, (size_t) st.st_size); > return (nl_catd) -1; > } > > if (ntohl(((struct _nls_cat_hdr *) data)->__magic) != _NLS_MAGIC) { > munmap(data, (size_t) st.st_size); > -- Ariane
Re: OpenBSD 4.9 iked (Ikev2)
no. On Tue, Jul 12, 2011 at 1:47 PM, Gaurav Kansal wrote: > Hi > > Is there a list available of supported/missing features in iked? > > Regards, > Gaurav Kansal
Re: Expose openat(2), etc in libc
On Tue, Jul 12, 2011 at 10:45:00PM +, Christian Weisgerber wrote: > The test does > > ln -s conftest.no-such conftest.dangle > > and then runs this program: > > ---> > #include > #include > #include > #include > #include > int > main () > { > return (fchownat (AT_FDCWD, "conftest.dangle", -1, getgid (), > AT_SYMLINK_NOFOLLOW) != 0 > && errno == ENOENT); > } > <--- > > That indeed looks wrong to me. Ugh, indeed... FOLLOW vs follow typo, see diff below. ok? (N.B., this issue didn't affect any existing system calls, only the newly added *at() functions.) Index: vfs_syscalls.c === RCS file: /home/mdempsky/anoncvs/cvs/src/sys/kern/vfs_syscalls.c,v retrieving revision 1.174 diff -u -p -r1.174 vfs_syscalls.c --- vfs_syscalls.c 9 Jul 2011 05:46:26 - 1.174 +++ vfs_syscalls.c 12 Jul 2011 23:05:34 - @@ -1957,7 +1957,7 @@ dofchmodat(struct proc *p, int fd, const return (EINVAL); follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW; - NDINITAT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fd, path, p); + NDINITAT(&nd, LOOKUP, follow, UIO_USERSPACE, fd, path, p); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp; @@ -2054,7 +2054,7 @@ dofchownat(struct proc *p, int fd, const return (EINVAL); follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW; - NDINITAT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fd, path, p); + NDINITAT(&nd, LOOKUP, follow, UIO_USERSPACE, fd, path, p); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp;
Re: Expose openat(2), etc in libc
On Tue, Jul 12, 2011, Christian Weisgerber wrote: > Matthew Dempsky wrote: > >> Now that all of the new AT_* flags are supported, it's okay to expose >> openat(2), etc. in libc. > > ... revealing that the gnulib configure tests think that our > fchownat() is broken. fix: Index: vfs_syscalls.c === RCS file: /home/tedu/cvs/src/sys/kern/vfs_syscalls.c,v retrieving revision 1.174 diff -u -p -r1.174 vfs_syscalls.c --- vfs_syscalls.c 9 Jul 2011 05:46:26 - 1.174 +++ vfs_syscalls.c 12 Jul 2011 23:12:02 - @@ -2054,7 +2054,7 @@ dofchownat(struct proc *p, int fd, const return (EINVAL); follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW; - NDINITAT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fd, path, p); + NDINITAT(&nd, LOOKUP, follow, UIO_USERSPACE, fd, path, p); if ((error = namei(&nd)) != 0) return (error); vp = nd.ni_vp;
Re: Expose openat(2), etc in libc
Matthew Dempsky wrote: > Now that all of the new AT_* flags are supported, it's okay to expose > openat(2), etc. in libc. ... revealing that the gnulib configure tests think that our fchownat() is broken. The test does ln -s conftest.no-such conftest.dangle and then runs this program: ---> #include #include #include #include #include int main () { return (fchownat (AT_FDCWD, "conftest.dangle", -1, getgid (), AT_SYMLINK_NOFOLLOW) != 0 && errno == ENOENT); } <--- That indeed looks wrong to me. -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: Shouldn't call munmap(2) if mmap(2) failed in catopen(3)
ok djm@ On Tue, 12 Jul 2011, Matthew Dempsky wrote: > ok? > > Index: catopen.c > === > RCS file: /home/mdempsky/anoncvs/cvs/src/lib/libc/nls/catopen.c,v > retrieving revision 1.13 > diff -U5 -p -r1.13 catopen.c > --- catopen.c 26 Jun 2008 05:42:05 - 1.13 > +++ catopen.c 12 Jul 2011 21:05:47 - > @@ -131,11 +131,10 @@ load_msgcat(const char *path) > > data = mmap(0, (size_t) st.st_size, PROT_READ, MAP_SHARED, fd, > (off_t)0); > close (fd); > > if (data == MAP_FAILED) { > - munmap(data, (size_t) st.st_size); > return (nl_catd) -1; > } > > if (ntohl(((struct _nls_cat_hdr *) data)->__magic) != _NLS_MAGIC) { > munmap(data, (size_t) st.st_size);
Shouldn't call munmap(2) if mmap(2) failed in catopen(3)
ok? Index: catopen.c === RCS file: /home/mdempsky/anoncvs/cvs/src/lib/libc/nls/catopen.c,v retrieving revision 1.13 diff -U5 -p -r1.13 catopen.c --- catopen.c 26 Jun 2008 05:42:05 - 1.13 +++ catopen.c 12 Jul 2011 21:05:47 - @@ -131,11 +131,10 @@ load_msgcat(const char *path) data = mmap(0, (size_t) st.st_size, PROT_READ, MAP_SHARED, fd, (off_t)0); close (fd); if (data == MAP_FAILED) { - munmap(data, (size_t) st.st_size); return (nl_catd) -1; } if (ntohl(((struct _nls_cat_hdr *) data)->__magic) != _NLS_MAGIC) { munmap(data, (size_t) st.st_size);
Re: malloc flags: even more strict 'S'
On Tue, Jul 12, 2011 at 08:24:34PM +0200, Ariane van der Steldt wrote: > On Tue, Jul 12, 2011 at 01:23:52PM +0200, Otto Moerbeek wrote: > > at the cost of some speed, reduce the malloc cache size to 0 with > > flag 'S'. This means that pages that become free will be unmapped asap. > > This detects more use-after-free bugs. The slowdown is because of more > > unmap/mmap calls. > > > > ok? > > I like it. Any reason not to do this with the F (freeguard) option? Originally the freeguard just set the protection to NONE. But come to think of it, setting cache size to 0 has a very similar effect. So freeguard could only do the small chunks and let the rest to cachesize 0. I am wondering: how expensieve are mprotect calls compared to mmap/munmap? -Otto > > > > Index: malloc.c > > === > > RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v > > retrieving revision 1.138 > > diff -u -p -r1.138 malloc.c > > --- malloc.c20 Jun 2011 18:04:06 - 1.138 > > +++ malloc.c12 Jul 2011 11:18:41 - > > @@ -68,6 +68,8 @@ > > #define MALLOC_MAXCACHE256 > > #define MALLOC_DELAYED_CHUNKS 15 /* max of getrnibble() */ > > #define MALLOC_INITIAL_REGIONS 512 > > +#define MALLOC_DEFAULT_CACHE 64 > > + > > /* > > * When the P option is active, we move allocations between half a page > > * and a whole page towards the end, subject to alignment constraints. > > @@ -461,7 +463,7 @@ omalloc_init(struct dir_info **dp) > > */ > > mopts.malloc_abort = 1; > > mopts.malloc_move = 1; > > - mopts.malloc_cache = 64; > > + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; > > > > for (i = 0; i < 3; i++) { > > switch (i) { > > @@ -551,10 +553,12 @@ omalloc_init(struct dir_info **dp) > > case 's': > > mopts.malloc_freeprot = mopts.malloc_junk = 0; > > mopts.malloc_guard = 0; > > + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; > > break; > > case 'S': > > mopts.malloc_freeprot = mopts.malloc_junk = 1; > > mopts.malloc_guard = MALLOC_PAGESIZE; > > + mopts.malloc_cache = 0; > > break; > > case 'x': > > mopts.malloc_xmalloc = 0; > > > > -- > Ariane
Re: utrace(2)
On Tue, Jul 12, 2011 at 05:52:09PM +0200, Otto Moerbeek wrote: > The diff below implements utrace(2), a syscall to introduce data into > a ktrace stream from a userland program. > > The interface is taken from netbsd, freebsd also has a utrace(2) > syscall, but lacks the label argument. > > You could uise this as a debugging aid, to get tarce information > intermixed with sysclal info, or set more specific tracepoint and only > see the utrace records. > > Do we want this? If so, this should be reviewed and tested. And a man > page for utrace(2) should be written. > > Output of utrace("It is I", "some data", 10) looks like: > > 24413 a.outCALL utrace(0x500a09,0x5009ff,0xa) > 24413 a.outUSER It is I: 10 bytes >"some data\0" > 24413 a.outRET utrace 0 I like the functionality. Can we have a printf-like frontend for the call as well? -- Ariane
Re: malloc flags: even more strict 'S'
On Tue, Jul 12, 2011 at 01:23:52PM +0200, Otto Moerbeek wrote: > at the cost of some speed, reduce the malloc cache size to 0 with > flag 'S'. This means that pages that become free will be unmapped asap. > This detects more use-after-free bugs. The slowdown is because of more > unmap/mmap calls. > > ok? I like it. Any reason not to do this with the F (freeguard) option? > Index: malloc.c > === > RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v > retrieving revision 1.138 > diff -u -p -r1.138 malloc.c > --- malloc.c 20 Jun 2011 18:04:06 - 1.138 > +++ malloc.c 12 Jul 2011 11:18:41 - > @@ -68,6 +68,8 @@ > #define MALLOC_MAXCACHE 256 > #define MALLOC_DELAYED_CHUNKS15 /* max of getrnibble() */ > #define MALLOC_INITIAL_REGIONS 512 > +#define MALLOC_DEFAULT_CACHE 64 > + > /* > * When the P option is active, we move allocations between half a page > * and a whole page towards the end, subject to alignment constraints. > @@ -461,7 +463,7 @@ omalloc_init(struct dir_info **dp) >*/ > mopts.malloc_abort = 1; > mopts.malloc_move = 1; > - mopts.malloc_cache = 64; > + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; > > for (i = 0; i < 3; i++) { > switch (i) { > @@ -551,10 +553,12 @@ omalloc_init(struct dir_info **dp) > case 's': > mopts.malloc_freeprot = mopts.malloc_junk = 0; > mopts.malloc_guard = 0; > + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; > break; > case 'S': > mopts.malloc_freeprot = mopts.malloc_junk = 1; > mopts.malloc_guard = MALLOC_PAGESIZE; > + mopts.malloc_cache = 0; > break; > case 'x': > mopts.malloc_xmalloc = 0; > -- Ariane
Re: Support for AT_REMOVEDIR
Still awaiting feedback on this diff. On Fri, Jul 08, 2011 at 03:13:32AM -0700, Matthew Dempsky wrote: > I missed one flag: AT_REMOVEDIR. This makes unlinkat() behave the > same as rmdir(), and the diff below changes sys_rmdir() to call > dounlinkat() using it. > > Here's how to read this diff and be convinced it's correct: > > 1. First read dounlinkat() by itself, and convince yourself that if > flag == 0, the behavior is the same as it was already. (The new > control flow is a little awkward, but the semantics are the > same.) > > 2. Next compare the resulting code with the code in sys_rmdir(), and > notice that if flag == AT_REMOVEDIR, then they're the same. > > ok? > > > Index: sys/fcntl.h > === > RCS file: /home/mdempsky/anoncvs/cvs/src/sys/sys/fcntl.h,v > retrieving revision 1.14 > diff -u -p -r1.14 fcntl.h > --- sys/fcntl.h 8 Jul 2011 04:23:24 - 1.14 > +++ sys/fcntl.h 8 Jul 2011 10:05:05 - > @@ -194,6 +194,7 @@ struct flock { > #define AT_EACCESS 0x01 > #define AT_SYMLINK_NOFOLLOW 0x02 > #define AT_SYMLINK_FOLLOW 0x04 > +#define AT_REMOVEDIR0x08 > #endif > > #ifndef _KERNEL > Index: kern/vfs_syscalls.c > === > RCS file: /home/mdempsky/anoncvs/cvs/src/sys/kern/vfs_syscalls.c,v > retrieving revision 1.170 > diff -u -p -r1.170 vfs_syscalls.c > --- kern/vfs_syscalls.c 8 Jul 2011 04:23:24 - 1.170 > +++ kern/vfs_syscalls.c 8 Jul 2011 10:02:06 - > @@ -1484,9 +1484,8 @@ dounlinkat(struct proc *p, int fd, const > int error; > struct nameidata nd; > > - /* XXX: Support AT_REMOVEDIR. */ > - if (flag != 0) > - return (ENOTSUP); > + if (flag & ~AT_REMOVEDIR) > + return (EINVAL); > > NDINITAT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, > fd, path, p); > @@ -1494,24 +1493,41 @@ dounlinkat(struct proc *p, int fd, const > return (error); > vp = nd.ni_vp; > > + if (flag & AT_REMOVEDIR) { > + if (vp->v_type != VDIR) { > + error = ENOTDIR; > + goto out; > + } > + /* > + * No rmdir "." please. > + */ > + if (nd.ni_dvp == vp) { > + error = EBUSY; > + goto out; > + } > + } > + > /* >* The root of a mounted filesystem cannot be deleted. >*/ > - if (vp->v_flag & VROOT) { > + if (vp->v_flag & VROOT) > + error = EBUSY; > +out: > + if (!error) { > + if (flag & AT_REMOVEDIR) { > + error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); > + } else { > + (void)uvm_vnp_uncache(vp); > + error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); > + } > + } else { > VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); > if (nd.ni_dvp == vp) > vrele(nd.ni_dvp); > else > vput(nd.ni_dvp); > vput(vp); > - error = EBUSY; > - goto out; > } > - > - (void)uvm_vnp_uncache(vp); > - > - error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); > -out: > return (error); > } > > @@ -2614,43 +2630,9 @@ sys_rmdir(struct proc *p, void *v, regis > struct sys_rmdir_args /* { > syscallarg(const char *) path; > } */ *uap = v; > - struct vnode *vp; > - int error; > - struct nameidata nd; > > - NDINIT(&nd, DELETE, LOCKPARENT | LOCKLEAF, UIO_USERSPACE, > - SCARG(uap, path), p); > - if ((error = namei(&nd)) != 0) > - return (error); > - vp = nd.ni_vp; > - if (vp->v_type != VDIR) { > - error = ENOTDIR; > - goto out; > - } > - /* > - * No rmdir "." please. > - */ > - if (nd.ni_dvp == vp) { > - error = EBUSY; > - goto out; > - } > - /* > - * The root of a mounted filesystem cannot be deleted. > - */ > - if (vp->v_flag & VROOT) > - error = EBUSY; > -out: > - if (!error) { > - error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); > - } else { > - VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); > - if (nd.ni_dvp == vp) > - vrele(nd.ni_dvp); > - else > - vput(nd.ni_dvp); > - vput(vp); > - } > - return (error); > + return (dounlinkat(p, AT_FDCWD, SCARG(uap, path), AT_REMOVEDIR, > + retval)); > } > > /*
Re: utrace(2)
On Tue, Jul 12, 2011 at 09:31:37AM -0700, Philip Guenther wrote: > Hmm, if a process calls utrace() with a kernel that doesn't have > KTRACE defined, should it really kill the process (SIGSYS) or just do > nothing? (Just pondering a day when ld.so or libc calls utrace(). > Don't want to have to add another stub to the ramdisk build bits...) Agreed, I think utrace(2) should always be implemented, and just not do anything if the kernel's compiled without KTRACE.
Re: utrace(2)
On Tue, Jul 12, 2011 at 8:52 AM, Otto Moerbeek wrote: ... > diff -u -p -r1.117 syscalls.master > --- sys/kern/syscalls.master9 Jul 2011 05:46:26 - 1.117 > +++ sys/kern/syscalls.master12 Jul 2011 14:59:03 - > @@ -572,3 +572,9 @@ >int flag); } > 326STD { int sys_utimensat(int fd, const char *path, \ >const struct timespec *times, int flag); } > +#ifdef KTRACE > +327STD { int sys_utrace(const char *label, void *addr, \ > + size_t len); } > +#else > +327UNIMPL utrace > +#endif Hmm, if a process calls utrace() with a kernel that doesn't have KTRACE defined, should it really kill the process (SIGSYS) or just do nothing? (Just pondering a day when ld.so or libc calls utrace(). Don't want to have to add another stub to the ramdisk build bits...) Philip Guenther
Re: utrace(2)
On Tue, Jul 12, 2011, Otto Moerbeek wrote: > The diff below implements utrace(2), a syscall to introduce data into > a ktrace stream from a userland program. > Index: sys/kern/kern_ktrace.c > === > RCS file: /cvs/src/sys/kern/kern_ktrace.c,v > retrieving revision 1.54 > diff -u -p -r1.54 kern_ktrace.c > --- sys/kern/kern_ktrace.c11 Jul 2011 15:40:47 - 1.54 > +++ sys/kern/kern_ktrace.c12 Jul 2011 14:59:03 - > +int > +ktruser(struct proc *p, const char *id, void *addr, size_t len, int ustr) > +{ > + struct ktr_header kth; > + struct ktr_user *ktp; > + int error; > + > + if (!KTRPOINT(p, KTR_USER)) > + return (0); > + if (len > KTR_USER_MAXLEN) > + return ENOSPC; > + > + p->p_traceflag |= KTRFAC_ACTIVE; > + ktrinitheader(&kth, p, KTR_USER); > + ktp = malloc(sizeof(*ktp) + len, M_TEMP, M_WAITOK); > + bzero(ktp->ktr_id, KTR_USER_MAXIDLEN); > + if (ustr) { > + error = copyinstr(id, ktp->ktr_id, KTR_USER_MAXIDLEN, NULL); > + if (error) > + goto out; > + } else > + strlcpy(ktp->ktr_id, id, KTR_USER_MAXIDLEN); There is only one caller, so we don't need the ustr argument. > +sys_utrace(struct proc *curp, void *v, register_t *retval) > +{ > + struct sys_utrace_args /* { > + syscallarg(const char *) label; > + syscallarg(void) addr; missing * here.
utrace(2)
Hi, The diff below implements utrace(2), a syscall to introduce data into a ktrace stream from a userland program. The interface is taken from netbsd, freebsd also has a utrace(2) syscall, but lacks the label argument. You could uise this as a debugging aid, to get tarce information intermixed with sysclal info, or set more specific tracepoint and only see the utrace records. Do we want this? If so, this should be reviewed and tested. And a man page for utrace(2) should be written. Output of utrace("It is I", "some data", 10) looks like: 24413 a.outCALL utrace(0x500a09,0x5009ff,0xa) 24413 a.outUSER It is I: 10 bytes "some data\0" 24413 a.outRET utrace 0 -Otto Index: lib/libc/sys/Makefile.inc === RCS file: /cvs/src/lib/libc/sys/Makefile.inc,v retrieving revision 1.92 diff -u -p -r1.92 Makefile.inc --- lib/libc/sys/Makefile.inc 3 Jul 2010 04:44:51 - 1.92 +++ lib/libc/sys/Makefile.inc 12 Jul 2011 14:59:02 - @@ -64,7 +64,7 @@ ASM= accept.o access.o acct.o adjfreq.o setuid.o shmat.o shmctl.o shmdt.o shmget.o shutdown.o sigaction.o \ sigaltstack.o socket.o socketpair.o stat.o statfs.o swapctl.o \ symlink.o sync.o sysarch.o umask.o unlink.o unmount.o \ - utimes.o wait4.o write.o writev.o nnpfspioctl.o __semctl.o \ + utimes.o utrace.o wait4.o write.o writev.o nnpfspioctl.o __semctl.o \ __syscall.o __sysctl.o __getcwd.o sched_yield.o getthrid.o \ thrsleep.o thrwakeup.o threxit.o thrsigdivert.o \ setrtable.o getrtable.o Index: lib/libc/sys/ktrace.2 === RCS file: /cvs/src/lib/libc/sys/ktrace.2,v retrieving revision 1.20 diff -u -p -r1.20 ktrace.2 --- lib/libc/sys/ktrace.2 8 Jul 2011 19:30:32 - 1.20 +++ lib/libc/sys/ktrace.2 12 Jul 2011 14:59:02 - @@ -94,6 +94,8 @@ generate much output). .It Dv KTRFAC_EMUL Trace emulation changes. .It Dv KTRFAC_CSW Trace context switch points. .It Dv KTRFAC_STRUCT Trace various structs +.It Dv KTRFAC_USER Trace user data coming from +.Xr utrace 2 .It Dv KTRFAC_INHERIT Inherit tracing to future children. .El .Pp @@ -174,7 +176,8 @@ No process can be found corresponding to .El .Sh SEE ALSO .Xr kdump 1 , -.Xr ktrace 1 +.Xr ktrace 1, +.Xr utrace 2 .Sh HISTORY A .Fn ktrace Index: sys/kern/init_sysent.c === RCS file: /cvs/src/sys/kern/init_sysent.c,v retrieving revision 1.129 diff -u -p -r1.129 init_sysent.c --- sys/kern/init_sysent.c 9 Jul 2011 05:46:58 - 1.129 +++ sys/kern/init_sysent.c 12 Jul 2011 14:59:03 - @@ -1,4 +1,4 @@ -/* $OpenBSD: init_sysent.c,v 1.129 2011/07/09 05:46:58 matthew Exp $ */ +/* $OpenBSD$ */ /* * System call switch table. @@ -785,5 +785,12 @@ struct sysent sysent[] = { sys_unlinkat }, /* 325 = unlinkat */ { 4, s(struct sys_utimensat_args), 0, sys_utimensat },/* 326 = utimensat */ +#ifdef KTRACE + { 3, s(struct sys_utrace_args), 0, + sys_utrace }, /* 327 = utrace */ +#else + { 0, 0, 0, + sys_nosys },/* 327 = unimplemented utrace */ +#endif }; Index: sys/kern/kern_ktrace.c === RCS file: /cvs/src/sys/kern/kern_ktrace.c,v retrieving revision 1.54 diff -u -p -r1.54 kern_ktrace.c --- sys/kern/kern_ktrace.c 11 Jul 2011 15:40:47 - 1.54 +++ sys/kern/kern_ktrace.c 12 Jul 2011 14:59:03 - @@ -58,6 +58,7 @@ int ktrsetchildren(struct proc *, struct struct vnode *); int ktrwrite(struct proc *, struct ktr_header *); int ktrcanset(struct proc *, struct proc *); +int ktruser(struct proc *, const char *, void *, size_t, int); /* * Change the trace vnode in a correct way (to avoid races). @@ -297,6 +298,41 @@ ktrstruct(struct proc *p, const char *na p->p_traceflag &= ~KTRFAC_ACTIVE; } +int +ktruser(struct proc *p, const char *id, void *addr, size_t len, int ustr) +{ + struct ktr_header kth; + struct ktr_user *ktp; + int error; + + if (!KTRPOINT(p, KTR_USER)) + return (0); + if (len > KTR_USER_MAXLEN) + return ENOSPC; + + p->p_traceflag |= KTRFAC_ACTIVE; + ktrinitheader(&kth, p, KTR_USER); + ktp = malloc(sizeof(*ktp) + len, M_TEMP, M_WAITOK); + bzero(ktp->ktr_id, KTR_USER_MAXIDLEN); + if (ustr) { + error = copyinstr(id, ktp->ktr_id, KTR_USER_MAXIDLEN, NULL); + if (error) + goto out; + } else + strlcpy(ktp->ktr_id, id, KTR_USER_MAXIDLEN); + error = copyin(addr, (void *)(ktp + 1), len); + if (error) + goto out; + kth.kt
Re: malloc flags: even more strict 'S'
On Tue, Jul 12, 2011 at 01:23:52PM +0200, Otto Moerbeek wrote: > Hi, > > at the cost of some speed, reduce the malloc cache size to 0 with > flag 'S'. This means that pages that become free will be unmapped asap. > This detects more use-after-free bugs. The slowdown is because of more > unmap/mmap calls. > > ok? > > -Otto > I like this too. ok krw@ no matter how slow it is. :-). Ken > Index: malloc.c > === > RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v > retrieving revision 1.138 > diff -u -p -r1.138 malloc.c > --- malloc.c 20 Jun 2011 18:04:06 - 1.138 > +++ malloc.c 12 Jul 2011 11:18:41 - > @@ -68,6 +68,8 @@ > #define MALLOC_MAXCACHE 256 > #define MALLOC_DELAYED_CHUNKS15 /* max of getrnibble() */ > #define MALLOC_INITIAL_REGIONS 512 > +#define MALLOC_DEFAULT_CACHE 64 > + > /* > * When the P option is active, we move allocations between half a page > * and a whole page towards the end, subject to alignment constraints. > @@ -461,7 +463,7 @@ omalloc_init(struct dir_info **dp) >*/ > mopts.malloc_abort = 1; > mopts.malloc_move = 1; > - mopts.malloc_cache = 64; > + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; > > for (i = 0; i < 3; i++) { > switch (i) { > @@ -551,10 +553,12 @@ omalloc_init(struct dir_info **dp) > case 's': > mopts.malloc_freeprot = mopts.malloc_junk = 0; > mopts.malloc_guard = 0; > + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; > break; > case 'S': > mopts.malloc_freeprot = mopts.malloc_junk = 1; > mopts.malloc_guard = MALLOC_PAGESIZE; > + mopts.malloc_cache = 0; > break; > case 'x': > mopts.malloc_xmalloc = 0;
Re: -n support for syslogc(8)
On 2011/07/12 12:46, Stuart Henderson wrote: > As suggested by Theo, also handle syslogc -nnn (like tail does). > Code borrowed from tail with some changes as syslogc only deals with > lines (and I see no need to extend that). Updated manual (I meant to use 'lines' instead of the 'number' which I copy-n-pasted from tail, and add -lines to the options list). Index: syslogc.8 === RCS file: /cvs/src/usr.sbin/syslogc/syslogc.8,v retrieving revision 1.9 diff -u -p -r1.9 syslogc.8 --- syslogc.8 12 Jul 2011 11:28:31 - 1.9 +++ syslogc.8 12 Jul 2011 13:45:51 - @@ -22,7 +22,10 @@ .Sh SYNOPSIS .Nm syslogc .Op Fl Ccfo -.Op Fl n Ar lines +.Oo +.Fl n Ar lines | +.Fl Ns Ar lines +.Oc .Op Fl s Ar reporting_socket .Ar logname .Nm syslogc @@ -63,7 +66,7 @@ Like the .Fl f option in .Xr tail 1 . -.It Fl n Ar lines +.It Fl n Ar lines | Fl Ns Ar lines Print the specified number of lines from the end of the buffer. .It Fl o Check whether the specified log has overflowed. Index: syslogc.c === RCS file: /cvs/src/usr.sbin/syslogc/syslogc.c,v retrieving revision 1.16 diff -u -p -r1.16 syslogc.c --- syslogc.c 12 Jul 2011 11:28:31 - 1.16 +++ syslogc.c 12 Jul 2011 13:45:51 - @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogc.c,v 1.16 2011/07/12 11:28:31 sthen Exp $ */ +/* $OpenBSD: syslogc.c,v 1.15 2011/07/04 20:23:09 mpf Exp $ */ /* * Copyright (c) 2004 Damien Miller @@ -64,11 +64,69 @@ usage(void) extern char *__progname; fprintf(stderr, - "usage: %s [-Ccfo] [-n lines] [-s reporting_socket] logname\n" + "usage: %s [-Ccfo] [-n lines | -lines] [-s reporting_socket] " + "logname\n" " %s -q\n", __progname, __progname); exit(1); } +/* + * Convert the obsolete argument form into something that getopt can handle. + * This means that anything of the form -[0-9][0-9]* that isn't the option + * argument for -n gets converted. + */ +static void +obsolete(char *argv[]) +{ + char *ap, *p, *t; + size_t len; + char *start; + + while ((ap = *++argv)) { + /* Return if "--" or not an option of any form. */ + if ((ap[0] != '-') || (ap[1] == '-')) + return; + + switch(*++ap) { + /* Old-style option. */ + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + + /* Malloc space for new option and argument. */ + len = strlen(*argv); + if ((start = p = malloc(len + 2)) == NULL) + err(1, NULL); + + *p++ = *argv[0]; + *p++ = 'n'; + (void)strlcpy(p, ap, start + len + 2 - p); + *argv = start; + continue; + + /* +* Options w/ arguments, skip the argument and continue +* with the next option. +*/ + case 's': + case 'n': + if (!ap[1]) + ++argv; + /* FALLTHROUGH */ + /* Options w/o arguments, continue with the next option. */ + case 'C': + case 'c': + case 'f': + case 'o': + case 'q': + continue; + + /* Illegal option, return and let getopt handle it. */ + default: + return; + } + } +} + int main(int argc, char **argv) { @@ -85,6 +143,7 @@ main(int argc, char **argv) memset(&cc, '\0', sizeof(cc)); + obsolete(argv); ctlsock_path = DEFAULT_CTLSOCK; rval = oflag = 0; while ((ch = getopt(argc, argv, "Ccfhon:qs:")) != -1) {
Re: malloc flags: even more strict 'S'
i like this. On 12/07/2011, at 9:23 PM, Otto Moerbeek wrote: > Hi, > > at the cost of some speed, reduce the malloc cache size to 0 with > flag 'S'. This means that pages that become free will be unmapped asap. > This detects more use-after-free bugs. The slowdown is because of more > unmap/mmap calls. > > ok? > > -Otto > > Index: malloc.c > === > RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v > retrieving revision 1.138 > diff -u -p -r1.138 malloc.c > --- malloc.c 20 Jun 2011 18:04:06 - 1.138 > +++ malloc.c 12 Jul 2011 11:18:41 - > @@ -68,6 +68,8 @@ > #define MALLOC_MAXCACHE 256 > #define MALLOC_DELAYED_CHUNKS 15 /* max of getrnibble() */ > #define MALLOC_INITIAL_REGIONS512 > +#define MALLOC_DEFAULT_CACHE 64 > + > /* > * When the P option is active, we move allocations between half a page > * and a whole page towards the end, subject to alignment constraints. > @@ -461,7 +463,7 @@ omalloc_init(struct dir_info **dp) >*/ > mopts.malloc_abort = 1; > mopts.malloc_move = 1; > - mopts.malloc_cache = 64; > + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; > > for (i = 0; i < 3; i++) { > switch (i) { > @@ -551,10 +553,12 @@ omalloc_init(struct dir_info **dp) > case 's': > mopts.malloc_freeprot = mopts.malloc_junk = 0; > mopts.malloc_guard = 0; > + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; > break; > case 'S': > mopts.malloc_freeprot = mopts.malloc_junk = 1; > mopts.malloc_guard = MALLOC_PAGESIZE; > + mopts.malloc_cache = 0; > break; > case 'x': > mopts.malloc_xmalloc = 0;
Botellitas shampoo conditioner etc impresas a todo color con su logotipo
Un surtido de Botellitas desde 30 cc , 45 cc y 50 cc varios modelos Se las imprimimos a todo color en transparente , y los contenidos que le ofrecemos son: SHAMPOO , SHAMPOO DUO , CONDITIONER Y GEL DE BANO CANTIDADES DE COMPRA SUPER ACCESIBLES . SOLICITE LISTA DE PRECIOS Y CATALOGO . Amenitie Solutions si no desea recibir informacion favor de responder con asunto REMOVER
TV Led y Cámaras Digitales - Importador Directo
Atención telefónica de lúnes a viernes de 14 a 18 hsTV Led Samsung 40 Pulgadas Modelo UN40D6450 Lentes 3DUSD 2100TV Led Samsung55 Pulgadas Modelo UN55D6450 Lentes 3DUSD 4200TV Led Samsung 40 Pulgadas Modelo UN46D6050 Nuevo USD 2599Consulte por Nikon P300, P500 y filmadoras Sony CX150, C160, XR160Netbooks Acer a partir de los 390 dlsNuevaUSD 750Fuji Finepix HS20 Cámara digital compacta / visor electrónicoSensor CMOS de 16,00 MP efectivosObjetivo (en 35 mm) 24,0 - 720,0 mmZoom 30x (óptico) Soportes compatibles SD Card, SDHC, SDXCPantalla TFT de 3,00 pulgadas USD 590Panasonic Lumix FZ100Cámara digital compacta, visor electrónico / Sensor MOS de 14,10 MP efectivos / Objetivo (en 35 mm) 25,0 - 600,0 mmZoom 24x (óptico) / 4x (digital) / Soportes compatibles SD Card, SDHC, SDXC / Pantalla TFT de 3,00 pulgadas USD 375Nikon coolpix L120Cámara digital compacta, sin visor / Sensor CCD de 14,10 MP efectivos / Objetivo (en 35 mm) 25,0 - 525,0 mm / Zoom 21x (óptico) / Soportes compatibles SD Card, SDHC, SDXC / Pantalla TFT de 3,00 pulgadas s USD 375Fuji FInepix S2950TCámara digital compacta, visor electrónico / Sensor CCD de 14,00 MP efectivos / Objetivo (en 35 mm) 28,0 - 504,0 mm / Zoom 18x (óptico) / Soportes compatibles SD Card, SDHC / Pantalla TFT de 3,00 pulgadas USD 1480Canon EOS 60D BodyTipo réflex, objetivos intercambiables / Sensor CMOS de 18,00 MP efectivos / Tamaño sensor 22,30 x 14,90 mm / Montura Canon EF-S - / Factor de multiplicación 1,60x / Pantalla TFT de 3,00 pulgadas Canon EOS 60D Kit 18-105 USD 1820 USD 1600Nikon D7000 BodyTipo réflex, objetivos intercambiables / Sensor CMOS de 16,20 MP efectivos / Tamaño sensor 23,60 x 15,60 mm / Montura Nikon -/ Factor de multiplicación 1,50x / Pantalla TFT de 3,00 pulgadas Nikon D7000 Kit 18-105 USD 1980
OpenBSD 4.9 iked (Ikev2)
Hi Is there a list available of supported/missing features in iked? Regards, Gaurav Kansal
Re: -n support for syslogc(8)
As suggested by Theo, also handle syslogc -nnn (like tail does). Code borrowed from tail with some changes as syslogc only deals with lines (and I see no need to extend that). Index: syslogc.8 === RCS file: /cvs/src/usr.sbin/syslogc/syslogc.8,v retrieving revision 1.9 diff -u -p -r1.9 syslogc.8 --- syslogc.8 12 Jul 2011 11:28:31 - 1.9 +++ syslogc.8 12 Jul 2011 11:44:03 - @@ -22,7 +22,10 @@ .Sh SYNOPSIS .Nm syslogc .Op Fl Ccfo -.Op Fl n Ar lines +.Oo +.Fl n Ar lines | +.Fl Ns Ar number +.Oc .Op Fl s Ar reporting_socket .Ar logname .Nm syslogc Index: syslogc.c === RCS file: /cvs/src/usr.sbin/syslogc/syslogc.c,v retrieving revision 1.16 diff -u -p -r1.16 syslogc.c --- syslogc.c 12 Jul 2011 11:28:31 - 1.16 +++ syslogc.c 12 Jul 2011 11:44:03 - @@ -1,4 +1,4 @@ -/* $OpenBSD: syslogc.c,v 1.16 2011/07/12 11:28:31 sthen Exp $ */ +/* $OpenBSD: syslogc.c,v 1.15 2011/07/04 20:23:09 mpf Exp $ */ /* * Copyright (c) 2004 Damien Miller @@ -64,11 +64,69 @@ usage(void) extern char *__progname; fprintf(stderr, - "usage: %s [-Ccfo] [-n lines] [-s reporting_socket] logname\n" + "usage: %s [-Ccfo] [-n lines | -lines] [-s reporting_socket] " + "logname\n" " %s -q\n", __progname, __progname); exit(1); } +/* + * Convert the obsolete argument form into something that getopt can handle. + * This means that anything of the form -[0-9][0-9]* that isn't the option + * argument for -n gets converted. + */ +static void +obsolete(char *argv[]) +{ + char *ap, *p, *t; + size_t len; + char *start; + + while ((ap = *++argv)) { + /* Return if "--" or not an option of any form. */ + if ((ap[0] != '-') || (ap[1] == '-')) + return; + + switch(*++ap) { + /* Old-style option. */ + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + + /* Malloc space for new option and argument. */ + len = strlen(*argv); + if ((start = p = malloc(len + 2)) == NULL) + err(1, NULL); + + *p++ = *argv[0]; + *p++ = 'n'; + (void)strlcpy(p, ap, start + len + 2 - p); + *argv = start; + continue; + + /* +* Options w/ arguments, skip the argument and continue +* with the next option. +*/ + case 's': + case 'n': + if (!ap[1]) + ++argv; + /* FALLTHROUGH */ + /* Options w/o arguments, continue with the next option. */ + case 'C': + case 'c': + case 'f': + case 'o': + case 'q': + continue; + + /* Illegal option, return and let getopt handle it. */ + default: + return; + } + } +} + int main(int argc, char **argv) { @@ -85,6 +143,7 @@ main(int argc, char **argv) memset(&cc, '\0', sizeof(cc)); + obsolete(argv); ctlsock_path = DEFAULT_CTLSOCK; rval = oflag = 0; while ((ch = getopt(argc, argv, "Ccfhon:qs:")) != -1) {
Re: malloc flags: even more strict 'S'
On Tue, Jul 12, 2011 at 01:23:52PM +0200, Otto Moerbeek wrote: > Hi, > > at the cost of some speed, reduce the malloc cache size to 0 with > flag 'S'. This means that pages that become free will be unmapped asap. > This detects more use-after-free bugs. The slowdown is because of more > unmap/mmap calls. > > ok? I like this and don't mind the slowdown. > > -Otto > > Index: malloc.c > === > RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v > retrieving revision 1.138 > diff -u -p -r1.138 malloc.c > --- malloc.c 20 Jun 2011 18:04:06 - 1.138 > +++ malloc.c 12 Jul 2011 11:18:41 - > @@ -68,6 +68,8 @@ > #define MALLOC_MAXCACHE 256 > #define MALLOC_DELAYED_CHUNKS15 /* max of getrnibble() */ > #define MALLOC_INITIAL_REGIONS 512 > +#define MALLOC_DEFAULT_CACHE 64 > + > /* > * When the P option is active, we move allocations between half a page > * and a whole page towards the end, subject to alignment constraints. > @@ -461,7 +463,7 @@ omalloc_init(struct dir_info **dp) >*/ > mopts.malloc_abort = 1; > mopts.malloc_move = 1; > - mopts.malloc_cache = 64; > + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; > > for (i = 0; i < 3; i++) { > switch (i) { > @@ -551,10 +553,12 @@ omalloc_init(struct dir_info **dp) > case 's': > mopts.malloc_freeprot = mopts.malloc_junk = 0; > mopts.malloc_guard = 0; > + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; > break; > case 'S': > mopts.malloc_freeprot = mopts.malloc_junk = 1; > mopts.malloc_guard = MALLOC_PAGESIZE; > + mopts.malloc_cache = 0; > break; > case 'x': > mopts.malloc_xmalloc = 0;
malloc flags: even more strict 'S'
Hi, at the cost of some speed, reduce the malloc cache size to 0 with flag 'S'. This means that pages that become free will be unmapped asap. This detects more use-after-free bugs. The slowdown is because of more unmap/mmap calls. ok? -Otto Index: malloc.c === RCS file: /cvs/src/lib/libc/stdlib/malloc.c,v retrieving revision 1.138 diff -u -p -r1.138 malloc.c --- malloc.c20 Jun 2011 18:04:06 - 1.138 +++ malloc.c12 Jul 2011 11:18:41 - @@ -68,6 +68,8 @@ #define MALLOC_MAXCACHE256 #define MALLOC_DELAYED_CHUNKS 15 /* max of getrnibble() */ #define MALLOC_INITIAL_REGIONS 512 +#define MALLOC_DEFAULT_CACHE 64 + /* * When the P option is active, we move allocations between half a page * and a whole page towards the end, subject to alignment constraints. @@ -461,7 +463,7 @@ omalloc_init(struct dir_info **dp) */ mopts.malloc_abort = 1; mopts.malloc_move = 1; - mopts.malloc_cache = 64; + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; for (i = 0; i < 3; i++) { switch (i) { @@ -551,10 +553,12 @@ omalloc_init(struct dir_info **dp) case 's': mopts.malloc_freeprot = mopts.malloc_junk = 0; mopts.malloc_guard = 0; + mopts.malloc_cache = MALLOC_DEFAULT_CACHE; break; case 'S': mopts.malloc_freeprot = mopts.malloc_junk = 1; mopts.malloc_guard = MALLOC_PAGESIZE; + mopts.malloc_cache = 0; break; case 'x': mopts.malloc_xmalloc = 0;