[PATCH libssl] Fix typo in man page

2019-12-02 Thread Michael Forney
---
 src/lib/libssl/man/SSL_CTX_set_cipher_list.3 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/lib/libssl/man/SSL_CTX_set_cipher_list.3 
b/src/lib/libssl/man/SSL_CTX_set_cipher_list.3
index 64da0092d..6f15dbaaa 100644
--- a/src/lib/libssl/man/SSL_CTX_set_cipher_list.3
+++ b/src/lib/libssl/man/SSL_CTX_set_cipher_list.3
@@ -230,7 +230,7 @@ An alias for
 .Cm aDSS .
 .It Cm ECDH
 An alias for
-.Cm kEECHD .
+.Cm kEECDH .
 .It Cm ECDHE
 Cipher suites using ephemeral ECDH for key exchange,
 but excluding those that don't do any server authentication.
@@ -245,7 +245,7 @@ An alias for
 .It Cm EDH
 An alias for
 .Cm DHE .
-.It Cm EECHD
+.It Cm EECDH
 An alias for
 .Cm ECDHE .
 .It Cm eNULL
-- 
2.20.1



Re: fwide() does not unlock if error was occurred

2019-12-02 Thread Philip Guenther
On Mon, Dec 2, 2019 at 7:48 PM Masato Asou  wrote:

> fwide() does not unlock if error was occurred.
>
> ok?
>

ok guenther@


fwide() does not unlock if error was occurred

2019-12-02 Thread Masato Asou
fwide() does not unlock if error was occurred.

ok?

Index: lib/libc/stdio/fwide.c
===
RCS file: /cvs/src/lib/libc/stdio/fwide.c,v
retrieving revision 1.5
diff -u -p -r1.5 fwide.c
--- lib/libc/stdio/fwide.c  31 Aug 2015 02:53:57 -  1.5
+++ lib/libc/stdio/fwide.c  3 Dec 2019 03:25:26 -
@@ -51,8 +51,10 @@ fwide(FILE *fp, int mode)
 
FLOCKFILE(fp);
wcio = WCIO_GET(fp);
-   if (!wcio)
+   if (!wcio) {
+   FUNLOCKFILE(fp);
return 0; /* XXX */
+   }
 
if (wcio->wcio_mode == 0 && mode != 0)
wcio->wcio_mode = mode;
--
ASOU Masato



tcpdump(8): RFC 8300 Network Service Header (NSH) printing

2019-12-02 Thread David Gwynne
this handles printing of NSH packets as per RFC 8300.

i was trying to understand how the protocol was put together, and this
helped me a lot. it looks like this:

$ ./obj/tcpdump -nr /home/dlg/tmp/nsh.pcap  
tcpdump: WARNING: snaplen raised from 116 to 262144
09:13:40.394208 NSH spi 777 si 7 md1: 10.0.8.3.52229 > 10.13.13.13.8000: udp 6 
(DF)
$ ./obj/tcpdump -nr /home/dlg/tmp/nsh.pcap -v
tcpdump: WARNING: snaplen raised from 116 to 262144
09:13:40.394208 NSH spi 777 si 7 md1
context 0001 0002 0003 0004
10.0.8.3.52229 > 10.13.13.13.8000: [no udp cksum] udp 6 (DF) (ttl 64, id 
10308, len 34)
$ ./obj/tcpdump -nr /home/dlg/tmp/nsh-over-vxlan-gpe.pcap
tcpdump: WARNING: snaplen raised from 116 to 262144
00:19:08.994912 127.0.0.1.4790 > 127.0.0.1.4790: VXLAN vni 65535: NSH spi 
16777215 si 255 md2: NSH OAM (proto 0x1, len 40) (DF)
$ ./obj/tcpdump -nr /home/dlg/tmp/nsh-over-vxlan-gpe.pcap -v
tcpdump: WARNING: snaplen raised from 116 to 262144
00:19:08.994912 127.0.0.1.4790 > 127.0.0.1.4790: [udp sum ok] VXLAN vni 65535: 
NSH spi 16777215 si 255 md2
md class 1 type 2 12
md class 2 type 3 12
NSH OAM (proto 0x1, len 40)
 4500 0020 d431  ff11 6647 c0a8 0001
 c0a8 0002 2710 4e20 000c 2178 7465 7374
     (DF) (ttl 64, id 16419, len 92)

ok?

Index: Makefile
===
RCS file: /cvs/src/usr.sbin/tcpdump/Makefile,v
retrieving revision 1.63
diff -u -p -r1.63 Makefile
--- Makefile3 Feb 2018 13:39:48 -   1.63
+++ Makefile2 Dec 2019 23:11:06 -
@@ -42,7 +42,7 @@ SRCS= tcpdump.c addrtoname.c privsep.c p
print-vrrp.c print-wb.c print-decnet.c print-isoclns.c print-ipx.c \
print-atm.c print-dvmrp.c print-krb.c print-pim.c print-netbios.c \
util.c bpf_dump.c parsenfsfh.c version.c print-igrp.c \
-   print-gre.c print-radius.c print-enc.c print-cnfp.c \
+   print-gre.c print-nsh.c print-radius.c print-enc.c print-cnfp.c \
print-ipsec.c print-ike.c print-raw.c print-l2tp.c print-mobile.c \
print-ip6.c print-ip6opts.c print-icmp6.c print-dhcp6.c print-frag6.c \
print-bgp.c print-ospf6.c print-ripng.c print-rt6.c print-stp.c \
Index: interface.h
===
RCS file: /cvs/src/usr.sbin/tcpdump/interface.h,v
retrieving revision 1.82
diff -u -p -r1.82 interface.h
--- interface.h 2 Dec 2019 22:07:20 -   1.82
+++ interface.h 2 Dec 2019 23:11:06 -
@@ -216,6 +216,7 @@ extern void ppp_ether_if_print(u_char *,
const u_char *);
 extern void gre_print(const u_char *, u_int);
 extern void vxlan_print(const u_char *, u_int);
