urtwn(4): Fix potential crash urtwn_task

2015-07-11 Thread Stefan Sperling
The urtwn(4) USB driver uses the same broken pattern as run(4).
See http://marc.info/?l=openbsd-techm=143660130627359w=2

Single-band driver, so not actually affected.
Fix anyway for posterity.

Index: if_urtwn.c
===
RCS file: /cvs/src/sys/dev/usb/if_urtwn.c,v
retrieving revision 1.48
diff -u -p -r1.48 if_urtwn.c
--- if_urtwn.c  12 Jun 2015 15:47:31 -  1.48
+++ if_urtwn.c  11 Jul 2015 08:45:30 -
@@ -617,16 +617,20 @@ urtwn_task(void *arg)
struct urtwn_softc *sc = arg;
struct urtwn_host_cmd_ring *ring = sc-cmdq;
struct urtwn_host_cmd *cmd;
-   int s;
+   int s, generation;
 
/* Process host commands. */
s = splusb();
+   generation = ring-generation;
while (ring-next != ring-cur) {
cmd = ring-cmd[ring-next];
splx(s);
/* Invoke callback. */
cmd-cb(sc, cmd-data);
s = splusb();
+   /* Abort this task if interface was stopped meanwhile. */
+   if (generation != ring-generation)
+   break;
ring-queued--;
ring-next = (ring-next + 1) % URTWN_HOST_CMD_RING_COUNT;
}
@@ -642,6 +646,11 @@ urtwn_do_async(struct urtwn_softc *sc,
int s;
 
s = splusb();
+   if (ring-queued == URTWN_HOST_CMD_RING_COUNT) {
+   printf(%s: host command ring overflow\n, sc-sc_dev.dv_xname);
+   splx(s);
+   return;
+   }
cmd = ring-cmd[ring-cur];
cmd-cb = cb;
KASSERT(len = sizeof(cmd-data));
@@ -3735,6 +3744,10 @@ urtwn_stop(struct ifnet *ifp)
ifp-if_flags = ~(IFF_RUNNING | IFF_OACTIVE);
 
s = splusb();
+
+   /* Abort urtwn_task thread. */
+   sc-cmdq.generation++;
+
ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
/* Wait for all async commands to complete. */
urtwn_wait_async(sc);
Index: if_urtwnreg.h
===
RCS file: /cvs/src/sys/dev/usb/if_urtwnreg.h,v
retrieving revision 1.7
diff -u -p -r1.7 if_urtwnreg.h
--- if_urtwnreg.h   12 May 2015 11:19:35 -  1.7
+++ if_urtwnreg.h   11 Jul 2015 08:43:32 -
@@ -1137,6 +1137,7 @@ struct urtwn_host_cmd_ring {
int cur;
int next;
int queued;
+   int generation;
 };
 
 struct urtwn_softc {



otus(4): Fix potential crash in otus_task

2015-07-11 Thread Stefan Sperling
The otus(4) USB driver supports dual-band and uses the same broken pattern
as run(4). See http://marc.info/?l=openbsd-techm=143660130627359w=2

Untested since I don't have hardware.

Index: if_otus.c
===
RCS file: /cvs/src/sys/dev/usb/if_otus.c,v
retrieving revision 1.46
diff -u -p -r1.46 if_otus.c
--- if_otus.c   14 Mar 2015 03:38:49 -  1.46
+++ if_otus.c   11 Jul 2015 08:17:56 -
@@ -718,16 +718,20 @@ otus_task(void *arg)
struct otus_softc *sc = arg;
struct otus_host_cmd_ring *ring = sc-cmdq;
struct otus_host_cmd *cmd;
-   int s;
+   int s, generation;
 
/* Process host commands. */
s = splusb();
+   generation = ring-generation;
while (ring-next != ring-cur) {
cmd = ring-cmd[ring-next];
splx(s);
/* Callback. */
cmd-cb(sc, cmd-data);
s = splusb();
+   /* Abort this task if interface was stopped meanwhile. */
+   if (generation != ring-generation)
+   break;
ring-queued--;
ring-next = (ring-next + 1) % OTUS_HOST_CMD_RING_COUNT;
}
@@ -743,6 +747,11 @@ otus_do_async(struct otus_softc *sc, voi
int s;
 
s = splusb();
+   if (ring-queued == OTUS_HOST_CMD_RING_COUNT) {
+   printf(%s: host command ring overflow\n, sc-sc_dev.dv_xname);
+   splx(s);
+   return;
+   }
cmd = ring-cmd[ring-cur];
cmd-cb = cb;
KASSERT(len = sizeof (cmd-data));
@@ -914,9 +923,11 @@ otus_media_change(struct ifnet *ifp)
sc-fixed_ridx = ridx;
}
 
-   if ((ifp-if_flags  (IFF_UP | IFF_RUNNING)) == (IFF_UP | IFF_RUNNING))
+   if ((ifp-if_flags  (IFF_UP | IFF_RUNNING)) ==
+   (IFF_UP | IFF_RUNNING)) {
+   otus_stop(ifp);
error = otus_init(ifp);
-
+   }
return error;
 }
 
@@ -1531,8 +1542,10 @@ otus_ioctl(struct ifnet *ifp, u_long cmd
 
if (error == ENETRESET) {
if ((ifp-if_flags  (IFF_UP | IFF_RUNNING)) ==
-   (IFF_UP | IFF_RUNNING))
+   (IFF_UP | IFF_RUNNING)) {
+   otus_stop(ifp);
otus_init(ifp);
+   }
error = 0;
}
 
@@ -2318,6 +2331,10 @@ otus_stop(struct ifnet *ifp)
timeout_del(sc-calib_to);
 
s = splusb();
+
+   /* Abort otus_task thread. */
+   sc-cmdq.generation++;
+
ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
/* Wait for all queued asynchronous commands to complete. */
usb_wait_task(sc-sc_udev, sc-sc_task);
Index: if_otusreg.h
===
RCS file: /cvs/src/sys/dev/usb/if_otusreg.h,v
retrieving revision 1.9
diff -u -p -r1.9 if_otusreg.h
--- if_otusreg.h26 Nov 2013 20:33:18 -  1.9
+++ if_otusreg.h11 Jul 2015 08:13:16 -
@@ -899,6 +899,7 @@ struct otus_host_cmd_ring {
int cur;
int next;
int queued;
+   int generation;
 };
 
 struct otus_node {



rsu(4): Fix potential crash in rsu_task

2015-07-11 Thread Stefan Sperling
The rsu(4) USB driver uses the same broken pattern as run(4).
See http://marc.info/?l=openbsd-techm=143660130627359w=2

Single-band driver, so not actually affected.
Fix anyway for posterity.

Index: if_rsu.c
===
RCS file: /cvs/src/sys/dev/usb/if_rsu.c,v
retrieving revision 1.27
diff -u -p -r1.27 if_rsu.c
--- if_rsu.c12 Jun 2015 15:47:31 -  1.27
+++ if_rsu.c11 Jul 2015 08:22:46 -
@@ -487,16 +487,20 @@ rsu_task(void *arg)
struct rsu_softc *sc = arg;
struct rsu_host_cmd_ring *ring = sc-cmdq;
struct rsu_host_cmd *cmd;
-   int s;
+   int s, generation;
 
/* Process host commands. */
s = splusb();
+   generation = ring-generation;
while (ring-next != ring-cur) {
cmd = ring-cmd[ring-next];
splx(s);
/* Invoke callback. */
cmd-cb(sc, cmd-data);
s = splusb();
+   /* Abort this task if interface was stopped meanwhile. */
+   if (generation != ring-generation)
+   break;
ring-queued--;
ring-next = (ring-next + 1) % RSU_HOST_CMD_RING_COUNT;
}
@@ -512,6 +516,11 @@ rsu_do_async(struct rsu_softc *sc,
int s;
 
s = splusb();
+   if (ring-queued == RSU_HOST_CMD_RING_COUNT) {
+   printf(%s: host command ring overflow\n, sc-sc_dev.dv_xname);
+   splx(s);
+   return;
+   }
cmd = ring-cmd[ring-cur];
cmd-cb = cb;
KASSERT(len = sizeof(cmd-data));
@@ -2310,6 +2319,10 @@ rsu_stop(struct ifnet *ifp)
ic-ic_scan_lock = IEEE80211_SCAN_UNLOCKED;
 
s = splusb();
+
+   /* Abort rsu_task thread. */
+   sc-cmdq.generation++;
+
ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
/* Wait for all async commands to complete. */
rsu_wait_async(sc);
Index: if_rsureg.h
===
RCS file: /cvs/src/sys/dev/usb/if_rsureg.h,v
retrieving revision 1.3
diff -u -p -r1.3 if_rsureg.h
--- if_rsureg.h 15 Apr 2013 09:23:01 -  1.3
+++ if_rsureg.h 11 Jul 2015 08:21:20 -
@@ -711,6 +711,7 @@ struct rsu_host_cmd_ring {
int cur;
int next;
int queued;
+   int generation;
 };
 
 struct rsu_softc {



run(4): fix crash in run_task()

2015-07-11 Thread Stefan Sperling
While run_task() iterates through the host command queue during a scan,
the interface may get reset via run_stop() and run_init() when switching
bands (2GHz - 5GHz) in run_media_change().

The list state gets corrupted because run_init() resets the list counters
while run_task() is still iterating the list. run_task() will now attempt
to call garbage or NULL callback pointers.

run_newstate_cb SCAN - INIT
run_newstate_cb SCAN - SCAN
run_newstate_cb SCAN - SCAN
run_task ring-next=7
run_task ring-cur=0
run_task ring-queued=-7   -- negative nonesense
run_task cmd=0x80651110
run_task cmd-cb=0x0

The kernel now explodes trying to call cmd-cb.

This can be reproduced by running 'ifconfig run0 mediaopt monitor up'.
Only happens with dual-band devices.

run_init() can't know whether one or more run_task() tasks are scheduled.
So I cannot think of a better fix but make run_task() abort itself in
this situation, muck like iwm(4) does.

Also complain about host command ring overflow in dmesg.

ok?

Index: if_run.c
===
RCS file: /cvs/src/sys/dev/usb/if_run.c,v
retrieving revision 1.109
diff -u -p -r1.109 if_run.c
--- if_run.c12 Jun 2015 15:47:31 -  1.109
+++ if_run.c11 Jul 2015 07:51:29 -
@@ -1720,19 +1720,23 @@ run_task(void *arg)
struct run_softc *sc = arg;
struct run_host_cmd_ring *ring = sc-cmdq;
struct run_host_cmd *cmd;
-   int s;
+   int s, generation;
 
if (usbd_is_dying(sc-sc_udev))
return;
 
/* process host commands */
s = splusb();
+   generation = ring-generation;
while (ring-next != ring-cur) {
cmd = ring-cmd[ring-next];
splx(s);
/* callback */
cmd-cb(sc, cmd-data);
s = splusb();
+   /* Abort this task if interface was stopped meanwhile. */
+   if (generation != ring-generation)
+   break;
ring-queued--;
ring-next = (ring-next + 1) % RUN_HOST_CMD_RING_COUNT;
}
@@ -1751,6 +1755,11 @@ run_do_async(struct run_softc *sc, void 
return;
 
s = splusb();
+   if (ring-queued == RUN_HOST_CMD_RING_COUNT) {
+   printf(%s: host command ring overflow\n, sc-sc_dev.dv_xname);
+   splx(s);
+   return;
+   }
cmd = ring-cmd[ring-cur];
cmd-cb = cb;
KASSERT(len = sizeof (cmd-data));
@@ -4739,6 +4748,10 @@ run_stop(struct ifnet *ifp, int disable)
timeout_del(sc-calib_to);
 
s = splusb();
+
+   /* Abort run_task thread. */
+   sc-cmdq.generation++;
+
ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
/* wait for all queued asynchronous commands to complete */
usb_wait_task(sc-sc_udev, sc-sc_task);
Index: if_runvar.h
===
RCS file: /cvs/src/sys/dev/usb/if_runvar.h,v
retrieving revision 1.10
diff -u -p -r1.10 if_runvar.h
--- if_runvar.h 24 May 2014 10:10:17 -  1.10
+++ if_runvar.h 11 Jul 2015 07:26:41 -
@@ -123,6 +123,7 @@ struct run_host_cmd_ring {
int cur;
int next;
int queued;
+   int generation;
 };
 
 struct run_node {



Re: [PATCH] fix write error handling on SR RAID1

2015-07-11 Thread Joel Sing
On Friday 10 July 2015 22:01:43 Karel Gardas wrote:
 On Fri, Jul 10, 2015 at 9:34 PM, Chris Cappuccio ch...@nmedia.net wrote:
  My first impression, offlining the drive after a single chunk failure
  may be too aggressive as some errors are a result of issues other than
  drive failures.
 
 Indeed, it may look as too aggressive, but is my analysis written in
 comment correct? I mean: if there is a write error for whatever reason
 to one or more chunk(s) and if we completely ignore it since at least
 one write succeed, then arrays is in incorrect state where some
 drive(s) hold(s) correct data and another drive(s) hold(s) previous
 data. Since reading is done in round-robin fashion, then there is a
 chance that you will read old data in the future. If this is correct,
 then I think it calls for fix.

Your analysis is incorrect - offlining of chunks is handled via sr_ccb_done(). 
If lower level I/O indicates an error occurred then the chunk is marked 
offline, 
providing that the discipline has redundancy (for example, we do not offline 
chunks for RAID 0 or CRYPTO - it usually just makes things worse). This 
applies to both read and write operations. 

 If you do not like off-lining drive(s) just after 1 failed read, then
 perhaps correct may be to restart whole work unit and enforce writing
 again? We can even have some threshold where we may stop and consider
 the problematic block really not writeable at the end. Is something
 like that better solution?

We already offline after a single read or write failure occurs - it would be 
possible to implement some form of retry algorithm, however at some point we 
have to trust the lower layers (VFS, disk controller driver, disk hardware, 
etc).



better run(4) fix (was: run(4): fix crash in run_task())

2015-07-11 Thread Stefan Sperling
On Sat, Jul 11, 2015 at 09:54:34AM +0200, Stefan Sperling wrote:
 While run_task() iterates through the host command queue during a scan,
 the interface may get reset via run_stop() and run_init() when switching
 bands (2GHz - 5GHz) in run_media_change().
 
 The list state gets corrupted because run_init() resets the list counters
 while run_task() is still iterating the list. run_task() will now attempt
 to call garbage or NULL callback pointers.
 
 run_newstate_cb SCAN - INIT
 run_newstate_cb SCAN - SCAN
 run_newstate_cb SCAN - SCAN
 run_task ring-next=7
 run_task ring-cur=0
 run_task ring-queued=-7   -- negative nonesense
 run_task cmd=0x80651110
 run_task cmd-cb=0x0
 
 The kernel now explodes trying to call cmd-cb.
 
 This can be reproduced by running 'ifconfig run0 mediaopt monitor up'.

My previous duff cured a symptom.
I believe this new diff closes the actual race.

State transitions can already be waiting to be scheduled while run_stop()
is scheduling another transition trying to bring the device back to INIT.
Each state transition happens asynchronously in a process context.
So if multiple transitions are scheduled they can happen out of order.

When injecting a state transition from the side to force the device
into a particular state, like run_stop() does, we need to make sure the
net80211 stack is not concurrently trying to transition the driver for
other purposes, such as the scanning loop.

This issue probably affects a number of other wifi drivers as well.
If this fix is good to go I'll do a tree-wide sweep soon.

Please disregard all the other hackish patches I mailed out this morning.

Index: if_run.c
===
RCS file: /cvs/src/sys/dev/usb/if_run.c,v
retrieving revision 1.109
diff -u -p -r1.109 if_run.c
--- if_run.c12 Jun 2015 15:47:31 -  1.109
+++ if_run.c11 Jul 2015 13:00:21 -
@@ -1751,6 +1751,11 @@ run_do_async(struct run_softc *sc, void 
return;
 
s = splusb();
+   if (ring-queued == RUN_HOST_CMD_RING_COUNT) {
+   splx(s);
+   printf(%s: host cmd queue overrun\n, sc-sc_dev.dv_xname);
+   return; /* XXX */
+   }
cmd = ring-cmd[ring-cur];
cmd-cb = cb;
KASSERT(len = sizeof (cmd-data));
@@ -4504,7 +4509,9 @@ run_init(struct ifnet *ifp)
}
 
/* init host command ring */
-   sc-cmdq.cur = sc-cmdq.next = sc-cmdq.queued = 0;
+   if (sc-cmdq.queued != 0)
+   panic(outstanding host commands queued);
+   sc-cmdq.cur = sc-cmdq.next = 0;
 
/* init Tx rings (4 EDCAs) */
for (qid = 0; qid  4; qid++) {
@@ -4739,9 +4746,17 @@ run_stop(struct ifnet *ifp, int disable)
timeout_del(sc-calib_to);
 
s = splusb();
+
+   /*
+* Wait for all queued asynchronous commands to complete
+* before switching to INIT state.
+*/
+   usb_wait_task(sc-sc_udev, sc-sc_task);
+
ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
-   /* wait for all queued asynchronous commands to complete */
+   /* Wait for asynchronous state transition to complete. */
usb_wait_task(sc-sc_udev, sc-sc_task);
+
splx(s);
 
/* Disable Tx/Rx DMA. */



sndiod hangs

2015-07-11 Thread Mark Kettenis
Every now and then sndiod hangs on me.  Usually I discover this as
mplayer hangs while playing a video or hangs while opening the audio
device on startup.  Restarting sndiod using the /etc/rc.d/sndiod
script doesn't work; it blocks trying to stop the running sndiod.  I
have to use kill -9 to get rid of it.

Happened again last night and I investigated a bit.  This was after I
tried restarting it using /etc/rc.d/sndiod, but before resorting to
kill -9.  Attaching with gdb revealed that it was stuck in poll(2)
with the 2nd argument being 0 and the last argument being -1.  Since
no file descriptors are being monitored and the timeout is infinite,
the process just blocks forevere.

I did look at the file_list, and only the rsnd/0 file descriptor was
on the list.  That probably corresponded to the mplayer that hung (and
which I subsequently killed) as I had nothing else running that was
doing audio output.  Obviously the sndiod polling code had decided not
to poll for activity on rsnd/0, causing it to block as described
above.



Question about localedef for LC_TIME

2015-07-11 Thread Vladimir Támara Patiño


I would like to ask your advice about sending patches that include 
localedef and support for LC_TIME.


Some time ago I sent patches to support LC_TIME using source tables from 
FreeBSD:


  http://comments.gmane.org/gmane.os.openbsd.tech/36338

I understood from Stephan that source tables should be in localedef 
format and that starting with LC_TIME was good road.  I undertook that 
road, and I already have an implementation of localedef that can read 
LC_TIME from a file from CLDR and can produce tables in UTF-8 (tables 
that practically the function _loc in time/strftime.c can read).


This localedef is available at:
https://github.com/pasosdeJesus/adJ/blob/master/arboldes/usr/src/03-Tiempo-02-localedef.patch

My question is when would be good to send this and the other patches to 
support LC_TIME, in order to be reviewed?







---
Dios, gracias por tu amor infinito.
--
  Vladimir Támara Patiño.  http://vtamara.pasosdeJesus.org/
  http://www.pasosdejesus.org/dominio_publico_colombia.html



Removing chflags/di_flags

2015-07-11 Thread Michael McConville
This was buried in a support thread on misc@, so I thought I'd send it
here. I'm interested to hear what other devs think.

https://marc.info/?l=openbsd-miscm=143650092505421w=2

https://marc.info/?l=openbsd-miscm=143650301005709w=2

https://marc.info/?l=openbsd-miscm=143650420705906w=2



Re: Microsoft Now OpenBSD Foundation Gold Contributor

2015-07-11 Thread frantisek holop
Theo de Raadt, 11 Jul 2015 11:43:
  it flatters me somewhat that you read so much into
  my simple astonishment about a news item that does
  in most geek circles provoke the response no way,
  hell froze over.
 
 I quote from your original mail:
 
 this is very impressive news, although for me for all
 the wrong reasons.
 
 Have all the other sponsors contributed for only the right reasons
 over the 20 years?


i always wanted to do a bsd based soap.

TDR: You did not show simple astonishment -- you judged a sponsor.

FH: can't you just accept the fact that i was _happy_
for the foundation?  that despite feeling betrayed
by the fact that my favourite OS accepted stolen money
from a convicted monopolist...

TDR: Enough Leech!  You have an agenda!

sorry, couldn't resist.


 This is our house, and you don't get to insult guests who bring a
 generous green salad to the party.  That is how you become uninvited.

said Mr Goebels to Mrs Goebels after Hitler left the
dinner party.

sorry, couldn't resist again.

gasp, so now a bsd developer tells me i cannot judge
(not that i did) microsoft on an open mailing list,
after said microsoft just donated a bucket of money
to said bsd developer's project?  you can't make this
up, life immitates art.

jesus, you really sound like an american now.
what's next, you gonna sue me?
get a grip man, you are monty python heritage!


in a private email of yours you said you know zero
about microsoft, as you did not have to use it ever.
lucky you!

i wish i could have had that luxury of ignoring them
the same way i could now.  because i know a bit about
microsoft and some of their products as i have been
following them for the last 20 years.

so excuse me when a piece of news like this hits
i become alert, just like 90% of the other non-freaks
out there.  i am sure KRW felt way more surreal writing
that press release than any of us reading it.

why single me out when 90% of the mailing list was
thinking exactly. the. same.  so who has an agenda now?

-f
-- 
down with TLAs! (three letter acronyms)



Re: [PATCH] fix write error handling on SR RAID1

2015-07-11 Thread Karel Gardas
On Sat, Jul 11, 2015 at 3:44 PM, Joel Sing j...@sing.id.au wrote:
 Your analysis is incorrect - offlining of chunks is handled via sr_ccb_done().
 If lower level I/O indicates an error occurred then the chunk is marked 
 offline,
 providing that the discipline has redundancy (for example, we do not offline
 chunks for RAID 0 or CRYPTO - it usually just makes things worse). This
 applies to both read and write operations.

Joel,

thanks a lot for correcting me. Indeed, sr_ccb_done looks suspicious
and looks like is doing exactly what I expected sr_wu_done should do.
Thanks for the lesson, I'll need to read also softraid.c more closely
next time.

BTW: Speaking about SR, how do you test the stuff? Do you have any
work-flow ho to inject random or intended errors to the device or
emulated device and this way test that the code is doing exactly what
it should? I'm thinking here about several vnds and corrupting their
files or about running OpenBSD inside VBox and corrupting VM files
etc. I would really appreciate any idea in this domain since I'll need
to test my checksumming RAID 1 once code is ready.

Thanks,
Karel



Re: Microsoft Now OpenBSD Foundation Gold Contributor

2015-07-11 Thread Theo de Raadt
 it flatters me somewhat that you read so much into
 my simple astonishment about a news item that does
 in most geek circles provoke the response no way,
 hell froze over.

I quote from your original mail:

this is very impressive news, although for me for all
the wrong reasons.

Have all the other sponsors contributed for only the right reasons
over the 20 years?

You did not show simple astonishment -- you judged a sponsor.

Others on the day of that donation also crossed similar lines, some
implying that the donation was been accepted for the wrong reasons.

This is our house, and you don't get to insult guests who bring a
generous green salad to the party.  That is how you become uninvited.



Re: Microsoft Now OpenBSD Foundation Gold Contributor

2015-07-11 Thread frantisek holop
Theo de Raadt, 09 Jul 2015 21:08:
 As a group (with me and others as the proxy) we do ask for companies
 to help fund us from time to time, and this benefits everyone as a
 result of the common advancements.  As for output, there is no
 discrimination as to their cause, because that is not our
 oversight/job.  The general guidelines for access to software is CLEAR
 in the licence.
 
 Yet you clearly state that we should have some restrictive agenda, Mr.
 Do-Nothing-Except-State-Position.

i wrote no such thing in my email.  not. even. close.

it flatters me somewhat that you read so much into
my simple astonishment about a news item that does
in most geek circles provoke the response no way,
hell froze over.

as a leech, i am of course more than happy when
the project receives funding, no matter the source.

this whole tirade (including your private mails,
that leech etiquette forbids me to quote on an
open mailing list) comes off mildly amusing considering
you yourself foulmouthed a huge donour in the past
(hint hint us army money) and in turn they took their
ball and went home.  now that was damaging.
my email?  oh, please.  get a grip man.


 In essence, you are a loudmouth and a leech.

i am sorry that since i started using openbsd, i sent
its way only around 600 euros for releases, t-shirts,
hats, and mugs; not much perhaps, but i find that
windows users generally never reach this amount,
not by choice anyway.  i am also sorry that i couldn't
send more and better patches, or maintain more ports
than i do.  my contribution overall might not be much
(for whatever value of much), but a pure leech i am
definitely not, no matter how much you try to paint
me as one.  of course, by your logic all openbsd
users are leeches by definition.

maybe a non-leech community member is one that pays
your whole salary or what?


you can't have both: inviting people to contribute
no matter how litle to the project, and then turn
around and call them leeches.  that is not how a
community works, and sadly you could not learn that
even in 20+ years.

and the other bit, the DO MORE FOR ME one is getting
really really old and boring.  i never ever asked for
a feature for myself.  simple smooth operation of the
OS on all my gear is my ultimate goal, a goal every
single member of this community shares.  if you consider
bug reports requests to do work for others, maybe
you should be running a closed commercial project.

-f
-- 
raising your voice does not reinforce your argument.



tcpdump -A: really printable characters

2015-07-11 Thread Christian Weisgerber
I was looking at some SIP traffic (urgh) with tcpdump -A | less and
wondered why ^K and ^L were considered printable characters.  Let's
tighten this a bit.  Equivalent to what tcpdump.org has.

OK?

Index: tcpdump.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/tcpdump.c,v
retrieving revision 1.70
diff -u -p -r1.70 tcpdump.c
--- tcpdump.c   18 Apr 2015 18:28:38 -  1.70
+++ tcpdump.c   11 Jul 2015 20:35:11 -
@@ -603,8 +603,10 @@ default_print_ascii(const u_char *cp, un
printf(\n);
for (i = 0; i  length; i++) {
c = cp[i];
-   c = isprint(c) || isspace(c) ? c : '.';
-   putchar(c);
+   if (isprint(c) || c == '\t' || c == '\n' || c == '\r')
+   putchar(c);
+   else
+   putchar('.');
}
 }
 
-- 
Christian naddy Weisgerber  na...@mips.inka.de



Re: Microsoft Now OpenBSD Foundation Gold Contributor

2015-07-11 Thread Mike Larkin
On Sat, Jul 11, 2015 at 02:47:31PM -0600, Bob Beck wrote:
 Other verbiage aside guys - sorry Frantisek, I might not agree with
 Theo's level of rancor, but No, Your statement for all the wrong
 reasons
 is insulting to all of us, and more developers should speak out about it.

Yep, what is entirely a good thing for OpenBSD is being used by
conspiracy theorists to promote their own agenda.

I certainly hope the paranoia of a few trolls here on the mailing lists
doesn't deter future sponsors from contributing.

-ml

 
 I will speak somewhat out of turn here, and tell you I know for a fact
 because I have been witness to it that year, a donor (who I will not
 name) offered the foundation to meet it's *ENTIRE FUNDRAISING GOAL*
 for this 2015, the only condition was that they could brand the
 OpenBSD Web pages as and put links on them as a sponsor.  Not having
 any control of the OpenBSD web pages, the Foundation directors replied
 that they couldn't do that, but they could and would be listed as a
 donor.  The donor then declined and went away.
 
 1) The foundation owns no rights to OpenBSD, whatsoever. (Unlike
 FreeBSD and NetBSD, the OpenBSD foundation is not a rights holder and
 owns no code, or OpenBSD). The foundation exists only to support
 OpenBSD and chooses how to do that. (Theo is actuall not a part of it,
 he makes requests of the foundation).
 
 2) In light of what I've told you above, The very thought that the
 directors of the foundation and the OpenBSD developers would somehow
 sell out for what is, while very much appreciated, a relatively
 small amount of money is so ridiculous it is insulting. Your wild
 speculation
 is irrational, and insulting to me and good friends of mine.
 
 If you want to go look for conspiracies of corporate and government
 control you should be looking under a different HAT. Please apologize
 and
 let it drop, or leave our mailing lists and do not return.
 
 Thanks
 
 -Bob
 
 
 
 
 On Sat, Jul 11, 2015 at 11:43 AM, Theo de Raadt dera...@cvs.openbsd.org 
 wrote:
  it flatters me somewhat that you read so much into
  my simple astonishment about a news item that does
  in most geek circles provoke the response no way,
  hell froze over.
 
  I quote from your original mail:
 
  this is very impressive news, although for me for all
  the wrong reasons.
 
  Have all the other sponsors contributed for only the right reasons
  over the 20 years?
 
  You did not show simple astonishment -- you judged a sponsor.
 
  Others on the day of that donation also crossed similar lines, some
  implying that the donation was been accepted for the wrong reasons.
 
  This is our house, and you don't get to insult guests who bring a
  generous green salad to the party.  That is how you become uninvited.
 
 



Re: Microsoft Now OpenBSD Foundation Gold Contributor

2015-07-11 Thread Bob Beck
Other verbiage aside guys - sorry Frantisek, I might not agree with
Theo's level of rancor, but No, Your statement for all the wrong
reasons
is insulting to all of us, and more developers should speak out about it.

I will speak somewhat out of turn here, and tell you I know for a fact
because I have been witness to it that year, a donor (who I will not
name) offered the foundation to meet it's *ENTIRE FUNDRAISING GOAL*
for this 2015, the only condition was that they could brand the
OpenBSD Web pages as and put links on them as a sponsor.  Not having
any control of the OpenBSD web pages, the Foundation directors replied
that they couldn't do that, but they could and would be listed as a
donor.  The donor then declined and went away.

1) The foundation owns no rights to OpenBSD, whatsoever. (Unlike
FreeBSD and NetBSD, the OpenBSD foundation is not a rights holder and
owns no code, or OpenBSD). The foundation exists only to support
OpenBSD and chooses how to do that. (Theo is actuall not a part of it,
he makes requests of the foundation).

2) In light of what I've told you above, The very thought that the
directors of the foundation and the OpenBSD developers would somehow
sell out for what is, while very much appreciated, a relatively
small amount of money is so ridiculous it is insulting. Your wild
speculation
is irrational, and insulting to me and good friends of mine.

If you want to go look for conspiracies of corporate and government
control you should be looking under a different HAT. Please apologize
and
let it drop, or leave our mailing lists and do not return.

Thanks

-Bob




On Sat, Jul 11, 2015 at 11:43 AM, Theo de Raadt dera...@cvs.openbsd.org wrote:
 it flatters me somewhat that you read so much into
 my simple astonishment about a news item that does
 in most geek circles provoke the response no way,
 hell froze over.

 I quote from your original mail:

 this is very impressive news, although for me for all
 the wrong reasons.

 Have all the other sponsors contributed for only the right reasons
 over the 20 years?

 You did not show simple astonishment -- you judged a sponsor.

 Others on the day of that donation also crossed similar lines, some
 implying that the donation was been accepted for the wrong reasons.

 This is our house, and you don't get to insult guests who bring a
 generous green salad to the party.  That is how you become uninvited.




Re: tcpdump -A: really printable characters

2015-07-11 Thread Sebastien Marie
On Sat, Jul 11, 2015 at 10:45:44PM +0200, Christian Weisgerber wrote:
 I was looking at some SIP traffic (urgh) with tcpdump -A | less and
 wondered why ^K and ^L were considered printable characters.  Let's
 tighten this a bit.  Equivalent to what tcpdump.org has.
 
 OK?
 
 Index: tcpdump.c
 ===
 RCS file: /cvs/src/usr.sbin/tcpdump/tcpdump.c,v
 retrieving revision 1.70
 diff -u -p -r1.70 tcpdump.c
 --- tcpdump.c 18 Apr 2015 18:28:38 -  1.70
 +++ tcpdump.c 11 Jul 2015 20:35:11 -
 @@ -603,8 +603,10 @@ default_print_ascii(const u_char *cp, un
   printf(\n);
   for (i = 0; i  length; i++) {
   c = cp[i];
 - c = isprint(c) || isspace(c) ? c : '.';
 - putchar(c);
 + if (isprint(c) || c == '\t' || c == '\n' || c == '\r')

does printing '\r' will allow overriding previously printed char on line ?

$ echo 'bad thing\rgood thing'
good thing

 + putchar(c);
 + else
 + putchar('.');
   }
  }
  

-- 
Sebastien Marie



Re: tcpdump -A: really printable characters

2015-07-11 Thread Theo de Raadt
  Index: tcpdump.c
  ===
  RCS file: /cvs/src/usr.sbin/tcpdump/tcpdump.c,v
  retrieving revision 1.70
  diff -u -p -r1.70 tcpdump.c
  --- tcpdump.c   18 Apr 2015 18:28:38 -  1.70
  +++ tcpdump.c   11 Jul 2015 20:35:11 -
  @@ -603,8 +603,10 @@ default_print_ascii(const u_char *cp, un
  printf(\n);
  for (i = 0; i  length; i++) {
  c = cp[i];
  -   c = isprint(c) || isspace(c) ? c : '.';
  -   putchar(c);
  +   if (isprint(c) || c == '\t' || c == '\n' || c == '\r')
 
 does printing '\r' will allow overriding previously printed char on line ?
 
 $ echo 'bad thing\rgood thing'
 good thing

Hah, yeah pretty bad.

I sent a mail to naddy mentioning that a long time ago (feels like 10
years ago) we talked about using vis, but this would have made our
tcpdump far too different from others.  Not that it is very similar,
because of the baked-in privsep work.  Which reminds me... I have a
diff to send out...



tcpdump: make BIOCGSTATS a priv operation

2015-07-11 Thread Theo de Raadt
This moves the BIOCGSTATS ioctl operation done by the tcpdump process
(at ^C time, but not at -c count expiration) into a service provided
by the privsep monitor.

Had a bit of help from canacar, who wrote the original privsep code
with otto.

Will be needed for tame.

Index: privsep.c
===
RCS file: /cvs/src/usr.sbin/tcpdump/privsep.c,v
retrieving revision 1.33
diff -u -p -u -r1.33 privsep.c
--- privsep.c   15 Mar 2015 00:41:28 -  1.33
+++ privsep.c   12 Jul 2015 05:42:29 -
@@ -20,6 +20,7 @@
 #include sys/types.h
 #include sys/socket.h
 #include sys/wait.h
+#include sys/ioctl.h
 
 #include netinet/in.h
 #include net/if.h
@@ -59,7 +60,8 @@ enum priv_state {
STATE_INIT, /* initial state */
STATE_BPF,  /* input file/device opened */
STATE_FILTER,   /* filter applied */
-   STATE_RUN   /* running and accepting network traffic */
+   STATE_RUN,  /* running and accepting network traffic */
+   STATE_EXIT  /* in the process of dying */
 };
 
 #define ALLOW(action)  (1  (action))
@@ -76,7 +78,8 @@ static const int allowed_max[] = {
ALLOW(PRIV_ETHER_NTOHOST) | ALLOW(PRIV_INIT_DONE),
/* RUN */   ALLOW(PRIV_GETHOSTBYADDR) | ALLOW(PRIV_ETHER_NTOHOST) |
ALLOW(PRIV_GETRPCBYNUMBER) | ALLOW(PRIV_GETLINES) |
-   ALLOW(PRIV_LOCALTIME)
+   ALLOW(PRIV_LOCALTIME) | ALLOW(PRIV_PCAP_STATS),
+   /* EXIT */  0
 };
 
 /*
@@ -87,7 +90,9 @@ static int allowed_ext[] = {
/* INIT */  ALLOW(PRIV_SETFILTER),
/* BPF */   ALLOW(PRIV_SETFILTER),
/* FILTER */ALLOW(PRIV_GETSERVENTRIES),
-   /* RUN */   ALLOW(PRIV_GETLINES) | ALLOW(PRIV_LOCALTIME)
+   /* RUN */   ALLOW(PRIV_GETLINES) | ALLOW(PRIV_LOCALTIME) |
+   ALLOW(PRIV_PCAP_STATS),
+   /* EXIT */  0
 };
 
 struct ftab {
@@ -120,6 +125,7 @@ static void impl_getserventries(int);
 static voidimpl_getprotoentries(int);
 static voidimpl_localtime(int fd);
 static voidimpl_getlines(int);
+static voidimpl_pcap_stats(int, int *);
 
 static voidtest_state(int, int);
 static voidlogmsg(int, const char *, ...);
@@ -186,6 +192,7 @@ priv_init(int argc, char **argv)
}
 
sigprocmask(SIG_SETMASK, oset, NULL);
+   signal(SIGINT, SIG_IGN);
 
/* Child - drop suid privileges */
gid = getgid();
@@ -303,6 +310,10 @@ priv_init(int argc, char **argv)
test_state(cmd, STATE_RUN);
impl_getlines(socks[0]);
break;
+   case PRIV_PCAP_STATS:
+   test_state(cmd, STATE_RUN);
+   impl_pcap_stats(socks[0], bpfd);
+   break;
default:
logmsg(LOG_ERR, [priv]: unknown command %d, cmd);
_exit(1);
@@ -390,8 +401,6 @@ impl_setfilter(int fd, char *cmdbuf, int
 
if (setfilter(*bpfd, fd, cmdbuf))
logmsg(LOG_DEBUG, [priv]: setfilter() failed);
-   close(*bpfd);   /* done with bpf descriptor */
-   *bpfd = -1;
 }
 
 static void
@@ -401,8 +410,6 @@ impl_init_done(int fd, int *bpfd)
 
logmsg(LOG_DEBUG, [priv]: msg PRIV_INIT_DONE received);
 
-   close(*bpfd);   /* done with bpf descriptor */
-   *bpfd = -1;
ret = 0;
must_write(fd, ret, sizeof(ret));
 }
@@ -581,6 +588,19 @@ impl_getlines(int fd)
fclose(fp);
 }
 
+static void
+impl_pcap_stats(int fd, int *bpfd)
+{
+   struct pcap_stat stats;
+
+   logmsg(LOG_DEBUG, [priv]: msg PRIV_PCAP_STATS received);
+
+   if (ioctl(*bpfd, BIOCGSTATS, stats) == -1)
+   write_zero(fd);
+   else
+   must_write(fd, stats, sizeof(stats));
+}
+
 void
 priv_init_done(void)
 {
@@ -738,6 +758,17 @@ priv_getlines(size_t sz)
 
write_command(priv_fd, PRIV_GETLINES);
must_write(priv_fd, sz, sizeof(size_t));
+}
+
+int
+priv_pcap_stats(struct pcap_stat *ps)
+{
+   if (priv_fd  0)
+   errx(1, %s: called from privileged portion, __func__);
+
+   write_command(priv_fd, PRIV_PCAP_STATS);
+   must_read(priv_fd, ps, sizeof(*ps));
+   return (0);
 }
 
 /* retrieve a line from a file, should be called repeatedly after calling
Index: privsep.h
===
RCS file: /cvs/src/usr.sbin/tcpdump/privsep.h,v
retrieving revision 1.7
diff -u -p -u -r1.7 privsep.h
--- privsep.h   25 Aug 2009 06:59:17 -  1.7
+++ privsep.h   21 May 2015 01:27:53 -
@@ -37,7 +37,8 @@ enum cmd_types {
PRIV_GETPROTOENTRIES,   /* get the ip protocol entries table */
PRIV_LOCALTIME, /* return localtime */
PRIV_GETLINES,  /* get lines from a file */
-   PRIV_INIT_DONE