Re: midi(4): *sleep(9) -> *sleep_nsec(9)

2019-12-19 Thread Alexandre Ratchov
On Wed, Dec 18, 2019 at 10:41:56AM -0600, Scott Cheloha wrote:
> On Wed, Dec 18, 2019 at 09:54:43AM +0100, Alexandre Ratchov wrote:
> > On Tue, Dec 17, 2019 at 07:09:02PM -0600, Scott Cheloha wrote:
> > > The only conversion I'm having trouble with is the tsleep().
> > > The comment says "20ms", but then we use some arithmetic
> > > to derive a count of ticks.
> > > 
> > > Given
> > > 
> > >   hz * MIDI_MAXWRITE / MIDI_RATE
> > > 
> > > You have hz ticks/second, and 32 bytes, and 3125 bytes/second, so you
> > > have
> > > 
> > > hz ticks   32 bytes   3125 bytes
> > >  *  / --
> > > second1   second
> > > 
> > >   = 32 * hz ticks
> > > -
> > > 3125
> > > 
> > >   = 1 ticks
> > > 
> > > if hz = 100, with integer division.
> > > 
> > > I'm not sure how to use the constants to produce a count of
> > > milliseconds.  Maybe I'm just having a slow day.
> > 
> > The problem is that close() may reset the transmitter before the few
> > bytes of its internal buffer is sent on the wire; there's no "wait for
> > completion" feature in such simple hardware, so we just wait few
> > milliseconds.
> > 
> > The transmitter buffer size is around 16 bytes, the byte rate is 3125
> > bytes/second.  So if we wait at least 16B / 3125B/s = 5.12ms, we're
> > safe. Waiting 10ms-20ms is enough and is unnoticeable.
> 
> Just to be sure we're all on the same page, the comment says 20ms is
> 64 bytes' worth, and MIDI_MAXWRITE is 32 bytes, but you're saying the
> buffer is around 16 bytes.  Is any of this inconsistent?

Yeah, the comment doesn't match the code.

16B is what "typical" UARTs buffer. MIDI_MAXWRITE and 64 are both
upper bounds of it.

Waiting 20ms is safer. MIDI_MAXWRITE could be removed completely once
your diff is in.



net80211: block ack Rx fixes

2019-12-19 Thread Stefan Sperling
The function ieee80211_input_ba_seq() forwards any frames on the Rx block
ack queue up to a certain sequence number. But it forgets to move the
sequence number window forward accordingly. This exacerbates the effect
of lost frames: We will keep expecting to receive these frames which have
now been dealt with, holding back other frames waiting on the queue,
until the window gets moved for some other reason.
This results in ridiculously high ping times and stalled TCP connections.
The problem is trigged when the "input block ack window slides" counter
in 'netstat -W iwm0' goes up.
With this fix, such an event doesn't lead to stalled packets anymore.
Tested on a somewhat lossy network which is a lot more usable for me now.

Also, do not allow the peer to establish a block ack agreement before the
WPA handshake is done. Looking over packet captures I noticed that we
allow this, and it doesn't really make sense. Any data frames received
before the WPA handshake is done will be dropped.
So just ignore such early BA requests. The peer will retry later.

ok?

diff ed3519547daf2f19aa02539f55412ae93966c319 /usr/src
blob - 19b17c38cc1db1168cd4db07434c422827a828f3
file + sys/net80211/ieee80211_input.c
--- sys/net80211/ieee80211_input.c
+++ sys/net80211/ieee80211_input.c
@@ -782,7 +782,10 @@ ieee80211_input_ba_seq(struct ieee80211com *ic, struct
} else
ic->ic_stats.is_ht_rx_ba_frame_lost++;
ba->ba_head = (ba->ba_head + 1) % IEEE80211_BA_MAX_WINSZ;
+   /* move window forward */
+   ba->ba_winstart = (ba->ba_winstart + 1) & 0xfff;
}
+   ba->ba_winend = (ba->ba_winstart + ba->ba_winsize - 1) & 0xfff;
 }
 
 /* Flush a consecutive sequence of frames from the reorder buffer. */
@@ -2561,6 +2564,11 @@ ieee80211_recv_addba_req(struct ieee80211com *ic, stru
DPRINTF(("frame too short\n"));
return;
}
+
+   /* No point in starting block-ack before the WPA handshake is done. */
+   if ((ic->ic_flags & IEEE80211_F_RSNON) && !ni->ni_port_valid)
+   return;
+
/* MLME-ADDBA.indication */
wh = mtod(m, struct ieee80211_frame *);
frm = (const u_int8_t *)&wh[1];



arc4random: Replace memset(3) with explicit_bzero(3)

2019-12-19 Thread Fabio Scotoni
As far as I can tell, all of the calls to memset(3) in
lib/libc/crypt/arc4random.c are intended to wipe memory to avoid having
the randomly generated data in memory twice, so it would seem good
practice to use explicit_bzero(3) to avoid this being optimized out.

Index: lib/libc/crypt/arc4random.c
===
RCS file: /cvs/src/lib/libc/crypt/arc4random.c,v
retrieving revision 1.55
diff -u -p -r1.55 arc4random.c
--- lib/libc/crypt/arc4random.c 24 Mar 2019 17:56:54 -  1.55
+++ lib/libc/crypt/arc4random.c 19 Dec 2019 12:51:23 -
@@ -98,7 +98,7 @@ _rs_stir(void)

/* invalidate rs_buf */
rs->rs_have = 0;
-   memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
+   explicit_bzero(rsx->rs_buf, sizeof(rsx->rs_buf));

rs->rs_count = 160;
 }
@@ -119,7 +119,7 @@ static inline void
 _rs_rekey(u_char *dat, size_t datlen)
 {
 #ifndef KEYSTREAM_ONLY
-   memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
+   explicit_bzero(rsx->rs_buf, sizeof(rsx->rs_buf));
 #endif
/* fill rs_buf with the keystream */
chacha_encrypt_bytes(&rsx->rs_chacha, rsx->rs_buf,
@@ -134,7 +134,7 @@ _rs_rekey(u_char *dat, size_t datlen)
}
/* immediately reinit for backtracking resistance */
_rs_init(rsx->rs_buf, KEYSZ + IVSZ);
-   memset(rsx->rs_buf, 0, KEYSZ + IVSZ);
+   explicit_bzero(rsx->rs_buf, KEYSZ + IVSZ);
rs->rs_have = sizeof(rsx->rs_buf) - KEYSZ - IVSZ;
 }

@@ -152,7 +152,7 @@ _rs_random_buf(void *_buf, size_t n)
keystream = rsx->rs_buf + sizeof(rsx->rs_buf)
- rs->rs_have;
memcpy(buf, keystream, m);
-   memset(keystream, 0, m);
+   explicit_bzero(keystream, m);
buf += m;
n -= m;
rs->rs_have -= m;
@@ -172,7 +172,7 @@ _rs_random_u32(uint32_t *val)
_rs_rekey(NULL, 0);
keystream = rsx->rs_buf + sizeof(rsx->rs_buf) - rs->rs_have;
memcpy(val, keystream, sizeof(*val));
-   memset(keystream, 0, sizeof(*val));
+   explicit_bzero(keystream, sizeof(*val));
rs->rs_have -= sizeof(*val);
 }



[Patch]: VA-API integration with xenocara

2019-12-19 Thread Brad DeMorrow
This is a rather large patch that moves my previously submitted
VA-API ports into xenocara. For your convenience, I've inlined
a diff that shows you all of the changes I made to existing files
that you can easily read in your MUA.  The xenocara patch also
contains these changes and should be the only xenocara patch
you need to apply. The patch to BSD.x11.dist is inlined in
this email alone.

I tried sending this email yesterday with the gzipped xenocara
patch as an attachment, but it was apparently rejected from
the mailing list.  I've used xz to compress it instead and
uploaded it to my google drive.
Here is a link to download it instead:

https://drive.google.com/open?id=1_Jwd08vteJzM0mm4sXI_zjAq2pNj3yIK


Summary of Changes:
 - libva added to xenocara/lib/libva
 - vainfo added to xenocara/app/vainfo
 - intel-vaapi-driver added to xenocara/driver/intel-vaapi-driver
 - Mesa Makefile.bsd-wrapper updated to build with --enable-va flag
 - 3RDPARTY file updated to include libva, libva-utils, and intel-vaapi-driver
 - BSD.x11.dist updated to include /usr/X11R6/include/va/ (patch inlined here)

Architectures Tested: amd64 

Testing Instructions:
1. pkg_add xz
1. save xenocara-vaapi.patch.xz to /tmp
2. xz -d /tmp/xenocara-vaapi.patch.xz
3. cd /usr/xenocara
4. patch -p0 < /tmp/xenocara-vaapi.patch
5. Follow normal build instructions in README within the root of xenocara
6. Run vainfo.  It should report available profiles and entrypoints for VA-API.
   Example of successful execution:

libva info: VA-API version 1.6.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/X11R6/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_6
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.6 (libva 2.6.0.pre1)
vainfo: Driver version: Intel i965 driver for Intel(R) Kaby Lake - 2.4.0
vainfo: Supported profile and entrypoints
  VAProfileMPEG2Simple: VAEntrypointVLD
  VAProfileMPEG2Simple: VAEntrypointEncSlice
  VAProfileMPEG2Main  : VAEntrypointVLD
  VAProfileMPEG2Main  : VAEntrypointEncSlice
  VAProfileH264ConstrainedBaseline: VAEntrypointVLD
  VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
  VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
  VAProfileH264Main   : VAEntrypointVLD
  VAProfileH264Main   : VAEntrypointEncSlice
  VAProfileH264Main   : VAEntrypointEncSliceLP
  VAProfileH264High   : VAEntrypointVLD
  VAProfileH264High   : VAEntrypointEncSlice
  VAProfileH264High   : VAEntrypointEncSliceLP
  VAProfileH264MultiviewHigh  : VAEntrypointVLD
  VAProfileH264MultiviewHigh  : VAEntrypointEncSlice
  VAProfileH264StereoHigh : VAEntrypointVLD
  VAProfileH264StereoHigh : VAEntrypointEncSlice
  VAProfileVC1Simple  : VAEntrypointVLD
  VAProfileVC1Main: VAEntrypointVLD
  VAProfileVC1Advanced: VAEntrypointVLD
  VAProfileNone   : VAEntrypointVideoProc
  VAProfileJPEGBaseline   : VAEntrypointVLD
  VAProfileJPEGBaseline   : VAEntrypointEncPicture
  VAProfileVP8Version0_3  : VAEntrypointVLD
  VAProfileVP8Version0_3  : VAEntrypointEncSlice
  VAProfileHEVCMain   : VAEntrypointVLD
  VAProfileHEVCMain   : VAEntrypointEncSlice
  VAProfileHEVCMain10 : VAEntrypointVLD
  VAProfileHEVCMain10 : VAEntrypointEncSlice
  VAProfileVP9Profile0: VAEntrypointVLD
  VAProfileVP9Profile0: VAEntrypointEncSlice
  VAProfileVP9Profile2: VAEntrypointVLD
   


Inline diff for BSD.x11.dist:
Index: BSD.x11.dist
===
RCS file: /cvs/src/etc/mtree/BSD.x11.dist,v
retrieving revision 1.54
diff -u -p -u -p -r1.54 BSD.x11.dist
--- BSD.x11.dist27 May 2019 07:03:11 -  1.54
+++ BSD.x11.dist18 Dec 2019 18:23:46 -
@@ -87,6 +87,8 @@
 ..
 pixman-1
 ..
+va
+..
 vulkan
 ..
 xcb


List of existing xenocara files that have changed:
brad-laptop$ grep -E '^Index: ' xenocara-vaapi.patch | grep -v 'app/vainfo' | 
grep -v 'lib/libva' | grep -v 'driver/intel-vaapi-driver'
Index: 3RDPARTY
Index: app/Makefile
Index: driver/Makefile
Index: lib/Makefile
Index: lib/mesa/Makefile.bsd-wrapper