+extern void nsh_print(const u_char *, u_int);
 extern void icmp_print(const u_char *, u_int, const u_char *);
 extern void ieee802_11_if_print(u_char *, const struct pcap_pkthdr *,
 const u_char *);
Index: print-ether.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/print-ether.c,v
retrieving revision 1.35
diff -u -p -r1.35 print-ether.c
--- print-ether.c   18 Nov 2018 08:55:51 -  1.35
+++ print-ether.c   2 Dec 2019 23:11:06 -
@@ -289,6 +289,13 @@ recurse:
}
return (1);
 
+#ifndef ETHERTYPE_NSH
+#define ETHERTYPE_NSH 0x894f
+#endif
+   case ETHERTYPE_NSH:
+   nsh_print(p, length);
+   return (1);
+
 #ifndef ETHERTYPE_PBB
 #define ETHERTYPE_PBB 0x88e7
 #endif
Index: print-gre.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/print-gre.c,v
retrieving revision 1.28
diff -u -p -r1.28 print-gre.c
--- print-gre.c 2 Dec 2019 22:32:01 -   1.28
+++ print-gre.c 2 Dec 2019 23:11:06 -
@@ -277,6 +277,12 @@ gre_print_0(const u_char *p, u_int lengt
case ETHERTYPE_TRANSETHER:
ether_tryprint(p, length, 0);
break;
+#ifndef ETHERTYPE_NSH
+#define ETHERTYPE_NSH 0x894f
+#endif
+   case ETHERTYPE_NSH:
+   nsh_print(p, length);
+   break;
case ERSPAN_II:
gre_print_erspan(flags, p, length);
break;
@@ -758,7 +764,7 @@ vxlan_print(const u_char *p, u_int lengt
ether_tryprint(p, length, 0);
break;
case VXLAN_PROTO_NSH:
-   printf("NSH");
+   nsh_print(p, length);
break;
case VXLAN_PROTO_MPLS:
mpls_print(p, length);
Index: print-nsh.c
===
RCS file: print-nsh.c
diff -N print-nsh.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ print-nsh.c 2 Dec 2019 23:11:06 -
@@ -0,0 +1,308 @@
+/* $OpenBSD$ */
+
+/*
+ * Copyright (c) 2019 David Gwynne 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose 

Re: grep -R with no path

2019-12-02 Thread Klemens Nanni
On Mon, Dec 02, 2019 at 08:31:02AM +, Miod Vallat wrote:
> grep(1), when invoked with the -R option but no path, displays a
> "recursive search of stdin" warning and acts as if -R had not been
> specified.
> 
> GNU grep, in that case, will perform a recursive search in the current
> directory, i.e. uses an implicit "." path if none is given.
> 
> This is IMO a much better behaviour. What about the following diff?
Document this.

OK?

Index: grep.1
===
RCS file: /cvs/src/usr.bin/grep/grep.1,v
retrieving revision 1.49
diff -u -p -r1.49 grep.1
--- grep.1  7 Oct 2019 20:51:34 -   1.49
+++ grep.1  2 Dec 2019 23:58:56 -
@@ -246,6 +246,11 @@ will only search a file until a match ha
 making searches potentially less expensive.
 .It Fl R
 Recursively search subdirectories listed.
+If no
+.Ar file
+is given,
+.Nm
+searches the working directory.
 .It Fl s
 Silent mode.
 Nonexistent and unreadable files are ignored



Re: ix(4) need support for X553

2019-12-02 Thread Hrvoje Popovski
On 18.11.2019. 0:31, Hrvoje Popovski wrote:
> On 14.11.2019. 1:06, Stuart Henderson wrote:
>> Apart from the obvious style(9) problems, can anyone give me guidance on
>> how to approach this diff? I'm quite uneasy at the amount of changes but 
>> these
>> nics are quite important, they're all over the place on Atom C3xxx boards
>> which are pretty much the main "next step up" from APUs.
>>
>> I have an A2SDi-2C-HLN4F that I need to put in service soon (not so
>> bothered about the ix on this box, I'm using 4xSFP+ ixl, but giving it
>> a spin) - applying my merged diff (https://junkpile.org/ixgbe.diff2)
> 
> with this diff box panic while booting at starting network
> 
> ix0 at pci1 dev 0 function 0 "Intel 82599" rev 0x01: msi, address
> ix1 at pci1 dev 0 function 1 "Intel 82599" rev 0x01: msi, address
> em0 at pci7 dev 0 function 0 "Intel I350" rev 0x01: msi, address
> em1 at pci7 dev 0 function 1 "Intel I350" rev 0x01: msi, address
> 
> net.inet.ip.forwarding: 0 -> 1
> starting network
> panic: attempt to execute user address 0x0 in supervisor mode
> Stopped at  db_enter+0x10:  popq%rbp
> TIDPIDUID PRFLAGS PFLAGS  CPU  COMMAND
> *489100  47566  0 0x3  00K ifconfig
> db_enter() at db_enter+0x10
> panic(81cbe37d) at panic+0x128
> pageflttrap(8000224ebeb0,0) at pageflttrap+0x2db
> kerntrap(8000224ebeb0) at kerntrap+0x91
> alltraps_kern_meltdown() at alltraps_kern_meltdown+0x7b
> 0(80078000,80078000,aa0519036f37d371,80078000,8
> 0159300,7) at 0
> ixgbe_init(80078000) at ixgbe_init+0x36
> ixgbe_ioctl(80078048,8020690c,80159300) at ixgbe_ioctl+0x15a
> in_ifinit(80078048,80159300,8000224ec2d0,1) at
> in_ifinit+0xf3
> in_ioctl_change_ifaddr(8040691a,8000224ec2c0,80078048,1) at
> in_ioctl_change_ifaddr+0x350
> in_ioctl(8040691a,8000224ec2c0,80078048,1) at in_ioctl+0x12e
> ifioctl(fd83b36cad80,8040691a,8000224ec2c0,80004ee0) at
> ifioctl+0x99e
> sys_ioctl(80004ee0,8000224ec3d0,8000224ec430) at
> sys_ioctl+0x3c2
> syscall(8000224ec4a0) at syscall+0x389
> end trace frame: 0x8000224ec520, count: 0
> https://www.openbsd.org/ddb.html describes the minimum info required in bug
> reports.  Insufficient info makes it difficult to find and fix bugs.
> ddb{0}>

it seems that 82599 is affected by this diff, x552 and x540 are fine



Re: grep -R with no path

2019-12-02 Thread Todd C . Miller
On Mon, 02 Dec 2019 23:09:23 +0100, Jeremie Courreges-Anglas wrote:

> This diff moves the fake argv logic moves into grep_tree() where we can
> opt for pretty-printing.  ok?

That's similar to what I was going to propose.  OK millert@

 - todd



Re: grep -R with no path

2019-12-02 Thread Jeremie Courreges-Anglas
On Mon, Dec 02 2019, Jeremie Courreges-Anglas  wrote:

[...]

> I have had a similar diff for some time but didn't push for it because
> nitpicking: GNU grep doesn't prepend "./" to file names in this case.
> I have a diff to do this but let's keep the nitpicking for later.

Current:
--8<--
ritchie /usr/src/usr.bin/grep$ grep -R grep_tree
./grep.c:   c = grep_tree(argv);
./grep.h:int grep_tree(char **argv);
./util.c:grep_tree(char **argv)
Binary file ./grep matches
./grep.c.orig:  c = grep_tree(argv);
./util.c.orig:grep_tree(char **argv)
-->8--

With the diff below (matches GNU grep)
--8<--
ritchie /usr/src/usr.bin/grep$ obj/grep -R grep_tree
grep.c: c = grep_tree(argv);
grep.h:int   grep_tree(char **argv);
util.c:grep_tree(char **argv)
Binary file grep matches
grep.c.orig:c = grep_tree(argv);
util.c.orig:grep_tree(char **argv)
-->88

Explicit "."
--8<--
ritchie /usr/src/usr.bin/grep$ obj/grep -R grep_tree .
./grep.c:   c = grep_tree(argv);
./grep.h:int grep_tree(char **argv);
./util.c:grep_tree(char **argv)
Binary file ./grep matches
./grep.c.orig:  c = grep_tree(argv);
./util.c.orig:grep_tree(char **argv)
-->8--

This diff moves the fake argv logic moves into grep_tree() where we can
opt for pretty-printing.  ok?


Index: grep.c
===
RCS file: /cvs/src/usr.bin/grep/grep.c,v
retrieving revision 1.63
diff -u -p -r1.63 grep.c
--- grep.c  2 Dec 2019 21:50:11 -   1.63
+++ grep.c  2 Dec 2019 21:53:14 -
@@ -473,12 +473,6 @@ main(int argc, char *argv[])
++argv;
}
 
-   if (Rflag && argc == 0) {
-   /* default to . if no path given */
-   static char *dot_argv[] = { ".", NULL };
-   argv = dot_argv;
-   argc = 1;
-   }
if (Eflag)
cflags |= REG_EXTENDED;
if (Fflag)
@@ -516,7 +510,7 @@ main(int argc, char *argv[])
if ((argc == 0 || argc == 1) && !Rflag && !Hflag)
hflag = 1;
 
-   if (argc == 0)
+   if (argc == 0 && !Rflag)
exit(!procfile(NULL));
 
if (Rflag)
Index: util.c
===
RCS file: /cvs/src/usr.bin/grep/util.c,v
retrieving revision 1.61
diff -u -p -r1.61 util.c
--- util.c  7 Oct 2019 17:47:32 -   1.61
+++ util.c  2 Dec 2019 21:53:15 -
@@ -61,6 +61,12 @@ grep_tree(char **argv)
FTS *fts;
FTSENT  *p;
int c, fts_flags;
+   char*dot_argv[] = { ".", NULL };
+   char*path;
+
+   /* default to . if no path given */
+   if (argv[0] == NULL)
+   argv = dot_argv;
 
c = 0;
 
@@ -81,7 +87,11 @@ grep_tree(char **argv)
case FTS_DP:
break;
default:
-   c += procfile(p->fts_path);
+   path = p->fts_path;
+   /* skip "./" if implied */
+   if (argv == dot_argv && p->fts_pathlen >= 2)
+   path += 2;
+   c += procfile(path);
break;
}
}

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



