memory leaks in bwfm

2018-09-17 Thread Jonathan Gray
Index: bwfm.c
===
RCS file: /cvs/src/sys/dev/ic/bwfm.c,v
retrieving revision 1.54
diff -u -p -r1.54 bwfm.c
--- bwfm.c  25 Jul 2018 20:37:11 -  1.54
+++ bwfm.c  18 Sep 2018 05:21:30 -
@@ -1297,6 +1297,7 @@ bwfm_proto_bcdc_query_dcmd(struct bwfm_s
 
if (bwfm_proto_bcdc_txctl(sc, reqid, (char *)dcmd, )) {
DPRINTF(("%s: tx failed\n", DEVNAME(sc)));
+   free(dcmd, M_TEMP, size);
return ret;
}
 
@@ -1337,6 +1338,7 @@ bwfm_proto_bcdc_set_dcmd(struct bwfm_sof
 
if (bwfm_proto_bcdc_txctl(sc, reqid, (char *)dcmd, )) {
DPRINTF(("%s: txctl failed\n", DEVNAME(sc)));
+   free(dcmd, M_TEMP, size);
return ret;
}
 
@@ -1361,6 +1363,7 @@ bwfm_proto_bcdc_txctl(struct bwfm_softc 
 
if (sc->sc_bus_ops->bs_txctl(sc, ctl)) {
DPRINTF(("%s: tx failed\n", DEVNAME(sc)));
+   free(ctl, M_TEMP, sizeof(*ctl));
return 1;
}
 



memory leak in ihidev_hid_command()

2018-09-17 Thread Jonathan Gray
Index: ihidev.c
===
RCS file: /cvs/src/sys/dev/i2c/ihidev.c,v
retrieving revision 1.17
diff -u -p -r1.17 ihidev.c
--- ihidev.c25 Aug 2018 18:32:05 -  1.17
+++ ihidev.c18 Sep 2018 05:15:37 -
@@ -361,6 +361,7 @@ ihidev_hid_command(struct ihidev_softc *
DPRINTF(("%s: response report id %d != %d\n",
sc->sc_dev.dv_xname, d, rreq->id));
iic_release_bus(sc->sc_tag, 0);
+   free(tmprep, M_DEVBUF, report_len);
return (1);
}
 



memory leak in amdisplay_attach()

2018-09-17 Thread Jonathan Gray
Index: amdisplay.c
===
RCS file: /cvs/src/sys/arch/armv7/omap/amdisplay.c,v
retrieving revision 1.7
diff -u -p -r1.7 amdisplay.c
--- amdisplay.c 25 Oct 2017 14:34:22 -  1.7
+++ amdisplay.c 18 Sep 2018 05:12:41 -
@@ -272,6 +272,7 @@ amdisplay_attach(struct device *parent, 
 
if (rasops_init(>sc_ro, 200, 200)) {
printf("%s: no rasops\n", DEVNAME(sc));
+   free(edid_buf, M_DEVBUF, EDID_LENGTH);
amdisplay_detach(self, 0);
return;
}



mandoc: typo fix (?) in mandoc.1

2018-09-17 Thread Sascha Paunovic
Hi,

while reading mandoc(1), I noticed that under the PostScript output
section, it said the line-height was 1.4m, while it is 1.4em. I doubt
the line-height is approximately as tall as a 5th grader, so let's
clarify this:

diff --git usr.bin/mandoc/mandoc.1 usr.bin/mandoc/mandoc.1
index aa19c49d6..e180145ee 100644
--- usr.bin/mandoc/mandoc.1
+++ usr.bin/mandoc/mandoc.1
@@ -459,7 +459,7 @@ Level-2 pages may be generated by
 Output pages default to letter sized and are rendered in the Times font
 family, 11-point.
 Margins are calculated as 1/9 the page length and width.
-Line-height is 1.4m.
+Line-height is 1.4em.
 .Pp
 Special characters are rendered as in
 .Sx ASCII Output .

-- 
Sascha Paunovic 



Re: fix memory leak in ieee80211_end_scan()

2018-09-17 Thread Jonathan Gray
On Mon, Sep 17, 2018 at 10:27:30AM +0100, Ricardo Mestre wrote:
> Hi,
> 
> This plugs a resource leak in ieee80211_end_scan() when background scanning
> support was added to iwn(4). Noticed by Coverity ID 1473310.
> 
> OK?

ok

> 
> Index: ieee80211_node.c
> ===
> RCS file: /cvs/src/sys/net80211/ieee80211_node.c,v
> retrieving revision 1.151
> diff -u -p -u -r1.151 ieee80211_node.c
> --- ieee80211_node.c  17 Sep 2018 02:34:16 -  1.151
> +++ ieee80211_node.c  17 Sep 2018 09:24:34 -
> @@ -1376,6 +1376,7 @@ ieee80211_end_scan(struct ifnet *ifp)
>   IEEE80211_FC0_SUBTYPE_DEAUTH,
>   IEEE80211_REASON_AUTH_LEAVE) != 0) {
>   ic->ic_flags &= ~IEEE80211_F_BGSCAN;
> + free(arg, M_DEVBUF, sizeof(*arg));
>   return;
>   }
>  
> 



smtpctl.8 typo

2018-09-17 Thread Michael Mikonos
Hello,

My spell-checker found the following typo this morning. OK?

- Michael


Index: smtpctl.8
===
RCS file: /cvs/src/usr.sbin/smtpd/smtpctl.8,v
retrieving revision 1.63
diff -u -p -u -r1.63 smtpctl.8
--- smtpctl.8   14 May 2018 15:23:05 -  1.63
+++ smtpctl.8   18 Sep 2018 03:32:22 -
@@ -204,7 +204,7 @@ Current runstate: either "pending" or "i
 .Xr smtpd 8
 is running, or "offline" otherwise.
 .It
-Delay in seconds before the next attempt if pending, or time ellapsed
+Delay in seconds before the next attempt if pending, or time elapsed
 if currently running.
 This field is blank if
 .Xr smtpd 8



Re: more user_from_uid(3)

2018-09-17 Thread Todd C. Miller
On Tue, 18 Sep 2018 03:30:39 +0200, Theo Buehler wrote:

> I don't mind the slight change of behavior in write(1) in an unlikely
> branch, but how about doing this instead?
>
>   if ((login = user_from_uid(myuid, 1)) == NULL)
>   login = "???";
>
> either way ok.

The "???" is not terribly useful.  I think it is better to use the
uid of the user writing to the tty.  Either way, this is a code
path unlikely to be exercised.

 - todd



Re: rdist: use passwd/group caches

2018-09-17 Thread Theo Buehler
On Sun, Sep 16, 2018 at 07:55:19AM -0600, Todd C. Miller wrote:
> Any rdist users out there?  The way rdist does group caching (stash
> the struct group pointer) will stop working in the future so I'd
> like to get these changes in before then.

Perhaps we can give potential testers a bit more time, but your diff is
ok tb



ral(4): add RT3290 support

2018-09-17 Thread James Hastings



Ported from original vendor driver.
RT3290 is similar to RT5390 but integrates WLAN + Bluetooth on single chip.
Bluetooth not supported.

New 4kb firmware at /etc/firmware/ral-rt3290 for this chip only.
New routines to read efuse rom and control wlan core.
Tested on RT3090 and RT5390.


Index: share/man/man4/ral.4
===
RCS file: /cvs/src/share/man/man4/ral.4,v
retrieving revision 1.112
diff -u -p -r1.112 ral.4
--- share/man/man4/ral.415 Jul 2018 10:44:49 -  1.112
+++ share/man/man4/ral.418 Sep 2018 00:43:03 -
@@ -65,7 +65,10 @@ The RT3090 chipset is the first generati
 from Ralink.
 .Pp
 The RT3900E chipset is a single-chip 802.11n adapter from Ralink.
-The MAC/Baseband Processor can be an RT5390 or RT5392.
+The MAC/Baseband Processor can be an RT3290, RT5390 or RT5392.
+The RT3290 is a combo 802.11n and Bluetooth chip.
+It operates in the 2 Ghz spectrum and supports one transmit path and one
+receiver path (1T1R).
 The RT5390 chip operates in the 2GHz spectrum and supports one 
transmit path

 and one receiver path (1T1R).
 The RT5392 chip operates in the 2GHz spectrum and supports up to two 
transmit

@@ -139,6 +142,7 @@ files to be loaded when an interface is
 .It /etc/firmware/ral-rt2561s
 .It /etc/firmware/ral-rt2661
 .It /etc/firmware/ral-rt2860
+.It /etc/firmware/ral-rt3290
 .El
 .Pp
 The RT2500 chipset does not require a firmware file to operate.
Index: sys/dev/ic/rt2860.c
===
RCS file: /cvs/src/sys/dev/ic/rt2860.c,v
retrieving revision 1.95
diff -u -p -r1.95 rt2860.c
--- sys/dev/ic/rt2860.c 26 Oct 2017 15:00:28 -  1.95
+++ sys/dev/ic/rt2860.c 18 Sep 2018 00:43:06 -
@@ -17,7 +17,8 @@
  */

 /*-
- * Ralink Technology RT2860/RT3090/RT3390/RT3562/RT5390/RT5392 chipset 
driver

+ * Ralink Technology RT2860/RT3090/RT3290/RT3390/RT3562/RT5390/
+ * RT5392 chipset driver
  * http://www.ralinktech.com/
  */

@@ -97,6 +98,7 @@ void  rt2860_ampdu_rx_stop(struct ieee80
 intrt2860_newstate(struct ieee80211com *, enum ieee80211_state,
int);
 uint16_t   rt3090_efuse_read_2(struct rt2860_softc *, uint16_t);
+uint16_t   rt3290_efuse_read_2(struct rt2860_softc *, uint16_t);
 uint16_t   rt2860_eeprom_read_2(struct rt2860_softc *, uint16_t);
 void   rt2860_intr_coherent(struct rt2860_softc *);
 void   rt2860_drain_stats_fifo(struct rt2860_softc *);
@@ -147,6 +149,8 @@ const char *rt2860_get_rf(uint16_t);
 intrt2860_read_eeprom(struct rt2860_softc *);
 intrt2860_bbp_init(struct rt2860_softc *);
 void   rt5390_bbp_init(struct rt2860_softc *);
+void   rt3290_mac_init(struct rt2860_softc *);
+intrt3290_wlan_enable(struct rt2860_softc *);
 intrt2860_txrx_enable(struct rt2860_softc *);
 intrt2860_init(struct ifnet *);
 void   rt2860_stop(struct ifnet *, int);
@@ -172,6 +176,8 @@ static const struct {
uint8_t val;
 } rt2860_def_bbp[] = {
RT2860_DEF_BBP
+},rt3290_def_bbp[] = {
+   RT3290_DEF_BBP
 },rt5390_def_bbp[] = {
RT5390_DEF_BBP
 };
@@ -194,6 +200,8 @@ static const struct {
uint8_t val;
 }  rt3090_def_rf[] = {
RT3070_DEF_RF
+}, rt3290_def_rf[] = {
+   RT3290_DEF_RF
 }, rt3572_def_rf[] = {
RT3572_DEF_RF
 }, rt5390_def_rf[] = {
@@ -208,14 +216,19 @@ rt2860_attach(void *xsc, int id)
struct rt2860_softc *sc = xsc;
struct ieee80211com *ic = >sc_ic;
int qid, ntries, error;
-   uint32_t tmp;
+   uint32_t tmp, reg;

sc->amrr.amrr_min_success_threshold =  1;
sc->amrr.amrr_max_success_threshold = 15;

+   if (id == PCI_PRODUCT_RALINK_RT3290)
+   reg = RT2860_PCI_CFG;
+   else
+   reg = RT2860_ASIC_VER_ID;
+
/* wait for NIC to initialize */
for (ntries = 0; ntries < 100; ntries++) {
-   tmp = RAL_READ(sc, RT2860_ASIC_VER_ID);
+   tmp = RAL_READ(sc, reg);
if (tmp != 0 && tmp != 0x)
break;
DELAY(10);
@@ -286,7 +299,11 @@ rt2860_attachhook(struct device *self)
struct ifnet *ifp = >ic_if;
int i, error;

-   error = loadfirmware("ral-rt2860", >ucode, >ucsize);
+   if (sc->mac_ver == 0x3290) {
+   error = loadfirmware("ral-rt3290", >ucode, >ucsize);
+   } else {
+   error = loadfirmware("ral-rt2860", >ucode, >ucsize);
+   }
if (error != 0) {
printf("%s: error %d, could not read firmware file %s\n",
sc->sc_dev.dv_xname, error, "ral-rt2860");
@@ -1026,6 +1043,45 @@ rt3090_efuse_read_2(struct rt2860_softc
return (addr & 2) ? tmp >> 16 : tmp & 0x;
 }

+/* Read 16 bits from eFUSE ROM (RT3290 only) */
+uint16_t
+rt3290_efuse_read_2(struct rt2860_softc *sc, uint16_t 

Re: pwd_mkdb(8): estimate correct number of hash table elements

2018-09-17 Thread Theo Buehler
On Mon, Sep 17, 2018 at 11:08:04AM -0600, Todd C. Miller wrote:
> Since we store each entry 3 times the estimate of the number of
> elements needs to be 3x the number of entries.
> 
> Also set the bucket size to be the optimal file system block size
> instead of hard-coding to 4096.

ok tb



Re: more user_from_uid(3)

2018-09-17 Thread Theo Buehler
On Mon, Sep 17, 2018 at 11:14:40AM -0600, Todd C. Miller wrote:
> Two more pontential places where user_from_uid(3) makes sense.
> These were in my large diff but got lost chopping it up into smaller
> pieces.

I don't mind the slight change of behavior in write(1) in an unlikely
branch, but how about doing this instead?

if ((login = user_from_uid(myuid, 1)) == NULL)
login = "???";

either way ok.



Re: bsd.rd failure in VirtualBox

2018-09-17 Thread David Higgs
On Sun, Sep 16, 2018 at 1:15 PM, Johan Huldtgren
 wrote:
> On 2018/09/16 10:52, David Higgs wrote:
>> On Sun, Sep 16, 2018 at 10:17 AM, David Higgs  wrote:
>>> On Sat, Sep 15, 2018 at 10:05 PM, Philip Guenther  
>>> wrote:
 On Sat, Sep 15, 2018 at 11:59 AM David Higgs  wrote:
>
> I often use VirtualBox (version 5.2.18 on OS X) to familiarize myself
> with new features in snapshots, before upgrading my physical hardware.
>
> This afternoon, I tried updating bsd.rd (amd64, 6.4-beta RAMDISK_CD
> #281) and wasn't able to successfully boot it.  I had to rely on the
> video capture ability of VirtualBox to even notice there was a panic
> (typed out below) before it rebooted to the "BIOS" splash screen.

 ...
>
> Also attached is the dmesg from a prior working snapshot.  I haven't
> tried updating since this prior snapshot, so I don't have further
> insight into when the issue first appeared.


 Thank you for the complete and clear report!

 I have a diff in the amd64 snapshots to use the CPU's PCID support in many
 cases and this VirtualBox setup found a bug in it.  I've generated a new
 diff that should fix this, so a future snap should fix this, though when
 that'll happend depends on the snap builder's schedule.

>>>
>>> Not sure if the fix made it into RAMDISK_CD #282, but this panic is
>>> slightly different.  I haven't tried reproducing to see if the panic
>>> message differs between boots.
>>>
>>> 
>>> root on rd0a swap on rd0b dump on rd0b
>>> uvm_fault(0xff011f73ac60, 0x208, 0, 1) -> e
>>> fatal page fault in supervisor mode
>>> trap type 6 code 0 rip 8135510b cs 8 rflags 10246 cr2 208 cpl
>>> 0 rsp 800022026c90
>>> gsbase 0x81870ff0 kgsbase 0x0
>>> panic: trap type 6, code=0, pc=8135510b
>>> syncing disk... done
>>>
>>> dump to dev 17,1 not possible
>>> rebooting...
>>> 
>>>
>>> Hope this helps.
>>>
>>
>> FWIW, the vbox capture feature is pretty buggy - it doesn't create the
>> file when it says it is recording, and it frequently crashes.  It is
>> possible the panic above is from #281 instead, because I deleted the
>> video before I realizing this.
>>
>> Below is definitely from #282.
>>
>> 
>> Welcome to the OpenBSD/amd64 6.4 installation program.
>> fatal protection fault in supervisor mode
>> trap type 4 code 0 rip 810f4244 cs 8 rflags 10286 cr2 6c1fed
>> cpl a rsp 800022098800
>> gsbase 0x81870ff0 kgsbase 0x0
>> panic: trap type 4, code 0, pc=0x 810f4244
>> syncing disks... done
>>
>> dump to dev 17,1 not possible
>> rebooting...
>> 
>>
>> Hope this is actually useful and not another stupid VirtualBox bug.
>
> I see this an almost identical panic on real hardware too, the only difference
> being the string after 'rsp'
>
> Welcome to the OpenBSD/amd64 6.4 installation program.
> fatal protection fault in supervisor mode
> trap type 4 code 0 rip 810f4244 cs 8 rflags 10286 cr2 6c1fed cpl a 
> rsp 8000220ba9e0
> gsbase 0x81870ff0 kgsbase 0x0
> panic: trap type 4, code 0, pc=810f4244
> syncing disks... done
>
> dump to dev 17,1 not possible
> rebooting...
>
> Below is first the working dmesg snapshot, and then one from booting bsd.rd, 
> note
> the ACPI error about not being able to load tables, that's not there on the 
> working
> snap. That might be the culprit at least in my case?
>

FYI - successfully booted with RAMDISK_CD #283 and installed a
successfully-booting GENERIC #284 within VirtualBox.

Thanks again.

--david



Re: Linux DRM

2018-09-17 Thread Theo de Raadt
Thomas de Grivel  wrote:

> Le lun. 3 sept. 2018 à 23:33, Philip Guenther  a écrit :
> >
> > On Mon, Sep 3, 2018 at 11:46 AM Thomas de Grivel  wrote:
> >>
> >> I was browsing the DRM code ported from Linux and it's a terrible
> >> mess, is there any ongoing project to clean up that codebase or
> >> rewrite it entirely ?
> >
> >
> > No.  OpenBSD doesn't have the resources to reimplement the DRM subsystem or 
> > maintain a non-trivial fork of the Linux version.  We don't want to get 
> > stuck with a code base that doesn't support close-to-current hardware, so 
> > the porting work has concentrated on minimizing the changes necessary to 
> > make the upstream code base work in OpenBSD.
> >
> > It's clear that the hardware support in the upstream has large 
> > contributions from developers with inside access at the hardware vendors; 
> > without such access it's doubtful that all the hardware bugs^Wlimitations 
> > can be worked around with non-infinite resource.
> >
> > Improvements in the DRM code itself should be done in the upstream, not 
> > just to minimize OpenBSD costs in this area, but so that all OSes that draw 
> > from that base can benefit.
> 
> You probably do not care and actually neither do I but that current
> state of graphic hardware support code is crazy in my opinion.
> Computer graphic cards have to be the single most successful hardware
> in the history of computer hardware or even hardware in general and
> yet their drivers are a complete mess. It makes no sense to me. It all
> appears like a hideous obscurity-based false sense of security where
> you really cannot ensure the minimality of any driver and their
> features.
> 
> I would not be least surprised to see a few backdoors in that code,
> preventing OpenBSD for use for private intellectual property work,
> however different the advertisement can be. I sure hope I'm wrong.

It's been nearly 2 weeks and you haven't shown your draft reimplimentation yet!



ix0/1/2/3 at pci8 dev 0 function 0 "Intel X553 SFP+" rev 0x11: msi, address 00:30:18:xxxxxxx

2018-09-17 Thread sven falempin
Dear Tech reader,

I am recently working on  Intel(R) Atom(TM) CPU C3758  intel devices.
SFP Intel card are not working in 6.3/current openBSD base

I did patch intel driver reading netbsd, freebsd and intel code of ixgbe
driver.

I am now transferring data between two openBSD at ~1.50 Gb/s
for more than 48 hours ( been looping all week end )

First, i d like to find other user with ix card to check for regression !
Secondly, can i get some feedback on how to test 10Gb /s transfer
 - i usually download ramfs file through nginx or use iperf .
Third, how can i get a patch accepted into base : ie, how do i clean this
work ?

- - - - -

Patch :

17 K lines OOPS
Find the patch here : https://github.com/dohnuts/wip/blob/master/ixgbe.diff

- - - -

dmesg:

OpenBSD 6.3-stable (ACPI.MP) #10: Fri Sep 14 14:54:51 EDT 2018
root@futur:/usr/src/sys/arch/amd64/compile/ACPI.MP
real mem = 17130721280 (16337MB)
avail mem = 16604413952 (15835MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.0 @ 0x7f1fc000 (18 entries)
bios0: vendor American Megatrends Inc. version "0ACHIA01" date 06/14/2018
bios0: NF699 NF699
acpi0 at bios0: rev 2
#please dont mind this
acpi0: sleep states S0 S4 S5acpi_enable: 000C, 00A0, 0010,
0001, 00B2, 15 (15), acpi_writepm: smi = 00b2: a0
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010
 check acpi_enable, PM1, , 0001, 0010, can't enable ACPI
#please dont mind this
acpi0: tables DSDT FACP FPDT FIDT MCFG WDAT APIC BDAT HPET UEFI SSDT DMAR
HEST BERT ERST EINJ WSMT
acpi0: wakeup devices PEX0(S4) PEX1(S4) PEX2(S4) PEX3(S4) PEX4(S4) PEX5(S4)
PEX6(S4) PEX7(S4) XHC1(S4) LAN0(S4) LAN1(S4) LAN2(S4) LAN3(S4)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpimcfg0 at acpi0 addr 0xe000, bus 0-255
acpimadt0 at acpi0 addr 0xfee0: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Atom(TM) CPU C3758 @ 2.20GHz, 2200.41 MHz
cpu0:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,CX16,xTPR,PDCM,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,FSGSBASE,SMEP,ERMS,MPX,RDSEED,SMAP,CLFLUSHOPT,PT,SHA,IBRS,IBPB,STIBP,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu0: 2MB 64b/line 16-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 24MHz
cpu0: mwait min=64, max=64, C-substates=0.2.0.2, IBE
cpu1 at mainbus0: apid 4 (application processor)
cpu1: Intel(R) Atom(TM) CPU C3758 @ 2.20GHz, 2200.00 MHz
cpu1:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,CX16,xTPR,PDCM,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,FSGSBASE,SMEP,ERMS,MPX,RDSEED,SMAP,CLFLUSHOPT,PT,SHA,IBRS,IBPB,STIBP,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu1: 2MB 64b/line 16-way L2 cache
cpu1: smt 0, core 2, package 0
cpu2 at mainbus0: apid 8 (application processor)
cpu2: Intel(R) Atom(TM) CPU C3758 @ 2.20GHz, 2200.00 MHz
cpu2:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,MWAIT,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,CX16,xTPR,PDCM,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,FSGSBASE,SMEP,ERMS,MPX,RDSEED,SMAP,CLFLUSHOPT,PT,SHA,IBRS,IBPB,STIBP,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu2: 2MB 64b/line 16-way L2 cache
cpu2: smt 0, core 4, package 0
cpu3 at mainbus0: apid 12 (application processor)
cpu3: Intel(R) Atom(TM) CPU C3758 @ 2.20GHz, 2200.00 MHz
cpu3:

Re: csh: remove macros xmalloc,xcalloc,xreallocarray

2018-09-17 Thread Todd C. Miller
On Mon, 17 Sep 2018 23:55:32 +0800, Michael Mikonos wrote:

> In csh(1) the functions Malloc(), Calloc() & Reallocarray()
> are always called via the macros (which don't really do anything).
> This patch renames the functions and deletes the macros.
> Does this look OK?

OK millert@

 - todd



more user_from_uid(3)

2018-09-17 Thread Todd C. Miller
Two more pontential places where user_from_uid(3) makes sense.
These were in my large diff but got lost chopping it up into smaller
pieces.

 - todd

Index: usr.bin/write/write.c
===
RCS file: /cvs/src/usr.bin/write/write.c,v
retrieving revision 1.33
diff -u -p -u -r1.33 write.c
--- usr.bin/write/write.c   5 Feb 2016 19:00:39 -   1.33
+++ usr.bin/write/write.c   13 Sep 2018 15:39:12 -
@@ -224,20 +224,16 @@ term_chk(char *tty, int *msgsokP, time_t
 void
 do_write(char *tty, char *mytty, uid_t myuid)
 {
-   char *login, *nows;
-   struct passwd *pwd;
+   const char *login;
+   char *nows;
time_t now;
char path[PATH_MAX], host[HOST_NAME_MAX+1], line[512];
gid_t gid;
int fd;
 
/* Determine our login name before the we reopen() stdout */
-   if ((login = getlogin()) == NULL) {
-   if ((pwd = getpwuid(myuid)))
-   login = pwd->pw_name;
-   else
-   login = "???";
-   }
+   if ((login = getlogin()) == NULL)
+   login = user_from_uid(myuid, 0);
 
(void)snprintf(path, sizeof(path), "%s%s", _PATH_DEV, tty);
fd = open(path, O_WRONLY, 0666);
Index: usr.sbin/quot/quot.c
===
RCS file: /cvs/src/usr.sbin/quot/quot.c,v
retrieving revision 1.31
diff -u -p -u -r1.31 quot.c
--- usr.sbin/quot/quot.c26 Jul 2018 13:37:40 -  1.31
+++ usr.sbin/quot/quot.c13 Sep 2018 15:39:12 -
@@ -227,8 +227,8 @@ static struct user *
 user(uid_t uid)
 {
int i;
-   struct passwd *pwd;
struct user *usr;
+   const char *name;
 
while (1) {
for (usr = users + (uid&(nusers - 1)), i = nusers;
@@ -237,10 +237,10 @@ user(uid_t uid)
if (!usr->name) {
usr->uid = uid;
 
-   if (!(pwd = getpwuid(uid)))
+   if ((name = user_from_uid(uid, 1)) == NULL)
asprintf(>name, "#%u", uid);
else
-   usr->name = strdup(pwd->pw_name);
+   usr->name = strdup(name);
if (!usr->name)
err(1, "allocate users");
return usr;
@@ -368,6 +368,8 @@ douser(int fd, struct fs *super, char *n
struct user *usr, *usrs;
union dinode *dp;
int n;
+
+   setpassent(1);
 
maxino = super->fs_ncg * super->fs_ipg - 1;
for (inode = 0; inode < maxino; inode++) {



pwd_mkdb(8): estimate correct number of hash table elements

2018-09-17 Thread Todd C. Miller
Since we store each entry 3 times the estimate of the number of
elements needs to be 3x the number of entries.

Also set the bucket size to be the optimal file system block size
instead of hard-coding to 4096.

 - todd

Index: usr.sbin/pwd_mkdb/pwd_mkdb.c
===
RCS file: /cvs/src/usr.sbin/pwd_mkdb/pwd_mkdb.c,v
retrieving revision 1.53
diff -u -p -u -r1.53 pwd_mkdb.c
--- usr.sbin/pwd_mkdb/pwd_mkdb.c5 Nov 2015 15:10:11 -   1.53
+++ usr.sbin/pwd_mkdb/pwd_mkdb.c17 Sep 2018 16:39:31 -
@@ -188,8 +188,13 @@ main(int argc, char **argv)
/* Tweak openinfo values for large passwd files. */
if (st.st_size > (off_t)100*1024)
openinfo.cachesize = MINIMUM(st.st_size * 20, 
(off_t)12*1024*1024);
-   if (st.st_size / 128 > openinfo.nelem)
-   openinfo.nelem = st.st_size / 128;
+   /* Estimate number of elements based on a 128-byte average entry. */
+   if (st.st_size / 128 * 3 > openinfo.nelem)
+   openinfo.nelem = st.st_size / 128 * 3;
+
+   /* Use optimal filesystem block size. */
+   if (st.st_blksize > openinfo.bsize)
+   openinfo.bsize = st.st_blksize;
 
/* If only updating a single record, stash the old uid */
if (username) {



csh: remove macros xmalloc,xcalloc,xreallocarray

2018-09-17 Thread Michael Mikonos
Hello,

In csh(1) the functions Malloc(), Calloc() & Reallocarray()
are always called via the macros (which don't really do anything).
This patch renames the functions and deletes the macros.
Does this look OK?

- Michael


Index: csh.h
===
RCS file: /cvs/src/bin/csh/csh.h,v
retrieving revision 1.30
diff -u -p -u -r1.30 csh.h
--- csh.h   30 Aug 2017 06:42:21 -  1.30
+++ csh.h   17 Sep 2018 15:45:21 -
@@ -69,10 +69,6 @@ typedef void *ioctl_t;   /* Third arg of 
 #include "char.h"
 #include "error.h"
 
-#define xmalloc(i) Malloc(i)
-#define xreallocarray(p, i, j) Reallocarray(p, i, j)
-#define xcalloc(n, s)  Calloc(n, s)
-
 #include 
 FILE *cshin, *cshout, *csherr;
 
Index: extern.h
===
RCS file: /cvs/src/bin/csh/extern.h,v
retrieving revision 1.27
diff -u -p -u -r1.27 extern.h
--- extern.h15 Sep 2018 12:15:32 -  1.27
+++ extern.h17 Sep 2018 15:45:21 -
@@ -281,9 +281,9 @@ voidpsecs(long);
 /*
  * alloc.c
  */
-void * Malloc(size_t);
-void * Reallocarray(void *, size_t, size_t);
-void * Calloc(size_t, size_t);
+void * xmalloc(size_t);
+void * xreallocarray(void *, size_t, size_t);
+void * xcalloc(size_t, size_t);
 
 /*
  * str.c:
Index: alloc.c
===
RCS file: /cvs/src/bin/csh/alloc.c,v
retrieving revision 1.17
diff -u -p -u -r1.17 alloc.c
--- alloc.c 26 Dec 2015 13:48:38 -  1.17
+++ alloc.c 17 Sep 2018 15:45:21 -
@@ -39,7 +39,7 @@
 #include "extern.h"
 
 void *
-Malloc(size_t n)
+xmalloc(size_t n)
 {
 void *ptr;
 
@@ -51,7 +51,7 @@ Malloc(size_t n)
 }
 
 void *
-Reallocarray(void * p, size_t c, size_t n)
+xreallocarray(void * p, size_t c, size_t n)
 {
 void *ptr;
 
@@ -63,7 +63,7 @@ Reallocarray(void * p, size_t c, size_t 
 }
 
 void *
-Calloc(size_t s, size_t n)
+xcalloc(size_t s, size_t n)
 {
 void *ptr;
 



Re: csh: simplify strsave()

2018-09-17 Thread Michael Mikonos
On Mon, Sep 17, 2018 at 09:06:16AM -0600, Todd C. Miller wrote:
> On Mon, 17 Sep 2018 15:53:06 +0200, Martijn van Duren wrote:
> 
> > It should be safe. There are 5 instances where any() isn't called with
> > a string literal:
> 
> Thanks for checking.  OK millert@ for the diff.
> 
>  - todd

Also OK miko@ as I didn't hit any cases where the source string is NULL
when running this patch.



Re: csh: simplify strsave()

2018-09-17 Thread Todd C. Miller
On Mon, 17 Sep 2018 15:53:06 +0200, Martijn van Duren wrote:

> It should be safe. There are 5 instances where any() isn't called with
> a string literal:

Thanks for checking.  OK millert@ for the diff.

 - todd



Re: Always call bridge_iflist `bif'

2018-09-17 Thread Alexander Bluhm
On Mon, Sep 17, 2018 at 10:20:51AM -0300, Martin Pieuchot wrote:
> I'd like to always use the same name of `bridge_iflist', it helps me
> deal with the different data structures and their relation with `ifp'.
> 
> Diff below use `bif' everywhere, ok?

Yes, p was a very unspecific name.  OK bluhm@

> No intentional functional change.

I have compared objdump -d if_bridge.o, no difference.

> Index: net/if_bridge.c
> ===
> RCS file: /cvs/src/sys/net/if_bridge.c,v
> retrieving revision 1.308
> diff -u -p -r1.308 if_bridge.c
> --- net/if_bridge.c   19 Apr 2018 22:31:25 -  1.308
> +++ net/if_bridge.c   17 Sep 2018 13:16:16 -
> @@ -233,22 +233,22 @@ bridge_clone_destroy(struct ifnet *ifp)
>  }
>  
>  int
> -bridge_delete(struct bridge_softc *sc, struct bridge_iflist *p)
> +bridge_delete(struct bridge_softc *sc, struct bridge_iflist *bif)
>  {
>   int error;
>  
> - if (p->bif_flags & IFBIF_STP)
> - bstp_delete(p->bif_stp);
> + if (bif->bif_flags & IFBIF_STP)
> + bstp_delete(bif->bif_stp);
>  
> - p->ifp->if_bridgeport = NULL;
> - error = ifpromisc(p->ifp, 0);
> - hook_disestablish(p->ifp->if_detachhooks, p->bif_dhcookie);
> -
> - if_ih_remove(p->ifp, bridge_input, NULL);
> - TAILQ_REMOVE(>sc_iflist, p, next);
> - bridge_rtdelete(sc, p->ifp, 0);
> - bridge_flushrule(p);
> - free(p, M_DEVBUF, sizeof *p);
> + bif->ifp->if_bridgeport = NULL;
> + error = ifpromisc(bif->ifp, 0);
> + hook_disestablish(bif->ifp->if_detachhooks, bif->bif_dhcookie);
> +
> + if_ih_remove(bif->ifp, bridge_input, NULL);
> + TAILQ_REMOVE(>sc_iflist, bif, next);
> + bridge_rtdelete(sc, bif->ifp, 0);
> + bridge_flushrule(bif);
> + free(bif, M_DEVBUF, sizeof *bif);
>  
>   return (error);
>  }
> @@ -260,7 +260,7 @@ bridge_ioctl(struct ifnet *ifp, u_long c
>   struct ifbreq *req = (struct ifbreq *)data;
>   struct ifbropreq *brop = (struct ifbropreq *)data;
>   struct ifnet *ifs;
> - struct bridge_iflist *p;
> + struct bridge_iflist *bif;
>   struct bstp_port *bp;
>   struct bstp_state *bs = sc->sc_stp;
>   int error = 0;
> @@ -284,8 +284,8 @@ bridge_ioctl(struct ifnet *ifp, u_long c
>   }
>  
>   if (ifs->if_bridgeport != NULL) {
> - p = (struct bridge_iflist *)ifs->if_bridgeport;
> - if (p->bridge_sc == sc)
> + bif = (struct bridge_iflist *)ifs->if_bridgeport;
> + if (bif->bridge_sc == sc)
>   error = EEXIST;
>   else
>   error = EBUSY;
> @@ -293,10 +293,10 @@ bridge_ioctl(struct ifnet *ifp, u_long c
>   }
>  
>   /* If it's in the span list, it can't be a member. */
> - TAILQ_FOREACH(p, >sc_spanlist, next)
> - if (p->ifp == ifs)
> + TAILQ_FOREACH(bif, >sc_spanlist, next)
> + if (bif->ifp == ifs)
>   break;
> - if (p != NULL) {
> + if (bif != NULL) {
>   error = EBUSY;
>   break;
>   }
> @@ -316,24 +316,24 @@ bridge_ioctl(struct ifnet *ifp, u_long c
>   break;
>   }
>  
> - p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT|M_ZERO);
> - if (p == NULL) {
> + bif = malloc(sizeof(*bif), M_DEVBUF, M_NOWAIT|M_ZERO);
> + if (bif == NULL) {
>   if (ifs->if_type == IFT_ETHER)
>   ifpromisc(ifs, 0);
>   error = ENOMEM;
>   break;
>   }
>  
> - p->bridge_sc = sc;
> - p->ifp = ifs;
> - p->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER;
> - SIMPLEQ_INIT(>bif_brlin);
> - SIMPLEQ_INIT(>bif_brlout);
> - ifs->if_bridgeport = (caddr_t)p;
> - p->bif_dhcookie = hook_establish(ifs->if_detachhooks, 0,
> + bif->bridge_sc = sc;
> + bif->ifp = ifs;
> + bif->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER;
> + SIMPLEQ_INIT(>bif_brlin);
> + SIMPLEQ_INIT(>bif_brlout);
> + ifs->if_bridgeport = (caddr_t)bif;
> + bif->bif_dhcookie = hook_establish(ifs->if_detachhooks, 0,
>   bridge_ifdetach, ifs);
> - if_ih_insert(p->ifp, bridge_input, NULL);
> - TAILQ_INSERT_TAIL(>sc_iflist, p, next);
> + if_ih_insert(bif->ifp, bridge_input, NULL);
> + TAILQ_INSERT_TAIL(>sc_iflist, bif, next);
>   break;
>   case SIOCBRDGDEL:
>   if ((error = suser(curproc)) != 0)
> @@ -343,12 +343,12 @@ bridge_ioctl(struct ifnet *ifp, u_long c
>   error = ENOENT;
>   break;
>  

Re: bgpd roa-set backend

2018-09-17 Thread Claudio Jeker
On Fri, Sep 14, 2018 at 04:59:51PM +0200, Claudio Jeker wrote:
> This diff extends the existing trie code for prefix-set to also work with
> roa-set. Unlike prefix-set there is no need for a prefixlen mask during
> lookup, instead the source-as needs to be checked and also if the
> prefixlen of the prefix is allowed.
> The lookup can return 3 states:
> ROA_UNKNONW: prefix is not covered by any entry
> ROA_VALID: prefix is covered and the source-as matches as does the prefixlen
> ROA_INVALID: there was a covering ROA entry that did not match source-as
>   or prefixlen
> The source-as check is done with an as_set and should therefor scale well.
> In general these lookups need to be quick since all prefixes will go
> through roa lookups.
> 
> The frontend code (parse.y and imsg passing) is missing, since this is
> already fairly large and it is tested by the unit tests I decided to send
> this out as an idividual step.
> 

Anyone having something against me committing this later today?
Will make it easier to send out the next bits to get us ROA support.

-- 
:wq Claudio

> Index: usr.sbin/bgpd/bgpd.h
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/bgpd.h,v
> retrieving revision 1.340
> diff -u -p -r1.340 bgpd.h
> --- usr.sbin/bgpd/bgpd.h  14 Sep 2018 10:22:11 -  1.340
> +++ usr.sbin/bgpd/bgpd.h  14 Sep 2018 14:08:49 -
> @@ -952,6 +952,11 @@ struct filter_set {
>   enum action_types   type;
>  };
>  
> +struct roa_set {
> + u_int32_t   as; /* must be first */
> + u_int32_t   maxlen; /* change type for better struct layout */
> +};
> +
>  struct prefixset_item {
>   struct filter_prefix p;
>   SIMPLEQ_ENTRY(prefixset_item)entry;
> Index: usr.sbin/bgpd/rde.h
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/rde.h,v
> retrieving revision 1.190
> diff -u -p -r1.190 rde.h
> --- usr.sbin/bgpd/rde.h   9 Sep 2018 12:33:51 -   1.190
> +++ usr.sbin/bgpd/rde.h   14 Sep 2018 14:08:22 -
> @@ -36,6 +36,12 @@ enum peer_state {
>   PEER_ERR/* error occurred going to PEER_DOWN state */
>  };
>  
> +enum roa_state {
> + ROA_UNKNOWN,
> + ROA_INVALID,
> + ROA_VALID
> +};
> +
>  /*
>   * How do we identify peers between the session handler and the rde?
>   * Currently I assume that we can do that with the neighbor_ip...
> @@ -332,7 +338,8 @@ struct rde_prefixset {
>   charname[SET_NAME_LEN];
>   struct trie_headth;
>   SIMPLEQ_ENTRY(rde_prefixset)entry;
> - int  dirty;
> + int dirty;
> + int roa;
>  };
>  SIMPLEQ_HEAD(rde_prefixset_head, rde_prefixset);
>  
> @@ -578,8 +585,12 @@ int   up_dump_mp_reach(u_char *, u_int16
>  /* rde_trie.c */
>  int  trie_add(struct trie_head *, struct bgpd_addr *, u_int8_t, u_int8_t,
>   u_int8_t);
> +int  trie_roa_add(struct trie_head *, struct bgpd_addr *, u_int8_t,
> + struct as_set *);
>  void trie_free(struct trie_head *);
>  int  trie_match(struct trie_head *, struct bgpd_addr *, u_int8_t, int);
> +int  trie_roa_check(struct trie_head *, struct bgpd_addr *, u_int8_t,
> + u_int32_t);
>  void trie_dump(struct trie_head *);
>  int  trie_equal(struct trie_head *, struct trie_head *);
>  
> Index: usr.sbin/bgpd/rde_trie.c
> ===
> RCS file: /cvs/src/usr.sbin/bgpd/rde_trie.c,v
> retrieving revision 1.5
> diff -u -p -r1.5 rde_trie.c
> --- usr.sbin/bgpd/rde_trie.c  10 Sep 2018 13:15:50 -  1.5
> +++ usr.sbin/bgpd/rde_trie.c  14 Sep 2018 14:08:22 -
> @@ -57,22 +57,20 @@
>   */
>  struct tentry_v4 {
>   struct tentry_v4*trie[2];
> + struct as_set   *aset;  /* for roa source-as set */
>   struct in_addr   addr;
>   struct in_addr   plenmask;
>   u_int8_t plen;
>   u_int8_t node;
> -
> - /* roa source-as list pointer */
>  };
>  
>  struct tentry_v6 {
>   struct tentry_v6*trie[2];
> + struct as_set   *aset;  /* for roa source-as set */
>   struct in6_addr  addr;
>   struct in6_addr  plenmask;
>   u_int8_t plen;
>   u_int8_t node;
> -
> - /* roa source-as list pointer */
>  };
>  
>  /*
> @@ -143,37 +141,14 @@ inet6setbit(struct in6_addr *addr, u_int
>   addr->s6_addr[bit / 8] |= (0x80 >> (bit % 8));
>  }
>  
> -static int
> -trie_add_v4(struct trie_head *th, struct in_addr *prefix, u_int8_t plen,
> -u_int8_t min, u_int8_t max)
> +static struct tentry_v4 *
> +trie_add_v4(struct trie_head *th, struct in_addr *prefix, u_int8_t plen)
>  {
>   struct tentry_v4 *n, *new, *b, **prev;
> - struct in_addr p, plenmask;
> - 

inpcb table and socket lock

2018-09-17 Thread Alexander Bluhm
Hi,

I want to reduce the scope of the net lock and finally get a mutex
per inpcb or socket.  A step in this direction is to remove the net
lock for netstat -an.

Introduce a global mutex that protects the tables and hashes for
the internet PCBs.  To detect detached PCB, set its inp_socket field
to NULL.  This has to be protected by a per PCB mutex.

My future plan is to extend the protection of the PCB mutex and run
more code without net lock.

ok?

bluhm

Index: kern/kern_sysctl.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.346
diff -u -p -r1.346 kern_sysctl.c
--- kern/kern_sysctl.c  12 Jul 2018 01:23:38 -  1.346
+++ kern/kern_sysctl.c  17 Sep 2018 13:10:27 -
@@ -1179,7 +1179,8 @@ fill_file(struct kinfo_file *kf, struct 
kf->inp_rtableid = inpcb->inp_rtableid;
if (so->so_type == SOCK_RAW)
kf->inp_proto = inpcb->inp_ip.ip_p;
-   if (so->so_proto->pr_protocol == IPPROTO_TCP) {
+   if (so->so_proto->pr_protocol == IPPROTO_TCP &&
+   inpcb->inp_ppcb != NULL) {
struct tcpcb *tcpcb = (void *)inpcb->inp_ppcb;
kf->t_rcv_wnd = tcpcb->rcv_wnd;
kf->t_snd_wnd = tcpcb->snd_wnd;
@@ -1206,7 +1207,8 @@ fill_file(struct kinfo_file *kf, struct 
kf->inp_rtableid = inpcb->inp_rtableid;
if (so->so_type == SOCK_RAW)
kf->inp_proto = inpcb->inp_ipv6.ip6_nxt;
-   if (so->so_proto->pr_protocol == IPPROTO_TCP) {
+   if (so->so_proto->pr_protocol == IPPROTO_TCP &&
+   inpcb->inp_ppcb != NULL) {
struct tcpcb *tcpcb = (void *)inpcb->inp_ppcb;
kf->t_rcv_wnd = tcpcb->rcv_wnd;
kf->t_snd_wnd = tcpcb->snd_wnd;
@@ -1320,10 +1322,16 @@ sysctl_file(int *name, u_int namelen, ch
}   \
needed += elem_size;\
 } while (0)
+
 #define FILLIT(fp, fdp, i, vp, pr) \
FILLIT2(fp, fdp, i, vp, pr, NULL)
-#define FILLSO(so) \
-   FILLIT2(NULL, NULL, 0, NULL, NULL, so)
+
+#define FILLINPCB(inp) do {\
+   mtx_enter(>inp_mtx);   \
+   if (inp->inp_socket != NULL)\
+   FILLIT2(NULL, NULL, 0, NULL, NULL, inp->inp_socket);\
+   mtx_leave(>inp_mtx);   \
+} while (0)
 
switch (op) {
case KERN_FILE_BYFILE:
@@ -1331,19 +1339,26 @@ sysctl_file(int *name, u_int namelen, ch
if (arg == DTYPE_SOCKET) {
struct inpcb *inp;
 
-   NET_LOCK();
+   /*
+* The inpcb and socket fields are accessed and read
+* without net lock.  This may result in inconsistent
+* data provided to userland.  The fix will be to
+* protect the socket fields with the inpcb mutex.
+* XXXSMP
+*/
+   mtx_enter(_mtx);
TAILQ_FOREACH(inp, _queue, inp_queue)
-   FILLSO(inp->inp_socket);
+   FILLINPCB(inp);
TAILQ_FOREACH(inp, _queue, inp_queue)
-   FILLSO(inp->inp_socket);
+   FILLINPCB(inp);
TAILQ_FOREACH(inp, _queue, inp_queue)
-   FILLSO(inp->inp_socket);
+   FILLINPCB(inp);
 #ifdef INET6
TAILQ_FOREACH(inp, _queue,
inp_queue)
-   FILLSO(inp->inp_socket);
+   FILLINPCB(inp);
 #endif
-   NET_UNLOCK();
+   mtx_leave(_mtx);
}
fp = NULL;
while ((fp = fd_iterfile(fp, p)) != NULL) {
Index: netinet/in_pcb.c
===
RCS file: /data/mirror/openbsd/cvs/src/sys/netinet/in_pcb.c,v
retrieving revision 1.245
diff -u -p -r1.245 in_pcb.c
--- netinet/in_pcb.c14 Sep 2018 12:55:17 -  1.245
+++ netinet/in_pcb.c17 Sep 2018 13:10:27 -
@@ -111,12 +111,16 @@ int ipport_lastauto = IPPORT_USERRESERVE
 int ipport_hifirstauto = IPPORT_HIFIRSTAUTO;
 int ipport_hilastauto = IPPORT_HILASTAUTO;
 
+/* Protect PCB table queues, lookup hashes and existence of inpcb. */
+struct mutex 

Re: fdformat: reformat usage()

2018-09-17 Thread Robert Klein
On Sun, 16 Sep 2018 22:48:01 +0100
Jason McIntyre  wrote:

> On Wed, Sep 12, 2018 at 05:40:49PM +0100, Jason McIntyre wrote:
> > On Wed, Sep 12, 2018 at 11:50:18AM +0200, Sascha Paunovic wrote:  
> > > Since C99, string literal concatenation is provided, allowing the
> > > number of printf() calls to be greatly reduced (20 -> 1).
> > > 
> > > This is my first diff I'm sending, feedback would be very
> > > appreciated. 
> > 
> > hi.
> > 
> > i'm all for the diff but... generally usage() does not spit out a
> > description of the options (with some exceptions). if you look at
> > the man page, the irony is that the usage seems more verbose.
> > 
> > anyone object to removing the list that follows the synopsis? if
> > not, i'd prefer that.
> > 
> > unrelated question: anyone know why the argument to -g is "gap3len"?
> > 
> > jmc
> >   
> 
> ok, so here's the diff i propose. yay? nay?
> jmc
> 
> Index: fdformat.c
> ===
> RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
> retrieving revision 1.22
> diff -u -r1.22 fdformat.c
> --- fdformat.c16 Mar 2016 15:41:11 -  1.22
> +++ fdformat.c16 Sep 2018 21:46:04 -
> @@ -132,26 +132,10 @@
>  static void
>  usage(void)
>  {
> - printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> gap3len] ",
> - __progname);
> - printf("[-h heads]\n");
> - printf("\t[-i intleave] [-r rate] [-S secshft] [-s secs]\n");
> - printf("\t[-t steps_per_track] device_name\n");
> - printf("Options:\n");
> - printf("\t-n\tdon't verify floppy after formatting\n");
> - printf("\t-q\tsuppress any normal output, don't ask for
> confirmation\n");
> - printf("\t-v\tdon't format, verify only\n");
> - printf("\tdevname\tthe full name of floppy device or in
> short form fd0, fd1\n");
> - printf("Obscure options:\n");
> - printf("\t-c #\tspecify number of cylinders, 40 or 80\n");
> - printf("\t-F #\tspecify fill byte\n");
> - printf("\t-g #\tspecify gap length\n");
> - printf("\t-h #\tspecify number of floppy heads, 1 or 2\n");
> - printf("\t-i #\tspecify interleave factor\n");
> - printf("\t-r #\tspecify data rate, 250, 300 or 500 kbps\n");
> - printf("\t-S #\tspecify sector size, 0=128, 1=256, 2=512
> bytes\n");
> - printf("\t-s #\tspecify number of sectors per track, 9, 10,
> 15 or 18\n");
> - printf("\t-t #\tnumber of steps per track\n");
> + printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> gap3len] "
> + "[-h heads]\n"
> + "   [-i intleave] [-r rate] [-S secshft] [-s
> secs]\n"
> + "   [-t steps_per_track] device_name\n",
> __progname); exit(2);
>  }
>  
> 

How about putting the information from “usage” in the rather sparse man
page (see below)?

Best regards,
Robert


Index: usr.sbin/fdformat/fdformat.1
===
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.1,v
retrieving revision 1.19
diff -u -p -r1.19 fdformat.1
--- usr.sbin/fdformat/fdformat.18 Jan 2017 01:32:02 -   1.19
+++ usr.sbin/fdformat/fdformat.117 Sep 2018 07:25:45 -
@@ -62,28 +62,37 @@ are meaningless, since they're overridde
 .Pp
 The options are as follows:
 .Pp
-.Bl -tag -width Ds -compact
+.Bl -tag -width Ds
 .It Fl n
 Don't verify floppy after formatting.
-.Pp
 .It Fl q
 Suppress any normal output from the command, and don't ask the
 user for confirmation whether to format the floppy disk at
 .Ar device_name .
-.Pp
 .It Fl v
 Don't format; verify only.
-.Pp
 .It Fl c Ar cyls
+Number of cylinders (40 or 80).
 .It Fl F Ar fillbyte
+Use
+.Ar fillbyte
+as fill byte.
 .It Fl g Ar gap3len
+Length of gap at the end of any sector.
 .It Fl h Ar heads
+Number of floppy heads (1 or 2).
 .It Fl i Ar intleave
+Sector interleave.
 .It Fl r Ar rate
+Data transfer rate in kilobyte/sec (250, 300, or 500).
 .It Fl S Ar secshft
+Sector size shift factor (use 0 for 128, 1 for 256, and 2 for 512 byte
+sectors).
 .It Fl s Ar secs
+Number of sectors per track (9, 10, 15, or 18).
 .It Fl t Ar steps_per_track
-An alternate method to specify the geometry data to write to the floppy disk.
+Number of steps per track.  An alternate method to specify the
+geometry data to write to the floppy disk.
 .El
 .Pp
 If the




Re: csh: simplify strsave()

2018-09-17 Thread Martijn van Duren
On 09/15/18 14:16, Todd C. Miller wrote:
> On Sat, 15 Sep 2018 12:42:22 +0200, Martijn van Duren wrote:
> 
>> While here, should we also remove any in favour of strchr? Only
>> difference seems to be the return type (bool vs pointer).
> 
> Note that any(NULL, ch) is safe whereas strchr(NULL, ch) will crash.
> It is hard to say whether or not there are actual calls to any()
> with a NULL string (most use a constant string) but this needs to
> be checked before committing.
> 
>  - todd
> 
It should be safe. There are 5 instances where any() isn't called with
a string literal:
Index: dol.c
===
RCS file: /cvs/src/bin/csh/dol.c,v
retrieving revision 1.21
diff -u -p -r1.21 dol.c
--- dol.c   16 Dec 2017 10:27:21 -  1.21
+++ dol.c   15 Sep 2018 10:41:24 -
@@ -918,7 +918,7 @@ heredoc(Char *term)
 * If any ` in line do command substitution
 */
mbp = mbuf;
-   if (any(short2str(mbp), '`')) {
+   if (strchr(short2str(mbp), '`')) {
/*
 * 1 arg to dobackp causes substitution to be literal. Words are
 * broken only at newlines so that all blanks and tabs are

This one is safe, because mbp is based on mbuf, which is on the stack.

Index: exec.c
===
RCS file: /cvs/src/bin/csh/exec.c,v
retrieving revision 1.19
diff -u -p -r1.19 exec.c
--- exec.c  26 Dec 2015 13:48:38 -  1.19
+++ exec.c  15 Sep 2018 10:41:24 -
@@ -137,7 +137,7 @@ doexec(Char **v, struct command *t)
blkfree(pv);
pexerr();
 }
-slash = any(short2str(expath), '/');
+slash = (bool) strchr(short2str(expath), '/');

This one is safe, because expath is set right before via Strsave and 3  
lines before it already assumes expath to be a valid pointer.

 /*
  * Glob the argument list, if necessary. Otherwise trim off the quote bits.
@@ -492,7 +492,7 @@ iscommand(Char *name)
 Char **pv;
 Char *sav;
 struct varent *v;
-bool slash = any(short2str(name), '/');
+bool slash = (bool) strchr(short2str(name), '/');
 int hashval = 0, hashval1, i;

 v = adrof(STRpath);
@@ -680,7 +680,7 @@ tellmewhat(struct wordent *lexp, Char *s
 if ((i = iscommand(sp->word)) != 0) {
Char **pv;
struct varent *v;
-   boolslash = any(short2str(sp->word), '/');
+   boolslash = (bool) strchr(short2str(sp->word), '/');
v = adrof(STRpath);
if (v == 0 || v->vec[0] == 0 || slash)

The two should be safe, because they're both called with sp->word from
tellmewhat(), which is set via globone just prior to iscommand.
Since globone is called with G_IGNORE handleone() always returns a valid
pointer through Strsave. Other return cases in globone check the
validity of the pointer and return it, or create a new string via
Strsave(STRNULL).

Index: lex.c
===
RCS file: /cvs/src/bin/csh/lex.c,v
retrieving revision 1.25
diff -u -p -r1.25 lex.c
--- lex.c   30 Aug 2017 07:54:54 -  1.25
+++ lex.c   15 Sep 2018 10:41:24 -
@@ -957,7 +957,7 @@ domod(Char *cp, int type)

 case 'h':
 case 't':
-   if (!any(short2str(cp), '/'))
+   if (!strchr(short2str(cp), '/'))
return (type == 't' ? Strsave(cp) : 0);
wp = Strend(cp);
while (*--wp != '/')

This function is called from 2 other functions:

Through subword twice, which is called twice from dosub: First call
to subword is safe, because en->word is checked before calling the
function. The second call input is derived from the return of the
first call to subword and subword itself makes sure that it does not
return a NULL-pointer through Strsave.

Through setDolp is safe, because on the first iteration cp is
ensured via Strsave. Next increments are assured to have a
valid pointer, because of the break on line 754.



Re: unveil for audioctl

2018-09-17 Thread Alexandre Ratchov
On Mon, Sep 17, 2018 at 01:27:03PM +0100, Ricardo Mestre wrote:
> And of course I missed disabling unveil(2) just right the first call...
> 
> Index: audioctl.c
> ===
> RCS file: /cvs/src/usr.bin/audioctl/audioctl.c,v
> retrieving revision 1.35
> diff -u -p -u -r1.35 audioctl.c
> --- audioctl.c31 May 2017 04:18:58 -  1.35
> +++ audioctl.c17 Sep 2018 12:26:30 -
> @@ -217,6 +217,11 @@ main(int argc, char **argv)
>   argc -= optind;
>   argv += optind;
>  
> + if (unveil(path, "rw") == -1)
> + err(1, "unveil");
> + if (unveil(NULL, NULL) == -1)
> + err(1, "unveil");
> +
>   fd = open(path, O_RDWR);
>   if (fd < 0)
>   err(1, "%s", path);

looks fine, thanks.

ok ratchov



Always call bridge_iflist `bif'

2018-09-17 Thread Martin Pieuchot
I'd like to always use the same name of `bridge_iflist', it helps me
deal with the different data structures and their relation with `ifp'.

Diff below use `bif' everywhere, ok?

No intentional functional change.

Index: net/if_bridge.c
===
RCS file: /cvs/src/sys/net/if_bridge.c,v
retrieving revision 1.308
diff -u -p -r1.308 if_bridge.c
--- net/if_bridge.c 19 Apr 2018 22:31:25 -  1.308
+++ net/if_bridge.c 17 Sep 2018 13:16:16 -
@@ -233,22 +233,22 @@ bridge_clone_destroy(struct ifnet *ifp)
 }
 
 int
-bridge_delete(struct bridge_softc *sc, struct bridge_iflist *p)
+bridge_delete(struct bridge_softc *sc, struct bridge_iflist *bif)
 {
int error;
 
-   if (p->bif_flags & IFBIF_STP)
-   bstp_delete(p->bif_stp);
+   if (bif->bif_flags & IFBIF_STP)
+   bstp_delete(bif->bif_stp);
 
-   p->ifp->if_bridgeport = NULL;
-   error = ifpromisc(p->ifp, 0);
-   hook_disestablish(p->ifp->if_detachhooks, p->bif_dhcookie);
-
-   if_ih_remove(p->ifp, bridge_input, NULL);
-   TAILQ_REMOVE(>sc_iflist, p, next);
-   bridge_rtdelete(sc, p->ifp, 0);
-   bridge_flushrule(p);
-   free(p, M_DEVBUF, sizeof *p);
+   bif->ifp->if_bridgeport = NULL;
+   error = ifpromisc(bif->ifp, 0);
+   hook_disestablish(bif->ifp->if_detachhooks, bif->bif_dhcookie);
+
+   if_ih_remove(bif->ifp, bridge_input, NULL);
+   TAILQ_REMOVE(>sc_iflist, bif, next);
+   bridge_rtdelete(sc, bif->ifp, 0);
+   bridge_flushrule(bif);
+   free(bif, M_DEVBUF, sizeof *bif);
 
return (error);
 }
@@ -260,7 +260,7 @@ bridge_ioctl(struct ifnet *ifp, u_long c
struct ifbreq *req = (struct ifbreq *)data;
struct ifbropreq *brop = (struct ifbropreq *)data;
struct ifnet *ifs;
-   struct bridge_iflist *p;
+   struct bridge_iflist *bif;
struct bstp_port *bp;
struct bstp_state *bs = sc->sc_stp;
int error = 0;
@@ -284,8 +284,8 @@ bridge_ioctl(struct ifnet *ifp, u_long c
}
 
if (ifs->if_bridgeport != NULL) {
-   p = (struct bridge_iflist *)ifs->if_bridgeport;
-   if (p->bridge_sc == sc)
+   bif = (struct bridge_iflist *)ifs->if_bridgeport;
+   if (bif->bridge_sc == sc)
error = EEXIST;
else
error = EBUSY;
@@ -293,10 +293,10 @@ bridge_ioctl(struct ifnet *ifp, u_long c
}
 
/* If it's in the span list, it can't be a member. */
-   TAILQ_FOREACH(p, >sc_spanlist, next)
-   if (p->ifp == ifs)
+   TAILQ_FOREACH(bif, >sc_spanlist, next)
+   if (bif->ifp == ifs)
break;
-   if (p != NULL) {
+   if (bif != NULL) {
error = EBUSY;
break;
}
@@ -316,24 +316,24 @@ bridge_ioctl(struct ifnet *ifp, u_long c
break;
}
 
-   p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT|M_ZERO);
-   if (p == NULL) {
+   bif = malloc(sizeof(*bif), M_DEVBUF, M_NOWAIT|M_ZERO);
+   if (bif == NULL) {
if (ifs->if_type == IFT_ETHER)
ifpromisc(ifs, 0);
error = ENOMEM;
break;
}
 
-   p->bridge_sc = sc;
-   p->ifp = ifs;
-   p->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER;
-   SIMPLEQ_INIT(>bif_brlin);
-   SIMPLEQ_INIT(>bif_brlout);
-   ifs->if_bridgeport = (caddr_t)p;
-   p->bif_dhcookie = hook_establish(ifs->if_detachhooks, 0,
+   bif->bridge_sc = sc;
+   bif->ifp = ifs;
+   bif->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER;
+   SIMPLEQ_INIT(>bif_brlin);
+   SIMPLEQ_INIT(>bif_brlout);
+   ifs->if_bridgeport = (caddr_t)bif;
+   bif->bif_dhcookie = hook_establish(ifs->if_detachhooks, 0,
bridge_ifdetach, ifs);
-   if_ih_insert(p->ifp, bridge_input, NULL);
-   TAILQ_INSERT_TAIL(>sc_iflist, p, next);
+   if_ih_insert(bif->ifp, bridge_input, NULL);
+   TAILQ_INSERT_TAIL(>sc_iflist, bif, next);
break;
case SIOCBRDGDEL:
if ((error = suser(curproc)) != 0)
@@ -343,12 +343,12 @@ bridge_ioctl(struct ifnet *ifp, u_long c
error = ENOENT;
break;
}
-   p = (struct bridge_iflist *)ifs->if_bridgeport;
-   if (p == NULL || p->bridge_sc != sc) {
+   bif = (struct bridge_iflist *)ifs->if_bridgeport;
+   if (bif == NULL 

Re: Change to mailer.conf(5) man page

2018-09-17 Thread Jason McIntyre
On Sun, Sep 16, 2018 at 10:58:28PM +0100, Jason McIntyre wrote:
> On Sun, Sep 16, 2018 at 05:49:58PM -0400, Matt Schwartz wrote:
> > Yes, the comment should go as it is superfluous. Let me know if you
> > decide you want the BUGS section after all and I will re-do the patch.
> 
> thanks, but at this stage there's no need to resubmit a diff - i can
> tweak it based on any feedback.
> 
> note that i'm not proposing to remove the comment wholesale - just the part
> which lists the path to the binary.
> 
> jmc

below is the diff i propose, and will commit shortly.

i didn't remove BUGS - if there is a desire, it could be dealt with in a
separate diff. i'm unsure about its removal.

we could also add text about adding mailers from packages, but again i
think a different diff. i'm also not convinced about the merits of that.

jmc

Index: mailer.conf.5
===
RCS file: /cvs/src/usr.sbin/mailwrapper/mailer.conf.5,v
retrieving revision 1.17
diff -u -r1.17 mailer.conf.5
--- mailer.conf.5   8 Dec 2015 09:06:32 -   1.17
+++ mailer.conf.5   17 Sep 2018 13:14:17 -
@@ -78,14 +78,14 @@
 MTA suite in place of
 .Xr smtpd 8 .
 .Bd -literal
-# Execute the "real" sendmail program, named /usr/libexec/sendmail/sendmail
-sendmail   /usr/libexec/sendmail/sendmail
-send-mail  /usr/libexec/sendmail/sendmail
-mailq  /usr/libexec/sendmail/sendmail
-makemap/usr/libexec/sendmail/makemap
-newaliases /usr/libexec/sendmail/sendmail
-hoststat   /usr/libexec/sendmail/sendmail
-purgestat  /usr/libexec/sendmail/sendmail
+# Execute the "real" sendmail program
+sendmail   /usr/local/libexec/sendmail/sendmail
+send-mail  /usr/local/libexec/sendmail/sendmail
+mailq  /usr/local/libexec/sendmail/sendmail
+makemap/usr/local/libexec/sendmail/makemap
+newaliases /usr/local/libexec/sendmail/sendmail
+hoststat   /usr/local/libexec/sendmail/sendmail
+purgestat  /usr/local/libexec/sendmail/sendmail
 .Ed
 .Sh SEE ALSO
 .Xr mail 1 ,



Re: fdformat: reformat usage()

2018-09-17 Thread Jason McIntyre
On Mon, Sep 17, 2018 at 02:40:49PM +0200, Robert Klein wrote:
> > 
> > ok, so here's the diff i propose. yay? nay?
> > jmc
> > 
> > Index: fdformat.c
> > ===
> > RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
> > retrieving revision 1.22
> > diff -u -r1.22 fdformat.c
> > --- fdformat.c  16 Mar 2016 15:41:11 -  1.22
> > +++ fdformat.c  16 Sep 2018 21:46:04 -
> > @@ -132,26 +132,10 @@
> >  static void
> >  usage(void)
> >  {
> > -   printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> > gap3len] ",
> > -   __progname);
> > -   printf("[-h heads]\n");
> > -   printf("\t[-i intleave] [-r rate] [-S secshft] [-s secs]\n");
> > -   printf("\t[-t steps_per_track] device_name\n");
> > -   printf("Options:\n");
> > -   printf("\t-n\tdon't verify floppy after formatting\n");
> > -   printf("\t-q\tsuppress any normal output, don't ask for
> > confirmation\n");
> > -   printf("\t-v\tdon't format, verify only\n");
> > -   printf("\tdevname\tthe full name of floppy device or in
> > short form fd0, fd1\n");
> > -   printf("Obscure options:\n");
> > -   printf("\t-c #\tspecify number of cylinders, 40 or 80\n");
> > -   printf("\t-F #\tspecify fill byte\n");
> > -   printf("\t-g #\tspecify gap length\n");
> > -   printf("\t-h #\tspecify number of floppy heads, 1 or 2\n");
> > -   printf("\t-i #\tspecify interleave factor\n");
> > -   printf("\t-r #\tspecify data rate, 250, 300 or 500 kbps\n");
> > -   printf("\t-S #\tspecify sector size, 0=128, 1=256, 2=512
> > bytes\n");
> > -   printf("\t-s #\tspecify number of sectors per track, 9, 10,
> > 15 or 18\n");
> > -   printf("\t-t #\tnumber of steps per track\n");
> > +   printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> > gap3len] "
> > +   "[-h heads]\n"
> > +   "   [-i intleave] [-r rate] [-S secshft] [-s
> > secs]\n"
> > +   "   [-t steps_per_track] device_name\n",
> > __progname); exit(2);
> >  }
> >  
> > 
> 
> How about putting the information from ???usage??? in the rather sparse man
> page (see below)?
> 
> Best regards,
> Robert
> 

actually i'm slightly embarrassed that that didn;t occur to me. i
definitely like the idea. i reworked the diff a bit to order the
options.

so below is the diff i propose, which i'll commit shortly if no one
starts yelling.

jmc

Index: fdformat.1
===
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.1,v
retrieving revision 1.20
diff -u -r1.20 fdformat.1
--- fdformat.1  7 Jun 2018 11:37:21 -   1.20
+++ fdformat.1  17 Sep 2018 13:00:32 -
@@ -61,29 +61,43 @@
 .Nm fdformat .
 .Pp
 The options are as follows:
-.Pp
-.Bl -tag -width Ds -compact
+.Bl -tag -width Ds
+.It Fl c Ar cyls
+Number of cylinders
+.Pq 40 or 80 .
+.It Fl F Ar fillbyte
+Use
+.Ar fillbyte
+as fill byte.
+.It Fl g Ar gap3len
+Length of gap at the end of any sector
+.Pq Dq gap 3 .
+.It Fl h Ar heads
+Number of floppy heads
+.Pq 1 or 2 .
+.It Fl i Ar intleave
+Sector interleave to be used.
 .It Fl n
 Don't verify floppy after formatting.
-.Pp
 .It Fl q
 Suppress any normal output from the command, and don't ask the
 user for confirmation whether to format the floppy disk at
 .Ar device_name .
-.Pp
-.It Fl v
-Don't format; verify only.
-.Pp
-.It Fl c Ar cyls
-.It Fl F Ar fillbyte
-.It Fl g Ar gap3len
-.It Fl h Ar heads
-.It Fl i Ar intleave
 .It Fl r Ar rate
+Data transfer rate in kilobyte/sec
+.Pq 250, 300, or 500 .
 .It Fl S Ar secshft
+Sector size code: 0 for 128, 1 for 256, and 2 for 512 byte
+sectors.
 .It Fl s Ar secs
+Number of sectors per track
+.Pq 9, 10, 15, or 18 .
 .It Fl t Ar steps_per_track
-An alternate method to specify the geometry data to write to the floppy disk.
+Number of steps per track.
+An alternate method to specify the
+geometry data to write to the floppy disk.
+.It Fl v
+Don't format; verify only.
 .El
 .Pp
 If the
Index: fdformat.c
===
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
retrieving revision 1.22
diff -u -r1.22 fdformat.c
--- fdformat.c  16 Mar 2016 15:41:11 -  1.22
+++ fdformat.c  17 Sep 2018 13:00:32 -
@@ -132,26 +132,10 @@
 static void
 usage(void)
 {
-   printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g gap3len] ",
-   __progname);
-   printf("[-h heads]\n");
-   printf("\t[-i intleave] [-r rate] [-S secshft] [-s secs]\n");
-   printf("\t[-t steps_per_track] device_name\n");
-   printf("Options:\n");
-   printf("\t-n\tdon't verify floppy after formatting\n");
-   printf("\t-q\tsuppress any normal output, don't ask for 
confirmation\n");
-   printf("\t-v\tdon't format, verify only\n");
-   printf("\tdevname\tthe full name of floppy device or in short form fd0, 
fd1\n");
-   printf("Obscure options:\n");
-   printf("\t-c #\tspecify number of cylinders, 40 or 80\n");
-   printf("\t-F #\tspecify fill byte\n");
-   

Re: fdformat: reformat usage()

2018-09-17 Thread Robert Klein
(sorry, if this turns up twice, first attempt didn't show up for a
couple of hours; updated doc patch below)

 On Sun, 16 Sep 2018 22:48:01 +0100
Jason McIntyre  wrote:

> On Wed, Sep 12, 2018 at 05:40:49PM +0100, Jason McIntyre wrote:
> > On Wed, Sep 12, 2018 at 11:50:18AM +0200, Sascha Paunovic wrote:  
> > > Since C99, string literal concatenation is provided, allowing the
> > > number of printf() calls to be greatly reduced (20 -> 1).
> > > 
> > > This is my first diff I'm sending, feedback would be very
> > > appreciated. 
> > 
> > hi.
> > 
> > i'm all for the diff but... generally usage() does not spit out a
> > description of the options (with some exceptions). if you look at
> > the man page, the irony is that the usage seems more verbose.
> > 
> > anyone object to removing the list that follows the synopsis? if
> > not, i'd prefer that.
> > 
> > unrelated question: anyone know why the argument to -g is "gap3len"?
> > 
> > jmc
> >   
> 
> ok, so here's the diff i propose. yay? nay?
> jmc
> 
> Index: fdformat.c
> ===
> RCS file: /cvs/src/usr.sbin/fdformat/fdformat.c,v
> retrieving revision 1.22
> diff -u -r1.22 fdformat.c
> --- fdformat.c16 Mar 2016 15:41:11 -  1.22
> +++ fdformat.c16 Sep 2018 21:46:04 -
> @@ -132,26 +132,10 @@
>  static void
>  usage(void)
>  {
> - printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> gap3len] ",
> - __progname);
> - printf("[-h heads]\n");
> - printf("\t[-i intleave] [-r rate] [-S secshft] [-s secs]\n");
> - printf("\t[-t steps_per_track] device_name\n");
> - printf("Options:\n");
> - printf("\t-n\tdon't verify floppy after formatting\n");
> - printf("\t-q\tsuppress any normal output, don't ask for
> confirmation\n");
> - printf("\t-v\tdon't format, verify only\n");
> - printf("\tdevname\tthe full name of floppy device or in
> short form fd0, fd1\n");
> - printf("Obscure options:\n");
> - printf("\t-c #\tspecify number of cylinders, 40 or 80\n");
> - printf("\t-F #\tspecify fill byte\n");
> - printf("\t-g #\tspecify gap length\n");
> - printf("\t-h #\tspecify number of floppy heads, 1 or 2\n");
> - printf("\t-i #\tspecify interleave factor\n");
> - printf("\t-r #\tspecify data rate, 250, 300 or 500 kbps\n");
> - printf("\t-S #\tspecify sector size, 0=128, 1=256, 2=512
> bytes\n");
> - printf("\t-s #\tspecify number of sectors per track, 9, 10,
> 15 or 18\n");
> - printf("\t-t #\tnumber of steps per track\n");
> + printf("usage: %s [-nqv] [-c cyls] [-F fillbyte] [-g
> gap3len] "
> + "[-h heads]\n"
> + "   [-i intleave] [-r rate] [-S secshft] [-s
> secs]\n"
> + "   [-t steps_per_track] device_name\n",
> __progname); exit(2);
>  }
>  
> 

How about putting the information from “usage” in the rather sparse man
page (see below)?

Best regards,
Robert


Index: usr.sbin/fdformat/fdformat.1
===
RCS file: /cvs/src/usr.sbin/fdformat/fdformat.1,v
retrieving revision 1.19
diff -u -p -r1.19 fdformat.1
--- usr.sbin/fdformat/fdformat.18 Jan 2017 01:32:02 -   1.19
+++ usr.sbin/fdformat/fdformat.117 Sep 2018 10:00:23 -
@@ -61,29 +61,43 @@ are meaningless, since they're overridde
 .Nm fdformat .
 .Pp
 The options are as follows:
-.Pp
-.Bl -tag -width Ds -compact
+.Bl -tag -width Ds
 .It Fl n
 Don't verify floppy after formatting.
-.Pp
 .It Fl q
 Suppress any normal output from the command, and don't ask the
 user for confirmation whether to format the floppy disk at
 .Ar device_name .
-.Pp
 .It Fl v
 Don't format; verify only.
-.Pp
 .It Fl c Ar cyls
+Number of cylinders
+.Pq 40 or 80 .
 .It Fl F Ar fillbyte
+Use
+.Ar fillbyte
+as fill byte.
 .It Fl g Ar gap3len
+Length of gap at the end of any sector
+.Pq Dq gap 3 .
 .It Fl h Ar heads
+Number of floppy heads
+.Pq 1 or 2 .
 .It Fl i Ar intleave
+Sector interleave to be used.
 .It Fl r Ar rate
+Data transfer rate in kilobyte/sec
+.Pq 250, 300, or 500 .
 .It Fl S Ar secshft
+Sector size code: 0 for 128, 1 for 256, and 2 for 512 byte
+sectors.
 .It Fl s Ar secs
+Number of sectors per track
+.Pq 9, 10, 15, or 18 .
 .It Fl t Ar steps_per_track
-An alternate method to specify the geometry data to write to the floppy disk.
+Number of steps per track.
+An alternate method to specify the
+geometry data to write to the floppy disk.
 .El
 .Pp
 If the



Re: unveil for audioctl

2018-09-17 Thread Ricardo Mestre
And of course I missed disabling unveil(2) just right the first call...

Index: audioctl.c
===
RCS file: /cvs/src/usr.bin/audioctl/audioctl.c,v
retrieving revision 1.35
diff -u -p -u -r1.35 audioctl.c
--- audioctl.c  31 May 2017 04:18:58 -  1.35
+++ audioctl.c  17 Sep 2018 12:26:30 -
@@ -217,6 +217,11 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
 
+   if (unveil(path, "rw") == -1)
+   err(1, "unveil");
+   if (unveil(NULL, NULL) == -1)
+   err(1, "unveil");
+
fd = open(path, O_RDWR);
if (fd < 0)
err(1, "%s", path);

On 13:22 Mon 17 Sep , Ricardo Mestre wrote:
> Hi,
> 
> This adds unveil(2) to audioctl(1) which only needs rw to the access control
> device, which by default is /dev/audioctl0, but can be manipulated via args.
> 
> OK?
> 



unveil for audioctl

2018-09-17 Thread Ricardo Mestre
Hi,

This adds unveil(2) to audioctl(1) which only needs rw to the access control
device, which by default is /dev/audioctl0, but can be manipulated via args.

OK?

Index: audioctl.c
===
RCS file: /cvs/src/usr.bin/audioctl/audioctl.c,v
retrieving revision 1.35
diff -u -p -u -r1.35 audioctl.c
--- audioctl.c  31 May 2017 04:18:58 -  1.35
+++ audioctl.c  17 Sep 2018 12:16:03 -
@@ -217,6 +217,9 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
 
+   if (unveil(path, "rw") == -1)
+   err(1, "unveil");
+
fd = open(path, O_RDWR);
if (fd < 0)
err(1, "%s", path);



fix memory leak in ieee80211_end_scan()

2018-09-17 Thread Ricardo Mestre
Hi,

This plugs a resource leak in ieee80211_end_scan() when background scanning
support was added to iwn(4). Noticed by Coverity ID 1473310.

OK?

Index: ieee80211_node.c
===
RCS file: /cvs/src/sys/net80211/ieee80211_node.c,v
retrieving revision 1.151
diff -u -p -u -r1.151 ieee80211_node.c
--- ieee80211_node.c17 Sep 2018 02:34:16 -  1.151
+++ ieee80211_node.c17 Sep 2018 09:24:34 -
@@ -1376,6 +1376,7 @@ ieee80211_end_scan(struct ifnet *ifp)
IEEE80211_FC0_SUBTYPE_DEAUTH,
IEEE80211_REASON_AUTH_LEAVE) != 0) {
ic->ic_flags &= ~IEEE80211_F_BGSCAN;
+   free(arg, M_DEVBUF, sizeof(*arg));
return;
}
 



[patch] Use the same backlog parameter for listen() function in netcat.c

2018-09-17 Thread Nan Xiao
Hi tech@,

Since netcat can only process one connection at one time, maybe
UNIX-domain socket can use the same backlog parameter for listen()
function as network socket, thanks!

diff --git netcat.c netcat.c
index 341e7e5..b6fd199 100644
--- netcat.c
+++ netcat.c
@@ -894,7 +894,7 @@ unix_listen(char *path)
if ((s = unix_bind(path, 0)) < 0)
return -1;

-   if (listen(s, 5) < 0) {
+   if (listen(s, 1) < 0) {
close(s);
return -1;
}
-- 
Best Regards
Nan Xiao