Inline diffs for these files:

Index: 3RDPARTY
===
RCS file: /cvs/xenocara/3RDPARTY,v
retrieving revision 1.354
diff -u -p -u -p -r1.354 3RDPARTY
--- 3RDPARTY12 Dec 2019 06:08:12 -  1.354
+++ 3RDPARTY18 Dec 2019 19:32:09 -
@@ -1,5 +1,17 @@
 # $OpenBSD: 3RDPARTY,v 1.354 2019/12/12 06:08:12 matthieu Exp $

bgpct minor cleanup

2019-12-19 Thread Claudio Jeker
This is just some minor cleanup needed before starting to split out
functions into a new file. First it shuffles and changes the fmt_timecore
functions. It adds an additional check to not print negative timeframes
(the result would most probably be wrong anyway).
Second switch show_mrt_dump to use show_rib instead of calling
show_rib_detail or show_rib_brief directly.

This should not cause any visible change to bgpctl.
OK?
-- 
:wq Claudio

Index: bgpctl.c
===
RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v
retrieving revision 1.251
diff -u -p -r1.251 bgpctl.c
--- bgpctl.c19 Dec 2019 06:43:51 -  1.251
+++ bgpctl.c19 Dec 2019 15:57:02 -
@@ -58,8 +58,7 @@ void   print_neighbor_capa_mp(struct pee
 voidprint_neighbor_capa_restart(struct peer *);
 voidprint_neighbor_msgstats(struct peer *);
 voidprint_timer(const char *, time_t);
-static char*fmt_timeframe(time_t t);
-static char*fmt_timeframe_core(time_t t);
+const char *fmt_timeframe(time_t t);
 voidshow_fib_flags(u_int16_t);
 voidshow_fib(struct kroute_full *);
 voidshow_fib_table(struct ktable *);
@@ -821,30 +820,10 @@ print_neighbor_msgstats(struct peer *p)
p->stats.prefix_sent_eor, p->stats.prefix_rcvd_eor);
 }
 
-void
-print_timer(const char *name, time_t d)
-{
-   printf("  %-20s ", name);
-
-   if (d <= 0)
-   printf("%-20s\n", "due");
-   else
-   printf("due in %-13s\n", fmt_timeframe_core(d));
-}
-
 #define TF_BUFS8
 #define TF_LEN 9
 
-static char *
-fmt_timeframe(time_t t)
-{
-   if (t == 0)
-   return ("Never");
-   else
-   return (fmt_timeframe_core(time(NULL) - t));
-}
-
-static char *
+static const char *
 fmt_timeframe_core(time_t t)
 {
char*buf;
@@ -878,6 +857,31 @@ fmt_timeframe_core(time_t t)
return (buf);
 }
 
+const char *
+fmt_timeframe(time_t t)
+{
+   time_t now;
+
+   if (t == 0)
+   return ("Never");
+
+   now = time(NULL);
+   if (t > now)/* time in the future is not possible */
+   t = now;
+   return (fmt_timeframe_core(now - t));
+}
+
+void
+print_timer(const char *name, time_t d)
+{
+   printf("  %-20s ", name);
+
+   if (d <= 0)
+   printf("%-20s\n", "due");
+   else
+   printf("due in %-13s\n", fmt_timeframe_core(d));
+}
+
 void
 show_fib_flags(u_int16_t flags)
 {
@@ -1880,10 +1884,14 @@ void
 show_mrt_dump(struct mrt_rib *mr, struct mrt_peer *mp, void *arg)
 {
struct ctl_show_rib  ctl;
+   struct parse_result  res;
struct ctl_show_rib_request *req = arg;
struct mrt_rib_entry*mre;
u_int16_ti, j;
 
+   memset(&res, 0, sizeof(res));
+   res.flags = req->flags;
+
for (i = 0; i < mr->nentries; i++) {
mre = &mr->entries[i];
bzero(&ctl, sizeof(ctl));
@@ -1937,14 +1945,13 @@ show_mrt_dump(struct mrt_rib *mr, struct
!match_aspath(mre->aspath, mre->aspath_len, &req->as))
continue;
 
+   show_rib(&ctl, mre->aspath, mre->aspath_len, &res);
if (req->flags & F_CTL_DETAIL) {
-   show_rib_detail(&ctl, mre->aspath, mre->aspath_len, 0);
for (j = 0; j < mre->nattrs; j++)
show_attr(mre->attrs[j].attr,
mre->attrs[j].attr_len,
req->flags);
-   } else
-   show_rib_brief(&ctl, mre->aspath, mre->aspath_len);
+   }
}
 }
 



fix mcount.po target in libc/gmon/Makefile.inc

2019-12-19 Thread Theo Buehler
According to the comment in lib/libc/gmon/Makefile.inc, mcount needs
special treatment since it cannot be compiled with profiling or pie.

When depend was removed as an independent target, this special case was
missed.  Align it with the inference rules in bsd.lib.mk. This also
makes 'make clean' work correctly (it currently leaves mcount.po.d
behind).

Index: lib/libc/gmon/Makefile.inc
===
RCS file: /var/cvs/src/lib/libc/gmon/Makefile.inc,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile.inc
--- lib/libc/gmon/Makefile.inc  30 Mar 2016 06:38:41 -  1.6
+++ lib/libc/gmon/Makefile.inc  19 Dec 2019 10:04:01 -
@@ -9,6 +9,7 @@ MAN+=   moncontrol.3
 # mcount cannot be compiled with profiling or pie
 mcount.po:
@echo "${COMPILE.c} ${NOPIE_FLAGS} ${.IMPSRC} -o ${.TARGET}"
-   @${COMPILE.c} ${NOPIE_FLAGS} ${.IMPSRC} -o ${.TARGET}.o
+   @${COMPILE.c} ${DFLAGS} ${NOPIE_FLAGS} ${.IMPSRC} -o ${.TARGET}.o
+   @-mv $@.d $*.d
@${LD} -X -r ${.TARGET}.o -o ${.TARGET}
@rm -f ${.TARGET}.o



Re: ublink(4), led(4) and ledctl(1)

2019-12-19 Thread Patrick Wildt
On Fri, Dec 13, 2019 at 10:34:59PM +0100, Patrick Wildt wrote:
> Hi,
> 
> I have a ThingM blink(1) USB RGB device that shows up as uhid(4).
> The tooling is "interesting", especially with all those libusb and
> HID libraries doing the abstraction.  This introduces ublink(4), a
> dedicated kernel driver for that device.  There are two LEDs on the
> device, which can be modified seperately.  The firmware is impress-
> ive and provides features like playing sequences and adjusting how
> long it should take to fade from one colour to another.  Obviously
> this also increases the complexity of the tools involved to toggle
> those RGB LEDs.  Thus, the driver is kept simple (for now).
> 
> In addition to providing a way to set RGB LEDs, we can also use it
> as a watchdog.  If we don't "tickle" it in a specific timeframe it
> will play a (unless otherwise programmed) random sequence, which for
> instance can be used to see that the machine has paniced.  This has
> been quite useful while debugging the USB stack, because once the
> magic sequence started you know that you're in deep trouble.  All
> other features are unimplemented.  Gamma correction would be nice
> to have.
> 
> Since there is no abstraction layer for LEDs yet, this also intro-
> duces led(4), which attaches to ublink(4), and provides /dev/ledX.
> 
> uhidev1 at uhub0 port 3 configuration 1 interface 0 "ThingM blink(1) mk2" rev 
> 2.00/0.02 addr 2
> uhidev1: iclass 3/0, 1 report id
> ublink0 at uhidev1 reportid 1
> led0 at ublink0: 2 LEDs
> 
> led(4) can be improved even further.  We can attach the ThinkPad
> LEDs to it to control it.  There are also plenty of mouses that
> have controllable RGBs. We could add "human readable descrip-
> tions", for instance "upper side LED" or "docking station LED",
> so that users can find out more easily which LED they have to
> toggle.  A fading or blinking mechanism, including hardware off-
> loading, can probably be added as well.
> 
> To be able to control those devices, there's ledctl(1), a simple
> program that can turn on/off /dev/ledX devices and also set RGB
> colours.
> 
> I only did the MAKEDEV stuff for amd64, and also there are no
> manpages yet.  Also I haven't run it through make build yet,
> sorry.  And I don't often do userland tools, so feel free to
> let me know how to improve it.
> 
> Thanks,
> Patrick

Updated diff, changes:

 * All the manpages!
 * /dev/led{0,1,2,...} are now by default 600.
 * Doesn't panic when you remove the stick, I think I
   might have already had that fixed in the first diff.
 * Some small improvements here and there, nothing special.

Thanks to jan for ledctl(1) manpage and review.  And thanks to
cheloha@!

Patrick

diff --git a/etc/MAKEDEV.common b/etc/MAKEDEV.common
index c187df748d6..dc67b54ec5a 100644
--- a/etc/MAKEDEV.common
+++ b/etc/MAKEDEV.common
@@ -521,6 +521,8 @@ __devitem(ipmi, ipmi*, IPMI BMC access)dnl
 _mkdev(ipmi, ipmi*, {-M ipmi$U c major_ipmi_c $U 600-})dnl
 __devitem(gpio, gpio*, General Purpose Input/Output)dnl
 _mcdev(gpio, gpio*, gpio, {-major_gpio_c-}, 600)dnl
+__devitem(led, led*, Generic LED devices)dnl
+_mcdev({-led-}, led*, {-led-}, {-major_led_c-}, 600)dnl
 __devitem(vmm, vmm, Virtual Machine Monitor)dnl
 _mkdev(vmm, vmm, {-M vmm c major_vmm_c 0 600-})dnl
 __devitem(pvbus, pvbus*, paravirtual device tree root)dnl
diff --git a/etc/etc.amd64/MAKEDEV b/etc/etc.amd64/MAKEDEV
index 543b0ec731b..50f7ac53acb 100644
--- a/etc/etc.amd64/MAKEDEV
+++ b/etc/etc.amd64/MAKEDEV
@@ -78,6 +78,7 @@
 #  gpio*   General Purpose Input/Output
 #  hotplug devices hot plugging
 #  ipmi*   IPMI BMC access
+#  led*Generic LED devices
 #  nvram   NVRAM access
 #  kcovKernel code coverage tracing
 #  pci*PCI bus devices
@@ -329,6 +330,10 @@ nvram)
M nvram c 85 0 440 kmem
;;
 
+led*)
+   M led$U c 55 $U 600
+   ;;
+
 ipmi*)
M ipmi$U c 96 $U 600
;;
diff --git a/etc/etc.amd64/MAKEDEV.md b/etc/etc.amd64/MAKEDEV.md
index f46b52bd7d6..66e85a16da8 100644
--- a/etc/etc.amd64/MAKEDEV.md
+++ b/etc/etc.amd64/MAKEDEV.md
@@ -76,6 +76,7 @@ _DEV(gpio, 88)
 _DEV(hotplug, 82)
 _DEV(ipmi, 96)
 dnl _DEV(joy, 26)
+_DEV(led, 55)
 _DEV(nvram, 85)
 _DEV(kcov, 19)
 _DEV(pci, 72)
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index 307bd44b66b..45ab7539c60 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -41,8 +41,8 @@ MAN=  aac.4 abcrtc.4 ac97.4 acphy.4 acrtc.4 \
ip.4 ip6.4 ipcomp.4 ipgphy.4 ipmi.4 ips.4 ipsec.4 ipw.4 \
isa.4 isagpio.4 isapnp.4 islrtc.4 it.4 itherm.4 iwi.4 iwn.4 iwm.4 \
ix.4 ixgb.4 ixl.4 jmb.4 jme.4 jmphy.4 \
-   kate.4 kcov.4 km.4 ksmn.4 ksyms.4 kubsan.4 kue.4 lc.4 lge.4 lii.4 \
-   lisa.4 lm.4 lmenv.4 lmn.4 lmtemp.4 lo.4 lpt.4 lxtphy.4 luphy.4 \
+   kate.4 kcov.4 km.4 ksmn.4 ksyms.4 kubsan.4 kue.4 lc.4 led.4 lge.4 \
+   lii.4 lisa.4 lm.4 lmenv.4 lmn.4 lmtemp.4 lo.4 lpt.4 lxtphy.4 luphy.4 \
maestro.4 mainbus.4 m