unveil radioctl/fdformat/gpioctl

2019-12-02 Thread Ricardo Mestre
Hi tech@

radioctl/fdformat/gpioctl need to open the device and then all operations go
through ioctls forbidden by pledge but no further filesystem access is needed
so it can be disallowed right afterwards.

CAVEAT: The sources for these applications are simple enough to follow, but
unfortunately I don't have any of these devices to actually test them, so take
this with a really tiny pinch of salt.

Comments, OK?

/mestre

Index: usr.bin/radioctl/radioctl.c
===
RCS file: /cvs/src/usr.bin/radioctl/radioctl.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 radioctl.c
--- usr.bin/radioctl/radioctl.c 28 Jun 2019 13:35:03 -  1.20
+++ usr.bin/radioctl/radioctl.c 2 Dec 2019 18:51:03 -
@@ -186,6 +186,11 @@ main(int argc, char **argv)
if (rd == -1)
err(1, "%s open error", radiodev);
 
+   if (unveil("/", "") == -1)
+   err(1, "unveil");
+   if (unveil(NULL, NULL) == -1)
+   err(1, "unveil");
+
if (ioctl(rd, RIOCGINFO, ) == -1)
err(1, "RIOCGINFO");
 
Index: usr.sbin/fdformat/fdformat.c
===
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
retrieving revision 1.24
diff -u -p -u -r1.24 fdformat.c
--- usr.sbin/fdformat/fdformat.c28 Jun 2019 13:32:47 -  1.24
+++ usr.sbin/fdformat/fdformat.c2 Dec 2019 18:51:04 -
@@ -246,6 +246,11 @@ main(int argc, char *argv[])
if ((fd = opendev(argv[optind], O_RDWR, OPENDEV_PART, )) == -1)
err(1, "%s", devname);
 
