Clean up regress/usr.bin/sdiff
Okan reminded me that my old regress tests used systrace policy files as example text, which weren't the easiest to decypher. I've replaced them with simpler files that should make life easier for any future regress test writers. Comments? Suggestions? Ray Index: Iflag12.out === RCS file: /home/cvs/src/regress/usr.bin/sdiff/Iflag12.out,v retrieving revision 1.2 diff -u -p -r1.2 Iflag12.out --- Iflag12.out 13 Sep 2015 17:08:04 - 1.2 +++ Iflag12.out 30 May 2016 06:06:09 - @@ -1,100 +1,8 @@ -Policy: /usr/bin/lynx, Emulation: nativePolicy: /usr/bin/lynx, Emulation: native - > native-issetugid: permit - > native-mprotect: permit - > native-mmap: permit -native-sysctl: permit native-sysctl: permit - > native-fsread: filename eq "/var/run/ld.so.hints" then pe - > native-fstat: permit -native-close: permit native-close: permit -native-connect: sockaddr eq "inet-[127.0.0.1]:53" then pe | native-fsread: filename match "/usr/lib/libssl.so.*" then -native-connect: sockaddr match "inet-\\\[*\\\]:80" then p | native-read: permit -native-exit: permit | native-fsread: filename match "/usr/lib/libcrypto.so.*" t -native-fcntl: cmd eq "F_SETFD" then permit| native-fsread: filename match "/usr/lib/libncurses.so.*" -native-fsread: filename eq "/" then permit| native-fsread: filename match "/usr/lib/libc.so.*" then p -native-fsread: filename match "/: | native-munmap: permit -native-fsread: filename eq "/etc/lynx.cfg" then permit| native-sigprocmask: permit -native-fsread: filename eq "/etc/malloc.conf" then permit native-fsread: filename eq "/etc/malloc.conf" then permit -native-fsread: filename eq "/etc/resolv.conf" then permit | native-getpid: permit -native-fsread: filename eq "/etc/utmp" then permit< -native-fsread: filename eq "/home" then permit< -native-fsread: filename eq "$HOME" then permit< -native-fsread: filename eq "$HOME/.lynx-keymaps" then per < -native-fsread: filename eq "$HOME/.lynxrc" then permit< -native-fsread: filename eq "$HOME/.mailcap" then permit < -native-fsread: filename eq "$HOME/.mime.types" then permi < -native-fsread: filename eq "$HOME/.terminfo" then permit < -native-fsread: filename eq "$HOME/.terminfo.db" then perm < -native-fsread: filename eq "/obj" then permit < -native-fsread: filename eq "/tmp" then permit native-fsread: filename eq "/tmp" then permit -native-fsread: filename match "/tmp/lynx-*/." then permit native-fswrite: filename match "/tmp/lynx-*" then permit - ) native-fsread: filename match "/tmp/lynx-*/." then permit - > native-fsread: filename eq "$HOME" then permit - > native-fsread: filename eq "/etc/lynx.cfg" then permit - > native-fsread: filename eq "/" then permit - > native-fsread: filename eq "/usr/obj/bin/systrace/." then - > native-fsread: filename eq "/usr/obj/bin" then permit - > native-fcntl: permit - > native-getdirentries: permit - > native-lseek: permit - > native-fsread: filename eq "/usr/obj" then permit -native-fsread: filename eq "/usr" then permit native-fsread: filename eq "/usr" then permit -native-fsread: filename eq "/usr/bin" then permit native-fsread: filename eq "/usr/bin" then permit -native-fsread: filename eq "/usr/games" then permit native-fsread: filename eq "/usr/games" then permit -native-fsread: filename eq "/usr/include" then permit native-fsread: filename eq "/usr/include" then permit -native-fsread: filename eq "/usr/lib" then permit native-fsread: filename eq "/usr/lib" then permit -native-fsr
Re: libc: __getcwd() is hidden
On Sun, 29 May 2016, Philip Guenther wrote: > Total turd polishing: __getcwd() isn't ex, so ported in the shared > version of libc, ... "__getcwd() isn't exported in the shared version of libc"
libc: __getcwd() is hidden
Total turd polishing: __getcwd() isn't ex, so ported in the shared version of libc, so let's exclude it from the static build too. For historical reasons, the ${HIDDEN} target strips a leading underbar when figuring out the name of the syscall to generate a hidden stub for, so add another underbar when switching from ASM to HIDDEN. ok? Index: sys/Makefile.inc === RCS file: /data/src/openbsd/src/lib/libc/sys/Makefile.inc,v retrieving revision 1.144 diff -u -p -r1.144 Makefile.inc --- sys/Makefile.inc19 May 2016 05:31:22 - 1.144 +++ sys/Makefile.inc30 May 2016 05:41:26 - @@ -40,7 +40,7 @@ SRCS+=${CANCEL:%=w_%.c} w_pread.c w_pre # modules with default implementations on all architectures, unless overridden # below: -ASM= __getcwd.o __semctl.o __syscall.o __thrsigdivert.o \ +ASM= __semctl.o __syscall.o __thrsigdivert.o \ access.o acct.o adjfreq.o adjtime.o \ bind.o chdir.o chflags.o chflagsat.o chmod.o chown.o chroot.o \ clock_getres.o clock_gettime.o clock_settime.o \ @@ -112,7 +112,7 @@ PPSEUDO_NOERR=${PSEUDO_NOERR:.o=.po} SPSEUDO_NOERR=${PSEUDO_NOERR:.o=.so} DPSEUDO_NOERR=${PSEUDO_NOERR:.o=.do} -HIDDEN= fork.o sigaction.o _ptrace.o ${CANCEL:=.o} +HIDDEN= ___getcwd.o fork.o sigaction.o _ptrace.o ${CANCEL:=.o} GHIDDEN=${HIDDEN:.o=.go} PHIDDEN=${HIDDEN:.o=.po} SHIDDEN=${HIDDEN:.o=.so}
libc: stop using/exporting 'end'
On some architectures, the internal __minbrk/__curbrk variables are defined in terms of 'end' instead of '_end'. The normal ld maps support that, providing plain 'end' only when it is referenced, but we not only use it but also export it. That's kinda silly as the 'end' symbol in a shared library is useless, being overriden by the *real* end (and _end) symbols from the executable. The diff below switches the remaining architectures from "end" to "_end" in their brk/sbrk implementations: arm, hppa, mips64, powerpc, and sh Any emacs users on those archs that can test this *before* it's committed? Philip Guenther Index: arch/arm/Symbols.list === RCS file: /data/src/openbsd/src/lib/libc/arch/arm/Symbols.list,v retrieving revision 1.2 diff -u -p -r1.2 Symbols.list --- arch/arm/Symbols.list 26 Aug 2015 01:54:09 - 1.2 +++ arch/arm/Symbols.list 22 May 2016 02:49:02 - @@ -66,7 +66,6 @@ _softfloat_float_rounding_mode _stack add64 add96 -end eq64 fabsl frexpl Index: arch/arm/sys/brk.S === RCS file: /data/src/openbsd/src/lib/libc/arch/arm/sys/brk.S,v retrieving revision 1.7 diff -u -p -r1.7 brk.S --- arch/arm/sys/brk.S 10 Sep 2015 13:29:09 - 1.7 +++ arch/arm/sys/brk.S 21 May 2016 09:01:41 - @@ -34,14 +34,14 @@ #include "SYS.h" - .globl _C_LABEL(end) + .globl _C_LABEL(_end) .globl __curbrk .data .align 0 .type __minbrk,#object __minbrk: - .word _C_LABEL(end) + .word _C_LABEL(_end) END(__minbrk) .weak brk Index: arch/arm/sys/sbrk.S === RCS file: /data/src/openbsd/src/lib/libc/arch/arm/sys/sbrk.S,v retrieving revision 1.7 diff -u -p -r1.7 sbrk.S --- arch/arm/sys/sbrk.S 10 Sep 2015 13:29:09 - 1.7 +++ arch/arm/sys/sbrk.S 21 May 2016 09:01:55 - @@ -34,7 +34,7 @@ #include "SYS.h" - .globl _C_LABEL(end) + .globl _C_LABEL(_end) .data .align 0 @@ -42,7 +42,7 @@ .type __curbrk,#object .hidden __curbrk __curbrk: - .word _C_LABEL(end) + .word _C_LABEL(_end) END(__curbrk) .weak sbrk Index: arch/hppa/Symbols.list === RCS file: /data/src/openbsd/src/lib/libc/arch/hppa/Symbols.list,v retrieving revision 1.2 diff -u -p -r1.2 Symbols.list --- arch/hppa/Symbols.list 26 Aug 2015 01:54:09 - 1.2 +++ arch/hppa/Symbols.list 22 May 2016 02:49:04 - @@ -1,6 +1,5 @@ _GLOBAL_OFFSET_TABLE_ _mcount -end fabsl frexpl ldexpl Index: arch/hppa/sys/brk.S === RCS file: /data/src/openbsd/src/lib/libc/arch/hppa/sys/brk.S,v retrieving revision 1.17 diff -u -p -r1.17 brk.S --- arch/hppa/sys/brk.S 10 Sep 2015 13:29:09 - 1.17 +++ arch/hppa/sys/brk.S 30 May 2016 03:14:49 - @@ -29,12 +29,12 @@ #include "SYS.h" .import __curbrk, data - .import end, data + .import _end, data .data .export __minbrk, data __minbrk - .long end + .long _end .weak brk Index: arch/hppa/sys/sbrk.S === RCS file: /data/src/openbsd/src/lib/libc/arch/hppa/sys/sbrk.S,v retrieving revision 1.16 diff -u -p -r1.16 sbrk.S --- arch/hppa/sys/sbrk.S10 Sep 2015 13:29:09 - 1.16 +++ arch/hppa/sys/sbrk.S22 May 2016 09:27:37 - @@ -28,12 +28,12 @@ #include "SYS.h" - .import end, data + .import _end, data .data .export __curbrk, data __curbrk - .long end + .long _end .weak sbrk Index: arch/mips64/Symbols.list === RCS file: /data/src/openbsd/src/lib/libc/arch/mips64/Symbols.list,v retrieving revision 1.3 diff -u -p -r1.3 Symbols.list --- arch/mips64/Symbols.list13 Sep 2015 08:31:47 - 1.3 +++ arch/mips64/Symbols.list22 May 2016 02:49:06 - @@ -9,6 +9,5 @@ _ftext _gp _mcount cacheflush -end get_fpc_csr set_fpc_csr Index: arch/mips64/sys/brk.S === RCS file: /data/src/openbsd/src/lib/libc/arch/mips64/sys/brk.S,v retrieving revision 1.7 diff -u -p -r1.7 brk.S --- arch/mips64/sys/brk.S 5 Sep 2015 06:22:47 - 1.7 +++ arch/mips64/sys/brk.S 21 May 2016 09:04:07 - @@ -37,7 +37,7 @@ .data __minbrk: - PTR_VAL _C_LABEL(end) + PTR_VAL _C_LABEL(_end) .size __minbrk, . - __minbrk .type __minbrk,@object .text Index: arch/mips64/sys/sbrk.S === RCS file: /data/src/openbsd/src/lib/libc/arch/mips64/sys/s
libcrypto errata update
A bug in the previous libcrypto errata caused an error when reading ASN.1 elements over 16kb. Patches for OpenBSD are available. Updated LibreSSL-portable releases will be available later. http://ftp.openbsd.org/pub/OpenBSD/patches/5.9/common/009_crypto.patch.sig http://ftp.openbsd.org/pub/OpenBSD/patches/5.8/common/015_crypto.patch.sig
Re: more YP cleanup bits
> The best part here is the comment in yp_prot.h: how many years has it > been, Theo? Started writing the code in Feb 1992, and probably that comment in April.
more YP cleanup bits
Since we don't export _yp_dobind() anymore, we should stop declaring it in the public headers and instead declare it as hidden in the internal headers, without the extra jockeying of PROTO_NORMAL/DEF_WEAK. While here, mark the __ypexclude_* as hidden. The best part here is the comment in yp_prot.h: how many years has it been, Theo? ok? Philip Guenther Index: include/rpcsvc/yp_prot.h === RCS file: /data/src/openbsd/src/include/rpcsvc/yp_prot.h,v retrieving revision 1.9 diff -u -p -r1.9 yp_prot.h --- include/rpcsvc/yp_prot.h28 Sep 2015 20:49:24 - 1.9 +++ include/rpcsvc/yp_prot.h29 May 2016 23:48:18 - @@ -190,29 +190,6 @@ struct ypresp_maplist { #define YP_VERS((unsigned long)-8) /* YP server version mismatch */ /* - * Sun's header file says: - * "Domain binding data structure, used by ypclnt package and ypserv modules. - * Users of the ypclnt package (or of this protocol) don't HAVE to know about - * it, but it must be available to users because _yp_dobind is a public - * interface." - * - * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is - * a public interface, and I don't know any reason anyone would want to call - * it. But, just in case anyone does actually expect it to be available.. - * we provide this.. exactly as Sun wants it. - */ -struct dom_binding { - struct dom_binding *dom_pnext; - char dom_domain[YPMAXDOMAIN + 1]; - struct sockaddr_in dom_server_addr; - unsigned short dom_server_port; - int dom_socket; - CLIENT *dom_client; - unsigned short dom_local_port; - long dom_vers; -}; - -/* * YPBIND PROTOCOL: * * ypbind supports the following procedures: Index: include/rpcsvc/ypclnt.h === RCS file: /data/src/openbsd/src/include/rpcsvc/ypclnt.h,v retrieving revision 1.9 diff -u -p -r1.9 ypclnt.h --- include/rpcsvc/ypclnt.h 22 Jan 2004 21:48:02 - 1.9 +++ include/rpcsvc/ypclnt.h 29 May 2016 23:48:24 - @@ -63,8 +63,6 @@ struct ypall_callback { __BEGIN_DECLS intyp_bind(const char *); -struct dom_binding; -int_yp_dobind(const char *, struct dom_binding **); void yp_unbind(const char *); intyp_get_default_domain(char **); intyp_match(const char *, const char *, const char *, int , char **, Index: lib/libc/hidden/rpcsvc/ypclnt.h === RCS file: /data/src/openbsd/src/lib/libc/hidden/rpcsvc/ypclnt.h,v retrieving revision 1.1 diff -u -p -r1.1 ypclnt.h --- lib/libc/hidden/rpcsvc/ypclnt.h 13 Sep 2015 20:57:28 - 1.1 +++ lib/libc/hidden/rpcsvc/ypclnt.h 29 May 2016 23:52:58 - @@ -20,7 +20,11 @@ #include_next -PROTO_NORMAL(_yp_dobind); +__BEGIN_HIDDEN_DECLS +struct dom_binding; +int_yp_dobind(const char *, struct dom_binding **); +__END_HIDDEN_DECLS + PROTO_DEPRECATED(yp_all); PROTO_NORMAL(yp_bind); PROTO_NORMAL(yp_first); Index: lib/libc/yp/yp_bind.c === RCS file: /data/src/openbsd/src/lib/libc/yp/yp_bind.c,v retrieving revision 1.27 diff -u -p -r1.27 yp_bind.c --- lib/libc/yp/yp_bind.c 29 May 2016 22:42:24 - 1.27 +++ lib/libc/yp/yp_bind.c 29 May 2016 23:53:16 - @@ -248,7 +248,6 @@ gotdata: *ypdb = ysd; return 0; } -DEF_WEAK(_yp_dobind); void _yp_unbind(struct dom_binding *ypb) Index: lib/libc/yp/ypexclude.h === RCS file: /data/src/openbsd/src/lib/libc/yp/ypexclude.h,v retrieving revision 1.1 diff -u -p -r1.1 ypexclude.h --- lib/libc/yp/ypexclude.h 3 Jun 2009 16:02:44 - 1.1 +++ lib/libc/yp/ypexclude.h 29 May 2016 23:42:53 - @@ -36,6 +36,8 @@ struct _ypexclude { struct _ypexclude *next; }; +__BEGIN_HIDDEN_DECLS int __ypexclude_add(struct _ypexclude **, const char *); int __ypexclude_is(struct _ypexclude **, const char *); void __ypexclude_free(struct _ypexclude **); +__END_HIDDEN_DECLS
Re: libc/i386: add setjmp cookies
On Sun, 29 May 2016, Philip Guenther wrote: > On Sun, 29 May 2016, Philip Guenther wrote: > > It took a few beers, but I finally tackled the register-poor i386. This > > diffs add setjmp cookies and--while we're here--eliminates the use of > > sigblock/sigsetmask. > > > > For bonus points, I scrambled the cookie offsets among the three calls > > (_setjmp/setjmp/sigsetjmp) so if something tries to mix calls, using > > longjmp() on a buffer from sigsetjmp(), for example, it'll find itself at > > a random address. > > > > This is the diff -w output to it easier to see what is actually changing. > > The real diff has more whitespace adjustments to line up columns. > > > > No regressions against regress/lib/libc/*setjmp* > > > > ok? > > This diff has switched to failing after updating other parts of my src > tree, so hold on playing with it for now... I think I flubbed my test setup before and was 'testing' the unchanged libc. This time the regress tests are happy even after installing the updated version and it's successfully done a build and rebooted to it. Philip Index: _setjmp.S === RCS file: /data/src/openbsd/src/lib/libc/arch/i386/gen/_setjmp.S,v retrieving revision 1.5 diff -u -p -r1.5 _setjmp.S --- _setjmp.S 7 Aug 2005 11:30:38 - 1.5 +++ _setjmp.S 29 May 2016 20:12:47 - @@ -33,6 +33,8 @@ #include + .global __jmpxor + /* * C library -- _setjmp, _longjmp * @@ -44,28 +46,45 @@ */ ENTRY(_setjmp) + call1f +1: popl%ecx + addl$__jmpxor-1b,%ecx # load cookie address movl4(%esp),%eax movl0(%esp),%edx - movl%edx, 0(%eax) /* rta */ + xorl0(%ecx),%edx# use eip cookie + movl%edx, 0(%eax) movl%ebx, 4(%eax) - movl%esp, 8(%eax) - movl%ebp,12(%eax) + movl%esp, %edx + xorl4(%ecx),%edx# use esp cookie + movl%edx, 8(%eax) + movl8(%ecx),%ecx# load ebp cookie over cookie address + xorl%ebp, %ecx + movl%ecx,12(%eax) movl%esi,16(%eax) movl%edi,20(%eax) xorl%eax,%eax ret +END(_setjmp) ENTRY(_longjmp) - movl4(%esp),%edx - movl8(%esp),%eax - movl0(%edx),%ecx - movl4(%edx),%ebx - movl8(%edx),%esp + call1f +1: popl%ecx + addl$__jmpxor-1b,%ecx # load cookie address + movl 4(%esp),%edx + movl 8(%esp),%eax + movl 4(%edx),%ebx + movl 8(%edx),%esi # load xor'ed esp into safe register + xorl 4(%ecx),%esi # use esp cookie + movl %esi, %esp # un-xor'ed esp is safe to use movl12(%edx),%ebp + xorl 8(%ecx),%ebp # use ebp cookie movl16(%edx),%esi movl20(%edx),%edi + movl 0(%ecx),%ecx # load eip cookie over cookie address + xorl 0(%edx),%ecx # overwrite eip cookie testl %eax,%eax jnz 1f incl%eax 1: movl%ecx,0(%esp) ret +END(_longjmp) Index: setjmp.S === RCS file: /data/src/openbsd/src/lib/libc/arch/i386/gen/setjmp.S,v retrieving revision 1.10 diff -u -p -r1.10 setjmp.S --- setjmp.S13 Sep 2015 07:36:58 - 1.10 +++ setjmp.S29 May 2016 20:13:39 - @@ -31,7 +31,17 @@ * SUCH DAMAGE. */ -#include +#include "SYS.h" + + .section.openbsd.randomdata,"aw",@progbits + .balign 4 + .globl __jmpxor + .hidden __jmpxor +__jmpxor: + .zero 4*3 # (eip, esp, ebp) + END(__jmpxor) + .type __jmpxor,@object + /* * C library -- setjmp, longjmp @@ -44,50 +54,60 @@ */ ENTRY(setjmp) - PIC_PROLOGUE - pushl $0 -#ifdef __PIC__ - callPIC_PLT(_C_LABEL(_libc_sigblock)) -#else - call_C_LABEL(_libc_sigblock) -#endif - addl$4,%esp - PIC_EPILOGUE + pushl $0 /* mask = empty */ + pushl $1 /* how = SIG_BLOCK */ + call1f +1: movl$(SYS_sigprocmask),%eax + int $0x80 /* leave oset in %eax */ + popl%edx + addl$8,%esp + addl$__jmpxor-1b,%edx # load cookie address movl4(%esp),%ecx - movl0(%esp),%edx - movl%edx, 0(%ecx) + movl%eax,24(%ecx) movl%ebx, 4(%ecx) - movl%esp, 8(%ecx) - movl%ebp,12(%ecx) + movl%esp, %eax + xorl0(%edx),%eax# use esp cookie + movl%eax, 8(%ecx) + movl%ebp, %eax + xorl4(%edx),%eax# use ebp cookie + movl%eax,12(%ecx) movl%esi,16(%ecx)
Re: find errors in "make tags"
frantisek holop, 29 May 2016 16:24: > btw. making tags for /usr/src fails for me atm: > ... > ===> gnu/usr.bin/cc/cc_int > make: don't know how to make genrtl.c (prerequisite of: tags) > Stop in gnu/usr.bin/cc/cc_int > *** Error 2 in gnu/usr.bin/cc (:48 'tags') > *** Error 1 in gnu/usr.bin (:48 'tags') > *** Error 1 in gnu (:48 'tags') > *** Error 1 in /usr/src (:48 'tags') this is false alarm, i was missing a make depend. sorry about this noise. -f -- the smallest handcuff in the world is a wedding ring.
disklabel(8): refactor readlabel() for a better placed pledge
The readlabel() function in disklabel() does two things: it reads the disklabel from the device using a ioctl() and then parses it into some strings. We can't pledge beforehand since we have no way of knowing the file we process is actually a disk device. However, once the ioctl() succeeds, we know that we deal with a disk and we can do all further processing of the untrusted data under pledge. Thus, split up readlabel() into two functions, and pledge between the two function calls. This seems cleaner than moving some of the pledging into readlabel, because this would make the different pledge regimes harder to discern. I tested the diff with make release on amd64. Index: disklabel.c === RCS file: /var/cvs/src/sbin/disklabel/disklabel.c,v retrieving revision 1.219 diff -u -p -r1.219 disklabel.c --- disklabel.c 29 May 2016 17:02:21 - 1.219 +++ disklabel.c 29 May 2016 20:41:50 - @@ -206,20 +206,26 @@ main(int argc, char *argv[]) if (f < 0) err(4, "%s", specname); - if (op != WRITE || aflag || dflag) + if (op != WRITE || aflag || dflag) { readlabel(f); - else if (argc == 2 || argc == 3) + + if (op == EDIT || op == EDITOR || aflag) { + if (pledge("stdio rpath wpath cpath disklabel proc " + "exec", NULL) == -1) + err(1, "pledge"); + } else { + if (pledge("stdio rpath wpath disklabel", NULL) == -1) + err(1, "pledge"); + } + + parselabel(); + } else if (argc == 2 || argc == 3) { makelabel(argv[1], argc == 3 ? argv[2] : NULL, &lab); - else - usage(); - if (op == EDIT || op == EDITOR || aflag) { - if (pledge("stdio rpath wpath cpath disklabel proc exec", NULL) == -1) - err(1, "pledge"); - } else { if (pledge("stdio rpath wpath disklabel", NULL) == -1) err(1, "pledge"); - } + } else + usage(); if (autotable != NULL) parse_autotable(autotable); @@ -353,9 +359,6 @@ l_perror(char *s) void readlabel(int f) { - char *partname, *partduid; - struct fstab *fsent; - int i; if (cflag && ioctl(f, DIOCRLDINFO) < 0) err(4, "ioctl DIOCRLDINFO"); @@ -367,6 +370,14 @@ readlabel(int f) if (ioctl(f, DIOCGDINFO, &lab) < 0) err(4, "ioctl DIOCGDINFO"); } +} + +void +parselabel(void) +{ + char *partname, *partduid; + struct fstab *fsent; + int i; i = asprintf(&partname, "/dev/%s%c", dkname, 'a'); if (i == -1) Index: extern.h === RCS file: /var/cvs/src/sbin/disklabel/extern.h,v retrieving revision 1.27 diff -u -p -r1.27 extern.h --- extern.h17 Oct 2015 13:27:08 - 1.27 +++ extern.h29 May 2016 20:40:30 - @@ -28,6 +28,7 @@ void display_partition(FILE *, struct di intduid_parse(struct disklabel *, char *); void readlabel(int); +void parselabel(void); struct disklabel *makebootarea(char *, struct disklabel *); inteditor(int); void editor_allocspace(struct disklabel *);
lockmgr() api removal
It is time for the lockmgr() api to die. The api is only used by filesystems, where it is a trivial change to use rrw locks instead. All it needs is LK_* defines for the RW_* flags. (See the sys/lock.h hunk in the diff below.) The ffs regress tests display the same number of fail/ok results before and after applying diff below, and I have done some manual testing with various filesystems on amd64 and macppc. Again, the purpose is to make filesystem code less scary and more comprehensible. Ok? natano Index: distrib/sets/lists/comp/mi === RCS file: /cvs/src/distrib/sets/lists/comp/mi,v retrieving revision 1.1233 diff -u -p -r1.1233 mi --- distrib/sets/lists/comp/mi 23 May 2016 00:59:55 - 1.1233 +++ distrib/sets/lists/comp/mi 29 May 2016 18:13:57 - @@ -2712,7 +2712,6 @@ ./usr/share/man/man9/kthread.9 ./usr/share/man/man9/ktrace.9 ./usr/share/man/man9/loadfirmware.9 -./usr/share/man/man9/lock.9 ./usr/share/man/man9/log.9 ./usr/share/man/man9/malloc.9 ./usr/share/man/man9/mbuf.9 Index: share/man/man9/Makefile === RCS file: /cvs/src/share/man/man9/Makefile,v retrieving revision 1.276 diff -u -p -r1.276 Makefile --- share/man/man9/Makefile 25 Apr 2016 19:24:42 - 1.276 +++ share/man/man9/Makefile 29 May 2016 18:14:11 - @@ -20,7 +20,7 @@ MAN= aml_evalnode.9 atomic_add_int.9 ato ieee80211_radiotap.9 if_get.9 if_rxr_init.9 ifq_enqueue.9 \ ifq_deq_begin.9 iic.9 intro.9 inittodr.9 intr_barrier.9 \ kern.9 km_alloc.9 knote.9 kthread.9 ktrace.9 \ - loadfirmware.9 lock.9 log.9 \ + loadfirmware.9 log.9 \ malloc.9 membar_sync.9 mbuf.9 mbuf_tags.9 md5.9 mi_switch.9 \ microtime.9 ml_init.9 mq_init.9 mutex.9 \ namei.9 \ Index: share/man/man9/VOP_LOOKUP.9 === RCS file: /cvs/src/share/man/man9/VOP_LOOKUP.9,v retrieving revision 1.35 diff -u -p -r1.35 VOP_LOOKUP.9 --- share/man/man9/VOP_LOOKUP.9 23 May 2016 09:31:28 - 1.35 +++ share/man/man9/VOP_LOOKUP.9 29 May 2016 18:14:11 - @@ -1,6 +1,7 @@ .\" $OpenBSD: VOP_LOOKUP.9,v 1.35 2016/05/23 09:31:28 natano Exp $ .\" .\" Copyright (c) 2003 Ted Unangst +.\" Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -565,16 +566,54 @@ to lock a vnode. It should not be used by other file system code. .Fn VOP_UNLOCK unlocks a vnode. -.Fn VOP_ISLOCKED -returns 1 if -.Fa vp -is locked and 0 if not. -It should be used cautiously, as not all file systems implement locks -effectively. Note the asymmetry between .Xr vn_lock 9 and .Fn VOP_UNLOCK . +.Pp +.Fa flags +may contain the following flags: +.Pp +.Bl -tag -width LK_RECURSEFAIL -compact -offset indent +.It Dv LK_EXCLUSIVE +Acquire an exclusive lock. +.It Dv LK_SHARED +Acquire a shared lock. +.It Dv LK_NOWAIT +Don't wait if the vnode lock is held by someone else +(may still wait on reclamation lock). +.It Dv LK_RECURSEFAIL +Attempt at recursive lock fails. +.It Dv LK_DRAIN +Wait for all activity on the lock to end, then mark it decommissioned. +This feature is used to ensure that no other activity can occur while the +underlying object of a vnode is being cleaned out. +Must be used in combination with +.Dv LK_EXCLUSIVE . +.El +.Pp +.Fn VOP_ISLOCKED +returns one of the following values: +.Pp +.Bl -tag -width LK_EXCLUSIVE -compact -offset indent +.It Dv LK_EXCLUSIVE +.Fa vp +is locked for exclusive access by the calling thread. +.It Dv LK_EXCLOTHER +.Fa vp +is locked for exclusive access by a different thread. +.It Dv LK_SHARED +.Fa vp +is locked for shared access. +The current thread may be one of the threads that have it locked. +.It 0 +.Fa vp +is not locked. +.El +.Pp +.Fn VOP_ISLOCKED +should be used cautiously, as not all file systems implement locks +effectively. .Pp .It Fn VOP_KQFILTER vp kn Register the Index: share/man/man9/mutex.9 === RCS file: /cvs/src/share/man/man9/mutex.9,v retrieving revision 1.22 diff -u -p -r1.22 mutex.9 --- share/man/man9/mutex.9 13 Feb 2014 14:23:05 - 1.22 +++ share/man/man9/mutex.9 29 May 2016 18:14:11 - @@ -104,7 +104,6 @@ function will return non-zero if it succ .Fa mtxp , otherwise it will return 0. .Sh SEE ALSO -.Xr lockmgr 9 , .Xr msleep 9 , .Xr rwlock 9 , .Xr spl 9 Index: share/man/man9/rwlock.9 === RCS file: /cvs/src/share/man/man9/rwlock.9,v retrieving revision 1.17 diff -u -p -r1.17 rwlock.9 --- share/man/man9/rwlock.9 9 Jul 2014 18:00:09 - 1.17 +++ share/man/man9/rwlock.9 29 May 2016 18:14:11 - @@ -183,8 +183,8 @@ can be called during autoconf, from proc .Pp All other functions can be called during aut
W^X compliance
A few developers are starting to push for some W^X compliance in the ports tree. The following diff is in snapshots. In the near future, different versions of this diff with different semantics may be show up in other snapshots. The purpose of this change in snapshots is to help developers establish priorities as to what they try to get repaired first. This is a very lightly restrictice policy which will provide alerts about programs which perform W^X violations. Those alerts are rate limited. If sysctl kern.wxabort=1, then the processes are killed, typically generating a core file. Upon seeing messages like this some of you may feel like you need to report the problem. Please do not complain to the ports group; they will already be aware of the problem, and will become overwhelmed. If anyone decides to engage an upstream developer about their software performing W^X violations, please be respectful, detailed, and calm. The major W^X violators which remain are not simple pieces of software, and their authors will not make improvements in this area in a fortnight. It is going to take a lot of patience. At least with these changes we bring the scope of the problem to light, and hopefully find some upstreams who agree to improve. Index: sys/exec.h === RCS file: /cvs/src/sys/sys/exec.h,v retrieving revision 1.31 diff -u -p -u -r1.31 exec.h --- sys/exec.h 28 Sep 2015 20:32:59 - 1.31 +++ sys/exec.h 28 May 2016 16:24:56 - @@ -142,6 +142,7 @@ struct exec_package { #defineEXEC_HASARGL0x0004 /* has fake args vector */ #defineEXEC_SKIPARG0x0008 /* don't copy user-supplied argv[0] */ #defineEXEC_DESTR 0x0010 /* destructive ops performed */ +#defineEXEC_WXNEEDED 0x0020 /* executable will violate W^X */ #ifdef _KERNEL /* Index: sys/proc.h === RCS file: /cvs/src/sys/sys/proc.h,v retrieving revision 1.220 diff -u -p -u -r1.220 proc.h --- sys/proc.h 10 May 2016 18:39:53 - 1.220 +++ sys/proc.h 29 May 2016 16:30:27 - @@ -190,6 +190,8 @@ struct process { struct rusage ps_cru; /* sum of stats for reaped children */ struct itimerval ps_timer[3]; /* timers, indexed by ITIMER_* */ + u_int64_t ps_wxcounter; + /* End area that is zeroed on creation. */ #defineps_endzero ps_startcopy @@ -259,6 +261,7 @@ struct process { #definePS_ZOMBIE 0x0004 /* Dead and ready to be waited for */ #definePS_NOBROADCASTKILL 0x0008 /* Process excluded from kill -1. */ #definePS_PLEDGE 0x0010 /* Has called pledge(2) */ +#definePS_WXNEEDED 0x0020 /* Process may violate W^X */ #definePS_BITS \ ("\20" "\01CONTROLT" "\02EXEC" "\03INEXEC" "\04EXITING" "\05SUGID" \ Index: kern/exec_elf.c === RCS file: /cvs/src/sys/kern/exec_elf.c,v retrieving revision 1.121 diff -u -p -u -r1.121 exec_elf.c --- kern/exec_elf.c 10 May 2016 18:39:51 - 1.121 +++ kern/exec_elf.c 28 May 2016 16:23:33 - @@ -76,6 +76,7 @@ #include #include #include +#include #include #include #include @@ -878,6 +879,23 @@ ELFNAME(os_pt_note)(struct proc *p, stru if ((error = ELFNAME(read_from)(p, epp->ep_vp, eh->e_phoff, (caddr_t)hph, phsize)) != 0) goto out1; + + for (ph = hph; ph < &hph[eh->e_phnum]; ph++) { + if (ph->p_type == PT_OPENBSD_WXNEEDED) { + int wxallowed = (epp->ep_vp->v_mount && + (epp->ep_vp->v_mount->mnt_flag & MNT_WXALLOWED)); + + if (!wxallowed) { + log(LOG_NOTICE, + "%s(%d): W^X binary outside wxallowed mountpoint\n", + epp->ep_name, p->p_pid); + error = ENOEXEC; + goto out1; + } + epp->ep_flags |= EXEC_WXNEEDED; + break; + } + } for (ph = hph; ph < &hph[eh->e_phnum]; ph++) { if (ph->p_type != PT_NOTE || Index: kern/kern_exec.c === RCS file: /cvs/src/sys/kern/kern_exec.c,v retrieving revision 1.178 diff -u -p -u -r1.178 kern_exec.c --- kern/kern_exec.c23 May 2016 20:11:47 - 1.178 +++ kern/kern_exec.c28 May 2016 16:19:21 - @@ -707,6 +707,9 @@ sys_execve(struct proc *p, void *v, regi if ((pack.ep_flags & EXEC_HASFD) && pack.ep_fd < 255) p->p_descfd = pack.ep_fd; + if (pack.ep_flags & EXEC_WXNEEDED) + p->p_p->ps_flags |= PS_WXNEEDED; +
schizo0: safari error
Hi, I have a sun blade 1000 which I use (infrequently) for testing stuff big endian. Recently it has started locking up with the message: schizo0: safari error It seems to be a hard lock which cannot be recovered from. Sometimes the lock is during boot, sometimes it is after 10 minutes or so. I think the hardware is OK. 'test all' in the eeprom passes. Well, actually the floppy test fails, but that's because there is no floppy drive. I built a kernel with schizo debugging on another sparc64 machine, and booted it on the trouble machine. Sadly, no clues are printed around the time of the lock. Any ideas? I'm going to try backing out: http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/arch/sparc64/dev/schizo.c.diff?r1=1.63&r2=1.64 Here's a dmesg from the debug kernel: console is keyboard/display Copyright (c) 1982, 1986, 1989, 1991, 1993 The Regents of the University of California. All rights reserved. Copyright (c) 1995-2016 OpenBSD. All rights reserved. http://www.OpenBSD.org OpenBSD 6.0-beta (GENERIC.MP) #0: Sat May 28 19:43:36 BST 2016 e...@netra.home:/usr/src/sys/arch/sparc64/compile/GENERIC.MP real mem = 1073741824 (1024MB) avail mem = 1038516224 (990MB) mpath0 at root scsibus0 at mpath0: 256 targets mainbus0 at root: SUNW,Sun-Blade-1000 (2 X UltraSPARC-III) cpu0 at mainbus0: SUNW,UltraSPARC-III (rev 5.14) @ 900 MHz cpu0: physical 32K instruction (32 b/l), 64K data (32 b/l), 8192K external (512 b/l) cpu1 at mainbus0: SUNW,UltraSPARC-III (rev 5.14) @ 750 MHz cpu1: physical 32K instruction (32 b/l), 64K data (32 b/l), 8192K external (512 b/l) "memory-controller" at mainbus0 not configured "memory-controller" at mainbus0 not configured schizo0 at mainbus0: "Schizo", version 4, ign 200, bus B 0 to 0 schizo0: schizo_iommu_init: getprop failed, using iobase=0x, tsbsize=7 dvma map c000- schizo_bus_map: type 0 off 0 sz 100 flags 0 cspace 0pci0 at schizo0 ebus0 at pci0 dev 5 function 0 "Sun RIO EBus" rev 0x01 "flashprom" at ebus0 addr 0-1f not configured pcfiic0 at ebus0 addr 2e-2f, 2d-2d ivec 0x23schizo_bus_map: type 2 off 7e2e sz 2 flags 0 cspace 2schizo_bus_map: type 2 off 7e2d sz 1 flags 0 cspace 2 iic0 at pcfiic0 bbc0 at ebus0 addr 0-fschizo_bus_map: type 2 off 7e00 sz 10 flags 0 cspace 2: AID 0x00 ppm0 at ebus0 addr e-28, 728000-728003, 30002e-30002f, 300600-300607schizo_bus_map: type 2 off 7e30002e sz 2 flags 0 cspace 2schizo_bus_map: type 2 off 7e300600 sz 8 flags 0 cspace 2 pcfiic1 at ebus0 addr 30-31 ivec 0x23schizo_bus_map: type 2 off 7e30 sz 2 flags 0 cspace 2 iic1 at pcfiic1 admtemp0 at iic1 addr 0x18: max1617 admtemp1 at iic1 addr 0x4c: max1617 tda0 at iic1 addr 0x24 "scm001" at iic1 addr 0x20 not configured "firei" at iic1 addr 0x30 not configured beep0 at ebus0 addr 32-37schizo_bus_map: type 2 off 7e32 sz 6 flags 0 cspace 2: clock 75MHz audioce0 at ebus0 addr 20-2000ff, 702000-70200f, 704000-70400f, 722000-722003 ivec 0x20 ivec 0x21schizo_bus_map: type 2 off 7e20 sz 100 flags 2 cspace 2schizo_bus_map: type 2 off 7e702000 sz 10 flags 2 cspace 2schizo_bus_map: type 2 off 7e704000 sz 10 flags 2 cspace 2schizo_bus_map: type 2 off 7e722000 sz 4 flags 2 cspace 2: nvaddrs 0 audio0 at audioce0 rtc0 at ebus0 addr 300070-300071 ivec 0x24schizo_bus_map: type 2 off 7e300070 sz 2 flags 0 cspace 2: ds1287 "gpio" at ebus0 addr 300600-300607 not configured pmc0 at ebus0 addr 300700-300701schizo_bus_map: type 2 off fff38700 sz 0 flags 16 cspace 2 lpt0 at ebus0 addr 300278-300287, 30002e-30002f, 70-7f ivec 0x1cschizo_bus_map: type 2 off 7e300278 sz 10 flags 0 cspace 2schizo_bus_map: type 2 off 7e30002e sz 2 flags 0 cspace 2: polled sab0 at ebus0 addr 40-40007f ivec 0x22schizo_bus_map: type 2 off 7e40 sz 80 flags 0 cspace 2: rev 3.2 sabtty0 at sab0 port 0 sabtty1 at sab0 port 1 gem0 at pci0 dev 5 function 1 "Sun ERI Ether" rev 0x01schizo_bus_map: type 2 off 10 sz 2 flags 0 cspace 2schizo_bus_map: type 2 off 40 sz 40 flags 0 cspace 2: ivec 0x21d, address 00:03:ba:10:0e:6a luphy0 at gem0 phy 1: LU6612 10/100 PHY, rev. 1 "Sun FireWire" rev 0x01 at pci0 dev 5 function 2 not configured ohci0 at pci0 dev 5 function 3 "Sun USB" rev 0x01schizo_bus_map: type 2 off 100 sz 8000 flags 0 cspace 2: ivec 0x21f, version 1.0, legacy support siop0 at pci0 dev 6 function 0 "Symbios Logic 53c875" rev 0x37schizo_bus_map: type 2 off 124000 sz 100 flags 0 cspace 2schizo_bus_map: type 1 off 300 sz 100 flags 0 cspace 1: ivec 0x218schizo_bus_map: type 2 off 126000 sz 1000 flags 0 cspace 2, using 4K of on-board RAM scsibus1 at siop0: 16 targets, initiator 7 cd0 at scsibus1 targ 0 lun 0: SCSI2 5/cdrom removable siop1 at pci0 dev 6 function 1 "Symbios Logic 53c875" rev 0x37schizo_bus_map: type 2 off 128000 sz 100 flags 0 cspace 2schizo_bus_map: type 1 off 400 sz 100 flags 0 cspace 1: ivec 0x219schizo_bus_map: type 2 off 12a000 sz 1000 flags 0 cspace 2, using 4K of on-board RAM scsibus2 at siop1:
find errors in "make tags"
$ cd /usr/src/sys $ make tags cd /usr/src/sys/kern; make tags ... find: /usr/src/sys/arch/armish/../../lib/libkern/arch/armish: No such file or directory ... find: /usr/src/sys/arch/armv7/../../lib/libkern/arch/armv7: No such file or directory ... find: /usr/src/sys/arch/landisk/../../lib/libkern/arch/landisk: No such file or directory ... find: /usr/src/sys/arch/loongson/../../lib/libkern/arch/loongson: No such file or directory ... find: /usr/src/sys/arch/luna88k/../../lib/libkern/arch/luna88k: No such file or directory ... find: /usr/src/sys/arch/macppc/../../lib/libkern/arch/macppc: No such file or directory ... find: /usr/src/sys/arch/octeon/../../lib/libkern/arch/octeon: No such file or directory ... find: /usr/src/sys/arch/sgi/../../lib/libkern/arch/sgi: No such file or directory ... find: /usr/src/sys/arch/socppc/../../lib/libkern/arch/socppc: No such file or directory ... find: /usr/src/sys/arch/zaurus/../../lib/libkern/arch/zaurus: No such file or directory if these archs are using libkern/arch/arm instead, and if there is a chance that some .h files will show up there in the future, maybe changing _mach to _arch is preferable. this patch does that. removed some needless quotes while here. btw. making tags for /usr/src fails for me atm: ... ===> gnu/usr.bin/cc/cc_int make: don't know how to make genrtl.c (prerequisite of: tags) Stop in gnu/usr.bin/cc/cc_int *** Error 2 in gnu/usr.bin/cc (:48 'tags') *** Error 1 in gnu/usr.bin (:48 'tags') *** Error 1 in gnu (:48 'tags') *** Error 1 in /usr/src (:48 'tags') -f Index: sys/arch/armish/Makefile === RCS file: /cvs/src/sys/arch/armish/Makefile,v retrieving revision 1.6 diff -u -p -r1.6 Makefile --- sys/arch/armish/Makefile8 Dec 2013 14:46:39 - 1.6 +++ sys/arch/armish/Makefile29 May 2016 13:53:54 - @@ -25,7 +25,7 @@ tags:: eval "_mach=\"`make -V _mach -f $${TDIR}/Makefile`\"" && \ eval "_machdir=\$S/arch/$${_mach}" && \ eval "_archdir=\$S/arch/$${_arch}" && \ - eval "HFILES=\"`find $S \( -path $S/'arch' -o -path $S/stand -o -path $S/lib/libsa -o -path $S'/lib/libkern/arch' \) -prune -o -name '*.h'; find $${_machdir} $${_archdir} $S/lib/libkern/arch/$${_mach} \( -name boot -o -name stand \) -prune -o -name '*.h'`\"" && \ + eval "HFILES=\"`find $S \( -path $S/arch -o -path $S/stand -o -path $S/lib/libsa -o -path $S/lib/libkern/arch \) -prune -o -name '*.h'; find $${_machdir} $${_archdir} $S/lib/libkern/arch/$${_arch} \( -name boot -o -name stand \) -prune -o -name '*.h'`\"" && \ eval "SFILES=\"`make -V SFILES -f $${TDIR}/Makefile`\"" && \ eval "CFILES=\"`make -V CFILES -f $${TDIR}/Makefile`\"" && \ eval "AFILES=\"`make -V AFILES -f $${TDIR}/Makefile`\"" && \ Index: sys/arch/armv7/Makefile === RCS file: /cvs/src/sys/arch/armv7/Makefile,v retrieving revision 1.3 diff -u -p -r1.3 Makefile --- sys/arch/armv7/Makefile 23 May 2016 02:19:46 - 1.3 +++ sys/arch/armv7/Makefile 29 May 2016 13:53:54 - @@ -25,7 +25,7 @@ tags:: eval "_mach=\"`make -V _mach -f $${TDIR}/Makefile`\"" && \ eval "_machdir=\$S/arch/$${_mach}" && \ eval "_archdir=\$S/arch/$${_arch}" && \ - eval "HFILES=\"`find $S \( -path $S/'arch' -o -path $S/stand -o -path $S/lib/libsa -o -path $S'/lib/libkern/arch' \) -prune -o -name '*.h'; find $${_machdir} $${_archdir} $S/lib/libkern/arch/$${_mach} \( -name boot -o -name stand \) -prune -o -name '*.h'`\"" && \ + eval "HFILES=\"`find $S \( -path $S/arch -o -path $S/stand -o -path $S/lib/libsa -o -path $S/lib/libkern/arch \) -prune -o -name '*.h'; find $${_machdir} $${_archdir} $S/lib/libkern/arch/$${_arch} \( -name boot -o -name stand \) -prune -o -name '*.h'`\"" && \ eval "SFILES=\"`make -V SFILES -f $${TDIR}/Makefile`\"" && \ eval "CFILES=\"`make -V CFILES -f $${TDIR}/Makefile`\"" && \ eval "AFILES=\"`make -V AFILES -f $${TDIR}/Makefile`\"" && \ Index: sys/arch/landisk/Makefile === RCS file: /cvs/src/sys/arch/landisk/Makefile,v retrieving revision 1.7 diff -u -p -r1.7 Makefile --- sys/arch/landisk/Makefile 8 Dec 2013 14:46:39 - 1.7 +++ sys/arch/landisk/Makefile 29 May 2016 13:53:55 - @@ -25,7 +25,7 @@ tags:: eval "_mach=\"`make -V _mach -f $${TDIR}/Makefile`\"" && \ eval "_machdir=\$S/arch/$${_mach}" && \ eval "_archdir=\$S/arch/$${_arch}" && \ - eval "HFILES=\"`find $S \( -path $S/'arch' -o -path $S/stand -o -path $S/lib/libsa -o -path $S'/lib/libkern/arch' \) -prune -o -name '*.h'; find $${_machdir} $${_archdir} $S/lib/libkern/arch/$${_mach} \( -name boot -o -name stand \) -prune -o -name '*.h'`\"" && \ + eval "HFILES=\"`find $S \( -path $S/arch -o -path $S/stand -o -path $S/lib/libsa -o -path $S/lib/libkern/arch \)
Re: Fix begin of word bug in ed
Here's an updated diff based on a comment I found in vi's substitute code. When a 0-length match is found directly on the position where the previous non-0-length match ended it should skip that match. Consider the following: text: aabb command: s/a*/X/g without check: XXbXbX with check: XbXbX This command isn't possible in the current ed, since it borks out on an infinite loop detection, so the previous diff would still be an improvement, but it's not what sed/vi does. On 05/29/16 15:18, Martijn van Duren wrote: > Hello tech@, > > Here's a first attempt at fixing the begin of word bug as also found in > sed. It does a little more then I initially sed^ht out to do, but I also > found some other unexpected behaviour. > 1) It removes the isbinary test and the accompanying > NUL_TO_NEWLINE/NEWLINE_TO_NUL conversions. If a NUL-byte is found in a > text ed detects it as a binary file and converts every NUL to a newline > prior to doing the regexec commands. After this is done it converts > every newline back to a NUL-byte. Luckily one can never find a native > newline character in a binary file. Right? Right? > 2) Currently ed aborts the substitution when it finds a only-positioning > match on location 0 to prevent an infinite loop. Because of this s/^/X/g > will never match. If this occurs just increment the next offset by one. > 3) The else clause in the do/while loop contains similar code as the if > clause. So determine the offset, hoist the code above the if and remove > the else clause for readability. > 4) Don't increment the txt-pointer, but use REG_STARTEND|REG_NOTBOL > instead. This fixes the actual bug. > > There's still code in ed that uses the newline/NUL conversion, but we > don't support binary editing in ed, so if you do so it's at your own > risk. > It *might* be possible to make it work properly if the conversions were > removed and get_compiled_pattern in re.c would use REG_PEND, but I"m not > going to chase windmills. > > Any thoughts/comments? > > Minimally tested. > > martijn@ > Index: sub.c === RCS file: /cvs/src/bin/ed/sub.c,v retrieving revision 1.15 diff -u -p -r1.15 sub.c --- sub.c 22 Mar 2016 17:58:28 - 1.15 +++ sub.c 29 May 2016 14:16:29 - @@ -180,52 +180,54 @@ substitute_matching_text(regex_t *pat, l int off = 0; int changed = 0; int matchno = 0; - int i = 0; + int nempty = -1; + off_t i = 0, skip; regmatch_t rm[SE_MAX]; char *txt; char *eot; if ((txt = get_sbuf_line(lp)) == NULL) return ERR; - if (isbinary) - NUL_TO_NEWLINE(txt, lp->len); eot = txt + lp->len; - if (!regexec(pat, txt, SE_MAX, rm, 0)) { + rm[0].rm_so = 0; + rm[0].rm_eo = lp->len; + if (!regexec(pat, txt, SE_MAX, rm, REG_STARTEND)) { do { - if (!kth || kth == ++matchno) { - changed++; - i = rm[0].rm_so; - REALLOC(rbuf, rbufsz, off + i, ERR); - if (isbinary) - NEWLINE_TO_NUL(txt, rm[0].rm_eo); - memcpy(rbuf + off, txt, i); - off += i; +/* Don't allow an 0-length match after a non-0-length match */ + if (rm[0].rm_so == nempty && rm[0].rm_eo == nempty) { + rm[0].rm_so++; + rm[0].rm_eo = lp->len; + nempty = -1; + continue; + } + nempty = -1; + skip = (!kth || kth == ++matchno) ? + rm[0].rm_so : rm[0].rm_eo; + REALLOC(rbuf, rbufsz, off + skip - i, ERR); + memcpy(rbuf + off, txt + i, skip - i); + off += (skip - i); + i = rm[0].rm_eo; + if (!kth || kth == matchno) { + changed = 1; if ((off = apply_subst_template(txt, rm, off, pat->re_nsub)) < 0) return ERR; - } else { - i = rm[0].rm_eo; - REALLOC(rbuf, rbufsz, off + i, ERR); - if (isbinary) - NEWLINE_TO_NUL(txt, i); - memcpy(rbuf + off, txt, i); - off += i; + if (kth) + break; } - txt += rm[0].rm_eo; - } while (*txt && (!changed || ((gflag & GSG) && rm[0].rm_eo)) && -
Fix begin of word bug in ed
Hello tech@, Here's a first attempt at fixing the begin of word bug as also found in sed. It does a little more then I initially sed^ht out to do, but I also found some other unexpected behaviour. 1) It removes the isbinary test and the accompanying NUL_TO_NEWLINE/NEWLINE_TO_NUL conversions. If a NUL-byte is found in a text ed detects it as a binary file and converts every NUL to a newline prior to doing the regexec commands. After this is done it converts every newline back to a NUL-byte. Luckily one can never find a native newline character in a binary file. Right? Right? 2) Currently ed aborts the substitution when it finds a only-positioning match on location 0 to prevent an infinite loop. Because of this s/^/X/g will never match. If this occurs just increment the next offset by one. 3) The else clause in the do/while loop contains similar code as the if clause. So determine the offset, hoist the code above the if and remove the else clause for readability. 4) Don't increment the txt-pointer, but use REG_STARTEND|REG_NOTBOL instead. This fixes the actual bug. There's still code in ed that uses the newline/NUL conversion, but we don't support binary editing in ed, so if you do so it's at your own risk. It *might* be possible to make it work properly if the conversions were removed and get_compiled_pattern in re.c would use REG_PEND, but I"m not going to chase windmills. Any thoughts/comments? Minimally tested. martijn@ Index: sub.c === RCS file: /cvs/src/bin/ed/sub.c,v retrieving revision 1.15 diff -u -p -r1.15 sub.c --- sub.c 22 Mar 2016 17:58:28 - 1.15 +++ sub.c 29 May 2016 13:12:58 - @@ -180,52 +180,43 @@ substitute_matching_text(regex_t *pat, l int off = 0; int changed = 0; int matchno = 0; - int i = 0; + off_t i = 0, skip; regmatch_t rm[SE_MAX]; char *txt; char *eot; if ((txt = get_sbuf_line(lp)) == NULL) return ERR; - if (isbinary) - NUL_TO_NEWLINE(txt, lp->len); eot = txt + lp->len; - if (!regexec(pat, txt, SE_MAX, rm, 0)) { + rm[0].rm_so = 0; + rm[0].rm_eo = lp->len; + if (!regexec(pat, txt, SE_MAX, rm, REG_STARTEND)) { do { - if (!kth || kth == ++matchno) { - changed++; - i = rm[0].rm_so; - REALLOC(rbuf, rbufsz, off + i, ERR); - if (isbinary) - NEWLINE_TO_NUL(txt, rm[0].rm_eo); - memcpy(rbuf + off, txt, i); - off += i; + skip = (!kth || kth == ++matchno) ? + rm[0].rm_so : rm[0].rm_eo; + REALLOC(rbuf, rbufsz, off + skip - i, ERR); + memcpy(rbuf + off, txt + i, skip - i); + off += (skip - i); + i = rm[0].rm_eo; + if (!kth || kth == matchno) { + changed = 1; if ((off = apply_subst_template(txt, rm, off, pat->re_nsub)) < 0) return ERR; - } else { - i = rm[0].rm_eo; - REALLOC(rbuf, rbufsz, off + i, ERR); - if (isbinary) - NEWLINE_TO_NUL(txt, i); - memcpy(rbuf + off, txt, i); - off += i; + if (kth) + break; } - txt += rm[0].rm_eo; - } while (*txt && (!changed || ((gflag & GSG) && rm[0].rm_eo)) && - !regexec(pat, txt, SE_MAX, rm, REG_NOTBOL)); - i = eot - txt; - REALLOC(rbuf, rbufsz, off + i + 2, ERR); - if (i > 0 && !rm[0].rm_eo && (gflag & GSG)) { - seterrmsg("infinite substitution loop"); - return ERR; - } - if (isbinary) - NEWLINE_TO_NUL(txt, i); - memcpy(rbuf + off, txt, i); - memcpy(rbuf + off + i, "\n", 2); + + rm[0].rm_so = (rm[0].rm_so == rm[0].rm_eo) ? + rm[0].rm_eo + 1 : rm[0].rm_eo; + rm[0].rm_eo = lp->len; + } while ((txt + i < eot) && + !regexec(pat, txt, SE_MAX, rm, REG_STARTEND | REG_NOTBOL)); + REALLOC(rbuf, rbufsz, off + lp->len - i + 2, ERR); + memcpy(rbuf + off, txt + i, lp->len - i); + memcpy(rbuf + off + lp->len - i, "\n", 2); } - return chan
Re: libc/i386: add setjmp cookies
On Sun, 29 May 2016, Philip Guenther wrote: > It took a few beers, but I finally tackled the register-poor i386. This > diffs add setjmp cookies and--while we're here--eliminates the use of > sigblock/sigsetmask. > > For bonus points, I scrambled the cookie offsets among the three calls > (_setjmp/setjmp/sigsetjmp) so if something tries to mix calls, using > longjmp() on a buffer from sigsetjmp(), for example, it'll find itself at > a random address. > > This is the diff -w output to it easier to see what is actually changing. > The real diff has more whitespace adjustments to line up columns. > > No regressions against regress/lib/libc/*setjmp* > > ok? This diff has switched to failing after updating other parts of my src tree, so hold on playing with it for now... Philip
Re: libc/amd64: stop using sigblock/sigsetmask in setjmp/longjmp
Philip Guenther schreef op 2016-05-29 05:01: This converts setjmp/longjmp and their sig* versions to use the sigprocmask syscall directly instead of the obsolete sigblock/sigsetmask APIs. No change in the results of the regress/lib/libc/*setjmp* tests. Ok? ok kettenis@ Index: setjmp.S === RCS file: /data/src/openbsd/src/lib/libc/arch/amd64/gen/setjmp.S,v retrieving revision 1.6 diff -u -p -r1.6 setjmp.S --- setjmp.S12 May 2016 15:46:03 - 1.6 +++ setjmp.S20 May 2016 08:38:12 - @@ -37,7 +37,7 @@ */ -#include +#include "SYS.h" #include .section.openbsd.randomdata,"aw",@progbits @@ -59,10 +59,12 @@ __jmpxor: */ ENTRY(setjmp) - pushq %rdi - xorq%rdi,%rdi - call_C_LABEL(_libc_sigblock) - popq%rdi + movq%rdi,%r8/* save jmpbuf addr */ + movl$1,%edi /* how = SIG_BLOCK */ + xorl%esi,%esi /* set = empty */ + movl$SYS_sigprocmask,%eax + syscall + movq%r8,%rdi/* restore jmpbuf addr */ movq%rax,(_JB_SIGMASK * 8)(%rdi) movq(%rsp),%r11 @@ -91,10 +93,11 @@ ENTRY(longjmp) movq%rdi,%r12 movl%esi,%r8d - movq(_JB_SIGMASK * 8)(%rdi),%rdi - pushq %r8 - call_C_LABEL(_libc_sigsetmask) - popq%r8 + movq(_JB_SIGMASK * 8)(%rdi),%rsi/* get set from sc_mask */ + movl$3,%edi /* how = SIG_SETMASK */ + movl$SYS_sigprocmask,%eax + syscall + movl%r8d,%eax leaq __jmpxor(%rip),%rcx movq(_JB_RBX * 8)(%r12),%rbx @@ -112,7 +115,6 @@ ENTRY(longjmp) movq(_JB_R12 * 8)(%r12),%r12 xorq%rcx,%rcx - movl%r8d,%eax testl %eax,%eax jnz 1f incl%eax Index: sigsetjmp.S === RCS file: /data/src/openbsd/src/lib/libc/arch/amd64/gen/sigsetjmp.S,v retrieving revision 1.6 diff -u -p -r1.6 sigsetjmp.S --- sigsetjmp.S 12 May 2016 15:46:03 - 1.6 +++ sigsetjmp.S 20 May 2016 08:38:12 - @@ -37,7 +37,7 @@ */ -#include +#include "SYS.h" #include .hidden __jmpxor @@ -57,10 +57,12 @@ ENTRY(sigsetjmp) testl %esi,%esi jz 2f - pushq %rdi - xorq%rdi,%rdi - call_C_LABEL(_libc_sigblock) - popq%rdi + movq%rdi,%r8/* save jmpbuf addr */ + movl$1,%edi /* how = SIG_BLOCK */ + xorl%esi,%esi /* set = empty */ + movl$SYS_sigprocmask,%eax + syscall + movq%r8,%rdi/* restore jmpbuf addr */ movq%rax,(_JB_SIGMASK * 8)(%rdi) 2: movq(%rsp),%r11 @@ -87,13 +89,15 @@ END(sigsetjmp) ENTRY(siglongjmp) movq%rdi,%r12 - pushq %rsi + movl%esi,%r8d cmpl$0, (_JB_SIGFLAG * 8)(%rdi) jz 2f - movq(_JB_SIGMASK * 8)(%rdi),%rdi - call_C_LABEL(_libc_sigsetmask) -2: popq%rax + movq(_JB_SIGMASK * 8)(%rdi),%rsi/* get set from sc_mask */ + movl$3,%edi /* how = SIG_SETMASK */ + movl$SYS_sigprocmask,%eax + syscall +2: movl%r8d,%eax leaq __jmpxor(%rip),%rcx movq(_JB_RBX * 8)(%r12),%rbx
Re: libc: delete unused hash algorithms
On Sat, May 28, 2016 at 07:47:50PM -0700, Philip Guenther wrote: > > Overriding the hash algorithm used by the Berkeley DB bits isn't support > (it would break getpw* if nothing else) and hasn't been possible since the > symbol hiding effort last fall. So eliminate the redirection through a > variable and declare it as a hidden function to eliminate the relocations > for it. > > Ok? Looks good to me. libc shouldn't be a dumping ground for everyone's favorite hash function, especially if not even compiled in. > > > Philip Guenther > > > Index: hidden/db.h > === > RCS file: /data/src/openbsd/src/lib/libc/hidden/db.h,v > retrieving revision 1.3 > diff -u -p -r1.3 db.h > --- hidden/db.h 17 Oct 2015 21:48:42 - 1.3 > +++ hidden/db.h 20 May 2016 09:03:13 - > @@ -73,6 +73,9 @@ DB *__bt_open(const char *, int, int, co > DB *__hash_open(const char *, int, int, const HASHINFO *, int); > DB *__rec_open(const char *, int, int, const RECNOINFO *, int); > void __dbpanic(DB *dbp); > + > +/* Default hash function, from db/hash/hash_func.c */ > +u_int32_t__default_hash(const void *, size_t); > __END_HIDDEN_DECLS > > PROTO_NORMAL(dbopen); > Index: stdlib/hcreate.c > === > RCS file: /data/src/openbsd/src/lib/libc/stdlib/hcreate.c,v > retrieving revision 1.6 > diff -u -p -r1.6 hcreate.c > --- stdlib/hcreate.c 10 Sep 2015 18:13:46 - 1.6 > +++ stdlib/hcreate.c 20 May 2016 09:03:55 - > @@ -55,6 +55,8 @@ > #include > #include > > +#include /* for __default_hash */ > + > #ifndef _DIAGASSERT > #define _DIAGASSERT(x) > #endif > @@ -79,9 +81,6 @@ SLIST_HEAD(internal_head, internal_entry > #define MAX_BUCKETS_LG2 (sizeof (size_t) * 8 - 1 - 5) > #define MAX_BUCKETS ((size_t)1 << MAX_BUCKETS_LG2) > > -/* Default hash function, from db/hash/hash_func.c */ > -extern u_int32_t (*__default_hash)(const void *, size_t); > - > static struct internal_head *htable; > static size_t htablesize; > > @@ -164,7 +163,7 @@ hsearch(ENTRY item, ACTION action) > _DIAGASSERT(action == ENTER || action == FIND); > > len = strlen(item.key); > - hashval = (*__default_hash)(item.key, len); > + hashval = __default_hash(item.key, len); > > head = &htable[hashval & (htablesize - 1)]; > ie = SLIST_FIRST(head); > Index: db/hash/extern.h > === > RCS file: /data/src/openbsd/src/lib/libc/db/hash/extern.h,v > retrieving revision 1.8 > diff -u -p -r1.8 extern.h > --- db/hash/extern.h 27 Aug 2015 04:37:09 - 1.8 > +++ db/hash/extern.h 20 May 2016 09:04:27 - > @@ -56,9 +56,6 @@ int __put_page(HTAB *, char *, u_int32_ > void __reclaim_buf(HTAB *, BUFHEAD *); > int __split_page(HTAB *, u_int32_t, u_int32_t); > > -/* Default hash routine. */ > -extern u_int32_t (*__default_hash)(const void *, size_t); > - > #ifdef HASH_STATISTICS > extern int hash_accesses, hash_collisions, hash_expansions, hash_overflows; > #endif > Index: db/hash/hash_func.c > === > RCS file: /data/src/openbsd/src/lib/libc/db/hash/hash_func.c,v > retrieving revision 1.10 > diff -u -p -r1.10 hash_func.c > --- db/hash/hash_func.c 5 Aug 2005 13:03:00 - 1.10 > +++ db/hash/hash_func.c 29 May 2016 02:41:12 - > @@ -35,118 +35,10 @@ > #include > > #include > -#include "hash.h" > -#include "page.h" > -#include "extern.h" > - > -#ifdef notdef > -static u_int32_t hash1(const void *, size_t); > -static u_int32_t hash2(const void *, size_t); > -static u_int32_t hash3(const void *, size_t); > -#endif > -static u_int32_t hash4(const void *, size_t); > - > -/* Default hash function. */ > -u_int32_t (*__default_hash)(const void *, size_t) = hash4; > - > -#ifdef notdef > -/* > - * Assume that we've already split the bucket to which this key hashes, > - * calculate that bucket, and check that in fact we did already split it. > - * > - * EJB's original hsearch hash. > - */ > -#define PRIME1 37 > -#define PRIME2 1048583 > - > -u_int32_t > -hash1(const void *key, size_t len) > -{ > - u_int32_t h; > - u_int8_t *k; > - > - h = 0; > - k = (u_int8_t *)key; > - /* Convert string to integer */ > - while (len--) > - h = h * PRIME1 ^ (*k++ - ' '); > - h %= PRIME2; > - return (h); > -} > - > -/* > - * Phong Vo's linear congruential hash > - */ > -#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c)) > - > -u_int32_t > -hash2(const void *key, size_t len) > -{ > - u_int32_t h; > - u_int8_t *e, c, *k; > - > - k = (u_int8_t *)key; > - e = k + len; > - for (h = 0; k != e;) { > - c = *k++; > - if (!c && k > e) > - break; > - dc
Re: update Mesa to 11.2.2
On Sun, May 29, 2016 at 11:18:18AM +0200, Matthieu Herrb wrote: > On Wed, May 18, 2016 at 01:08:37PM +1000, Jonathan Gray wrote: > > On Sun, May 15, 2016 at 11:52:18AM +0200, Matthieu Herrb wrote: > > > On Sun, May 15, 2016 at 06:45:54PM +1000, Jonathan Gray wrote: > > > > On Sun, May 15, 2016 at 10:01:49AM +0200, Matthieu Herrb wrote: > > > > > On Sat, May 14, 2016 at 01:30:08PM +1000, Jonathan Gray wrote: > > > > > > Still looking for some tests on r600 and powerpc for this. > > > > > > > > > > Tested on amd64 on > > > > > > > > > > radeondrm0 at pci2 dev 0 function 0 "ATI Radeon Mobility HD 5430" rev > > > > > 0x00 > > > > > > > > > > and on macppc on > > > > > > > > > > radeondrm0 at pci2 dev 2 function 0 "ATI Radeon VË rev 0x00 > > > > > > > > > > I've attached glxinfo dumps for both machines. > > > > > Also tested on amd64 on my X240 (Haswell) and my NUC (Broadwell). > > > > > > > > Thanks, unfortunately I get a reproduceable crash with > > > > the gallium software renderer on armv7 over X11 forwarding though > > > > sparc64 > > > > and amd64 seems fine with it. > > > > > > Also, with Mesa 11.0.9 I get a similar crash running on arm with display > > > on > > > amd64: > > > > It turns out this is a bug in gcc. I built Mesa with gcc 4.9.3 on armv7 > > and can't reproduce the problem. > > Hi, > > I hope I'm not the one blocking. I think we should move forward. > > Jonathan, could you commit the current mesa bits and we'll see how to > handle the gcc bug in-tree. I need to move my Sabre Lite over to the > new u-boot + EFI boot loader first. I was hoping another minor release would show up but as the freetype update is going in today I'll try get this in as well. > > > > > > > > > (gdb) bt > > > #0 add_uniform (this=Variable "this" is not available. > > > ) at builtin_variables.cpp:484 > > > #1 0x478a7480 in generate_uniforms (this=0xbffe8ff8) > > > at builtin_variables.cpp:808 > > > #2 0x478a8b98 in _mesa_glsl_initialize_variables (instructions=Variable > > > "instructions" is not available. > > > ) > > > at builtin_variables.cpp:1182 > > > #3 0x476d0f18 in _mesa_get_fixed_func_fragment_program (ctx=0x4184d000) > > > at > > > /share/OpenBSD/xenocara/lib/mesa/src/mesa/main/ff_fragment_shader.cpp:1226 > > > #4 0x4777eb24 in _mesa_update_state_locked () at glsl_symbol_table.h:45 > > > #5 0x4777ec58 in _mesa_update_state () at glsl_symbol_table.h:45 > > > #6 0x4769cc8c in _mesa_Clear () > > > at /share/OpenBSD/xenocara/lib/mesa/src/glsl/nir/glsl_to_nir.cpp:160 > > > #7 0x45bd8f88 in glClear () from /usr/X11R6/lib/libGL.so.16.0 > > > #8 0xa998 in __register_frame_info () > > > #9 0xbffe95b8 in ?? () > > > Cannot access memory at address 0x685d7f3d > > > (gdb) > > > > > > > > > > > > > > https://bugs.freedesktop.org/show_bug.cgi?id=95395 > > > > > > > > Program received signal SIGSEGV, Segmentation fault. > > > > add_uniform (this=Variable "this" is not available.) at > > > > /usr/xenocara/lib/mesa/src/compiler/glsl/builtin_variables.cpp:544 > > > > 544const unsigned array_count = type->is_array() ? type->length > > > > : 1; > > > > Current language: auto; currently c++ > > > > (gdb) bt > > > > #0 add_uniform (this=Variable "this" is not available.) at > > > > /usr/xenocara/lib/mesa/src/compiler/glsl/builtin_variables.cpp:544 > > > > #1 0x453d97ec in generate_uniforms (this=0xbfff1508) at > > > > /usr/xenocara/lib/mesa/src/compiler/glsl/builtin_variables.cpp:882 > > > > #2 0x453db110 in _mesa_glsl_initialize_variables > > > > (instructions=Variable "instructions" is not available. > > > > ) at /usr/xenocara/lib/mesa/src/compiler/glsl/builtin_variables.cpp:1304 > > > > #3 0x451ec5e4 in _mesa_get_fixed_func_fragment_program > > > > (ctx=0x40246000) at > > > > /usr/xenocara/lib/mesa/src/mesa/main/ff_fragment_shader.cpp:1225 > > > > #4 0x4529d038 in _mesa_update_state_locked () at glsl_symbol_table.h:45 > > > > #5 0x4529d1b0 in _mesa_update_state () at glsl_symbol_table.h:45 > > > > #6 0x451b8268 in _mesa_Clear () at nir_builder_opcodes.h:80 > > > > #7 0x469e3e30 in glClear () from /usr/X11R6/lib/libGL.so.17.0 > > > > #8 0xa998 in __register_frame_info () > > > > #9 0xbfff1a80 in ?? () > > > > Cannot access memory at address 0x34388d3f > > > > (gdb) p type > > > > $1 = (const glsl_type *) 0x0 > > > > (gdb) p name > > > > $2 = 0x4558e6fc "gl_CurrentAttribVertMESA" > > > > > > -- > > > Matthieu Herrb > > -- > Matthieu Herrb
libc/i386: add setjmp cookies
It took a few beers, but I finally tackled the register-poor i386. This diffs add setjmp cookies and--while we're here--eliminates the use of sigblock/sigsetmask. For bonus points, I scrambled the cookie offsets among the three calls (_setjmp/setjmp/sigsetjmp) so if something tries to mix calls, using longjmp() on a buffer from sigsetjmp(), for example, it'll find itself at a random address. This is the diff -w output to it easier to see what is actually changing. The real diff has more whitespace adjustments to line up columns. No regressions against regress/lib/libc/*setjmp* ok? Philip Guenther Index: arch/i386/gen/_setjmp.S === RCS file: /data/src/openbsd/src/lib/libc/arch/i386/gen/_setjmp.S,v retrieving revision 1.5 diff -u -p -w -r1.5 _setjmp.S --- arch/i386/gen/_setjmp.S 7 Aug 2005 11:30:38 - 1.5 +++ arch/i386/gen/_setjmp.S 29 May 2016 08:46:27 - @@ -33,6 +33,8 @@ #include + .global __jmpxor + /* * C library -- _setjmp, _longjmp * @@ -44,28 +46,45 @@ */ ENTRY(_setjmp) + call1f +1: popl%ecx + addl__jmpxor-1b,%ecx# load cookie address movl4(%esp),%eax movl0(%esp),%edx - movl%edx, 0(%eax) /* rta */ + xorl0(%ecx),%edx# use eip cookie + movl%edx, 0(%eax) movl%ebx, 4(%eax) - movl%esp, 8(%eax) - movl%ebp,12(%eax) + movl%esp, %edx + xorl4(%ecx),%edx# use esp cookie + movl%edx, 8(%eax) + movl8(%ecx),%ecx# load ebp cookie over cookie address + xorl%ebp, %ecx + movl%ecx,12(%eax) movl%esi,16(%eax) movl%edi,20(%eax) xorl%eax,%eax ret +END(_setjmp) ENTRY(_longjmp) + call1f +1: popl%ecx + addl__jmpxor-1b,%ecx# load cookie address movl4(%esp),%edx movl8(%esp),%eax - movl0(%edx),%ecx movl4(%edx),%ebx - movl8(%edx),%esp + movl 8(%edx),%esi # load xor'ed esp into safe register + xorl 4(%ecx),%esi # use esp cookie + movl %esi, %esp # un-xor'ed esp is safe to use movl12(%edx),%ebp + xorl 8(%ecx),%ebp # use ebp cookie movl16(%edx),%esi movl20(%edx),%edi + movl 0(%ecx),%ecx # load eip cookie over cookie address + xorl 0(%edx),%ecx # overwrite eip cookie testl %eax,%eax jnz 1f incl%eax 1: movl%ecx,0(%esp) ret +END(_longjmp) Index: arch/i386/gen/setjmp.S === RCS file: /data/src/openbsd/src/lib/libc/arch/i386/gen/setjmp.S,v retrieving revision 1.10 diff -u -p -w -r1.10 setjmp.S --- arch/i386/gen/setjmp.S 13 Sep 2015 07:36:58 - 1.10 +++ arch/i386/gen/setjmp.S 29 May 2016 09:10:57 - @@ -31,7 +31,17 @@ * SUCH DAMAGE. */ -#include +#include "SYS.h" + + .section.openbsd.randomdata,"aw",@progbits + .balign 4 + .globl __jmpxor + .hidden __jmpxor +__jmpxor: + .zero 4*3 # (eip, esp, ebp) + END(__jmpxor) + .type __jmpxor,@object + /* * C library -- setjmp, longjmp @@ -44,50 +54,63 @@ */ ENTRY(setjmp) - PIC_PROLOGUE - pushl $0 -#ifdef __PIC__ - callPIC_PLT(_C_LABEL(_libc_sigblock)) -#else - call_C_LABEL(_libc_sigblock) -#endif - addl$4,%esp - PIC_EPILOGUE + pushl $0 /* mask = empty */ + pushl $1 /* how = SIG_BLOCK */ + subl$4,%esp + movl$(SYS_sigprocmask),%eax + int $0x80 /* leave oset in %eax */ + addl$12,%esp - movl4(%esp),%ecx - movl0(%esp),%edx - movl%edx, 0(%ecx) + call1f +1: popl%edx + addl__jmpxor-1b,%edx# load cookie address + + movl%eax,24(%ecx) movl%ebx, 4(%ecx) - movl%esp, 8(%ecx) - movl%ebp,12(%ecx) + movl%esp, %eax + xorl0(%edx),%eax# use esp cookie + movl%eax, 8(%ecx) + movl%ebp, %eax + xorl4(%edx),%eax# use ebp cookie + movl%eax,12(%ecx) movl%esi,16(%ecx) movl%edi,20(%ecx) - movl%eax,24(%ecx) + movl8(%edx),%edx# load eip cookie over cookie address + xorl0(%esp),%edx + movl%edx, 0(%ecx) xorl%eax,%eax ret +END(setjmp) ENTRY(longjmp) movl4(%esp),%edx - PIC_PROLOGUE - pushl 24(%edx) -#ifdef __PIC__ - callPIC_PLT(_C_LABEL(_libc_sigsetmask)) -#else - call_C_LABEL(_libc_
Re: update Mesa to 11.2.2
On Wed, May 18, 2016 at 01:08:37PM +1000, Jonathan Gray wrote: > On Sun, May 15, 2016 at 11:52:18AM +0200, Matthieu Herrb wrote: > > On Sun, May 15, 2016 at 06:45:54PM +1000, Jonathan Gray wrote: > > > On Sun, May 15, 2016 at 10:01:49AM +0200, Matthieu Herrb wrote: > > > > On Sat, May 14, 2016 at 01:30:08PM +1000, Jonathan Gray wrote: > > > > > Still looking for some tests on r600 and powerpc for this. > > > > > > > > Tested on amd64 on > > > > > > > > radeondrm0 at pci2 dev 0 function 0 "ATI Radeon Mobility HD 5430" rev > > > > 0x00 > > > > > > > > and on macppc on > > > > > > > > radeondrm0 at pci2 dev 2 function 0 "ATI Radeon VË rev 0x00 > > > > > > > > I've attached glxinfo dumps for both machines. > > > > Also tested on amd64 on my X240 (Haswell) and my NUC (Broadwell). > > > > > > Thanks, unfortunately I get a reproduceable crash with > > > the gallium software renderer on armv7 over X11 forwarding though sparc64 > > > and amd64 seems fine with it. > > > > Also, with Mesa 11.0.9 I get a similar crash running on arm with display on > > amd64: > > It turns out this is a bug in gcc. I built Mesa with gcc 4.9.3 on armv7 > and can't reproduce the problem. Hi, I hope I'm not the one blocking. I think we should move forward. Jonathan, could you commit the current mesa bits and we'll see how to handle the gcc bug in-tree. I need to move my Sabre Lite over to the new u-boot + EFI boot loader first. > > > > > (gdb) bt > > #0 add_uniform (this=Variable "this" is not available. > > ) at builtin_variables.cpp:484 > > #1 0x478a7480 in generate_uniforms (this=0xbffe8ff8) > > at builtin_variables.cpp:808 > > #2 0x478a8b98 in _mesa_glsl_initialize_variables (instructions=Variable > > "instructions" is not available. > > ) > > at builtin_variables.cpp:1182 > > #3 0x476d0f18 in _mesa_get_fixed_func_fragment_program (ctx=0x4184d000) > > at > > /share/OpenBSD/xenocara/lib/mesa/src/mesa/main/ff_fragment_shader.cpp:1226 > > #4 0x4777eb24 in _mesa_update_state_locked () at glsl_symbol_table.h:45 > > #5 0x4777ec58 in _mesa_update_state () at glsl_symbol_table.h:45 > > #6 0x4769cc8c in _mesa_Clear () > > at /share/OpenBSD/xenocara/lib/mesa/src/glsl/nir/glsl_to_nir.cpp:160 > > #7 0x45bd8f88 in glClear () from /usr/X11R6/lib/libGL.so.16.0 > > #8 0xa998 in __register_frame_info () > > #9 0xbffe95b8 in ?? () > > Cannot access memory at address 0x685d7f3d > > (gdb) > > > > > > > > > > https://bugs.freedesktop.org/show_bug.cgi?id=95395 > > > > > > Program received signal SIGSEGV, Segmentation fault. > > > add_uniform (this=Variable "this" is not available.) at > > > /usr/xenocara/lib/mesa/src/compiler/glsl/builtin_variables.cpp:544 > > > 544const unsigned array_count = type->is_array() ? type->length : > > > 1; > > > Current language: auto; currently c++ > > > (gdb) bt > > > #0 add_uniform (this=Variable "this" is not available.) at > > > /usr/xenocara/lib/mesa/src/compiler/glsl/builtin_variables.cpp:544 > > > #1 0x453d97ec in generate_uniforms (this=0xbfff1508) at > > > /usr/xenocara/lib/mesa/src/compiler/glsl/builtin_variables.cpp:882 > > > #2 0x453db110 in _mesa_glsl_initialize_variables (instructions=Variable > > > "instructions" is not available. > > > ) at /usr/xenocara/lib/mesa/src/compiler/glsl/builtin_variables.cpp:1304 > > > #3 0x451ec5e4 in _mesa_get_fixed_func_fragment_program (ctx=0x40246000) > > > at /usr/xenocara/lib/mesa/src/mesa/main/ff_fragment_shader.cpp:1225 > > > #4 0x4529d038 in _mesa_update_state_locked () at glsl_symbol_table.h:45 > > > #5 0x4529d1b0 in _mesa_update_state () at glsl_symbol_table.h:45 > > > #6 0x451b8268 in _mesa_Clear () at nir_builder_opcodes.h:80 > > > #7 0x469e3e30 in glClear () from /usr/X11R6/lib/libGL.so.17.0 > > > #8 0xa998 in __register_frame_info () > > > #9 0xbfff1a80 in ?? () > > > Cannot access memory at address 0x34388d3f > > > (gdb) p type > > > $1 = (const glsl_type *) 0x0 > > > (gdb) p name > > > $2 = 0x4558e6fc "gl_CurrentAttribVertMESA" > > > > -- > > Matthieu Herrb -- Matthieu Herrb signature.asc Description: PGP signature
disklabel(8) fixes
Yesterday's code shuffling in disklabel(8) left behind a bit of a mess. It also changed behavior of 'disklabel sd1' for non-root users (previously you could print the disklabel without being root, now you get EPERM). There still is the breakage due to insufficient checks on the file before pledging: $ ktrace disklabel /dev/tty Abort trap (core dumped) $ kdump | tail 94670 disklabel CALL open(0x5c312b45620,0x2) 94670 disklabel NAMI "/dev/tty" 94670 disklabel RET open 3 94670 disklabel CALL pledge(0x5c312838423,0) 94670 disklabel STRU pledge promise="stdio rpath wpath disklabel" 94670 disklabel RET pledge 0 94670 disklabel CALL ioctl(3,DIOCGDINFO,0x5c312b4c180) 94670 disklabel PLDG ioctl, "ioctl", errno 1 Operation not permitted 94670 disklabel PSIG SIGABRT SIG_DFL 94670 disklabel NAMI "disklabel.core" This patch reverts the change of behavior, cleans up the logic before pledge a bit and fixes the pledge fallout. It's based on Bob's patch that was backed out, but also covers the write flag. Tested on amd64 with 'make release', installing the release on an usb stick and messing about with the disklabel on that stick. Index: disklabel.c === RCS file: /var/cvs/src/sbin/disklabel/disklabel.c,v retrieving revision 1.218 diff -u -p -r1.218 disklabel.c --- disklabel.c 28 May 2016 23:38:30 - 1.218 +++ disklabel.c 29 May 2016 07:28:40 - @@ -174,7 +174,7 @@ main(int argc, char *argv[]) if (strchr("bckmgtBCKMGT", optarg[0]) == NULL || optarg[1] != '\0') { fprintf(stderr, "Valid units are bckmgt\n"); - exit(1); + return 1; } print_unit = tolower((unsigned char)optarg[0]); break; @@ -191,6 +191,13 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + if (op == UNSPEC) + op = READ; + + if (argc < 1 || (fstabfile && !(op == EDITOR || op == RESTORE || + aflag))) + usage(); + if (argv[0] == NULL) usage(); dkname = argv[0]; @@ -199,6 +206,13 @@ main(int argc, char *argv[]) if (f < 0) err(4, "%s", specname); + if (op != WRITE || aflag || dflag) + readlabel(f); + else if (argc == 2 || argc == 3) + makelabel(argv[1], argc == 3 ? argv[2] : NULL, &lab); + else + usage(); + if (op == EDIT || op == EDITOR || aflag) { if (pledge("stdio rpath wpath cpath disklabel proc exec", NULL) == -1) err(1, "pledge"); @@ -207,13 +221,6 @@ main(int argc, char *argv[]) err(1, "pledge"); } - if (op == UNSPEC) - op = READ; - - if (argc < 1 || (fstabfile && !(op == EDITOR || op == RESTORE || - aflag))) - usage(); - if (autotable != NULL) parse_autotable(autotable); @@ -221,19 +228,16 @@ main(int argc, char *argv[]) case EDIT: if (argc != 1) usage(); - readlabel(f); error = edit(&lab, f); break; case EDITOR: if (argc != 1) usage(); - readlabel(f); error = editor(f); break; case READ: if (argc != 1) usage(); - readlabel(f); if (pledge("stdio", NULL) == -1) err(1, "pledge"); @@ -247,7 +251,6 @@ main(int argc, char *argv[]) case RESTORE: if (argc < 2 || argc > 3) usage(); - readlabel(f); if (!(t = fopen(argv[1], "r"))) err(4, "%s", argv[1]); error = getasciilabel(t, &lab); @@ -263,12 +266,6 @@ main(int argc, char *argv[]) fclose(t); break; case WRITE: - if (dflag || aflag) { - readlabel(f); - } else if (argc < 2 || argc > 3) - usage(); - else - makelabel(argv[1], argc == 3 ? argv[2] : NULL, &lab); error = checklabel(&lab); if (error == 0) error = writelabel(f, &lab); @@ -276,7 +273,7 @@ main(int argc, char *argv[]) default: break; } - exit(error); + return error; } /*
Re: prefer AF_* over PF_*
On Sat, May 28, 2016 at 07:55:00PM -0700, Philip Guenther wrote: > > About the only place userland code should use PF_* socket constants is > with sysctl(3)'s CTL_NET hierarchy. All the standardized functions are > defined as taking AF_* values. Let's use the preferred names in the > getaddrinfo(3) and socketpair(2) manpages. > > ok? POSIX only mentions AF_*. ok natano@ > > Philip Guenther > > Index: net/getaddrinfo.3 > === > RCS file: /data/src/openbsd/src/lib/libc/net/getaddrinfo.3,v > retrieving revision 1.57 > diff -u -p -r1.57 getaddrinfo.3 > --- net/getaddrinfo.3 16 Feb 2015 18:26:56 - 1.57 > +++ net/getaddrinfo.3 20 May 2016 00:06:21 - > @@ -94,7 +94,7 @@ The protocol family that should be used. > When > .Fa ai_family > is set to > -.Dv PF_UNSPEC , > +.Dv AF_UNSPEC , > it means the caller will accept any protocol family supported by the > operating system. > .It Fa ai_socktype > @@ -229,7 +229,7 @@ behaves as if the caller provided a > with > .Fa ai_family > set to > -.Dv PF_UNSPEC , > +.Dv AF_UNSPEC , > .Fa ai_flags > set to > .Dv AI_ADDRCONFIG , > @@ -351,7 +351,7 @@ int s; > const char *cause = NULL; > > memset(&hints, 0, sizeof(hints)); > -hints.ai_family = PF_UNSPEC; > +hints.ai_family = AF_UNSPEC; > hints.ai_socktype = SOCK_STREAM; > error = getaddrinfo("www.kame.net", "www", &hints, &res0); > if (error) > @@ -393,7 +393,7 @@ int nsock; > const char *cause = NULL; > > memset(&hints, 0, sizeof(hints)); > -hints.ai_family = PF_UNSPEC; > +hints.ai_family = AF_UNSPEC; > hints.ai_socktype = SOCK_STREAM; > hints.ai_flags = AI_PASSIVE; > error = getaddrinfo(NULL, "www", &hints, &res0); > Index: sys/socketpair.2 > === > RCS file: /data/src/openbsd/src/lib/libc/sys/socketpair.2,v > retrieving revision 1.19 > diff -u -p -r1.19 socketpair.2 > --- sys/socketpair.2 19 Mar 2016 22:10:49 - 1.19 > +++ sys/socketpair.2 20 May 2016 00:05:48 - > @@ -124,7 +124,7 @@ This call is currently implemented only > Many operating systems only accept a > .Fa protocol > of > -.Dv PF_UNSPEC , > +.Dv AF_UNSPEC , > so that should be used instead of > -.Dv PF_LOCAL > +.Dv AF_LOCAL > for maximal portability. >