Re: arc4random: Replace memset(3) with explicit_bzero(3)

2019-12-19 Thread Theo de Raadt
Fabio Scotoni  wrote:

> As far as I can tell, all of the calls to memset(3) in
> lib/libc/crypt/arc4random.c are intended to wipe memory to avoid having
> the randomly generated data in memory twice, so it would seem good
> practice to use explicit_bzero(3) to avoid this being optimized out.

please clarify under what rules would those memset's be optimized out

> Index: lib/libc/crypt/arc4random.c
> ===
> RCS file: /cvs/src/lib/libc/crypt/arc4random.c,v
> retrieving revision 1.55
> diff -u -p -r1.55 arc4random.c
> --- lib/libc/crypt/arc4random.c   24 Mar 2019 17:56:54 -  1.55
> +++ lib/libc/crypt/arc4random.c   19 Dec 2019 12:51:23 -
> @@ -98,7 +98,7 @@ _rs_stir(void)
> 
>   /* invalidate rs_buf */
>   rs->rs_have = 0;
> - memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
> + explicit_bzero(rsx->rs_buf, sizeof(rsx->rs_buf));

rsx is global scope, non-static, the compiler has no justification for
eliding a bzero since other external code has visibility on the buffer
 
>   rs->rs_count = 160;
>  }
> @@ -119,7 +119,7 @@ static inline void
>  _rs_rekey(u_char *dat, size_t datlen)
>  {
>  #ifndef KEYSTREAM_ONLY
> - memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
> + explicit_bzero(rsx->rs_buf, sizeof(rsx->rs_buf));

same here

>  #endif
>   /* fill rs_buf with the keystream */
>   chacha_encrypt_bytes(&rsx->rs_chacha, rsx->rs_buf,
> @@ -134,7 +134,7 @@ _rs_rekey(u_char *dat, size_t datlen)
>   }
>   /* immediately reinit for backtracking resistance */
>   _rs_init(rsx->rs_buf, KEYSZ + IVSZ);
> - memset(rsx->rs_buf, 0, KEYSZ + IVSZ);
> + explicit_bzero(rsx->rs_buf, KEYSZ + IVSZ);

same here

>   rs->rs_have = sizeof(rsx->rs_buf) - KEYSZ - IVSZ;
>  }
> 
> @@ -152,7 +152,7 @@ _rs_random_buf(void *_buf, size_t n)
>   keystream = rsx->rs_buf + sizeof(rsx->rs_buf)
>   - rs->rs_have;
>   memcpy(buf, keystream, m);
> - memset(keystream, 0, m);
> + explicit_bzero(keystream, m);

keystream is a piece of rsx, same argument as above

>   buf += m;
>   n -= m;
>   rs->rs_have -= m;
> @@ -172,7 +172,7 @@ _rs_random_u32(uint32_t *val)
>   _rs_rekey(NULL, 0);
>   keystream = rsx->rs_buf + sizeof(rsx->rs_buf) - rs->rs_have;
>   memcpy(val, keystream, sizeof(*val));
> - memset(keystream, 0, sizeof(*val));
> + explicit_bzero(keystream, sizeof(*val));

and same here

>   rs->rs_have -= sizeof(*val);
>  }
> 

there is no voodoo involved in the "compiler deletes memset" optimization.
it only happens when it can prove there are no other viewers.  this is a
clearcut case that there are other viewers.  therefore we don't need the
function-call non-optimized overhead of explicit_bzero.



[2/3] ssh/readconf.c: reorder keywords

2019-12-19 Thread Martin
Hey!

Part 2: This moves always unsupported keywords in the appropriate section.
Also move oSecurityProvider to match the order in the OpCodes enum.

Best,

Martin