+   if (unveil("/", "") == -1)
+   err(1, "unveil");
+   if (unveil(NULL, NULL) == -1)
+   err(1, "unveil");
+
if (ioctl(fd, FD_GTYPE, ) == -1)
errx(1, "not a floppy disk: %s", devname);
 
Index: usr.sbin/gpioctl/gpioctl.c
===
RCS file: /cvs/src/usr.sbin/gpioctl/gpioctl.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 gpioctl.c
--- usr.sbin/gpioctl/gpioctl.c  26 Dec 2015 20:52:03 -  1.17
+++ usr.sbin/gpioctl/gpioctl.c  2 Dec 2019 18:51:04 -
@@ -101,6 +101,11 @@ main(int argc, char *argv[])
if ((devfd = open(dev, O_RDWR)) == -1)
err(1, "%s", dev);
 
+   if (unveil("/", "") == -1)
+   err(1, "unveil");
+   if (unveil(NULL, NULL) == -1)
+   err(1, "unveil");
+
if (argc == 1) {
getinfo();
return 0;



Re: grep -R with no path

2019-12-02 Thread Todd C . Miller
On Mon, 02 Dec 2019 08:31:02 +, Miod Vallat wrote:

> grep(1), when invoked with the -R option but no path, displays a
> "recursive search of stdin" warning and acts as if -R had not been
> specified.
>
> GNU grep, in that case, will perform a recursive search in the current
> directory, i.e. uses an implicit "." path if none is given.

Our behavior was based on what GNU grep originally did.  However,
GNU grep has moved on and so should we.

> This is IMO a much better behaviour. What about the following diff?

OK millert@

 - todd



Re: grep -R with no path

2019-12-02 Thread Visa Hankala
On Mon, Dec 02, 2019 at 06:08:35PM +0100, Jeremie Courreges-Anglas wrote:
> On Mon, Dec 02 2019, Marc Espie  wrote:
> > On Mon, Dec 02, 2019 at 08:31:02AM +, Miod Vallat wrote:
> >> grep(1), when invoked with the -R option but no path, displays a
> >> "recursive search of stdin" warning and acts as if -R had not been
> >> specified.
> >> 
> >> GNU grep, in that case, will perform a recursive search in the current
> >> directory, i.e. uses an implicit "." path if none is given.
> >> 
> >> This is IMO a much better behaviour. What about the following diff?
> >> 
> >> Index: grep.c
> >> ===
> >> RCS file: /OpenBSD/src/usr.bin/grep/grep.c,v
> >> retrieving revision 1.62
> >> diff -u -p -r1.62 grep.c
> >> --- grep.c 7 Oct 2019 20:04:00 -   1.62
> >> +++ grep.c 2 Dec 2019 08:27:09 -
> >> @@ -473,8 +473,12 @@ main(int argc, char *argv[])
> >>++argv;
> >>}
> >>  
> >> -  if (Rflag && argc == 0)
> >> -  warnx("warning: recursive search of stdin");
> >> +  if (Rflag && argc == 0) {
> >> +  /* default to . if no path given */
> >> +  static char *dot_argv[] = { ".", NULL };
> >> +  argv = dot_argv;
> >> +  argc = 1;
> >> +  }
> >>if (Eflag)
> >>cflags |= REG_EXTENDED;
> >>if (Fflag)
> >> 
> >> 
> > I concur, I like it better as well.
> > -R isn't in POSIX anyway, so we don't have to worry about standard.
> 
> Same here, even if muscle memory helps this is just a better default IMO.
> 
> I have had a similar diff for some time but didn't push for it because
> nitpicking: GNU grep doesn't prepend "./" to file names in this case.
> I have a diff to do this but let's keep the nitpicking for later.
> 
> I'd like us to go with Miod's diff.  Any objection?  oks?
> ok jca@ if Marc or someone else wants to commit it.

OK visa@



Re: grep -R with no path

