Re: svn commit: r286102 - head/usr.bin/wall

2015-08-01 Thread Bruce Evans

On Fri, 31 Jul 2015, Pedro Giffuni wrote:


On 07/31/15 02:12, Bruce Evans wrote:

On Fri, 31 Jul 2015, Pedro F. Giffuni wrote:


...


static char errbuf[1024];


Another static buffer.  The function is obviously not reentrant.  This
large static buffer mainly wastes space all the time instead of only
when the function is called.


But if I drop that static I get a bunch of errors:


Yes.  I forgot that it is is returned.  Older not so good APIs often
return a pointer to static data.

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


Re: svn commit: r285973 - head/sys/dev/bxe

2015-08-01 Thread John Baldwin
On Tuesday, July 28, 2015 07:15:45 PM David C Somayajulu wrote:
 Author: davidcs
 Date: Tue Jul 28 19:15:44 2015
 New Revision: 285973
 URL: https://svnweb.freebsd.org/changeset/base/285973
 
 Log:
   - Avoid lock contention in the if_transmit callback by using trylock and
enqueueing the frames when it fails. This way there is some latency
removed from the transmitting path.

Most drivers that used to do this have stopped doing it do to the race
that if you have bursty traffic you can end up with packets delayed
until another packet is transmitted.  If you are always blasting traffic
non-stop, that's fine.  If you have bursty traffic, it's not so great.

A real-life scenario I had with igb(4) resulted in packets delayed by
a full second.

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


Re: svn commit: r283998 - in head/sys: dev/drm dev/drm2 fs/devfs kern sys vm

2015-08-01 Thread John Baldwin
On Thursday, July 30, 2015 09:11:54 PM Oliver Pinter wrote:
 Hi John!
 
 On Thu, Jun 4, 2015 at 9:41 PM, John Baldwin j...@freebsd.org wrote:
  Author: jhb
  Date: Thu Jun  4 19:41:15 2015
  New Revision: 283998
  URL: https://svnweb.freebsd.org/changeset/base/283998
 
  Log:
Add a new file operations hook for mmap operations.  File type-specific
logic is now placed in the mmap hook implementation rather than requiring
it to be placed in sys/vm/vm_mmap.c.  This hook allows new file types to
support mmap() as well as potentially allowing mmap() for existing file
types that do not currently support any mapping.
 
The vm_mmap() function is now split up into two functions.  A new
vm_mmap_object() function handles the back half of vm_mmap() and accepts
a referenced VM object to map rather than a (handle, handle_type) tuple.
vm_mmap() is now reduced to converting a (handle, handle_type) tuple to a
a VM object and then calling vm_mmap_object() to handle the actual 
  mapping.
The vm_mmap() function remains for use by other parts of the kernel
(e.g. device drivers and exec) but now only supports mapping vnodes,
character devices, and anonymous memory.
 
The mmap() system call invokes vm_mmap_object() directly with a NULL 
  object
for anonymous mappings.  For mappings using a file descriptor, the
descriptors fo_mmap() hook is invoked instead.  The fo_mmap() hook is
responsible for performing type-specific checks and adjustments to
arguments as well as possibly modifying mapping parameters such as flags
or the object offset.  The fo_mmap() hook routines then call
vm_mmap_object() to handle the actual mapping.
 
The fo_mmap() hook is optional.  If it is not set, then fo_mmap() will
fail with ENODEV.  A fo_mmap() hook is implemented for regular files,
character devices, and shared memory objects (created via shm_open()).
 
While here, consistently use the VM_PROT_* constants for the vm_prot_t
type for the 'prot' variable passed to vm_mmap() and vm_mmap_object()
as well as the vm_mmap_vnode() and vm_mmap_cdev() helper routines.
Previously some places were using the mmap()-specific PROT_* constants
instead.  While this happens to work because PROT_xx == VM_PROT_xx,
using VM_PROT_* is more correct.
 
Differential Revision:https://reviews.freebsd.org/D2658
Reviewed by:  alc (glanced over), kib
MFC after:1 month
Sponsored by: Chelsio
 
  Modified:
head/sys/dev/drm/drm_bufs.c
head/sys/dev/drm2/drm_bufs.c
head/sys/fs/devfs/devfs_vnops.c
head/sys/kern/subr_uio.c
head/sys/kern/uipc_shm.c
head/sys/kern/vfs_vnops.c
head/sys/sys/file.h
head/sys/sys/mman.h
head/sys/vm/vm_extern.h
head/sys/vm/vm_mmap.c
 
 
  ... patch trimmed...
 
 When plan you to MFC this change to 10-STABLE?

There's a regression reported by sbruno@ that needs to be resolved before it
can be merged.  I might also need to employ an extra hack to preserve the ABI
(e.g. adding a new flag that has to be set in the fileops to say that the
fo_mmap field is present like was done for fo_truncate).

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


svn commit: r286146 - in head/sys: kern sys

2015-08-01 Thread Ed Schouten
Author: ed
Date: Sat Aug  1 07:21:14 2015
New Revision: 286146
URL: https://svnweb.freebsd.org/changeset/base/286146

Log:
  Add kern_shm_open().
  
  This allows you to specify the capabilities that the new file descriptor
  should have. This allows us to create shared memory objects that only
  have the rights we're interested in.
  
  The idea behind restricting the rights is that it makes it a lot easier
  for CloudABI to get consistent behaviour across different operating
  systems. We only need to make sure that a shared memory implementation
  consistently implements the operations that are whitelisted.
  
  Approved by:  kib
  Obtained from:https://github.com/NuxiNL/freebsd

Modified:
  head/sys/kern/uipc_shm.c
  head/sys/sys/syscallsubr.h

Modified: head/sys/kern/uipc_shm.c
==
--- head/sys/kern/uipc_shm.cSat Aug  1 03:37:00 2015(r286145)
+++ head/sys/kern/uipc_shm.cSat Aug  1 07:21:14 2015(r286146)
@@ -68,6 +68,7 @@ __FBSDID($FreeBSD$);
 #include sys/resourcevar.h
 #include sys/rwlock.h
 #include sys/stat.h
+#include sys/syscallsubr.h
 #include sys/sysctl.h
 #include sys/sysproto.h
 #include sys/systm.h
@@ -683,9 +684,9 @@ shm_remove(char *path, Fnv32_t fnv, stru
return (ENOENT);
 }
 
-/* System calls. */
 int
