Re: svn commit: r317277 - head/sys/crypto/chacha20

2017-04-21 Thread Colin Percival
On 04/21/17 19:33, Rui Paulo wrote:
> On Apr 21, 2017, at 18:06, Dag-Erling Smørgrav  wrote:
>> Author: des
>> Date: Sat Apr 22 01:06:23 2017
>> New Revision: 317277
>> URL: https://svnweb.freebsd.org/changeset/base/317277
>>
>> Log:
>>  Fix counter increment in Salsa and ChaCha.
>>
>>  In my eagerness to eliminate a branch which is taken once per 2^38
>>  bytes of keystream, I forgot that the state words are in host order.
>>  Thus, the counter increment code worked fine on little-endian
>>  machines, but not on big-endian ones.  Switch to a simpler (branchful)
>>  solution.
> 
> I’m surprised there’s no mention of who reviewed your change, especially when 
> you’re changing crypto code.

Reviewed by:cperciva

-- 
Colin Percival
Security Officer Emeritus, FreeBSD | The power to serve
Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Re: svn commit: r317277 - head/sys/crypto/chacha20

2017-04-21 Thread Rui Paulo
On Apr 21, 2017, at 18:06, Dag-Erling Smørgrav  wrote:
> 
> Author: des
> Date: Sat Apr 22 01:06:23 2017
> New Revision: 317277
> URL: https://svnweb.freebsd.org/changeset/base/317277
> 
> Log:
>  Fix counter increment in Salsa and ChaCha.
> 
>  In my eagerness to eliminate a branch which is taken once per 2^38
>  bytes of keystream, I forgot that the state words are in host order.
>  Thus, the counter increment code worked fine on little-endian
>  machines, but not on big-endian ones.  Switch to a simpler (branchful)
>  solution.

I’m surprised there’s no mention of who reviewed your change, especially when 
you’re changing crypto code.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

svn commit: r317278 - head/sys/net80211

2017-04-21 Thread Adrian Chadd
Author: adrian
Date: Sat Apr 22 02:12:07 2017
New Revision: 317278
URL: https://svnweb.freebsd.org/changeset/base/317278

Log:
  [net80211] add methods to fetch the global and per-VAP WME parameters.
  
  For now there isn't any per-VAP WME state.  The eventual aim is to migrate
  the driver direct use of WME parameters over to use these methods as
  appropriate (global for most devices, per-VAP for firmware NICs that support
  it) in preparation for actual per-VAP WME (and other thing) state change
  support.

Modified:
  head/sys/net80211/ieee80211_proto.c
  head/sys/net80211/ieee80211_proto.h

Modified: head/sys/net80211/ieee80211_proto.c
==
--- head/sys/net80211/ieee80211_proto.c Sat Apr 22 01:06:23 2017
(r317277)
+++ head/sys/net80211/ieee80211_proto.c Sat Apr 22 02:12:07 2017
(r317278)
@@ -1306,6 +1306,20 @@ ieee80211_wme_updateparams(struct ieee80
}
 }
 