2019-12-02 Thread Jeremie Courreges-Anglas
On Mon, Dec 02 2019, Marc Espie  wrote:
> On Mon, Dec 02, 2019 at 08:31:02AM +, Miod Vallat wrote:
>> grep(1), when invoked with the -R option but no path, displays a
>> "recursive search of stdin" warning and acts as if -R had not been
>> specified.
>> 
>> GNU grep, in that case, will perform a recursive search in the current
>> directory, i.e. uses an implicit "." path if none is given.
>> 
>> This is IMO a much better behaviour. What about the following diff?
>> 
>> Index: grep.c
>> ===
>> RCS file: /OpenBSD/src/usr.bin/grep/grep.c,v
>> retrieving revision 1.62
>> diff -u -p -r1.62 grep.c
>> --- grep.c   7 Oct 2019 20:04:00 -   1.62
>> +++ grep.c   2 Dec 2019 08:27:09 -
>> @@ -473,8 +473,12 @@ main(int argc, char *argv[])
>>  ++argv;
>>  }
>>  
>> -if (Rflag && argc == 0)
>> -warnx("warning: recursive search of stdin");
>> +if (Rflag && argc == 0) {
>> +/* default to . if no path given */
>> +static char *dot_argv[] = { ".", NULL };
>> +argv = dot_argv;
>> +argc = 1;
>> +}
>>  if (Eflag)
>>  cflags |= REG_EXTENDED;
>>  if (Fflag)
>> 
>> 
> I concur, I like it better as well.
> -R isn't in POSIX anyway, so we don't have to worry about standard.

Same here, even if muscle memory helps this is just a better default IMO.

I have had a similar diff for some time but didn't push for it because
nitpicking: GNU grep doesn't prepend "./" to file names in this case.
I have a diff to do this but let's keep the nitpicking for later.

I'd like us to go with Miod's diff.  Any objection?  oks?
ok jca@ if Marc or someone else wants to commit it.

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Infinite sleeps in sys/miscfs

2019-12-02 Thread Martin Pieuchot
Ok?

Index: miscfs/deadfs/dead_vnops.c
===
RCS file: /cvs/src/sys/miscfs/deadfs/dead_vnops.c,v
retrieving revision 1.30
diff -u -p -r1.30 dead_vnops.c
--- miscfs/deadfs/dead_vnops.c  19 Oct 2019 06:56:18 -  1.30
+++ miscfs/deadfs/dead_vnops.c  2 Dec 2019 14:11:12 -
@@ -266,7 +266,7 @@ chkvnlock(struct vnode *vp)
 
while (vp->v_flag & VXLOCK) {
vp->v_flag |= VXWANT;
-   tsleep(vp, PINOD, "chkvnlock", 0);
+   tsleep_nsec(vp, PINOD, "chkvnlock", INFSLP);
locked = 1;
}
return (locked);
Index: miscfs/fuse/fusebuf.c
===
RCS file: /cvs/src/sys/miscfs/fuse/fusebuf.c,v
retrieving revision 1.16
diff -u -p -r1.16 fusebuf.c
--- miscfs/fuse/fusebuf.c   21 Jun 2018 14:53:36 -  1.16
+++ miscfs/fuse/fusebuf.c   2 Dec 2019 14:11:26 -
@@ -82,7 +82,7 @@ int
 fb_queue(dev_t dev, struct fusebuf *fbuf)
 {
fuse_device_queue_fbuf(dev, fbuf);
-   tsleep(fbuf, PWAIT, "fuse", 0);
+   tsleep_nsec(fbuf, PWAIT, "fuse", INFSLP);
 
return (fbuf->fb_err);
 }



Infinite sleeps in sys/scsi

2019-12-02 Thread Martin Pieuchot
Convert them to msleep_nsec(9) and tsleep_nsec(9), ok?

Index: scsi/scsi_base.c
===
RCS file: /cvs/src/sys/scsi/scsi_base.c,v
retrieving revision 1.250
diff -u -p -r1.250 scsi_base.c
--- scsi/scsi_base.c1 Dec 2019 16:56:26 -   1.250
+++ scsi/scsi_base.c2 Dec 2019 14:12:25 -
@@ -432,7 +432,7 @@ scsi_move(struct scsi_io_mover *m)
 {
mtx_enter(>mtx);
while (!m->done)
-   msleep(m, >mtx, PRIBIO, "scsiiomv", 0);
+   msleep_nsec(m, >mtx, PRIBIO, "scsiiomv", INFSLP);
mtx_leave(>mtx);
 }
 
@@ -706,7 +706,8 @@ scsi_link_shutdown(struct scsi_link *lin
}
 
while (link->pending > 0)
-   msleep(>pending, >mtx, PRIBIO, "pendxs", 0);
+   msleep_nsec(>pending, >mtx, PRIBIO, "pendxs",
+   INFSLP);
mtx_leave(>mtx);
 