-sys_shm_open(struct thread *td, struct shm_open_args *uap)
+kern_shm_open(struct thread *td, const char *userpath, int flags, mode_t mode,
+struct filecaps *fcaps)
 {
struct filedesc *fdp;
struct shmfd *shmfd;
@@ -699,28 +700,27 @@ sys_shm_open(struct thread *td, struct s
/*
 * shm_open(2) is only allowed for anonymous objects.
 */
-   if (IN_CAPABILITY_MODE(td)  (uap-path != SHM_ANON))
+   if (IN_CAPABILITY_MODE(td)  (userpath != SHM_ANON))
return (ECAPMODE);
 #endif
 
-   if ((uap-flags  O_ACCMODE) != O_RDONLY 
-   (uap-flags  O_ACCMODE) != O_RDWR)
+   if ((flags  O_ACCMODE) != O_RDONLY  (flags  O_ACCMODE) != O_RDWR)
return (EINVAL);
 
-   if ((uap-flags  ~(O_ACCMODE | O_CREAT | O_EXCL | O_TRUNC | 
O_CLOEXEC)) != 0)
+   if ((flags  ~(O_ACCMODE | O_CREAT | O_EXCL | O_TRUNC | O_CLOEXEC)) != 
0)
return (EINVAL);
 
fdp = td-td_proc-p_fd;
-   cmode = (uap-mode  ~fdp-fd_cmask)  ACCESSPERMS;
+   cmode = (mode  ~fdp-fd_cmask)  ACCESSPERMS;
 
-   error = falloc(td, fp, fd, O_CLOEXEC);
+   error = falloc_caps(td, fp, fd, O_CLOEXEC, fcaps);
if (error)
return (error);
 
/* A SHM_ANON path pointer creates an anonymous object. */
-   if (uap-path == SHM_ANON) {
+   if (userpath == SHM_ANON) {
/* A read-only anonymous object is pointless. */
-   if ((uap-flags  O_ACCMODE) == O_RDONLY) {
+   if ((flags  O_ACCMODE) == O_RDONLY) {
fdclose(td, fp, fd);
fdrop(fp, td);
return (EINVAL);
@@ -728,7 +728,7 @@ sys_shm_open(struct thread *td, struct s
shmfd = shm_alloc(td-td_ucred, cmode);
} else {
path = malloc(MAXPATHLEN, M_SHMFD, M_WAITOK);
-   error = copyinstr(uap-path, path, MAXPATHLEN, NULL);
+   error = copyinstr(userpath, path, MAXPATHLEN, NULL);
 #ifdef KTRACE
if (error == 0  KTRPOINT(curthread, KTR_NAMEI))
ktrnamei(path);
@@ -748,7 +748,7 @@ sys_shm_open(struct thread *td, struct s
shmfd = shm_lookup(path, fnv);
if (shmfd == NULL) {
/* Object does not yet exist, create it if requested. */
-   if (uap-flags  O_CREAT) {
+   if (flags  O_CREAT) {
 #ifdef MAC
error = mac_posixshm_check_create(td-td_ucred,
path);
@@ -769,17 +769,16 @@ sys_shm_open(struct thread *td, struct s
 * reference if requested and permitted.
 */
free(path, M_SHMFD);
-   if ((uap-flags  (O_CREAT | O_EXCL)) ==
-   (O_CREAT | O_EXCL))
+   if ((flags  (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL))
error = EEXIST;
else {
 #ifdef MAC
error = mac_posixshm_check_open(td-td_ucred,
-   shmfd, FFLAGS(uap-flags  O_ACCMODE));
+   shmfd, FFLAGS(flags  O_ACCMODE));
if (error == 0)
 #endif
error = shm_access(shmfd, td-td_ucred,
-   FFLAGS(uap-flags  O_ACCMODE));
+   FFLAGS(flags  O_ACCMODE));
}
 
/*
@@ -788,7 +787,7 @@ 

Re: svn commit: r285888 - head/sys/kern

2015-08-01 Thread John Baldwin
On Sunday, July 26, 2015 10:53:33 AM Andrey V. Elsukov wrote:
 Author: ae
 Date: Sun Jul 26 10:53:32 2015
 New Revision: 285888
 URL: https://svnweb.freebsd.org/changeset/base/285888
 
 Log:
   Build debug version of rmlock's methods only when LOCK_DEBUG  0.
   
   Currently LOCK_DEBUG is always defined in sys/lock.h (0 or 1).
   This means that debugging code always built. In addition the kernel
   modules have always defined LOCK_DEBUG as 1. So, debugging rmlock code
   is always used by kernel modules.

Debugging versions of locking primitives are always used by all locking
primitives (mutexes, rw, sx, etc.) so that if the kernel has INVARIANTS
enabled then those checks are always performed regardless of how the
module is compiled.

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


svn commit: r286159 - head/usr.bin/getopt

2015-08-01 Thread John-Mark Gurney
Author: jmg
Date: Sat Aug  1 17:27:47 2015
New Revision: 286159
URL: https://svnweb.freebsd.org/changeset/base/286159

Log:
  use : instead of true...
  
  Change file file to file1 file2, partly for igor, and partly because
  it's odd to pass the same file to a command twice..

Modified:
  head/usr.bin/getopt/getopt.1

Modified: head/usr.bin/getopt/getopt.1
==
--- head/usr.bin/getopt/getopt.1Sat Aug  1 16:27:52 2015
(r286158)
+++ head/usr.bin/getopt/getopt.1Sat Aug  1 17:27:47 2015
(r286159)
@@ -1,6 +1,6 @@
 .\ $FreeBSD$
 .\
-.Dd January 26, 2011
+.Dd August 1, 2015
 .Dt GETOPT 1
 .Os
 .Sh NAME
@@ -62,7 +62,7 @@ set \-\- $args
 # You cannot use the set command with a backquoted getopt directly,
 # since the exit code from getopt would be shadowed by those of set,
 # which is zero by definition.
-while true; do
+while :; do
case $1 in
\-a|\-b)
echo flag $1 set; sflags=${1#-}$sflags
@@ -83,10 +83,10 @@ echo oarg is '$oarg'
 .Pp
 This code will accept any of the following as equivalent:
 .Bd -literal -offset indent
-cmd \-aoarg file file
-cmd \-a \-o arg file file
-cmd \-oarg -a file file
-cmd \-a \-oarg \-\- file file
+cmd \-aoarg file1 file2
+cmd \-a \-o arg file1 file2
+cmd \-oarg -a file1 file2
+cmd \-a \-oarg \-\- file1 file2
 .Ed
 .Sh SEE ALSO
 .Xr getopts 1 ,
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r286147 - head/sys/compat/cloudabi

2015-08-01 Thread John Baldwin
On Saturday, August 01, 2015 07:51:48 AM Ed Schouten wrote:
 Author: ed
 Date: Sat Aug  1 07:51:48 2015
 New Revision: 286147
 URL: https://svnweb.freebsd.org/changeset/base/286147
 
 Log:
   Allow CloudABI processes to create shared memory objects.
   
   Summary:
   Use the newly created `kern_shm_open()` function to create objects with
   just the rights that are actually needed.
   
   Reviewers: jhb, kib
   
   Subscribers: imp
   
   Differential Revision: https://reviews.freebsd.org/D3260

Can you please not use 'arc commit'?  For one, it doesn't follow the standard
FreeBSD commit template (and apparently it's hard to fix or we would have done
it by now), but it also isn't clear who actually reviews things.

What I do is keep the URL to the review open in another window and just copy
and paste the commit message and URL over to the stock template in my editor.
You can then set a proper 'Reviewed by' line that reflects who actually
reviewed the change as well.

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


Re: svn commit: r286144 - head/usr.bin/wall

2015-08-01 Thread Pedro Giffuni



On 08/01/15 09:34, Eric van Gyzen wrote:

On 7/31/15 8:29 PM, Pedro F. Giffuni wrote:

Author: pfg
Date: Sat Aug  1 01:29:55 2015
New Revision: 286144
URL: https://svnweb.freebsd.org/changeset/base/286144

Log:
   Buffer overflow in wall(1).

   Revert r286102 and apply a cleaner fix.
   Tested for overflows by FORTIFY_SOURCE GSoC (with clang).

   Suggested by:bde
   Reviewed by:Oliver Pinter
   Tested by:Oliver Pinter
   MFC after:3 days

Modified:
   head/usr.bin/wall/ttymsg.c

Modified: head/usr.bin/wall/ttymsg.c
==

--- head/usr.bin/wall/ttymsg.cFri Jul 31 23:40:18 2015(r286143)
+++ head/usr.bin/wall/ttymsg.cSat Aug  1 01:29:55 2015(r286144)
@@ -62,7 +62,7 @@ ttymsg(struct iovec *iov, int iovcnt, co
  struct iovec localiov[7];
  ssize_t left, wret;
  int cnt, fd;
-char device[MAXNAMLEN] = _PATH_DEV;
+char device[MAXNAMLEN];
  static char errbuf[1024];
  char *p;
  int forked;
@@ -71,8 +71,9 @@ ttymsg(struct iovec *iov, int iovcnt, co
  if (iovcnt  (int)(sizeof(localiov) / sizeof(localiov[0])))
  return (too many iov's (change code in wall/ttymsg.c));

-strlcat(device, line, sizeof(device));
+strlcpy(device, _PATH_DEV, sizeof(device));
  p = device + sizeof(_PATH_DEV) - 1;
+strlcpy(p, line, sizeof(device) - sizeof(_PATH_DEV));


You're probably already sick of this change, but I would encourage this
instead:

 strlcat(device, line, sizeof(device));



It looks exactly like the code I just replaced ;).


Your current code works, and it's even more efficient than strlcat.


Indeed, efficient is good and was the reason for the changes suggested
by bde. We evaluated snprintf but costs even more.


However, doing arithmetic on either the first or third argument to
strlcpy/strlcat is precisely what caused the overflow that you're
fixing.  In fact, the size passed by the current code is one byte too
small.  This is obviously not a real concern in this code, but it
demonstrates how easy it is to get these calculations wrong.



Yeah, it's a benign off-by-one :(. I will fix it by using the
return value of the original strlcpy so we it will be less confusing
at the cost of adding a new variable.

This said, the original bug is the first detected by FORTIFY_SOURCE that 
is not detected by Coverity, so it will be very exciting to bring

FORTIFY_SOURCE to the tree.

Pedro.



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


svn commit: r286155 - head/usr.sbin/pw

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sat Aug  1 11:52:48 2015
New Revision: 286155
URL: https://svnweb.freebsd.org/changeset/base/286155

Log:
  Fix build

Modified:
  head/usr.sbin/pw/pw_conf.c

Modified: head/usr.sbin/pw/pw_conf.c
==
--- head/usr.sbin/pw/pw_conf.c  Sat Aug  1 11:31:59 2015(r286154)
+++ head/usr.sbin/pw/pw_conf.c  Sat Aug  1 11:52:48 2015(r286155)
@@ -348,6 +348,7 @@ read_userconfig(char const * file)
if (errstr)
warnx(Invalid min_gid: '%s';
 ignoring, q);
+   }
break;
case _UC_MAXGID:
if ((q = unquote(q)) != NULL) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286153 - head/usr.sbin/chkgrp

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sat Aug  1 10:40:17 2015
New Revision: 286153
URL: https://svnweb.freebsd.org/changeset/base/286153

Log:
  Revert r286148

Modified:
  head/usr.sbin/chkgrp/chkgrp.c

Modified: head/usr.sbin/chkgrp/chkgrp.c
==
--- head/usr.sbin/chkgrp/chkgrp.c   Sat Aug  1 10:25:55 2015
(r286152)
+++ head/usr.sbin/chkgrp/chkgrp.c   Sat Aug  1 10:40:17 2015
(r286153)
@@ -171,9 +171,9 @@ main(int argc, char *argv[])
 
/* check the range of the group id */
errno = 0;
-   gid = strtoumax(f[2], NULL, 10);
+   gid = strtoul(f[2], NULL, 10);
if (errno != 0) {
-   warnx(%s: line %d: strtoumax failed, gfn, n);
+   warnx(%s: line %d: strtoul failed, gfn, n);
} else if (gid  GID_MAX) {
warnx(%s: line %d: group id is too large (%ju  %ju),
gfn, n, (uintmax_t)gid, (uintmax_t)GID_MAX);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286160 - in head: share/misc usr.bin/calendar/calendars

2015-08-01 Thread Jason Unovitch
Author: junovitch (ports committer)
Date: Sat Aug  1 17:29:52 2015
New Revision: 286160
URL: https://svnweb.freebsd.org/changeset/base/286160

Log:
  - Add myself to the committers-ports.dot and add my mentor relationship.
  - Add myself to the calendar.freebsd.
  
  Approved by:  delphij (mentor)
  Differential Revision:https://reviews.FreeBSD.org/D3265

Modified:
  head/share/misc/committers-ports.dot
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/share/misc/committers-ports.dot
==
--- head/share/misc/committers-ports.dotSat Aug  1 17:27:47 2015
(r286159)
+++ head/share/misc/committers-ports.dotSat Aug  1 17:29:52 2015
(r286160)
@@ -128,6 +128,7 @@ johans [label=Johan Selst\njohans@FreeB
 josef [label=Josef El-Rayes\njo...@freebsd.org\n2004/12/20]
 jpaetzel [label=Josh Paetzel\njpaet...@freebsd.org\n2008/09/05]
 jsa [label=Joseph S. Atkinson\n...@freebsd.org\n2010/07/15]
+junovitch [label=Jason Unovitch\njunovi...@freebsd.org\n2015/07/27]
 jylefort [label=Jean-Yves Lefort\njylef...@freebsd.org\n2005/04/12]
 kami [label=Dominic Fandrey\nk...@freebsd.org\n2014/09/09]
 kevlo [label=Kevin Lo\nke...@freebsd.org\n2003/02/21]
@@ -315,6 +316,7 @@ db - tj
 
 decke - sperber
 
+delphij - junovitch
 delphij - nemoliu
 delphij - rafan
 
@@ -347,6 +349,8 @@ erwin - lbr
 erwin - lth
 erwin - simon
 
+feld - junovitch
+
 fjoe - danfe
 fjoe - flo
 fjoe - krion
@@ -508,6 +512,7 @@ pawel - nemysis
 pgj - ashish
 pgj - jacula
 
+pgollucci - junovitch
 pgollucci - sunpoet
 pgollucci - swills
 

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdSat Aug  1 17:27:47 
2015(r286159)
+++ head/usr.bin/calendar/calendars/calendar.freebsdSat Aug  1 17:29:52 
2015(r286160)
@@ -122,6 +122,7 @@
 04/03  Hellmuth Michaelis h...@freebsd.org born in Kiel, Schleswig-Holstein, 
Germany, 1958
 04/03  Tong Liu nemo...@freebsd.org born in Beijing, People's Republic of 
China, 1981
 04/03  Gabor Pali p...@freebsd.org born in Kunhegyes, Hungary, 1982
+04/04  Jason Unovitch junovitch@FreeBSD born in Scranton, Pennsylvania, 
United States, 1986
 04/05  Stacey Son s...@freebsd.org born in Burley, Idaho, United States, 1967
 04/06  Peter Jeremy pet...@freebsd.org born in Sydney, New South Wales, 
Australia, 1961
 04/07  Edward Tomasz Napierala tr...@freebsd.org born in Wolsztyn, Poland, 
1981
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286156 - head/usr.sbin/pw

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sat Aug  1 12:18:48 2015
New Revision: 286156
URL: https://svnweb.freebsd.org/changeset/base/286156

Log:
  Partial revert of r286152
  
  More work needed on the cli validation

Modified:
  head/usr.sbin/pw/pw.c
  head/usr.sbin/pw/pw_conf.c
  head/usr.sbin/pw/pw_user.c
  head/usr.sbin/pw/pwupd.h

Modified: head/usr.sbin/pw/pw.c
==
--- head/usr.sbin/pw/pw.c   Sat Aug  1 11:52:48 2015(r286155)
+++ head/usr.sbin/pw/pw.c   Sat Aug  1 12:18:48 2015(r286156)
@@ -262,11 +262,6 @@ main(int argc, char *argv[])
case 'c':
conf.gecos = pw_checkname(optarg, 1);
break;
-   case 'e':
-   conf.expire_days = strtonum(optarg, 0, INT_MAX, 
errstr);
-   if (errstr)
-   errx(EX_USAGE, Invalid expired days: %s, 
optarg);
-   break;
case 'g':
if (which == 0) { /* for user* */
addarg(arglist, 'g', optarg);
@@ -326,11 +321,6 @@ main(int argc, char *argv[])
case 'o':
conf.checkduplicate = false;
break;
-   case 'p':
-   conf.password_days = strtonum(optarg, 0, INT_MAX, 
errstr);
-   if (errstr)
-   errx(EX_USAGE, Invalid password days: %s, 
optarg);
-   break;
case 'q':
conf.quiet = true;
break;

Modified: head/usr.sbin/pw/pw_conf.c
==
--- head/usr.sbin/pw/pw_conf.c  Sat Aug  1 11:52:48 2015(r286155)
+++ head/usr.sbin/pw/pw_conf.c  Sat Aug  1 12:18:48 2015(r286156)
@@ -367,6 +367,8 @@ read_userconfig(char const * file)
warnx(Invalid expire days:
 '%s'; ignoring, q);
}
+   if ((q = unquote(q)) != NULL  isdigit(*q))
+   config.expire_days = atoi(q);
break;
case _UC_PASSWORD:
if ((q = unquote(q)) != NULL) {

Modified: head/usr.sbin/pw/pw_user.c
==
--- head/usr.sbin/pw/pw_user.c  Sat Aug  1 11:52:48 2015(r286155)
+++ head/usr.sbin/pw/pw_user.c  Sat Aug  1 12:18:48 2015(r286156)
@@ -418,14 +418,14 @@ pw_user(int mode, char *name, long id, s
errx(EX_OSFILE, root home `%s' is not a directory, 
cnf-home);
}
 
-   if (conf.expire_days  0)
-   cnf-expire_days = conf.expire_days;
+   if ((arg = getarg(args, 'e')) != NULL)
+   cnf-expire_days = atoi(arg-val);
 
if ((arg = getarg(args, 'y')) != NULL)
cnf-nispasswd = arg-val;
 
-   if (conf.password_days  0)
-   cnf-password_days = conf.password_days;
+   if ((arg = getarg(args, 'p')) != NULL  arg-val)
+   cnf-password_days = atoi(arg-val);
 
if ((arg = getarg(args, 'g')) != NULL) {
if (!*(p = arg-val))   /* Handle empty group list specially */

Modified: head/usr.sbin/pw/pwupd.h
==
--- head/usr.sbin/pw/pwupd.hSat Aug  1 11:52:48 2015(r286155)
+++ head/usr.sbin/pw/pwupd.hSat Aug  1 12:18:48 2015(r286156)
@@ -86,8 +86,6 @@ struct pwconf {
char*newname;
char*config;
char*gecos;
-   int  expire_days;
-   int  password_days;
int  fd;
int  rootfd;
int  which;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r286144 - head/usr.bin/wall

2015-08-01 Thread Eric van Gyzen

On 7/31/15 8:29 PM, Pedro F. Giffuni wrote:

Author: pfg
Date: Sat Aug  1 01:29:55 2015
New Revision: 286144
URL: https://svnweb.freebsd.org/changeset/base/286144

Log:
   Buffer overflow in wall(1).

   Revert r286102 and apply a cleaner fix.
   Tested for overflows by FORTIFY_SOURCE GSoC (with clang).

   Suggested by:bde
   Reviewed by: Oliver Pinter
   Tested by:   Oliver Pinter
   MFC after:   3 days

Modified:
   head/usr.bin/wall/ttymsg.c

Modified: head/usr.bin/wall/ttymsg.c
==
--- head/usr.bin/wall/ttymsg.c  Fri Jul 31 23:40:18 2015(r286143)
+++ head/usr.bin/wall/ttymsg.c  Sat Aug  1 01:29:55 2015(r286144)
@@ -62,7 +62,7 @@ ttymsg(struct iovec *iov, int iovcnt, co
struct iovec localiov[7];
ssize_t left, wret;
int cnt, fd;
-   char device[MAXNAMLEN] = _PATH_DEV;
+   char device[MAXNAMLEN];
static char errbuf[1024];
char *p;
int forked;
@@ -71,8 +71,9 @@ ttymsg(struct iovec *iov, int iovcnt, co
if (iovcnt  (int)(sizeof(localiov) / sizeof(localiov[0])))
return (too many iov's (change code in wall/ttymsg.c));

-   strlcat(device, line, sizeof(device));
+   strlcpy(device, _PATH_DEV, sizeof(device));
p = device + sizeof(_PATH_DEV) - 1;
+   strlcpy(p, line, sizeof(device) - sizeof(_PATH_DEV));


You're probably already sick of this change, but I would encourage this 
instead:


strlcat(device, line, sizeof(device));

Your current code works, and it's even more efficient than strlcat. 
However, doing arithmetic on either the first or third argument to 
strlcpy/strlcat is precisely what caused the overflow that you're 
fixing.  In fact, the size passed by the current code is one byte too 
small.  This is obviously not a real concern in this code, but it 
demonstrates how easy it is to get these calculations wrong.



if (strncmp(p, pts/, 4) == 0)
p += 4;
if (strchr(p, '/') != NULL) {


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


svn commit: r286158 - in head: sys/kern tests/sys/kern

2015-08-01 Thread John Baldwin
Author: jhb
Date: Sat Aug  1 16:27:52 2015
New Revision: 286158
URL: https://svnweb.freebsd.org/changeset/base/286158

Log:
  Clear P_TRACED before reparenting a detached process back to its
  original parent. Otherwise the debugee will be set as an orphan of
  the debugger.
  
  Add tests for tracing forks via PT_FOLLOW_FORK.
  
  Reviewed by:  kib
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D2809

Modified:
  head/sys/kern/sys_process.c
  head/tests/sys/kern/ptrace_test.c

Modified: head/sys/kern/sys_process.c
==
--- head/sys/kern/sys_process.c Sat Aug  1 12:20:55 2015(r286157)
+++ head/sys/kern/sys_process.c Sat Aug  1 16:27:52 2015(r286158)
@@ -947,7 +947,15 @@ kern_ptrace(struct thread *td, int req, 
}
break;
case PT_DETACH:
-   /* reset process parent */
+   /*
+* Reset the process parent.
+*
+* NB: This clears P_TRACED before reparenting
+* a detached process back to its original
+* parent.  Otherwise the debugee will be set
+* as an orphan of the debugger.
+*/
+   p-p_flag = ~(P_TRACED | P_WAITED | P_FOLLOWFORK);
if (p-p_oppid != p-p_pptr-p_pid) {
PROC_LOCK(p-p_pptr);
sigqueue_take(p-p_ksi);
@@ -963,7 +971,6 @@ kern_ptrace(struct thread *td, int req, 
} else
CTR1(KTR_PTRACE, PT_DETACH: pid %d, p-p_pid);
p-p_oppid = 0;
-   p-p_flag = ~(P_TRACED | P_WAITED | P_FOLLOWFORK);
p-p_stops = 0;
 
/* should we send SIGCHLD? */

Modified: head/tests/sys/kern/ptrace_test.c
==
--- head/tests/sys/kern/ptrace_test.c   Sat Aug  1 12:20:55 2015
(r286157)
+++ head/tests/sys/kern/ptrace_test.c   Sat Aug  1 16:27:52 2015
(r286158)
@@ -50,7 +50,7 @@ __FBSDID($FreeBSD$);
#exp  not met);   \
} while (0)
 
-static void __dead2
+static __dead2 void
 child_fail_require(const char *file, int line, const char *str)
 {
char buf[128];
@@ -60,6 +60,58 @@ child_fail_require(const char *file, int
_exit(32);
 }
 
+static void
+trace_me(void)
+{
+
+   /* Attach the parent process as a tracer of this process. */
+   CHILD_REQUIRE(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+   /* Trigger a stop. */
+   raise(SIGSTOP);
+}
+
+static void
+attach_child(pid_t pid)
+{
+   pid_t wpid;
+   int status;
+
+   ATF_REQUIRE(ptrace(PT_ATTACH, pid, NULL, 0) == 0);
+
+   wpid = waitpid(pid, status, 0);
+   ATF_REQUIRE(wpid == pid);
+   ATF_REQUIRE(WIFSTOPPED(status));
+   ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+}
+
+static void
+wait_for_zombie(pid_t pid)
+{
+
+   /*
+* Wait for a process to exit.  This is kind of gross, but
+* there is not a better way.
+*/
+   for (;;) {
+   struct kinfo_proc kp;
+   size_t len;
+   int mib[4];
+
+   mib[0] = CTL_KERN;
+   mib[1] = KERN_PROC;
+   mib[2] = KERN_PROC_PID;
+   mib[3] = pid;
+   len = sizeof(kp);
+   if (sysctl(mib, nitems(mib), kp, len, NULL, 0) == -1) {
+   /* The KERN_PROC_PID sysctl fails for zombies. */
+   ATF_REQUIRE(errno == ESRCH);
+   break;
+   }
+   usleep(5000);
+   }
+}
+
 /*
  * Verify that a parent debugger process sees the exit of a debugged
  * process exactly once when attached via PT_TRACE_ME.
@@ -73,10 +125,7 @@ ATF_TC_BODY(ptrace__parent_wait_after_tr
ATF_REQUIRE((child = fork()) != -1);
if (child == 0) {
/* Child process. */
-   CHILD_REQUIRE(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-   /* Trigger a stop. */
-   raise(SIGSTOP);
+   trace_me();
 
exit(1);
}
@@ -131,13 +180,7 @@ ATF_TC_BODY(ptrace__parent_wait_after_at
/* Parent process. */
 
/* Attach to the child process. */
-   ATF_REQUIRE(ptrace(PT_ATTACH, child, NULL, 0) == 0);
-
-   /* The first wait() should report the SIGSTOP from PT_ATTACH. */
-   wpid = waitpid(child, status, 0);
-   ATF_REQUIRE(wpid == child);
-   ATF_REQUIRE(WIFSTOPPED(status));
-   ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+   attach_child(child);
 
/* Continue the child ignoring the SIGSTOP. */

svn commit: r286161 - head/usr.bin/calendar/calendars

2015-08-01 Thread Jason Unovitch
Author: junovitch (ports committer)
Date: Sat Aug  1 17:48:35 2015
New Revision: 286161
URL: https://svnweb.freebsd.org/changeset/base/286161

Log:
  - Add myself to the calendar.freebsd. (fix typo in r286160)
  
  Approved by:  delphij (mentor)
  Differential Revision:https://reviews.FreeBSD.org/D3265

Modified:
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdSat Aug  1 17:29:52 
2015(r286160)
+++ head/usr.bin/calendar/calendars/calendar.freebsdSat Aug  1 17:48:35 
2015(r286161)
@@ -122,7 +122,7 @@
 04/03  Hellmuth Michaelis h...@freebsd.org born in Kiel, Schleswig-Holstein, 
Germany, 1958
 04/03  Tong Liu nemo...@freebsd.org born in Beijing, People's Republic of 
China, 1981
 04/03  Gabor Pali p...@freebsd.org born in Kunhegyes, Hungary, 1982
-04/04  Jason Unovitch junovitch@FreeBSD born in Scranton, Pennsylvania, 
United States, 1986
+04/04  Jason Unovitch junovi...@freebsd.org born in Scranton, Pennsylvania, 
United States, 1986
 04/05  Stacey Son s...@freebsd.org born in Burley, Idaho, United States, 1967
 04/06  Peter Jeremy pet...@freebsd.org born in Sydney, New South Wales, 
Australia, 1961
 04/07  Edward Tomasz Napierala tr...@freebsd.org born in Wolsztyn, Poland, 
1981
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286157 - head/usr.sbin/pw

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sat Aug  1 12:20:55 2015
New Revision: 286157
URL: https://svnweb.freebsd.org/changeset/base/286157

Log:
  Remove things that crept in after badly checked revert

Modified:
  head/usr.sbin/pw/pw_conf.c

Modified: head/usr.sbin/pw/pw_conf.c
==
--- head/usr.sbin/pw/pw_conf.c  Sat Aug  1 12:18:48 2015(r286156)
+++ head/usr.sbin/pw/pw_conf.c  Sat Aug  1 12:20:55 2015(r286157)
@@ -367,8 +367,6 @@ read_userconfig(char const * file)
warnx(Invalid expire days:
 '%s'; ignoring, q);
}
-   if ((q = unquote(q)) != NULL  isdigit(*q))
-   config.expire_days = atoi(q);
break;
case _UC_PASSWORD:
if ((q = unquote(q)) != NULL) {
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r285985 - in head/usr.sbin/pw: . tests

2015-08-01 Thread Bruce Evans

On Sat, 1 Aug 2015, Jilles Tjoelker wrote:


On Wed, Jul 29, 2015 at 08:52:52AM +1000, Bruce Evans wrote:

On Tue, 28 Jul 2015, Baptiste Daroussin wrote:

Added: head/usr.sbin/pw/tests/pw_groupadd.sh
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/pw/tests/pw_groupadd.sh   Tue Jul 28 21:10:58 2015
(r285985)
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+# Import helper functions
+. $(atf_get_srcdir)/helper_functions.shin
+
+atf_test_case group_add_gid_too_large
+group_add_gid_too_large_body() {
+   populate_etc_skel
+   atf_check -s exit:64 -e inline:pw: Bad id '9': too 
large\n \
+   ${PW} groupadd -n test1 -g 9
+}



Check for large valid ids on i386 (should succeed, but currently fail),
negative ids (require failure), magic ids like (uid_t)-1 and (uid_t)-2
(should fail, but currently succeed on amd64), and the hex ids (should
succeed, but currently fail).  (uid_t)-1 is special for some syscalls,
so shouldn't be permitted for users.  (uid_t)-2 special for nfs (see
exports(5)).  The magic ids are hard to spell without using hex, but
pw is too broken to accept that.  For 32-bit ids, the above number
should be replaced by 0x1 when pw supports hex.  Also check
that 0x and 0xfffe are not too large, but reserved, and
that 0xfffd is not too large and not reserved.


These values are easily written using arithmetic expansion, for example
largeid=$((0x1)).


Not really.  Shells are also very buggy or limited in this area.  I
often use old versions of sh and bash that only support up to INT32_MAX
and have broken overflow handling.  /bin/sh in -current only supports
up to INT64_MAX (or maybe INTMAX_MAX) and has broken overflow handling
(it clamps to INT64_MAX).  Not so old versions of bash only support
up to INT64_MAX and have differently broken overflow handling (4.3.99
blindly assigns to int64_t, so $((0x8000)) becomes
-0x8000.

expr is also limited to INT64_MAX, but attempts to have non-broken
overflow handling.


When using strtol() or similar functions, accepting hex typically
implies accepting octal as well, which causes confusing and
POSIX-violating results like 010 interpreted as eight.


This is a problem.  strtonum could accept hex but not octal by calling
strtoimax() twice for bases 10 and 16.  Also dehumanized formats like
1k and 1K.  It should also actually accept numbers as input.  1.1e1 if
not I * Pi.

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


svn commit: r286154 - head/usr.sbin/pw

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sat Aug  1 11:31:59 2015
New Revision: 286154
URL: https://svnweb.freebsd.org/changeset/base/286154

Log:
  Fix formatting of new code
  Fix sorting or errstr
  Remove useless initialisation or errstr
  
  Reported by:  bde

Modified:
  head/usr.sbin/pw/pw_conf.c

Modified: head/usr.sbin/pw/pw_conf.c
==
--- head/usr.sbin/pw/pw_conf.c  Sat Aug  1 10:40:17 2015(r286153)
+++ head/usr.sbin/pw/pw_conf.c  Sat Aug  1 11:31:59 2015(r286154)
@@ -228,9 +228,9 @@ read_userconfig(char const * file)
 {
FILE*fp;
char*buf, *p;
+   const char *errstr;
size_t  linecap;
ssize_t linelen;
-   const char *errstr;
 
buf = NULL;
linecap = 0;
@@ -325,49 +325,55 @@ read_userconfig(char const * file)
break;
case _UC_MINUID:
if ((q = unquote(q)) != NULL) {
-   errstr = NULL;
-   config.min_uid = strtounum(q, 0, 
UID_MAX, errstr);
+   config.min_uid = strtounum(q, 0,
+   UID_MAX, errstr);
if (errstr)
-   warnx(Invalid min_uid: '%s', 
ignoring, q);
+   warnx(Invalid min_uid: '%s';
+ignoring, q);
}
break;
case _UC_MAXUID:
if ((q = unquote(q)) != NULL) {
-   errstr = NULL;
-   config.max_uid = strtounum(q, 0, 
UID_MAX, errstr);
+   config.max_uid = strtounum(q, 0,
+   UID_MAX, errstr);
if (errstr)
-   warnx(Invalid max_uid: '%s', 
ignoring, q);
+   warnx(Invalid max_uid: '%s';
+ignoring, q);
}
break;
case _UC_MINGID:
-   if ((q = unquote(q)) != NULL  isdigit(*q))
-   errstr = NULL;
-   config.min_gid = strtounum(q, 0, 
GID_MAX, errstr);
+   if ((q = unquote(q)) != NULL) {
+   config.min_gid = strtounum(q, 0,
+   GID_MAX, errstr);
if (errstr)
-   warnx(Invalid min_gid: '%s', 
ignoring, q);
+   warnx(Invalid min_gid: '%s';
+ignoring, q);
break;
case _UC_MAXGID:
if ((q = unquote(q)) != NULL) {
-   errstr = NULL;
-   config.max_gid = strtounum(q, 0, 
GID_MAX, errstr);
+   config.max_gid = strtounum(q, 0,
+   GID_MAX, errstr);
if (errstr)
-   warnx(Invalid max_gid: '%s', 
ignoring, q);
+   warnx(Invalid max_gid: '%s';
+ignoring, q);
}
break;
case _UC_EXPIRE:
if ((q = unquote(q)) != NULL) {
-   errstr = NULL;
-   config.expire_days = strtonum(q, 0, 
INT_MAX, errstr);
+   config.expire_days = strtonum(q, 0,
+   INT_MAX, errstr);
if (errstr)
-   warnx(Invalid expire days: 
'%s', ignoring, q);
+   warnx(Invalid expire days:
+'%s'; ignoring, q);
}
break;
case _UC_PASSWORD:
if ((q = unquote(q)) != NULL) {
-   errstr = NULL;
-   config.password_days = strtonum(q, 0, 
INT_MAX, errstr);
+   

Re: svn commit: r285985 - in head/usr.sbin/pw: . tests

2015-08-01 Thread Jilles Tjoelker
On Wed, Jul 29, 2015 at 08:52:52AM +1000, Bruce Evans wrote:
 On Tue, 28 Jul 2015, Baptiste Daroussin wrote:
  Added: head/usr.sbin/pw/tests/pw_groupadd.sh
  ==
  --- /dev/null   00:00:00 1970   (empty, because file is newly added)
  +++ head/usr.sbin/pw/tests/pw_groupadd.sh   Tue Jul 28 21:10:58 2015
  (r285985)
  @@ -0,0 +1,15 @@
  +# $FreeBSD$
  +
  +# Import helper functions
  +. $(atf_get_srcdir)/helper_functions.shin
  +
  +atf_test_case group_add_gid_too_large
  +group_add_gid_too_large_body() {
  +   populate_etc_skel
  +   atf_check -s exit:64 -e inline:pw: Bad id '9': too 
  large\n \
  +   ${PW} groupadd -n test1 -g 9
  +}

 Check for large valid ids on i386 (should succeed, but currently fail),
 negative ids (require failure), magic ids like (uid_t)-1 and (uid_t)-2
 (should fail, but currently succeed on amd64), and the hex ids (should
 succeed, but currently fail).  (uid_t)-1 is special for some syscalls,
 so shouldn't be permitted for users.  (uid_t)-2 special for nfs (see
 exports(5)).  The magic ids are hard to spell without using hex, but
 pw is too broken to accept that.  For 32-bit ids, the above number
 should be replaced by 0x1 when pw supports hex.  Also check
 that 0x and 0xfffe are not too large, but reserved, and
 that 0xfffd is not too large and not reserved.

These values are easily written using arithmetic expansion, for example
largeid=$((0x1)).

When using strtol() or similar functions, accepting hex typically
implies accepting octal as well, which causes confusing and
POSIX-violating results like 010 interpreted as eight.

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


Re: svn commit: r286142 - head/sys/net

2015-08-01 Thread Guy Helmer

 On Aug 1, 2015, at 4:50 AM, Ed Schouten e...@nuxi.nl wrote:
 
 Hi Luiz,
 
 2015-07-31 23:43 GMT+02:00 Luiz Otavio O Souza l...@freebsd.org:
 -   while (d-bd_hbuf_in_use)
 -   mtx_sleep(d-bd_hbuf_in_use, d-bd_lock,
 -   PRINET, bd_hbuf, 0);
 
 Would it make sense to replace them by an assertion, instead of
 omitting them entirely?
 
 KASSERT(!d-bd_hbuf_in_use, (...));

I would appreciate the confidence that would provide.

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


Re: svn commit: r286173 - head/usr.sbin/pw/tests

2015-08-01 Thread Garrett Cooper

 On Aug 1, 2015, at 17:33, Baptiste Daroussin b...@freebsd.org wrote:
 
 Author: bapt
 Date: Sun Aug  2 00:33:34 2015
 New Revision: 286173
 URL: https://svnweb.freebsd.org/changeset/base/286173
 
 Log:
  Remove netbsd tests on pw(8)
 
  First they are redundant with the tests we currently have on pw(8)
  Second they to modify the host database instead of being self contained 
 withing
  the test directory
 
 Modified:
  head/usr.sbin/pw/tests/Makefile
 
 Modified: head/usr.sbin/pw/tests/Makefile
 ==
 --- head/usr.sbin/pw/tests/MakefileSun Aug  2 00:24:21 2015(r286172)
 +++ head/usr.sbin/pw/tests/MakefileSun Aug  2 00:33:34 2015(r286173)
 @@ -1,8 +1,5 @@
 # $FreeBSD$
 
 -TESTSRC=${.CURDIR}/../../../contrib/netbsd-tests/usr.sbin/useradd
 -.PATH: ${TESTSRC}
 -
 TESTSDIR=${TESTSBASE}/usr.sbin/pw
 
 ATF_TESTS_SH=pw_etcdir \
 @@ -24,12 +21,4 @@ FILES=group helper_functions.shin mast
pw-modified.conf
 FILESDIR=   ${TESTSDIR}
 
 -ATF_TESTS_SH+=pw_test
 -# - user{add,del} does not exist on FreeBSD; use pw user{add,del} instead
 -# - The command passes on FreeBSD
 -ATF_TESTS_SH_SED_pw_test=-e 's/useradd /pw useradd /'
 -ATF_TESTS_SH_SED_pw_test+=-e 's/userdel /pw userdel /'
 -ATF_TESTS_SH_SED_pw_test+=-e '/atf_expect_fail PR bin\/39546/d'
 -ATF_TESTS_SH_SRC_pw_test=t_useradd.sh
 -
 .include bsd.test.mk

You forgot to add an ObsoleteFiles.inc entry..
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r286168 - head/sys/net

2015-08-01 Thread John-Mark Gurney
Bruce Evans wrote this message on Sun, Aug 02, 2015 at 14:10 +1000:
 On Sun, 2 Aug 2015, John-Mark Gurney wrote:
 
  Log:
   convert to C11's _Static_assert, and pull in sys/cdefs.h for
   compatibility w/ older non-C11 compilers...
 
 This include is bogus.  net/pfkeyv2.h already depends on the includer
 including other headers that include sys/cdefs.h.  Mainly sys/types.h.
 sys/types.h defined massive namespace pollution that includes everything
 in sys/cdefs.h.  It includes sys/cdefs.h an infinite number of times
 via recursion, except the recursion is stopped by anti-reinclude guards.
 Th recursion makes the static number of nested includes of sys/cdefs.h
 hard to count.

I'll test w/o sys/cdefs.h and if it compiles, I'll remove it...

 Also, this is a kernel header.  All kernel headers depend on the includer

Except it isn't just a kernel header as we found out, otherwise
CTASSERT would have been perfectly fine...  It defines an API between
kernel and userland for adding and changing the kernel SA/SP
database...  See sbin/setkey and lib/libipsec...

[comments about kernel only headers deleted]

 If an application wants to abuse a kernel header, then it must fake
 the kernel environment for it.  I don't know much about this header,
 but it is not documented in any man page so it can do anything.

-- 
  John-Mark Gurney  Voice: +1 415 225 5579

 All that I will do, has been done, All that I have, has not.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286177 - head/lib/libc/stdio

2015-08-01 Thread John Baldwin
Author: jhb
Date: Sun Aug  2 02:00:20 2015
New Revision: 286177
URL: https://svnweb.freebsd.org/changeset/base/286177

Log:
  Fix a couple of markup typos.
  
  MFC after:2 weeks

Modified:
  head/lib/libc/stdio/open_memstream.3

Modified: head/lib/libc/stdio/open_memstream.3
==
--- head/lib/libc/stdio/open_memstream.3Sun Aug  2 01:09:30 2015
(r286176)
+++ head/lib/libc/stdio/open_memstream.3Sun Aug  2 02:00:20 2015
(r286177)
@@ -25,7 +25,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd October 28, 2014
+.Dd August 1, 2015
 .Dt OPEN_MEMSTREAM 3
 .Os
 .Sh NAME
@@ -86,13 +86,13 @@ will contain the start of the memory buf
 will contain the smaller of the current position and the current buffer length.
 .Pp
 After a successful call to
-.Xr fflush 3,
+.Xr fflush 3 ,
 the pointer referenced by
 .Fa bufp
 and the variable referenced by
 .Fa sizep
 are only valid until the next write operation or a call to
-.Xr fclose 3.
+.Xr fclose 3 .
 .Pp
 Once a stream is closed,
 the allocated buffer referenced by
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r284345 - in head: . bin/cat bin/chflags bin/chio bin/chmod bin/cp bin/csh bin/date bin/dd bin/df bin/domainname bin/echo bin/ed bin/expr bin/freebsd-version bin/getfacl bin/hostname b

2015-08-01 Thread Simon J. Gerraty
Baptiste Daroussin b...@freebsd.org wrote:
 This breaks using fmake from ports because of usage of :U in sys.mk

Oops - sorry.
I saw Warner posted a patch for this which looked ok, but doesn't appear
to have been committed.

 is compatible with FreeBSD 9 (not that I'm just speaking about sys.mk not 
 other
 parts)

Understood.

AFAICT the following allows fmake to consume sys.mk

Index: share/mk/sys.mk
===
--- share/mk/sys.mk (revision 286177)
+++ share/mk/sys.mk (working copy)
@@ -33,8 +33,10 @@
 
 # early include for customization
 # see local.sys.mk below
-.-include local.sys.env.mk
+.sinclude local.sys.env.mk
 
+.if defined(.PARSEDIR)
+# none of this is relevant without bmake
 .if ${MK_META_MODE} == yes
 .-include meta.sys.mk
 .elif ${MK_META_FILES} == yes  ${.MAKEFLAGS:U:M-B} == 
@@ -44,6 +46,7 @@
 # This needs to be done early - before .PATH is computed
 .-include auto.obj.mk
 .endif
+.endif
 
 # If the special target .POSIX appears (without prerequisites or
 # commands) before the first noncomment line in the makefile, make shall
@@ -361,7 +364,7 @@
 .endif
 
 # late include for customization
-.-include local.sys.mk
+.sinclude local.sys.mk
 
 .if defined(__MAKE_SHELL)  !empty(__MAKE_SHELL)
 SHELL= ${__MAKE_SHELL}
@@ -378,11 +381,12 @@
 # when running target scripts, this is a problem for many makefiles here.
 # So define a shell that will do what FreeBSD expects.
 .ifndef WITHOUT_SHELL_ERRCTL
+___MAKE_SHELL?= /bin/sh
 .SHELL: name=sh \
quiet=set - echo=set -v filter=set - \
hasErrCtl=yes check=set -e ignore=set +e \
echoFlag=v errFlag=e \
-   path=${__MAKE_SHELL:U/bin/sh}
+   path=${__MAKE_SHELL}
 .endif
 
 .include bsd.cpu.mk
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r284598 - head/share/mk

2015-08-01 Thread Simon J. Gerraty
Bryan Drewery bdrew...@freebsd.org wrote:
head/share/mk/local.sys.mk
 
 I'm bothered by the amount of local.* files committed in the tree. I
 expect, as a user and working in a downstream product, that a local.*
 file is MINE, not FREEBSD. The pattern of using 'local' is quite common
 as a *user* file.

Yes that's exactly the point.
local*mk (and src*) do not get installed in /usr/share/mk, yet the
inlcudes exist as points for you to customize the behavior.

 Why are these named as such? It seems they should just be 'src.' with
 .sinclude hooks for actual local overrides.

local* are name as such since that's all that bsd* should know about.
Providing for local customization.

Ideally the local.*.mk in src/share/mk would do nothing except include 
src.*mk which is where the smarts for building src should be.
But /usr/share/mk/ should know noting about src*
since it is supposed to be generically useful infra.

There's extra stuff there because it might be useful as an example.
We can work on that over time I guess.

After many years consulting and providing tools to customers,
I really like making it possible for them to customize without touching
(hacking) any of the original bits, it has worked very well.

That's key when you get to something really complicated like dirdeps.mk

  +# site customizations that do not depend on anything!
  +SRC_ENV_CONF?= /etc/src-env.conf
  +.if !empty(SRC_ENV_CONF)  !target(_src_env_conf_included_)
  +.-include ${SRC_ENV_CONF}
  +_src_env_conf_included_:   .NOTMAIN
   .endif
 
 This needs to be documented in at least src.conf(5). I'm concerned that
 the need to add this indicates subtle changes elsewhere that may break
 existing /etc/src.conf setups, but I cannot find an example.

Sorry, I didn't do the above originally; what is the concern?

  +# late include for customization
  +.-include local.sys.mk
 
 In local.sys.mk from r284345 is an inclusion of SRCCONF, which is now
 different and earlier than before. I wonder if this should move back to
 only being included from bsd.own.mk (there is even a lingering
 WITHOUT_SRCCONF check in that file). The way it is now is very obscure
 in terms of when it is actually included and from where.

Since I didn't move the inlcude of src.conf from bsd.own.mk
(I would *guess* it was part of the src.opts changes) I'm not sure 
what the pros/cons of the two locations are.
Certainly changing *anything* has potential to bite someone,
but it is very hard to improve without change.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r286168 - head/sys/net

2015-08-01 Thread Bruce Evans

On Sun, 2 Aug 2015, John-Mark Gurney wrote:


Log:
 convert to C11's _Static_assert, and pull in sys/cdefs.h for
 compatibility w/ older non-C11 compilers...


This include is bogus.  net/pfkeyv2.h already depends on the includer
including other headers that include sys/cdefs.h.  Mainly sys/types.h.
sys/types.h defined massive namespace pollution that includes everything
in sys/cdefs.h.  It includes sys/cdefs.h an infinite number of times
via recursion, except the recursion is stopped by anti-reinclude guards.
Th recursion makes the static number of nested includes of sys/cdefs.h
hard to count.

Also, this is a kernel header.  All kernel headers depend on the includer
including sys/param.h and sys/systm.h.  Some work accidentally
without this, and broken includers depend on this.  For example, this
file didn't depend on sys/systm.h for the definition of CTASSERT()
and wasn't broken when CTASSERT() was added, but if any includers of
it that didn't include sys/systm.h had there brokenness exposed.
sys/param.h and sys/systm.h defined much more massive namespace
pollution than sys/types.h, together with some names that that are
not pollution.  Almost everything in sys/cdef.h is now part of the
API.

As a result, most kernel headers should not include sys/cdefs.h.
Some leaf headers like the x86 _types.h check that it is included
before them.  Some headers that are intentionally shared between
the kernel and userland have a sloppy but non-polluting _KERNEL
section that depends on many includes (mainly all the ones in
sys/param.h and doesn't include anything explicitly, followed
by a non-sloppy  userland section that begins with an include of
sys/cdefs.h.  This include used to be used for __BEGIN/__END_DECLS
and __P(()) but is now just used for the former.  Macros like
__BEGIN/__END_DECLS and _Static_assert are just as ugly as __P(())
and should go away, but they have proliferated faster than __P(())
went away.  The non-sloppyness includes not including sys/types.h
but using basic types and declaring the few ufoo_t types that are
part of the documented API of the header.

If an application wants to abuse a kernel header, then it must fake
the kernel environment for it.  I don't know much about this header,
but it is not documented in any man page so it can do anything.

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


svn commit: r286178 - head

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sun Aug  2 02:23:30 2015
New Revision: 286178
URL: https://svnweb.freebsd.org/changeset/base/286178

Log:
  Add removed tests to ObsoleteFiles.inc
  
  Submitted by: ngie

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Sun Aug  2 02:00:20 2015(r286177)
+++ head/ObsoleteFiles.inc  Sun Aug  2 02:23:30 2015(r286178)
@@ -38,6 +38,8 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20150802: Remove netbsd's test on pw(8)
+OLD_FILES+=usr/tests/usr.sbin/pw/pw_test
 # 20150719: Remove libarchive.pc
 OLD_FILES+=usr/libdata/pkgconfig/libarchive.pc
 # 20150705: Rename DTrace provider man pages.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r285985 - in head/usr.sbin/pw: . tests

2015-08-01 Thread Bruce Evans

On Sat, 1 Aug 2015, Jilles Tjoelker wrote:


On Sun, Aug 02, 2015 at 02:59:00AM +1000, Bruce Evans wrote:

On Sat, 1 Aug 2015, Jilles Tjoelker wrote:

These values are easily written using arithmetic expansion, for example
largeid=$((0x1)).



Not really.  Shells are also very buggy or limited in this area.  I
often use old versions of sh and bash that only support up to INT32_MAX
and have broken overflow handling.  /bin/sh in -current only supports
up to INT64_MAX (or maybe INTMAX_MAX) and has broken overflow handling
(it clamps to INT64_MAX).  Not so old versions of bash only support
up to INT64_MAX and have differently broken overflow handling (4.3.99
blindly assigns to int64_t, so $((0x8000)) becomes
-0x8000.



expr is also limited to INT64_MAX, but attempts to have non-broken
overflow handling.


The tests need not work with old versions of sh and bash (they already
rely on many more recent features and bugfixes). The broken overflow
handling in parsing literals does not affect the given example.


But I complained about the example being deficient.  It only needs to
test up to UINT32_MAX now, but that may change.  A similar test in
dd already needs to go up to UINT64_MAX.  dd does support hex numbers,
and is suppose to support offsets about OFF_MAX, but this is broken
by excessive support for the signedness of off_t.  All kernel addresses
in /dev/kmem are above 0x on amd64.  I tried to get
green@ to fix this in Y2K, but the result was a larger mess.


When using strtol() or similar functions, accepting hex typically
implies accepting octal as well, which causes confusing and
POSIX-violating results like 010 interpreted as eight.



This is a problem.  strtonum could accept hex but not octal by calling
strtoimax() twice for bases 10 and 16.  Also dehumanized formats like
1k and 1K.  It should also actually accept numbers as input.  1.1e1 if
not I * Pi.


Silently expanding what strtonum() accepts might cause breakage or even
security vulnerabilities.


It is hard to fix broken APIs/UIs once they are used.

strtonum() is not used often in /usr/src.  Its main use is in openssh,
and that is hard to fix since both strtonum and opensh are from OpenBSD.
Using names in the reserved namespace causes portability problems.
FreeBSD's expand_number() is a much worse name, but at least it doesn't
conflict with better future uses of a reserved name.

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


Re: svn commit: r286170 - head/share/man/man9

2015-08-01 Thread Bruce Evans

On Sun, 2 Aug 2015, John-Mark Gurney wrote:


Log:
 mark this function as deprecated, and put the warning first, since I
 doubt most people will read to the end...  Note the use of sys/cdefs.h
 for pre-C11 compilers...


This function shouldn't be deprecated.  It is a kernel wrapper with a
good name for hiding the implementation detail or not-yet standard
interface _Static_assert().

CTASSERT() is the compile-time variant of KASSERT().  We intentionally
use KASSERT() instead of anything like the standard assert(3) since
we don't like the API or semantics of assert() and want one with
different design and implementation bugs.  I can't think of any use
for different semantics to _Static_assert(), but using CTASSERT()
retains flexibility.

sys/cdefs.h isn't a prerequisite for this function.  The correct
prerequisites for this function are already documented.  They are
sys/param.h and sys/systm.h.


 I didn't included a note about being compatibile w/ userland since a
 C11 feature should be obviously usable in userland...


If CTASSERT() is abused in userland, then the kernel environment must
be faked.


Modified: head/share/man/man9/CTASSERT.9
==
--- head/share/man/man9/CTASSERT.9  Sun Aug  2 00:18:48 2015
(r286169)
+++ head/share/man/man9/CTASSERT.9  Sun Aug  2 00:22:14 2015
(r286170)
@@ -26,7 +26,7 @@
.\
.\ $FreeBSD$
.\
-.Dd July 30, 2015
+.Dd August 1, 2015
.Dt CTASSERT 9
.Os
.Sh NAME
@@ -39,6 +39,15 @@
.Sh DESCRIPTION
The
.Fn CTASSERT
+macro is deprecated and the C11 standard
+.Fn _Static_assert
+should be used instead.
+The header
+.Fa sys/cdefs.h
+should be included to provide compatibility for pre-C11 compilers.


_Static_assert() shoudn't be used instead, but when it is including
sys/cdefs.h isn' optional.  Then the documented prerequisites for this
function might not be needed for the replacement but in the kernel they
must be provided for other functions.

Some section 9 man pages, e.g., atomic.9, document a minimal
prerequisite like sys/types.h, but this sets a bad example and
inhibits adding conditional features like KASSERTS()s in atomic.h.
atomic.h is so low-level that you normally wouldn't want to bloat it
with assertions, but you might want to add them for debugging.  In
fact, it is a style bug for any kernel file to use the documented
prerequisite for the atomic functions.  machine/atomic.h is part of
the standard pollution in sys/systm.h and it is a style bug to not
depend on that.

sys/param.h is a documented prerequisite in 264 section 9 man pages
(at the source level; many more counting links).  sys/systm.h is in
only 34.  sys/types.h is in 41.


+.Pp
+The
+.Fn CTASSERT
macro evaluates
.Fa expression
at compile time and causes a compiler error if it is false.
@@ -48,10 +57,6 @@ The
macro is useful for asserting the size or alignment of important
data structures and variables during compilation, which would
otherwise cause the code to fail at run time.
-.Pp
-The
-.Fn CTASSERT
-macro is not usable in userland.


The CTASSERT() macro is still not usable in userland.  It is only abusable.
Its alternative _Static_assert() is usable, but most people won't read to
the beginning of this to find it here.


.Sh EXAMPLES
Assert that the size of the
.Vt uuid


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


svn commit: r286167 - head/sys/cddl/contrib/opensolaris/uts/common/dtrace

2015-08-01 Thread Mark Johnston
Author: markj
Date: Sun Aug  2 00:11:56 2015
New Revision: 286167
URL: https://svnweb.freebsd.org/changeset/base/286167

Log:
  Avoid dereferencing curthread-td_proc-p_cred in DTrace probe context.
  
  When a process is exiting, there is a narrow window where p_cred may be
  NULL while its threads are still executing. Specifically, the last thread
  to exit a process sets the process state to PRS_ZOMBIE with the proc
  spinlock held and then calls thread_exit(). thread_exit() drops the spin
  lock, permitting the process to be reaped and thus causing its cred struct
  to be released. However, the exiting thread may still cause DTrace probes
  to fire by calling sched_throw(), resulting in a double fault if such a
  probe enabling attempts to access the GID or UID DIF variables.
  
  The thread's cred reference is not susceptible to this race since it is not
  released until after the thread has exited.
  
  MFC after:1 week

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.cSun Aug 
 2 00:03:08 2015(r286166)
+++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/dtrace.cSun Aug 
 2 00:11:56 2015(r286167)
@@ -3510,7 +3510,6 @@ dtrace_dif_variable(dtrace_mstate_t *mst
 */
if (DTRACE_ANCHORED(mstate-dtms_probe)  CPU_ON_INTR(CPU))
return ((uint64_t)p0.p_cred-cr_uid);
-#endif
 
/*
 * It is always safe to dereference one's own t_procp pointer:
@@ -3522,6 +3521,9 @@ dtrace_dif_variable(dtrace_mstate_t *mst
 * credential, since this is never NULL after process birth.
 */
return ((uint64_t)curthread-t_procp-p_cred-cr_uid);
+#else
+   return ((uint64_t)curthread-td_ucred-cr_uid);
+#endif
 
case DIF_VAR_GID:
if (!dtrace_priv_proc(state))
@@ -3533,7 +3535,6 @@ dtrace_dif_variable(dtrace_mstate_t *mst
 */
if (DTRACE_ANCHORED(mstate-dtms_probe)  CPU_ON_INTR(CPU))
return ((uint64_t)p0.p_cred-cr_gid);
-#endif
 
/*
 * It is always safe to dereference one's own t_procp pointer:
@@ -3545,6 +3546,9 @@ dtrace_dif_variable(dtrace_mstate_t *mst
 * credential, since this is never NULL after process birth.
 */
return ((uint64_t)curthread-t_procp-p_cred-cr_gid);
+#else
+   return ((uint64_t)curthread-td_ucred-cr_gid);
+#endif
 
case DIF_VAR_ERRNO: {
 #ifdef illumos
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286174 - in head: cddl/usr.sbin/dtrace share/mk tools/build/options

2015-08-01 Thread Mark Johnston
Author: markj
Date: Sun Aug  2 00:37:33 2015
New Revision: 286174
URL: https://svnweb.freebsd.org/changeset/base/286174

Log:
  Add a src.conf option to build and install the DTrace test suite.
  
  Reviewed by:  gnn, ngie
  Differential Revision:https://reviews.freebsd.org/D3195

Added:
  head/tools/build/options/WITH_DTRACE_TESTS   (contents, props changed)
Modified:
  head/cddl/usr.sbin/dtrace/Makefile
  head/share/mk/src.opts.mk

Modified: head/cddl/usr.sbin/dtrace/Makefile
==
--- head/cddl/usr.sbin/dtrace/Makefile  Sun Aug  2 00:33:34 2015
(r286173)
+++ head/cddl/usr.sbin/dtrace/Makefile  Sun Aug  2 00:37:33 2015
(r286174)
@@ -1,5 +1,7 @@
 # $FreeBSD$
 
+.include src.opts.mk
+
 .PATH: ${.CURDIR}/../../../cddl/contrib/opensolaris/cmd/dtrace
 
 PROG=  dtrace
@@ -22,4 +24,8 @@ CFLAGS+=  -I${.CURDIR}/../../../sys/cddl/
 
 LIBADD=dtrace
 
+.if ${MK_DTRACE_TESTS} != no
+SUBDIR+=   tests
+.endif
+
 .include bsd.prog.mk

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Sun Aug  2 00:33:34 2015(r286173)
+++ head/share/mk/src.opts.mk   Sun Aug  2 00:37:33 2015(r286174)
@@ -178,6 +178,7 @@ __DEFAULT_YES_OPTIONS = \
 __DEFAULT_NO_OPTIONS = \
 BSD_GREP \
 CLANG_EXTRAS \
+DTRACE_TESTS \
 EISA \
 HESIOD \
 LLDB \
@@ -318,6 +319,10 @@ MK_KERBEROS:=  no
 MK_AUTHPF:=no
 .endif
 
+.if ${MK_TESTS} == no
+MK_DTRACE_TESTS:= no
+.endif
+
 .if ${MK_TEXTPROC} == no
 MK_GROFF:= no
 .endif

Added: head/tools/build/options/WITH_DTRACE_TESTS
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/build/options/WITH_DTRACE_TESTS  Sun Aug  2 00:37:33 2015
(r286174)
@@ -0,0 +1,5 @@
+.\ $FreeBSD$
+Set to build and install the DTrace test suite in
+.Pa /usr/tests/cddl/usr.sbin/dtrace .
+This test suite is considered experimental on architectures other than
+amd64/amd64 and running it may cause system instability.
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286165 - head/sys/arm/ti

2015-08-01 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Sat Aug  1 23:10:36 2015
New Revision: 286165
URL: https://svnweb.freebsd.org/changeset/base/286165

Log:
  Set output pin initial value based on pin's pinmux pullup/pulldown setup
  
  Some of FDT blobs for AM335x-based devices use pinmux pullup/pulldown
  flag to setup initial GPIO ouputp value, e.g. 4DCAPE-43 sets LCD DATAEN
  signal this way. It works for Linux because Linux driver does not enforce
  pin direction until after it's requested by consumer. So input with pullup
  flag set acts as output with GPIO_HIGH value
  
  Reviewed by:  loos

Modified:
  head/sys/arm/ti/ti_gpio.c

Modified: head/sys/arm/ti/ti_gpio.c
==
--- head/sys/arm/ti/ti_gpio.c   Sat Aug  1 22:56:42 2015(r286164)
+++ head/sys/arm/ti/ti_gpio.c   Sat Aug  1 23:10:36 2015(r286165)
@@ -573,7 +573,7 @@ ti_gpio_bank_init(device_t dev)
 {
int pin;
struct ti_gpio_softc *sc;
-   uint32_t flags, reg_oe, rev;
+   uint32_t flags, reg_oe, reg_set, rev;
clk_ident_t clk;
 
sc = device_get_softc(dev);
@@ -607,12 +607,18 @@ ti_gpio_bank_init(device_t dev)
 
/* Init OE register based on pads configuration. */
reg_oe = 0x;
+   reg_set = 0;
for (pin = 0; pin  PINS_PER_BANK; pin++) {
TI_GPIO_GET_FLAGS(dev, pin, flags);
-   if (flags  GPIO_PIN_OUTPUT)
+   if (flags  GPIO_PIN_OUTPUT) {
reg_oe = ~(1UL  pin);
+   if (flags  GPIO_PIN_PULLUP)
+   reg_set |= (1UL  pin);
+   }
}
ti_gpio_write_4(sc, TI_GPIO_OE, reg_oe);
+   if (reg_set)
+   ti_gpio_write_4(sc, TI_GPIO_SETDATAOUT, reg_set);
 
return (0);
 }
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286169 - head/cddl/contrib/opensolaris/lib/libdtrace/common

2015-08-01 Thread Mark Johnston
Author: markj
Date: Sun Aug  2 00:18:48 2015
New Revision: 286169
URL: https://svnweb.freebsd.org/changeset/base/286169

Log:
  Perform bounds checking when constructing a format string.
  
  This was detected by the FORTIFY_SOURCE build.
  
  PR:   201657
  Reported by:  pfg
  MFC after:2 weeks

Modified:
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c

Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c
==
--- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c  Sun Aug 
 2 00:15:52 2015(r286168)
+++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_printf.c  Sun Aug 
 2 00:18:48 2015(r286169)
@@ -1348,6 +1348,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE
dtrace_aggdesc_t *agg;
caddr_t lim = (caddr_t)buf + len, limit;
char format[64] = %;
+   size_t ret;
int i, aggrec, curagg = -1;
uint64_t normal;
 
@@ -1379,7 +1380,9 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE
int prec = pfd-pfd_prec;
int rval;
 
+   const char *start;
char *f = format + 1; /* skip initial '%' */
+   size_t fmtsz = sizeof(format) - 1;
const dtrace_recdesc_t *rec;
dt_pfprint_f *func;
caddr_t addr;
@@ -1536,6 +1539,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE
break;
}
 
+   start = f;
if (pfd-pfd_flags  DT_PFCONV_ALT)
*f++ = '#';
if (pfd-pfd_flags  DT_PFCONV_ZPAD)
@@ -1548,6 +1552,7 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE
*f++ = '\'';
if (pfd-pfd_flags  DT_PFCONV_SPACE)
*f++ = ' ';
+   fmtsz -= f - start;
 
/*
 * If we're printing a stack and DT_PFCONV_LEFT is set, we
@@ -1558,13 +1563,20 @@ dt_printf_format(dtrace_hdl_t *dtp, FILE
if (func == pfprint_stack  (pfd-pfd_flags  DT_PFCONV_LEFT))
width = 0;
 
-   if (width != 0)
-   f += snprintf(f, sizeof (format), %d, ABS(width));
+   if (width != 0) {
+   ret = snprintf(f, fmtsz, %d, ABS(width));
+   f += ret;
+   fmtsz = MAX(0, fmtsz - ret);
+   }
 
-   if (prec  0)
-   f += snprintf(f, sizeof (format), .%d, prec);
+   if (prec  0) {
+   ret = snprintf(f, fmtsz, .%d, prec);
+   f += ret;
+   fmtsz = MAX(0, fmtsz - ret);
+   }
 
-   (void) strcpy(f, pfd-pfd_fmt);
+   if (strlcpy(f, pfd-pfd_fmt, fmtsz) = fmtsz)
+   return (dt_set_errno(dtp, EDT_COMPILER));
pfd-pfd_rec = rec;
 
if (func(dtp, fp, format, pfd, addr, size, normal)  0)
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286173 - head/usr.sbin/pw/tests

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sun Aug  2 00:33:34 2015
New Revision: 286173
URL: https://svnweb.freebsd.org/changeset/base/286173

Log:
  Remove netbsd tests on pw(8)
  
  First they are redundant with the tests we currently have on pw(8)
  Second they to modify the host database instead of being self contained 
withing
  the test directory

Modified:
  head/usr.sbin/pw/tests/Makefile

Modified: head/usr.sbin/pw/tests/Makefile
==
--- head/usr.sbin/pw/tests/Makefile Sun Aug  2 00:24:21 2015
(r286172)
+++ head/usr.sbin/pw/tests/Makefile Sun Aug  2 00:33:34 2015
(r286173)
@@ -1,8 +1,5 @@
 # $FreeBSD$
 
-TESTSRC=   ${.CURDIR}/../../../contrib/netbsd-tests/usr.sbin/useradd
-.PATH: ${TESTSRC}
-
 TESTSDIR=  ${TESTSBASE}/usr.sbin/pw
 
 ATF_TESTS_SH=  pw_etcdir \
@@ -24,12 +21,4 @@ FILES=   group helper_functions.shin mast
pw-modified.conf
 FILESDIR=   ${TESTSDIR}
 
-ATF_TESTS_SH+= pw_test
-# - user{add,del} does not exist on FreeBSD; use pw user{add,del} instead
-# - The command passes on FreeBSD
-ATF_TESTS_SH_SED_pw_test=  -e 's/useradd /pw useradd /'
-ATF_TESTS_SH_SED_pw_test+= -e 's/userdel /pw userdel /'
-ATF_TESTS_SH_SED_pw_test+= -e '/atf_expect_fail PR bin\/39546/d'
-ATF_TESTS_SH_SRC_pw_test=  t_useradd.sh
-
 .include bsd.test.mk
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286166 - in head/sys: kern sys

2015-08-01 Thread Mark Johnston
Author: markj
Date: Sun Aug  2 00:03:08 2015
New Revision: 286166
URL: https://svnweb.freebsd.org/changeset/base/286166

Log:
  Don't modify curthread-td_locks unless INVARIANTS is enabled.
  
  This field is only used in a KASSERT that verifies that no locks are held
  when returning to user mode. Moreover, the td_locks accounting is only
  correct when LOCK_DEBUG  0, which is implied by INVARIANTS.
  
  Reviewed by:  jhb
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D3205

Modified:
  head/sys/kern/kern_lock.c
  head/sys/kern/kern_mutex.c
  head/sys/kern/kern_rmlock.c
  head/sys/kern/kern_rwlock.c
  head/sys/kern/kern_sx.c
  head/sys/sys/proc.h

Modified: head/sys/kern/kern_lock.c
==
--- head/sys/kern/kern_lock.c   Sat Aug  1 23:10:36 2015(r286165)
+++ head/sys/kern/kern_lock.c   Sun Aug  2 00:03:08 2015(r286166)
@@ -69,12 +69,8 @@ CTASSERT(LK_UNLOCKED == (LK_UNLOCKED 
 
 #ifndef INVARIANTS
 #define_lockmgr_assert(lk, what, file, line)
-#defineTD_LOCKS_INC(td)
-#defineTD_LOCKS_DEC(td)
-#else
-#defineTD_LOCKS_INC(td)((td)-td_locks++)
-#defineTD_LOCKS_DEC(td)((td)-td_locks--)
 #endif
+
 #defineTD_SLOCKS_INC(td)   ((td)-td_lk_slocks++)
 #defineTD_SLOCKS_DEC(td)   ((td)-td_lk_slocks--)
 

Modified: head/sys/kern/kern_mutex.c
==
--- head/sys/kern/kern_mutex.c  Sat Aug  1 23:10:36 2015(r286165)
+++ head/sys/kern/kern_mutex.c  Sun Aug  2 00:03:08 2015(r286166)
@@ -224,7 +224,7 @@ __mtx_lock_flags(volatile uintptr_t *c, 
line);
WITNESS_LOCK(m-lock_object, (opts  ~MTX_RECURSE) | LOP_EXCLUSIVE,
file, line);
-   curthread-td_locks++;
+   TD_LOCKS_INC(curthread);
 }
 
 void
@@ -248,7 +248,7 @@ __mtx_unlock_flags(volatile uintptr_t *c
mtx_assert(m, MA_OWNED);
 
__mtx_unlock(m, curthread, opts, file, line);
-   curthread-td_locks--;
+   TD_LOCKS_DEC(curthread);
 }
 
 void
@@ -347,7 +347,7 @@ _mtx_trylock_flags_(volatile uintptr_t *
if (rval) {
WITNESS_LOCK(m-lock_object, opts | LOP_EXCLUSIVE | 
LOP_TRYLOCK,
file, line);
-   curthread-td_locks++;
+   TD_LOCKS_INC(curthread);
if (m-mtx_recurse == 0)
LOCKSTAT_PROFILE_OBTAIN_LOCK_SUCCESS(adaptive__acquire,
m, contested, waittime, file, line);
@@ -958,7 +958,7 @@ _mtx_destroy(volatile uintptr_t *c)
if (LOCK_CLASS(m-lock_object) == lock_class_mtx_spin)
spinlock_exit();
else
-   curthread-td_locks--;
+   TD_LOCKS_DEC(curthread);
 
lock_profile_release_lock(m-lock_object);
/* Tell witness this isn't locked to make it happy. */

Modified: head/sys/kern/kern_rmlock.c
==
--- head/sys/kern/kern_rmlock.c Sat Aug  1 23:10:36 2015(r286165)
+++ head/sys/kern/kern_rmlock.c Sun Aug  2 00:03:08 2015(r286166)
@@ -608,11 +608,8 @@ _rm_wlock_debug(struct rmlock *rm, const
_rm_wlock(rm);
 
LOCK_LOG_LOCK(RMWLOCK, rm-lock_object, 0, 0, file, line);
-
WITNESS_LOCK(rm-lock_object, LOP_EXCLUSIVE, file, line);
-
-   curthread-td_locks++;
-
+   TD_LOCKS_INC(curthread);
 }
 
 void
@@ -628,7 +625,7 @@ _rm_wunlock_debug(struct rmlock *rm, con
WITNESS_UNLOCK(rm-lock_object, LOP_EXCLUSIVE, file, line);
LOCK_LOG_LOCK(RMWUNLOCK, rm-lock_object, 0, 0, file, line);
_rm_wunlock(rm);
-   curthread-td_locks--;
+   TD_LOCKS_DEC(curthread);
 }
 
 int
@@ -670,9 +667,7 @@ _rm_rlock_debug(struct rmlock *rm, struc
LOCK_LOG_LOCK(RMRLOCK, rm-lock_object, 0, 0, file,
line);
WITNESS_LOCK(rm-lock_object, 0, file, line);
-
-   curthread-td_locks++;
-
+   TD_LOCKS_INC(curthread);
return (1);
} else if (trylock)
LOCK_LOG_TRY(RMRLOCK, rm-lock_object, 0, 0, file, line);
@@ -694,7 +689,7 @@ _rm_runlock_debug(struct rmlock *rm, str
WITNESS_UNLOCK(rm-lock_object, 0, file, line);
LOCK_LOG_LOCK(RMRUNLOCK, rm-lock_object, 0, 0, file, line);
_rm_runlock(rm, tracker);
-   curthread-td_locks--;
+   TD_LOCKS_DEC(curthread);
 }
 
 #else

Modified: head/sys/kern/kern_rwlock.c
==
--- head/sys/kern/kern_rwlock.c Sat Aug  1 23:10:36 2015(r286165)
+++ head/sys/kern/kern_rwlock.c Sun Aug  2 00:03:08 2015(r286166)
@@ -268,7 +268,7 @@ _rw_wlock_cookie(volatile uintptr_t *c, 
__rw_wlock(rw, curthread, file, line);
 

Re: svn commit: r285985 - in head/usr.sbin/pw: . tests

2015-08-01 Thread Jilles Tjoelker
On Sun, Aug 02, 2015 at 02:59:00AM +1000, Bruce Evans wrote:
 On Sat, 1 Aug 2015, Jilles Tjoelker wrote:
  These values are easily written using arithmetic expansion, for example
  largeid=$((0x1)).

 Not really.  Shells are also very buggy or limited in this area.  I
 often use old versions of sh and bash that only support up to INT32_MAX
 and have broken overflow handling.  /bin/sh in -current only supports
 up to INT64_MAX (or maybe INTMAX_MAX) and has broken overflow handling
 (it clamps to INT64_MAX).  Not so old versions of bash only support
 up to INT64_MAX and have differently broken overflow handling (4.3.99
 blindly assigns to int64_t, so $((0x8000)) becomes
 -0x8000.

 expr is also limited to INT64_MAX, but attempts to have non-broken
 overflow handling.

The tests need not work with old versions of sh and bash (they already
rely on many more recent features and bugfixes). The broken overflow
handling in parsing literals does not affect the given example.

  When using strtol() or similar functions, accepting hex typically
  implies accepting octal as well, which causes confusing and
  POSIX-violating results like 010 interpreted as eight.

 This is a problem.  strtonum could accept hex but not octal by calling
 strtoimax() twice for bases 10 and 16.  Also dehumanized formats like
 1k and 1K.  It should also actually accept numbers as input.  1.1e1 if
 not I * Pi.

Silently expanding what strtonum() accepts might cause breakage or even
security vulnerabilities.

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


svn commit: r286163 - head/etc

2015-08-01 Thread Jilles Tjoelker
Author: jilles
Date: Sat Aug  1 22:00:25 2015
New Revision: 286163
URL: https://svnweb.freebsd.org/changeset/base/286163

Log:
  rc.subr: Allow rc.conf.d with multi-directory local_startup.
  
  I also changed ${...%*/rc.d} to ${...%/rc.d} since the shortest match always
  has an empty string for the asterisk.
  
  PR:   201641
  Submitted by: Jamie Landeg-Jones (original version)
  MFC after:1 week

Modified:
  head/etc/rc.subr

Modified: head/etc/rc.subr
==
--- head/etc/rc.subrSat Aug  1 20:40:37 2015(r286162)
+++ head/etc/rc.subrSat Aug  1 22:00:25 2015(r286163)
@@ -1333,7 +1333,8 @@ load_rc_config()
# If a service name was specified, attempt to load
# service-specific configuration
if [ -n $_name ] ; then
-   for _d in /etc ${local_startup%*/rc.d}; do
+   for _d in /etc ${local_startup}; do
+   _d=${_d%/rc.d}
if [ -f ${_d}/rc.conf.d/$_name ]; then
debug Sourcing ${_d}/rc.conf.d/$_name
. ${_d}/rc.conf.d/$_name
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286171 - head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip

2015-08-01 Thread Mark Johnston
Author: markj
Date: Sun Aug  2 00:23:18 2015
New Revision: 286171
URL: https://svnweb.freebsd.org/changeset/base/286171

Log:
  - Remove hardcoded paths for the perl executable.
  - Rather than assuming that a process is listening on 127.0.0.1:22, use
nc(1) to find an available port and bind to it for the duration of the
test.
  
  MFC after:1 week
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl   
Sun Aug  2 00:22:14 2015(r286170)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv4remote.pl   
Sun Aug  2 00:23:18 2015(r286171)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # CDDL HEADER START
 #

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl   
Sun Aug  2 00:22:14 2015(r286170)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/get.ipv6remote.pl   
Sun Aug  2 00:23:18 2015(r286171)
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/env perl
 #
 # CDDL HEADER START
 #

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh
Sun Aug  2 00:22:14 2015(r286170)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4localtcp.ksh
Sun Aug  2 00:23:18 2015(r286171)
@@ -58,12 +58,25 @@ fi
 
 dtrace=$1
 local=127.0.0.1
-tcpport=22
 DIR=/var/tmp/dtest.$$
 
+tcpport=1024
+bound=5000
+while [ $tcpport -lt $bound ]; do
+   nc -z $local $tcpport /dev/null || break
+   tcpport=$(($tcpport + 1))
+done
+if [ $tcpport -eq $bound ]; then
+   echo couldn't find an available TCP port
+   exit 1
+fi
+
 mkdir $DIR
 cd $DIR
 
+# nc will exit when the connection is closed.
+nc -l $local $tcpport 
+
 cat  test.pl -EOPERL
use IO::Socket;
my \$s = IO::Socket::INET-new(
@@ -76,7 +89,7 @@ cat  test.pl -EOPERL
sleep(2);
 EOPERL
 
-$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin EODTRACE
+$dtrace -c 'perl test.pl' -qs /dev/stdin EODTRACE
 BEGIN
 {
ipsend = tcpsend = ipreceive = tcpreceive = 0;

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh
   Sun Aug  2 00:22:14 2015(r286170)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.ipv4remotetcp.ksh
   Sun Aug  2 00:23:18 2015(r286171)
@@ -79,7 +79,7 @@ cat  test.pl -EOPERL
sleep(2);
 EOPERL
 
-$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin EODTRACE
+$dtrace -c 'perl test.pl' -qs /dev/stdin EODTRACE
 BEGIN
 {
ipsend = tcpsend = ipreceive = tcpreceive = 0;

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
   Sun Aug  2 00:22:14 2015(r286170)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.localtcpstate.ksh
   Sun Aug  2 00:23:18 2015(r286171)
@@ -82,7 +82,7 @@ cat  test.pl -EOPERL
sleep(2);
 EOPERL
 
-$dtrace -c '/usr/bin/perl test.pl' -qs /dev/stdin EODTRACE
+$dtrace -c 'perl test.pl' -qs /dev/stdin EODTRACE
 BEGIN
 {
ipsend = tcpsend = ipreceive = tcpreceive = 0;

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh
  Sun Aug  2 00:22:14 2015(r286170)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/ip/tst.remotetcpstate.ksh
  Sun Aug  2 00:23:18 2015(r286171)
@@ -87,7 +87,7 @@ cat  test.pl -EOPERL

svn commit: r286172 - head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs

2015-08-01 Thread Mark Johnston
Author: markj
Date: Sun Aug  2 00:24:21 2015
New Revision: 286172
URL: https://svnweb.freebsd.org/changeset/base/286172

Log:
  Don't hardcode the module or function component of lockstat probes.
  
  MFC after:1 week

Modified:
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d
  
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d
   Sun Aug  2 00:23:18 2015(r286171)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoofew.d
   Sun Aug  2 00:24:21 2015(r286172)
@@ -34,7 +34,7 @@
  *
  */
 
-lockstat:kernel:mtx_lock:adaptive-acquire
+lockstat:::adaptive-acquire
 {
mutex_owned();
exit(1);

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d
  Sun Aug  2 00:23:18 2015(r286171)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.motoomany.d
  Sun Aug  2 00:24:21 2015(r286172)
@@ -34,7 +34,7 @@
  *
  */
 
-lockstat:kernel:mtx_lock:adaptive-acquire
+lockstat:::adaptive-acquire
 {
mutex_owned((kmutex_t *)arg0, 99);
exit(1);

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d
  Sun Aug  2 00:23:18 2015(r286171)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoofew.d
  Sun Aug  2 00:24:21 2015(r286172)
@@ -36,7 +36,7 @@
  */
 
 
-lockstat:kernel:mtx_lock:adaptive-acquire
+lockstat:::adaptive-acquire
 {
mutex_type_adaptive();
exit(1);

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d
 Sun Aug  2 00:23:18 2015(r286171)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/err.D_PROTO_LEN.mtatoomany.d
 Sun Aug  2 00:24:21 2015(r286172)
@@ -35,7 +35,7 @@
  */
 
 
-lockstat:kernel:mtx_lock:adaptive-acquire
+lockstat:::adaptive-acquire
 {
mutex_type_adaptive((kmutex_t *)arg0, 99);
exit(1);

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d
Sun Aug  2 00:23:18 2015(r286171)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_owner.d
Sun Aug  2 00:24:21 2015(r286172)
@@ -48,7 +48,7 @@ BEGIN
i = 0;
 }
 
-lockstat::mtx_lock:adaptive-acquire
+lockstat:::adaptive-acquire
 {
 
ptr = mutex_owner((struct mtx *)arg0);

Modified: 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d
==
--- 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d
Sun Aug  2 00:23:18 2015(r286171)
+++ 
head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/funcs/tst.mutex_type_adaptive.d
Sun Aug  2 00:24:21 2015(r286172)
@@ -44,7 +44,7 @@ BEGIN
ret = -99;
 }
 
-mtx_lock:adaptive-acquire
+lockstat:::adaptive-acquire
 {
ret = mutex_type_adaptive((struct mtx *)arg0);
i++;
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286175 - head/share/man/man5

2015-08-01 Thread Mark Johnston
Author: markj
Date: Sun Aug  2 00:56:16 2015
New Revision: 286175
URL: https://svnweb.freebsd.org/changeset/base/286175

Log:
  Regenerate after r286174.

Modified:
  head/share/man/man5/src.conf.5

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Sun Aug  2 00:37:33 2015
(r286174)
+++ head/share/man/man5/src.conf.5  Sun Aug  2 00:56:16 2015
(r286175)
@@ -1,7 +1,7 @@
 .\ DO NOT EDIT-- this file is automatically generated.
 .\ from FreeBSD: head/tools/build/options/makeman 284708 2015-06-22 20:21:57Z 
sjg
 .\ $FreeBSD$
-.Dd July 29, 2015
+.Dd August 1, 2015
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -137,8 +137,8 @@ associated utilities, and examples.
 .Pp
 This option only affects amd64/amd64.
 .It Va WITHOUT_BINUTILS
-.\ from FreeBSD: head/tools/build/options/WITHOUT_BINUTILS 266158 2014-05-15 
16:51:45Z brooks
-Set to not build or install binutils (as, c++-filt, gconv,
+.\ from FreeBSD: head/tools/build/options/WITHOUT_BINUTILS 286036 2015-07-29 
20:02:20Z emaste
+Set to not build or install binutils (as, c++-filt,
 ld, nm, objcopy, objdump, readelf, size and strip) as part
 of the normal system build.
 The resulting system cannot build programs from source.
@@ -274,14 +274,14 @@ Set to avoid building the ARCMigrate, Re
 the Clang C/C++ compiler.
 .Pp
 It is a default setting on
-arm/arm, arm/armeb, arm/armv6, arm/armv6hf, mips/mipsel, mips/mips, 
mips/mips64el, mips/mips64, mips/mipsn32 and sparc64/sparc64.
+mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32 and 
sparc64/sparc64.
 .It Va WITH_CLANG_FULL
 .\ from FreeBSD: head/tools/build/options/WITH_CLANG_FULL 246259 2013-02-02 
22:28:29Z dim
 Set to build the ARCMigrate, Rewriter and StaticAnalyzer components of the
 Clang C/C++ compiler.
 .Pp
 It is a default setting on
-amd64/amd64, arm64/aarch64, i386/i386, pc98/i386, powerpc/powerpc and 
powerpc/powerpc64.
+amd64/amd64, arm/arm, arm/armeb, arm/armv6, arm/armv6hf, arm64/aarch64, 
i386/i386, pc98/i386, powerpc/powerpc and powerpc/powerpc64.
 .It Va WITHOUT_CLANG_IS_CC
 .\ from FreeBSD: head/tools/build/options/WITHOUT_CLANG_IS_CC 242629 
2012-11-05 21:53:23Z brooks
 Set to install the GCC compiler as
@@ -414,6 +414,12 @@ Set to not build dma Mail Transport Agen
 .\ from FreeBSD: head/tools/build/options/WITHOUT_DOCCOMPRESS 266752 
2014-05-27 15:52:27Z gjb
 Set to not to install compressed system documentation.
 Only the uncompressed version will be installed.
+.It Va WITH_DTRACE_TESTS
+.\ from FreeBSD: head/tools/build/options/WITH_DTRACE_TESTS 286174 2015-08-02 
00:37:33Z markj
+Set to build and install the DTrace test suite in
+.Pa /usr/tests/cddl/usr.sbin/dtrace .
+This test suite is considered experimental on architectures other than
+amd64/amd64 and running it may cause system instability.
 .It Va WITHOUT_DYNAMICROOT
 .\ from FreeBSD: head/tools/build/options/WITHOUT_DYNAMICROOT 156932 
2006-03-21 07:50:50Z ru
 Set this if you do not want to link
@@ -1268,6 +1274,8 @@ When set, it also enforces the following
 .Pp
 .Bl -item -compact
 .It
+.Va WITHOUT_DTRACE_TESTS
+.It
 .Va WITHOUT_TESTS_SUPPORT
 .El
 .It Va WITHOUT_TESTS_SUPPORT
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286176 - in head/tools/bus_space: . C Python

2015-08-01 Thread Marcel Moolenaar
Author: marcel
Date: Sun Aug  2 01:09:30 2015
New Revision: 286176
URL: https://svnweb.freebsd.org/changeset/base/286176

Log:
  Rename busdma_sync() to busdma_sync_range() and rename the
  base and size parameters to ofs and len (resp). Add a new
  busdma_sync() that makes the entire MD coherent.

Modified:
  head/tools/bus_space/C/lang.c
  head/tools/bus_space/C/libbus.h
  head/tools/bus_space/Python/lang.c
  head/tools/bus_space/busdma.c
  head/tools/bus_space/busdma.h

Modified: head/tools/bus_space/C/lang.c
==
--- head/tools/bus_space/C/lang.c   Sun Aug  2 00:56:16 2015
(r286175)
+++ head/tools/bus_space/C/lang.c   Sun Aug  2 01:09:30 2015
(r286176)
@@ -227,8 +227,15 @@ busdma_seg_get_size(busdma_seg_t seg)
 }
 
 int
-busdma_sync(busdma_md_t md, int op, bus_addr_t base, bus_size_t size)
+busdma_sync(busdma_md_t md, int op)
 {
 
-   return (bd_sync(md, op, base, size));
+   return (bd_sync(md, op, 0UL, ~0UL));
+}
+
+int
+busdma_sync_range(busdma_md_t md, int op, bus_size_t ofs, bus_size_t len)
+{
+
+   return (bd_sync(md, op, ofs, len));
 }

Modified: head/tools/bus_space/C/libbus.h
==
--- head/tools/bus_space/C/libbus.h Sun Aug  2 00:56:16 2015
(r286175)
+++ head/tools/bus_space/C/libbus.h Sun Aug  2 01:09:30 2015
(r286176)
@@ -78,6 +78,7 @@ bus_size_tbusdma_seg_get_size(busdma_se
 #defineBUSDMA_SYNC_PREWRITE4
 #defineBUSDMA_SYNC_POSTWRITE   8
 
-intbusdma_sync(busdma_md_t md, int op, bus_addr_t, bus_size_t);
+intbusdma_sync(busdma_md_t md, int op);
+intbusdma_sync_range(busdma_md_t md, int op, bus_size_t, bus_size_t);
 
 #endif /* _LIBBUS_SPACE_H_ */

Modified: head/tools/bus_space/Python/lang.c
==
--- head/tools/bus_space/Python/lang.c  Sun Aug  2 00:56:16 2015
(r286175)
+++ head/tools/bus_space/Python/lang.c  Sun Aug  2 01:09:30 2015
(r286176)
@@ -384,12 +384,27 @@ busdma_seg_get_size(PyObject *self, PyOb
 static PyObject *
 busdma_sync(PyObject *self, PyObject *args)
 {
-   u_long base, size;
int error, mdid, op;
 
-   if (!PyArg_ParseTuple(args, iikk, mdid, op, base, size))
+   if (!PyArg_ParseTuple(args, ii, mdid, op))
return (NULL);
-   error = bd_sync(mdid, op, base, size);
+   error = bd_sync(mdid, op, 0UL, ~0UL);
+   if (error) {
+   PyErr_SetString(PyExc_IOError, strerror(error));
+   return (NULL);
+   }
+   Py_RETURN_NONE;
+}
+
+static PyObject *
+busdma_sync_range(PyObject *self, PyObject *args)
+{
+   u_long ofs, len;
+   int error, mdid, op;
+
+   if (!PyArg_ParseTuple(args, iikk, mdid, op, ofs, len))
+   return (NULL);
+   error = bd_sync(mdid, op, ofs, len);
if (error) {
PyErr_SetString(PyExc_IOError, strerror(error));
return (NULL);
@@ -448,7 +463,9 @@ static PyMethodDef busdma_methods[] = {
Return the size of the segment. },
 
 { sync, busdma_sync, METH_VARARGS,
-   Keep memory/caches coherent WRT to DMA. },
+   Make the entire memory descriptor coherent WRT to DMA. },
+{ sync_range, busdma_sync_range, METH_VARARGS,
+   Make part of the memory descriptor coherent WRT to DMA. },
 
 { NULL, NULL, 0, NULL }
 };

Modified: head/tools/bus_space/busdma.c
==
--- head/tools/bus_space/busdma.c   Sun Aug  2 00:56:16 2015
(r286175)
+++ head/tools/bus_space/busdma.c   Sun Aug  2 01:09:30 2015
(r286176)
@@ -536,7 +536,7 @@ bd_seg_get_size(int sid, u_long *size_p)
 }
 
 int
-bd_sync(int mdid, u_int op, u_long base, u_long size)
+bd_sync(int mdid, u_int op, u_long ofs, u_long len)
 {
struct proto_ioc_busdma ioc;
struct obj *md;
@@ -549,8 +549,8 @@ bd_sync(int mdid, u_int op, u_long base,
ioc.request = PROTO_IOC_BUSDMA_SYNC;
ioc.key = md-key;
ioc.u.sync.op = op;
-   ioc.u.sync.base = base;
-   ioc.u.sync.size = size;
+   ioc.u.sync.base = ofs;
+   ioc.u.sync.size = len;
if (ioctl(md-fd, PROTO_IOC_BUSDMA, ioc) == -1)
return (errno);
 

Modified: head/tools/bus_space/busdma.h
==
--- head/tools/bus_space/busdma.h   Sun Aug  2 00:56:16 2015
(r286175)
+++ head/tools/bus_space/busdma.h   Sun Aug  2 01:09:30 2015
(r286176)
@@ -51,6 +51,6 @@ int   bd_md_next_seg(int mdid, int sid);
 intbd_seg_get_addr(int sid, u_long *);
 intbd_seg_get_size(int sid, u_long *);
 
-intbd_sync(int mdid, u_int op, u_long base, u_long size);
+intbd_sync(int mdid, u_int op, u_long ofs, u_long len);
 
 #endif /* 

Re: svn commit: r286147 - head/sys/compat/cloudabi

2015-08-01 Thread Ed Schouten
2015-08-01 17:34 GMT+02:00 John Baldwin j...@freebsd.org:
 Can you please not use 'arc commit'?

Sure!

That said, maybe there is something we can do to make it integrate
with our workflow so that it does work the way we want. Or maybe we
could somehow administratively disable 'arc commit', so that others
don't do it either.

Added phabric-admin@ to the CC. Maybe they have some good ideas?

-- 
Ed Schouten e...@nuxi.nl
Nuxi, 's-Hertogenbosch, the Netherlands
KvK/VAT number: 62051717
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r286144 - head/usr.bin/wall

2015-08-01 Thread Pedro Giffuni



On 01/08/2015 10:01 a.m., Pedro Giffuni wrote:



On 08/01/15 09:34, Eric van Gyzen wrote:

On 7/31/15 8:29 PM, Pedro F. Giffuni wrote:

Author: pfg
Date: Sat Aug  1 01:29:55 2015
New Revision: 286144
URL: https://svnweb.freebsd.org/changeset/base/286144

Log:
   Buffer overflow in wall(1).

   Revert r286102 and apply a cleaner fix.
   Tested for overflows by FORTIFY_SOURCE GSoC (with clang).

   Suggested by:bde
   Reviewed by:Oliver Pinter
   Tested by:Oliver Pinter
   MFC after:3 days

Modified:
   head/usr.bin/wall/ttymsg.c

Modified: head/usr.bin/wall/ttymsg.c
== 



--- head/usr.bin/wall/ttymsg.cFri Jul 31 23:40:18 2015 (r286143)
+++ head/usr.bin/wall/ttymsg.cSat Aug  1 01:29:55 2015 (r286144)
@@ -62,7 +62,7 @@ ttymsg(struct iovec *iov, int iovcnt, co
  struct iovec localiov[7];
  ssize_t left, wret;
  int cnt, fd;
-char device[MAXNAMLEN] = _PATH_DEV;
+char device[MAXNAMLEN];
  static char errbuf[1024];
  char *p;
  int forked;
@@ -71,8 +71,9 @@ ttymsg(struct iovec *iov, int iovcnt, co
  if (iovcnt  (int)(sizeof(localiov) / sizeof(localiov[0])))
  return (too many iov's (change code in wall/ttymsg.c));

-strlcat(device, line, sizeof(device));
+strlcpy(device, _PATH_DEV, sizeof(device));
  p = device + sizeof(_PATH_DEV) - 1;
+strlcpy(p, line, sizeof(device) - sizeof(_PATH_DEV));


You're probably already sick of this change, but I would encourage this
instead:

 strlcat(device, line, sizeof(device));



It looks exactly like the code I just replaced ;).





Your current code works, and it's even more efficient than strlcat.





Actually it looks like there may be some consensus towards reverting this
as the previous version was more readable. Since the code still works better
than when there was an overflow, let's leave it for a couple of days, maybe
interested developers will come with a better change.

Pedro.

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


svn commit: r286170 - head/share/man/man9

2015-08-01 Thread John-Mark Gurney
Author: jmg
Date: Sun Aug  2 00:22:14 2015
New Revision: 286170
URL: https://svnweb.freebsd.org/changeset/base/286170

Log:
  mark this function as deprecated, and put the warning first, since I
  doubt most people will read to the end...  Note the use of sys/cdefs.h
  for pre-C11 compilers...
  
  I didn't included a note about being compatibile w/ userland since a
  C11 feature should be obviously usable in userland...
  
  Suggested by: imp

Modified:
  head/share/man/man9/CTASSERT.9

Modified: head/share/man/man9/CTASSERT.9
==
--- head/share/man/man9/CTASSERT.9  Sun Aug  2 00:18:48 2015
(r286169)
+++ head/share/man/man9/CTASSERT.9  Sun Aug  2 00:22:14 2015
(r286170)
@@ -26,7 +26,7 @@
 .\
 .\ $FreeBSD$
 .\
-.Dd July 30, 2015
+.Dd August 1, 2015
 .Dt CTASSERT 9
 .Os
 .Sh NAME
@@ -39,6 +39,15 @@
 .Sh DESCRIPTION
 The
 .Fn CTASSERT
+macro is deprecated and the C11 standard
+.Fn _Static_assert
+should be used instead.
+The header
+.Fa sys/cdefs.h
+should be included to provide compatibility for pre-C11 compilers.
+.Pp
+The
+.Fn CTASSERT
 macro evaluates
 .Fa expression
 at compile time and causes a compiler error if it is false.
@@ -48,10 +57,6 @@ The
 macro is useful for asserting the size or alignment of important
 data structures and variables during compilation, which would
 otherwise cause the code to fail at run time.
-.Pp
-The
-.Fn CTASSERT
-macro is not usable in userland.
 .Sh EXAMPLES
 Assert that the size of the
 .Vt uuid
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286162 - head/sys/dev/e1000

2015-08-01 Thread Hans Petter Selasky
Author: hselasky
Date: Sat Aug  1 20:40:37 2015
New Revision: 286162
URL: https://svnweb.freebsd.org/changeset/base/286162

Log:
  Free mbufs when busdma loading fails.
  
  Reviewed by:  erj, sbruno
  MFC after:1 month

Modified:
  head/sys/dev/e1000/if_em.c
  head/sys/dev/e1000/if_igb.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Sat Aug  1 17:48:35 2015(r286161)
+++ head/sys/dev/e1000/if_em.c  Sat Aug  1 20:40:37 2015(r286162)
@@ -2029,9 +2029,6 @@ retry:
/* Try it again, but only once */
remap = 0;
goto retry;
-   } else if (error == ENOMEM) {
-   adapter-no_tx_dma_setup++;
-   return (error);
} else if (error != 0) {
adapter-no_tx_dma_setup++;
m_freem(*m_headp);

Modified: head/sys/dev/e1000/if_igb.c
==
--- head/sys/dev/e1000/if_igb.c Sat Aug  1 17:48:35 2015(r286161)
+++ head/sys/dev/e1000/if_igb.c Sat Aug  1 20:40:37 2015(r286162)
@@ -1908,9 +1908,6 @@ retry:
goto retry;
} else
return (error);
-   case ENOMEM:
-   txr-no_tx_dma_setup++;
-   return (error);
default:
txr-no_tx_dma_setup++;
m_freem(*m_headp);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286168 - head/sys/net

2015-08-01 Thread John-Mark Gurney
Author: jmg
Date: Sun Aug  2 00:15:52 2015
New Revision: 286168
URL: https://svnweb.freebsd.org/changeset/base/286168

Log:
  convert to C11's _Static_assert, and pull in sys/cdefs.h for
  compatibility w/ older non-C11 compilers...
  
  passed make tinerdbox..
  
  Suggested by: imp

Modified:
  head/sys/net/pfkeyv2.h

Modified: head/sys/net/pfkeyv2.h
==
--- head/sys/net/pfkeyv2.h  Sun Aug  2 00:11:56 2015(r286167)
+++ head/sys/net/pfkeyv2.h  Sun Aug  2 00:15:52 2015(r286168)
@@ -39,9 +39,7 @@
 #ifndef _NET_PFKEYV2_H_
 #define _NET_PFKEYV2_H_
 
-#ifndef _KERNEL
-#define CTASSERT(x)struct __thisisjustnothing;
-#endif
+#include sys/cdefs.h
 
 /*
 This file defines structures and symbols for the PF_KEY Version 2
@@ -231,7 +229,7 @@ struct sadb_x_policy {
   u_int32_t sadb_x_policy_id;
   u_int32_t sadb_x_policy_reserved2;
 };
-CTASSERT(sizeof(struct sadb_x_policy) == 16);
+_Static_assert(sizeof(struct sadb_x_policy) == 16, struct size mismatch);
 
 /*
  * When policy_type == IPSEC, it is followed by some of
@@ -267,7 +265,7 @@ struct sadb_x_nat_t_type {
   u_int8_t sadb_x_nat_t_type_type;
   u_int8_t sadb_x_nat_t_type_reserved[3];
 };
-CTASSERT(sizeof(struct sadb_x_nat_t_type) == 8);
+_Static_assert(sizeof(struct sadb_x_nat_t_type) == 8, struct size mismatch);
 
 /* NAT-Traversal source or destination port. */
 struct sadb_x_nat_t_port { 
@@ -276,7 +274,7 @@ struct sadb_x_nat_t_port { 
   u_int16_t sadb_x_nat_t_port_port;
   u_int16_t sadb_x_nat_t_port_reserved;
 };
-CTASSERT(sizeof(struct sadb_x_nat_t_port) == 8);
+_Static_assert(sizeof(struct sadb_x_nat_t_port) == 8, struct size mismatch);
 
 /* ESP fragmentation size. */
 struct sadb_x_nat_t_frag {
@@ -285,7 +283,7 @@ struct sadb_x_nat_t_frag {
   u_int16_t sadb_x_nat_t_frag_fraglen;
   u_int16_t sadb_x_nat_t_frag_reserved;
 };
-CTASSERT(sizeof(struct sadb_x_nat_t_frag) == 8);
+_Static_assert(sizeof(struct sadb_x_nat_t_frag) == 8, struct size mismatch);
 
 
 #define SADB_EXT_RESERVED 0
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286147 - head/sys/compat/cloudabi

2015-08-01 Thread Ed Schouten
Author: ed
Date: Sat Aug  1 07:51:48 2015
New Revision: 286147
URL: https://svnweb.freebsd.org/changeset/base/286147

Log:
  Allow CloudABI processes to create shared memory objects.
  
  Summary:
  Use the newly created `kern_shm_open()` function to create objects with
  just the rights that are actually needed.
  
  Reviewers: jhb, kib
  
  Subscribers: imp
  
  Differential Revision: https://reviews.freebsd.org/D3260

Modified:
  head/sys/compat/cloudabi/cloudabi_fd.c

Modified: head/sys/compat/cloudabi/cloudabi_fd.c
==
--- head/sys/compat/cloudabi/cloudabi_fd.c  Sat Aug  1 07:21:14 2015
(r286146)
+++ head/sys/compat/cloudabi/cloudabi_fd.c  Sat Aug  1 07:51:48 2015
(r286147)
@@ -30,6 +30,7 @@ __FBSDID($FreeBSD$);
 #include sys/capsicum.h
 #include sys/filedesc.h
 #include sys/proc.h
+#include sys/mman.h
 #include sys/socketvar.h
 #include sys/syscallsubr.h
 #include sys/sysproto.h
@@ -97,11 +98,16 @@ int
 cloudabi_sys_fd_create1(struct thread *td,
 struct cloudabi_sys_fd_create1_args *uap)
 {
+   struct filecaps fcaps = {};
struct socket_args socket_args = {
.domain = AF_UNIX,
};
 
switch (uap-type) {
+   case CLOUDABI_FILETYPE_SHARED_MEMORY:
+   cap_rights_init(fcaps.fc_rights, CAP_FSTAT, CAP_FTRUNCATE,
+   CAP_MMAP_RWX);
+   return (kern_shm_open(td, SHM_ANON, O_RDWR, 0, fcaps));
case CLOUDABI_FILETYPE_SOCKET_DGRAM:
socket_args.type = SOCK_DGRAM;
return (sys_socket(td, socket_args));
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286148 - head/usr.sbin/chkgrp

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sat Aug  1 08:35:20 2015
New Revision: 286148
URL: https://svnweb.freebsd.org/changeset/base/286148

Log:
  Use strtoumax instead of strtoul

Modified:
  head/usr.sbin/chkgrp/chkgrp.c

Modified: head/usr.sbin/chkgrp/chkgrp.c
==
--- head/usr.sbin/chkgrp/chkgrp.c   Sat Aug  1 07:51:48 2015
(r286147)
+++ head/usr.sbin/chkgrp/chkgrp.c   Sat Aug  1 08:35:20 2015
(r286148)
@@ -32,6 +32,7 @@ __FBSDID($FreeBSD$);
 #include err.h
 #include errno.h
 #include ctype.h
+#include inttypes.h
 #include limits.h
 #include stdint.h
 #include stdio.h
@@ -169,9 +170,9 @@ main(int argc, char *argv[])
 
/* check the range of the group id */
errno = 0;
-   gid = strtoul(f[2], NULL, 10);
+   gid = strtoumax(f[2], NULL, 10);
if (errno != 0) {
-   warnx(%s: line %d: strtoul failed, gfn, n);
+   warnx(%s: line %d: strtoumax failed, gfn, n);
} else if (gid  GID_MAX) {
warnx(%s: line %d: group id is too large (%ju  %ju),
gfn, n, (uintmax_t)gid, (uintmax_t)GID_MAX);
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286149 - head/usr.sbin/chkgrp

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sat Aug  1 08:39:55 2015
New Revision: 286149
URL: https://svnweb.freebsd.org/changeset/base/286149

Log:
  Handle +:*:: the same way we handle +::: when checking group file
  
  The first is what the documentation recommands for NIS client

Modified:
  head/usr.sbin/chkgrp/chkgrp.c

Modified: head/usr.sbin/chkgrp/chkgrp.c
==
--- head/usr.sbin/chkgrp/chkgrp.c   Sat Aug  1 08:35:20 2015
(r286148)
+++ head/usr.sbin/chkgrp/chkgrp.c   Sat Aug  1 08:39:55 2015
(r286149)
@@ -106,7 +106,8 @@ main(int argc, char *argv[])
/*
 * Hack: special case for + line
 */
-   if (strncmp(line, +:::, len) == 0)
+   if (strncmp(line, +:::, len) == 0 ||
+   strncmp(line, +:*::, len) == 0)
continue;
 
/*
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


Re: svn commit: r286142 - head/sys/net

2015-08-01 Thread Ed Schouten
Hi Luiz,

2015-07-31 23:43 GMT+02:00 Luiz Otavio O Souza l...@freebsd.org:
 -   while (d-bd_hbuf_in_use)
 -   mtx_sleep(d-bd_hbuf_in_use, d-bd_lock,
 -   PRINET, bd_hbuf, 0);

Would it make sense to replace them by an assertion, instead of
omitting them entirely?

KASSERT(!d-bd_hbuf_in_use, (...));

Thanks,
-- 
Ed Schouten e...@nuxi.nl
Nuxi, 's-Hertogenbosch, the Netherlands
KvK/VAT number: 62051717
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286150 - head/usr.sbin/pw

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sat Aug  1 09:55:47 2015
New Revision: 286150
URL: https://svnweb.freebsd.org/changeset/base/286150

Log:
  Cast uid/git to uintmax_t when using printf-like functions so the size of
  uid/gid size remains a implementation detail

Modified:
  head/usr.sbin/pw/pw_conf.c
  head/usr.sbin/pw/pw_group.c
  head/usr.sbin/pw/pw_user.c

Modified: head/usr.sbin/pw/pw_conf.c
==
--- head/usr.sbin/pw/pw_conf.c  Sat Aug  1 08:39:55 2015(r286149)
+++ head/usr.sbin/pw/pw_conf.c  Sat Aug  1 09:55:47 2015(r286150)
@@ -31,6 +31,7 @@ static const char rcsid[] =
 
 #include sys/types.h
 #include sys/sbuf.h
+#include inttypes.h
 #include string.h
 #include ctype.h
 #include fcntl.h
@@ -446,19 +447,19 @@ write_userconfig(char const * file)
config.default_class : );
break;
case _UC_MINUID:
-   sbuf_printf(buf, %u, config.min_uid);
+   sbuf_printf(buf, %ju, (uintmax_t)config.min_uid);
quote = 0;
break;
case _UC_MAXUID:
-   sbuf_printf(buf, %u, config.max_uid);
+   sbuf_printf(buf, %ju, (uintmax_t)config.max_uid);
quote = 0;
break;
case _UC_MINGID:
-   sbuf_printf(buf, %u, config.min_gid);
+   sbuf_printf(buf, %ju, (uintmax_t)config.min_gid);
quote = 0;
break;
case _UC_MAXGID:
-   sbuf_printf(buf, %u, config.max_gid);
+   sbuf_printf(buf, %ju, (uintmax_t)config.max_gid);
quote = 0;
break;
case _UC_EXPIRE:

Modified: head/usr.sbin/pw/pw_group.c
==
--- head/usr.sbin/pw/pw_group.c Sat Aug  1 08:39:55 2015(r286149)
+++ head/usr.sbin/pw/pw_group.c Sat Aug  1 09:55:47 2015(r286150)
@@ -31,6 +31,7 @@ static const char rcsid[] =
 
 #include ctype.h
 #include err.h
+#include inttypes.h
 #include termios.h
 #include stdbool.h
 #include unistd.h
@@ -97,7 +98,7 @@ pw_groupnext(struct userconf *cnf, bool 
 
if (quiet)
return (next);
-   printf(%u\n, next);
+   printf(%ju\n, (uintmax_t)next);
 
return (EXIT_SUCCESS);
 }
@@ -283,7 +284,7 @@ pw_group(int mode, char *name, long id, 
if ((grp = GETGRNAM(name)) == NULL)
errx(EX_SOFTWARE, group disappeared during update);
 
-   pw_log(cnf, mode, W_GROUP, %s(%u), grp-gr_name, grp-gr_gid);
+   pw_log(cnf, mode, W_GROUP, %s(%ju), grp-gr_name, 
(uintmax_t)grp-gr_gid);
 
return EXIT_SUCCESS;
 }
@@ -345,7 +346,7 @@ gr_gidpolicy(struct userconf * cnf, long
gid = (gid_t) id;
 
if ((grp = GETGRGID(gid)) != NULL  conf.checkduplicate)
-   errx(EX_DATAERR, gid `%u' has already been allocated, 
grp-gr_gid);
+   errx(EX_DATAERR, gid `%ju' has already been 
allocated, (uintmax_t)grp-gr_gid);
} else {
struct bitmap   bm;
 

Modified: head/usr.sbin/pw/pw_user.c
==
--- head/usr.sbin/pw/pw_user.c  Sat Aug  1 08:39:55 2015(r286149)
+++ head/usr.sbin/pw/pw_user.c  Sat Aug  1 09:55:47 2015(r286150)
@@ -33,6 +33,7 @@ static const char rcsid[] =
 #include ctype.h
 #include err.h
 #include fcntl.h
+#include inttypes.h
 #include sys/param.h
 #include dirent.h
 #include paths.h
@@ -81,8 +82,8 @@ create_and_populate_homedir(struct passw
 
copymkdir(conf.rootfd, pwd-pw_dir, skelfd, cnf-homemode, pwd-pw_uid,
pwd-pw_gid, 0);
-   pw_log(cnf, M_ADD, W_USER, %s(%u) home %s made, pwd-pw_name,
-   pwd-pw_uid, pwd-pw_dir);
+   pw_log(cnf, M_ADD, W_USER, %s(%ju) home %s made, pwd-pw_name,
+   (uintmax_t)pwd-pw_uid, pwd-pw_dir);
 }
 
 static int
@@ -155,7 +156,7 @@ pw_usernext(struct userconf *cnf, bool q
if (quiet)
return (next);
 
-   printf(%u:, next);
+   printf(%ju:, (uintmax_t)next);
pw_groupnext(cnf, quiet);
 
return (EXIT_SUCCESS);
@@ -749,9 +750,9 @@ pw_user(int mode, char *name, long id, s
errx(EX_NOUSER, user '%s' disappeared during update, name);
 
grp = GETGRGID(pwd-pw_gid);
-   pw_log(cnf, mode, W_USER, %s(%u):%s(%u):%s:%s:%s,
-  pwd-pw_name, pwd-pw_uid,
-   grp ? grp-gr_name : unknown, (grp ? grp-gr_gid : (uid_t)-1),
+   pw_log(cnf, mode, W_USER, %s(%ju):%s(%ju):%s:%s:%s,
+  pwd-pw_name, (uintmax_t)pwd-pw_uid,
+   grp ? grp-gr_name : unknown, (uintmax_t)(grp ? grp-gr_gid : 
(uid_t)-1),
   pwd-pw_gecos, pwd-pw_dir, 

svn commit: r286151 - head/usr.sbin/pw

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sat Aug  1 10:10:13 2015
New Revision: 286151
URL: https://svnweb.freebsd.org/changeset/base/286151

Log:
  Validate the max_uid/max_gid boundaries and entry type in pw.conf

Modified:
  head/usr.sbin/pw/pw_conf.c

Modified: head/usr.sbin/pw/pw_conf.c
==
--- head/usr.sbin/pw/pw_conf.c  Sat Aug  1 09:55:47 2015(r286150)
+++ head/usr.sbin/pw/pw_conf.c  Sat Aug  1 10:10:13 2015(r286151)
@@ -230,6 +230,7 @@ read_userconfig(char const * file)
char*buf, *p;
size_t  linecap;
ssize_t linelen;
+   const char *errstr;
 
buf = NULL;
linecap = 0;
@@ -323,20 +324,35 @@ read_userconfig(char const * file)
? NULL : newstr(q);
break;
case _UC_MINUID:
-   if ((q = unquote(q)) != NULL  isdigit(*q))
-   config.min_uid = (uid_t) atol(q);
+   if ((q = unquote(q)) != NULL) {
+   errstr = NULL;
+   config.min_uid = strtounum(q, 0, 
UID_MAX, errstr);
+   if (errstr)
+   warnx(Invalid min_uid: '%s', 
ignoring, q);
+   }
break;
case _UC_MAXUID:
-   if ((q = unquote(q)) != NULL  isdigit(*q))
-   config.max_uid = (uid_t) atol(q);
+   if ((q = unquote(q)) != NULL) {
+   errstr = NULL;
+   config.max_uid = strtounum(q, 0, 
UID_MAX, errstr);
+   if (errstr)
+   warnx(Invalid max_uid: '%s', 
ignoring, q);
+   }
break;
case _UC_MINGID:
if ((q = unquote(q)) != NULL  isdigit(*q))
-   config.min_gid = (gid_t) atol(q);
+   errstr = NULL;
+   config.min_gid = strtounum(q, 0, 
GID_MAX, errstr);
+   if (errstr)
+   warnx(Invalid min_gid: '%s', 
ignoring, q);
break;
case _UC_MAXGID:
-   if ((q = unquote(q)) != NULL  isdigit(*q))
-   config.max_gid = (gid_t) atol(q);
+   if ((q = unquote(q)) != NULL) {
+   errstr = NULL;
+   config.max_gid = strtounum(q, 0, 
GID_MAX, errstr);
+   if (errstr)
+   warnx(Invalid max_gid: '%s', 
ignoring, q);
+   }
break;
case _UC_EXPIRE:
if ((q = unquote(q)) != NULL  isdigit(*q))
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to svn-src-head-unsubscr...@freebsd.org


svn commit: r286152 - head/usr.sbin/pw

2015-08-01 Thread Baptiste Daroussin
Author: bapt
Date: Sat Aug  1 10:25:55 2015
New Revision: 286152
URL: https://svnweb.freebsd.org/changeset/base/286152

Log:
  Validate expiration days and password days from commmand line and pw.conf

Modified:
  head/usr.sbin/pw/pw.c
  head/usr.sbin/pw/pw_conf.c
  head/usr.sbin/pw/pw_user.c
  head/usr.sbin/pw/pwupd.h

Modified: head/usr.sbin/pw/pw.c
==
--- head/usr.sbin/pw/pw.c   Sat Aug  1 10:10:13 2015(r286151)
+++ head/usr.sbin/pw/pw.c   Sat Aug  1 10:25:55 2015(r286152)
@@ -262,6 +262,11 @@ main(int argc, char *argv[])
case 'c':
conf.gecos = pw_checkname(optarg, 1);
break;
+   case 'e':
+   conf.expire_days = strtonum(optarg, 0, INT_MAX, 
errstr);
+   if (errstr)
+   errx(EX_USAGE, Invalid expired days: %s, 
optarg);
+   break;
case 'g':
if (which == 0) { /* for user* */
addarg(arglist, 'g', optarg);
@@ -321,6 +326,11 @@ main(int argc, char *argv[])
case 'o':
conf.checkduplicate = false;
break;
+   case 'p':
+   conf.password_days = strtonum(optarg, 0, INT_MAX, 
errstr);
+   if (errstr)
+   errx(EX_USAGE, Invalid password days: %s, 
optarg);
+   break;
case 'q':
conf.quiet = true;
break;

Modified: head/usr.sbin/pw/pw_conf.c
==
--- head/usr.sbin/pw/pw_conf.c  Sat Aug  1 10:10:13 2015(r286151)
+++ head/usr.sbin/pw/pw_conf.c  Sat Aug  1 10:25:55 2015(r286152)
@@ -355,12 +355,20 @@ read_userconfig(char const * file)
}
break;
case _UC_EXPIRE:
-   if ((q = unquote(q)) != NULL  isdigit(*q))
-   config.expire_days = atoi(q);
+   if ((q = unquote(q)) != NULL) {
+   errstr = NULL;
+   config.expire_days = strtonum(q, 0, 
INT_MAX, errstr);
+   if (errstr)
+   warnx(Invalid expire days: 
'%s', ignoring, q);
+   }
break;
case _UC_PASSWORD:
-   if ((q = unquote(q)) != NULL  isdigit(*q))
-   config.password_days = atoi(q);
+   if ((q = unquote(q)) != NULL) {
+   errstr = NULL;
+   config.password_days = strtonum(q, 0, 
INT_MAX, errstr);
+   if (errstr)
+   warnx(Invalid password days: 
'%s', ignoring, q);
+   }
break;
case _UC_FIELDS:
case _UC_NONE:

Modified: head/usr.sbin/pw/pw_user.c
==
--- head/usr.sbin/pw/pw_user.c  Sat Aug  1 10:10:13 2015(r286151)
+++ head/usr.sbin/pw/pw_user.c  Sat Aug  1 10:25:55 2015(r286152)
@@ -418,14 +418,14 @@ pw_user(int mode, char *name, long id, s
errx(EX_OSFILE, root home `%s' is not a directory, 
cnf-home);
}
 
-   if ((arg = getarg(args, 'e')) != NULL)
-   cnf-expire_days = atoi(arg-val);
+   if (conf.expire_days  0)
+   cnf-expire_days = conf.expire_days;
 
if ((arg = getarg(args, 'y')) != NULL)
cnf-nispasswd = arg-val;
 
-   if ((arg = getarg(args, 'p')) != NULL  arg-val)
-   cnf-password_days = atoi(arg-val);
+   if (conf.password_days  0)
+   cnf-password_days = conf.password_days;
 
if ((arg = getarg(args, 'g')) != NULL) {
if (!*(p = arg-val))   /* Handle empty group list specially */

Modified: head/usr.sbin/pw/pwupd.h
==
--- head/usr.sbin/pw/pwupd.hSat Aug  1 10:10:13 2015(r286151)
+++ head/usr.sbin/pw/pwupd.hSat Aug  1 10:25:55 2015(r286152)
@@ -86,6 +86,8 @@ struct pwconf {
char*newname;
char*config;
char*gecos;
+   int  expire_days;
+   int  password_days;
int  fd;
int  rootfd;
int  which;

Re: svn commit: r286148 - head/usr.sbin/chkgrp

2015-08-01 Thread Bruce Evans

On Sat, 1 Aug 2015, Baptiste Daroussin wrote:


Log:
 Use strtoumax instead of strtoul


This does nothing good, and breaks 32-bit arches.


Modified: head/usr.sbin/chkgrp/chkgrp.c
==
--- head/usr.sbin/chkgrp/chkgrp.c   Sat Aug  1 07:51:48 2015
(r286147)
+++ head/usr.sbin/chkgrp/chkgrp.c   Sat Aug  1 08:35:20 2015
(r286148)
@@ -169,9 +170,9 @@ main(int argc, char *argv[])

/* check the range of the group id */
errno = 0;
-   gid = strtoul(f[2], NULL, 10);
+   gid = strtoumax(f[2], NULL, 10);


gid still has type u_long (spelled verbosely as unsigned long.)  This
used to work on arches where gid_t is no larger than u_long, which is
the case on all supported arches.  Now the value returned by strtoumax()
is corrupted by blindly assigning it to u_long.  E.g., 0x10001
becomes 1.


if (errno != 0) {
-   warnx(%s: line %d: strtoul failed, gfn, n);
+   warnx(%s: line %d: strtoumax failed, gfn, n);


This has a less usual subset of common bugs in using the strtoul() family.
The most common bug is to not check ERANGE.  This does check ERANGE, but
doesn't check for garbage following the integer (it doesn't even pass
endptr).  It uses a POSIX extension to check that the integer has some
digits.


} else if (gid  GID_MAX) {


This used to work.  Now it checks the corrupted value.


warnx(%s: line %d: group id is too large (%ju  %ju),
gfn, n, (uintmax_t)gid, (uintmax_t)GID_MAX);


This format is bogus for printing `gid'.  gid should have type gid_t, but
actually has type u_long.  u_long should be printed using %lu and no
cast.

GID_MAX is undocumented, so no one knows its type.  Its type should
be gid_t, but is actually u_int.  gid_t is logically different again
-- it is __uint32_t.  GID_MAX is defined in sys/limits.h, so there are
namespace problems in matching its type with that of gid_t.  The
current implementation is best until gid_t is expanded.

So casting GID_MAX to uintmax_t is good for safety and portability.
However, chckgrp.c already assumed that gid_t is no larger than u_long.
Otherwise it would have been broken in the reverse way to this commit
-- values would have been clamped by strtoul().  The bounds checking
would have worked, but large values would have been unsupported.  The
old value might as well have cast to u_long.  strtoumax() can support
any size for gid_t.  After fixing all the other type errors, the types
in the warnx() become correct.

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