diff --git readconf.c readconf.c
index eff2d5d1672..c2c3d55b656 100644
--- readconf.c
+++ readconf.c
@@ -183,6 +183,9 @@ static struct {
{ "afstokenpassing", oUnsupported },
{ "kerberosauthentication", oUnsupported },
{ "kerberostgtpassing", oUnsupported },
+   { "rsaauthentication", oUnsupported },
+   { "rhostsrsaauthentication", oUnsupported },
+   { "compressionlevel", oUnsupported },
 
/* Sometimes-unsupported options */
 #if defined(GSSAPI)
@@ -199,10 +202,6 @@ static struct {
{ "smartcarddevice", oUnsupported },
{ "pkcs11provider", oUnsupported },
 #endif
-   { "securitykeyprovider", oSecurityKeyProvider },
-   { "rsaauthentication", oUnsupported },
-   { "rhostsrsaauthentication", oUnsupported },
-   { "compressionlevel", oUnsupported },
 
{ "forwardagent", oForwardAgent },
{ "forwardx11", oForwardX11 },
@@ -296,6 +295,7 @@ static struct {
{ "pubkeyacceptedkeytypes", oPubkeyAcceptedKeyTypes },
{ "ignoreunknown", oIgnoreUnknown },
{ "proxyjump", oProxyJump },
+   { "securitykeyprovider", oSecurityKeyProvider },
 
{ NULL, oBadOption }
 };



Re: ublink(4), led(4) and ledctl(1)

2019-12-19 Thread Stuart Henderson
While it's nice to have basic support in the kernel, for people using
these devices for sequences / controlling a chain of neopixels / etc
they're going to need a custom kernel with the driver disabled in order
to access it from userland.

For release users this either locks them out of using syspatch
completely (if they do this by building -stable with custom config -
syspatch won't run at all with -stable), or at least from using syspatch
for kernel fixes (if using config -ef) - so it would be really nice to
have a better way around this before adding more drivers taking over
from existing device support.



[3/3] ssh/readconf.c: Remove deprecated/unsupported opcodes

2019-12-19 Thread Martin
Hey!

Final part: Remove deprecated/always unsupported opcodes from the enum. This is
already the case for the majority of the deprecated/always unsupported opcodes.

Best,

Martin

diff --git readconf.c readconf.c
index c2c3d55b656..cc845c6fc16 100644
--- readconf.c
+++ readconf.c
@@ -130,15 +130,15 @@ typedef enum {
oHost, oMatch, oInclude,
oForwardAgent, oForwardX11, oForwardX11Trusted, oForwardX11Timeout,
oGatewayPorts, oExitOnForwardFailure,
-   oPasswordAuthentication, oRSAAuthentication,
+   oPasswordAuthentication,
oChallengeResponseAuthentication, oXAuthLocation,
-   oIdentityFile, oHostname, oPort, oCipher, oRemoteForward, oLocalForward,
+   oIdentityFile, oHostname, oPort, oRemoteForward, oLocalForward,
oCertificateFile, oAddKeysToAgent, oIdentityAgent,
-   oUser, oEscapeChar, oRhostsRSAAuthentication, oProxyCommand,
+   oUser, oEscapeChar, oProxyCommand,
oGlobalKnownHostsFile, oUserKnownHostsFile, oConnectionAttempts,
oBatchMode, oCheckHostIP, oStrictHostKeyChecking, oCompression,
-   oCompressionLevel, oTCPKeepAlive, oNumberOfPasswordPrompts,
-   oUsePrivilegedPort, oLogFacility, oLogLevel, oCiphers, oMacs,
+   oTCPKeepAlive, oNumberOfPasswordPrompts,
+   oLogFacility, oLogLevel, oCiphers, oMacs,
oPubkeyAuthentication,
oKbdInteractiveAuthentication, oKbdInteractiveDevices, oHostKeyAlias,
oDynamicForward, oPreferredAuthentications, oHostbasedAuthentication,



Re: ublink(4), led(4) and ledctl(1)

2019-12-19 Thread Theo de Raadt
Stuart Henderson  wrote:

> While it's nice to have basic support in the kernel, for people using
> these devices for sequences / controlling a chain of neopixels / etc
> they're going to need a custom kernel with the driver disabled in order
> to access it from userland.
> 
> For release users this either locks them out of using syspatch
> completely (if they do this by building -stable with custom config -
> syspatch won't run at all with -stable), or at least from using syspatch
> for kernel fixes (if using config -ef) - so it would be really nice to
> have a better way around this before adding more drivers taking over
> from existing device support.

I disagree.

This unbridled ugen/uhid/usb direct-access via libusb has got to stop.

"taking over existing device support" is backwards.  We don't expose
/dev/pci for X anymore, and we should not do it here either.




[1/3] ssh/readconf.c: Remove SSH1 options in example

2019-12-19 Thread Martin
Hey!

This diff removes unsupported SSH1 options from the format example
comment.

Best,

Martin

P.S.: This is the first of 3 diffs, I did them with git this time I hope they
are in the correct format.

diff --git readconf.c readconf.c
index 44464bed71e..eff2d5d1672 100644
--- readconf.c
+++ readconf.c
@@ -107,8 +107,6 @@
  ForwardAgent no
  ForwardX11 no
  PasswordAuthentication yes
- RSAAuthentication yes
- RhostsRSAAuthentication yes
  StrictHostKeyChecking yes
  TcpKeepAlive no
  IdentityFile ~/.ssh/identity



Re: attention please: host's IP stack behavior got changed slightly

2019-12-19 Thread Daniel Jakots
On Mon, 16 Dec 2019 14:13:50 +0100, Alexander Bluhm
 wrote:

> Daniel, is your sshd bound to a * or to a 127.0.0.1 socket?

According to fstat, it's *:22

> If it
> is a * socket, does it work to redirect to the IP address of the
> incoming interface?

Yes it does.

Cheers,
Daniel



"usually" is usually spelled "usually"

2019-12-19 Thread Bryan Stenson
Hi all -

Just a doc/typo patch (inlined):

Bryan Stenson

---

diff --git gnu/gcc/gcc/unwind.inc gnu/gcc/gcc/unwind.inc
index b533eb58873..d55f49cab79 100644
--- gnu/gcc/gcc/unwind.inc
+++ gnu/gcc/gcc/unwind.inc
@@ -107,7 +107,7 @@ _Unwind_RaiseException(struct _Unwind_Exception *exc)
  return _URC_END_OF_STACK;

   if (code != _URC_NO_REASON)
- /* Some error encountered.  Ususally the unwinder doesn't
+ /* Some error encountered.  Usually the unwinder doesn't
 diagnose these and merely crashes.  */
  return _URC_FATAL_PHASE1_ERROR;

diff --git gnu/usr.bin/gcc/gcc/unwind.inc gnu/usr.bin/gcc/gcc/unwind.inc
index 0938d501f5f..394073aa9e8 100644
--- gnu/usr.bin/gcc/gcc/unwind.inc
+++ gnu/usr.bin/gcc/gcc/unwind.inc
@@ -99,7 +99,7 @@ _Unwind_RaiseException(struct _Unwind_Exception *exc)
  return _URC_END_OF_STACK;

   if (code != _URC_NO_REASON)
- /* Some error encountered.  Ususally the unwinder doesn't
+ /* Some error encountered.  Usually the unwinder doesn't
 diagnose these and merely crashes.  */
  return _URC_FATAL_PHASE1_ERROR;

diff --git gnu/usr.bin/perl/Porting/Glossary gnu/usr.bin/perl/Porting/Glossary
index e9adc57685c..c44e5b76797 100644
--- gnu/usr.bin/perl/Porting/Glossary
+++ gnu/usr.bin/perl/Porting/Glossary
@@ -2098,7 +2098,7 @@ d_random_r (d_random_r.U):
 d_re_comp (d_regcmp.U):
  This variable conditionally defines the HAS_RECOMP symbol, which
  indicates to the C program that the re_comp() routine is available
- for regular patern matching (usally on BSD). If so, it is likely that
+ for regular patern matching (usually on BSD). If so, it is likely that
  re_exec() exists.

 d_readdir (d_readdir.U):
@@ -2131,12 +2131,12 @@ d_recvmsg (d_recvmsg.U):
 d_regcmp (d_regcmp.U):
  This variable conditionally defines the HAS_REGCMP symbol, which
  indicates to the C program that the regcmp() routine is available
- for regular patern matching (usally on System V).
+ for regular patern matching (usually on System V).

 d_regcomp (d_regcmp.U):
  This variable conditionally defines the HAS_REGCOMP symbol, which
  indicates to the C program that the regcomp() routine is available
- for regular patern matching (usally on POSIX.2 conforming systems).
+ for regular patern matching (usually on POSIX.2 conforming systems).

 d_remainder (d_remainder.U):
  This variable conditionally defines the HAS_REMAINDER symbol, which
diff --git lib/libssl/man/SSL_CTX_set_cipher_list.3
lib/libssl/man/SSL_CTX_set_cipher_list.3
index fa5d9809137..b2739840c28 100644
--- lib/libssl/man/SSL_CTX_set_cipher_list.3
+++ lib/libssl/man/SSL_CTX_set_cipher_list.3
@@ -137,7 +137,7 @@ It can only be used as the first word.
 .It Cm @STRENGTH
 Sort the list by decreasing encryption strength,
 preserving the order of cipher suites that have the same strength.
-It is usally given as the last word.
+It is usually given as the last word.
 .El
 .Pp
 The following words can be used to select groups of cipher suites,
diff --git regress/sbin/ifconfig/ifaddr.c regress/sbin/ifconfig/ifaddr.c
index 07cfbf6261b..e0aa471100c 100644
--- regress/sbin/ifconfig/ifaddr.c
+++ regress/sbin/ifconfig/ifaddr.c
@@ -3,7 +3,7 @@
 /*
  * This file has been copied from ifconfig and adapted to test
  * SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFDSTADDR, SIOCSIFBRDADDR
- * ioctls.  Ususally ifconfig uses SIOCAIFADDR and SIOCDIFADDR, but
+ * ioctls.  Usually ifconfig uses SIOCAIFADDR and SIOCDIFADDR, but
  * the old kernel interface has to be tested, too.
  */

diff --git sys/dev/isa/if_ie.c sys/dev/isa/if_ie.c
index 7f39c1d9877..47e37ed08d1 100644
--- sys/dev/isa/if_ie.c
+++ sys/dev/isa/if_ie.c
@@ -416,7 +416,7 @@ sl_probe(sc, ia)
  }

  /*
- * Divine memory size on-board the card.  Ususally 16k.
+ * Divine memory size on-board the card.  Usually 16k.
  */
  sc->sc_maddr = ISA_HOLE_VADDR(ia->ia_maddr);
  ie_find_mem_size(sc);



Re: [Patch]: Integrate VA-API into xenocara

2019-12-19 Thread Matthieu Herrb
On Wed, Dec 18, 2019 at 03:28:48PM -0600, Brad DeMorrow wrote:
> This is a rather large patch that moves my previously submitted
> VA-API ports into xenocara. For your convenience, I've inlined
> a diff that shows you all of the changes I made to existing files
> that you can easily read in your MUA.  The attached patch also
> contains these changes and should be the only xenocara patch
> you need to apply.
> 
> Summary of Changes:
>  - libva added to xenocara/lib/libva
>  - vainfo added to xenocara/app/vainfo
>  - intel-vaapi-driver added to xenocara/driver/intel-vaapi-driver
>  - Mesa Makefile.bsd-wrapper updated to build with --enable-va flag
>  - 3RDPARTY file updated to include libva, libva-utils, and intel-vaapi-driver
>  - BSD.x11.dist updated to include /usr/X11R6/include/va/ (separate patch)
> 
> Architectures Tested: amd64 
> 
> Testing Instructions:
> 1. save xenocara-vaapi.patch.gz to /tmp
> 2. cd /tmp; gunzip xenocara-vaapi.patch.gz
> 3. cd /usr/xenocara
> 4. patch -p0 < /tmp/xenocara-vaapi.patch
> 5. Follow normal build instructions in README within the root of xenocara
> 6. Run vainfo.  It should report available profiles and entrypoints for 
> VA-API.
>Example of successful execution:

Hi,

I won't be able to look at this before the 28th, being busy for work
and then away for vacation.

Thaks for this work.
-- 
Matthieu Herrb



typo fix for "patern"

2019-12-19 Thread Bryan Stenson
Another set of typos (inlined below).

Bryan Stenson

diff --git gnu/gcc/gcc/config/mips/mips.c gnu/gcc/gcc/config/mips/mips.c
index 1edd6b90e4b..1c9d8902428 100644
--- gnu/gcc/gcc/config/mips/mips.c
+++ gnu/gcc/gcc/config/mips/mips.c
@@ -8911,7 +8911,7 @@ vr4130_align_insns (void)
   if (length > 0)
  {
/* If the instruction is an asm statement or multi-instruction
-  mips.md patern, the length is only an estimate.  Insert an
+  mips.md pattern, the length is only an estimate.  Insert an
   8 byte alignment after it so that the following instructions
   can be handled correctly.  */
if (NONJUMP_INSN_P (SEQ_BEGIN (insn))
diff --git gnu/gcc/gcc/see.c gnu/gcc/gcc/see.c
index d20cdf4be28..705a2e7fdb1 100644
--- gnu/gcc/gcc/see.c
+++ gnu/gcc/gcc/see.c
@@ -1256,7 +1256,7 @@ see_update_leader_extra_info (struct web_entry
*first, struct web_entry *second)
  }
   break;
 default:
-  /* Unknown patern type.  */
+  /* Unknown pattern type.  */
   gcc_unreachable ();
 }

diff --git gnu/usr.bin/perl/Porting/Glossary gnu/usr.bin/perl/Porting/Glossary
index c44e5b76797..b476bbd7d37 100644
--- gnu/usr.bin/perl/Porting/Glossary
+++ gnu/usr.bin/perl/Porting/Glossary
@@ -2098,7 +2098,7 @@ d_random_r (d_random_r.U):
 d_re_comp (d_regcmp.U):
  This variable conditionally defines the HAS_RECOMP symbol, which
  indicates to the C program that the re_comp() routine is available
- for regular patern matching (usually on BSD). If so, it is likely that
+ for regular pattern matching (usually on BSD). If so, it is likely that
  re_exec() exists.

 d_readdir (d_readdir.U):
@@ -2131,12 +2131,12 @@ d_recvmsg (d_recvmsg.U):
 d_regcmp (d_regcmp.U):
  This variable conditionally defines the HAS_REGCMP symbol, which
  indicates to the C program that the regcmp() routine is available
- for regular patern matching (usually on System V).
+ for regular pattern matching (usually on System V).

 d_regcomp (d_regcmp.U):
  This variable conditionally defines the HAS_REGCOMP symbol, which
  indicates to the C program that the regcomp() routine is available
- for regular patern matching (usually on POSIX.2 conforming systems).
+ for regular pattern matching (usually on POSIX.2 conforming systems).

 d_remainder (d_remainder.U):
  This variable conditionally defines the HAS_REMAINDER symbol, which
diff --git gnu/usr.bin/perl/Porting/config_H gnu/usr.bin/perl/Porting/config_H
index 8092eac48f5..ad249f5d196 100644
--- gnu/usr.bin/perl/Porting/config_H
+++ gnu/usr.bin/perl/Porting/config_H
@@ -350,7 +350,7 @@

 /* HAS_REGCOMP:
  * This symbol, if defined, indicates that the regcomp() routine is
- * available to do some regular patern matching (usually on POSIX.2
+ * available to do some regular pattern matching (usually on POSIX.2
  * conforming systems).
  */
 #define HAS_REGCOMP /* POSIX.2 */
diff --git gnu/usr.bin/perl/config_h.SH gnu/usr.bin/perl/config_h.SH
index f275932e211..9775315f688 100644
--- gnu/usr.bin/perl/config_h.SH
+++ gnu/usr.bin/perl/config_h.SH
@@ -381,7 +381,7 @@ sed <$CONFIG_H -e
's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un

 /* HAS_REGCOMP:
  * This symbol, if defined, indicates that the regcomp() routine is
- * available to do some regular patern matching (usually on POSIX.2
+ * available to do some regular pattern matching (usually on POSIX.2
  * conforming systems).
  */
 #$d_regcomp HAS_REGCOMP /* POSIX.2 */
diff --git gnu/usr.bin/perl/uconfig.h gnu/usr.bin/perl/uconfig.h
index a43a3a1e0cf..396dc264759 100644
--- gnu/usr.bin/perl/uconfig.h
+++ gnu/usr.bin/perl/uconfig.h
@@ -346,7 +346,7 @@

 /* HAS_REGCOMP:
  * This symbol, if defined, indicates that the regcomp() routine is
- * available to do some regular patern matching (usually on POSIX.2
+ * available to do some regular pattern matching (usually on POSIX.2
  * conforming systems).
  */
 #define HAS_REGCOMP /* POSIX.2 */
diff --git gnu/usr.bin/perl/win32/config_H.gc gnu/usr.bin/perl/win32/config_H.gc
index 3af1a012b8a..405b00863b8 100644
--- gnu/usr.bin/perl/win32/config_H.gc
+++ gnu/usr.bin/perl/win32/config_H.gc
@@ -340,7 +340,7 @@

 /* HAS_REGCOMP:
  * This symbol, if defined, indicates that the regcomp() routine is
- * available to do some regular patern matching (usually on POSIX.2
+ * available to do some regular pattern matching (usually on POSIX.2
  * conforming systems).
  */
 /*#define HAS_REGCOMP / * POSIX.2 */
diff --git gnu/usr.bin/perl/win32/config_H.vc gnu/usr.bin/perl/win32/config_H.vc
index fa09da070ca..7d47eee25ab 100644
--- gnu/usr.bin/perl/win32/config_H.vc
+++ gnu/usr.bin/perl/win32/config_H.vc
@@ -340,7 +340,7 @@

 /* HAS_REGCOMP:
  * This symbol, if defined, indicates that the regcomp() routine is
- * available to do some regular patern matching (usually on POSIX.2
+ * available to do some regular pattern matching (usually on POSIX.2
  * conforming systems).
  */
 /*#define HAS_REGCOMP / * POSIX.2 */



Re: typo fix for "patern"

2019-12-19 Thread Theo de Raadt
We don't accept such changes to what we consider upstream software
incorporated into our tree, it just creates difficulty later.

Submit to the upstreams.


Bryan Stenson  wrote:

> Another set of typos (inlined below).
> 
> Bryan Stenson
> 
> diff --git gnu/gcc/gcc/config/mips/mips.c gnu/gcc/gcc/config/mips/mips.c
> index 1edd6b90e4b..1c9d8902428 100644
> --- gnu/gcc/gcc/config/mips/mips.c
> +++ gnu/gcc/gcc/config/mips/mips.c
> @@ -8911,7 +8911,7 @@ vr4130_align_insns (void)
>if (length > 0)
>   {
> /* If the instruction is an asm statement or multi-instruction
> -  mips.md patern, the length is only an estimate.  Insert an
> +  mips.md pattern, the length is only an estimate.  Insert an
>8 byte alignment after it so that the following instructions
>can be handled correctly.  */
> if (NONJUMP_INSN_P (SEQ_BEGIN (insn))
> diff --git gnu/gcc/gcc/see.c gnu/gcc/gcc/see.c
> index d20cdf4be28..705a2e7fdb1 100644
> --- gnu/gcc/gcc/see.c
> +++ gnu/gcc/gcc/see.c
> @@ -1256,7 +1256,7 @@ see_update_leader_extra_info (struct web_entry
> *first, struct web_entry *second)
>   }
>break;
>  default:
> -  /* Unknown patern type.  */
> +  /* Unknown pattern type.  */
>gcc_unreachable ();
>  }
> 
> diff --git gnu/usr.bin/perl/Porting/Glossary gnu/usr.bin/perl/Porting/Glossary
> index c44e5b76797..b476bbd7d37 100644
> --- gnu/usr.bin/perl/Porting/Glossary
> +++ gnu/usr.bin/perl/Porting/Glossary
> @@ -2098,7 +2098,7 @@ d_random_r (d_random_r.U):
>  d_re_comp (d_regcmp.U):
>   This variable conditionally defines the HAS_RECOMP symbol, which
>   indicates to the C program that the re_comp() routine is available
> - for regular patern matching (usually on BSD). If so, it is likely that
> + for regular pattern matching (usually on BSD). If so, it is likely that
>   re_exec() exists.
> 
>  d_readdir (d_readdir.U):
> @@ -2131,12 +2131,12 @@ d_recvmsg (d_recvmsg.U):
>  d_regcmp (d_regcmp.U):
>   This variable conditionally defines the HAS_REGCMP symbol, which
>   indicates to the C program that the regcmp() routine is available
> - for regular patern matching (usually on System V).
> + for regular pattern matching (usually on System V).
> 
>  d_regcomp (d_regcmp.U):
>   This variable conditionally defines the HAS_REGCOMP symbol, which
>   indicates to the C program that the regcomp() routine is available
> - for regular patern matching (usually on POSIX.2 conforming systems).
> + for regular pattern matching (usually on POSIX.2 conforming systems).
> 
>  d_remainder (d_remainder.U):
>   This variable conditionally defines the HAS_REMAINDER symbol, which
> diff --git gnu/usr.bin/perl/Porting/config_H gnu/usr.bin/perl/Porting/config_H
> index 8092eac48f5..ad249f5d196 100644
> --- gnu/usr.bin/perl/Porting/config_H
> +++ gnu/usr.bin/perl/Porting/config_H
> @@ -350,7 +350,7 @@
> 
>  /* HAS_REGCOMP:
>   * This symbol, if defined, indicates that the regcomp() routine is
> - * available to do some regular patern matching (usually on POSIX.2
> + * available to do some regular pattern matching (usually on POSIX.2
>   * conforming systems).
>   */
>  #define HAS_REGCOMP /* POSIX.2 */
> diff --git gnu/usr.bin/perl/config_h.SH gnu/usr.bin/perl/config_h.SH
> index f275932e211..9775315f688 100644
> --- gnu/usr.bin/perl/config_h.SH
> +++ gnu/usr.bin/perl/config_h.SH
> @@ -381,7 +381,7 @@ sed <$CONFIG_H -e
> 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un
> 
>  /* HAS_REGCOMP:
>   * This symbol, if defined, indicates that the regcomp() routine is
> - * available to do some regular patern matching (usually on POSIX.2
> + * available to do some regular pattern matching (usually on POSIX.2
>   * conforming systems).
>   */
>  #$d_regcomp HAS_REGCOMP /* POSIX.2 */
> diff --git gnu/usr.bin/perl/uconfig.h gnu/usr.bin/perl/uconfig.h
> index a43a3a1e0cf..396dc264759 100644
> --- gnu/usr.bin/perl/uconfig.h
> +++ gnu/usr.bin/perl/uconfig.h
> @@ -346,7 +346,7 @@
> 
>  /* HAS_REGCOMP:
>   * This symbol, if defined, indicates that the regcomp() routine is
> - * available to do some regular patern matching (usually on POSIX.2
> + * available to do some regular pattern matching (usually on POSIX.2
>   * conforming systems).
>   */
>  #define HAS_REGCOMP /* POSIX.2 */
> diff --git gnu/usr.bin/perl/win32/config_H.gc 
> gnu/usr.bin/perl/win32/config_H.gc
> index 3af1a012b8a..405b00863b8 100644
> --- gnu/usr.bin/perl/win32/config_H.gc
> +++ gnu/usr.bin/perl/win32/config_H.gc
> @@ -340,7 +340,7 @@
> 
>  /* HAS_REGCOMP:
>   * This symbol, if defined, indicates that the regcomp() routine is
> - * available to do some regular patern matching (usually on POSIX.2
> + * available to do some regular pattern matching (usually on POSIX.2
>   * conforming systems).
>   */
>  /*#define HAS_REGCOMP / * POSIX.2 */
> diff --git gnu/usr.bin/perl/win32/config_H.vc 
> gnu/usr.bin/perl/win32/config_H.vc
> index fa09da070ca..7d47eee25ab 100644
> --- gnu/usr.bin/perl/win32/config_H.vc
> +++ gnu/usr.bin/perl/win32/conf

Re: typo fix for "patern"

2019-12-19 Thread Bryan Stenson
oh, my apologies.  sorry for the noise.  thanks.

On Thu, Dec 19, 2019 at 12:16 PM Theo de Raadt  wrote:
>
> We don't accept such changes to what we consider upstream software
> incorporated into our tree, it just creates difficulty later.
>
> Submit to the upstreams.
>
>
> Bryan Stenson  wrote:
>
> > Another set of typos (inlined below).
> >
> > Bryan Stenson
> >
> > diff --git gnu/gcc/gcc/config/mips/mips.c gnu/gcc/gcc/config/mips/mips.c
> > index 1edd6b90e4b..1c9d8902428 100644
> > --- gnu/gcc/gcc/config/mips/mips.c
> > +++ gnu/gcc/gcc/config/mips/mips.c
> > @@ -8911,7 +8911,7 @@ vr4130_align_insns (void)
> >if (length > 0)
> >   {
> > /* If the instruction is an asm statement or multi-instruction
> > -  mips.md patern, the length is only an estimate.  Insert an
> > +  mips.md pattern, the length is only an estimate.  Insert an
> >8 byte alignment after it so that the following instructions
> >can be handled correctly.  */
> > if (NONJUMP_INSN_P (SEQ_BEGIN (insn))
> > diff --git gnu/gcc/gcc/see.c gnu/gcc/gcc/see.c
> > index d20cdf4be28..705a2e7fdb1 100644
> > --- gnu/gcc/gcc/see.c
> > +++ gnu/gcc/gcc/see.c
> > @@ -1256,7 +1256,7 @@ see_update_leader_extra_info (struct web_entry
> > *first, struct web_entry *second)
> >   }
> >break;
> >  default:
> > -  /* Unknown patern type.  */
> > +  /* Unknown pattern type.  */
> >gcc_unreachable ();
> >  }
> >
> > diff --git gnu/usr.bin/perl/Porting/Glossary 
> > gnu/usr.bin/perl/Porting/Glossary
> > index c44e5b76797..b476bbd7d37 100644
> > --- gnu/usr.bin/perl/Porting/Glossary
> > +++ gnu/usr.bin/perl/Porting/Glossary
> > @@ -2098,7 +2098,7 @@ d_random_r (d_random_r.U):
> >  d_re_comp (d_regcmp.U):
> >   This variable conditionally defines the HAS_RECOMP symbol, which
> >   indicates to the C program that the re_comp() routine is available
> > - for regular patern matching (usually on BSD). If so, it is likely that
> > + for regular pattern matching (usually on BSD). If so, it is likely that
> >   re_exec() exists.
> >
> >  d_readdir (d_readdir.U):
> > @@ -2131,12 +2131,12 @@ d_recvmsg (d_recvmsg.U):
> >  d_regcmp (d_regcmp.U):
> >   This variable conditionally defines the HAS_REGCMP symbol, which
> >   indicates to the C program that the regcmp() routine is available
> > - for regular patern matching (usually on System V).
> > + for regular pattern matching (usually on System V).
> >
> >  d_regcomp (d_regcmp.U):
> >   This variable conditionally defines the HAS_REGCOMP symbol, which
> >   indicates to the C program that the regcomp() routine is available
> > - for regular patern matching (usually on POSIX.2 conforming systems).
> > + for regular pattern matching (usually on POSIX.2 conforming systems).
> >
> >  d_remainder (d_remainder.U):
> >   This variable conditionally defines the HAS_REMAINDER symbol, which
> > diff --git gnu/usr.bin/perl/Porting/config_H 
> > gnu/usr.bin/perl/Porting/config_H
> > index 8092eac48f5..ad249f5d196 100644
> > --- gnu/usr.bin/perl/Porting/config_H
> > +++ gnu/usr.bin/perl/Porting/config_H
> > @@ -350,7 +350,7 @@
> >
> >  /* HAS_REGCOMP:
> >   * This symbol, if defined, indicates that the regcomp() routine is
> > - * available to do some regular patern matching (usually on POSIX.2
> > + * available to do some regular pattern matching (usually on POSIX.2
> >   * conforming systems).
> >   */
> >  #define HAS_REGCOMP /* POSIX.2 */
> > diff --git gnu/usr.bin/perl/config_h.SH gnu/usr.bin/perl/config_h.SH
> > index f275932e211..9775315f688 100644
> > --- gnu/usr.bin/perl/config_h.SH
> > +++ gnu/usr.bin/perl/config_h.SH
> > @@ -381,7 +381,7 @@ sed <$CONFIG_H -e
> > 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un
> >
> >  /* HAS_REGCOMP:
> >   * This symbol, if defined, indicates that the regcomp() routine is
> > - * available to do some regular patern matching (usually on POSIX.2
> > + * available to do some regular pattern matching (usually on POSIX.2
> >   * conforming systems).
> >   */
> >  #$d_regcomp HAS_REGCOMP /* POSIX.2 */
> > diff --git gnu/usr.bin/perl/uconfig.h gnu/usr.bin/perl/uconfig.h
> > index a43a3a1e0cf..396dc264759 100644
> > --- gnu/usr.bin/perl/uconfig.h
> > +++ gnu/usr.bin/perl/uconfig.h
> > @@ -346,7 +346,7 @@
> >
> >  /* HAS_REGCOMP:
> >   * This symbol, if defined, indicates that the regcomp() routine is
> > - * available to do some regular patern matching (usually on POSIX.2
> > + * available to do some regular pattern matching (usually on POSIX.2
> >   * conforming systems).
> >   */
> >  #define HAS_REGCOMP /* POSIX.2 */
> > diff --git gnu/usr.bin/perl/win32/config_H.gc 
> > gnu/usr.bin/perl/win32/config_H.gc
> > index 3af1a012b8a..405b00863b8 100644
> > --- gnu/usr.bin/perl/win32/config_H.gc
> > +++ gnu/usr.bin/perl/win32/config_H.gc
> > @@ -340,7 +340,7 @@
> >
> >  /* HAS_REGCOMP:
> >   * This symbol, if defined, indicates that the regcomp() routine is
> > - * available to do some regular patern matching (usually on POSIX.2
> > + * a

Re: "usually" is usually spelled "usually"

2019-12-19 Thread Jason McIntyre
On Thu, Dec 19, 2019 at 11:59:20AM -0800, Bryan Stenson wrote:
> Hi all -
> 
> Just a doc/typo patch (inlined):
> 
> Bryan Stenson
> 
> ---

as theo noted, 3rd party fixes like this should go upstream (generally
stuff in /usr/src/gnu). i committed the last three fixes though.

jmc

> 
> diff --git gnu/gcc/gcc/unwind.inc gnu/gcc/gcc/unwind.inc
> index b533eb58873..d55f49cab79 100644
> --- gnu/gcc/gcc/unwind.inc
> +++ gnu/gcc/gcc/unwind.inc
> @@ -107,7 +107,7 @@ _Unwind_RaiseException(struct _Unwind_Exception *exc)
>   return _URC_END_OF_STACK;
> 
>if (code != _URC_NO_REASON)
> - /* Some error encountered.  Ususally the unwinder doesn't
> + /* Some error encountered.  Usually the unwinder doesn't
>  diagnose these and merely crashes.  */
>   return _URC_FATAL_PHASE1_ERROR;
> 
> diff --git gnu/usr.bin/gcc/gcc/unwind.inc gnu/usr.bin/gcc/gcc/unwind.inc
> index 0938d501f5f..394073aa9e8 100644
> --- gnu/usr.bin/gcc/gcc/unwind.inc
> +++ gnu/usr.bin/gcc/gcc/unwind.inc
> @@ -99,7 +99,7 @@ _Unwind_RaiseException(struct _Unwind_Exception *exc)
>   return _URC_END_OF_STACK;
> 
>if (code != _URC_NO_REASON)
> - /* Some error encountered.  Ususally the unwinder doesn't
> + /* Some error encountered.  Usually the unwinder doesn't
>  diagnose these and merely crashes.  */
>   return _URC_FATAL_PHASE1_ERROR;
> 
> diff --git gnu/usr.bin/perl/Porting/Glossary gnu/usr.bin/perl/Porting/Glossary
> index e9adc57685c..c44e5b76797 100644
> --- gnu/usr.bin/perl/Porting/Glossary
> +++ gnu/usr.bin/perl/Porting/Glossary
> @@ -2098,7 +2098,7 @@ d_random_r (d_random_r.U):
>  d_re_comp (d_regcmp.U):
>   This variable conditionally defines the HAS_RECOMP symbol, which
>   indicates to the C program that the re_comp() routine is available
> - for regular patern matching (usally on BSD). If so, it is likely that
> + for regular patern matching (usually on BSD). If so, it is likely that
>   re_exec() exists.
> 
>  d_readdir (d_readdir.U):
> @@ -2131,12 +2131,12 @@ d_recvmsg (d_recvmsg.U):
>  d_regcmp (d_regcmp.U):
>   This variable conditionally defines the HAS_REGCMP symbol, which
>   indicates to the C program that the regcmp() routine is available
> - for regular patern matching (usally on System V).
> + for regular patern matching (usually on System V).
> 
>  d_regcomp (d_regcmp.U):
>   This variable conditionally defines the HAS_REGCOMP symbol, which
>   indicates to the C program that the regcomp() routine is available
> - for regular patern matching (usally on POSIX.2 conforming systems).
> + for regular patern matching (usually on POSIX.2 conforming systems).
> 
>  d_remainder (d_remainder.U):
>   This variable conditionally defines the HAS_REMAINDER symbol, which
> diff --git lib/libssl/man/SSL_CTX_set_cipher_list.3
> lib/libssl/man/SSL_CTX_set_cipher_list.3
> index fa5d9809137..b2739840c28 100644
> --- lib/libssl/man/SSL_CTX_set_cipher_list.3
> +++ lib/libssl/man/SSL_CTX_set_cipher_list.3
> @@ -137,7 +137,7 @@ It can only be used as the first word.
>  .It Cm @STRENGTH
>  Sort the list by decreasing encryption strength,
>  preserving the order of cipher suites that have the same strength.
> -It is usally given as the last word.
> +It is usually given as the last word.
>  .El
>  .Pp
>  The following words can be used to select groups of cipher suites,
> diff --git regress/sbin/ifconfig/ifaddr.c regress/sbin/ifconfig/ifaddr.c
> index 07cfbf6261b..e0aa471100c 100644
> --- regress/sbin/ifconfig/ifaddr.c
> +++ regress/sbin/ifconfig/ifaddr.c
> @@ -3,7 +3,7 @@
>  /*
>   * This file has been copied from ifconfig and adapted to test
>   * SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFDSTADDR, SIOCSIFBRDADDR
> - * ioctls.  Ususally ifconfig uses SIOCAIFADDR and SIOCDIFADDR, but
> + * ioctls.  Usually ifconfig uses SIOCAIFADDR and SIOCDIFADDR, but
>   * the old kernel interface has to be tested, too.
>   */
> 
> diff --git sys/dev/isa/if_ie.c sys/dev/isa/if_ie.c
> index 7f39c1d9877..47e37ed08d1 100644
> --- sys/dev/isa/if_ie.c
> +++ sys/dev/isa/if_ie.c
> @@ -416,7 +416,7 @@ sl_probe(sc, ia)
>   }
> 
>   /*
> - * Divine memory size on-board the card.  Ususally 16k.
> + * Divine memory size on-board the card.  Usually 16k.
>   */
>   sc->sc_maddr = ISA_HOLE_VADDR(ia->ia_maddr);
>   ie_find_mem_size(sc);
> 



Re: "usually" is usually spelled "usually"

2019-12-19 Thread Bryan Stenson
thanks.  i'll work upstream to fix my OCD. :)

On Thu, Dec 19, 2019 at 12:27 PM Jason McIntyre  wrote:
>
> On Thu, Dec 19, 2019 at 11:59:20AM -0800, Bryan Stenson wrote:
> > Hi all -
> >
> > Just a doc/typo patch (inlined):
> >
> > Bryan Stenson
> >
> > ---
>
> as theo noted, 3rd party fixes like this should go upstream (generally
> stuff in /usr/src/gnu). i committed the last three fixes though.
>
> jmc
>
> >
> > diff --git gnu/gcc/gcc/unwind.inc gnu/gcc/gcc/unwind.inc
> > index b533eb58873..d55f49cab79 100644
> > --- gnu/gcc/gcc/unwind.inc
> > +++ gnu/gcc/gcc/unwind.inc
> > @@ -107,7 +107,7 @@ _Unwind_RaiseException(struct _Unwind_Exception *exc)
> >   return _URC_END_OF_STACK;
> >
> >if (code != _URC_NO_REASON)
> > - /* Some error encountered.  Ususally the unwinder doesn't
> > + /* Some error encountered.  Usually the unwinder doesn't
> >  diagnose these and merely crashes.  */
> >   return _URC_FATAL_PHASE1_ERROR;
> >
> > diff --git gnu/usr.bin/gcc/gcc/unwind.inc gnu/usr.bin/gcc/gcc/unwind.inc
> > index 0938d501f5f..394073aa9e8 100644
> > --- gnu/usr.bin/gcc/gcc/unwind.inc
> > +++ gnu/usr.bin/gcc/gcc/unwind.inc
> > @@ -99,7 +99,7 @@ _Unwind_RaiseException(struct _Unwind_Exception *exc)
> >   return _URC_END_OF_STACK;
> >
> >if (code != _URC_NO_REASON)
> > - /* Some error encountered.  Ususally the unwinder doesn't
> > + /* Some error encountered.  Usually the unwinder doesn't
> >  diagnose these and merely crashes.  */
> >   return _URC_FATAL_PHASE1_ERROR;
> >
> > diff --git gnu/usr.bin/perl/Porting/Glossary 
> > gnu/usr.bin/perl/Porting/Glossary
> > index e9adc57685c..c44e5b76797 100644
> > --- gnu/usr.bin/perl/Porting/Glossary
> > +++ gnu/usr.bin/perl/Porting/Glossary
> > @@ -2098,7 +2098,7 @@ d_random_r (d_random_r.U):
> >  d_re_comp (d_regcmp.U):
> >   This variable conditionally defines the HAS_RECOMP symbol, which
> >   indicates to the C program that the re_comp() routine is available
> > - for regular patern matching (usally on BSD). If so, it is likely that
> > + for regular patern matching (usually on BSD). If so, it is likely that
> >   re_exec() exists.
> >
> >  d_readdir (d_readdir.U):
> > @@ -2131,12 +2131,12 @@ d_recvmsg (d_recvmsg.U):
> >  d_regcmp (d_regcmp.U):
> >   This variable conditionally defines the HAS_REGCMP symbol, which
> >   indicates to the C program that the regcmp() routine is available
> > - for regular patern matching (usally on System V).
> > + for regular patern matching (usually on System V).
> >
> >  d_regcomp (d_regcmp.U):
> >   This variable conditionally defines the HAS_REGCOMP symbol, which
> >   indicates to the C program that the regcomp() routine is available
> > - for regular patern matching (usally on POSIX.2 conforming systems).
> > + for regular patern matching (usually on POSIX.2 conforming systems).
> >
> >  d_remainder (d_remainder.U):
> >   This variable conditionally defines the HAS_REMAINDER symbol, which
> > diff --git lib/libssl/man/SSL_CTX_set_cipher_list.3
> > lib/libssl/man/SSL_CTX_set_cipher_list.3
> > index fa5d9809137..b2739840c28 100644
> > --- lib/libssl/man/SSL_CTX_set_cipher_list.3
> > +++ lib/libssl/man/SSL_CTX_set_cipher_list.3
> > @@ -137,7 +137,7 @@ It can only be used as the first word.
> >  .It Cm @STRENGTH
> >  Sort the list by decreasing encryption strength,
> >  preserving the order of cipher suites that have the same strength.
> > -It is usally given as the last word.
> > +It is usually given as the last word.
> >  .El
> >  .Pp
> >  The following words can be used to select groups of cipher suites,
> > diff --git regress/sbin/ifconfig/ifaddr.c regress/sbin/ifconfig/ifaddr.c
> > index 07cfbf6261b..e0aa471100c 100644
> > --- regress/sbin/ifconfig/ifaddr.c
> > +++ regress/sbin/ifconfig/ifaddr.c
> > @@ -3,7 +3,7 @@
> >  /*
> >   * This file has been copied from ifconfig and adapted to test
> >   * SIOCSIFADDR, SIOCSIFNETMASK, SIOCSIFDSTADDR, SIOCSIFBRDADDR
> > - * ioctls.  Ususally ifconfig uses SIOCAIFADDR and SIOCDIFADDR, but
> > + * ioctls.  Usually ifconfig uses SIOCAIFADDR and SIOCDIFADDR, but
> >   * the old kernel interface has to be tested, too.
> >   */
> >
> > diff --git sys/dev/isa/if_ie.c sys/dev/isa/if_ie.c
> > index 7f39c1d9877..47e37ed08d1 100644
> > --- sys/dev/isa/if_ie.c
> > +++ sys/dev/isa/if_ie.c
> > @@ -416,7 +416,7 @@ sl_probe(sc, ia)
> >   }
> >
> >   /*
> > - * Divine memory size on-board the card.  Ususally 16k.
> > + * Divine memory size on-board the card.  Usually 16k.
> >   */
> >   sc->sc_maddr = ISA_HOLE_VADDR(ia->ia_maddr);
> >   ie_find_mem_size(sc);
> >
>



Clarify drand48() return values

2019-12-19 Thread j


Clarify that drand48 returns values not including 1.0.

Index: src/lib/libc/stdlib/rand48.3
===
RCS file: /cvs/src/lib/libc/stdlib/rand48.3,v
retrieving revision 1.20
diff -u -r1.20 rand48.3
--- src/lib/libc/stdlib/rand48.310 Nov 2015 23:48:18 -  1.20
+++ src/lib/libc/stdlib/rand48.320 Dec 2019 00:08:24 -
@@ -101,7 +101,8 @@
 return values of type double.
 The full 48 bits of r(n+1) are
 loaded into the mantissa of the returned value, with the exponent set
-such that the values produced lie in the interval [0.0, 1.0].
+such that the values produced lie in the interval (0.0, 1.0] (which
+excludes 1.0 and includes 0.0).
 .Pp
 .Fn lrand48
 and



Re: Clarify drand48() return values

2019-12-19 Thread Joerg Sonnenberger
On Thu, Dec 19, 2019 at 04:19:36PM -0800, j...@bitminer.ca wrote:
> 
> Clarify that drand48 returns values not including 1.0.
> 
> Index: src/lib/libc/stdlib/rand48.3
> ===
> RCS file: /cvs/src/lib/libc/stdlib/rand48.3,v
> retrieving revision 1.20
> diff -u -r1.20 rand48.3
> --- src/lib/libc/stdlib/rand48.3  10 Nov 2015 23:48:18 -  1.20
> +++ src/lib/libc/stdlib/rand48.3  20 Dec 2019 00:08:24 -
> @@ -101,7 +101,8 @@
>  return values of type double.
>  The full 48 bits of r(n+1) are
>  loaded into the mantissa of the returned value, with the exponent set
> -such that the values produced lie in the interval [0.0, 1.0].
> +such that the values produced lie in the interval (0.0, 1.0] (which
> +excludes 1.0 and includes 0.0).
>  .Pp
>  .Fn lrand48
>  and

...except that your patch says the reverse.

Joerg



amd64 SMEP SMAP trap panic print

2019-12-19 Thread Alexander Bluhm
Hi,

Can we use the regular trap panic for SMEP and SMAP?  pageflttrap()
returns 0 to print a nice reason in kerntrap().  Especially if ddb
is disabled, additional information is printed.

attempt to access user address 0xe27539f1000 in supervisor mode
fatal page fault in supervisor mode
trap type 6 code 3 rip 819c2665 cs 8 rflags 10202 cr2 e27539f1000 cpl 0 
rsp 80001ffbfe28
gsbase 0x80001fb63ff0  kgsbase 0x0
panic: trap type 6, code=3, pc=819c2665

While there, prevent a double space in output.

If the kernel calls a NULL function, ddb tries to disassmble at 0
after SMEP.  Don't do that to prevent a fault in ddb.

ok?

bluhm

Index: arch/amd64/amd64/trap.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/arch/amd64/amd64/trap.c,v
retrieving revision 1.77
diff -u -p -r1.77 trap.c
--- arch/amd64/amd64/trap.c 6 Sep 2019 12:22:01 -   1.77
+++ arch/amd64/amd64/trap.c 19 Dec 2019 23:46:40 -
@@ -163,14 +163,18 @@ pageflttrap(struct trapframe *frame, int
extern struct vm_map *kernel_map;

/* This will only trigger if SMEP is enabled */
-   if (cr2 <= VM_MAXUSER_ADDRESS && frame->tf_err & PGEX_I)
-   panic("attempt to execute user address %p "
-   "in supervisor mode", (void *)cr2);
+   if (cr2 <= VM_MAXUSER_ADDRESS && frame->tf_err & PGEX_I) {
+   printf("attempt to execute user address %p "
+   "in supervisor mode\n", (void *)cr2);
+   return 0;
+   }
/* This will only trigger if SMAP is enabled */
if (pcb->pcb_onfault == NULL && cr2 <= VM_MAXUSER_ADDRESS &&
-   frame->tf_err & PGEX_P)
-   panic("attempt to access user address %p "
-   "in supervisor mode", (void *)cr2);
+   frame->tf_err & PGEX_P) {
+   printf("attempt to access user address %p "
+   "in supervisor mode\n", (void *)cr2);
+   return 0;
+   }

/*
 * It is only a kernel address space fault iff:
@@ -395,7 +399,7 @@ trap_print(struct trapframe *frame, int
printf(" in %s mode\n", KERNELMODE(frame->tf_cs, frame->tf_rflags) ?
"supervisor" : "user");
printf("trap type %d code %llx rip %llx cs %llx rflags %llx cr2 "
-  " %llx cpl %x rsp %llx\n",
+  "%llx cpl %x rsp %llx\n",
type, frame->tf_err, frame->tf_rip, frame->tf_cs,
frame->tf_rflags, rcr2(), curcpu()->ci_ilevel, frame->tf_rsp);
printf("gsbase %p  kgsbase %p\n",
Index: ddb/db_examine.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/ddb/db_examine.c,v
retrieving revision 1.26
diff -u -p -r1.26 db_examine.c
--- ddb/db_examine.c7 Nov 2019 13:16:25 -   1.26
+++ ddb/db_examine.c20 Dec 2019 00:38:11 -
@@ -288,8 +288,10 @@ void
 db_print_loc_and_inst(vaddr_t loc)
 {
db_printsym(loc, DB_STGY_PROC, db_printf);
-   db_printf(":\t");
-   (void) db_disasm(loc, 0);
+   if (loc) {
+   db_printf(":\t");
+   db_disasm(loc, 0);
+   }
 }

 /* local copy is needed here so that we can trace strlcpy() in libkern */



Re: amd64 SMEP SMAP trap panic print

2019-12-19 Thread Philip Guenther
On Fri, 20 Dec 2019, Alexander Bluhm wrote:
> Can we use the regular trap panic for SMEP and SMAP?  pageflttrap() 
> returns 0 to print a nice reason in kerntrap().  Especially if ddb is 
> disabled, additional information is printed.
> 
> attempt to access user address 0xe27539f1000 in supervisor mode
> fatal page fault in supervisor mode
> trap type 6 code 3 rip 819c2665 cs 8 rflags 10202 cr2 e27539f1000 cpl 
> 0 rsp 80001ffbfe28
> gsbase 0x80001fb63ff0  kgsbase 0x0
> panic: trap type 6, code=3, pc=819c2665
...
> Index: arch/amd64/amd64/trap.c
> ===
> RCS file: /data/mirror/openbsd/cvs/src/sys/arch/amd64/amd64/trap.c,v
> retrieving revision 1.77
> diff -u -p -r1.77 trap.c
> --- arch/amd64/amd64/trap.c   6 Sep 2019 12:22:01 -   1.77
> +++ arch/amd64/amd64/trap.c   19 Dec 2019 23:46:40 -
> @@ -163,14 +163,18 @@ pageflttrap(struct trapframe *frame, int
>   extern struct vm_map *kernel_map;
> 
>   /* This will only trigger if SMEP is enabled */
> - if (cr2 <= VM_MAXUSER_ADDRESS && frame->tf_err & PGEX_I)
> - panic("attempt to execute user address %p "
> - "in supervisor mode", (void *)cr2);
> + if (cr2 <= VM_MAXUSER_ADDRESS && frame->tf_err & PGEX_I) {
> + printf("attempt to execute user address %p "
> + "in supervisor mode\n", (void *)cr2);
> + return 0;
> + }
>   /* This will only trigger if SMAP is enabled */
>   if (pcb->pcb_onfault == NULL && cr2 <= VM_MAXUSER_ADDRESS &&
> - frame->tf_err & PGEX_P)
> - panic("attempt to access user address %p "
> - "in supervisor mode", (void *)cr2);
> + frame->tf_err & PGEX_P) {
> + printf("attempt to access user address %p "
> + "in supervisor mode\n", (void *)cr2);
> + return 0;
> + }
> 
>   /*
>* It is only a kernel address space fault iff:

For this part, should we reuse the 'faultstr' logic seen later to set the 
panic string and do something like, say...

Index: amd64/trap.c
===
RCS file: /data/src/openbsd/src/sys/arch/amd64/amd64/trap.c,v
retrieving revision 1.77
diff -u -p -r1.77 trap.c
--- amd64/trap.c6 Sep 2019 12:22:01 -   1.77
+++ amd64/trap.c20 Dec 2019 02:21:03 -
@@ -77,6 +77,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -132,6 +133,24 @@ static inline void verify_smap(const cha
 static inline void debug_trap(struct trapframe *_frame, struct proc *_p,
 long _type);
 
+static inline int
+fault(const char *format, ...)
+{
+   static char faultbuf[512];
+   va_list ap;
+
+   /*
+* Save the fault info for DDB and retain the kernel lock to keep
+* faultbuf from being overwritten by another CPU.
+*/
+   va_start(ap, format);
+   vsnprintf(faultbuf, sizeof faultbuf, format, ap);
+   va_end(ap);
+   printf("%s\n", faultbuf);
+   faultstr = faultbuf;
+   return 0;
+}
+
 /*
  * pageflttrap(frame, usermode): page fault handler
  * Returns non-zero if the fault was handled (possibly by generating
@@ -164,12 +183,12 @@ pageflttrap(struct trapframe *frame, int
 
/* This will only trigger if SMEP is enabled */
if (cr2 <= VM_MAXUSER_ADDRESS && frame->tf_err & PGEX_I)
-   panic("attempt to execute user address %p "
+   return fault("attempt to execute user address %p "
"in supervisor mode", (void *)cr2);
/* This will only trigger if SMAP is enabled */
if (pcb->pcb_onfault == NULL && cr2 <= VM_MAXUSER_ADDRESS &&
frame->tf_err & PGEX_P)
-   panic("attempt to access user address %p "
+   return fault("attempt to access user address %p "
"in supervisor mode", (void *)cr2);
 
/*
@@ -211,18 +230,9 @@ pageflttrap(struct trapframe *frame, int
frame->tf_rip = (u_int64_t)pcb->pcb_onfault;
return 1;
} else {
-   /*
-* Bad memory access in the kernel; save the fault
-* info for DDB and retain the kernel lock to keep
-* faultbuf from being overwritten by another CPU.
-*/
-   static char faultbuf[512];
-   snprintf(faultbuf, sizeof faultbuf,
-   "uvm_fault(%p, 0x%llx, 0, %d) -> %x",
+   /* bad memory access in the kernel */
+   return faul

Re: fix mcount.po target in libc/gmon/Makefile.inc

2019-12-19 Thread Philip Guenther
On Thu, 19 Dec 2019, Theo Buehler wrote:
> According to the comment in lib/libc/gmon/Makefile.inc, mcount needs
> special treatment since it cannot be compiled with profiling or pie.
> 
> When depend was removed as an independent target, this special case was
> missed.  Align it with the inference rules in bsd.lib.mk. This also
> makes 'make clean' work correctly (it currently leaves mcount.po.d
> behind).

ok guenther@



Re: Clarify drand48() return values

2019-12-19 Thread Theo de Raadt
j...@bitminer.ca wrote:

> Clarify that drand48 returns values not including 1.0.
> 
> Index: src/lib/libc/stdlib/rand48.3
> ===
> RCS file: /cvs/src/lib/libc/stdlib/rand48.3,v
> retrieving revision 1.20
> diff -u -r1.20 rand48.3
> --- src/lib/libc/stdlib/rand48.3  10 Nov 2015 23:48:18 -  1.20
> +++ src/lib/libc/stdlib/rand48.3  20 Dec 2019 00:08:24 -
> @@ -101,7 +101,8 @@
>  return values of type double.
>  The full 48 bits of r(n+1) are
>  loaded into the mantissa of the returned value, with the exponent set
> -such that the values produced lie in the interval [0.0, 1.0].
> +such that the values produced lie in the interval (0.0, 1.0] (which
> +excludes 1.0 and includes 0.0).
>  .Pp
>  .Fn lrand48
>  and

It's a mathematical notation that anyone using this page should
understand because it comes with the territory.  Once you are touching
doubles, soon you'll be looking at functions in libm proper, where this
type of notation is even more common.  Will you then propose to change
all those as well?

I think understanding the landscape's notation is a requirement, and we
don't need to say things a 2nd time in baby talk.



Re: Clarify drand48() return values

2019-12-19 Thread Andras Farkas
On Thu, Dec 19, 2019 at 10:05 PM Theo de Raadt  wrote:
> It's a mathematical notation that anyone using this page should
> understand because it comes with the territory.
> [snip]
>
> I think understanding the landscape's notation is a requirement, and we
> don't need to say things a 2nd time in baby talk.
I agree it doesn't need to be repeated, but I think there's value in
explicitly showing whether an interval is open or closed.
Though, in this case, the interval would be correctly expressed as
[0.0, 1.0)
or
[0.0, 1.0[
rather than how j's diff does it.

I attached a diff which I feel concisely does this.  I elected to not
change the latter two of the three intervals in the man page, since
they already included -1 in their upper bound.  But I also have that
as an option, via largediff.txt
Index: rand48.3
===
RCS file: /cvs/src/lib/libc/stdlib/rand48.3,v
retrieving revision 1.20
diff -u -p -r1.20 rand48.3
--- rand48.310 Nov 2015 23:48:18 -  1.20
+++ rand48.320 Dec 2019 03:43:34 -
@@ -101,7 +101,7 @@ and
 return values of type double.
 The full 48 bits of r(n+1) are
 loaded into the mantissa of the returned value, with the exponent set
-such that the values produced lie in the interval [0.0, 1.0].
+such that the values produced lie in the interval [0.0, 1.0).
 .Pp
 .Fn lrand48
 and
Index: rand48.3
===
RCS file: /cvs/src/lib/libc/stdlib/rand48.3,v
retrieving revision 1.20
diff -u -p -r1.20 rand48.3
--- rand48.310 Nov 2015 23:48:18 -  1.20
+++ rand48.320 Dec 2019 03:46:09 -
@@ -101,13 +101,13 @@ and
 return values of type double.
 The full 48 bits of r(n+1) are
 loaded into the mantissa of the returned value, with the exponent set
-such that the values produced lie in the interval [0.0, 1.0].
+such that the values produced lie in the interval [0.0, 1.0).
 .Pp
 .Fn lrand48
 and
 .Fn nrand48
 return values of type long in the range
-[0, 2**31-1].
+[0, 2**31).
 The high-order (31) bits of
 r(n+1) are loaded into the lower bits of the returned value, with
 the topmost (sign) bit set to zero.
@@ -116,7 +116,7 @@ the topmost (sign) bit set to zero.
 and
 .Fn jrand48
 return values of type long in the range
-[-2**31, 2**31-1].
+[-2**31, 2**31).
 The high-order (32) bits of r(n+1) are loaded into the returned value.
 .Pp
 In the deterministic mode, the


Re: Clarify drand48() return values

2019-12-19 Thread Andras Farkas
Not to appeal to majority, but to compare and contrast...
FreeBSD, NetBSD, POSIX, and Solaris all use the correct (or the more
explicit) interval notation for [0.0, 1.0) in drand48.3
https://www.freebsd.org/cgi/man.cgi?query=drand48&apropos=0&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html
https://netbsd.gw.com/cgi-bin/man-cgi?drand48+3
https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html
https://docs.oracle.com/cd/E88353_01/html/E37843/drand48-3c.html
https://docs.oracle.com/cd/E26505_01/html/816-5168/drand48-3c.html
(though, Solaris's latter two of three intervals are wrong, unless
they really do mean their upper bound is inclusive)

On Thu, Dec 19, 2019 at 10:48 PM Andras Farkas
 wrote:
>
> On Thu, Dec 19, 2019 at 10:05 PM Theo de Raadt  wrote:
> > It's a mathematical notation that anyone using this page should
> > understand because it comes with the territory.
> > [snip]
> >
> > I think understanding the landscape's notation is a requirement, and we
> > don't need to say things a 2nd time in baby talk.
> I agree it doesn't need to be repeated, but I think there's value in
> explicitly showing whether an interval is open or closed.
> Though, in this case, the interval would be correctly expressed as
> [0.0, 1.0)
> or
> [0.0, 1.0[
> rather than how j's diff does it.
>
> I attached a diff which I feel concisely does this.  I elected to not
> change the latter two of the three intervals in the man page, since
> they already included -1 in their upper bound.  But I also have that
> as an option, via largediff.txt



Re: Clarify drand48() return values

2019-12-19 Thread Theo de Raadt
Yes, it should be fixed.  I'll let the math nerds crawl through the
tree looking for additional errors.

My objection stands, that we should not dumb this down.

Andras Farkas  wrote:

> Not to appeal to majority, but to compare and contrast...
> FreeBSD, NetBSD, POSIX, and Solaris all use the correct (or the more
> explicit) interval notation for [0.0, 1.0) in drand48.3
> https://www.freebsd.org/cgi/man.cgi?query=drand48&apropos=0&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html
> https://netbsd.gw.com/cgi-bin/man-cgi?drand48+3
> https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html
> https://docs.oracle.com/cd/E88353_01/html/E37843/drand48-3c.html
> https://docs.oracle.com/cd/E26505_01/html/816-5168/drand48-3c.html
> (though, Solaris's latter two of three intervals are wrong, unless
> they really do mean their upper bound is inclusive)
> 
> On Thu, Dec 19, 2019 at 10:48 PM Andras Farkas
>  wrote:
> >
> > On Thu, Dec 19, 2019 at 10:05 PM Theo de Raadt  wrote:
> > > It's a mathematical notation that anyone using this page should
> > > understand because it comes with the territory.
> > > [snip]
> > >
> > > I think understanding the landscape's notation is a requirement, and we
> > > don't need to say things a 2nd time in baby talk.
> > I agree it doesn't need to be repeated, but I think there's value in
> > explicitly showing whether an interval is open or closed.
> > Though, in this case, the interval would be correctly expressed as
> > [0.0, 1.0)
> > or
> > [0.0, 1.0[
> > rather than how j's diff does it.
> >
> > I attached a diff which I feel concisely does this.  I elected to not
> > change the latter two of the three intervals in the man page, since
> > they already included -1 in their upper bound.  But I also have that
> > as an option, via largediff.txt



Re: Clarify drand48() return values

2019-12-19 Thread j
OK ok ok.  I admit and agree my original patch was flawed.  Dumbing down 
need

not be done just for my benefit.

--J

On 2019-12-19 21:34, Theo de Raadt wrote:

Yes, it should be fixed.  I'll let the math nerds crawl through the
tree looking for additional errors.

My objection stands, that we should not dumb this down.

Andras Farkas  wrote:


Not to appeal to majority, but to compare and contrast...
FreeBSD, NetBSD, POSIX, and Solaris all use the correct (or the more
explicit) interval notation for [0.0, 1.0) in drand48.3
https://www.freebsd.org/cgi/man.cgi?query=drand48&apropos=0&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports&arch=default&format=html
https://netbsd.gw.com/cgi-bin/man-cgi?drand48+3
https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html
https://docs.oracle.com/cd/E88353_01/html/E37843/drand48-3c.html
https://docs.oracle.com/cd/E26505_01/html/816-5168/drand48-3c.html
(though, Solaris's latter two of three intervals are wrong, unless
they really do mean their upper bound is inclusive)

On Thu, Dec 19, 2019 at 10:48 PM Andras Farkas
 wrote:
>
> On Thu, Dec 19, 2019 at 10:05 PM Theo de Raadt  wrote:
> > It's a mathematical notation that anyone using this page should
> > understand because it comes with the territory.
> > [snip]
> >
> > I think understanding the landscape's notation is a requirement, and we
> > don't need to say things a 2nd time in baby talk.
> I agree it doesn't need to be repeated, but I think there's value in
> explicitly showing whether an interval is open or closed.
> Though, in this case, the interval would be correctly expressed as
> [0.0, 1.0)
> or
> [0.0, 1.0[
> rather than how j's diff does it.
>
> I attached a diff which I feel concisely does this.  I elected to not
> change the latter two of the three intervals in the man page, since
> they already included -1 in their upper bound.  But I also have that
> as an option, via largediff.txt




bgpctl: split out show functions into own file

2019-12-19 Thread Claudio Jeker
This diff just moves most show related functions into a new file.
It is mostly mechanical (remove function from bgpctl.c and add it to
output.c).

OK?
-- 
:wq Claudio

? obj
Index: Makefile
===
RCS file: /cvs/src/usr.sbin/bgpctl/Makefile,v
retrieving revision 1.15
diff -u -p -r1.15 Makefile
--- Makefile25 Jun 2019 07:44:20 -  1.15
+++ Makefile20 Dec 2019 07:20:26 -
@@ -3,7 +3,7 @@
 .PATH: ${.CURDIR}/../bgpd
 
 PROG=  bgpctl
-SRCS=  bgpctl.c parser.c mrtparser.c util.c
+SRCS=  bgpctl.c output.c parser.c mrtparser.c util.c
 CFLAGS+= -Wall
 CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
 CFLAGS+= -Wmissing-declarations
Index: bgpctl.c
===
RCS file: /cvs/src/usr.sbin/bgpctl/bgpctl.c,v
retrieving revision 1.253
diff -u -p -r1.253 bgpctl.c
--- bgpctl.c20 Dec 2019 07:18:51 -  1.253
+++ bgpctl.c20 Dec 2019 07:20:27 -
@@ -2,6 +2,7 @@
 
 /*
  * Copyright (c) 2003 Henning Brauer 
+ * Copyright (c) 2004-2019 Claudio Jeker 
  * Copyright (c) 2016 Job Snijders 
  * Copyright (c) 2016 Peter Hessler 
  *
@@ -38,49 +39,20 @@
 #include "bgpd.h"
 #include "session.h"
 #include "rde.h"
+
+#include "bgpctl.h"
 #include "parser.h"
 #include "mrtparser.h"
 
-enum neighbor_views {
-   NV_DEFAULT,
-   NV_TIMERS
-};
-
-#define EOL0(flag) ((flag & F_CTL_SSV) ? ';' : '\n')
-
 int main(int, char *[]);
 int show(struct imsg *, struct parse_result *);
-char   *fmt_peer(const char *, const struct bgpd_addr *, int);
-voidshow_summary(struct peer *);
-voidshow_neighbor_full(struct peer *, struct parse_result *);
-voidshow_neighbor(struct peer *, struct parse_result *res);
-voidprint_neighbor_capa_mp(struct peer *);
-voidprint_neighbor_capa_restart(struct peer *);
-voidprint_neighbor_msgstats(struct peer *);
 voidprint_timer(const char *, time_t);
-const char *fmt_timeframe(time_t t);
-voidshow_fib_flags(u_int16_t);
-voidshow_fib(struct kroute_full *);
-voidshow_fib_table(struct ktable *);
-voidshow_nexthop(struct ctl_show_nexthop *);
-voidshow_interface(struct ctl_show_interface *);
-voidprint_prefix(struct bgpd_addr *, u_int8_t, u_int8_t, u_int8_t);
-const char *print_origin(u_int8_t, int);
-const char *print_ovs(u_int8_t, int);
-voidprint_flags(u_int8_t, int);
-voidshow_rib(struct ctl_show_rib *, u_char *, size_t,
-   struct parse_result *);
-voidshow_rib_brief(struct ctl_show_rib *, u_char *, size_t);
-voidshow_rib_detail(struct ctl_show_rib *, u_char *, size_t, int);
 voidshow_attr(void *, u_int16_t, int);
 voidshow_communities(u_char *, size_t, int);
 voidshow_community(u_char *, u_int16_t);
 voidshow_large_community(u_char *, u_int16_t);
 voidshow_ext_community(u_char *, u_int16_t);
-voidshow_rib_mem(struct rde_memstats *);
-voidshow_rib_hash(struct rde_hashstats *);
 voidsend_filterset(struct imsgbuf *, struct filter_set_head *);
-const char *get_errstr(u_int8_t, u_int8_t);
 voidshow_mrt_dump_neighbors(struct mrt_rib *, struct mrt_peer *,
void *);
 voidshow_mrt_dump(struct mrt_rib *, struct mrt_peer *, void *);
@@ -89,10 +61,7 @@ void  show_mrt_state(struct mrt_bgp_sta
 voidshow_mrt_msg(struct mrt_bgp_msg *, void *);
 const char *msg_type(u_int8_t);
 voidnetwork_bulk(struct parse_result *);
-const char *print_auth_method(enum auth_method);
 int match_aspath(void *, u_int16_t, struct filter_as *);
-voidshow_head(struct parse_result *);
-voidshow_result(u_int);
 
 struct imsgbuf *ibuf;
 struct mrt_parser show_mrt = { show_mrt_dump, show_mrt_state, show_mrt_msg };
@@ -537,46 +506,6 @@ fmt_peer(const char *descr, const struct
return (p);
 }
 
-void
-show_summary(struct peer *p)
-{
-   char*s;
-   const char  *a;
-   size_t  alen;
-
-   s = fmt_peer(p->conf.descr, &p->conf.remote_addr,
-   p->conf.remote_masklen);
-
-   a = log_as(p->conf.remote_as);
-   alen = strlen(a);
-   /* max displayed length of the peers name is 28 */
-   if (alen < 28) {
-   if (strlen(s) > 28 - alen)
-   s[28 - alen] = '\0';
-   } else
-   alen = 0;
-
-   printf("%-*s %s %10llu %10llu %5u %-8s ",
-   (28 - (int)alen), s, a,
-   p->stats.msg_rcvd_open + p->stats.msg_rcvd_notification +
-   p->stats.msg_rcvd_update + p->stats.msg_rcvd_keepalive +
-   p->stats.msg_rcvd_rrefresh,
-   p->stats.msg_sent_open + p-