while ((ioh = TAILQ_FIRST()) != NULL) {
@@ -1440,7 +1441,7 @@ scsi_xs_sync(struct scsi_xfer *xs)
 
mtx_enter();
while (xs->cookie != NULL)
-   msleep(xs, , PRIBIO, "syncxs", 0);
+   msleep_nsec(xs, , PRIBIO, "syncxs", INFSLP);
mtx_leave();
 
error = scsi_xs_error(xs);
@@ -1530,7 +1531,7 @@ scsi_delay(struct scsi_xfer *xs, int sec
}
 
while (seconds-- > 0) {
-   if (tsleep(, PRIBIO|PCATCH, "scbusy", 0)) {
+   if (tsleep_nsec(, PRIBIO|PCATCH, "scbusy", INFSLP)) {
/* Signal == abort xs. */
return (EIO);
}



Infinite sleeps in sys/nfs

2019-12-02 Thread Martin Pieuchot
Convert all of them to tsleep_nsec(9), ok?

Index: nfs/nfs_aiod.c
===
RCS file: /cvs/src/sys/nfs/nfs_aiod.c,v
retrieving revision 1.7
diff -u -p -r1.7 nfs_aiod.c
--- nfs/nfs_aiod.c  28 Aug 2015 00:03:54 -  1.7
+++ nfs/nfs_aiod.c  2 Dec 2019 14:04:19 -
@@ -112,7 +112,7 @@ loop:   /* Loop around until SIGKILL */
}
 
while (!(aiod->nad_flags & NFSAIOD_WAKEUP))
-   tsleep(aiod, PWAIT, "aiodidle", 0);
+   tsleep_nsec(aiod, PWAIT, "aiodidle", INFSLP);
 
/*
 * Wakeup for this aiod happens in one of the following
Index: nfs/nfs_kq.c
===
RCS file: /cvs/src/sys/nfs/nfs_kq.c,v
retrieving revision 1.25
diff -u -p -r1.25 nfs_kq.c
--- nfs/nfs_kq.c5 Aug 2019 08:35:59 -   1.25
+++ nfs/nfs_kq.c2 Dec 2019 14:05:36 -
@@ -193,7 +193,7 @@ filt_nfsdetach(struct knote *kn)
while (ke->flags & KEVQ_BUSY) {
ke->flags |= KEVQ_WANT;
rw_exit_write(_lock);
-   (void) tsleep(ke, PSOCK, "nfskqdet", 0);
+   tsleep_nsec(ke, PSOCK, "nfskqdet", INFSLP);
rw_enter_write(_lock);
}
 
Index: nfs/nfs_socket.c
===
RCS file: /cvs/src/sys/nfs/nfs_socket.c,v
retrieving revision 1.133
diff -u -p -r1.133 nfs_socket.c
--- nfs/nfs_socket.c13 May 2019 19:21:31 -  1.133
+++ nfs/nfs_socket.c2 Dec 2019 14:06:18 -
@@ -407,7 +407,7 @@ nfs_reconnect(struct nfsreq *rep)
while ((error = nfs_connect(nmp, rep)) != 0) {
if (error == EINTR || error == ERESTART)
return (EINTR);
-   (void)tsleep((caddr_t), PSOCK, "nfsrecon", 0);
+   tsleep_nsec(, PSOCK, "nfsrecon", INFSLP);
}
 
/*
Index: nfs/nfs_srvcache.c
===
RCS file: /cvs/src/sys/nfs/nfs_srvcache.c,v
retrieving revision 1.28
diff -u -p -r1.28 nfs_srvcache.c
--- nfs/nfs_srvcache.c  28 Aug 2015 00:03:54 -  1.28
+++ nfs/nfs_srvcache.c  2 Dec 2019 14:06:01 -
@@ -183,7 +183,7 @@ nfsrv_getcache(struct nfsrv_descript *nd
rp = TAILQ_FIRST();
while ((rp->rc_flag & RC_LOCKED) != 0) {
rp->rc_flag |= RC_WANTED;
-   tsleep(rp, PZERO-1, "nfsrc", 0);
+   tsleep_nsec(rp, PZERO-1, "nfsrc", INFSLP);
rp = TAILQ_FIRST();
}
rp->rc_flag |= RC_LOCKED;
@@ -285,7 +285,7 @@ loop:
netaddr_match(NETFAMILY(rp), >rc_haddr, nd->nd_nam)) {
if ((rp->rc_flag & RC_LOCKED)) {
rp->rc_flag |= RC_WANTED;
-   tsleep(rp, PZERO - 1, "nfsrc", 0);
+   tsleep_nsec(rp, PZERO - 1, "nfsrc", INFSLP);
goto loop;
}
rp->rc_flag |= RC_LOCKED;
Index: nfs/nfs_syscalls.c
===
RCS file: /cvs/src/sys/nfs/nfs_syscalls.c,v
retrieving revision 1.114
diff -u -p -r1.114 nfs_syscalls.c
--- nfs/nfs_syscalls.c  6 Jun 2018 06:55:22 -   1.114
+++ nfs/nfs_syscalls.c  2 Dec 2019 14:07:21 -
@@ -165,7 +165,7 @@ sys_nfssvc(struct proc *p, void *v, regi
 
while (nfssvc_sockhead_flag & SLP_INIT) {
nfssvc_sockhead_flag |= SLP_WANTINIT;
-   tsleep(_sockhead, PSOCK, "nfsd init", 0);
+   tsleep_nsec(_sockhead, PSOCK, "nfsd init", INFSLP);
}
 
switch (flags) {
@@ -604,8 +604,8 @@ nfssvc_iod(void *arg)
/* Just loop around doin our stuff until SIGKILL. */
for (;;) {
while (TAILQ_FIRST(_bufq) == NULL && error == 0) {
-   error = tsleep(_bufq,
-   PWAIT | PCATCH, "nfsidl", 0);
+   error = tsleep_nsec(_bufq,
+   PWAIT | PCATCH, "nfsidl", INFSLP);
}
while ((bp = TAILQ_FIRST(_bufq)) != NULL) {
/* Take one off the front of the list */
@@ -702,7 +702,7 @@ again:
(nfsd_head_flag & NFSD_CHECKSLP) == 0) {
nfsd->nfsd_flag |= NFSD_WAITING;
nfsd_waiting++;
-   error = tsleep(nfsd, PSOCK | PCATCH, "nfsd", 0);
+   error = tsleep_nsec(nfsd, PSOCK | PCATCH, "nfsd", INFSLP);
nfsd_waiting--;
if (error)
return (error);



rewrite dhcpv6 handling in tcpdump(8)

2019-12-02 Thread David Gwynne
tcpdump segfaulted on me when i was running it on sparc64, and i think i
narrowed it down to the dhcp6 code. while trying to fix it i discovered
that it implements parsing of some extremely pre-rfc dhcpv6 protocol,
and is completely wrong. this rewrites it so it follows the most recent
rfc, specifically rfc8415.

the main difference difference between the pre-rfc code and the post-rfc
code is that pre-rfc seemed to implement some large basic messages, and
decorated some of them with a small number of options or extension
headers. rfc compliant dhcpv6 is all options. the base header is 4 bytes
and includes a 1 byte message type, and a 3 byte transaction id.
literally everything else is handled by options.

if you need convincing about the rfc compliant message structure,
look at https://tools.ietf.org/html/rfc8415#section-8.

the exception is relay messages, which have a slightly larger header,
but i am ignoring them for now.

as well as throwing out the base pre-rfc message parsing, this diff
basically throws out the option handling too and just prints all options
as bytes. this means some future work will be needed to make it
prettier, but until then i know this wont segfault.

to demo what it looks like before and after, i'm using the DHCPv6.cap
file from https://packetlife.net/captures/protocol/dhcpv6/.

a diff of vanilla tcpdump output:

@@ -1,12 +1,12 @@
 07:52:36.799722 fe80::a00:27ff:fed4:10bb > ff02::16: HBH multicast listener 
report v2, 2 group record(s) [hlim 1]
-07:52:44.775688 fe80::a00:27ff:fefe:8f95.dhcpv6-client > 
ff02::1:2.dhcpv6-server: dhcp6 solicit [hlim 1]
+07:52:44.775688 fe80::a00:27ff:fefe:8f95.dhcpv6-client > 
ff02::1:2.dhcpv6-server: DHCPv6 Solicit xid 100874 [hlim 1]
 07:52:44.776922 fe80::a00:27ff:fed4:10bb > ff02::1:fffe:8f95: icmp6: neighbor 
sol: who has fe80::a00:27ff:fefe:8f95
 07:52:44.777020 fe80::a00:27ff:fefe:8f95 > fe80::a00:27ff:fed4:10bb: icmp6: 
neighbor adv: tgt is fe80::a00:27ff:fefe:8f95
-07:52:44.777375 fe80::a00:27ff:fed4:10bb.dhcpv6-server > 
fe80::a00:27ff:fefe:8f95.dhcpv6-client: dhcp6 advert
+07:52:44.777375 fe80::a00:27ff:fed4:10bb.dhcpv6-server > 
fe80::a00:27ff:fefe:8f95.dhcpv6-client: DHCPv6 Advertise xid 100874
 07:52:44.987623 fe80::a00:27ff:fed4:10bb > ff02::16: HBH multicast listener 
report v2, 2 group record(s) [hlim 1]
-07:52:45.837792 fe80::a00:27ff:fefe:8f95.dhcpv6-client > 
ff02::1:2.dhcpv6-server: dhcp6 request [hlim 1]
-07:52:45.839157 fe80::a00:27ff:fed4:10bb.dhcpv6-server > 
fe80::a00:27ff:fefe:8f95.dhcpv6-client: dhcp6
+07:52:45.837792 fe80::a00:27ff:fefe:8f95.dhcpv6-client > 
ff02::1:2.dhcpv6-server: DHCPv6 Request xid 49174e [hlim 1]
+07:52:45.839157 fe80::a00:27ff:fed4:10bb.dhcpv6-server > 
fe80::a00:27ff:fefe:8f95.dhcpv6-client: DHCPv6 Reply xid 49174e
 07:52:49.784131 fe80::a00:27ff:fefe:8f95 > fe80::a00:27ff:fed4:10bb: icmp6: 
neighbor sol: who has fe80::a00:27ff:fed4:10bb
 07:52:49.784807 fe80::a00:27ff:fed4:10bb > fe80::a00:27ff:fefe:8f95: icmp6: 
neighbor adv: tgt is fe80::a00:27ff:fed4:10bb
-07:52:49.892611 fe80::a00:27ff:fefe:8f95.dhcpv6-client > 
ff02::1:2.dhcpv6-server: dhcp6 [hlim 1]
-07:52:49.893300 fe80::a00:27ff:fed4:10bb.dhcpv6-server > 
fe80::a00:27ff:fefe:8f95.dhcpv6-client: dhcp6
+07:52:49.892611 fe80::a00:27ff:fefe:8f95.dhcpv6-client > 
ff02::1:2.dhcpv6-server: DHCPv6 Release xid c789b0 [hlim 1]
+07:52:49.893300 fe80::a00:27ff:fed4:10bb.dhcpv6-server > 
fe80::a00:27ff:fefe:8f95.dhcpv6-client: DHCPv6 Reply xid c789b0

tcpdump -v:

@@ -1,12 +1,35 @@
 07:52:36.799722 fe80::a00:27ff:fed4:10bb > ff02::16: HBH (rtalert: 0x) 
multicast listener report v2, 2 group record(s) [gaddr ff05::1:3 to_ex, 0 
source(s)] [gaddr ff02::1:2 to_ex, 0 source(s)] [icmp6 cksum ok] [hlim 1] (len 
56)
-07:52:44.775688 fe80::a00:27ff:fefe:8f95.dhcpv6-client > 
ff02::1:2.dhcpv6-server: [udp sum ok] dhcp6 solicit( 
cliaddr=1:e:1:1:1c39:cf88:800:27fe relayaddr=8f95:6:4:17:18:8:2:0) [hlim 1] 
(len 60)
+07:52:44.775688 fe80::a00:27ff:fefe:8f95.dhcpv6-client > 
ff02::1:2.dhcpv6-server: [udp sum ok] DHCPv6 Solicit xid 100874
+   option 1 len 14 1c39cf88080027fe8f9500060004
+   option 6 len 4 00080002
+   option 8 len 2 000c
+   option 25 len 12 0e101518 [hlim 1] (len 60)
 07:52:44.776922 fe80::a00:27ff:fed4:10bb > ff02::1:fffe:8f95: icmp6: neighbor 
sol: who has fe80::a00:27ff:fefe:8f95(src lladdr: 08:00:27:d4:10:bb) [icmp6 
cksum ok] (len 32, hlim 255)
 07:52:44.777020 fe80::a00:27ff:fefe:8f95 > fe80::a00:27ff:fed4:10bb: icmp6: 
neighbor adv: tgt is fe80::a00:27ff:fefe:8f95(SO)(tgt lladdr: 
08:00:27:fe:8f:95) [icmp6 cksum ok] (len 32, hlim 255)
-07:52:44.777375 fe80::a00:27ff:fed4:10bb.dhcpv6-server > 
fe80::a00:27ff:fefe:8f95.dhcpv6-client: [udp sum ok] dhcp6 advert( pref=116 
cliaddr=19:29:27fe:8f95:: relayaddr=1a:19:0:1194:0:1c20:4020:100 
servaddr=0:fe::100 (unknown, len=256)) (len 93, hlim 64)
+07:52:44.777375 fe80::a00:27ff:fed4:10bb.dhcpv6-server > 
fe80::a00:27ff:fefe:8f95.dhcpv6-client: [udp sum ok] 

Re: syscall call-from verification

2019-12-02 Thread Thomas de Grivel
My bad, SBCL uses the libc's wrappers indeed looking at the sources.

Le ven. 29 nov. 2019 à 22:41, Josh Elsasser  a écrit :
>
> On Fri, Nov 29, 2019 at 10:12:10AM +0100, Thomas de Grivel wrote:
> > Maybe Go is not the only problem, I see SBCL compiling syscalls too.
> >
> > Truth is libc is for C and not all programs are written in C nowadays.
>
> Where are you seeing SBCL compiling direct syscalls? In my testing,
> SBCL self-hosts just fine under a kernel modified to disallow syscalls
> from the text segment, whereas go is killed under such a kernel. Are
> you sure you're not seeing SBCL compile calls to the libc syscall
> wrappers?



-- 
 Thomas de Grivel
 kmx.io



Re: change to bsd.port.mk to help debug packages a bit

2019-12-02 Thread Landry Breuil
On Wed, Nov 27, 2019 at 05:55:47PM +0100, Marc Espie wrote:
> This should get rid of the weird error (don't know how to make
> .../all/debug-*.tgz) when switching from !DEBUG_PACKAGES to DEBUG_PACKAGES.
> 
> Basically, this introduces a "build two targets at once" in bsd.port.mk.
> 
> make has some glue to figure out whether this is a "duplicate the work" or
> "one target builds two things" (already used for yacc and friends), by
> looking for variations on $@... which includes $@D for better or worse, hence
> the small tweak.
> 
> This should work on all settings, including running make -jN package
> (which doesn't make a lot of sense, but whatever).
> 
> Please check/test

Fixes the error i was seeing, looks ok to me.



Re: grep -R with no path

2019-12-02 Thread Marc Espie
On Mon, Dec 02, 2019 at 08:31:02AM +, Miod Vallat wrote:
> grep(1), when invoked with the -R option but no path, displays a
> "recursive search of stdin" warning and acts as if -R had not been
> specified.
> 
> GNU grep, in that case, will perform a recursive search in the current
> directory, i.e. uses an implicit "." path if none is given.
> 
> This is IMO a much better behaviour. What about the following diff?
> 
> Index: grep.c
> ===
> RCS file: /OpenBSD/src/usr.bin/grep/grep.c,v
> retrieving revision 1.62
> diff -u -p -r1.62 grep.c
> --- grep.c7 Oct 2019 20:04:00 -   1.62
> +++ grep.c2 Dec 2019 08:27:09 -
> @@ -473,8 +473,12 @@ main(int argc, char *argv[])
>   ++argv;
>   }
>  
> - if (Rflag && argc == 0)
> - warnx("warning: recursive search of stdin");
> + if (Rflag && argc == 0) {
> + /* default to . if no path given */
> + static char *dot_argv[] = { ".", NULL };
> + argv = dot_argv;
> + argc = 1;
> + }
>   if (Eflag)
>   cflags |= REG_EXTENDED;
>   if (Fflag)
> 
> 
I concur, I like it better as well.
-R isn't in POSIX anyway, so we don't have to worry about standard.



grep -R with no path

2019-12-02 Thread Miod Vallat
grep(1), when invoked with the -R option but no path, displays a
"recursive search of stdin" warning and acts as if -R had not been
specified.

GNU grep, in that case, will perform a recursive search in the current
directory, i.e. uses an implicit "." path if none is given.

This is IMO a much better behaviour. What about the following diff?

Index: grep.c
===
RCS file: /OpenBSD/src/usr.bin/grep/grep.c,v
retrieving revision 1.62
diff -u -p -r1.62 grep.c
--- grep.c  7 Oct 2019 20:04:00 -   1.62
+++ grep.c  2 Dec 2019 08:27:09 -
@@ -473,8 +473,12 @@ main(int argc, char *argv[])
++argv;
}
 
-   if (Rflag && argc == 0)
-   warnx("warning: recursive search of stdin");
+   if (Rflag && argc == 0) {
+   /* default to . if no path given */
+   static char *dot_argv[] = { ".", NULL };
+   argv = dot_argv;
+   argc = 1;
+   }
if (Eflag)
cflags |= REG_EXTENDED;
if (Fflag)