Re: mg(1) tell make-backup-files is on by default

2019-11-08 Thread Sebastian Benoit
Solene Rapenne(sol...@perso.pw) on 2019.11.08 18:39:20 +0100:
> Someone on reddit had issue with this config file, there was no backup
> file, in file directory or in ~/.mg.d
> 
> make-backup-files
> backup-to-home-directory
> 
> in fact, having "make-backup-files" disables backups.
> 
> 
> I've looked at the mg logic for backup files and I could sort that the
> default make-backup-files value is 0
> 
> /funmap.c: {makebkfile, "make-backup-files", 0},

No, that 0 is not the default. The line defines a command
'make-backup-files' (that can be given in the config file, but also with
"Meta-x make-backup-files"). The 0 indicates to the command parser that
this command does not take a argument, i.e. is a "toggle". When the command
is given, the makebkfile() is called.

> but in file.c there is a statement with a default to TRUE
> 
>  * Save the contents of the current buffer back into its associated
>  * file.
>   */
>   static int  makebackup = TRUE;
> 
> 
> I don't really get the logic here, nor when the configuration file and
> that TRUE variable get in touch.

in the file.c function makebkfile() which modifies the static variable
makebackup.

So yes, the default is TRUE and the command make-backup-files changes the
variable makebackup in makebkfile():

makebackup = !makebackup;

> What I propose is to update the manual that make-backup-files is true by
> default, so toggling it disable backups.

I think that is the correct sollution. ok benno@
 