+void
+ieee80211_wme_vap_getparams(struct ieee80211vap *vap, struct chanAccParams *wp)
+{
+
+   memcpy(wp, >iv_ic->ic_wme.wme_chanParams, sizeof(*wp));
+}
+
+void
+ieee80211_wme_ic_getparams(struct ieee80211com *ic, struct chanAccParams *wp)
+{
+
+   memcpy(wp, >ic_wme.wme_chanParams, sizeof(*wp));
+}
+
 static void
 parent_updown(void *arg, int npending)
 {

Modified: head/sys/net80211/ieee80211_proto.h
==
--- head/sys/net80211/ieee80211_proto.h Sat Apr 22 01:06:23 2017
(r317277)
+++ head/sys/net80211/ieee80211_proto.h Sat Apr 22 02:12:07 2017
(r317278)
@@ -292,6 +292,10 @@ struct ieee80211_wme_state {
 void   ieee80211_wme_initparams(struct ieee80211vap *);
 void   ieee80211_wme_updateparams(struct ieee80211vap *);
 void   ieee80211_wme_updateparams_locked(struct ieee80211vap *);
+void   ieee80211_wme_vap_getparams(struct ieee80211vap *vap,
+   struct chanAccParams *);
+void   ieee80211_wme_ic_getparams(struct ieee80211com *ic,
+   struct chanAccParams *);
 
 /*
  * Return the WME TID from a QoS frame.  If no TID
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317277 - head/sys/crypto/chacha20

2017-04-21 Thread Dag-Erling Smørgrav
Author: des
Date: Sat Apr 22 01:06:23 2017
New Revision: 317277
URL: https://svnweb.freebsd.org/changeset/base/317277

Log:
  Fix counter increment in Salsa and ChaCha.
  
  In my eagerness to eliminate a branch which is taken once per 2^38
  bytes of keystream, I forgot that the state words are in host order.
  Thus, the counter increment code worked fine on little-endian
  machines, but not on big-endian ones.  Switch to a simpler (branchful)
  solution.

Modified:
  head/sys/crypto/chacha20/chacha20.c

Modified: head/sys/crypto/chacha20/chacha20.c
==
--- head/sys/crypto/chacha20/chacha20.c Fri Apr 21 23:01:32 2017
(r317276)
+++ head/sys/crypto/chacha20/chacha20.c Sat Apr 22 01:06:23 2017
(r317277)
@@ -130,7 +130,6 @@ size_t
 chacha20_encrypt(chacha20_ctx *ctx, const void *vpt, uint8_t *ct, size_t len)
 {
const uint8_t *pt = vpt;
-   uint64_t ctr;
uint32_t mix[16];
uint8_t ks[64];
unsigned int b, i;
@@ -157,8 +156,8 @@ chacha20_encrypt(chacha20_ctx *ctx, cons
for (i = 0; i < 64 && i < len; ++i)
*ct++ = *pt++ ^ ks[i];
}
-   ctr = le64dec(ctx->state + 12);
-   le64enc(ctx->state + 12, ++ctr);
+   if (++ctx->state[12] == 0)
+   ++ctx->state[13];
}
return (len);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317275 - head/sys/fs/nfs

2017-04-21 Thread Rick Macklem
Author: rmacklem
Date: Fri Apr 21 22:38:26 2017
New Revision: 317275
URL: https://svnweb.freebsd.org/changeset/base/317275

Log:
  Don't create a backchannel for a DS connection.
  
  An NFSv4.1 client connection to a Data Server (DS) should not have a
  backchannel. This patch fixes the NFSv4.1/pNFS client to not do a backchannel
  for this case.
  Found during recent testing with the pNFS server under development.
  
  MFC after:2 weeks

Modified:
  head/sys/fs/nfs/nfs_commonkrpc.c

Modified: head/sys/fs/nfs/nfs_commonkrpc.c
==
--- head/sys/fs/nfs/nfs_commonkrpc.cFri Apr 21 22:19:13 2017
(r317274)
+++ head/sys/fs/nfs/nfs_commonkrpc.cFri Apr 21 22:38:26 2017
(r317275)
@@ -280,7 +280,8 @@ newnfs_connect(struct nfsmount *nmp, str
retries = nmp->nm_retry;
} else
retries = INT_MAX;
-   if (NFSHASNFSV4N(nmp)) {
+   /* cred == NULL for DS connects. */
+   if (NFSHASNFSV4N(nmp) && cred != NULL) {
/*
 * Make sure the nfscbd_pool doesn't get destroyed
 * while doing this.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r317269 - in head/sys: fs/nfs sys

2017-04-21 Thread Slawa Olhovchenkov
On Fri, Apr 21, 2017 at 08:08:10PM +, Rick Macklem wrote:

> Author: rmacklem
> Date: Fri Apr 21 20:08:10 2017
> New Revision: 317269
> URL: https://svnweb.freebsd.org/changeset/base/317269
> 
> Log:
>   Set default uid/gid to nobody/nogroup for NFSv4 mapping.
>   
>   The default uid/gid for NFSv4 are set by the nfsuserd(8) daemon.
>   However, they were 0 until the nfsuserd(8) was run. Since it is
>   possible to use NFSv4 without running the nfsuserd(8) daemon, set them
>   to nobody/nogroup initially.
>   Without this patch, the values would be set by the nfsuserd(8) daemon
>   and left changed even if the nfsuserd(8) daemon was killed. The default
>   values of 0 meant that setting a group to "wheel" would fail even when
>   done by root.
>   It also adds a definition of GID_NOGROUP to sys/conf.h.
>   
>   Discussed on:   freebsd-current@
>   MFC after:  2 weeks

Can you also look to this problem
https://lists.freebsd.org/pipermail/freebsd-stable/2012-March/066868.html
?
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317274 - in head/contrib/bmake: . unit-tests

2017-04-21 Thread Simon J. Gerraty
Author: sjg
Date: Fri Apr 21 22:19:13 2017
New Revision: 317274
URL: https://svnweb.freebsd.org/changeset/base/317274

Log:
  Str_Match: fix closure tests for [^] and add unit-test.

Modified:
  head/contrib/bmake/str.c
  head/contrib/bmake/unit-tests/modmatch.exp
  head/contrib/bmake/unit-tests/modmatch.mk

Modified: head/contrib/bmake/str.c
==
--- head/contrib/bmake/str.cFri Apr 21 22:00:22 2017(r317273)
+++ head/contrib/bmake/str.cFri Apr 21 22:19:13 2017(r317274)
@@ -382,8 +382,11 @@ Str_Match(const char *string, const char
} else
nomatch = 0;
for (;;) {
-   if ((*pattern == ']') || (*pattern == 0))
-   return(nomatch);
+   if ((*pattern == ']') || (*pattern == 0)) {
+   if (nomatch)
+   break;
+   return(0);
+   }
if (*pattern == *string)
break;
if (pattern[1] == '-') {
@@ -400,7 +403,7 @@ Str_Match(const char *string, const char
}
++pattern;
}
-   if (nomatch)
+   if (nomatch && (*pattern != ']') && (*pattern != 0))
return 0;
while ((*pattern != ']') && (*pattern != 0))
++pattern;

Modified: head/contrib/bmake/unit-tests/modmatch.exp
==
--- head/contrib/bmake/unit-tests/modmatch.exp  Fri Apr 21 22:00:22 2017
(r317273)
+++ head/contrib/bmake/unit-tests/modmatch.exp  Fri Apr 21 22:19:13 2017
(r317274)
@@ -16,4 +16,5 @@ LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/
 Mscanner=OK
 Upper=One Two Three Four
 Lower=five six seven
+nose=One Three five
 exit status 0

Modified: head/contrib/bmake/unit-tests/modmatch.mk
==
--- head/contrib/bmake/unit-tests/modmatch.mk   Fri Apr 21 22:00:22 2017
(r317273)
+++ head/contrib/bmake/unit-tests/modmatch.mk   Fri Apr 21 22:19:13 2017
(r317274)
@@ -31,3 +31,4 @@ LIST= One Two Three Four five six seven
 check-cclass:
@echo Upper=${LIST:M[A-Z]*}
@echo Lower=${LIST:M[^A-Z]*}
+   @echo nose=${LIST:M[^s]*[ex]}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317273 - head/sys/fs/fuse

2017-04-21 Thread Conrad Meyer
Author: cem
Date: Fri Apr 21 22:00:22 2017
New Revision: 317273
URL: https://svnweb.freebsd.org/changeset/base/317273

Log:
  fuse: Implement FOPEN_KEEP_CACHE flag
  
  Implement FUSE open flag FOPEN_KEEP_CACHE.  Without this flag, cached file
  contents should be invalidated on open.  Apparently, fusefs-encfs relies
  upon this behavior.
  
  PR:   218636
  Submitted by: Ben RUBSON 

Modified:
  head/sys/fs/fuse/fuse_node.c

Modified: head/sys/fs/fuse/fuse_node.c
==
--- head/sys/fs/fuse/fuse_node.cFri Apr 21 21:43:00 2017
(r317272)
+++ head/sys/fs/fuse/fuse_node.cFri Apr 21 22:00:22 2017
(r317273)
@@ -272,8 +272,6 @@ fuse_vnode_open(struct vnode *vp, int32_
/*
 * Funcation is called for every vnode open.
 * Merge fuse_open_flags it may be 0
-*
-* XXXIP: Handle FOPEN_KEEP_CACHE
 */
/*
 * Ideally speaking, direct io should be enabled on
@@ -293,6 +291,8 @@ fuse_vnode_open(struct vnode *vp, int32_
VTOFUD(vp)->flag |= FN_DIRECTIO;
fuse_io_invalbuf(vp, td);
} else {
+   if ((fuse_open_flags & FOPEN_KEEP_CACHE) == 0)
+   fuse_io_invalbuf(vp, td);
VTOFUD(vp)->flag &= ~FN_DIRECTIO;
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317272 - head/sys/fs/nfsclient

2017-04-21 Thread Rick Macklem
Author: rmacklem
Date: Fri Apr 21 21:43:00 2017
New Revision: 317272
URL: https://svnweb.freebsd.org/changeset/base/317272

Log:
  Add checks for failed operations to the NFSv4 client function nfscl_mtofh().
  
  The nfscl_mtofh() function didn't check for failed operations and, as such,
  would have returned EBADRPC for these cases, due to parsing failure.
  This patch adds checks, so that it returns with ND_NOMOREDATA set.
  This is needed for future use in the pNFS server and acts as a safety
  belt in the meantime.
  
  MFC after:2 weeks

Modified:
  head/sys/fs/nfsclient/nfs_clcomsubs.c

Modified: head/sys/fs/nfsclient/nfs_clcomsubs.c
==
--- head/sys/fs/nfsclient/nfs_clcomsubs.c   Fri Apr 21 21:06:11 2017
(r317271)
+++ head/sys/fs/nfsclient/nfs_clcomsubs.c   Fri Apr 21 21:43:00 2017
(r317272)
@@ -471,6 +471,11 @@ nfscl_mtofh(struct nfsrv_descript *nd, s
flag = fxdr_unsigned(int, *tl);
} else if (nd->nd_flag & ND_NFSV4) {
NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
+   /* If the GetFH failed, clear flag. */
+   if (*++tl != 0) {
+   nd->nd_flag |= ND_NOMOREDATA;
+   flag = 0;
+   }
}
if (flag) {
error = nfsm_getfh(nd, nfhpp);
@@ -481,8 +486,12 @@ nfscl_mtofh(struct nfsrv_descript *nd, s
/*
 * Now, get the attributes.
 */
-   if (nd->nd_flag & ND_NFSV4) {
+   if (flag != 0 && (nd->nd_flag & ND_NFSV4) != 0) {
NFSM_DISSECT(tl, u_int32_t *, 2 * NFSX_UNSIGNED);
+   if (*++tl != 0) {
+   nd->nd_flag |= ND_NOMOREDATA;
+   flag = 0;
+   }
} else if (nd->nd_flag & ND_NFSV3) {
NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
if (flag) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317270 - head/usr.sbin/nfsuserd

2017-04-21 Thread Rick Macklem
Author: rmacklem
Date: Fri Apr 21 20:53:51 2017
New Revision: 317270
URL: https://svnweb.freebsd.org/changeset/base/317270

Log:
  Get rid of bogus statement in the nfsuserd.8 man page.
  
  The nfsuserd.8 man page stated that a usertimeout of 0 would disable
  the cache timeout. This was simply not true, so this patch deletes
  the sentence.
  
  This is a content change.
  
  PR:   217406
  MFC after:2 weeks

Modified:
  head/usr.sbin/nfsuserd/nfsuserd.8

Modified: head/usr.sbin/nfsuserd/nfsuserd.8
==
--- head/usr.sbin/nfsuserd/nfsuserd.8   Fri Apr 21 20:08:10 2017
(r317269)
+++ head/usr.sbin/nfsuserd/nfsuserd.8   Fri Apr 21 20:53:51 2017
(r317270)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 1, 2015
+.Dd April 21, 2017
 .Dt NFSUSERD 8
 .Os
 .Sh NAME
@@ -64,8 +64,8 @@ if that name is not a fully qualified ho
 reported by
 .Xr getaddrinfo 3 .
 .It Fl usertimeout Ar minutes
-Overrides the default timeout for cache entries, in minutes. If the
-timeout is specified as 0, cache entries never time out. The longer the
+Overrides the default timeout for cache entries, in minutes.
+The longer the
 time out, the better the performance, but the longer it takes for replaced
 entries to be seen. If your user/group database management system almost
 never re-uses the same names or id numbers, a large timeout is recommended.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317269 - in head/sys: fs/nfs sys

2017-04-21 Thread Rick Macklem
Author: rmacklem
Date: Fri Apr 21 20:08:10 2017
New Revision: 317269
URL: https://svnweb.freebsd.org/changeset/base/317269

Log:
  Set default uid/gid to nobody/nogroup for NFSv4 mapping.
  
  The default uid/gid for NFSv4 are set by the nfsuserd(8) daemon.
  However, they were 0 until the nfsuserd(8) was run. Since it is
  possible to use NFSv4 without running the nfsuserd(8) daemon, set them
  to nobody/nogroup initially.
  Without this patch, the values would be set by the nfsuserd(8) daemon
  and left changed even if the nfsuserd(8) daemon was killed. The default
  values of 0 meant that setting a group to "wheel" would fail even when
  done by root.
  It also adds a definition of GID_NOGROUP to sys/conf.h.
  
  Discussed on: freebsd-current@
  MFC after:2 weeks

Modified:
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/sys/conf.h

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==
--- head/sys/fs/nfs/nfs_commonsubs.cFri Apr 21 20:03:08 2017
(r317268)
+++ head/sys/fs/nfs/nfs_commonsubs.cFri Apr 21 20:08:10 2017
(r317269)
@@ -63,8 +63,8 @@ int nfsrv_useacl = 1;
 struct nfssockreq nfsrv_nfsuserdsock;
 int nfsrv_nfsuserd = 0;
 struct nfsreqhead nfsd_reqq;
-uid_t nfsrv_defaultuid;
-gid_t nfsrv_defaultgid;
+uid_t nfsrv_defaultuid = UID_NOBODY;
+gid_t nfsrv_defaultgid = GID_NOGROUP;
 int nfsrv_lease = NFSRV_LEASE;
 int ncl_mbuf_mlen = MLEN;
 int nfsd_enable_stringtouid = 0;

Modified: head/sys/sys/conf.h
==
--- head/sys/sys/conf.h Fri Apr 21 20:03:08 2017(r317268)
+++ head/sys/sys/conf.h Fri Apr 21 20:08:10 2017(r317269)
@@ -315,6 +315,7 @@ voiddevfs_free_cdp_inode(ino_t ino);
 #defineGID_GAMES   13
 #defineGID_VIDEO   44
 #defineGID_DIALER  68
+#defineGID_NOGROUP 65533
 #defineGID_NOBODY  65534
 
 typedef void (*dev_clone_fn)(void *arg, struct ucred *cred, char *name,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317267 - in head: cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/lib/libzfs/common sys/cddl/contrib/opensolaris/common/zfs

2017-04-21 Thread Josh Paetzel
Author: jpaetzel
Date: Fri Apr 21 19:53:52 2017
New Revision: 317267
URL: https://svnweb.freebsd.org/changeset/base/317267

Log:
  MFV 316891
  
  7386 zfs get does not work properly with bookmarks
  
  illumos/illumos-gate@edb901aab9c738b5eb15aa55933e82b0f2f9d9a2
  
https://github.com/illumos/illumos-gate/commit/edb901aab9c738b5eb15aa55933e82b0f2f9d9a2
  
  https://www.illumos.org/issues/7386
The zfs get command does not work with the bookmark parameter while it works
properly with both filesystem and snapshot:
# zfs get -t all -r creation rpool/test
NAME   PROPERTY  VALUE  SOURCE
rpool/test creation  Fri Sep 16 15:00 2016  -
rpool/test@snapcreation  Fri Sep 16 15:00 2016  -
rpool/test#bkmark  creation  Fri Sep 16 15:00 2016  -
# zfs get -t all -r creation rpool/test@snap
NAME PROPERTY  VALUE  SOURCE
rpool/test@snap  creation  Fri Sep 16 15:00 2016  -
# zfs get -t all -r creation rpool/test#bkmark
cannot open 'rpool/test#bkmark': invalid dataset name
#
The zfs get command should be modified to work properly with bookmarks too.
  
  Reviewed by: Simon Klinkert 
  Reviewed by: Paul Dagnelie 
  Approved by: Matthew Ahrens 
  Author: Marcel Telka 

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs.8
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
  head/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.c
  head/sys/cddl/contrib/opensolaris/common/zfs/zfs_namecheck.h
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/cddl/contrib/opensolaris/cmd/zfs/   (props changed)
  head/cddl/contrib/opensolaris/lib/libzfs/   (props changed)
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8
==
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Fri Apr 21 19:41:33 2017
(r317266)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Fri Apr 21 19:53:52 2017
(r317267)
@@ -25,13 +25,13 @@
 .\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
 .\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
 .\" Copyright (c) 2013, Steven Hartland 
-.\" Copyright (c) 2014 Nexenta Systems, Inc. All Rights Reserved.
+.\" Copyright (c) 2016 Nexenta Systems, Inc. All Rights Reserved.
 .\" Copyright (c) 2014, Xin LI 
 .\" Copyright (c) 2014-2015, The FreeBSD Foundation, All Rights Reserved.
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 31, 2016
+.Dd September 16, 2016
 .Dt ZFS 8
 .Os
 .Sh NAME
@@ -114,7 +114,7 @@
 .Op Fl t Ar type Ns Oo , Ns type Ns Oc Ns ...
 .Oo Fl s Ar property Oc Ns ...
 .Oo Fl S Ar property Oc Ns ...
-.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
+.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot | Ns Ar bookmark Ns ...
 .Nm
 .Cm set
 .Ar property Ns = Ns Ar value Oo Ar property Ns = Ns Ar value Oc Ns ...
@@ -2156,7 +2156,7 @@ section.
 .Op Fl t Ar type Ns Oo , Ns Ar type Oc Ns ...
 .Op Fl s Ar source Ns Oo , Ns Ar source Oc Ns ...
 .Ar all | property Ns Oo , Ns Ar property Oc Ns ...
-.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot Ns ...
+.Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot Ns | Ns Ar bookmark Ns ...
 .Xc
 .Pp
 Displays properties for the given datasets. If no datasets are specified, then

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cFri Apr 21 19:41:33 
2017(r317266)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cFri Apr 21 19:53:52 
2017(r317267)
@@ -243,7 +243,7 @@ get_usage(zfs_help_t idx)
"[-o \"all\" | field[,...]]\n"
"\t[-t type[,...]] [-s source[,...]]\n"
"\t<\"all\" | property[,...]> "
-   "[filesystem|volume|snapshot] ...\n"));
+   "[filesystem|volume|snapshot|bookmark] ...\n"));
case HELP_INHERIT:
return (gettext("\tinherit [-rS]  "
" ...\n"));
@@ -1622,7 +1622,7 @@ zfs_do_get(int argc, char **argv)
 {
zprop_get_cbdata_t cb = { 0 };
int i, c, flags = ZFS_ITER_ARGS_CAN_BE_PATHS;
-   int types = ZFS_TYPE_DATASET;
+   int types = ZFS_TYPE_DATASET | ZFS_TYPE_BOOKMARK;
char *value, *fields;
int ret = 0;
int limit = 0;

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
==
--- 

svn commit: r317265 - in head/lib: libgssapi libiconv_modules/ISO2022 libutil

2017-04-21 Thread Pedro F. Giffuni
Author: pfg
Date: Fri Apr 21 19:27:33 2017
New Revision: 317265
URL: https://svnweb.freebsd.org/changeset/base/317265

Log:
  lib: initial use of reallocarray(3).
  
  Make some use of reallocarray, attempting to limit it to cases where the
  parameters are unsigned and there is some theoretical chance of overflow.
  
  MFC afer: 2 weeks
  Differential Revision:https://reviews.freebsd.org/D9980

Modified:
  head/lib/libgssapi/gss_buffer_set.c
  head/lib/libiconv_modules/ISO2022/citrus_iso2022.c
  head/lib/libutil/gr_util.c
  head/lib/libutil/login_cap.c
  head/lib/libutil/pw_util.c

Modified: head/lib/libgssapi/gss_buffer_set.c
==
--- head/lib/libgssapi/gss_buffer_set.c Fri Apr 21 17:57:23 2017
(r317264)
+++ head/lib/libgssapi/gss_buffer_set.c Fri Apr 21 19:27:33 2017
(r317265)
@@ -76,8 +76,8 @@ gss_add_buffer_set_member(OM_uint32 * mi
}
 
set = *buffer_set;
-   set->elements = realloc(set->elements,
-   (set->count + 1) * sizeof(set->elements[0]));
+   set->elements = reallocarray(set->elements, set->count + 1,
+   sizeof(set->elements[0]));
if (set->elements == NULL) {
*minor_status = ENOMEM;
return (GSS_S_FAILURE);

Modified: head/lib/libiconv_modules/ISO2022/citrus_iso2022.c
==
--- head/lib/libiconv_modules/ISO2022/citrus_iso2022.c  Fri Apr 21 17:57:23 
2017(r317264)
+++ head/lib/libiconv_modules/ISO2022/citrus_iso2022.c  Fri Apr 21 19:27:33 
2017(r317265)
@@ -259,8 +259,8 @@ get_recommend(_ISO2022EncodingInfo * __r
if (!ei->recommend[i])
ei->recommend[i] = malloc(sizeof(_ISO2022Charset));
else {
-   p = realloc(ei->recommend[i],
-   sizeof(_ISO2022Charset) * (ei->recommendsize[i] + 1));
+   p = reallocarray(ei->recommend[i], ei->recommendsize[i] + 1,
+   sizeof(_ISO2022Charset));
if (!p)
return (_PARSEFAIL);
ei->recommend[i] = p;

Modified: head/lib/libutil/gr_util.c
==
--- head/lib/libutil/gr_util.c  Fri Apr 21 17:57:23 2017(r317264)
+++ head/lib/libutil/gr_util.c  Fri Apr 21 19:27:33 2017(r317265)
@@ -205,7 +205,7 @@ gr_copy(int ffd, int tfd, const struct g
if (eof)
break;
while ((size_t)(q - p) >= size) {
-   if ((tmp = realloc(buf, size * 2)) == NULL) {
+   if ((tmp = reallocarray(buf, 2, size)) == NULL) 
{
warnx("group line too long");
goto err;
}

Modified: head/lib/libutil/login_cap.c
==
--- head/lib/libutil/login_cap.cFri Apr 21 17:57:23 2017
(r317264)
+++ head/lib/libutil/login_cap.cFri Apr 21 19:27:33 2017
(r317265)
@@ -86,7 +86,7 @@ allocarray(size_t sz)
 
 if (sz <= internal_arraysz)
p = internal_array;
-else if ((p = realloc(internal_array, sz * sizeof(char*))) != NULL) {
+else if ((p = reallocarray(internal_array, sz, sizeof(char*))) != NULL) {
internal_arraysz = sz;
internal_array = p;
 }

Modified: head/lib/libutil/pw_util.c
==
--- head/lib/libutil/pw_util.c  Fri Apr 21 17:57:23 2017(r317264)
+++ head/lib/libutil/pw_util.c  Fri Apr 21 19:27:33 2017(r317265)
@@ -468,7 +468,7 @@ pw_copy(int ffd, int tfd, const struct p
if (eof)
break;
while ((size_t)(q - p) >= size) {
-   if ((tmp = realloc(buf, size * 2)) == NULL) {
+   if ((tmp = reallocarray(buf, 2, size)) == NULL) 
{
warnx("passwd line too long");
goto err;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317264 - head/sys/dev/syscons

2017-04-21 Thread Bruce Evans
Author: bde
Date: Fri Apr 21 17:57:23 2017
New Revision: 317264
URL: https://svnweb.freebsd.org/changeset/base/317264

Log:
  Optimize setting of the foreground color in the main planar method much
  like for the background color.
  
  This is a about 5% faster for output that actually reaches the screen.

Modified:
  head/sys/dev/syscons/scvgarndr.c

Modified: head/sys/dev/syscons/scvgarndr.c
==
--- head/sys/dev/syscons/scvgarndr.cFri Apr 21 17:42:48 2017
(r317263)
+++ head/sys/dev/syscons/scvgarndr.cFri Apr 21 17:57:23 2017
(r317264)
@@ -736,7 +736,7 @@ vga_vgadraw_planar(scr_stat *scp, int fr
vm_offset_t d;
vm_offset_t e;
u_char *f;
-   u_short bg;
+   u_short bg, fg;
u_short col1, col2;
int line_width;
int i, j;
@@ -754,7 +754,7 @@ vga_vgadraw_planar(scr_stat *scp, int fr
outw(GDCIDX, 0x0005);   /* read mode 0, write mode 0 */
outw(GDCIDX, 0x0003);   /* data rotate/function select */
outw(GDCIDX, 0x0f01);   /* set/reset enable */
-   bg = -1;
+   fg = bg = -1;
if (from + count > scp->xsize*scp->ysize)
count = scp->xsize*scp->ysize - from;
for (i = from; count-- > 0; ++i) {
@@ -769,6 +769,7 @@ vga_vgadraw_planar(scr_stat *scp, int fr
/* set background color in EGA/VGA latch */
if (bg != col2) {
bg = col2;
+   fg = -1;
outw(GDCIDX, bg | 0x00); /* set/reset */
if (scp->sc->adp->va_type != KD_VGA)
outw(GDCIDX, 0xff08); /* bit mask */
@@ -776,7 +777,10 @@ vga_vgadraw_planar(scr_stat *scp, int fr
c = readb(d);   /* set bg color in the latch */
}
/* foreground color */
-   outw(GDCIDX, col1 | 0x00);  /* set/reset */
+   if (fg != col1) {
+   fg = col1;
+   outw(GDCIDX, col1 | 0x00); /* set/reset */
+   }
e = d;
f = &(scp->font[sc_vtb_getc(>vtb, i)*scp->font_size]);
for (j = 0; j < scp->font_size; ++j, ++f) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r317208 - head/sys/netinet

2017-04-21 Thread Justin Hibbits
On Fri, Apr 21, 2017 at 9:39 AM, Ian Lepore  wrote:
> On Fri, 2017-04-21 at 21:53 +1000, Bruce Evans wrote:
>> On Fri, 21 Apr 2017, Hans Petter Selasky wrote:
>>
>> > On 04/21/17 10:10, Bruce Evans wrote:
>> >> ...
>> >> [...]
>>
>> With another hat on, I lecture about the error of using unsigned types
>> except in emergency.  int32_t time_t rollover in 2038 is getting a bit
>> closer to an emergency.  Even for variables and types that were
>> misdesigned to be unsigned, it is easy to forget this and use them in
>> things like delta-calculations which require signed types.
>>
>> Bruce
>>
>
> In freebsd, only i386 and powerpc32 use 32-bit time_t.  So we have 21
> years left to wither-away all use of those 32-bit arches. :)
>

Talking with kib yesterday I intend to move powerpc/powerpc{,spe} to
64-bit time_t for 12, unless there are any objections (will start the
bikeshed sometime in the next few months).

Since it's Tier-2 I don't have to worry too much about compatibility
(but will make some token effort).

- Justin
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317256 - head/sys/dev/syscons

2017-04-21 Thread Bruce Evans
Author: bde
Date: Fri Apr 21 15:12:43 2017
New Revision: 317256
URL: https://svnweb.freebsd.org/changeset/base/317256

Log:
  Merge the main ega drawing method into the main vga planar method and
  remove the former.
  
  All other EGA/VGA methods were already shared, with VGA-only features
  mostly not used and no decisions in inner loops to optimize fof VGA,
  but this method was split up because it is the only important one and
  using VGA methods if possible is about twice as fast.  The speed is
  mostly not from splitting to reduce branches but from doing half as
  many bus accesses, so make this easier to maintain by not splitting.
  There is now 1 extra branch in an inner loop where it costs less than
  1% of the bus access overhead on Haswell even if the compiler schedules
  it poorly.

Modified:
  head/sys/dev/syscons/scvgarndr.c

Modified: head/sys/dev/syscons/scvgarndr.c
==
--- head/sys/dev/syscons/scvgarndr.cFri Apr 21 14:50:29 2017
(r317255)
+++ head/sys/dev/syscons/scvgarndr.cFri Apr 21 15:12:43 2017
(r317256)
@@ -71,7 +71,6 @@ static vr_clear_t vga_pxlclear_direct;
 static vr_clear_t  vga_pxlclear_planar;
 static vr_draw_border_tvga_pxlborder_direct;
 static vr_draw_border_tvga_pxlborder_planar;
-static vr_draw_t   vga_egadraw;
 static vr_draw_t   vga_vgadraw_direct;
 static vr_draw_t   vga_vgadraw_planar;
 static vr_set_cursor_t vga_pxlcursor_shape;
@@ -524,10 +523,7 @@ vga_rndrinit(scr_stat *scp)
if (scp->sc->adp->va_info.vi_mem_model == V_INFO_MM_PLANAR) {
scp->rndr->clear = vga_pxlclear_planar;
scp->rndr->draw_border = vga_pxlborder_planar;
-   if (scp->sc->adp->va_type == KD_VGA)
-   scp->rndr->draw = vga_vgadraw_planar;
-   else
-   scp->rndr->draw = vga_egadraw;
+   scp->rndr->draw = vga_vgadraw_planar;
scp->rndr->draw_cursor = vga_pxlcursor_planar;
scp->rndr->blink_cursor = vga_pxlblink_planar;
scp->rndr->draw_mouse = vga_pxlmouse_planar;
@@ -684,64 +680,6 @@ vga_pxlborder_planar(scr_stat *scp, int 
outw(GDCIDX, 0x0001);   /* set/reset enable */
 }
 
-static void 
-vga_egadraw(scr_stat *scp, int from, int count, int flip)
-{
-   vm_offset_t d;
-   vm_offset_t e;
-   u_char *f;
-   u_short bg;
-   u_short col1, col2;
-   int line_width;
-   int i, j;
-   int a;
-   u_char c;
-
-   line_width = scp->sc->adp->va_line_width;
-
-   d = GET_PIXEL(scp, from, 1, line_width);
-
-   outw(GDCIDX, 0x0005);   /* read mode 0, write mode 0 */
-   outw(GDCIDX, 0x0003);   /* data rotate/function select */
-   outw(GDCIDX, 0x0f01);   /* set/reset enable */
-   bg = -1;
-   if (from + count > scp->xsize*scp->ysize)
-   count = scp->xsize*scp->ysize - from;
-   for (i = from; count-- > 0; ++i) {
-   a = sc_vtb_geta(>vtb, i);
-   if (flip) {
-   col1 = ((a & 0x7000) >> 4) | (a & 0x0800);
-   col2 = ((a & 0x8000) >> 4) | (a & 0x0700);
-   } else {
-   col1 = (a & 0x0f00);
-   col2 = (a & 0xf000) >> 4;
-   }
-   /* set background color in EGA/VGA latch */
-   if (bg != col2) {
-   bg = col2;
-   outw(GDCIDX, bg | 0x00);/* set/reset */
-   outw(GDCIDX, 0xff08);   /* bit mask */
-   writeb(d, 0);
-   c = readb(d);   /* set bg color in the latch */
-   }
-   /* foreground color */
-   outw(GDCIDX, col1 | 0x00);  /* set/reset */
-   e = d;
-   f = &(scp->font[sc_vtb_getc(>vtb, i)*scp->font_size]);
-   for (j = 0; j < scp->font_size; ++j, ++f) {
-   outw(GDCIDX, (*f << 8) | 0x08); /* bit mask */
-   writeb(e, 0);
-   e += line_width;
-   }
-   ++d;
-   if ((i % scp->xsize) == scp->xsize - 1)
-   d += scp->font_size * line_width - scp->xsize;
-   }
-   outw(GDCIDX, 0x);   /* set/reset */
-   outw(GDCIDX, 0x0001);   /* set/reset enable */
-   outw(GDCIDX, 0xff08);   /* bit mask */
-}
-
 static void
 vga_vgadraw_direct(scr_stat *scp, int from, int count, int flip)
 {
@@ -809,10 +747,13 @@ vga_vgadraw_planar(scr_stat *scp, int fr
 
d = GET_PIXEL(scp, from, 1, line_width);
 
-   outw(GDCIDX, 0x0305);   /* read mode 0, write mode 3 */
+   if (scp->sc->adp->va_type == KD_VGA) {
+   outw(GDCIDX, 0x0305);   

svn commit: r317255 - in head: share/man/man5 share/mk tools/build/options

2017-04-21 Thread Ed Maste
Author: emaste
Date: Fri Apr 21 14:50:29 2017
New Revision: 317255
URL: https://svnweb.freebsd.org/changeset/base/317255

Log:
  bsdgrep: disable GNU_GREP_COMPAT by default
  
  The GNU extension bits in the base system are old, no longer faithful
  to upstream, and surprising in some regards. Switch to documenting
  WITH_GNU_GREP_COMPAT and default GNU_GREP_COMPAT to OFF in the name of
  good behavior.
  
  According to http://www.regular-expressions.info, GNU extensions:
  
  -  Add missing quantifiers to BREs: \?, \+
  
  -  Add branching to BREs: \|
  
  -  Add backreferences (\1 through \9) to EREs
  
  -  Add \w, \W, \s, and \S corresponding to :alnum:, [^[:alnum:]],
 :space:, and [^[:space:]] respectively
  
  -  Add word boundaries and anchors:
 \b: word boundary
 \B: not word boundary
 \<: Strt of word
 \>: End of word
 \`: Start of subject string
  \': End of subject string
  
  These extensions are still available in /usr/bin/grep by default today,
  as it is still GNU grep.  As part of the bsdgrep migration plan these
  extensions may be added to bsdgrep's regex support if necessary.
  
  Submitted by: Kyle Evans 
  Reviewed by:  cem
  Differential Revision:https://reviews.freebsd.org/D10114

Added:
  head/tools/build/options/WITH_GNU_GREP_COMPAT   (contents, props changed)
Modified:
  head/share/man/man5/src.conf.5
  head/share/mk/src.opts.mk

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Fri Apr 21 14:36:09 2017
(r317254)
+++ head/share/man/man5/src.conf.5  Fri Apr 21 14:50:29 2017
(r317255)
@@ -732,9 +732,10 @@ and
 .It Va WITHOUT_GNU_GREP
 Set to not build GNU
 .Xr grep 1 .
-.It Va WITHOUT_GNU_GREP_COMPAT
-Set this option to omit the gnu extensions to grep from being included in
-BSD grep.
+.It Va WITH_GNU_GREP_COMPAT
+Set this option to include GNU extensions in
+.Xr bsdgrep 1
+by linking against libgnuregex.
 .It Va WITHOUT_GPIO
 Set to not build
 .Xr gpioctl 8

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Fri Apr 21 14:36:09 2017(r317254)
+++ head/share/mk/src.opts.mk   Fri Apr 21 14:50:29 2017(r317255)
@@ -99,7 +99,6 @@ __DEFAULT_YES_OPTIONS = \
 GCOV \
 GNU_DIFF \
 GNU_GREP \
-GNU_GREP_COMPAT \
 GPIO \
 GPL_DTC \
 GROFF \
@@ -181,6 +180,7 @@ __DEFAULT_NO_OPTIONS = \
 BSD_GREP \
 CLANG_EXTRAS \
 DTRACE_TESTS \
+GNU_GREP_COMPAT \
 HESIOD \
 LIBSOFT \
 NAND \

Added: head/tools/build/options/WITH_GNU_GREP_COMPAT
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/build/options/WITH_GNU_GREP_COMPAT   Fri Apr 21 14:50:29 
2017(r317255)
@@ -0,0 +1,4 @@
+.\" $FreeBSD$
+Set this option to include GNU extensions in
+.Xr bsdgrep 1
+by linking against libgnuregex.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r317208 - head/sys/netinet

2017-04-21 Thread Ian Lepore
On Fri, 2017-04-21 at 21:53 +1000, Bruce Evans wrote:
> On Fri, 21 Apr 2017, Hans Petter Selasky wrote:
> 
> > On 04/21/17 10:10, Bruce Evans wrote:
> >> ...
> >> [...]
> 
> With another hat on, I lecture about the error of using unsigned types
> except in emergency.  int32_t time_t rollover in 2038 is getting a bit
> closer to an emergency.  Even for variables and types that were
> misdesigned to be unsigned, it is easy to forget this and use them in
> things like delta-calculations which require signed types.
> 
> Bruce
> 

In freebsd, only i386 and powerpc32 use 32-bit time_t.  So we have 21
years left to wither-away all use of those 32-bit arches. :)

With laptops and other portable devices increasingly being built around
arm chips, and powerpc32 being relegated mostly to special purpose
embedded systems, it may just happen naturally.  (As someone who builds
special purpose embedded systems related to timekeeping, it probably
won't be as easy or natural for me.)

-- Ian
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317254 - in head: share/man/man5 share/mk tools/build/options usr.bin/grep

2017-04-21 Thread Ed Maste
Author: emaste
Date: Fri Apr 21 14:36:09 2017
New Revision: 317254
URL: https://svnweb.freebsd.org/changeset/base/317254

Log:
  bsdgrep: add BSD_GREP_FASTMATCH knob for built-in fastmatch
  
  Bugs have been found in the fastmatch implementation as used in bsdgrep.
  Some have been fixed (r316495) while fixes for others are in review
  (D10098).
  
  In comparison with the fastmatch implementation, Kyle Evans found that:
  
  - regex(3)'s performance with literal expressions offers a speed
improvement over fastmatch
  
  - regex(3)'s performance, both with simple BREs and EREs, seems to be
comparable
  
  The regex implementation was imported in r226035, and the commit message
  reports:
  
  This is a temporary solution until the whole regex library is
  not replaced so that BSD grep development can continue and the
  backported code gets some review and testing. This change only
  improves scalability slightly, there is no big performance boost
  yet but several minor bugs have been found and fixed.
  
  Introduce a WITH_/WITHOUT_BSD_GREP_FASTMATCH knob to support testing
  of both approaches.
  
  PR:   175314, 194823
  Submitted by: Kyle Evans 
  Reviewed by:  bdrewery (in part)
  Differential Revision:https://reviews.freebsd.org/D10282

Added:
  head/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH   (contents, props 
changed)
Modified:
  head/share/man/man5/src.conf.5
  head/share/mk/src.opts.mk
  head/usr.bin/grep/Makefile
  head/usr.bin/grep/grep.c
  head/usr.bin/grep/grep.h
  head/usr.bin/grep/util.c

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Fri Apr 21 13:45:01 2017
(r317253)
+++ head/share/man/man5/src.conf.5  Fri Apr 21 14:36:09 2017
(r317254)
@@ -1,6 +1,6 @@
 .\" DO NOT EDIT-- this file is generated by tools/build/options/makeman.
 .\" $FreeBSD$
-.Dd April 19, 2017
+.Dd April 21, 2017
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -215,6 +215,11 @@ Set to not build the BSD licensed versio
 .Xr libarchive 3 .
 .It Va WITH_BSD_GREP
 Install BSD-licensed grep as '[ef]grep' instead of GNU grep.
+.It Va WITHOUT_BSD_GREP_FASTMATCH
+Set this option to exclude the fastmatch implementation from
+.Xr bsdgrep 1 ,
+instead using only
+.Xr regex 3 .
 .It Va WITHOUT_BSNMP
 Set to not build or install
 .Xr bsnmpd 1

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Fri Apr 21 13:45:01 2017(r317253)
+++ head/share/mk/src.opts.mk   Fri Apr 21 14:36:09 2017(r317254)
@@ -62,6 +62,7 @@ __DEFAULT_YES_OPTIONS = \
 BOOTPARAMD \
 BOOTPD \
 BSD_CPIO \
+BSD_GREP_FASTMATCH \
 BSDINSTALL \
 BSNMP \
 BZIP2 \

Added: head/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/build/options/WITHOUT_BSD_GREP_FASTMATCH Fri Apr 21 14:36:09 
2017(r317254)
@@ -0,0 +1,5 @@
+.\" $FreeBSD$
+Set this option to exclude the fastmatch implementation from
+.Xr bsdgrep 1 ,
+instead using only
+.Xr regex 3 .

Modified: head/usr.bin/grep/Makefile
==
--- head/usr.bin/grep/Makefile  Fri Apr 21 13:45:01 2017(r317253)
+++ head/usr.bin/grep/Makefile  Fri Apr 21 14:36:09 2017(r317254)
@@ -15,10 +15,14 @@ bsdgrep.1: grep.1
 .endif
 SRCS=  file.c grep.c queue.c util.c
 
-# Extra files ported backported form some regex improvements
+.if ${MK_BSD_GREP_FASTMATCH} == "yes"
+# Extra files ported backported for some regex improvements
 .PATH: ${.CURDIR}/regex
 SRCS+= fastmatch.c hashtable.c tre-compile.c tre-fastmatch.c
 CFLAGS+=-I${.CURDIR}/regex
+.else
+CFLAGS+= -DWITHOUT_FASTMATCH
+.endif
 
 CFLAGS.gcc+= --param max-inline-insns-single=500
 

Modified: head/usr.bin/grep/grep.c
==
--- head/usr.bin/grep/grep.cFri Apr 21 13:45:01 2017(r317253)
+++ head/usr.bin/grep/grep.cFri Apr 21 14:36:09 2017(r317254)
@@ -49,7 +49,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#ifndef WITHOUT_FASTMATCH
 #include "fastmatch.h"
+#endif
 #include "grep.h"
 
 #ifndef WITHOUT_NLS
@@ -86,7 +88,9 @@ unsigned int   patterns;
 static unsigned int pattern_sz;
 struct pat *pattern;
 regex_t*r_pattern;
+#ifndef WITHOUT_FASTMATCH
 fastmatch_t*fg_pattern;
+#endif
 
 /* Filename exclusion/inclusion patterns */
 unsigned int   fpatterns, dpatterns;
@@ -715,20 +719,25 @@ main(int argc, char *argv[])
usage();
}
 
+#ifndef WITHOUT_FASTMATCH
fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern));
+#endif
r_pattern = grep_calloc(patterns, sizeof(*r_pattern));
 
 

Re: svn commit: r317231 - head/usr.bin/systat

2017-04-21 Thread Bruce Evans

On Fri, 21 Apr 2017, Bruce Evans wrote:


On Thu, 20 Apr 2017, Jung-uk Kim wrote:


Log:
 Fix systat(1) regression.  It was broken by r317061.


It is more broken than before.  Now it fails when the kernel is older
than the utility instead of vice versa.  When it fails, the failures
are more serious than before.  systat -v actually does complete
checking for errors (some are only errors in itself), but mishandles
them.  It reports the errors on the status line and continues.  The
error message overwrites the previous one.  Continuing is more broken
than before:


The follow patch reduces the ABI breakage as much as possible.  On a
lightly loaded system, the maximum value in any counter used by top,
vmstat or systat -v is growing at a rate of 1M per hour, so the 32-bit
variables in the application are enough for about 166 days.

I only applied the fix to some counter sysctls with broken ABIs, but
wrote it for general use.  It doesn't handle SYSCTL_IN(), and assumes
unsigned counters.

X Index: subr_counter.c
X ===
X --- subr_counter.c(revision 317243)
X +++ subr_counter.c(working copy)
X @@ -74,6 +75,95 @@
X   uma_zfree(pcpu_zone_64, c);
X  }
X 
X +/* Output a signed integer with the caller's size as well as possible. */

X +__unused
X +static int
X +sysctl_out_i(struct sysctl_req *req, intmax_t val)
X +{
X + intmax_t valtrunc;
X + int64_t val64;
X + int32_t val32;
X + int16_t val16;
X + int8_t val8;
X + int error;
X +
X + switch (req->oldlen) {
X + case 1:
X + valtrunc = val8 = val;
X + error = SYSCTL_OUT(req, , 1);
X + break;
X + case 2:
X + valtrunc = val16 = val;
X + error = SYSCTL_OUT(req, , 2);
X + break;
X + case 4:
X + valtrunc = val32 = val;
X + error = SYSCTL_OUT(req, , 4);
X + break;
X + case 8:
X + valtrunc = val64 = val;
X + error = SYSCTL_OUT(req, , 8);
X + break;
X + default:
X + valtrunc = val;
X + error = SYSCTL_OUT(req, , sizeof(val));
X + break;
X + }
X + if (valtrunc != val && error == 0)
X + error = EOVERFLOW;
X + return (error);
X +}
X +
X +uintmax_t sysoui_max;
X +
X +/* Output an unsigned integer with the caller's size as well as possible. */
X +static int
X +sysctl_out_ui(struct sysctl_req *req, uintmax_t val)
X +{
X + uintmax_t valtrunc;
X + uint64_t val64;
X + uint32_t val32;
X + uint16_t val16;
X + uint8_t val8;
X + int error;
X +
X + if (sysoui_max < val) {
X + sysoui_max = val;
X + if ((val & 0x) == 0)
X + printf("new sysoui_max %#jx\n", val);
X + }
X + val64 = val32 = val16 = val8 = 0;
X + switch (req->oldlen) {
X + case 1:
X + valtrunc = val8 = val;
X + error = SYSCTL_OUT(req, , 1);
X + break;
X + case 2:
X + valtrunc = val16 = val;
X + error = SYSCTL_OUT(req, , 2);
X + break;
X + case 4:
X + valtrunc = val32 = val;
X + error = SYSCTL_OUT(req, , 4);
X + break;
X + case 8:
X + valtrunc = val64 = val;
X + error = SYSCTL_OUT(req, , 8);
X + break;
X + default:
X + valtrunc = val;
X + error = SYSCTL_OUT(req, , sizeof(val));
X + break;
X + }
X + if (valtrunc != val && error == 0) {
X + printf(
X + "val %#jx, valtrunc %#jx, val64 %#jx, val32 %#x, val16 %#x, val8 %#x\n",
X + val, valtrunc, val64, val32, val16, val8);
X + error = EOVERFLOW;
X + }
X + return (error);
X +}
X +
X  int
X  sysctl_handle_counter_u64(SYSCTL_HANDLER_ARGS)
X  {
X @@ -82,7 +172,7 @@
X 
X  	out = counter_u64_fetch(*(counter_u64_t *)arg1);
X 
X -	error = SYSCTL_OUT(req, , sizeof(uint64_t));

X + error = sysctl_out_ui(req, out);
X 
X  	if (error || !req->newptr)

X   return (error);

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317253 - head/sys/net

2017-04-21 Thread Alexander Motin
Author: mav
Date: Fri Apr 21 13:45:01 2017
New Revision: 317253
URL: https://svnweb.freebsd.org/changeset/base/317253

Log:
  Add interface reference counting to if_lagg.
  
  Using plain ifunit() looks like request for troubles.
  
  MFC after:2 weeks

Modified:
  head/sys/net/if_lagg.c

Modified: head/sys/net/if_lagg.c
==
--- head/sys/net/if_lagg.c  Fri Apr 21 13:39:14 2017(r317252)
+++ head/sys/net/if_lagg.c  Fri Apr 21 13:45:01 2017(r317253)
@@ -683,6 +683,7 @@ lagg_port_lladdr(struct lagg_port *lp, u
if (llq == NULL)/* XXX what to do */
return;
 
+   if_ref(ifp);
llq->llq_ifp = ifp;
llq->llq_type = llq_type;
bcopy(lladdr, llq->llq_lladdr, ETHER_ADDR_LEN);
@@ -731,6 +732,7 @@ lagg_port_setlladdr(void *arg, int pendi
EVENTHANDLER_INVOKE(iflladdr_event, ifp);
CURVNET_RESTORE();
head = SLIST_NEXT(llq, llq_entries);
+   if_rele(ifp);
free(llq, M_DEVBUF);
}
 }
@@ -805,6 +807,7 @@ lagg_port_create(struct lagg_softc *sc, 
lp->lp_output = ifp->if_output;
ifp->if_output = lagg_port_output;
 
+   if_ref(ifp);
lp->lp_ifp = ifp;
lp->lp_softc = sc;
 
@@ -958,6 +961,7 @@ lagg_port_destroy(struct lagg_port *lp, 
if (llq->llq_ifp == ifp) {
SLIST_REMOVE(>sc_llq_head, llq, lagg_llq,
llq_entries);
+   if_rele(llq->llq_ifp);
free(llq, M_DEVBUF);
break;  /* Only appears once */
}
@@ -967,6 +971,7 @@ lagg_port_destroy(struct lagg_port *lp, 
if (lp->lp_ifflags)
if_printf(ifp, "%s: lp_ifflags unclean\n", __func__);
 
+   if_rele(ifp);
free(lp, M_DEVBUF);
 
/* Update lagg capabilities */
@@ -1443,7 +1448,7 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
break;
case SIOCGLAGGPORT:
if (rp->rp_portname[0] == '\0' ||
-   (tpif = ifunit(rp->rp_portname)) == NULL) {
+   (tpif = ifunit_ref(rp->rp_portname)) == NULL) {
error = EINVAL;
break;
}
@@ -1453,18 +1458,20 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
lp->lp_softc != sc) {
error = ENOENT;
LAGG_RUNLOCK(sc, );
+   if_rele(tpif);
break;
}
 
lagg_port2req(lp, rp);
LAGG_RUNLOCK(sc, );
+   if_rele(tpif);
break;
case SIOCSLAGGPORT:
error = priv_check(td, PRIV_NET_LAGG);
if (error)
break;
if (rp->rp_portname[0] == '\0' ||
-   (tpif = ifunit(rp->rp_portname)) == NULL) {
+   (tpif = ifunit_ref(rp->rp_portname)) == NULL) {
error = EINVAL;
break;
}
@@ -1491,13 +1498,14 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
LAGG_WLOCK(sc);
error = lagg_port_create(sc, tpif);
LAGG_WUNLOCK(sc);
+   if_rele(tpif);
break;
case SIOCSLAGGDELPORT:
error = priv_check(td, PRIV_NET_LAGG);
if (error)
break;
if (rp->rp_portname[0] == '\0' ||
-   (tpif = ifunit(rp->rp_portname)) == NULL) {
+   (tpif = ifunit_ref(rp->rp_portname)) == NULL) {
error = EINVAL;
break;
}
@@ -1507,11 +1515,13 @@ lagg_ioctl(struct ifnet *ifp, u_long cmd
lp->lp_softc != sc) {
error = ENOENT;
LAGG_WUNLOCK(sc);
+   if_rele(tpif);
break;
}
 
error = lagg_port_destroy(lp, 1);
LAGG_WUNLOCK(sc);
+   if_rele(tpif);
break;
case SIOCSIFFLAGS:
/* Set flags on ports too */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317252 - head/gnu/usr.bin

2017-04-21 Thread Ed Maste
Author: emaste
Date: Fri Apr 21 13:39:14 2017
New Revision: 317252
URL: https://svnweb.freebsd.org/changeset/base/317252

Log:
  Simplify gnu/usr.bin Makefile conditions
  
  After r307655 MK_GDB is forced to no if MK_BINUTILS is no, and similarly
  MK_GROFF is forced to no if MK_CXX is no, so we can remove nested
  conditionals.
  
  Reviewed by:  bapt, brooks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D8287

Modified:
  head/gnu/usr.bin/Makefile

Modified: head/gnu/usr.bin/Makefile
==
--- head/gnu/usr.bin/Makefile   Fri Apr 21 11:48:12 2017(r317251)
+++ head/gnu/usr.bin/Makefile   Fri Apr 21 13:39:14 2017(r317252)
@@ -5,21 +5,17 @@
 
 .if ${MK_CXX} != "no"
 SUBDIR.${MK_GCC}+= gperf
-SUBDIR.${MK_GROFF}+=   groff
 .endif
 
 SUBDIR.${MK_BINUTILS}+=binutils
 SUBDIR.${MK_DIALOG}+=  dialog
-
-.if ${MK_BINUTILS} != "no"
-SUBDIR.${MK_GDB}+= gdb
-SUBDIR_DEPEND_gdb= binutils
-.endif
-
 SUBDIR.${MK_GCC}+= cc
 SUBDIR.${MK_GNU_DIFF}+=diff3
 SUBDIR.${MK_GNU_GREP}+=grep
+SUBDIR.${MK_GDB}+= gdb
+SUBDIR_DEPEND_gdb= binutils
 SUBDIR.${MK_GPL_DTC}+= dtc
+SUBDIR.${MK_GROFF}+=   groff
 SUBDIR.${MK_TESTS}+=   tests
 
 SUBDIR_PARALLEL=
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r317240 - head/sys/fs/nfs

2017-04-21 Thread Bruce Evans

On Fri, 21 Apr 2017, Rick Macklem wrote:


Yes, I agree that hardcoded values are bad.
Thanks for pointing out the constants in sys/conf.h, I can use those instead.
sys/conf.h does not have an entry for "nogroup", which is what has been used
by nfsuserd since it was written.

Is adding an entry to sys/conf.h for GID_NOGROUP ok to do?


It is currently mostly for device configuration, but the user/group defines
in it are already misplaced (for convenience) so a couple more wouldn't hurt.


rick
ps: I hope you don't mind the top post...


I prefer not.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r317208 - head/sys/netinet

2017-04-21 Thread Bruce Evans

On Fri, 21 Apr 2017, Hans Petter Selasky wrote:


On 04/21/17 10:10, Bruce Evans wrote:

...
i386 should use time_t = uint32_t to fully support years 2038-2106 instead
of time_t = int32_t to partially support years 1902-1970
  (even time 0 (the Epoch) and other early hours in 1970 are not fully
  supported now and would be broken by unsigned time_t, since subtraction
  of the timezone offset from 0 gives negative values with signed time_t
  and overflowing values with unsigned time_t).  (time_t)-1 is special,
  so the time 1 second before the Epoch cannot work with signed time_t.
  This value works better with unsigned time_t because it is not in the
  middle of the range, but times before the Epoch are just unrepresentable
  with unsigned time_t.

Changing the signedness of time_t would break the ABI less than changing
its size, but it still causes problems with buggy software which assumes
that time_t is signed or encodes special values in it.  Negative times
are at best unspecified by POSIX.  They give a large range of magic out
of band values below 0, provided nothing assumes that the system is better
designed than POSIX so supports times before the Epoch.  Even the Standard
C library is not that bad, except POSIX forces a bad design for time_t so
mktime() and friends are restricted to times.  If time_t is unsigned,
then no times before the Epoch can work, and if it is signed then times
before
the Epoch are unportable.

...

Your proposal to change time_t to unsigned type is potentially dangerous in 
combination with NTP, where negative time deltas may occur. Consider existing 
code like this, both in three and outside the tree.


Yes, I already pointed out that there is a lot of buggy software out there.
Maybe ntp understansd time_t, but its users might not.


static time_t last;
time_t now = time();
time_t delta

delta = now - last;


This assumes something like POSIX plus signed time_t.  In standard C,
time_t can be almost anything so the subtraction is invalid.  You have
to use difftime().  difftime() was heavyweight when C was young, but
now with time_t = double and difftime() inline, it is probably lighter
and faster than POSIX timespecs.  difftime(x, y) can be just x - y
in 64-bit double precision, while timespecs may be bloated to 128 bits
and are in a non-binary format that is hard to subtract.  Timespecs
do have a larger range.  The precision of 64-bit double is only enough
for microseconds resolution over 272 years.  So it can easily replace
timevals but not timespecs.

In original POSIX, time_t could be any arithmetic type.  This allowed
it to be double.  Good for userland but bad for kernels and sysctls,
so few or no POSIX systems made it double.  time_t is now integral
in POSIX.  It could be unsigned the last time I looked.


if (delta > 0) {
  /* do something */
} else {
  /* ignore */
}

If time_t is now unsigned, then the check above becomes true for alomost all 
values of time_t, except zero, which is wrong!


Who would write such buggy code? :-)  Practical POSIX code near ntp would
probably use timespecs or timevals, and they can't be subtracted or compared
easily anyway.  FreeBSD has macros for this, but they are unportable and
not as easy to use as difftime or simple conversion to floating point
(except for timespecs, the conversion is not so simple since it may lose
resolution).


Can C-compilers assert signedness of a variable?


Yes, but they don't since this would find too many errors and non-errors
for conversions.


I propose, utime_t -> unsigned time and stime_t -> signed time.


That would just increase unportability and not help to avoid changing
the size of time_t in standard APIs that require it.

With another hat on, I lecture about the error of using unsigned types
except in emergency.  int32_t time_t rollover in 2038 is getting a bit
closer to an emergency.  Even for variables and types that were
misdesigned to be unsigned, it is easy to forget this and use them in
things like delta-calculations which require signed types.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317251 - head/sys/fs/nfs

2017-04-21 Thread Rick Macklem
Author: rmacklem
Date: Fri Apr 21 11:48:12 2017
New Revision: 317251
URL: https://svnweb.freebsd.org/changeset/base/317251

Log:
  Revert r317240. I didn't realize there were defined constants for
  uid/gid values in sys/conf.h. I will do another commit using those.

Modified:
  head/sys/fs/nfs/nfs_commonsubs.c

Modified: head/sys/fs/nfs/nfs_commonsubs.c
==
--- head/sys/fs/nfs/nfs_commonsubs.cFri Apr 21 10:16:34 2017
(r317250)
+++ head/sys/fs/nfs/nfs_commonsubs.cFri Apr 21 11:48:12 2017
(r317251)
@@ -63,8 +63,8 @@ int nfsrv_useacl = 1;
 struct nfssockreq nfsrv_nfsuserdsock;
 int nfsrv_nfsuserd = 0;
 struct nfsreqhead nfsd_reqq;
-uid_t nfsrv_defaultuid = 65534;
-gid_t nfsrv_defaultgid = 65533;
+uid_t nfsrv_defaultuid;
+gid_t nfsrv_defaultgid;
 int nfsrv_lease = NFSRV_LEASE;
 int ncl_mbuf_mlen = MLEN;
 int nfsd_enable_stringtouid = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r317240 - head/sys/fs/nfs

2017-04-21 Thread Rick Macklem
Yes, I agree that hardcoded values are bad.
Thanks for pointing out the constants in sys/conf.h, I can use those instead.
sys/conf.h does not have an entry for "nogroup", which is what has been used
by nfsuserd since it was written.

Is adding an entry to sys/conf.h for GID_NOGROUP ok to do?

rick
ps: I hope you don't mind the top post...

From: Bruce Evans 
Sent: Friday, April 21, 2017 1:19:25 AM
To: Rick Macklem
Cc: src-committ...@freebsd.org; svn-src-...@freebsd.org; 
svn-src-head@freebsd.org
Subject: Re: svn commit: r317240 - head/sys/fs/nfs

On Fri, 21 Apr 2017, Rick Macklem wrote:

> Log:
>  Set default uid/gid to nobody/nogroup for NFSv4 mapping.
>
>  The default uid/gid for NFSv4 are set by the nfsuserd(8) daemon.
>  However, they were 0 until the nfsuserd(8) was run. Since it is
>  possible to use NFSv4 without running the nfsuserd(8) daemon, set them
>  to nobody/nogroup initially.
>  Without this patch, the values would be set by the nfsuserd(8) daemon
>  and left changed even if the nfsuserd(8) daemon was killed. Also, the default
>  values of 0 meant that setting a group to "wheel" would fail even when
>  done by root and this patch fixes this issue.

Hard-coding these values is wrong, and the actual values seem wronger.

The values in nfsuserd(8) are clearly wrong.  It hard-codes 32767 (with
bogus casts) for both the default uid and the default gid.  These values
are in the user namespace have nothing to do with nobody/nogroup.

>  and left changed even if the nfsuserd(8) daemon was killed. Also, the default
>  ...
> Modified: head/sys/fs/nfs/nfs_commonsubs.c
> ==
> --- head/sys/fs/nfs/nfs_commonsubs.c  Fri Apr 21 00:45:44 2017
> (r317239)
> +++ head/sys/fs/nfs/nfs_commonsubs.c  Fri Apr 21 01:50:41 2017
> (r317240)
> @@ -63,8 +63,8 @@ int nfsrv_useacl = 1;
> struct nfssockreq nfsrv_nfsuserdsock;
> int nfsrv_nfsuserd = 0;
> struct nfsreqhead nfsd_reqq;
> -uid_t nfsrv_defaultuid;
> -gid_t nfsrv_defaultgid;
> +uid_t nfsrv_defaultuid = 65534;
> +gid_t nfsrv_defaultgid = 65533;
> int nfsrv_lease = NFSRV_LEASE;
> int ncl_mbuf_mlen = MLEN;
> int nfsd_enable_stringtouid = 0;

These are the traditional values in /etc/group.  It is bogus but traditional
to have a uid in /etc/group.  nobody doesn't actually have group nogroup.
nobody is also in the correct place (/etc/passwd) provided the sysadmin
didn't meddle with this, but it has group 65534 there.  Group 65533 is
traditionally for kmem and tty in /etc/passwd.

mountd uses the less bogus values with more bogus casts (uid_t)-2 and
(gid_t)-2.  These are obfuscated spellings of 0xfffe.  You don't
really want these values to depend on the types because then the values
break when the types are expanded, like they already did for the
expansion to 32 bits.  These values should be reserved in /etc/passwd
and /etc/group, but they still aren't, 20-25 years after the expansion.
You don't want to spell these values in decimal because decimal values
much larger than 65534 are too hard to convert back to hex to see what
they mean.  The bogus casts are to break warnings about converting the
easy-to-remember (but wrong becaus they are negative) values of -2 to
unsigned.

The magic values are still incompletely documented in exports(8) as
pure -2:-2.  It doesn't mention nobody or any other magic numbers or
any bugs in defaulting or specifying the numbers.

Last time I looked, most utilities and even basic library functions
had the usual errors for parsing large and negative values by misusing
atoi() or strtol().  Many can't parse 0xfffe or even this value
in decimal, so the value has to be spelled -2 so that undocumented
overflow bugs can convert it to the correct value of 0xe.  On
64-bit systems, it might be first converted to 0xe so
another layer of overflow bugs is needed to get back to 0xfffe.
Since library functions are buggy, it is at best unportable to put any
of -2, 0xfffe or this value in hex in /etc/passwd or /etc/group.
65534 always worked there since it is much smaller than 32-bit LONG_MAX
and the library was probably never bad enough to use atoi() and 16-bit
ints.  IIRC, -2 doesn't wrok in /etc/passwd, but is the only spelling
that works near mountd.

Checking now shows mountd using many different misparsing methods:
- it uses only atoi() in parescred().  This can read -2 in /etc/exports,
   but misparses the correct value of 0xfffe to 0 and the correct
   value of this in decimal to 0x7fffl; it silently ignores errors
   in both cases; it blindly assigns to uid_t/gid_t, so -2 becomes the
   correct value
- it uses strtol() with mostly missing and half wrong error checking
   for masklen
- it uses strtoul() with mostly wrong but not so much missing error
   checking for -p.  First it truncates the value to break its subsequent
   range checks...
- its use 

Re: svn commit: r317208 - head/sys/netinet

2017-04-21 Thread Hans Petter Selasky

On 04/21/17 10:10, Bruce Evans wrote:

On Fri, 21 Apr 2017, Michael Tuexen wrote:


On 21. Apr 2017, at 05:16, Bruce Evans  wrote:

On Thu, 20 Apr 2017, Cy Schubert wrote:

Please trim quotes.


In message <201704201919.v3kjjyko052...@repo.freebsd.org>, Michael
Tuexen
write
s:


[>> ... 5 lines trimmed]


Log:
 Syncoockies can be used in combination with the syncache. If the
cache
 overflows, syncookies are used.


[>> ... 16 lines trimmed]


Modified: head/sys/netinet/tcp_syncache.c
=

=
--- head/sys/netinet/tcp_syncache.cThu Apr 20 19:14:52 2017
(r31720
7)
+++ head/sys/netinet/tcp_syncache.cThu Apr 20 19:19:33 2017
(r31720
8)
@@ -260,6 +260,7 @@ syncache_init(void)
 _tcp_syncache.hashbase[i].sch_mtx, 0);
V_tcp_syncache.hashbase[i].sch_length = 0;
V_tcp_syncache.hashbase[i].sch_sc = _tcp_syncache;
+V_tcp_syncache.hashbase[i].sch_last_overflow = INT64_MIN;

...
This line produced the following on i386:

/opt/src/svn-current/sys/netinet/tcp_syncache.c:263:50: error: implicit
conversion from 'long long' to 'time_t' (aka 'int') changes value from
-9223372036854775808 to 0 [-Werror,-Wconstant-conversion]
  V_tcp_syncache.hashbase[i].sch_last_overflow = INT64_MIN;
   ~ ^
./x86/_stdint.h:91:41: note: expanded from macro 'INT64_MIN'
#define INT64_MIN   (-0x7fffLL-1)
   ~^~

Looks like it needs a time_t cast.


A cast would just break the warning.  INT64_MIN has nothing to do with
time_t.  The expression (time_t)INT64_MIN would be more obviously
garbage
since in the above it is not clear that sch_last_overflow has a type
unrelated to the constant.

Fixed in https://svnweb.freebsd.org/changeset/base/317244


INT64_MIN is also broken if time_t is 64 bits but unsigned.  Then it is
converted to half of plus infinity instead of the intended minus
infinity.

The patch assumes that time_t is signed, which is true for FreeBSD on all
platforms. Or am I missing a platform?


Only future platforms.

i386 should use time_t = uint32_t to fully support years 2038-2106 instead
of time_t = int32_t to partially support years 1902-1970
  (even time 0 (the Epoch) and other early hours in 1970 are not fully
  supported now and would be broken by unsigned time_t, since subtraction
  of the timezone offset from 0 gives negative values with signed time_t
  and overflowing values with unsigned time_t).  (time_t)-1 is special,
  so the time 1 second before the Epoch cannot work with signed time_t.
  This value works better with unsigned time_t because it is not in the
  middle of the range, but times before the Epoch are just unrepresentable
  with unsigned time_t.

Changing the signedness of time_t would break the ABI less than changing
its size, but it still causes problems with buggy software which assumes
that time_t is signed or encodes special values in it.  Negative times
are at best unspecified by POSIX.  They give a large range of magic out
of band values below 0, provided nothing assumes that the system is better
designed than POSIX so supports times before the Epoch.  Even the Standard
C library is not that bad, except POSIX forces a bad design for time_t so
mktime() and friends are restricted to times.  If time_t is unsigned,
then no times before the Epoch can work, and if it is signed then times
before
the Epoch are unportable.

netinet could use non-negative times far in the past as out-of-band
values if there are any.  But it mostly uses monotonic times.  The
Epoch for monotonic times starts at boot time (modulo other bugs), so
there are not enough times far enough in the past shortly after booting.
If time_t is unsigned, there just aren't enough, and if it is signed
there are only enough by using unportable negative times.


Hi,

Your proposal to change time_t to unsigned type is potentially dangerous 
in combination with NTP, where negative time deltas may occur. Consider 
existing code like this, both in three and outside the tree.


static time_t last;
time_t now = time();
time_t delta

delta = now - last;
if (delta > 0) {
   /* do something */
} else {
   /* ignore */
}

If time_t is now unsigned, then the check above becomes true for alomost 
all values of time_t, except zero, which is wrong!


Can C-compilers assert signedness of a variable?


I propose, utime_t -> unsigned time and stime_t -> signed time.

--HPS
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r317208 - head/sys/netinet

2017-04-21 Thread Bruce Evans

On Fri, 21 Apr 2017, Michael Tuexen wrote:


On 21. Apr 2017, at 05:16, Bruce Evans  wrote:

On Thu, 20 Apr 2017, Cy Schubert wrote:

Please trim quotes.


In message <201704201919.v3kjjyko052...@repo.freebsd.org>, Michael Tuexen
write
s:


[>> ... 5 lines trimmed]


Log:
 Syncoockies can be used in combination with the syncache. If the cache
 overflows, syncookies are used.


[>> ... 16 lines trimmed]


Modified: head/sys/netinet/tcp_syncache.c
=
=
--- head/sys/netinet/tcp_syncache.c Thu Apr 20 19:14:52 2017(r31720
7)
+++ head/sys/netinet/tcp_syncache.c Thu Apr 20 19:19:33 2017(r31720
8)
@@ -260,6 +260,7 @@ syncache_init(void)
 _tcp_syncache.hashbase[i].sch_mtx, 0);
V_tcp_syncache.hashbase[i].sch_length = 0;
V_tcp_syncache.hashbase[i].sch_sc = _tcp_syncache;
+   V_tcp_syncache.hashbase[i].sch_last_overflow = INT64_MIN;

...
This line produced the following on i386:

/opt/src/svn-current/sys/netinet/tcp_syncache.c:263:50: error: implicit
conversion from 'long long' to 'time_t' (aka 'int') changes value from
-9223372036854775808 to 0 [-Werror,-Wconstant-conversion]
  V_tcp_syncache.hashbase[i].sch_last_overflow = INT64_MIN;
   ~ ^
./x86/_stdint.h:91:41: note: expanded from macro 'INT64_MIN'
#define INT64_MIN   (-0x7fffLL-1)
   ~^~

Looks like it needs a time_t cast.


A cast would just break the warning.  INT64_MIN has nothing to do with
time_t.  The expression (time_t)INT64_MIN would be more obviously garbage
since in the above it is not clear that sch_last_overflow has a type
unrelated to the constant.

Fixed in https://svnweb.freebsd.org/changeset/base/317244


INT64_MIN is also broken if time_t is 64 bits but unsigned.  Then it is
converted to half of plus infinity instead of the intended minus infinity.

The patch assumes that time_t is signed, which is true for FreeBSD on all
platforms. Or am I missing a platform?


Only future platforms.

i386 should use time_t = uint32_t to fully support years 2038-2106 instead
of time_t = int32_t to partially support years 1902-1970
  (even time 0 (the Epoch) and other early hours in 1970 are not fully
  supported now and would be broken by unsigned time_t, since subtraction
  of the timezone offset from 0 gives negative values with signed time_t
  and overflowing values with unsigned time_t).  (time_t)-1 is special,
  so the time 1 second before the Epoch cannot work with signed time_t.
  This value works better with unsigned time_t because it is not in the
  middle of the range, but times before the Epoch are just unrepresentable
  with unsigned time_t.

Changing the signedness of time_t would break the ABI less than changing
its size, but it still causes problems with buggy software which assumes
that time_t is signed or encodes special values in it.  Negative times
are at best unspecified by POSIX.  They give a large range of magic out
of band values below 0, provided nothing assumes that the system is better
designed than POSIX so supports times before the Epoch.  Even the Standard
C library is not that bad, except POSIX forces a bad design for time_t so
mktime() and friends are restricted to times.  If time_t is unsigned, then 
no times before the Epoch can work, and if it is signed then times before

the Epoch are unportable.

netinet could use non-negative times far in the past as out-of-band
values if there are any.  But it mostly uses monotonic times.  The
Epoch for monotonic times starts at boot time (modulo other bugs), so
there are not enough times far enough in the past shortly after booting.
If time_t is unsigned, there just aren't enough, and if it is signed
there are only enough by using unportable negative times.

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317247 - head/sys/geom/eli

2017-04-21 Thread Alexander Motin
Author: mav
Date: Fri Apr 21 07:43:44 2017
New Revision: 317247
URL: https://svnweb.freebsd.org/changeset/base/317247

Log:
  Dump md_iterations as signed, which it really is.
  
  PR:   208305
  PR:   196834
  MFC after:2 weeks

Modified:
  head/sys/geom/eli/g_eli.h

Modified: head/sys/geom/eli/g_eli.h
==
--- head/sys/geom/eli/g_eli.h   Fri Apr 21 07:16:07 2017(r317246)
+++ head/sys/geom/eli/g_eli.h   Fri Apr 21 07:43:44 2017(r317247)
@@ -510,7 +510,7 @@ eli_metadata_dump(const struct g_eli_met
printf("  provsize: %ju\n", (uintmax_t)md->md_provsize);
printf("sectorsize: %u\n", (u_int)md->md_sectorsize);
printf("  keys: 0x%02x\n", (u_int)md->md_keys);
-   printf("iterations: %u\n", (u_int)md->md_iterations);
+   printf("iterations: %d\n", (int)md->md_iterations);
bzero(str, sizeof(str));
for (i = 0; i < sizeof(md->md_salt); i++) {
str[i * 2] = hex[md->md_salt[i] >> 4];
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317246 - in head: sbin/geom/class/eli sys/geom/eli

2017-04-21 Thread Alexander Motin
Author: mav
Date: Fri Apr 21 07:16:07 2017
New Revision: 317246
URL: https://svnweb.freebsd.org/changeset/base/317246

Log:
  Always allow setting number of iterations for the first time.
  
  Before this change it was impossible to set number of PKCS#5v2 iterations,
  required to set passphrase, if it has two keys and never had any passphrase.
  Due to present metadata format limitations there are still cases when number
  of iterations can not be changed, but now it works in cases when it can.
  
  PR:   218512
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.
  Differential Revision:https://reviews.freebsd.org/D10338

Modified:
  head/sbin/geom/class/eli/geom_eli.c
  head/sys/geom/eli/g_eli_ctl.c

Modified: head/sbin/geom/class/eli/geom_eli.c
==
--- head/sbin/geom/class/eli/geom_eli.c Fri Apr 21 06:55:17 2017
(r317245)
+++ head/sbin/geom/class/eli/geom_eli.c Fri Apr 21 07:16:07 2017
(r317246)
@@ -1118,7 +1118,9 @@ eli_setkey_detached(struct gctl_req *req
 
val = gctl_get_intmax(req, "iterations");
/* Check if iterations number should and can be changed. */
-   if (val != -1) {
+   if (val != -1 && md->md_iterations == -1) {
+   md->md_iterations = val;
+   } else if (val != -1 && val != md->md_iterations) {
if (bitcount32(md->md_keys) != 1) {
gctl_error(req, "To be able to use '-i' option, only "
"one key can be defined.");

Modified: head/sys/geom/eli/g_eli_ctl.c
==
--- head/sys/geom/eli/g_eli_ctl.c   Fri Apr 21 06:55:17 2017
(r317245)
+++ head/sys/geom/eli/g_eli_ctl.c   Fri Apr 21 07:16:07 2017
(r317246)
@@ -618,7 +618,9 @@ g_eli_ctl_setkey(struct gctl_req *req, s
return;
}
/* Check if iterations number should and can be changed. */
-   if (*valp != -1) {
+   if (*valp != -1 && md.md_iterations == -1) {
+   md.md_iterations = *valp;
+   } else if (*valp != -1 && *valp != md.md_iterations) {
if (bitcount32(md.md_keys) != 1) {
gctl_error(req, "To be able to use '-i' option, only "
"one key can be defined.");
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317245 - head/sys/dev/syscons

2017-04-21 Thread Bruce Evans
Author: bde
Date: Fri Apr 21 06:55:17 2017
New Revision: 317245
URL: https://svnweb.freebsd.org/changeset/base/317245

Log:
  Oops, the previous commit swapped the main ega method with the main
  vga planar method (for testing that was supposed to be local that the
  former still works).  The ega method works on vga but is about twice
  as slow.  The vga method doesn't work on ega.
  
  Optimize the main vga planar method a little.  For changing the
  background color (which was otherwise optimized better than most
  things), don't switch the write mode from 3 to 0 just to select
  the pixel mask of 0xff obscurely by writing 0.  Just write 0xff
  directly.

Modified:
  head/sys/dev/syscons/scvgarndr.c

Modified: head/sys/dev/syscons/scvgarndr.c
==
--- head/sys/dev/syscons/scvgarndr.cFri Apr 21 06:05:34 2017
(r317244)
+++ head/sys/dev/syscons/scvgarndr.cFri Apr 21 06:55:17 2017
(r317245)
@@ -525,9 +525,9 @@ vga_rndrinit(scr_stat *scp)
scp->rndr->clear = vga_pxlclear_planar;
scp->rndr->draw_border = vga_pxlborder_planar;
if (scp->sc->adp->va_type == KD_VGA)
-   scp->rndr->draw = vga_egadraw;
-   else
scp->rndr->draw = vga_vgadraw_planar;
+   else
+   scp->rndr->draw = vga_egadraw;
scp->rndr->draw_cursor = vga_pxlcursor_planar;
scp->rndr->blink_cursor = vga_pxlblink_planar;
scp->rndr->draw_mouse = vga_pxlmouse_planar;
@@ -828,11 +828,9 @@ vga_vgadraw_planar(scr_stat *scp, int fr
/* set background color in EGA/VGA latch */
if (bg != col2) {
bg = col2;
-   outw(GDCIDX, 0x0005);   /* read mode 0, write mode 0 */
outw(GDCIDX, bg | 0x00); /* set/reset */
-   writeb(d, 0);
+   writeb(d, 0xff);
c = readb(d);   /* set bg color in the latch */
-   outw(GDCIDX, 0x0305);   /* read mode 0, write mode 3 */
}
/* foreground color */
outw(GDCIDX, col1 | 0x00);  /* set/reset */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r317208 - head/sys/netinet

2017-04-21 Thread Michael Tuexen

> On 21. Apr 2017, at 05:16, Bruce Evans  wrote:
> 
> On Thu, 20 Apr 2017, Cy Schubert wrote:
> 
> Please trim quotes.
> 
>> In message <201704201919.v3kjjyko052...@repo.freebsd.org>, Michael Tuexen
>> write
>> s:
> 
> [>> ... 5 lines trimmed]
> 
>>> Log:
>>>  Syncoockies can be used in combination with the syncache. If the cache
>>>  overflows, syncookies are used.
> 
> [>> ... 16 lines trimmed]
> 
>>> Modified: head/sys/netinet/tcp_syncache.c
>>> =
>>> =
>>> --- head/sys/netinet/tcp_syncache.c Thu Apr 20 19:14:52 2017(r31720
>>> 7)
>>> +++ head/sys/netinet/tcp_syncache.c Thu Apr 20 19:19:33 2017(r31720
>>> 8)
>>> @@ -260,6 +260,7 @@ syncache_init(void)
>>>  _tcp_syncache.hashbase[i].sch_mtx, 0);
>>> V_tcp_syncache.hashbase[i].sch_length = 0;
>>> V_tcp_syncache.hashbase[i].sch_sc = _tcp_syncache;
>>> +   V_tcp_syncache.hashbase[i].sch_last_overflow = INT64_MIN;
>> ...
>> This line produced the following on i386:
>> 
>> /opt/src/svn-current/sys/netinet/tcp_syncache.c:263:50: error: implicit
>> conversion from 'long long' to 'time_t' (aka 'int') changes value from
>> -9223372036854775808 to 0 [-Werror,-Wconstant-conversion]
>>   V_tcp_syncache.hashbase[i].sch_last_overflow = INT64_MIN;
>>~ ^
>> ./x86/_stdint.h:91:41: note: expanded from macro 'INT64_MIN'
>> #define INT64_MIN   (-0x7fffLL-1)
>>~^~
>> 
>> Looks like it needs a time_t cast.
> 
> A cast would just break the warning.  INT64_MIN has nothing to do with
> time_t.  The expression (time_t)INT64_MIN would be more obviously garbage
> since in the above it is not clear that sch_last_overflow has a type
> unrelated to the constant.
Fixed in https://svnweb.freebsd.org/changeset/base/317244
> 
> INT64_MIN is also broken if time_t is 64 bits but unsigned.  Then it is
> converted to half of plus infinity instead of the intended minus infinity.
The patch assumes that time_t is signed, which is true for FreeBSD on all
platforms. Or am I missing a platform?

Best regards
Michael
> 
> Bruce

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r317208 - head/sys/netinet

2017-04-21 Thread Michael Tuexen

> On 21. Apr 2017, at 03:43, Cy Schubert  wrote:
> 
> In message <201704201919.v3kjjyko052...@repo.freebsd.org>, Michael Tuexen 
> writes:
> 
[...]
> Hi Michael,
> 
> This line produced the following on i386:
> 
> /opt/src/svn-current/sys/netinet/tcp_syncache.c:263:50: error: implicit 
> conversion from 'long long' to 'time_t' (aka 'int') changes value from 
> -9223372036854775808 to 0 [-Werror,-Wconstant-conversion]
>V_tcp_syncache.hashbase[i].sch_last_overflow = INT64_MIN;
> ~ ^
> ./x86/_stdint.h:91:41: note: expanded from macro 'INT64_MIN'
> #define INT64_MIN   (-0x7fffLL-1)
> ~^~
> 
> Looks like it needs a time_t cast.
Fixed in https://svnweb.freebsd.org/changeset/base/317244.

Thanks for reporting and sorry for the breakage.

Best regards
Michael
> 
>> [...]
> 
> 
> -- 
> Cheers,
> Cy Schubert 
> FreeBSD UNIX:     Web:  http://www.FreeBSD.org
> 
>   The need of the many outweighs the greed of the few.
> 
> 
> 

___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r317244 - head/sys/netinet

2017-04-21 Thread Michael Tuexen
Author: tuexen
Date: Fri Apr 21 06:05:34 2017
New Revision: 317244
URL: https://svnweb.freebsd.org/changeset/base/317244

Log:
  Represent "a syncache overflow hasn't happend yet" by using
  -(SYNCOOKIE_LIFETIME + 1) instead of INT64_MIN, since it is
  good enough and works when time_t is int32 or int64.
  This fixes the issue reported by cy@ on i386.
  
  Reported by:  cy
  MFC after:1 week
  Sponsored by: Netflix, Inc.

Modified:
  head/sys/netinet/tcp_syncache.c

Modified: head/sys/netinet/tcp_syncache.c
==
--- head/sys/netinet/tcp_syncache.c Fri Apr 21 02:11:44 2017
(r317243)
+++ head/sys/netinet/tcp_syncache.c Fri Apr 21 06:05:34 2017
(r317244)
@@ -260,7 +260,8 @@ syncache_init(void)
 _tcp_syncache.hashbase[i].sch_mtx, 0);
V_tcp_syncache.hashbase[i].sch_length = 0;
V_tcp_syncache.hashbase[i].sch_sc = _tcp_syncache;
-   V_tcp_syncache.hashbase[i].sch_last_overflow = INT64_MIN;
+   V_tcp_syncache.hashbase[i].sch_last_overflow =
+   -(SYNCOOKIE_LIFETIME + 1);
}
 
/* Create the syncache entry zone. */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"