> Index: mg.1
> ===
> RCS file: /data/cvs/src/usr.bin/mg/mg.1,v
> retrieving revision 1.117
> diff -u -p -r1.117 mg.1
> --- mg.1  2 Jul 2019 16:25:39 -   1.117
> +++ mg.1  8 Nov 2019 17:16:47 -
> @@ -688,6 +688,7 @@ Bind a key mapping in the local (topmost
>  Unbind a key mapping in the local (topmost) mode.
>  .It make-backup-files
>  Toggle generation of backup files.
> +Enabled by default.
>  .It make-directory
>  Prompt the user for a path or directory name which is then created.
>  .It mark-paragraph
> 



Re: upgrade66.html missing acme-client.conf staging api url change

2019-11-08 Thread Sebastian Benoit
Solene Rapenne(sol...@perso.pw) on 2019.11.08 18:13:40 +0100:
> The staging api changed too. I know people who did not update that url,
> it's not especially obvious because the old url doesn't contain v01.
> 
> ok ?

Nice! I actually wondered about that and my google foo was too low.
Thanks for fixing it. ok benno@

> 
> Index: upgrade66.html
> ===
> RCS file: /data/cvs/www/faq/upgrade66.html,v
> retrieving revision 1.15
> diff -u -p -r1.15 upgrade66.html
> --- upgrade66.html30 Oct 2019 04:11:00 -  1.15
> +++ upgrade66.html8 Nov 2019 17:12:01 -
> @@ -147,6 +147,14 @@ any post-release fixes.
>
>https://acme-v02.api.letsencrypt.org/directory
> +  The staging api url should also be changed from
> +  
> +  https://acme-staging.api.letsencrypt.org/directory
> +  to
> +  
> +  https://acme-staging-v02.api.letsencrypt.org/directory
>
>The -A and -D flags have been removed from
>https://man.openbsd.org/OpenBSD-6.6/acme-client.1;>
> 



mg(1) tell make-backup-files is on by default

2019-11-08 Thread Solene Rapenne
Someone on reddit had issue with this config file, there was no backup
file, in file directory or in ~/.mg.d

make-backup-files
backup-to-home-directory

in fact, having "make-backup-files" disables backups.


I've looked at the mg logic for backup files and I could sort that the
default make-backup-files value is 0

/funmap.c: {makebkfile, "make-backup-files", 0},

but in file.c there is a statement with a default to TRUE

 * Save the contents of the current buffer back into its associated
 * file.
  */
  static int  makebackup = TRUE;


I don't really get the logic here, nor when the configuration file and
that TRUE variable get in touch.

What I propose is to update the manual that make-backup-files is true by
default, so toggling it disable backups.


Index: mg.1
===
RCS file: /data/cvs/src/usr.bin/mg/mg.1,v
retrieving revision 1.117
diff -u -p -r1.117 mg.1
--- mg.12 Jul 2019 16:25:39 -   1.117
+++ mg.18 Nov 2019 17:16:47 -
@@ -688,6 +688,7 @@ Bind a key mapping in the local (topmost
 Unbind a key mapping in the local (topmost) mode.
 .It make-backup-files
 Toggle generation of backup files.
+Enabled by default.
 .It make-directory
 Prompt the user for a path or directory name which is then created.
 .It mark-paragraph



Re: iwm: support more than one frame per interrupt

2019-11-08 Thread Stefan Sperling
On Fri, Nov 08, 2019 at 07:15:18PM +0200, Stefan Sperling wrote:
> On Fri, Nov 08, 2019 at 07:13:17PM +0200, Stefan Sperling wrote:
> > Previous versions of this diff included monitor mode support. I have 
> > stripped
> > this out for now and I am looking for stability tests in client mode only.
> > If this diff passes through testing this time around, adding monitor mode
> > on top will be easy.
> 
> Sorry, I made a mistake when splitting the diff. The diff I sent doesn't 
> build.
> I will post a new one shortly.

Fixed diff.

diff aa91687117b06dc9f357920a56ef1a22c0de6a7e 
16cec9db4484c7e9e6fa4838707a4c0c7ba2f314
blob - f7449f560623517dfa1b3fbe6d55b10a5494e26c
blob + 0d5f766801f75e839476ebc2393568ed31494e62
--- sys/dev/pci/if_iwm.c
+++ sys/dev/pci/if_iwm.c
@@ -366,8 +366,10 @@ intiwm_get_signal_strength(struct iwm_softc *, 
struct
 void   iwm_rx_rx_phy_cmd(struct iwm_softc *, struct iwm_rx_packet *,
struct iwm_rx_data *);
 intiwm_get_noise(const struct iwm_statistics_rx_non_phy *);
-void   iwm_rx_rx_mpdu(struct iwm_softc *, struct iwm_rx_packet *,
-   struct iwm_rx_data *, struct mbuf_list *);
+intiwm_rx_frame(struct iwm_softc *, struct mbuf *, uint32_t,
+   struct mbuf_list *);
+intiwm_ccmp_decap(struct iwm_softc *, struct mbuf *,
+   struct ieee80211_node *);
 void   iwm_enable_ht_cck_fallback(struct iwm_softc *, struct iwm_node *);
 void   iwm_rx_tx_cmd_single(struct iwm_softc *, struct iwm_rx_packet *,
struct iwm_node *);
@@ -472,6 +474,11 @@ const char *iwm_desc_lookup(uint32_t);
 void   iwm_nic_error(struct iwm_softc *);
 void   iwm_nic_umac_error(struct iwm_softc *);
 #endif
+void   iwm_rx_mpdu(struct iwm_softc *, struct mbuf *, size_t,
+   struct mbuf_list *);
+intiwm_rx_pkt_valid(struct iwm_rx_packet *);
+void   iwm_rx_pkt(struct iwm_softc *, struct iwm_rx_data *,
+   struct mbuf_list *);
 void   iwm_notif_intr(struct iwm_softc *);
 intiwm_intr(void *);
 intiwm_match(struct device *, void *, void *);
@@ -1807,7 +1814,6 @@ iwm_nic_rx_init(struct iwm_softc *sc)
IWM_FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL|
IWM_FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY   |  /* HW bug */
IWM_FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL   |
-   IWM_FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK|
(IWM_RX_RB_TIMEOUT << IWM_FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) |
IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K|
IWM_RX_QUEUE_SIZE_LOG << IWM_FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS);
@@ -3539,56 +3545,24 @@ iwm_get_noise(const struct iwm_statistics_rx_non_phy *
return (nbant == 0) ? -127 : (total / nbant) - 107;
 }
 
-void
-iwm_rx_rx_mpdu(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
-struct iwm_rx_data *data, struct mbuf_list *ml)
+int
+iwm_rx_frame(struct iwm_softc *sc, struct mbuf *m, uint32_t rx_pkt_status,
+struct mbuf_list *ml)
 {
struct ieee80211com *ic = >sc_ic;
struct ieee80211_frame *wh;
struct ieee80211_node *ni;
struct ieee80211_rxinfo rxi;
struct ieee80211_channel *bss_chan;
-   struct mbuf *m;
struct iwm_rx_phy_info *phy_info;
-   struct iwm_rx_mpdu_res_start *rx_res;
int device_timestamp;
-   uint32_t len;
-   uint32_t rx_pkt_status;
int rssi, chanidx;
uint8_t saved_bssid[IEEE80211_ADDR_LEN] = { 0 };
 
-   bus_dmamap_sync(sc->sc_dmat, data->map, 0, IWM_RBUF_SIZE,
-   BUS_DMASYNC_POSTREAD);
-
phy_info = >sc_last_phy_info;
-   rx_res = (struct iwm_rx_mpdu_res_start *)pkt->data;
-   wh = (struct ieee80211_frame *)(pkt->data + sizeof(*rx_res));
-   len = le16toh(rx_res->byte_count);
-   if (len < IEEE80211_MIN_LEN) {
-   ic->ic_stats.is_rx_tooshort++;
-   IC2IFP(ic)->if_ierrors++;
-   return;
-   }
-   if (len > IWM_RBUF_SIZE - sizeof(*rx_res)) {
-   IC2IFP(ic)->if_ierrors++;
-   return;
-   }
-   rx_pkt_status = le32toh(*(uint32_t *)(pkt->data +
-   sizeof(*rx_res) + len));
-
if (__predict_false(phy_info->cfg_phy_cnt > 20))
-   return;
+   return EINVAL;
 
-   if (!(rx_pkt_status & IWM_RX_MPDU_RES_STATUS_CRC_OK) ||
-   !(rx_pkt_status & IWM_RX_MPDU_RES_STATUS_OVERRUN_OK))
-   return; /* drop */
-
-   m = data->m;
-   if (iwm_rx_addbuf(sc, IWM_RBUF_SIZE, sc->rxq.cur) != 0)
-   return;
-   m->m_data = pkt->data + sizeof(*rx_res);
-   m->m_pkthdr.len = m->m_len = len;
-
device_timestamp = le32toh(phy_info->system_timestamp);
 
rssi = iwm_get_signal_strength(sc, phy_info);
@@ -3599,6 +3573,7 @@ iwm_rx_rx_mpdu(struct iwm_softc *sc, struct iwm_rx_pac
if (chanidx < 0 || chanidx >= nitems(ic->ic_channels))  
chanidx = ieee80211_chan2ieee(ic, ic->ic_ibss_chan);
 
+   wh = mtod(m, struct 

Re: iwm: support more than one frame per interrupt

2019-11-08 Thread Stefan Sperling
On Fri, Nov 08, 2019 at 07:13:17PM +0200, Stefan Sperling wrote:
> Previous versions of this diff included monitor mode support. I have stripped
> this out for now and I am looking for stability tests in client mode only.
> If this diff passes through testing this time around, adding monitor mode
> on top will be easy.

Sorry, I made a mistake when splitting the diff. The diff I sent doesn't build.
I will post a new one shortly.



iwm: support more than one frame per interrupt

2019-11-08 Thread Stefan Sperling
This adds support for receiving more than one frame per interrupt to iwm(4).
There have been several past attempts at this already, all of which failed
due to stability issues found during testing.

Previous versions of this diff included monitor mode support. I have stripped
this out for now and I am looking for stability tests in client mode only.
If this diff passes through testing this time around, adding monitor mode
on top will be easy.

Please update your tree before applying this and make sure your iwm device
is using either -17 or -34 firmware.
 
diff aa91687117b06dc9f357920a56ef1a22c0de6a7e 
662ed8a1ce51441cd90dfc355f27a6814968d0b9
blob - f7449f560623517dfa1b3fbe6d55b10a5494e26c
blob + 3fef13e8baf3c1564493717b3cf7750447faba4e
--- sys/dev/pci/if_iwm.c
+++ sys/dev/pci/if_iwm.c
@@ -366,8 +366,10 @@ intiwm_get_signal_strength(struct iwm_softc *, 
struct
 void   iwm_rx_rx_phy_cmd(struct iwm_softc *, struct iwm_rx_packet *,
struct iwm_rx_data *);
 intiwm_get_noise(const struct iwm_statistics_rx_non_phy *);
-void   iwm_rx_rx_mpdu(struct iwm_softc *, struct iwm_rx_packet *,
-   struct iwm_rx_data *, struct mbuf_list *);
+intiwm_rx_frame(struct iwm_softc *, struct mbuf *, uint32_t,
+   struct mbuf_list *);
+intiwm_ccmp_decap(struct iwm_softc *, struct mbuf *,
+   struct ieee80211_node *);
 void   iwm_enable_ht_cck_fallback(struct iwm_softc *, struct iwm_node *);
 void   iwm_rx_tx_cmd_single(struct iwm_softc *, struct iwm_rx_packet *,
struct iwm_node *);
@@ -428,7 +430,7 @@ uint8_t iwm_ridx2rate(struct ieee80211_rateset *, int)
 intiwm_rval2ridx(int);
 void   iwm_ack_rates(struct iwm_softc *, struct iwm_node *, int *, int *);
 void   iwm_mac_ctxt_cmd_common(struct iwm_softc *, struct iwm_node *,
-   struct iwm_mac_ctx_cmd *, uint32_t, int);
+   struct iwm_mac_ctx_cmd *, uint32_t);
 void   iwm_mac_ctxt_cmd_fill_sta(struct iwm_softc *, struct iwm_node *,
struct iwm_mac_data_sta *, int);
 intiwm_mac_ctxt_cmd(struct iwm_softc *, struct iwm_node *, uint32_t, int);
@@ -472,6 +474,11 @@ const char *iwm_desc_lookup(uint32_t);
 void   iwm_nic_error(struct iwm_softc *);
 void   iwm_nic_umac_error(struct iwm_softc *);
 #endif
+void   iwm_rx_mpdu(struct iwm_softc *, struct mbuf *, size_t,
+   struct mbuf_list *);
+intiwm_rx_pkt_valid(struct iwm_rx_packet *);
+void   iwm_rx_pkt(struct iwm_softc *, struct iwm_rx_data *,
+   struct mbuf_list *);
 void   iwm_notif_intr(struct iwm_softc *);
 intiwm_intr(void *);
 intiwm_match(struct device *, void *, void *);
@@ -1807,7 +1814,6 @@ iwm_nic_rx_init(struct iwm_softc *sc)
IWM_FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL|
IWM_FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY   |  /* HW bug */
IWM_FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL   |
-   IWM_FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK|
(IWM_RX_RB_TIMEOUT << IWM_FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) |
IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K|
IWM_RX_QUEUE_SIZE_LOG << IWM_FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS);
@@ -3539,56 +3545,24 @@ iwm_get_noise(const struct iwm_statistics_rx_non_phy *
return (nbant == 0) ? -127 : (total / nbant) - 107;
 }
 
-void
-iwm_rx_rx_mpdu(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
-struct iwm_rx_data *data, struct mbuf_list *ml)
+int
+iwm_rx_frame(struct iwm_softc *sc, struct mbuf *m, uint32_t rx_pkt_status,
+struct mbuf_list *ml)
 {
struct ieee80211com *ic = >sc_ic;
struct ieee80211_frame *wh;
struct ieee80211_node *ni;
struct ieee80211_rxinfo rxi;
struct ieee80211_channel *bss_chan;
-   struct mbuf *m;
struct iwm_rx_phy_info *phy_info;
-   struct iwm_rx_mpdu_res_start *rx_res;
int device_timestamp;
-   uint32_t len;
-   uint32_t rx_pkt_status;
int rssi, chanidx;
uint8_t saved_bssid[IEEE80211_ADDR_LEN] = { 0 };
 
-   bus_dmamap_sync(sc->sc_dmat, data->map, 0, IWM_RBUF_SIZE,
-   BUS_DMASYNC_POSTREAD);
-
phy_info = >sc_last_phy_info;
-   rx_res = (struct iwm_rx_mpdu_res_start *)pkt->data;
-   wh = (struct ieee80211_frame *)(pkt->data + sizeof(*rx_res));
-   len = le16toh(rx_res->byte_count);
-   if (len < IEEE80211_MIN_LEN) {
-   ic->ic_stats.is_rx_tooshort++;
-   IC2IFP(ic)->if_ierrors++;
-   return;
-   }
-   if (len > IWM_RBUF_SIZE - sizeof(*rx_res)) {
-   IC2IFP(ic)->if_ierrors++;
-   return;
-   }
-   rx_pkt_status = le32toh(*(uint32_t *)(pkt->data +
-   sizeof(*rx_res) + len));
-
if (__predict_false(phy_info->cfg_phy_cnt > 20))
-   return;
+   return EINVAL;
 
-   if (!(rx_pkt_status & IWM_RX_MPDU_RES_STATUS_CRC_OK) ||
-   !(rx_pkt_status & IWM_RX_MPDU_RES_STATUS_OVERRUN_OK))
-   

upgrade66.html missing acme-client.conf staging api url change

2019-11-08 Thread Solene Rapenne
The staging api changed too. I know people who did not update that url,
it's not especially obvious because the old url doesn't contain v01.

ok ?

Index: upgrade66.html
===
RCS file: /data/cvs/www/faq/upgrade66.html,v
retrieving revision 1.15
diff -u -p -r1.15 upgrade66.html
--- upgrade66.html  30 Oct 2019 04:11:00 -  1.15
+++ upgrade66.html  8 Nov 2019 17:12:01 -
@@ -147,6 +147,14 @@ any post-release fixes.
   
   https://acme-v02.api.letsencrypt.org/directory
+  The staging api url should also be changed from
+  
+  https://acme-staging.api.letsencrypt.org/directory
+  to
+  
+  https://acme-staging-v02.api.letsencrypt.org/directory
   
   The -A and -D flags have been removed from
   https://man.openbsd.org/OpenBSD-6.6/acme-client.1;>



Re: vm_map_assert_{un,}locked()

2019-11-08 Thread Martin Pieuchot
On 08/11/19(Fri) 17:28, Martin Pieuchot wrote:
> Current UVM code uses comments to explains when a `map' should be locked
> or unlocked.
> 
> The diff below introduces functions to check those assertions and start
> to use them in two safe places.  This also has the advantage of self-
> documenting the code, so fewer comments.
> 
> While here move the definition of uvm_map_is_stack_remappable() to its
> C file.

Now with the correct diff, ok?

Index: uvm/uvm_map.c
===
RCS file: /cvs/src/sys/uvm/uvm_map.c,v
retrieving revision 1.250
diff -u -p -r1.250 uvm_map.c
--- uvm/uvm_map.c   2 Nov 2019 16:41:57 -   1.250
+++ uvm/uvm_map.c   8 Nov 2019 16:42:05 -
@@ -157,6 +157,8 @@ int  uvm_map_findspace(struct vm_map*,
vaddr_t);
 vsize_t uvm_map_addr_augment_get(struct vm_map_entry*);
 voiduvm_map_addr_augment(struct vm_map_entry*);
+boolean_t   uvm_map_is_stack_remappable(vm_map_t, vaddr_t,
+vsize_t);
 
 int uvm_map_inentry_recheck(u_long, vaddr_t,
 struct p_inentry *);
@@ -1124,7 +1119,6 @@ out:
  * uvm_map: establish a valid mapping in map
  *
  * => *addr and sz must be a multiple of PAGE_SIZE.
- * => map must be unlocked.
  * =>  value meanings (4 cases):
  * [1]   == uoffset is a hint for PMAP_PREFER
  * [2]== don't PMAP_PREFER
@@ -1157,6 +1151,7 @@ uvm_map(struct vm_map *map, vaddr_t *add
splassert(IPL_NONE);
else
splassert(IPL_VM);
+   vm_map_assert_unlocked(map);
 
/*
 * We use pmap_align and pmap_offset as alignment and offset variables.
@@ -1889,8 +1884,6 @@ uvm_map_inentry(struct proc *p, struct p
 /*
  * Check whether the given address range can be converted to a MAP_STACK
  * mapping.
- *
- * Must be called with map locked.
  */
 boolean_t
 uvm_map_is_stack_remappable(struct vm_map *map, vaddr_t addr, vaddr_t sz)
@@ -1898,6 +1891,8 @@ uvm_map_is_stack_remappable(struct vm_ma
vaddr_t end = addr + sz;
struct vm_map_entry *first, *iter, *prev = NULL;
 
+   vm_map_assert_locked(map);
+
if (!uvm_map_lookup_entry(map, addr, )) {
printf("map stack 0x%lx-0x%lx of map %p failed: no mapping\n",
addr, end, map);
@@ -5442,6 +5437,30 @@ vm_map_unbusy_ln(struct vm_map *map, cha
mtx_leave(>flags_lock);
if (oflags & VM_MAP_WANTLOCK)
wakeup(>flags);
+}
+
+void
+vm_map_assert_locked_ln(struct vm_map *map, char *file, int line)
+{
+   if ((map->flags & VM_MAP_INTRSAFE) == 0)
+   rw_assert_anylock(>lock);
+   else
+   MUTEX_ASSERT_LOCKED(>mtx);
+   LPRINTF(("map locked: %p (at %s %d)\n", map, file, line));
+   uvm_tree_sanity(map, file, line);
+   uvm_tree_size_chk(map, file, line);
+}
+
+void
+vm_map_assert_unlocked_ln(struct vm_map *map, char *file, int line)
+{
+   if ((map->flags & VM_MAP_INTRSAFE) == 0)
+   rw_assert_unlocked(>lock);
+   else
+   MUTEX_ASSERT_UNLOCKED(>mtx);
+   LPRINTF(("map unlckd: %p (at %s %d)\n", map, file, line));
+   uvm_tree_sanity(map, file, line);
+   uvm_tree_size_chk(map, file, line);
 }
 
 #ifndef SMALL_KERNEL
Index: uvm/uvm_map.h
===
RCS file: /cvs/src/sys/uvm/uvm_map.h,v
retrieving revision 1.64
diff -u -p -r1.64 uvm_map.h
--- uvm/uvm_map.h   2 Nov 2019 09:36:08 -   1.64
+++ uvm/uvm_map.h   8 Nov 2019 16:42:05 -
@@ -399,7 +399,6 @@ int uvm_map_inherit(vm_map_t, vaddr_t, 
 intuvm_map_advice(vm_map_t, vaddr_t, vaddr_t, int);
 void   uvm_map_init(void);
 boolean_t  uvm_map_lookup_entry(vm_map_t, vaddr_t, vm_map_entry_t *);
-boolean_t  uvm_map_is_stack_remappable(vm_map_t, vaddr_t, vsize_t);
 intuvm_map_remap_as_stack(struct proc *, vaddr_t, vsize_t);
 intuvm_map_replace(vm_map_t, vaddr_t, vaddr_t,
vm_map_entry_t, int);
@@ -473,6 +472,8 @@ voidvm_map_downgrade_ln(struct vm_map*
 void   vm_map_upgrade_ln(struct vm_map*, char*, int);
 void   vm_map_busy_ln(struct vm_map*, char*, int);
 void   vm_map_unbusy_ln(struct vm_map*, char*, int);
+void   vm_map_assert_locked_ln(struct vm_map*, char*, int);
+void   vm_map_assert_unlocked_ln(struct vm_map*, char*, int);
 
 #ifdef DIAGNOSTIC
 #define vm_map_lock_try(map)   vm_map_lock_try_ln(map, __FILE__, __LINE__)
@@ -484,6 +485,10 @@ void   vm_map_unbusy_ln(struct vm_map*, c
 #define vm_map_upgrade(map)vm_map_upgrade_ln(map, __FILE__, __LINE__)
 #define vm_map_busy(map)   vm_map_busy_ln(map, __FILE__, __LINE__)
 #define vm_map_unbusy(map) vm_map_unbusy_ln(map, __FILE__, __LINE__)
+#define 

Re: net80211: do not connect to any open network by default

2019-11-08 Thread Theo de Raadt
Stefan Sperling  wrote:

>  .Cm join .
>  .It Cm -nwid
> -Set the NWID to the empty string to allow the interface to connect
> -to any available access point.
> +Clear the currently configured network ID.


I don't understand.  You are assuming that sentence will have obvious
consequences for users?



Re: net80211: do not connect to any open network by default

2019-11-08 Thread Stefan Sperling
On Fri, Nov 08, 2019 at 04:28:23PM +, Stuart Henderson wrote:
> On 2019/11/08 17:56, Stefan Sperling wrote:
> > The default wifi interface behaviour of connecting to any open network
> > when nothing is configured is confusing people who have gotten used to
> > the behaviour of ifconfig join.
> > 
> > With this diff connecting to any open network on 'ifconfg iwm0 up' requires
> > the user to run ifconfig iwm0 join "" first. Otherwise, only explicitly
> > configured network SSIDs will be used.
> > 
> > This also allows users to scan for available access points without sending
> > out probe, auth, or association requests to random accces points.
> > 
> > ok?
> 
> OK with me.  ifconfig(8) will need an update, but I think this is probably 
> enough.

Yes, indeed. This is what I had in mind for the man page:

diff a9ff202383120429722310361b939682fdaf8f03 /usr/src
blob - 79a5adcd2197d91d9780f29a2c97a091b9177389
file + sbin/ifconfig/ifconfig.8
--- sbin/ifconfig/ifconfig.8
+++ sbin/ifconfig/ifconfig.8
@@ -1044,13 +1044,11 @@ Connect to the network with NWID
 .Ar id .
 Unlike auto-join networks,
 information about the network is not retained.
-The empty string allows the interface to connect to any available
-access points.
+Only one network can be configured at a time.
 May not be used with
 .Cm join .
 .It Cm -nwid
-Set the NWID to the empty string to allow the interface to connect
-to any available access point.
+Clear the currently configured network ID.
 .It Cm nwkey Ar key
 Enable WEP encryption using the specified
 .Ar key .



vm_map_assert_{un,}locked()

2019-11-08 Thread Martin Pieuchot
Current UVM code uses comments to explains when a `map' should be locked
or unlocked.

The diff below introduces functions to check those assertions and start
to use them in two safe places.  This also has the advantage of self-
documenting the code, so fewer comments.

While here move the definition of uvm_map_is_stack_remappable() to its
C file.

Ok?

Index: uvm/uvm_map.c
===
RCS file: /cvs/src/sys/uvm/uvm_map.c,v
retrieving revision 1.250
diff -u -p -r1.250 uvm_map.c
--- uvm/uvm_map.c   2 Nov 2019 16:41:57 -   1.250
+++ uvm/uvm_map.c   8 Nov 2019 16:10:16 -
@@ -157,6 +157,8 @@ int  uvm_map_findspace(struct vm_map*,
vaddr_t);
 vsize_t uvm_map_addr_augment_get(struct vm_map_entry*);
 voiduvm_map_addr_augment(struct vm_map_entry*);
+boolean_t   uvm_map_is_stack_remappable(vm_map_t, vaddr_t,
+vsize_t);
 
 int uvm_map_inentry_recheck(u_long, vaddr_t,
 struct p_inentry *);
@@ -1124,7 +1126,6 @@ out:
  * uvm_map: establish a valid mapping in map
  *
  * => *addr and sz must be a multiple of PAGE_SIZE.
- * => map must be unlocked.
  * =>  value meanings (4 cases):
  * [1]   == uoffset is a hint for PMAP_PREFER
  * [2]== don't PMAP_PREFER
@@ -1157,6 +1158,7 @@ uvm_map(struct vm_map *map, vaddr_t *add
splassert(IPL_NONE);
else
splassert(IPL_VM);
+   vm_map_assert_unlocked(map);
 
/*
 * We use pmap_align and pmap_offset as alignment and offset variables.
@@ -1889,8 +1891,6 @@ uvm_map_inentry(struct proc *p, struct p
 /*
  * Check whether the given address range can be converted to a MAP_STACK
  * mapping.
- *
- * Must be called with map locked.
  */
 boolean_t
 uvm_map_is_stack_remappable(struct vm_map *map, vaddr_t addr, vaddr_t sz)
@@ -1898,6 +1898,8 @@ uvm_map_is_stack_remappable(struct vm_ma
vaddr_t end = addr + sz;
struct vm_map_entry *first, *iter, *prev = NULL;
 
+   vm_map_assert_locked(map);
+
if (!uvm_map_lookup_entry(map, addr, )) {
printf("map stack 0x%lx-0x%lx of map %p failed: no mapping\n",
addr, end, map);
@@ -5442,6 +5444,30 @@ vm_map_unbusy_ln(struct vm_map *map, cha
mtx_leave(>flags_lock);
if (oflags & VM_MAP_WANTLOCK)
wakeup(>flags);
+}
+
+void
+vm_map_assert_locked_ln(struct vm_map *map, char *file, int line)
+{
+   if ((map->flags & VM_MAP_INTRSAFE) == 0)
+   rw_assert_anylock(>lock);
+   else
+   MUTEX_ASSERT_LOCKED(>mtx);
+   LPRINTF(("map locked: %p (at %s %d)\n", map, file, line));
+   uvm_tree_sanity(map, file, line);
+   uvm_tree_size_chk(map, file, line);
+}
+
+void
+vm_map_assert_unlocked_ln(struct vm_map *map, char *file, int line)
+{
+   if ((map->flags & VM_MAP_INTRSAFE) == 0)
+   rw_assert_unlocked(>lock);
+   else
+   MUTEX_ASSERT_UNLOCKED(>mtx);
+   LPRINTF(("map unlckd: %p (at %s %d)\n", map, file, line));
+   uvm_tree_sanity(map, file, line);
+   uvm_tree_size_chk(map, file, line);
 }
 
 #ifndef SMALL_KERNEL
Index: uvm/uvm_map.h
===
RCS file: /cvs/src/sys/uvm/uvm_map.h,v
retrieving revision 1.64
diff -u -p -r1.64 uvm_map.h
--- uvm/uvm_map.h   2 Nov 2019 09:36:08 -   1.64
+++ uvm/uvm_map.h   8 Nov 2019 16:08:55 -
@@ -399,7 +399,6 @@ int uvm_map_inherit(vm_map_t, vaddr_t, 
 intuvm_map_advice(vm_map_t, vaddr_t, vaddr_t, int);
 void   uvm_map_init(void);
 boolean_t  uvm_map_lookup_entry(vm_map_t, vaddr_t, vm_map_entry_t *);
-boolean_t  uvm_map_is_stack_remappable(vm_map_t, vaddr_t, vsize_t);
 intuvm_map_remap_as_stack(struct proc *, vaddr_t, vsize_t);
 intuvm_map_replace(vm_map_t, vaddr_t, vaddr_t,
vm_map_entry_t, int);
@@ -473,6 +472,8 @@ voidvm_map_downgrade_ln(struct vm_map*
 void   vm_map_upgrade_ln(struct vm_map*, char*, int);
 void   vm_map_busy_ln(struct vm_map*, char*, int);
 void   vm_map_unbusy_ln(struct vm_map*, char*, int);
+void   vm_map_assert_locked(struct vm_map*, char*, int);
+void   vm_map_assert_unlocked(struct vm_map*, char*, int);
 
 #ifdef DIAGNOSTIC
 #define vm_map_lock_try(map)   vm_map_lock_try_ln(map, __FILE__, __LINE__)
@@ -484,6 +485,10 @@ void   vm_map_unbusy_ln(struct vm_map*, c
 #define vm_map_upgrade(map)vm_map_upgrade_ln(map, __FILE__, __LINE__)
 #define vm_map_busy(map)   vm_map_busy_ln(map, __FILE__, __LINE__)
 #define vm_map_unbusy(map) vm_map_unbusy_ln(map, __FILE__, __LINE__)
+#define vm_map_assert_locked(map)  \
+   vm_map_assert_locked_ln(map, __FILE__, __LINE__)

Re: net80211: do not connect to any open network by default

2019-11-08 Thread Stuart Henderson
On 2019/11/08 17:56, Stefan Sperling wrote:
> The default wifi interface behaviour of connecting to any open network
> when nothing is configured is confusing people who have gotten used to
> the behaviour of ifconfig join.
> 
> With this diff connecting to any open network on 'ifconfg iwm0 up' requires
> the user to run ifconfig iwm0 join "" first. Otherwise, only explicitly
> configured network SSIDs will be used.
> 
> This also allows users to scan for available access points without sending
> out probe, auth, or association requests to random accces points.
> 
> ok?

OK with me.  ifconfig(8) will need an update, but I think this is probably 
enough.


Index: ifconfig.8
===
RCS file: /cvs/src/sbin/ifconfig/ifconfig.8,v
retrieving revision 1.342
diff -u -p -r1.342 ifconfig.8
--- ifconfig.8  20 Sep 2019 12:37:04 -  1.342
+++ ifconfig.8  8 Nov 2019 16:21:36 -
@@ -965,6 +965,8 @@ It doesn't affect the channel to be crea
 Add the network with NWID/ESSID
 .Ar id
 to the list of auto-join networks.
+The empty string allows the interface to connect to any available
+access point.
 Information about such networks is retained,
 such that configured interfaces can automatically switch to such networks
 as necessary.
@@ -1044,8 +1046,6 @@ Connect to the network with NWID
 .Ar id .
 Unlike auto-join networks,
 information about the network is not retained.
-The empty string allows the interface to connect to any available
-access points.
 May not be used with
 .Cm join .
 .It Cm -nwid


> diff refs/heads/master refs/heads/no-assoc-any
> blob - 41530d2a311e1dbc2c0e70f95a14c360e9f981d6 (mode 644)
> blob + bc6a604c33daf297800f2f36dfae23c03d2dfb9d (mode 600)
> --- sys/net80211/ieee80211_node.c
> +++ sys/net80211/ieee80211_node.c
> @@ -1038,8 +1038,7 @@ ieee80211_match_bss(struct ieee80211com *ic, struct ie
>   rate = ieee80211_fix_rate(ic, ni, IEEE80211_F_DONEGO);
>   if (rate & IEEE80211_RATE_BASIC)
>   fail |= IEEE80211_NODE_ASSOCFAIL_BASIC_RATE;
> - if (ISSET(ic->ic_flags, IEEE80211_F_AUTO_JOIN) &&
> - ic->ic_des_esslen == 0)
> + if (ic->ic_des_esslen == 0)
>   fail |= IEEE80211_NODE_ASSOCFAIL_ESSID;
>   if (ic->ic_des_esslen != 0 &&
>   (ni->ni_esslen != ic->ic_des_esslen ||
> 
> 
> 



net80211: do not connect to any open network by default

2019-11-08 Thread Stefan Sperling
The default wifi interface behaviour of connecting to any open network
when nothing is configured is confusing people who have gotten used to
the behaviour of ifconfig join.

With this diff connecting to any open network on 'ifconfg iwm0 up' requires
the user to run ifconfig iwm0 join "" first. Otherwise, only explicitly
configured network SSIDs will be used.

This also allows users to scan for available access points without sending
out probe, auth, or association requests to random accces points.

ok?

diff refs/heads/master refs/heads/no-assoc-any
blob - 41530d2a311e1dbc2c0e70f95a14c360e9f981d6 (mode 644)
blob + bc6a604c33daf297800f2f36dfae23c03d2dfb9d (mode 600)
--- sys/net80211/ieee80211_node.c
+++ sys/net80211/ieee80211_node.c
@@ -1038,8 +1038,7 @@ ieee80211_match_bss(struct ieee80211com *ic, struct ie
rate = ieee80211_fix_rate(ic, ni, IEEE80211_F_DONEGO);
if (rate & IEEE80211_RATE_BASIC)
fail |= IEEE80211_NODE_ASSOCFAIL_BASIC_RATE;
-   if (ISSET(ic->ic_flags, IEEE80211_F_AUTO_JOIN) &&
-   ic->ic_des_esslen == 0)
+   if (ic->ic_des_esslen == 0)
fail |= IEEE80211_NODE_ASSOCFAIL_ESSID;
if (ic->ic_des_esslen != 0 &&
(ni->ni_esslen != ic->ic_des_esslen ||





Re: sysupgrade: Allow to use another directory for the sets

2019-11-08 Thread Stuart Henderson
On 2019/11/06 13:41, Renaud Allard wrote:
> Hello,
> 
> Given the amount of people which encrypt /home directory on their servers,
> it might be useful to be able to define another directory for the sets in
> sysupgrade as /home_sysupgrade will not be available in that case.

This (encrypted /home but not boot-loader-assisted FDE) doesn't seem
like it would be all that common a thing to me, but I can think of
other use cases for moving the directory.

I know a similar request was rejected in earlier sysupgrade, but now
that sysupgrade uses /auto_upgrade.conf rather than special code in
install.sub it seems a reasonable change to make.

> +.It Fl d Ar directory
> +Choose the 

Nit: trailing whitespace, otherwise it's OK sthen@





net80211: make join deselect failing APs

2019-11-08 Thread Stefan Sperling
An AP which never responds to auth/assoc requests can remain in the
joinlist and keep being selected. This results in an endless loop
between SCAN and AUTH (and sometimes ASSOC) states:

iwm0: SCAN -> AUTH
iwm0: sending auth to 00:1a:dd:da:e3:f1 on channel 64 mode 11a
iwm0: AUTH -> SCAN

Another AP added to the joinlist may never be selected if it has a
lower score than this "bad" AP in the list (e.g. if the "bad" AP is
using WPA and the alternative AP which was added uses no encryption).

In this example, the AP which does not respond has the SSID "OpenBSD",
and I added the unencrypted "univbuc_free" network to the joinlist
during SCAN:

iwm0: end passive scan
iwm0: AP 10:bd:18:3d:c1:11 "univbuc_free" score 43
iwm0: AP 10:bd:18:3d:c1:1e "univbuc_free" score 43
iwm0: AP 10:bd:18:4d:9f:f1 "univbuc_free" score 43
iwm0: AP 10:bd:18:4d:9f:fe "univbuc_free" score 43
iwm0: AP f4:ea:67:5c:f9:61 "univbuc_free" score 43
iwm0: AP f4:ea:67:5c:f9:6e "univbuc_free" score 45
iwm0: AP f4:ea:67:5d:01:51 "univbuc_free" score 43
iwm0: AP f4:ea:67:5d:01:5e "univbuc_free" score 43
iwm0: AP f4:ea:67:bf:aa:11 "univbuc_free" score 43
iwm0: AP f4:ea:67:c0:f8:71 "univbuc_free" score 43
iwm0: AP f4:ea:67:c0:f8:7e "univbuc_free" score 43
iwm0: best AP 00:1a:dd:da:e3:e1 "OpenBSD" score 52
iwm0: switching to network "OpenBSD"

With this diff we deselect an AP which fails to auth/assoc, and give
higher priority to APs which have had no auth/assoc failures yet.

This looks like:

iwm0: end active scan
iwm0: AP 10:bd:18:3c:d4:81 "univbuc_free" score 54
iwm0: AP 10:bd:18:3c:d4:8e "univbuc_free" score 54
iwm0: AP 10:bd:18:4d:98:81 "univbuc_free" score 54
iwm0: AP 10:bd:18:4d:98:8e "univbuc_free" score 53
iwm0: AP 10:bd:18:4d:9f:7e "univbuc_free" score 53
iwm0: AP 10:bd:18:4d:9f:fe "univbuc_free" score 53
iwm0: AP 10:bd:18:4d:cf:41 "univbuc_free" score 53
iwm0: AP 10:bd:18:4d:cf:4e "univbuc_free" score 53
iwm0: AP 10:bd:18:6c:aa:51 "univbuc_free" score 53
iwm0: AP 10:bd:18:6c:aa:5e "univbuc_free" score 53
iwm0: AP f4:ea:67:5c:f9:61 "univbuc_free" score 33
iwm0: AP f4:ea:67:5c:f9:6e "univbuc_free" score 53
iwm0: AP f4:ea:67:5d:01:51 "univbuc_free" score 53
iwm0: AP f4:ea:67:5d:01:5e "univbuc_free" score 53
iwm0: AP f4:ea:67:c0:f8:71 "univbuc_free" score 54
iwm0: AP f4:ea:67:c0:f8:7e "univbuc_free" score 54
iwm0: best AP 00:1a:dd:da:e3:f1 "OpenBSD" score 73
iwm0: switching to network "OpenBSD"

(long scan result list omitted)

iwm0: SCAN -> AUTH
iwm0: sending auth to 00:1a:dd:da:e3:f1 on channel 64 mode 11a
iwm0: authentication timed out for 00:1a:dd:da:e3:f1
iwm0: AUTH -> SCAN
iwm0: end active scan
iwm0: AP 00:1a:dd:da:e3:f1 "OpenBSD" score 52
iwm0: AP 10:bd:18:4d:9f:71 "univbuc_free" score 53
iwm0: AP 10:bd:18:4d:9f:7e "univbuc_free" score 53
iwm0: AP 10:bd:18:4d:9f:f1 "univbuc_free" score 53
iwm0: AP 10:bd:18:4d:9f:fe "univbuc_free" score 53
iwm0: AP 10:bd:18:4d:cf:41 "univbuc_free" score 53
iwm0: AP 10:bd:18:4d:cf:4e "univbuc_free" score 53
iwm0: AP 10:bd:18:6c:aa:51 "univbuc_free" score 53
iwm0: AP 18:33:9d:6d:9c:61 "univbuc_free" score 53
iwm0: AP 18:33:9d:6d:9c:6e "univbuc_free" score 53
iwm0: AP f4:ea:67:5c:f9:61 "univbuc_free" score 33
iwm0: AP f4:ea:67:5d:01:5e "univbuc_free" score 53
iwm0: AP f4:ea:67:be:74:21 "univbuc_free" score 53
iwm0: AP f4:ea:67:bf:aa:11 "univbuc_free" score 53
iwm0: AP f4:ea:67:c0:f8:71 "univbuc_free" score 53
iwm0: AP f4:ea:67:c0:f8:7e "univbuc_free" score 53
iwm0: best AP f4:ea:67:5d:01:51 "univbuc_free" score 53
iwm0: switching to network "univbuc_free"

ok?

diff refs/heads/master refs/heads/join-deselect
blob - bf2b2858f03d302ded03555bda21450f9c80cf66
blob + d66ca6238ff5d4c8a642805ef45843088bae4289
--- sys/net80211/ieee80211.c
+++ sys/net80211/ieee80211.c
@@ -772,8 +772,25 @@ ieee80211_watchdog(struct ifnet *ifp)
 {
struct ieee80211com *ic = (void *)ifp;
 
-   if (ic->ic_mgt_timer && --ic->ic_mgt_timer == 0)
+   if (ic->ic_mgt_timer && --ic->ic_mgt_timer == 0) {
+   if (ic->ic_opmode == IEEE80211_M_STA &&
+   (ic->ic_state == IEEE80211_S_AUTH ||
+   ic->ic_state == IEEE80211_S_ASSOC)) {
+   struct ieee80211_node *ni;
+   if (ifp->if_flags & IFF_DEBUG)
+   printf("%s: %s timed out for %s\n",
+   ifp->if_xname,
+   ic->ic_state == IEEE80211_S_ASSOC ?
+   "association" : "authentication",
+   ether_sprintf(ic->ic_bss->ni_macaddr));
+   ni = ieee80211_find_node(ic, ic->ic_bss->ni_macaddr);
+   if (ni)
+   ni->ni_fails++;
+   if (ISSET(ic->ic_flags, IEEE80211_F_AUTO_JOIN))
+   ieee80211_deselect_ess(ic);
+   }
ieee80211_new_state(ic, IEEE80211_S_SCAN, -1);
+   }
 
if (ic->ic_mgt_timer != 0)