svn commit: r285999 - head/sys/netpfil/pf

2015-07-28 Thread Kristof Provost
Author: kp
Date: Wed Jul 29 06:35:36 2015
New Revision: 285999
URL: https://svnweb.freebsd.org/changeset/base/285999

Log:
  pf: Always initialise pf_fragment.fr_flags
  
  When we allocate the struct pf_fragment in pf_fillup_fragment() we forgot to
  initialise the fr_flags field. As a result we sometimes mistakenly thought the
  fragment to not be a buffered fragment. This resulted in panics because we'd 
end
  up freeing the pf_fragment but not removing it from V_pf_fragqueue (believing 
it
  to be part of V_pf_cachequeue).
  The next time we iterated V_pf_fragqueue we'd use a freed object and panic.
  
  While here also fix a pf_fragment use after free in pf_normalize_ip().
  pf_reassemble() frees the pf_fragment, so we can't use it any more.
  
  PR:   201879, 201932
  MFC after:5 days

Modified:
  head/sys/netpfil/pf/pf_norm.c

Modified: head/sys/netpfil/pf/pf_norm.c
==
--- head/sys/netpfil/pf/pf_norm.c   Wed Jul 29 06:31:44 2015
(r285998)
+++ head/sys/netpfil/pf/pf_norm.c   Wed Jul 29 06:35:36 2015
(r285999)
@@ -431,6 +431,7 @@ pf_fillup_fragment(struct pf_fragment_cm
}
 
*(struct pf_fragment_cmp *)frag = *key;
+   frag->fr_flags = 0;
frag->fr_timeout = time_second;
frag->fr_maxlen = frent->fe_len;
TAILQ_INIT(&frag->fr_queue);
@@ -1284,9 +1285,6 @@ pf_normalize_ip(struct mbuf **m0, int di
if (m == NULL)
return (PF_DROP);
 
-   if (frag != NULL && (frag->fr_flags & PFFRAG_DROP))
-   goto drop;
-
h = mtod(m, struct ip *);
} else {
/* non-buffering fragment cache (drops or masks overlaps) */
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2015-07-28 Thread Ed Schouten
Author: ed
Date: Wed Jul 29 06:31:44 2015
New Revision: 285998
URL: https://svnweb.freebsd.org/changeset/base/285998

Log:
  Implement CloudABI's readdir().
  
  Summary:
  CloudABI's readdir() system call could be thought of as a mixture
  between FreeBSD's getdents(2) and pread(). Instead of using the file
  descriptor offset, userspace provides a 64-bit cloudabi_dircookie_t
  continue reading at a given point. CLOUDABI_DIRCOOKIE_START, having
  value 0, can be used to return entries at the start of the directory.
  
  The file descriptor offset is not used to store the cookie for the
  reason that in a file descriptor centric environment, it would make
  sense to allow concurrent use of a single file descriptor.
  
  The remaining space returned by the system call should be filled with a
  partially truncated copy of the next entry. The advantage of doing this
  is that it gracefully deals with long filenames. If the C library
  provides a buffer that is too small to hold a single entry, it can still
  extract the directory entry header, meaning that it can retry the read
  with a larger buffer or skip it using the cookie.
  
  Test Plan:
  This implementation passes the cloudlibc unit tests at:
  
https://github.com/NuxiNL/cloudlibc/tree/master/src/libc/dirent
  
  Reviewers: marcel, kib
  
  Reviewed By: kib
  
  Subscribers: imp
  
  Differential Revision: https://reviews.freebsd.org/D3226

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

Modified: head/sys/compat/cloudabi/cloudabi_file.c
==
--- head/sys/compat/cloudabi/cloudabi_file.cWed Jul 29 06:23:06 2015
(r285997)
+++ head/sys/compat/cloudabi/cloudabi_file.cWed Jul 29 06:31:44 2015
(r285998)
@@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -35,11 +36,15 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 #include 
 #include 
 
+#include 
+
 static MALLOC_DEFINE(M_CLOUDABI_PATH, "cloudabipath", "CloudABI pathnames");
 
 /*
@@ -197,13 +202,180 @@ cloudabi_sys_file_open(struct thread *td
return (ENOSYS);
 }
 
+/* Converts a FreeBSD directory entry structure and writes it to userspace. */
+static int
+write_dirent(struct dirent *bde, cloudabi_dircookie_t cookie, struct uio *uio)
+{
+   cloudabi_dirent_t cde = {
+   .d_next = cookie,
+   .d_ino = bde->d_fileno,
+   .d_namlen = bde->d_namlen,
+   };
+   size_t len;
+   int error;
+
+   /* Convert file type. */
+   switch (bde->d_type) {
+   case DT_BLK:
+   cde.d_type = CLOUDABI_FILETYPE_BLOCK_DEVICE;
+   break;
+   case DT_CHR:
+   cde.d_type = CLOUDABI_FILETYPE_CHARACTER_DEVICE;
+   break;
+   case DT_DIR:
+   cde.d_type = CLOUDABI_FILETYPE_DIRECTORY;
+   break;
+   case DT_FIFO:
+   cde.d_type = CLOUDABI_FILETYPE_FIFO;
+   break;
+   case DT_LNK:
+   cde.d_type = CLOUDABI_FILETYPE_SYMBOLIC_LINK;
+   break;
+   case DT_REG:
+   cde.d_type = CLOUDABI_FILETYPE_REGULAR_FILE;
+   break;
+   case DT_SOCK:
+   /* The exact socket type cannot be derived. */
+   cde.d_type = CLOUDABI_FILETYPE_SOCKET_STREAM;
+   break;
+   default:
+   cde.d_type = CLOUDABI_FILETYPE_UNKNOWN;
+   break;
+   }
+
+   /* Write directory entry structure. */
+   len = sizeof(cde) < uio->uio_resid ? sizeof(cde) : uio->uio_resid;
+   error = uiomove(&cde, len, uio);
+   if (error != 0)
+   return (error);
+
+   /* Write filename. */
+   len = bde->d_namlen < uio->uio_resid ? bde->d_namlen : uio->uio_resid;
+   return (uiomove(bde->d_name, len, uio));
+}
+
 int
 cloudabi_sys_file_readdir(struct thread *td,
 struct cloudabi_sys_file_readdir_args *uap)
 {
+   struct iovec iov = {
+   .iov_base = uap->buf,
+   .iov_len = uap->nbyte
+   };
+   struct uio uio = {
+   .uio_iov = &iov,
+   .uio_iovcnt = 1,
+   .uio_resid = iov.iov_len,
+   .uio_segflg = UIO_USERSPACE,
+   .uio_rw = UIO_READ,
+   .uio_td = td
+   };
+   struct file *fp;
+   struct vnode *vp;
+   void *readbuf;
+   cap_rights_t rights;
+   cloudabi_dircookie_t offset;
+   int error;
 
-   /* Not implemented. */
-   return (ENOSYS);
+   /* Obtain directory vnode. */
+   error = getvnode(td, uap->fd, cap_rights_init(&rights, CAP_READ), &fp);
+   if (error != 0) {
+   if (error == EINVAL)
+   return (ENOTDIR);
+   return (error);
+   }
+   if ((fp->f_flag & FREAD) == 0) {
+   fdrop(fp, td);
+   

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

2015-07-28 Thread Baptiste Daroussin
Author: bapt
Date: Wed Jul 29 06:23:06 2015
New Revision: 285997
URL: https://svnweb.freebsd.org/changeset/base/285997

Log:
  Actually add the new code

Added:
  head/usr.sbin/pw/strtounum.c   (contents, props changed)

Added: head/usr.sbin/pw/strtounum.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/pw/strtounum.cWed Jul 29 06:23:06 2015
(r285997)
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (C) Baptiste Daroussin 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY DAVID L. NUGENT AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL DAVID L. NUGENT OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+
+#include "pw.h"
+
+#define INVALID"invalid"
+#define TOOSMALL   "too small"
+#defineTOOLARGE"too large"
+
+uintmax_t
+strtounum(const char *numstr, uintmax_t minval, uintmax_t maxval,
+const char **errstrp)
+{
+   uintmax_t ret = 0;
+   char *ep;
+
+   if (minval > maxval) {
+   errno = EINVAL;
+   if (errstrp != NULL)
+   *errstrp = INVALID;
+   return (0);
+   }
+
+   ret = strtoumax(numstr, &ep, 10);
+   if (errno == EINVAL || numstr == ep || *ep != '\0') {
+   errno = EINVAL;
+   if (errstrp != NULL)
+   *errstrp = INVALID;
+   return (0);
+   } else if ((ret == 0 && errno == ERANGE) || ret < minval) {
+   errno = ERANGE;
+   if (errstrp != NULL)
+   *errstrp = TOOSMALL;
+   return (0);
+   } else if ((ret == UINTMAX_MAX && errno == ERANGE) || ret > maxval) {
+   errno = ERANGE;
+   if (errstrp != NULL)
+   *errstrp = TOOLARGE;
+   return (0);
+   }
+
+   return (ret);
+}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2015-07-28 Thread Baptiste Daroussin
Author: bapt
Date: Wed Jul 29 06:22:41 2015
New Revision: 285996
URL: https://svnweb.freebsd.org/changeset/base/285996

Log:
  Create a strtounum function using the same API as strtonum
  
  This function returns uintmax_t
  Use this function to convert to gid_t/uid_t

Modified:
  head/usr.sbin/pw/Makefile
  head/usr.sbin/pw/pw.c
  head/usr.sbin/pw/pw.h

Modified: head/usr.sbin/pw/Makefile
==
--- head/usr.sbin/pw/Makefile   Wed Jul 29 03:06:08 2015(r285995)
+++ head/usr.sbin/pw/Makefile   Wed Jul 29 06:22:41 2015(r285996)
@@ -3,7 +3,7 @@
 PROG=  pw
 MAN=   pw.conf.5 pw.8
 SRCS=  pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \
-   grupd.c pwupd.c psdate.c bitmap.c cpdir.c rm_r.c
+   grupd.c pwupd.c psdate.c bitmap.c cpdir.c rm_r.c strtounum.c
 
 WARNS?=3
 

Modified: head/usr.sbin/pw/pw.c
==
--- head/usr.sbin/pw/pw.c   Wed Jul 29 03:06:08 2015(r285995)
+++ head/usr.sbin/pw/pw.c   Wed Jul 29 06:22:41 2015(r285996)
@@ -199,7 +199,7 @@ main(int argc, char *argv[])
cmdhelp(mode, which);
else if (which != -1 && mode != -1) {
if (strspn(argv[1], "0123456789") == strlen(argv[1])) {
-   id = strtonum(argv[1], 0, LONG_MAX, &errstr);
+   id = strtounum(argv[1], 0, UID_MAX, &errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s",
argv[1], errstr);
@@ -269,7 +269,7 @@ main(int argc, char *argv[])
}
if (strspn(optarg, "0123456789") != strlen(optarg))
errx(EX_USAGE, "-g expects a number");
-   id = strtonum(optarg, 0, GID_MAX, &errstr);
+   id = strtounum(optarg, 0, GID_MAX, &errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s", optarg,
errstr);
@@ -281,7 +281,7 @@ main(int argc, char *argv[])
addarg(&arglist, 'u', optarg);
break;
}
-   id = strtonum(optarg, 0, UID_MAX, &errstr);
+   id = strtounum(optarg, 0, UID_MAX, &errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s", optarg,
errstr);

Modified: head/usr.sbin/pw/pw.h
==
--- head/usr.sbin/pw/pw.h   Wed Jul 29 03:06:08 2015(r285995)
+++ head/usr.sbin/pw/pw.h   Wed Jul 29 06:22:41 2015(r285996)
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -101,3 +102,6 @@ char *pw_pwcrypt(char *password);
 
 extern const char *Modes[];
 extern const char *Which[];
+
+uintmax_t strtounum(const char *numstr, uintmax_t minval, uintmax_t maxval,
+const char **errmsg);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r285993 - in head/sys: kern sys ufs/ffs vm

2015-07-28 Thread Conrad Meyer
On Tue, Jul 28, 2015 at 7:26 PM, Jeff Roberson  wrote:
> Author: jeff
> Date: Wed Jul 29 02:26:57 2015
> New Revision: 285993
> URL: https://svnweb.freebsd.org/changeset/base/285993
>
> Log:
>- Make 'struct buf *buf' private to vfs_bio.c.  Having a global variable
>  'buf' is inconvenient and has lead me to some irritating to discover
>  bugs over the years.  It also makes it more challenging to refactor
>  the buf allocation system.
>- Move swbuf and declare it as an extern in vfs_bio.c.  This is still
>  not perfect but better than it was before.
>- Eliminate the unused ffs function that relied on knowledge of the buf
>  array.
>- Move the shutdown code that iterates over the buf array into vfs_bio.c.
>
>   Reviewed by:  kib
>   Sponsored by: EMC / Isilon Storage Division
>
> Modified:
>   head/sys/kern/kern_shutdown.c
>   head/sys/kern/subr_param.c
>   head/sys/kern/vfs_bio.c
>   head/sys/sys/buf.h
>   head/sys/ufs/ffs/ffs_subr.c
>   head/sys/vm/vm_pager.c
>
> ...
>
> Modified: head/sys/kern/vfs_bio.c
> ==
> --- head/sys/kern/vfs_bio.c Wed Jul 29 02:21:35 2015(r285992)
> +++ head/sys/kern/vfs_bio.c Wed Jul 29 02:26:57 2015(r285993)
> ...

This section is #ifdef INVARIANTS, breaking build on non-INVARIANTS
kernels (missing bufshutdown):

> @@ -958,6 +958,134 @@ vfs_buf_check_mapped(struct buf *bp)
> KASSERT(bp->b_data < unmapped_buf || bp->b_data > unmapped_buf +
> MAXPHYS, ("b_data + b_offset unmapped %p", bp));
>  }
> +static int
> +isbufbusy(struct buf *bp)
> +{
> +   if (((bp->b_flags & (B_INVAL | B_PERSISTENT)) == 0 &&
> +   BUF_ISLOCKED(bp)) ||
> +   ((bp->b_flags & (B_DELWRI | B_INVAL)) == B_DELWRI))
> +   return (1);
> +   return (0);
> +}
> +
> +/*
> + * Shutdown the system cleanly to prepare for reboot, halt, or power off.
> + */
> +void
> +bufshutdown(int show_busybufs)
> +{
> +   static int first_buf_printf = 1;
> +   struct buf *bp;
> +   int iter, nbusy, pbusy;
> +#ifndef PREEMPTION
> +   int subiter;
> +#endif
> +
> +   /*
> +* Sync filesystems for shutdown
> +*/
> +   wdog_kern_pat(WD_LASTVAL);
> +   sys_sync(curthread, NULL);
> +
> +   /*
> +* With soft updates, some buffers that are
> +* written will be remarked as dirty until other
> +* buffers are written.
> +*/
> +   for (iter = pbusy = 0; iter < 20; iter++) {
> +   nbusy = 0;
> +   for (bp = &buf[nbuf]; --bp >= buf; )
> +   if (isbufbusy(bp))
> +   nbusy++;
> +   if (nbusy == 0) {
> +   if (first_buf_printf)
> +   printf("All buffers synced.");
> +   break;
> +   }
> +   if (first_buf_printf) {
> +   printf("Syncing disks, buffers remaining... ");
> +   first_buf_printf = 0;
> +   }
> +   printf("%d ", nbusy);
> +   if (nbusy < pbusy)
> +   iter = 0;
> +   pbusy = nbusy;
> +
> +   wdog_kern_pat(WD_LASTVAL);
> +   sys_sync(curthread, NULL);
> +
> +#ifdef PREEMPTION
> +   /*
> +* Drop Giant and spin for a while to allow
> +* interrupt threads to run.
> +*/
> +   DROP_GIANT();
> +   DELAY(5 * iter);
> +   PICKUP_GIANT();
> +#else
> +   /*
> +* Drop Giant and context switch several times to
> +* allow interrupt threads to run.
> +*/
> +   DROP_GIANT();
> +   for (subiter = 0; subiter < 50 * iter; subiter++) {
> +   thread_lock(curthread);
> +   mi_switch(SW_VOL, NULL);
> +   thread_unlock(curthread);
> +   DELAY(1000);
> +   }
> +   PICKUP_GIANT();
> +#endif
> +   }
> +   printf("\n");
> +   /*
> +* Count only busy local buffers to prevent forcing
> +* a fsck if we're just a client of a wedged NFS server
> +*/
> +   nbusy = 0;
> +   for (bp = &buf[nbuf]; --bp >= buf; ) {
> +   if (isbufbusy(bp)) {
> +#if 0
> +/* XXX: This is bogus.  We should probably have a BO_REMOTE flag instead */
> +   if (bp->b_dev == NULL) {
> +   TAILQ_REMOVE(&mountlist,
> +   bp->b_vp->v_mount, mnt_list);
> +   continue;
> +   }
> +#endif
> +   nbusy++;
> +   if (show_busybufs > 0) {
> +   printf(
> +   "%d: buf:%p, vnode:%p, flags:%0x, blkno:%jd, lblk

svn commit: r285995 - head/sys/fs/ext2fs

2015-07-28 Thread Jeff Roberson
Author: jeff
Date: Wed Jul 29 03:06:08 2015
New Revision: 285995
URL: https://svnweb.freebsd.org/changeset/base/285995

Log:
   - Remove some dead code copied from ffs.

Modified:
  head/sys/fs/ext2fs/ext2_subr.c

Modified: head/sys/fs/ext2fs/ext2_subr.c
==
--- head/sys/fs/ext2fs/ext2_subr.c  Wed Jul 29 02:34:25 2015
(r285994)
+++ head/sys/fs/ext2fs/ext2_subr.c  Wed Jul 29 03:06:08 2015
(r285995)
@@ -54,10 +54,6 @@
 #include 
 #include 
 
-#ifdef KDB
-void   ext2_checkoverlap(struct buf *, struct inode *);
-#endif
-
 /*
  * Return buffer with the contents of block "offset" from the beginning of
  * directory "ip".  If "res" is non-zero, fill it in with a pointer to the
@@ -130,34 +126,6 @@ normal:
return (0);
 }
 
-#ifdef KDB
-void
-ext2_checkoverlap(struct buf *bp, struct inode *ip)
-{
-   struct buf *ebp, *ep;
-   e4fs_daddr_t start, last;
-   struct vnode *vp;
-
-   ebp = &buf[nbuf];
-   start = bp->b_blkno;
-   last = start + btodb(bp->b_bcount) - 1;
-   for (ep = buf; ep < ebp; ep++) {
-   if (ep == bp || (ep->b_flags & B_INVAL))
-   continue;
-   vp = ip->i_ump->um_devvp;
-   /* look for overlap */
-   if (ep->b_bcount == 0 || ep->b_blkno > last ||
-   ep->b_blkno + btodb(ep->b_bcount) <= start)
-   continue;
-   vprint("Disk overlap", vp);
-   printf("\tstart %jd, end %jd overlap start %jd, end %jd\n",
-   (intmax_t)start, (intmax_t)last, (intmax_t)ep->b_blkno,
-   (intmax_t)(ep->b_blkno + btodb(ep->b_bcount) - 1));
-   panic("ext2_checkoverlap: Disk buffer overlap");
-   }
-}
-#endif /* KDB */
-
 /*
  * Update the cluster map because of an allocation of free like ffs.
  *
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285994 - in head: sbin/sysctl share/man/man9

2015-07-28 Thread Warner Losh
Author: imp
Date: Wed Jul 29 02:34:25 2015
New Revision: 285994
URL: https://svnweb.freebsd.org/changeset/base/285994

Log:
  Teach sysctl about the new optional suffix after IK to specify
  precision. Update input as well. Add IK to the manual (it was missing
  completely).
  
  Differential Revision: https://reviews.freebsd.org/D3181

Modified:
  head/sbin/sysctl/sysctl.c
  head/share/man/man9/sysctl.9

Modified: head/sbin/sysctl/sysctl.c
==
--- head/sbin/sysctl/sysctl.c   Wed Jul 29 02:26:57 2015(r285993)
+++ head/sbin/sysctl/sysctl.c   Wed Jul 29 02:34:25 2015(r285994)
@@ -81,7 +81,7 @@ static intshow_var(int *, int);
 static int sysctl_all(int *oid, int len);
 static int name2oid(const char *, int *);
 
-static int strIKtoi(const char *, char **);
+static int strIKtoi(const char *, char **, const char *);
 
 static int ctl_sign[CTLTYPE+1] = {
[CTLTYPE_INT] = 1,
@@ -336,8 +336,8 @@ parse(const char *string, int lineno)
 
switch (kind & CTLTYPE) {
case CTLTYPE_INT:
-   if (strcmp(fmt, "IK") == 0)
-   intval = strIKtoi(newvalstr, &endptr);
+   if (strncmp(fmt, "IK", 2) == 0)
+   intval = strIKtoi(newvalstr, &endptr, 
fmt);
else
intval = (int)strtol(newvalstr, &endptr,
0);
@@ -666,12 +666,13 @@ S_bios_smap_xattr(size_t l2, void *p)
 #endif
 
 static int
-strIKtoi(const char *str, char **endptrp)
+strIKtoi(const char *str, char **endptrp, const char *fmt)
 {
int kelv;
float temp;
size_t len;
const char *p;
+   int prec, i;
 
assert(errno == 0);
 
@@ -679,16 +680,36 @@ strIKtoi(const char *str, char **endptrp
/* caller already checked this */
assert(len > 0);
 
+   /*
+* A format of "IK" is in deciKelvin. A format of "IK3" is in
+* milliKelvin. The single digit following IK is log10 of the
+* multiplying factor to convert Kelvin into the untis of this sysctl,
+* or the dividing factor to convert the sysctl value to Kelvin. Numbers
+* larger than 6 will run into precision issues with 32-bit integers.
+* Characters that aren't ASCII digits after the 'K' are ignored. No
+* localization is present because this is an interface from the kernel
+* to this program (eg not an end-user interface), so isdigit() isn't
+* used here.
+*/
+   if (fmt[2] != '\0' && fmt[2] >= '0' && fmt[2] <= '9')
+   prec = fmt[2] - '0';
+   else
+   prec = 1;
p = &str[len - 1];
-   if (*p == 'C' || *p == 'F') {
+   if (*p == 'C' || *p == 'F' || *p == 'K') {
temp = strtof(str, endptrp);
if (*endptrp != str && *endptrp == p && errno == 0) {
if (*p == 'F')
temp = (temp - 32) * 5 / 9;
*endptrp = NULL;
-   return (temp * 10 + 2732);
+   if (*p != 'K')
+   temp += 273.15;
+   for (i = 0; i < prec; i++)
+   temp *= 10.0;
+   return ((int)(temp + 0.5));
}
} else {
+   /* No unit specified -> treat it as a raw number */
kelv = (int)strtol(str, endptrp, 10);
if (*endptrp != str && *endptrp == p && errno == 0) {
*endptrp = NULL;
@@ -772,7 +793,9 @@ show_var(int *oid, int nlen)
size_t intlen;
size_t j, len;
u_int kind;
+   float base;
int (*func)(size_t, void *);
+   int prec;
 
/* Silence GCC. */
umv = mv = intlen = 0;
@@ -893,8 +916,19 @@ show_var(int *oid, int nlen)
else if (fmt[1] == 'K') {
if (mv < 0)
printf("%jd", mv);
-   else
-   printf("%.1fC", (mv - 2732.0) / 10);
+   else {
+   /*
+* See strIKtoi for details on fmt.
+*/
+   prec = 1;
+   if (fmt[2] != '\0')
+   prec = fmt[2] - '0';
+   base = 1.0;
+   for (int i = 0; i < prec; i++)
+   base *= 10.0;
+   printf("%.*fC", prec,
+  

svn commit: r285993 - in head/sys: kern sys ufs/ffs vm

2015-07-28 Thread Jeff Roberson
Author: jeff
Date: Wed Jul 29 02:26:57 2015
New Revision: 285993
URL: https://svnweb.freebsd.org/changeset/base/285993

Log:
   - Make 'struct buf *buf' private to vfs_bio.c.  Having a global variable
 'buf' is inconvenient and has lead me to some irritating to discover
 bugs over the years.  It also makes it more challenging to refactor
 the buf allocation system.
   - Move swbuf and declare it as an extern in vfs_bio.c.  This is still
 not perfect but better than it was before.
   - Eliminate the unused ffs function that relied on knowledge of the buf
 array.
   - Move the shutdown code that iterates over the buf array into vfs_bio.c.
  
  Reviewed by:  kib
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/kern/kern_shutdown.c
  head/sys/kern/subr_param.c
  head/sys/kern/vfs_bio.c
  head/sys/sys/buf.h
  head/sys/ufs/ffs/ffs_subr.c
  head/sys/vm/vm_pager.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Wed Jul 29 02:21:35 2015
(r285992)
+++ head/sys/kern/kern_shutdown.c   Wed Jul 29 02:26:57 2015
(r285993)
@@ -275,24 +275,13 @@ doadump(boolean_t textdump)
return (error);
 }
 
-static int
-isbufbusy(struct buf *bp)
-{
-   if (((bp->b_flags & (B_INVAL | B_PERSISTENT)) == 0 &&
-   BUF_ISLOCKED(bp)) ||
-   ((bp->b_flags & (B_DELWRI | B_INVAL)) == B_DELWRI))
-   return (1);
-   return (0);
-}
-
 /*
  * Shutdown the system cleanly to prepare for reboot, halt, or power off.
  */
 void
 kern_reboot(int howto)
 {
-   static int first_buf_printf = 1;
-   static int waittime = -1;
+   static int once = 0;
 
 #if defined(SMP)
/*
@@ -321,116 +310,9 @@ kern_reboot(int howto)
/* 
 * Now sync filesystems
 */
-   if (!cold && (howto & RB_NOSYNC) == 0 && waittime < 0) {
-   register struct buf *bp;
-   int iter, nbusy, pbusy;
-#ifndef PREEMPTION
-   int subiter;
-#endif
-
-   waittime = 0;
-
-   wdog_kern_pat(WD_LASTVAL);
-   sys_sync(curthread, NULL);
-
-   /*
-* With soft updates, some buffers that are
-* written will be remarked as dirty until other
-* buffers are written.
-*/
-   for (iter = pbusy = 0; iter < 20; iter++) {
-   nbusy = 0;
-   for (bp = &buf[nbuf]; --bp >= buf; )
-   if (isbufbusy(bp))
-   nbusy++;
-   if (nbusy == 0) {
-   if (first_buf_printf)
-   printf("All buffers synced.");
-   break;
-   }
-   if (first_buf_printf) {
-   printf("Syncing disks, buffers remaining... ");
-   first_buf_printf = 0;
-   }
-   printf("%d ", nbusy);
-   if (nbusy < pbusy)
-   iter = 0;
-   pbusy = nbusy;
-
-   wdog_kern_pat(WD_LASTVAL);
-   sys_sync(curthread, NULL);
-
-#ifdef PREEMPTION
-   /*
-* Drop Giant and spin for a while to allow
-* interrupt threads to run.
-*/
-   DROP_GIANT();
-   DELAY(5 * iter);
-   PICKUP_GIANT();
-#else
-   /*
-* Drop Giant and context switch several times to
-* allow interrupt threads to run.
-*/
-   DROP_GIANT();
-   for (subiter = 0; subiter < 50 * iter; subiter++) {
-   thread_lock(curthread);
-   mi_switch(SW_VOL, NULL);
-   thread_unlock(curthread);
-   DELAY(1000);
-   }
-   PICKUP_GIANT();
-#endif
-   }
-   printf("\n");
-   /*
-* Count only busy local buffers to prevent forcing 
-* a fsck if we're just a client of a wedged NFS server
-*/
-   nbusy = 0;
-   for (bp = &buf[nbuf]; --bp >= buf; ) {
-   if (isbufbusy(bp)) {
-#if 0
-/* XXX: This is bogus.  We should probably have a BO_REMOTE flag instead */
-   if (bp->b_dev == NULL) {
-   TAILQ_REMOVE(&mountlist,
-   bp->b_vp->v_mount, mnt_list);
-   continue;
-   

Re: svn commit: r285926 - in head: libexec/ypxfr usr.bin/ypcat usr.bin/ypmatch usr.bin/ypwhich usr.sbin/yp_mkdb usr.sbin/yppush usr.sbin/ypserv

2015-07-28 Thread Marcelo Araujo
Hello Ed,

Fixed, thank you very much.
https://svnweb.freebsd.org/base?view=revision&revision=285992

Best,

2015-07-28 15:05 GMT+08:00 Ed Schouten :

> Hi Marcelo,
>
> Thanks for working on this!
>
> 2015-07-28 4:32 GMT+02:00 Marcelo Araujo :
> > -struct ypalias {
> > +const struct ypalias {
> > char *alias, *name;
> > -} ypaliases[] = {
> > +} static ypaliases[] = {
> > { "passwd", "passwd.byname" },
> > { "master.passwd", "master.passwd.byname" },
> > { "shadow", "shadow.byname" },
>
> I seem to remember that certain compilers (Intel?) are pretty picky
> about the ordering of 'static' and 'const'.
>
> const static int i; // Compiler error.
>
> It's also inconsistent with the rest of our codebase, where we
> typically put 'static' in front of the type. Could you please change
> this to the following?
>
> static const struct ypalias {
>...
> } ypaliases[] = {
>...
> };
>
> Thanks!
>
> --
> Ed Schouten 
> Nuxi, 's-Hertogenbosch, the Netherlands
> KvK/VAT number: 62051717
> ___
> svn-src-h...@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"
>



-- 

-- 
Marcelo Araujo(__)ara...@freebsd.org
\\\'',)http://www.FreeBSD.org    \/  \ ^
Power To Server. .\. /_)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285992 - in head/usr.bin: ypcat ypmatch ypwhich

2015-07-28 Thread Marcelo Araujo
Author: araujo (ports committer)
Date: Wed Jul 29 02:21:35 2015
New Revision: 285992
URL: https://svnweb.freebsd.org/changeset/base/285992

Log:
  Compilers will complain the usage of obsolescent variable declarations.
  Also it will fix the build problem with sparc64.
  
  Submitted by: ed@

Modified:
  head/usr.bin/ypcat/ypcat.c
  head/usr.bin/ypmatch/ypmatch.c
  head/usr.bin/ypwhich/ypwhich.c

Modified: head/usr.bin/ypcat/ypcat.c
==
--- head/usr.bin/ypcat/ypcat.c  Wed Jul 29 00:57:54 2015(r285991)
+++ head/usr.bin/ypcat/ypcat.c  Wed Jul 29 02:21:35 2015(r285992)
@@ -47,9 +47,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-const struct ypalias {
+static const struct ypalias {
char *alias, *name;
-} static ypaliases[] = {
+} ypaliases[] = {
{ "passwd", "passwd.byname" },
{ "master.passwd", "master.passwd.byname" },
{ "shadow", "shadow.byname" },

Modified: head/usr.bin/ypmatch/ypmatch.c
==
--- head/usr.bin/ypmatch/ypmatch.c  Wed Jul 29 00:57:54 2015
(r285991)
+++ head/usr.bin/ypmatch/ypmatch.c  Wed Jul 29 02:21:35 2015
(r285992)
@@ -47,9 +47,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-const struct ypalias {
+static const struct ypalias {
char *alias, *name;
-} static ypaliases[] = {
+} ypaliases[] = {
{ "passwd", "passwd.byname" },
{ "master.passwd", "master.passwd.byname" },
{ "shadow", "shadow.byname" },

Modified: head/usr.bin/ypwhich/ypwhich.c
==
--- head/usr.bin/ypwhich/ypwhich.c  Wed Jul 29 00:57:54 2015
(r285991)
+++ head/usr.bin/ypwhich/ypwhich.c  Wed Jul 29 02:21:35 2015
(r285992)
@@ -59,9 +59,9 @@ __FBSDID("$FreeBSD$");
 
 extern bool_t xdr_domainname();
 
-const struct ypalias {
+static const struct ypalias {
char *alias, *name;
-} static ypaliases[] = {
+} ypaliases[] = {
{ "passwd", "passwd.byname" },
{ "master.passwd", "master.passwd.byname" },
{ "shadow", "shadow.byname" },
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2015-07-28 Thread Bruce Evans

On Wed, 29 Jul 2015, Baptiste Daroussin wrote:


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

On Tue, 28 Jul 2015, Baptiste Daroussin wrote:


Log:
 Check uid/gid used when creating a user/group are not larger than 
UID_MAX/GID_MAX

 PR:173977
 Reported by:   nv...@gmx.com


This is broken in a different way than before.


Modified: head/usr.sbin/pw/pw.c
==
--- head/usr.sbin/pw/pw.c   Tue Jul 28 20:52:10 2015(r285984)
+++ head/usr.sbin/pw/pw.c   Tue Jul 28 21:10:58 2015(r285985)
@@ -269,7 +269,7 @@ main(int argc, char *argv[])
}
if (strspn(optarg, "0123456789") != strlen(optarg))
errx(EX_USAGE, "-g expects a number");
-   id = strtonum(optarg, 0, LONG_MAX, &errstr);
+   id = strtonum(optarg, 0, GID_MAX, &errstr);


`id' still has type long.  The assignment overflows on 32-bit arches when
the value exceeds 0x7fff.  That is for half of all valid values.  pw
is broken in not supporting these values, but at least it detected them
as errors in the previous version.  Old versions implemented this bug
using atoi() with no error checking.


So writting a function like strtonum like function with that prototype
intmax_t strtonumber(const char *, intmax_t min, intmax_t max, const char **);
and an unsigned equivalent
uintmax_t strtonumber(const char *, uintmax_t min, uintmax_t max, const char 
**);


Not completely, since this would restore some of the complications of the
strto*() family (there is API explosion, and types to match).  These 2
functions don't even handle all the integer ranges (with assymmetric
signedness), or hex numbers, or floating point).

To match the types for gid_t's with these APIs, you could write:

gid_t id = strtounum(optarg, 0, GID_MAX, &errstr);

or

uintmax_t id = strtounum(optarg, 0, GID_MAX, &errstr);

but can't mix these id types with others that need different signedness..
or use plain int/long/u_long for anything.  This is not a problem for
uids and gids since they usually have the same underlying type.

POSIX (XSI) made a mess of this for waitid(idtype_t idtype, id_t id,
...).  id can be either a pid, a uid, a gid or a session id.  So id_t
is specified as an integer type that can "contain" all of these.
Representing all of these is generally impossible due to the sign
differences, and the conversions made to "contain" seem to be
unspecified.  FreeBSD actually uses int64_t for id_t and an enum
for idtype_t, so simple conversions preserve the value at the cost
of bloat.  This wouldn't work with 64-bit uid_t.

A similar mess can be made for strto*num() by specifying it to work
with a container type num_t and making this type opaque so that it
is hard to use :-), except there no strict container exists for int64_t
and uint64_t.

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


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

2015-07-28 Thread Bryan Drewery
On 6/19/15 7:56 AM, Simon J. Gerraty wrote:
> Author: sjg
> Date: Fri Jun 19 14:56:24 2015
> New Revision: 284598
> URL: https://svnweb.freebsd.org/changeset/base/284598
> 
> Log:
>   Move include of make.conf back to its old position.
>   
>   This means moving include of local.sys.mk and src.sys.mk too.
>   Introduce new includes to take the early slot, for the purpose
>   of being able to influence toolchains and the like.
>   
>   Differential Revision:  D2860
>   Reviewed by:imp
> 
> Added:
>   head/share/mk/local.sys.env.mk
>  - copied, changed from r284432, head/share/mk/local.sys.mk
>   head/share/mk/src.sys.env.mk
>  - copied, changed from r284432, head/share/mk/src.sys.mk
> Modified:
>   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.

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

local.autodep.mk local.dirdeps.mk local.gendirdeps.mk local.init.mk
local.meta.sys.mk local.sys.env.mk local.sys.mk


>   head/share/mk/src.sys.mk
>   head/share/mk/sys.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.

> +
>  # If we were found via .../share/mk we need to replace that
>  # with ${.PARSEDIR:tA} so that we can be found by
>  # sub-makes launched from objdir.
> @@ -24,5 +22,3 @@ _srcconf_included_: .NOTMAIN
>  MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
>  .export MAKESYSPATH
>  .endif
> -# tempting, but bsd.compiler.mk causes problems this early
> -#.include "src.opts.mk"
> 
> Modified: head/share/mk/src.sys.mk
> ==
> --- head/share/mk/src.sys.mk  Fri Jun 19 14:20:21 2015(r284597)
> +++ head/share/mk/src.sys.mk  Fri Jun 19 14:56:24 2015(r284598)
> @@ -5,24 +5,13 @@
>  # to preserve historical (and useful) behavior. Changes here need to
>  # be reflected there so SRCCONF isn't included multiple times.
>  
> -# make sure this is defined in a consistent manner
> -SRCTOP:= ${.PARSEDIR:tA:H:H}
> -
>  # Allow user to configure things that only effect src tree builds.
>  SRCCONF?=/etc/src.conf
>  .if (exists(${SRCCONF}) || ${SRCCONF} != "/etc/src.conf") && 
> !target(_srcconf_included_)
>  .sinclude "${SRCCONF}"
>  _srcconf_included_:  .NOTMAIN
>  .endif
> -# If we were found via .../share/mk we need to replace that
> -# with ${.PARSEDIR:tA} so that we can be found by
> -# sub-makes launched from objdir.
> -.if ${.MAKEFLAGS:M.../share/mk} != ""
> -.MAKEFLAGS:= ${.MAKEFLAGS:S,.../share/mk,${.PARSEDIR:tA},}
> -.endif
> -.if ${MAKESYSPATH:Uno:M*.../*} != ""
> -MAKESYSPATH:= ${MAKESYSPATH:S,.../share/mk,${.PARSEDIR:tA},}
> -.export MAKESYSPATH
> -.endif
> +
>  # tempting, but bsd.compiler.mk causes problems this early
> +# probably need to remove dependence on bsd.own.mk 
>  #.include "src.opts.mk"
> 
> Modified: head/share/mk/sys.mk
> ==
> --- head/share/mk/sys.mk  Fri Jun 19 14:20:21 2015(r284597)
> +++ head/share/mk/sys.mk  Fri Jun 19 14:56:24 2015(r284598)
> @@ -31,15 +31,9 @@ __DEFAULT_DEPENDENT_OPTIONS= \
>  
>  .include 
>  
> -# Pull in global settings.
> -__MAKE_CONF?=/etc/make.conf
> -.if exists(${__MAKE_CONF})
> -.include "${__MAKE_CONF}"
> -.endif
> -
> -# Set any local definitions first. Place this early, but it needs
> -# MACHINE_CPUARCH to be defined.
> -.-include 
> +# early include for customization
> +# see local.sys.mk below
> +.-include 
>  
>  .if ${MK_META_MODE} == "yes"
>  .-include 
> @@ -360,6 +354,14 @@ YFLAGS   ?=  -d
>   rm -f ${.PREFIX}.tmp.c
>   ${CTFCONVERT_CMD}
>  
> +# Pull in global settings.
> +__MAKE_CONF?=/etc/make.conf
> +.if exists(${__MAKE_CONF})
> +.include "${__MAKE_CONF}"
> +.endif
> +
> +# late include for customization
> +.-include 

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.

>  
>  .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL)
>  SHELL=   ${__MAKE_SHELL}
> 


-- 
Regards,
Bryan Drewery
___
svn-src-all@freebsd.org m

svn commit: r285991 - in releng/10.2/sys/dev: pccbb pci

2015-07-28 Thread Glen Barber
Author: gjb
Date: Wed Jul 29 00:57:54 2015
New Revision: 285991
URL: https://svnweb.freebsd.org/changeset/base/285991

Log:
  MFS r285863 (jhb):
   Partially revert r284034.  In particular, revert the final change in
   this MFC (281874).  It broke suspend and resume on several Thinkpads
   (though not all) in 10 even though it works fine on the same laptops
   in HEAD.
  
  PR:   201239
  Reported by:  Kevin Oberman and several others
  Approved by:  re (kib)
  Sponsored by: The FreeBSD Foundation

Modified:
  releng/10.2/sys/dev/pccbb/pccbb_pci.c
  releng/10.2/sys/dev/pci/pci.c
  releng/10.2/sys/dev/pci/pci_pci.c
  releng/10.2/sys/dev/pci/pcib_private.h
  releng/10.2/sys/dev/pci/pcivar.h
Directory Properties:
  releng/10.2/   (props changed)

Modified: releng/10.2/sys/dev/pccbb/pccbb_pci.c
==
--- releng/10.2/sys/dev/pccbb/pccbb_pci.c   Tue Jul 28 22:48:58 2015
(r285990)
+++ releng/10.2/sys/dev/pccbb/pccbb_pci.c   Wed Jul 29 00:57:54 2015
(r285991)
@@ -259,6 +259,32 @@ cbb_pci_probe(device_t brdev)
 }
 
 /*
+ * Still need this because the pci code only does power for type 0
+ * header devices.
+ */
+static void
+cbb_powerstate_d0(device_t dev)
+{
+   u_int32_t membase, irq;
+
+   if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
+   /* Save important PCI config data. */
+   membase = pci_read_config(dev, CBBR_SOCKBASE, 4);
+   irq = pci_read_config(dev, PCIR_INTLINE, 4);
+
+   /* Reset the power state. */
+   device_printf(dev, "chip is in D%d power mode "
+   "-- setting to D0\n", pci_get_powerstate(dev));
+
+   pci_set_powerstate(dev, PCI_POWERSTATE_D0);
+
+   /* Restore PCI config data. */
+   pci_write_config(dev, CBBR_SOCKBASE, membase, 4);
+   pci_write_config(dev, PCIR_INTLINE, irq, 4);
+   }
+}
+
+/*
  * Print out the config space
  */
 static void
@@ -295,15 +321,15 @@ cbb_pci_attach(device_t brdev)
sc->cbdev = NULL;
sc->exca[0].pccarddev = NULL;
sc->domain = pci_get_domain(brdev);
+   sc->bus.sec = pci_read_config(brdev, PCIR_SECBUS_2, 1);
+   sc->bus.sub = pci_read_config(brdev, PCIR_SUBBUS_2, 1);
sc->pribus = pcib_get_bus(parent);
 #if defined(NEW_PCIB) && defined(PCI_RES_BUS)
pci_write_config(brdev, PCIR_PRIBUS_2, sc->pribus, 1);
pcib_setup_secbus(brdev, &sc->bus, 1);
-#else
-   sc->bus.sec = pci_read_config(brdev, PCIR_SECBUS_2, 1);
-   sc->bus.sub = pci_read_config(brdev, PCIR_SUBBUS_2, 1);
 #endif
SLIST_INIT(&sc->rl);
+   cbb_powerstate_d0(brdev);
 
rid = CBBR_SOCKBASE;
sc->base_res = bus_alloc_resource_any(brdev, SYS_RES_MEMORY, &rid,
@@ -448,6 +474,11 @@ cbb_chipinit(struct cbb_softc *sc)
if (pci_read_config(sc->dev, PCIR_LATTIMER, 1) < 0x20)
pci_write_config(sc->dev, PCIR_LATTIMER, 0x20, 1);
 
+   /* Restore bus configuration */
+   pci_write_config(sc->dev, PCIR_PRIBUS_2, sc->pribus, 1);
+   pci_write_config(sc->dev, PCIR_SECBUS_2, sc->bus.sec, 1);
+   pci_write_config(sc->dev, PCIR_SUBBUS_2, sc->bus.sub, 1);
+
/* Enable DMA, memory access for this card and I/O acces for children */
pci_enable_busmaster(sc->dev);
pci_enable_io(sc->dev, SYS_RES_IOPORT);
@@ -875,10 +906,15 @@ cbb_pci_resume(device_t brdev)
 * from D0 and back to D0 cause the bridge to lose its config space, so
 * all the bus mappings and such are preserved.
 *
-* The PCI layer handles standard PCI registers like the
-* command register and BARs, but cbb-specific registers are
-* handled here.
+* For most drivers, the PCI layer handles this saving. However, since
+* there's much black magic and arcane art hidden in these few lines of
+* code that would be difficult to transition into the PCI
+* layer. chipinit was several years of trial and error to write.
 */
+   pci_write_config(brdev, CBBR_SOCKBASE, rman_get_start(sc->base_res), 4);
+   DEVPRINTF((brdev, "PCI Memory allocated: %08lx\n",
+   rman_get_start(sc->base_res)));
+
sc->chipinit(sc);
 
/* reset interrupt -- Do we really need to do this? */

Modified: releng/10.2/sys/dev/pci/pci.c
==
--- releng/10.2/sys/dev/pci/pci.c   Tue Jul 28 22:48:58 2015
(r285990)
+++ releng/10.2/sys/dev/pci/pci.c   Wed Jul 29 00:57:54 2015
(r285991)
@@ -590,19 +590,9 @@ pci_hdrtypedata(device_t pcib, int b, in
cfg->nummaps= PCI_MAXMAPS_0;
break;
case PCIM_HDRTYPE_BRIDGE:
-   cfg->bridge.br_seclat = REG(PCIR_SECLAT_1, 1);
-   cfg->bridge.br_subbus = REG(PCIR_SUBBUS_1, 1);
-   cfg->bridge.br_secbus

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

2015-07-28 Thread Baptiste Daroussin
On Wed, Jul 29, 2015 at 08:52:52AM +1000, Bruce Evans wrote:
> On Tue, 28 Jul 2015, Baptiste Daroussin wrote:
> 
> > Log:
> >  Check uid/gid used when creating a user/group are not larger than 
> > UID_MAX/GID_MAX
> >
> >  PR:173977
> >  Reported by:   nv...@gmx.com
> 
> This is broken in a different way than before.
> 
> > Modified: head/usr.sbin/pw/pw.c
> > ==
> > --- head/usr.sbin/pw/pw.c   Tue Jul 28 20:52:10 2015(r285984)
> > +++ head/usr.sbin/pw/pw.c   Tue Jul 28 21:10:58 2015(r285985)
> > @@ -269,7 +269,7 @@ main(int argc, char *argv[])
> > }
> > if (strspn(optarg, "0123456789") != strlen(optarg))
> > errx(EX_USAGE, "-g expects a number");
> > -   id = strtonum(optarg, 0, LONG_MAX, &errstr);
> > +   id = strtonum(optarg, 0, GID_MAX, &errstr);
> 
> `id' still has type long.  The assignment overflows on 32-bit arches when
> the value exceeds 0x7fff.  That is for half of all valid values.  pw
> is broken in not supporting these values, but at least it detected them
> as errors in the previous version.  Old versions implemented this bug
> using atoi() with no error checking.

So writting a function like strtonum like function with that prototype
intmax_t strtonumber(const char *, intmax_t min, intmax_t max, const char **);
and an unsigned equivalent
uintmax_t strtonumber(const char *, uintmax_t min, uintmax_t max, const char 
**);

would do the right thing?

Best regards,
Bapt


pgpdO6XSSrNhj.pgp
Description: PGP signature


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

2015-07-28 Thread Bruce Evans

On Tue, 28 Jul 2015, Baptiste Daroussin wrote:


Log:
 Check uid/gid used when creating a user/group are not larger than 
UID_MAX/GID_MAX

 PR:173977
 Reported by:   nv...@gmx.com


This is broken in a different way than before.


Modified: head/usr.sbin/pw/pw.c
==
--- head/usr.sbin/pw/pw.c   Tue Jul 28 20:52:10 2015(r285984)
+++ head/usr.sbin/pw/pw.c   Tue Jul 28 21:10:58 2015(r285985)
@@ -269,7 +269,7 @@ main(int argc, char *argv[])
}
if (strspn(optarg, "0123456789") != strlen(optarg))
errx(EX_USAGE, "-g expects a number");
-   id = strtonum(optarg, 0, LONG_MAX, &errstr);
+   id = strtonum(optarg, 0, GID_MAX, &errstr);


`id' still has type long.  The assignment overflows on 32-bit arches when
the value exceeds 0x7fff.  That is for half of all valid values.  pw
is broken in not supporting these values, but at least it detected them
as errors in the previous version.  Old versions implemented this bug
using atoi() with no error checking.

The behaviour in the overflowing cases is implementation-defined.
Normally this converts large values to negative ones.  This defeats
the lower limit of 0.

The change works accidentally on 64-bit arches.  It is assumed that
GID_MAX is representable as long long (since strtonum()'s API is too
broken to use even intmax_t, and uintmax_t is needed).  This assumption
is satisfied now.  It would break if someone expands gid_t to uint64_t.
without expandling long long to int65_t or larger.  Then passing GID_MAX
would change it to an implementation-defined value.  Normally to
INT64_MIN.  This negative, so there are no values in the range.

Similarly for uids.


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.

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


svn commit: r285990 - head/lib/libc/sys

2015-07-28 Thread Bryan Drewery
Author: bdrewery
Date: Tue Jul 28 22:48:58 2015
New Revision: 285990
URL: https://svnweb.freebsd.org/changeset/base/285990

Log:
  unlink(2): Note the possibility for ENOSPC to be returned on ZFS.
  
  PR:   154930

Modified:
  head/lib/libc/sys/unlink.2

Modified: head/lib/libc/sys/unlink.2
==
--- head/lib/libc/sys/unlink.2  Tue Jul 28 21:49:38 2015(r285989)
+++ head/lib/libc/sys/unlink.2  Tue Jul 28 22:48:58 2015(r285990)
@@ -28,7 +28,7 @@
 .\" @(#)unlink.2   8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd April 25, 2010
+.Dd July 28, 2015
 .Dt UNLINK 2
 .Os
 .Sh NAME
@@ -151,6 +151,9 @@ The
 .Fa path
 argument
 points outside the process's allocated address space.
+.It Bq Er ENOSPC
+On file systems supporting copy-on-write or snapshots, there was not enough
+free space to record metadata for the delete operation of the file.
 .El
 .Pp
 In addition to the errors returned by the
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r285782 - head/usr.bin/netstat

2015-07-28 Thread Mark Johnston
On Tue, Jul 28, 2015 at 05:31:06PM +0300, Gleb Smirnoff wrote:
>   Mark, Jason,
> 
> On Tue, Jul 21, 2015 at 11:57:39PM +, Mark Johnston wrote:
> M>   Fix counter reads on platforms where sizeof(uint64_t) != sizeof(uint64_t 
> *).
> M>   
> M>   In the kernel, structs such as tcpstat are manipulated as an array of
> M>   counter_u64_t (uint64_t *), but made visible to userland as an array of
> M>   uint64_t. kread_counters() was previously copying the counter array into
> M>   user space and sequentially overwriting each counter with its value. This
> M>   mostly affects IPsec counters, as other counters are exported via sysctl.
> M>   
> M>   PR:  201700
> M>   Tested by:   Jason Unovitch
> 
> Thanks for fixing the bug after me.
> 
> One question, though: why do you use sizeof(u_long) instead of size of a
> pointer?

kvm_counter_u64_fetch(3) takes a u_long for the KVA of the counter, so it
seemed natural to read an array of counter addresses into an array of
u_long.

> 
> M> 
> ==
> M> --- head/usr.bin/netstat/main.cTue Jul 21 23:44:36 2015
> (r285781)
> M> +++ head/usr.bin/netstat/main.cTue Jul 21 23:57:38 2015
> (r285782)
> M> @@ -776,19 +776,31 @@ kread_counter(u_long addr)
> M>  int
> M>  kread_counters(u_long addr, void *buf, size_t size)
> M>  {
> M> -  uint64_t *c = buf;
> M> +  uint64_t *c;
> M> +  u_long *counters;
> M> +  size_t i, n;
> M>  
> M>if (kvmd_init() < 0)
> M>return (-1);
> M>  
> M> -  if (kread(addr, buf, size) < 0)
> M> +  if (size % sizeof(uint64_t) != 0) {
> M> +  xo_warnx("kread_counters: invalid counter set size");
> M>return (-1);
> M> +  }
> M>  
> M> -  while (size != 0) {
> M> -  *c = kvm_counter_u64_fetch(kvmd, *c);
> M> -  size -= sizeof(*c);
> M> -  c++;
> M> +  n = size / sizeof(uint64_t);
> M> +  if ((counters = malloc(n * sizeof(u_long))) == NULL)
> M> +  xo_err(-1, "malloc");
> M> +  if (kread(addr, counters, n * sizeof(u_long)) < 0) {
> M> +  free(counters);
> M> +  return (-1);
> M>}
> M> +
> M> +  c = buf;
> M> +  for (i = 0; i < n; i++)
> M> +  c[i] = kvm_counter_u64_fetch(kvmd, counters[i]);
> M> +
> M> +  free(counters);
> M>return (0);
> M>  }
> 
> -- 
> Totus tuus, Glebius.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r285125 - in head/sys: kern sys

2015-07-28 Thread Jean-Sébastien Pédron
On 23.07.2015 23:36, Adrian Chadd wrote:
> I've had no warnings/panics after applying this patch. Can we get it
> into -head plz?

I'm using this patch for three days and never got the panic again.

-- 
Jean-Sébastien Pédron



signature.asc
Description: OpenPGP digital signature


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

2015-07-28 Thread Baptiste Daroussin
Author: bapt
Date: Tue Jul 28 21:49:38 2015
New Revision: 285989
URL: https://svnweb.freebsd.org/changeset/base/285989

Log:
  Reject usermod and userdel if the user concerned is not on the user database
  supposed to be manipulated
  
  This prevent pw usermod creating a new local user when requesting to usermod 
on
  a username is defined in LDAP.
  
  This issue only happens when modifying the local user database (not inpacting
  commands when -V or -R are used).
  
  PR:   187653
  Submitted by: tmwalas...@gmail.com

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

Modified: head/usr.sbin/pw/pw_user.c
==
--- head/usr.sbin/pw/pw_user.c  Tue Jul 28 21:47:37 2015(r285988)
+++ head/usr.sbin/pw/pw_user.c  Tue Jul 28 21:49:38 2015(r285989)
@@ -310,6 +310,7 @@ pw_user(int mode, char *name, long id, s
FILE   *fp;
char *dmode_c;
void *set = NULL;
+   int valid_type = _PWF_FILES;
 
static struct passwd fakeuser =
{
@@ -505,6 +506,14 @@ pw_user(int mode, char *name, long id, s
errx(EX_NOUSER, "no such user `%s'", name);
}
 
+   if (conf.userconf->nispasswd && *conf.userconf->nispasswd == 
'/')
+   valid_type = _PWF_NIS;
+
+   if (PWF._altdir == PWF_REGULAR &&
+   ((pwd->pw_fields & _PWF_SOURCE) != valid_type))
+   errx(EX_NOUSER, "no such %s user `%s'",
+   valid_type == _PWF_FILES ? "local" : "NIS"  , name);
+
if (name == NULL)
name = pwd->pw_name;
 
@@ -1076,6 +1085,7 @@ pw_userdel(char *name, long id)
char grname[LOGNAMESIZE];
int  rc;
struct stat  st;
+   int  valid_type = _PWF_FILES;
 
if (id < 0 && name == NULL)
errx(EX_DATAERR, "username or id required");
@@ -1086,6 +1096,15 @@ pw_userdel(char *name, long id)
errx(EX_NOUSER, "no such uid `%ld'", id);
errx(EX_NOUSER, "no such user `%s'", name);
}
+
+   if (conf.userconf->nispasswd && *conf.userconf->nispasswd == '/')
+   valid_type = _PWF_NIS;
+
+   if (PWF._altdir == PWF_REGULAR &&
+   ((pwd->pw_fields & _PWF_SOURCE) != valid_type))
+   errx(EX_NOUSER, "no such %s user `%s'",
+   valid_type == _PWF_FILES ? "local" : "NIS"  , name);
+
uid = pwd->pw_uid;
if (name == NULL)
name = pwd->pw_name;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285988 - head/sys/dev/drm2/i915

2015-07-28 Thread Jean-Sebastien Pedron
Author: dumbbell
Date: Tue Jul 28 21:47:37 2015
New Revision: 285988
URL: https://svnweb.freebsd.org/changeset/base/285988

Log:
  drm/i915: Sort functions in i915_gem.c to match Linux 3.8's ordering
  
  While here, reduce the style diff with Linux.
  
  There is no functional change. The goal is to ease the future update to
  Linux 3.8's i915 driver.
  
  MFC after:2 months

Modified:
  head/sys/dev/drm2/i915/i915_drv.h
  head/sys/dev/drm2/i915/i915_gem.c
  head/sys/dev/drm2/i915/i915_gem_gtt.c

Modified: head/sys/dev/drm2/i915/i915_drv.h
==
--- head/sys/dev/drm2/i915/i915_drv.h   Tue Jul 28 21:43:23 2015
(r285987)
+++ head/sys/dev/drm2/i915/i915_drv.h   Tue Jul 28 21:47:37 2015
(r285988)
@@ -1151,8 +1151,6 @@ void i915_disable_pipestat(drm_i915_priv
 void i915_destroy_error_state(struct drm_device *dev);
 
 /* i915_gem.c */
-int i915_gem_create(struct drm_file *file, struct drm_device *dev, uint64_t 
size,
-   uint32_t *handle_p);
 int i915_gem_init_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv);
 int i915_gem_create_ioctl(struct drm_device *dev, void *data,
@@ -1243,7 +1241,6 @@ int i915_gem_object_finish_gpu(struct dr
 int i915_gem_flush_ring(struct intel_ring_buffer *ring,
 uint32_t invalidate_domains, uint32_t flush_domains);
 void i915_gem_release_mmap(struct drm_i915_gem_object *obj);
-int i915_gem_object_wait_rendering(struct drm_i915_gem_object *obj);
 int i915_gem_object_sync(struct drm_i915_gem_object *obj,
 struct intel_ring_buffer *to);
 int i915_gem_object_put_fence(struct drm_i915_gem_object *obj);

Modified: head/sys/dev/drm2/i915/i915_gem.c
==
--- head/sys/dev/drm2/i915/i915_gem.c   Tue Jul 28 21:43:23 2015
(r285987)
+++ head/sys/dev/drm2/i915/i915_gem.c   Tue Jul 28 21:47:37 2015
(r285988)
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+
 #include 
 #include 
 #include 
@@ -69,38 +70,40 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-static void i915_gem_object_flush_cpu_write_domain(
-struct drm_i915_gem_object *obj);
-static uint32_t i915_gem_get_gtt_size(struct drm_device *dev, uint32_t size,
-int tiling_mode);
-static uint32_t i915_gem_get_gtt_alignment(struct drm_device *dev,
-uint32_t size, int tiling_mode);
-static int i915_gem_object_bind_to_gtt(struct drm_i915_gem_object *obj,
-unsigned alignment, bool map_and_fenceable);
-static int i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj,
-int flags);
-static void i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj);
-static void i915_gem_object_put_pages_range(struct drm_i915_gem_object *obj,
-off_t start, off_t end);
+#define __user
+#define __force
+#define __iomem
+#define__must_check
+#defineto_user_ptr(x) ((void *)(uintptr_t)(x))
+#defineoffset_in_page(x) ((x) & PAGE_MASK)
+#definepage_to_phys(x) VM_PAGE_TO_PHYS(x)
+
+static void i915_gem_object_flush_gtt_write_domain(struct drm_i915_gem_object 
*obj);
+static void i915_gem_object_flush_cpu_write_domain(struct drm_i915_gem_object 
*obj);
+static __must_check int i915_gem_object_bind_to_gtt(struct drm_i915_gem_object 
*obj,
+   unsigned alignment,
+   bool map_and_fenceable);
+static int i915_gem_phys_pwrite(struct drm_device *dev,
+   struct drm_i915_gem_object *obj,
+   struct drm_i915_gem_pwrite *args,
+   struct drm_file *file);
+
+static void i915_gem_write_fence(struct drm_device *dev, int reg,
+struct drm_i915_gem_object *obj);
+static void i915_gem_object_update_fence(struct drm_i915_gem_object *obj,
+struct drm_i915_fence_reg *fence,
+bool enable);
+
+static void i915_gem_lowmem(void *arg);
+static void i915_gem_object_truncate(struct drm_i915_gem_object *obj);
+
 static int i915_gem_object_get_pages_range(struct drm_i915_gem_object *obj,
 off_t start, off_t end);
-static void i915_gem_object_finish_gtt(struct drm_i915_gem_object *obj);
-static void i915_gem_object_truncate(struct drm_i915_gem_object *obj);
-static int i915_gem_object_is_purgeable(struct drm_i915_gem_object *obj);
-static bool i915_gem_object_is_inactive(struct drm_i915_gem_object *obj);
-static int i915_gem_object_needs_bit17_swizzle(struct drm_i915_gem_object 
*obj);
+static void i915_gem_object_put_pages_range(struct drm_i915_gem_object *obj,
+off_t start, off_t end);
+
 static vm_page_t i915_gem_wire_page(vm_object_t object, vm_pindex_t pindex,
 bool *fresh);
-static void i915_gem_process_flushing_list(struct intel_ring_buffer *ring,
-uint32

svn commit: r285987 - releng/10.1/sys/conf

2015-07-28 Thread Xin LI
Author: delphij
Date: Tue Jul 28 21:43:23 2015
New Revision: 285987
URL: https://svnweb.freebsd.org/changeset/base/285987

Log:
  Correct patchlevel.
  
  Noticed by:   Piotr Kubaj
  Approved by:  so

Modified:
  releng/10.1/sys/conf/newvers.sh

Modified: releng/10.1/sys/conf/newvers.sh
==
--- releng/10.1/sys/conf/newvers.sh Tue Jul 28 21:39:58 2015
(r285986)
+++ releng/10.1/sys/conf/newvers.sh Tue Jul 28 21:43:23 2015
(r285987)
@@ -32,7 +32,7 @@
 
 TYPE="FreeBSD"
 REVISION="10.1"
-BRANCH="RELEASE-p15"
+BRANCH="RELEASE-p16"
 if [ "X${BRANCH_OVERRIDE}" != "X" ]; then
BRANCH=${BRANCH_OVERRIDE}
 fi
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r284356 - head/usr.sbin/crunch/crunchgen

2015-07-28 Thread Bryan Drewery
On 7/28/15 2:20 PM, Bryan Drewery wrote:
> On 6/13/15 3:01 PM, Adrian Chadd wrote:
>> > Author: adrian
>> > Date: Sat Jun 13 22:01:21 2015
>> > New Revision: 284356
>> > URL: https://svnweb.freebsd.org/changeset/base/284356
>> > 
>> > Log:
>> >   Fix up crunchgen binary generation to work with external cross-build
>> >   tools.
>> >   
>> >   * Allow STRIP to be overridden by the environment
> This change breaks the the build still. The build uses STRIP as the
> parameter for install(1), i.e., -s or blank. Once you rebuild
> usr.sbin/crunch/crunchgen with this change and then build rescue/rescue
> with 'make STRIP=' the following is encountered:
> 
> rescue
> sh: rescue: not found
> *** [rescue] Error code 127
> 
> make[1]: stopped in /usr/obj/root/svn/base/rescue/rescue

Fixed in r285986. Renamed to STRIPBIN as ports uses and documented in
build(7).

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


svn commit: r285986 - head/usr.sbin/crunch/crunchgen

2015-07-28 Thread Bryan Drewery
Author: bdrewery
Date: Tue Jul 28 21:39:58 2015
New Revision: 285986
URL: https://svnweb.freebsd.org/changeset/base/285986

Log:
  Fix rescue build after r284356 with STRIP= by using proper STRIPBIN per 
build(7).
  
  This was causing the following error:
  
rescue
sh: rescue: not found
*** [rescue] Error code 127
  
make[1]: stopped in /usr/obj/usr/src/rescue/rescue
  
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/usr.sbin/crunch/crunchgen/crunchgen.c

Modified: head/usr.sbin/crunch/crunchgen/crunchgen.c
==
--- head/usr.sbin/crunch/crunchgen/crunchgen.c  Tue Jul 28 21:10:58 2015
(r285985)
+++ head/usr.sbin/crunch/crunchgen/crunchgen.c  Tue Jul 28 21:39:58 2015
(r285986)
@@ -980,7 +980,7 @@ top_makefile_rules(FILE *outmk)
prog_t *p;
 
fprintf(outmk, "LD?= ld\n");
-   fprintf(outmk, "STRIP?= strip\n");
+   fprintf(outmk, "STRIPBIN?= strip\n");
if ( subtract_strlst(&libs, &libs_so) )
fprintf(outmk, "# NOTE: Some LIBS declarations below overridden 
by LIBS_SO\n");
 
@@ -1028,7 +1028,7 @@ top_makefile_rules(FILE *outmk)
fprintf(outmk, "\t$(CC) -static -o %s %s.o $(CRUNCHED_OBJS) $(LIBS)\n",
execfname, execfname);
fprintf(outmk, ".endif\n");
-   fprintf(outmk, "\t$(STRIP) %s\n", execfname);
+   fprintf(outmk, "\t$(STRIPBIN) %s\n", execfname);
fprintf(outmk, "realclean: clean subclean\n");
fprintf(outmk, "clean:\n\trm -f %s *.lo *.o *_stub.c\n", execfname);
fprintf(outmk, "subclean: $(SUBCLEAN_TARGETS)\n");
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r284356 - head/usr.sbin/crunch/crunchgen

2015-07-28 Thread Bryan Drewery
On 6/13/15 3:01 PM, Adrian Chadd wrote:
> Author: adrian
> Date: Sat Jun 13 22:01:21 2015
> New Revision: 284356
> URL: https://svnweb.freebsd.org/changeset/base/284356
> 
> Log:
>   Fix up crunchgen binary generation to work with external cross-build
>   tools.
>   
>   * Allow STRIP to be overridden by the environment

This change breaks the the build still. The build uses STRIP as the
parameter for install(1), i.e., -s or blank. Once you rebuild
usr.sbin/crunch/crunchgen with this change and then build rescue/rescue
with 'make STRIP=' the following is encountered:

rescue
sh: rescue: not found
*** [rescue] Error code 127

make[1]: stopped in /usr/obj/root/svn/base/rescue/rescue

I would suggest changing the name of this, perhaps STRIP_CMD as ports
has, or using a different mechanism.

Side note, something funky is going on with including /etc/make.conf.
When I build with buildworld (clean) I get the error, but not a plain
'make' having STRIP= in /etc/make.conf for both. My system is
pre-meta-mode merge at r280911.


>   * Use CC to tie things together, not LD
>   
>   Tested:
>   
>   * i386, mips32
>   
>   Submitted by:   kan
> 
> Modified:
>   head/usr.sbin/crunch/crunchgen/crunchgen.c
> 
> Modified: head/usr.sbin/crunch/crunchgen/crunchgen.c
> ==
> --- head/usr.sbin/crunch/crunchgen/crunchgen.cSat Jun 13 20:15:44 
> 2015(r284355)
> +++ head/usr.sbin/crunch/crunchgen/crunchgen.cSat Jun 13 22:01:21 
> 2015(r284356)
> @@ -980,6 +980,7 @@ top_makefile_rules(FILE *outmk)
>   prog_t *p;
>  
>   fprintf(outmk, "LD?= ld\n");
> + fprintf(outmk, "STRIP?= strip\n");
>   if ( subtract_strlst(&libs, &libs_so) )
>   fprintf(outmk, "# NOTE: Some LIBS declarations below overridden 
> by LIBS_SO\n");
>  
> @@ -1027,7 +1028,7 @@ top_makefile_rules(FILE *outmk)
>   fprintf(outmk, "\t$(CC) -static -o %s %s.o $(CRUNCHED_OBJS) $(LIBS)\n",
>   execfname, execfname);
>   fprintf(outmk, ".endif\n");
> - fprintf(outmk, "\tstrip %s\n", execfname);
> + fprintf(outmk, "\t$(STRIP) %s\n", execfname);
>   fprintf(outmk, "realclean: clean subclean\n");
>   fprintf(outmk, "clean:\n\trm -f %s *.lo *.o *_stub.c\n", execfname);
>   fprintf(outmk, "subclean: $(SUBCLEAN_TARGETS)\n");
> @@ -1109,7 +1110,7 @@ prog_makefile_rules(FILE *outmk, prog_t 
>   fprintf(outmk, " $(%s_LIBS)", p->ident);
>  
>   fprintf(outmk, "\n");
> - fprintf(outmk, "\t$(LD) -dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS)",
> + fprintf(outmk, "\t$(CC) -nostdlibs -dc -r -o %s.lo %s_stub.o 
> $(%s_OBJPATHS)",
>   p->name, p->name, p->ident);
>   if (p->libs)
>   fprintf(outmk, " $(%s_LIBS)", p->ident);
> 


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


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

2015-07-28 Thread Baptiste Daroussin
Author: bapt
Date: Tue Jul 28 21:10:58 2015
New Revision: 285985
URL: https://svnweb.freebsd.org/changeset/base/285985

Log:
  Check uid/gid used when creating a user/group are not larger than 
UID_MAX/GID_MAX
  
  PR:   173977
  Reported by:  nv...@gmx.com

Added:
  head/usr.sbin/pw/tests/pw_groupadd.sh   (contents, props changed)
Modified:
  head/usr.sbin/pw/pw.c
  head/usr.sbin/pw/tests/Makefile
  head/usr.sbin/pw/tests/pw_useradd.sh

Modified: head/usr.sbin/pw/pw.c
==
--- head/usr.sbin/pw/pw.c   Tue Jul 28 20:52:10 2015(r285984)
+++ head/usr.sbin/pw/pw.c   Tue Jul 28 21:10:58 2015(r285985)
@@ -269,7 +269,7 @@ main(int argc, char *argv[])
}
if (strspn(optarg, "0123456789") != strlen(optarg))
errx(EX_USAGE, "-g expects a number");
-   id = strtonum(optarg, 0, LONG_MAX, &errstr);
+   id = strtonum(optarg, 0, GID_MAX, &errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s", optarg,
errstr);
@@ -281,7 +281,7 @@ main(int argc, char *argv[])
addarg(&arglist, 'u', optarg);
break;
}
-   id = strtonum(optarg, 0, LONG_MAX, &errstr);
+   id = strtonum(optarg, 0, UID_MAX, &errstr);
if (errstr != NULL)
errx(EX_USAGE, "Bad id '%s': %s", optarg,
errstr);

Modified: head/usr.sbin/pw/tests/Makefile
==
--- head/usr.sbin/pw/tests/Makefile Tue Jul 28 20:52:10 2015
(r285984)
+++ head/usr.sbin/pw/tests/Makefile Tue Jul 28 21:10:58 2015
(r285985)
@@ -8,6 +8,7 @@ TESTSDIR=   ${TESTSBASE}/usr.sbin/pw
 ATF_TESTS_SH=  pw_etcdir \
pw_lock \
pw_config \
+   pw_groupadd \
pw_groupdel \
pw_groupmod \
pw_useradd \

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
+}
+
+atf_init_test_cases() {
+   atf_add_test_case group_add_gid_too_large
+}

Modified: head/usr.sbin/pw/tests/pw_useradd.sh
==
--- head/usr.sbin/pw/tests/pw_useradd.shTue Jul 28 20:52:10 2015
(r285984)
+++ head/usr.sbin/pw/tests/pw_useradd.shTue Jul 28 21:10:58 2015
(r285985)
@@ -289,6 +289,13 @@ user_add_uid0_body() {
-s exit:0 ${PW} usershow foo
 }
 
+atf_test_case user_add_uid_too_large
+user_add_uid_too_large_body() {
+   populate_etc_skel
+   atf_check -s exit:64 -e inline:"pw: Bad id '9': too 
large\n" \
+   ${PW} useradd -n test1 -u 9
+}
+
 atf_init_test_cases() {
atf_add_test_case user_add
atf_add_test_case user_add_noupdate
@@ -313,4 +320,5 @@ atf_init_test_cases() {
atf_add_test_case user_add_R
atf_add_test_case user_add_skel
atf_add_test_case user_add_uid0
+   atf_add_test_case user_add_uid_too_large
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2015-07-28 Thread Baptiste Daroussin
Author: bapt
Date: Tue Jul 28 20:52:10 2015
New Revision: 285984
URL: https://svnweb.freebsd.org/changeset/base/285984

Log:
  Fix wrong warning printed after changing or updating NIS users
  
  PR:   37672
  Submitted by: chris+free...@chrullrich.de

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

Modified: head/usr.sbin/pw/pw_user.c
==
--- head/usr.sbin/pw/pw_user.c  Tue Jul 28 20:42:36 2015(r285983)
+++ head/usr.sbin/pw/pw_user.c  Tue Jul 28 20:52:10 2015(r285984)
@@ -206,7 +206,7 @@ perform_chgpwent(const char *name, struc
rc = chgnispwent(conf.userconf->nispasswd, name, pwd);
if (rc == -1)
warn("User '%s' not found in NIS passwd", pwd->pw_name);
-   else
+   else if (rc != 0)
warn("NIS passwd update");
/* NOTE: NIS-only update errors are not fatal */
}
@@ -678,7 +678,7 @@ pw_user(int mode, char *name, long id, s
rc = addnispwent(cnf->nispasswd, pwd);
if (rc == -1)
warnx("User '%s' already exists in NIS passwd", 
pwd->pw_name);
-   else
+   else if (rc != 0)
warn("NIS passwd update");
/* NOTE: we treat NIS-only update errors as non-fatal */
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285983 - releng/10.2/release/doc/share/xml

2015-07-28 Thread Glen Barber
Author: gjb
Date: Tue Jul 28 20:42:36 2015
New Revision: 285983
URL: https://svnweb.freebsd.org/changeset/base/285983

Log:
  Document SA-15:14 through SA-15:16.
  
  Approved by:  re (implicit)
  Sponsored by: The FreeBSD Foundation

Modified:
  releng/10.2/release/doc/share/xml/security.xml

Modified: releng/10.2/release/doc/share/xml/security.xml
==
--- releng/10.2/release/doc/share/xml/security.xml  Tue Jul 28 20:38:52 
2015(r285982)
+++ releng/10.2/release/doc/share/xml/security.xml  Tue Jul 28 20:42:36 
2015(r285983)
@@ -133,6 +133,28 @@
resource exhaustion due to sessions stuck in
LAST_ACK state.
   
+
+  
+   FreeBSD-SA-15:14.bsdpatch
+   28 July 2015
+   Shell injection vulnerability
+  
+
+  
+   FreeBSD-SA-15:15.tcp
+   28 July 2015
+   resource exhaustion in TCP
+   reassembly
+  
+
+  
+   FreeBSD-SA-15:16.openssh
+   28 July 2015
+   Multiple vulnerabilities
+  
 
   
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285982 - in stable: 10/release/doc/share/xml 8/release/doc/share/xml 9/release/doc/share/xml

2015-07-28 Thread Glen Barber
Author: gjb
Date: Tue Jul 28 20:38:52 2015
New Revision: 285982
URL: https://svnweb.freebsd.org/changeset/base/285982

Log:
  Document SA-15:14 through SA-15:17.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/9/release/doc/share/xml/security.xml

Changes in other areas also in this revision:
Modified:
  stable/10/release/doc/share/xml/security.xml
  stable/8/release/doc/share/xml/security.xml

Modified: stable/9/release/doc/share/xml/security.xml
==
--- stable/9/release/doc/share/xml/security.xml Tue Jul 28 20:24:09 2015
(r285981)
+++ stable/9/release/doc/share/xml/security.xml Tue Jul 28 20:38:52 2015
(r285982)
@@ -170,6 +170,29 @@
resource exhaustion due to sessions stuck in
LAST_ACK state.
   
+
+  
+   FreeBSD-SA-15:15.tcp
+   28 July 2015
+   resource exhaustion in TCP
+   reassembly
+  
+
+  
+   FreeBSD-SA-15:16.openssh
+   28 July 2015
+   Multiple vulnerabilities
+  
+
+  
+   FreeBSD-SA-15:17.bind
+   28 July 2015
+   Remote denial of service
+   vulnerability
+  
 
   
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285982 - in stable: 10/release/doc/share/xml 8/release/doc/share/xml 9/release/doc/share/xml

2015-07-28 Thread Glen Barber
Author: gjb
Date: Tue Jul 28 20:38:52 2015
New Revision: 285982
URL: https://svnweb.freebsd.org/changeset/base/285982

Log:
  Document SA-15:14 through SA-15:17.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/release/doc/share/xml/security.xml

Changes in other areas also in this revision:
Modified:
  stable/8/release/doc/share/xml/security.xml
  stable/9/release/doc/share/xml/security.xml

Modified: stable/10/release/doc/share/xml/security.xml
==
--- stable/10/release/doc/share/xml/security.xmlTue Jul 28 20:24:09 
2015(r285981)
+++ stable/10/release/doc/share/xml/security.xmlTue Jul 28 20:38:52 
2015(r285982)
@@ -133,6 +133,28 @@
resource exhaustion due to sessions stuck in
LAST_ACK state.
   
+
+  
+   FreeBSD-SA-15:14.bsdpatch
+   28 July 2015
+   Shell injection vulnerability
+  
+
+  
+   FreeBSD-SA-15:15.tcp
+   28 July 2015
+   resource exhaustion in TCP
+   reassembly
+  
+
+  
+   FreeBSD-SA-15:16.openssh
+   28 July 2015
+   Multiple vulnerabilities
+  
 
   
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285982 - in stable: 10/release/doc/share/xml 8/release/doc/share/xml 9/release/doc/share/xml

2015-07-28 Thread Glen Barber
Author: gjb
Date: Tue Jul 28 20:38:52 2015
New Revision: 285982
URL: https://svnweb.freebsd.org/changeset/base/285982

Log:
  Document SA-15:14 through SA-15:17.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/8/release/doc/share/xml/security.xml

Changes in other areas also in this revision:
Modified:
  stable/10/release/doc/share/xml/security.xml
  stable/9/release/doc/share/xml/security.xml

Modified: stable/8/release/doc/share/xml/security.xml
==
--- stable/8/release/doc/share/xml/security.xml Tue Jul 28 20:24:09 2015
(r285981)
+++ stable/8/release/doc/share/xml/security.xml Tue Jul 28 20:38:52 2015
(r285982)
@@ -275,6 +275,29 @@
resource exhaustion due to sessions stuck in
LAST_ACK state.
   
+
+  
+   FreeBSD-SA-15:15.tcp
+   28 July 2015
+   resource exhaustion in TCP
+   reassembly
+  
+
+  
+   FreeBSD-SA-15:16.openssh
+   28 July 2015
+   Multiple vulnerabilities
+  
+
+  
+   FreeBSD-SA-15:17.bind
+   28 July 2015
+   Remote denial of service
+   vulnerability
+  
 
   
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285981 - head/sys/kern

2015-07-28 Thread Jeff Roberson
Author: jeff
Date: Tue Jul 28 20:24:09 2015
New Revision: 285981
URL: https://svnweb.freebsd.org/changeset/base/285981

Log:
   - Eliminate the EMPTYKVA queue.  It served as a cache of KVA allocations
 attached to bufs to avoid the overhead of the vm.  This purposes is now
 better served by vmem.  Freeing the kva immediately when a buf is
 destroyed leads to lower fragmentation and a much simpler scan algorithm.
  
  Reviewed by:  kib
  Sponsored by: EMC / Isilon Storage Division

Modified:
  head/sys/kern/vfs_bio.c

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Tue Jul 28 19:59:22 2015(r285980)
+++ head/sys/kern/vfs_bio.c Tue Jul 28 20:24:09 2015(r285981)
@@ -309,13 +309,12 @@ static int bdirtywait;
 /*
  * Definitions for the buffer free lists.
  */
-#define BUFFER_QUEUES  5   /* number of free buffer queues */
+#define BUFFER_QUEUES  4   /* number of free buffer queues */
 
 #define QUEUE_NONE 0   /* on no queue */
 #define QUEUE_CLEAN1   /* non-B_DELWRI buffers */
 #define QUEUE_DIRTY2   /* B_DELWRI buffers */
-#define QUEUE_EMPTYKVA 3   /* empty buffer headers w/KVA assignment */
-#define QUEUE_EMPTY4   /* empty buffer headers */
+#define QUEUE_EMPTY3   /* empty buffer headers */
 #define QUEUE_SENTINEL 1024/* not an queue index, but mark for sentinel */
 
 /* Queues for free buffers with various properties */
@@ -1862,10 +1861,8 @@ brelse(struct buf *bp)
bp->b_xflags &= ~(BX_BKGRDWRITE | BX_ALTDATA);
if (bp->b_vflags & BV_BKGRDINPROG)
panic("losing buffer 1");
-   if (bp->b_kvasize)
-   qindex = QUEUE_EMPTYKVA;
-   else
-   qindex = QUEUE_EMPTY;
+   bufkvafree(bp);
+   qindex = QUEUE_EMPTY;
bp->b_flags |= B_AGE;
/* buffers with junk contents */
} else if (bp->b_flags & (B_INVAL | B_NOCACHE | B_RELBUF) ||
@@ -2251,8 +2248,6 @@ getnewbuf_reuse_bp(struct buf *bp, int q
LIST_INIT(&bp->b_dep);
 }
 
-static int flushingbufs;
-
 static struct buf *
 getnewbuf_scan(int maxsize, int defrag, int unmapped, int metadata)
 {
@@ -2261,64 +2256,25 @@ getnewbuf_scan(int maxsize, int defrag, 
 
KASSERT(!unmapped || !defrag, ("both unmapped and defrag"));
 
-   pass = 1;
+   pass = 0;
 restart:
-   atomic_add_int(&getnewbufrestarts, 1);
+   if (pass != 0)
+   atomic_add_int(&getnewbufrestarts, 1);
 
-   /*
-* Setup for scan.  If we do not have enough free buffers,
-* we setup a degenerate case that immediately fails.  Note
-* that if we are specially marked process, we are allowed to
-* dip into our reserves.
-*
-* The scanning sequence is nominally: EMPTY->EMPTYKVA->CLEAN
-* for the allocation of the mapped buffer.  For unmapped, the
-* easiest is to start with EMPTY outright.
-*
-* We start with EMPTYKVA.  If the list is empty we backup to EMPTY.
-* However, there are a number of cases (defragging, reusing, ...)
-* where we cannot backup.
-*/
nbp = NULL;
mtx_lock(&bqclean);
-   if (!defrag && unmapped) {
-   nqindex = QUEUE_EMPTY;
-   nbp = TAILQ_FIRST(&bufqueues[QUEUE_EMPTY]);
-   }
-   if (nbp == NULL) {
-   nqindex = QUEUE_EMPTYKVA;
-   nbp = TAILQ_FIRST(&bufqueues[QUEUE_EMPTYKVA]);
-   }
-
/*
-* If no EMPTYKVA buffers and we are either defragging or
-* reusing, locate a CLEAN buffer to free or reuse.  If
-* bufspace useage is low skip this step so we can allocate a
-* new buffer.
+* If we're not defragging or low on bufspace attempt to make a new
+* buf from a header.
 */
-   if (nbp == NULL && (defrag || bufspace >= lobufspace)) {
-   nqindex = QUEUE_CLEAN;
-   nbp = TAILQ_FIRST(&bufqueues[QUEUE_CLEAN]);
-   }
-
-   /*
-* If we could not find or were not allowed to reuse a CLEAN
-* buffer, check to see if it is ok to use an EMPTY buffer.
-* We can only use an EMPTY buffer if allocating its KVA would
-* not otherwise run us out of buffer space.  No KVA is needed
-* for the unmapped allocation.
-*/
-   if (nbp == NULL && defrag == 0 && (bufspace + maxsize < hibufspace ||
-   metadata)) {
+   if (defrag == 0 && bufspace + maxsize < hibufspace) {
nqindex = QUEUE_EMPTY;
-   nbp = TAILQ_FIRST(&bufqueues[QUEUE_EMPTY]);
+   nbp = TAILQ_FIRST(&bufqueues[nqindex]);
}
-
/*
-* All available buffers might be clean, retry ignoring the
-* lobufspace as the last resort.
+* All available buffers might be 

svn commit: r285980 - in releng: 8.4 8.4/contrib/bind9/lib/dns 8.4/crypto/openssh 8.4/sys/conf 8.4/sys/netinet 9.3 9.3/contrib/bind9/lib/dns 9.3/crypto/openssh 9.3/sys/conf 9.3/sys/netinet

2015-07-28 Thread Xin LI
Author: delphij
Date: Tue Jul 28 19:59:22 2015
New Revision: 285980
URL: https://svnweb.freebsd.org/changeset/base/285980

Log:
  Fix resource exhaustion in TCP reassembly. [SA-15:15]
  
  Fix OpenSSH multiple vulnerabilities. [SA-15:16]
  
  Fix BIND remote denial of service vulnerability. [SA-15:17]
  
  Approved by:  so

Modified:
  releng/8.4/UPDATING
  releng/8.4/contrib/bind9/lib/dns/tkey.c
  releng/8.4/crypto/openssh/auth2-chall.c
  releng/8.4/crypto/openssh/sshconnect.c
  releng/8.4/sys/conf/newvers.sh
  releng/8.4/sys/netinet/tcp_reass.c
  releng/8.4/sys/netinet/tcp_subr.c
  releng/8.4/sys/netinet/tcp_var.h
  releng/9.3/UPDATING
  releng/9.3/contrib/bind9/lib/dns/tkey.c
  releng/9.3/crypto/openssh/auth2-chall.c
  releng/9.3/crypto/openssh/sshconnect.c
  releng/9.3/sys/conf/newvers.sh
  releng/9.3/sys/netinet/tcp_reass.c
  releng/9.3/sys/netinet/tcp_subr.c
  releng/9.3/sys/netinet/tcp_var.h

Modified: releng/8.4/UPDATING
==
--- releng/8.4/UPDATING Tue Jul 28 19:59:11 2015(r285979)
+++ releng/8.4/UPDATING Tue Jul 28 19:59:22 2015(r285980)
@@ -15,6 +15,16 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8.
debugging tools present in HEAD were left in place because
sun4v support still needs work to become production ready.
 
+20150728:  p35 FreeBSD-SA-15:15.tcp
+   FreeBSD-SA-15:16.openssh
+   FreeBSD-SA-15:17.bind
+
+   Fix resource exhaustion in TCP reassembly. [SA-15:15]
+
+   Fix OpenSSH multiple vulnerabilities. [SA-15:16]
+
+   Fix BIND remote denial of service vulnerability. [SA-15:17]
+
 20150721:  p34 FreeBSD-SA-15:13.tcp
 
Fix resource exhaustion due to sessions stuck in LAST_ACK state.

Modified: releng/8.4/contrib/bind9/lib/dns/tkey.c
==
--- releng/8.4/contrib/bind9/lib/dns/tkey.c Tue Jul 28 19:59:11 2015
(r285979)
+++ releng/8.4/contrib/bind9/lib/dns/tkey.c Tue Jul 28 19:59:22 2015
(r285980)
@@ -650,6 +650,7 @@ dns_tkey_processquery(dns_message_t *msg
 * Try the answer section, since that's where Win2000
 * puts it.
 */
+   name = NULL;
if (dns_message_findname(msg, DNS_SECTION_ANSWER, qname,
 dns_rdatatype_tkey, 0, &name,
 &tkeyset) != ISC_R_SUCCESS) {

Modified: releng/8.4/crypto/openssh/auth2-chall.c
==
--- releng/8.4/crypto/openssh/auth2-chall.c Tue Jul 28 19:59:11 2015
(r285979)
+++ releng/8.4/crypto/openssh/auth2-chall.c Tue Jul 28 19:59:22 2015
(r285980)
@@ -82,6 +82,7 @@ struct KbdintAuthctxt
void *ctxt;
KbdintDevice *device;
u_int nreq;
+   u_int devices_done;
 };
 
 #ifdef USE_PAM
@@ -169,9 +170,14 @@ kbdint_next_device(KbdintAuthctxt *kbdin
 
if (len == 0)
break;
-   for (i = 0; devices[i]; i++)
-   if (strncmp(kbdintctxt->devices, devices[i]->name, len) 
== 0)
+   for (i = 0; devices[i]; i++) {
+   if ((kbdintctxt->devices_done & (1 << i)) != 0)
+   continue;
+   if (strncmp(kbdintctxt->devices, devices[i]->name, len) 
== 0) {
kbdintctxt->device = devices[i];
+   kbdintctxt->devices_done |= 1 << i;
+   }
+   }
t = kbdintctxt->devices;
kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;
xfree(t);

Modified: releng/8.4/crypto/openssh/sshconnect.c
==
--- releng/8.4/crypto/openssh/sshconnect.c  Tue Jul 28 19:59:11 2015
(r285979)
+++ releng/8.4/crypto/openssh/sshconnect.c  Tue Jul 28 19:59:22 2015
(r285980)
@@ -1141,29 +1141,39 @@ verify_host_key(char *host, struct socka
 {
int flags = 0;
char *fp;
+   Key *plain = NULL;
 
fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
debug("Server host key: %s %s", key_type(host_key), fp);
xfree(fp);
 
-   /* XXX certs are not yet supported for DNS */
-   if (!key_is_cert(host_key) && options.verify_host_key_dns &&
-   verify_host_key_dns(host, hostaddr, host_key, &flags) == 0) {
-   if (flags & DNS_VERIFY_FOUND) {
-
-   if (options.verify_host_key_dns == 1 &&
-   flags & DNS_VERIFY_MATCH &&
-   flags & D

svn commit: r285979 - in releng/10.1: . crypto/openssh sys/netinet usr.bin/patch

2015-07-28 Thread Xin LI
Author: delphij
Date: Tue Jul 28 19:59:11 2015
New Revision: 285979
URL: https://svnweb.freebsd.org/changeset/base/285979

Log:
  Fix patch(1) shell injection vulnerability. [SA-15:14]
  
  Fix resource exhaustion in TCP reassembly. [SA-15:15]
  
  Fix OpenSSH multiple vulnerabilities. [SA-15:16]
  
  Approved by:  so

Modified:
  releng/10.1/UPDATING
  releng/10.1/crypto/openssh/auth2-chall.c
  releng/10.1/crypto/openssh/sshconnect.c
  releng/10.1/sys/netinet/tcp_reass.c
  releng/10.1/sys/netinet/tcp_subr.c
  releng/10.1/sys/netinet/tcp_var.h
  releng/10.1/usr.bin/patch/common.h
  releng/10.1/usr.bin/patch/inp.c

Modified: releng/10.1/UPDATING
==
--- releng/10.1/UPDATINGTue Jul 28 19:59:04 2015(r285978)
+++ releng/10.1/UPDATINGTue Jul 28 19:59:11 2015(r285979)
@@ -16,6 +16,16 @@ from older versions of FreeBSD, try WITH
 stable/10, and then rebuild without this option. The bootstrap process from
 older version of current is a bit fragile.
 
+20150728:  p16 FreeBSD-SA-15:14.bsdpatch
+   FreeBSD-SA-15:15.tcp
+   FreeBSD-SA-15:16.openssh
+
+   Fix patch(1) shell injection vulnerability. [SA-15:14]
+
+   Fix resource exhaustion in TCP reassembly. [SA-15:15]
+
+   Fix OpenSSH multiple vulnerabilities. [SA-15:16]
+
 20150721:  p15 FreeBSD-SA-15:13.tcp
 
Fix resource exhaustion due to sessions stuck in LAST_ACK state.

Modified: releng/10.1/crypto/openssh/auth2-chall.c
==
--- releng/10.1/crypto/openssh/auth2-chall.cTue Jul 28 19:59:04 2015
(r285978)
+++ releng/10.1/crypto/openssh/auth2-chall.cTue Jul 28 19:59:11 2015
(r285979)
@@ -82,6 +82,7 @@ struct KbdintAuthctxt
void *ctxt;
KbdintDevice *device;
u_int nreq;
+   u_int devices_done;
 };
 
 #ifdef USE_PAM
@@ -168,11 +169,15 @@ kbdint_next_device(Authctxt *authctxt, K
if (len == 0)
break;
for (i = 0; devices[i]; i++) {
-   if (!auth2_method_allowed(authctxt,
+   if ((kbdintctxt->devices_done & (1 << i)) != 0 ||
+   !auth2_method_allowed(authctxt,
"keyboard-interactive", devices[i]->name))
continue;
-   if (strncmp(kbdintctxt->devices, devices[i]->name, len) 
== 0)
+   if (strncmp(kbdintctxt->devices, devices[i]->name,
+   len) == 0) {
kbdintctxt->device = devices[i];
+   kbdintctxt->devices_done |= 1 << i;
+   }
}
t = kbdintctxt->devices;
kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;

Modified: releng/10.1/crypto/openssh/sshconnect.c
==
--- releng/10.1/crypto/openssh/sshconnect.c Tue Jul 28 19:59:04 2015
(r285978)
+++ releng/10.1/crypto/openssh/sshconnect.c Tue Jul 28 19:59:11 2015
(r285979)
@@ -1246,29 +1246,39 @@ verify_host_key(char *host, struct socka
 {
int flags = 0;
char *fp;
+   Key *plain = NULL;
 
fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
debug("Server host key: %s %s", key_type(host_key), fp);
free(fp);
 
-   /* XXX certs are not yet supported for DNS */
-   if (!key_is_cert(host_key) && options.verify_host_key_dns &&
-   verify_host_key_dns(host, hostaddr, host_key, &flags) == 0) {
-   if (flags & DNS_VERIFY_FOUND) {
-
-   if (options.verify_host_key_dns == 1 &&
-   flags & DNS_VERIFY_MATCH &&
-   flags & DNS_VERIFY_SECURE)
-   return 0;
-
-   if (flags & DNS_VERIFY_MATCH) {
-   matching_host_key_dns = 1;
-   } else {
-   warn_changed_key(host_key);
-   error("Update the SSHFP RR in DNS with the new "
-   "host key to get rid of this message.");
+   if (options.verify_host_key_dns) {
+   /*
+* XXX certs are not yet supported for DNS, so downgrade
+* them and try the plain key.
+*/
+   plain = key_from_private(host_key);
+   if (key_is_cert(plain))
+   key_drop_cert(plain);
+   if (verify_host_key_dns(host, hostaddr, plain, &flags) == 0) {
+   if 

svn commit: r285977 - in stable: 8/contrib/bind9/lib/dns 8/crypto/openssh 8/sys/netinet 9/contrib/bind9/lib/dns 9/crypto/openssh 9/sys/netinet

2015-07-28 Thread Xin LI
Author: delphij
Date: Tue Jul 28 19:58:54 2015
New Revision: 285977
URL: https://svnweb.freebsd.org/changeset/base/285977

Log:
  Fix resource exhaustion in TCP reassembly. [SA-15:15]
  
  Fix OpenSSH multiple vulnerabilities. [SA-15:16]
  
  Fix BIND remote denial of service vulnerability. [SA-15:17]

Modified:
  stable/8/contrib/bind9/lib/dns/tkey.c
  stable/8/crypto/openssh/auth2-chall.c
  stable/8/crypto/openssh/sshconnect.c
  stable/8/sys/netinet/tcp_reass.c
  stable/8/sys/netinet/tcp_subr.c
  stable/8/sys/netinet/tcp_var.h

Changes in other areas also in this revision:
Modified:
  stable/9/contrib/bind9/lib/dns/tkey.c
  stable/9/crypto/openssh/auth2-chall.c
  stable/9/crypto/openssh/sshconnect.c
  stable/9/sys/netinet/tcp_reass.c
  stable/9/sys/netinet/tcp_subr.c
  stable/9/sys/netinet/tcp_var.h

Modified: stable/8/contrib/bind9/lib/dns/tkey.c
==
--- stable/8/contrib/bind9/lib/dns/tkey.c   Tue Jul 28 19:58:44 2015
(r285976)
+++ stable/8/contrib/bind9/lib/dns/tkey.c   Tue Jul 28 19:58:54 2015
(r285977)
@@ -650,6 +650,7 @@ dns_tkey_processquery(dns_message_t *msg
 * Try the answer section, since that's where Win2000
 * puts it.
 */
+   name = NULL;
if (dns_message_findname(msg, DNS_SECTION_ANSWER, qname,
 dns_rdatatype_tkey, 0, &name,
 &tkeyset) != ISC_R_SUCCESS) {

Modified: stable/8/crypto/openssh/auth2-chall.c
==
--- stable/8/crypto/openssh/auth2-chall.c   Tue Jul 28 19:58:44 2015
(r285976)
+++ stable/8/crypto/openssh/auth2-chall.c   Tue Jul 28 19:58:54 2015
(r285977)
@@ -82,6 +82,7 @@ struct KbdintAuthctxt
void *ctxt;
KbdintDevice *device;
u_int nreq;
+   u_int devices_done;
 };
 
 #ifdef USE_PAM
@@ -169,9 +170,14 @@ kbdint_next_device(KbdintAuthctxt *kbdin
 
if (len == 0)
break;
-   for (i = 0; devices[i]; i++)
-   if (strncmp(kbdintctxt->devices, devices[i]->name, len) 
== 0)
+   for (i = 0; devices[i]; i++) {
+   if ((kbdintctxt->devices_done & (1 << i)) != 0)
+   continue;
+   if (strncmp(kbdintctxt->devices, devices[i]->name, len) 
== 0) {
kbdintctxt->device = devices[i];
+   kbdintctxt->devices_done |= 1 << i;
+   }
+   }
t = kbdintctxt->devices;
kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;
xfree(t);

Modified: stable/8/crypto/openssh/sshconnect.c
==
--- stable/8/crypto/openssh/sshconnect.cTue Jul 28 19:58:44 2015
(r285976)
+++ stable/8/crypto/openssh/sshconnect.cTue Jul 28 19:58:54 2015
(r285977)
@@ -1141,29 +1141,39 @@ verify_host_key(char *host, struct socka
 {
int flags = 0;
char *fp;
+   Key *plain = NULL;
 
fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
debug("Server host key: %s %s", key_type(host_key), fp);
xfree(fp);
 
-   /* XXX certs are not yet supported for DNS */
-   if (!key_is_cert(host_key) && options.verify_host_key_dns &&
-   verify_host_key_dns(host, hostaddr, host_key, &flags) == 0) {
-   if (flags & DNS_VERIFY_FOUND) {
-
-   if (options.verify_host_key_dns == 1 &&
-   flags & DNS_VERIFY_MATCH &&
-   flags & DNS_VERIFY_SECURE)
-   return 0;
-
-   if (flags & DNS_VERIFY_MATCH) {
-   matching_host_key_dns = 1;
-   } else {
-   warn_changed_key(host_key);
-   error("Update the SSHFP RR in DNS with the new "
-   "host key to get rid of this message.");
+   if (options.verify_host_key_dns) {
+   /*
+* XXX certs are not yet supported for DNS, so downgrade
+* them and try the plain key.
+*/
+   plain = key_from_private(host_key);
+   if (key_is_cert(plain))
+   key_drop_cert(plain);
+   if (verify_host_key_dns(host, hostaddr, plain, &flags) == 0) {
+   if (flags & DNS_VERIFY_FOUND) {
+   if (options.verify_host_key_dns == 1 &&
+   flags & DNS_VERIFY_MATCH &&
+   flags & DNS_VERIFY_SECURE) {
+   key_free(plain)

svn commit: r285978 - in releng/10.2: crypto/openssh sys/netinet usr.bin/patch

2015-07-28 Thread Xin LI
Author: delphij
Date: Tue Jul 28 19:59:04 2015
New Revision: 285978
URL: https://svnweb.freebsd.org/changeset/base/285978

Log:
  Fix patch(1) shell injection vulnerability. [SA-15:14]
  
  Fix resource exhaustion in TCP reassembly. [SA-15:15]
  
  Fix OpenSSH multiple vulnerabilities. [SA-15:16]
  
  Approved by:  re (so blanket)

Modified:
  releng/10.2/crypto/openssh/auth2-chall.c
  releng/10.2/crypto/openssh/sshconnect.c
  releng/10.2/sys/netinet/tcp_reass.c
  releng/10.2/sys/netinet/tcp_subr.c
  releng/10.2/sys/netinet/tcp_var.h
  releng/10.2/usr.bin/patch/common.h
  releng/10.2/usr.bin/patch/inp.c

Modified: releng/10.2/crypto/openssh/auth2-chall.c
==
--- releng/10.2/crypto/openssh/auth2-chall.cTue Jul 28 19:58:54 2015
(r285977)
+++ releng/10.2/crypto/openssh/auth2-chall.cTue Jul 28 19:59:04 2015
(r285978)
@@ -82,6 +82,7 @@ struct KbdintAuthctxt
void *ctxt;
KbdintDevice *device;
u_int nreq;
+   u_int devices_done;
 };
 
 #ifdef USE_PAM
@@ -168,11 +169,15 @@ kbdint_next_device(Authctxt *authctxt, K
if (len == 0)
break;
for (i = 0; devices[i]; i++) {
-   if (!auth2_method_allowed(authctxt,
+   if ((kbdintctxt->devices_done & (1 << i)) != 0 ||
+   !auth2_method_allowed(authctxt,
"keyboard-interactive", devices[i]->name))
continue;
-   if (strncmp(kbdintctxt->devices, devices[i]->name, len) 
== 0)
+   if (strncmp(kbdintctxt->devices, devices[i]->name,
+   len) == 0) {
kbdintctxt->device = devices[i];
+   kbdintctxt->devices_done |= 1 << i;
+   }
}
t = kbdintctxt->devices;
kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;

Modified: releng/10.2/crypto/openssh/sshconnect.c
==
--- releng/10.2/crypto/openssh/sshconnect.c Tue Jul 28 19:58:54 2015
(r285977)
+++ releng/10.2/crypto/openssh/sshconnect.c Tue Jul 28 19:59:04 2015
(r285978)
@@ -1246,29 +1246,39 @@ verify_host_key(char *host, struct socka
 {
int flags = 0;
char *fp;
+   Key *plain = NULL;
 
fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
debug("Server host key: %s %s", key_type(host_key), fp);
free(fp);
 
-   /* XXX certs are not yet supported for DNS */
-   if (!key_is_cert(host_key) && options.verify_host_key_dns &&
-   verify_host_key_dns(host, hostaddr, host_key, &flags) == 0) {
-   if (flags & DNS_VERIFY_FOUND) {
-
-   if (options.verify_host_key_dns == 1 &&
-   flags & DNS_VERIFY_MATCH &&
-   flags & DNS_VERIFY_SECURE)
-   return 0;
-
-   if (flags & DNS_VERIFY_MATCH) {
-   matching_host_key_dns = 1;
-   } else {
-   warn_changed_key(host_key);
-   error("Update the SSHFP RR in DNS with the new "
-   "host key to get rid of this message.");
+   if (options.verify_host_key_dns) {
+   /*
+* XXX certs are not yet supported for DNS, so downgrade
+* them and try the plain key.
+*/
+   plain = key_from_private(host_key);
+   if (key_is_cert(plain))
+   key_drop_cert(plain);
+   if (verify_host_key_dns(host, hostaddr, plain, &flags) == 0) {
+   if (flags & DNS_VERIFY_FOUND) {
+   if (options.verify_host_key_dns == 1 &&
+   flags & DNS_VERIFY_MATCH &&
+   flags & DNS_VERIFY_SECURE) {
+   key_free(plain);
+   return 0;
+   }
+   if (flags & DNS_VERIFY_MATCH) {
+   matching_host_key_dns = 1;
+   } else {
+   warn_changed_key(plain);
+   error("Update the SSHFP RR in DNS "
+   "with the new host key to get rid "
+   "of this message.");
+   }
}
}
+   key_free(plain);
}
 
return check_host_key(host, hostaddr, options.port, host_key, RDRW,

Modified: releng/10.2/sys/netinet/tcp_

svn commit: r285975 - head/crypto/openssh

2015-07-28 Thread Xin LI
Author: delphij
Date: Tue Jul 28 19:58:38 2015
New Revision: 285975
URL: https://svnweb.freebsd.org/changeset/base/285975

Log:
  Fix multiple OpenSSH vulnerabilities.
  
  Security: CVE-2014-2653
  Security: CVE-2015-5600
  Security: FreeBSD-SA-15:16.openssh

Modified:
  head/crypto/openssh/auth2-chall.c
  head/crypto/openssh/sshconnect.c

Modified: head/crypto/openssh/auth2-chall.c
==
--- head/crypto/openssh/auth2-chall.c   Tue Jul 28 19:58:36 2015
(r285974)
+++ head/crypto/openssh/auth2-chall.c   Tue Jul 28 19:58:38 2015
(r285975)
@@ -82,6 +82,7 @@ struct KbdintAuthctxt
void *ctxt;
KbdintDevice *device;
u_int nreq;
+   u_int devices_done;
 };
 
 #ifdef USE_PAM
@@ -168,11 +169,15 @@ kbdint_next_device(Authctxt *authctxt, K
if (len == 0)
break;
for (i = 0; devices[i]; i++) {
-   if (!auth2_method_allowed(authctxt,
+   if ((kbdintctxt->devices_done & (1 << i)) != 0 ||
+   !auth2_method_allowed(authctxt,
"keyboard-interactive", devices[i]->name))
continue;
-   if (strncmp(kbdintctxt->devices, devices[i]->name, len) 
== 0)
+   if (strncmp(kbdintctxt->devices, devices[i]->name,
+   len) == 0) {
kbdintctxt->device = devices[i];
+   kbdintctxt->devices_done |= 1 << i;
+   }
}
t = kbdintctxt->devices;
kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;

Modified: head/crypto/openssh/sshconnect.c
==
--- head/crypto/openssh/sshconnect.cTue Jul 28 19:58:36 2015
(r285974)
+++ head/crypto/openssh/sshconnect.cTue Jul 28 19:58:38 2015
(r285975)
@@ -1247,29 +1247,39 @@ verify_host_key(char *host, struct socka
 {
int flags = 0;
char *fp;
+   Key *plain = NULL;
 
fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
debug("Server host key: %s %s", key_type(host_key), fp);
free(fp);
 
-   /* XXX certs are not yet supported for DNS */
-   if (!key_is_cert(host_key) && options.verify_host_key_dns &&
-   verify_host_key_dns(host, hostaddr, host_key, &flags) == 0) {
-   if (flags & DNS_VERIFY_FOUND) {
-
-   if (options.verify_host_key_dns == 1 &&
-   flags & DNS_VERIFY_MATCH &&
-   flags & DNS_VERIFY_SECURE)
-   return 0;
-
-   if (flags & DNS_VERIFY_MATCH) {
-   matching_host_key_dns = 1;
-   } else {
-   warn_changed_key(host_key);
-   error("Update the SSHFP RR in DNS with the new "
-   "host key to get rid of this message.");
+   if (options.verify_host_key_dns) {
+   /*
+* XXX certs are not yet supported for DNS, so downgrade
+* them and try the plain key.
+*/
+   plain = key_from_private(host_key);
+   if (key_is_cert(plain))
+   key_drop_cert(plain);
+   if (verify_host_key_dns(host, hostaddr, plain, &flags) == 0) {
+   if (flags & DNS_VERIFY_FOUND) {
+   if (options.verify_host_key_dns == 1 &&
+   flags & DNS_VERIFY_MATCH &&
+   flags & DNS_VERIFY_SECURE) {
+   key_free(plain);
+   return 0;
+   }
+   if (flags & DNS_VERIFY_MATCH) {
+   matching_host_key_dns = 1;
+   } else {
+   warn_changed_key(plain);
+   error("Update the SSHFP RR in DNS "
+   "with the new host key to get rid "
+   "of this message.");
+   }
}
}
+   key_free(plain);
}
 
return check_host_key(host, hostaddr, options.port, host_key, RDRW,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285976 - in stable/10: crypto/openssh sys/netinet usr.bin/patch

2015-07-28 Thread Xin LI
Author: delphij
Date: Tue Jul 28 19:58:44 2015
New Revision: 285976
URL: https://svnweb.freebsd.org/changeset/base/285976

Log:
  Fix patch(1) shell injection vulnerability. [SA-15:14]
  
  Fix resource exhaustion in TCP reassembly. [SA-15:15]
  
  Fix OpenSSH multiple vulnerabilities. [SA-15:16]

Modified:
  stable/10/crypto/openssh/auth2-chall.c
  stable/10/crypto/openssh/sshconnect.c
  stable/10/sys/netinet/tcp_reass.c
  stable/10/sys/netinet/tcp_subr.c
  stable/10/sys/netinet/tcp_var.h
  stable/10/usr.bin/patch/common.h
  stable/10/usr.bin/patch/inp.c

Modified: stable/10/crypto/openssh/auth2-chall.c
==
--- stable/10/crypto/openssh/auth2-chall.c  Tue Jul 28 19:58:38 2015
(r285975)
+++ stable/10/crypto/openssh/auth2-chall.c  Tue Jul 28 19:58:44 2015
(r285976)
@@ -82,6 +82,7 @@ struct KbdintAuthctxt
void *ctxt;
KbdintDevice *device;
u_int nreq;
+   u_int devices_done;
 };
 
 #ifdef USE_PAM
@@ -168,11 +169,15 @@ kbdint_next_device(Authctxt *authctxt, K
if (len == 0)
break;
for (i = 0; devices[i]; i++) {
-   if (!auth2_method_allowed(authctxt,
+   if ((kbdintctxt->devices_done & (1 << i)) != 0 ||
+   !auth2_method_allowed(authctxt,
"keyboard-interactive", devices[i]->name))
continue;
-   if (strncmp(kbdintctxt->devices, devices[i]->name, len) 
== 0)
+   if (strncmp(kbdintctxt->devices, devices[i]->name,
+   len) == 0) {
kbdintctxt->device = devices[i];
+   kbdintctxt->devices_done |= 1 << i;
+   }
}
t = kbdintctxt->devices;
kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;

Modified: stable/10/crypto/openssh/sshconnect.c
==
--- stable/10/crypto/openssh/sshconnect.c   Tue Jul 28 19:58:38 2015
(r285975)
+++ stable/10/crypto/openssh/sshconnect.c   Tue Jul 28 19:58:44 2015
(r285976)
@@ -1246,29 +1246,39 @@ verify_host_key(char *host, struct socka
 {
int flags = 0;
char *fp;
+   Key *plain = NULL;
 
fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
debug("Server host key: %s %s", key_type(host_key), fp);
free(fp);
 
-   /* XXX certs are not yet supported for DNS */
-   if (!key_is_cert(host_key) && options.verify_host_key_dns &&
-   verify_host_key_dns(host, hostaddr, host_key, &flags) == 0) {
-   if (flags & DNS_VERIFY_FOUND) {
-
-   if (options.verify_host_key_dns == 1 &&
-   flags & DNS_VERIFY_MATCH &&
-   flags & DNS_VERIFY_SECURE)
-   return 0;
-
-   if (flags & DNS_VERIFY_MATCH) {
-   matching_host_key_dns = 1;
-   } else {
-   warn_changed_key(host_key);
-   error("Update the SSHFP RR in DNS with the new "
-   "host key to get rid of this message.");
+   if (options.verify_host_key_dns) {
+   /*
+* XXX certs are not yet supported for DNS, so downgrade
+* them and try the plain key.
+*/
+   plain = key_from_private(host_key);
+   if (key_is_cert(plain))
+   key_drop_cert(plain);
+   if (verify_host_key_dns(host, hostaddr, plain, &flags) == 0) {
+   if (flags & DNS_VERIFY_FOUND) {
+   if (options.verify_host_key_dns == 1 &&
+   flags & DNS_VERIFY_MATCH &&
+   flags & DNS_VERIFY_SECURE) {
+   key_free(plain);
+   return 0;
+   }
+   if (flags & DNS_VERIFY_MATCH) {
+   matching_host_key_dns = 1;
+   } else {
+   warn_changed_key(plain);
+   error("Update the SSHFP RR in DNS "
+   "with the new host key to get rid "
+   "of this message.");
+   }
}
}
+   key_free(plain);
}
 
return check_host_key(host, hostaddr, options.port, host_key, RDRW,

Modified: stable/10/sys/netinet/tcp_reass.c
===

svn commit: r285977 - in stable: 8/contrib/bind9/lib/dns 8/crypto/openssh 8/sys/netinet 9/contrib/bind9/lib/dns 9/crypto/openssh 9/sys/netinet

2015-07-28 Thread Xin LI
Author: delphij
Date: Tue Jul 28 19:58:54 2015
New Revision: 285977
URL: https://svnweb.freebsd.org/changeset/base/285977

Log:
  Fix resource exhaustion in TCP reassembly. [SA-15:15]
  
  Fix OpenSSH multiple vulnerabilities. [SA-15:16]
  
  Fix BIND remote denial of service vulnerability. [SA-15:17]

Modified:
  stable/9/contrib/bind9/lib/dns/tkey.c
  stable/9/crypto/openssh/auth2-chall.c
  stable/9/crypto/openssh/sshconnect.c
  stable/9/sys/netinet/tcp_reass.c
  stable/9/sys/netinet/tcp_subr.c
  stable/9/sys/netinet/tcp_var.h

Changes in other areas also in this revision:
Modified:
  stable/8/contrib/bind9/lib/dns/tkey.c
  stable/8/crypto/openssh/auth2-chall.c
  stable/8/crypto/openssh/sshconnect.c
  stable/8/sys/netinet/tcp_reass.c
  stable/8/sys/netinet/tcp_subr.c
  stable/8/sys/netinet/tcp_var.h

Modified: stable/9/contrib/bind9/lib/dns/tkey.c
==
--- stable/9/contrib/bind9/lib/dns/tkey.c   Tue Jul 28 19:58:44 2015
(r285976)
+++ stable/9/contrib/bind9/lib/dns/tkey.c   Tue Jul 28 19:58:54 2015
(r285977)
@@ -650,6 +650,7 @@ dns_tkey_processquery(dns_message_t *msg
 * Try the answer section, since that's where Win2000
 * puts it.
 */
+   name = NULL;
if (dns_message_findname(msg, DNS_SECTION_ANSWER, qname,
 dns_rdatatype_tkey, 0, &name,
 &tkeyset) != ISC_R_SUCCESS) {

Modified: stable/9/crypto/openssh/auth2-chall.c
==
--- stable/9/crypto/openssh/auth2-chall.c   Tue Jul 28 19:58:44 2015
(r285976)
+++ stable/9/crypto/openssh/auth2-chall.c   Tue Jul 28 19:58:54 2015
(r285977)
@@ -82,6 +82,7 @@ struct KbdintAuthctxt
void *ctxt;
KbdintDevice *device;
u_int nreq;
+   u_int devices_done;
 };
 
 #ifdef USE_PAM
@@ -168,11 +169,15 @@ kbdint_next_device(Authctxt *authctxt, K
if (len == 0)
break;
for (i = 0; devices[i]; i++) {
-   if (!auth2_method_allowed(authctxt,
+   if ((kbdintctxt->devices_done & (1 << i)) != 0 ||
+   !auth2_method_allowed(authctxt,
"keyboard-interactive", devices[i]->name))
continue;
-   if (strncmp(kbdintctxt->devices, devices[i]->name, len) 
== 0)
+   if (strncmp(kbdintctxt->devices, devices[i]->name,
+   len) == 0) {
kbdintctxt->device = devices[i];
+   kbdintctxt->devices_done |= 1 << i;
+   }
}
t = kbdintctxt->devices;
kbdintctxt->devices = t[len] ? xstrdup(t+len+1) : NULL;

Modified: stable/9/crypto/openssh/sshconnect.c
==
--- stable/9/crypto/openssh/sshconnect.cTue Jul 28 19:58:44 2015
(r285976)
+++ stable/9/crypto/openssh/sshconnect.cTue Jul 28 19:58:54 2015
(r285977)
@@ -1247,29 +1247,39 @@ verify_host_key(char *host, struct socka
 {
int flags = 0;
char *fp;
+   Key *plain = NULL;
 
fp = key_fingerprint(host_key, SSH_FP_MD5, SSH_FP_HEX);
debug("Server host key: %s %s", key_type(host_key), fp);
free(fp);
 
-   /* XXX certs are not yet supported for DNS */
-   if (!key_is_cert(host_key) && options.verify_host_key_dns &&
-   verify_host_key_dns(host, hostaddr, host_key, &flags) == 0) {
-   if (flags & DNS_VERIFY_FOUND) {
-
-   if (options.verify_host_key_dns == 1 &&
-   flags & DNS_VERIFY_MATCH &&
-   flags & DNS_VERIFY_SECURE)
-   return 0;
-
-   if (flags & DNS_VERIFY_MATCH) {
-   matching_host_key_dns = 1;
-   } else {
-   warn_changed_key(host_key);
-   error("Update the SSHFP RR in DNS with the new "
-   "host key to get rid of this message.");
+   if (options.verify_host_key_dns) {
+   /*
+* XXX certs are not yet supported for DNS, so downgrade
+* them and try the plain key.
+*/
+   plain = key_from_private(host_key);
+   if (key_is_cert(plain))
+   key_drop_cert(plain);
+   if (verify_host_key_dns(host, hostaddr, plain, &flags) == 0) {
+   if (flags & DNS_VERIFY_FOUND) {
+   if (options.verify_host_key_dns == 1 &&
+   f

svn commit: r285974 - head/usr.bin/patch

2015-07-28 Thread Xin LI
Author: delphij
Date: Tue Jul 28 19:58:36 2015
New Revision: 285974
URL: https://svnweb.freebsd.org/changeset/base/285974

Log:
  Fix shell injection vulnerability in patch(1) and drop SCCS
  support by replacing system() with execve().
  
  Future revisions may remove the functionality completely.
  
  Obtained from:Bitrig
  Security: CVE-2015-1416

Modified:
  head/usr.bin/patch/common.h
  head/usr.bin/patch/inp.c

Modified: head/usr.bin/patch/common.h
==
--- head/usr.bin/patch/common.h Tue Jul 28 19:15:44 2015(r285973)
+++ head/usr.bin/patch/common.h Tue Jul 28 19:58:36 2015(r285974)
@@ -43,12 +43,10 @@
 #defineLINENUM_MAX LONG_MAX
 
 #defineSCCSPREFIX "s."
-#defineGET "get -e %s"
-#defineSCCSDIFF "get -p %s | diff - %s >/dev/null"
 
 #defineRCSSUFFIX ",v"
-#defineCHECKOUT "co -l %s"
-#defineRCSDIFF "rcsdiff %s > /dev/null"
+#defineCHECKOUT "/usr/bin/co"
+#defineRCSDIFF "/usr/bin/rcsdiff"
 
 #defineORIGEXT ".orig"
 #defineREJEXT ".rej"

Modified: head/usr.bin/patch/inp.c
==
--- head/usr.bin/patch/inp.cTue Jul 28 19:15:44 2015(r285973)
+++ head/usr.bin/patch/inp.cTue Jul 28 19:58:36 2015(r285974)
@@ -31,8 +31,10 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -133,12 +135,14 @@ reallocate_lines(size_t *lines_allocated
 static bool
 plan_a(const char *filename)
 {
-   int ifd, statfailed;
+   int ifd, statfailed, devnull, pstat;
char*p, *s, lbuf[INITLINELEN];
struct stat filestat;
ptrdiff_t   sz;
size_t  i;
size_t  iline, lines_allocated;
+   pid_t   pid;
+   char*argp[4] = {NULL};
 
 #ifdef DEBUGGING
if (debug & 8)
@@ -166,13 +170,14 @@ plan_a(const char *filename)
}
if (statfailed && check_only)
fatal("%s not found, -C mode, can't probe further\n", filename);
-   /* For nonexistent or read-only files, look for RCS or SCCS versions.  
*/
+   /* For nonexistent or read-only files, look for RCS versions.  */
+
if (statfailed ||
/* No one can write to it.  */
(filestat.st_mode & 0222) == 0 ||
/* I can't write to it.  */
((filestat.st_mode & 0022) == 0 && filestat.st_uid != getuid())) {
-   const char  *cs = NULL, *filebase, *filedir;
+   char*filebase, *filedir;
struct stat cstat;
char *tmp_filename1, *tmp_filename2;
 
@@ -180,43 +185,26 @@ plan_a(const char *filename)
tmp_filename2 = strdup(filename);
if (tmp_filename1 == NULL || tmp_filename2 == NULL)
fatal("strdupping filename");
+
filebase = basename(tmp_filename1);
filedir = dirname(tmp_filename2);
 
-   /* Leave room in lbuf for the diff command.  */
-   s = lbuf + 20;
-
 #define try(f, a1, a2, a3) \
-   (snprintf(s, buf_size - 20, f, a1, a2, a3), stat(s, &cstat) == 0)
-
-   if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) ||
-   try("%s/RCS/%s%s", filedir, filebase, "") ||
-   try("%s/%s%s", filedir, filebase, RCSSUFFIX)) {
-   snprintf(buf, buf_size, CHECKOUT, filename);
-   snprintf(lbuf, sizeof lbuf, RCSDIFF, filename);
-   cs = "RCS";
-   } else if (try("%s/SCCS/%s%s", filedir, SCCSPREFIX, filebase) ||
-   try("%s/%s%s", filedir, SCCSPREFIX, filebase)) {
-   snprintf(buf, buf_size, GET, s);
-   snprintf(lbuf, sizeof lbuf, SCCSDIFF, s, filename);
-   cs = "SCCS";
-   } else if (statfailed)
-   fatal("can't find %s\n", filename);
-
-   free(tmp_filename1);
-   free(tmp_filename2);
+   (snprintf(lbuf, sizeof(lbuf), f, a1, a2, a3), stat(lbuf, &cstat) == 0)
 
/*
 * else we can't write to it but it's not under a version
 * control system, so just proceed.
 */
-   if (cs) {
+   if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) ||
+   try("%s/RCS/%s%s", filedir, filebase, "") ||
+   try("%s/%s%s", filedir, filebase, RCSSUFFIX)) {
if (!statfailed) {
if ((filestat.st_mode & 0222) != 0)
/* The owner can write to it.  */
fatal("file %s seems to be locked "
-

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

2015-07-28 Thread David C Somayajulu
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.
  - If IFF_DRV_OACTIVE is set (and also if IFF_DRV_RUNNING is not) just
   enqueue the desired frames and return successful transmit. This way we
   avoid to return errors on transmit side and resulting in
   possible out-of-order frames. Please note that IFF_DRV_OACTIVE is set
   everytime we get the threshold ring hit, so this can be happening quite
   often.
  
  Submitted by: attilio@isilon.com
  MFC after:5 days

Modified:
  head/sys/dev/bxe/bxe.c
  head/sys/dev/bxe/bxe.h

Modified: head/sys/dev/bxe/bxe.c
==
--- head/sys/dev/bxe/bxe.c  Tue Jul 28 18:41:28 2015(r285972)
+++ head/sys/dev/bxe/bxe.c  Tue Jul 28 19:15:44 2015(r285973)
@@ -5999,19 +5999,26 @@ bxe_tx_mq_start_locked(struct bxe_softc 
 
 rc = tx_count = 0;
 
+BXE_FP_TX_LOCK_ASSERT(fp);
+
 if (!tx_br) {
 BLOGE(sc, "Multiqueue TX and no buf_ring!\n");
 return (EINVAL);
 }
 
+if (!sc->link_vars.link_up ||
+(ifp->if_drv_flags &
+(IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING) {
+rc = drbr_enqueue_drv(ifp, tx_br, m);
+goto bxe_tx_mq_start_locked_exit;
+}
+
 /* fetch the depth of the driver queue */
 depth = drbr_inuse_drv(ifp, tx_br);
 if (depth > fp->eth_q_stats.tx_max_drbr_queue_depth) {
 fp->eth_q_stats.tx_max_drbr_queue_depth = depth;
 }
 
-BXE_FP_TX_LOCK_ASSERT(fp);
-
 if (m == NULL) {
 /* no new work, check for pending frames */
 next = drbr_dequeue_drv(ifp, tx_br);
@@ -6103,26 +6110,11 @@ bxe_tx_mq_start(struct ifnet *ifp,
 
 fp = &sc->fp[fp_index];
 
-if (!(if_getdrvflags(ifp) & IFF_DRV_RUNNING)) {
-BLOGW(sc, "Interface not running, ignoring transmit request\n");
-return (ENETDOWN);
-}
-
-if (if_getdrvflags(ifp) & IFF_DRV_OACTIVE) {
-BLOGW(sc, "Interface TX queue is full, ignoring transmit request\n");
-return (EBUSY);
-}
-
-if (!sc->link_vars.link_up) {
-BLOGW(sc, "Interface link is down, ignoring transmit request\n");
-return (ENETDOWN);
-}
-
-/* XXX change to TRYLOCK here and if failed then schedule taskqueue */
-
-BXE_FP_TX_LOCK(fp);
-rc = bxe_tx_mq_start_locked(sc, ifp, fp, m);
-BXE_FP_TX_UNLOCK(fp);
+if (BXE_FP_TX_TRYLOCK(fp)) {
+rc = bxe_tx_mq_start_locked(sc, ifp, fp, m);
+BXE_FP_TX_UNLOCK(fp);
+} else
+rc = drbr_enqueue_drv(ifp, fp->tx_br, m);
 
 return (rc);
 }

Modified: head/sys/dev/bxe/bxe.h
==
--- head/sys/dev/bxe/bxe.h  Tue Jul 28 18:41:28 2015(r285972)
+++ head/sys/dev/bxe/bxe.h  Tue Jul 28 19:15:44 2015(r285973)
@@ -582,6 +582,7 @@ struct bxe_fastpath {
 #define BXE_FP_TX_LOCK(fp)mtx_lock(&fp->tx_mtx)
 #define BXE_FP_TX_UNLOCK(fp)  mtx_unlock(&fp->tx_mtx)
 #define BXE_FP_TX_LOCK_ASSERT(fp) mtx_assert(&fp->tx_mtx, MA_OWNED)
+#define BXE_FP_TX_TRYLOCK(fp) mtx_trylock(&fp->tx_mtx)
 
 #define BXE_FP_RX_LOCK(fp)mtx_lock(&fp->rx_mtx)
 #define BXE_FP_RX_UNLOCK(fp)  mtx_unlock(&fp->rx_mtx)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285972 - in head: contrib/libarchive/libarchive contrib/libarchive/libarchive/test lib/libarchive/test

2015-07-28 Thread Bryan Drewery
Author: bdrewery
Date: Tue Jul 28 18:41:28 2015
New Revision: 285972
URL: https://svnweb.freebsd.org/changeset/base/285972

Log:
  MFV r285970:
  
Apply upstream changeset bf4f6ec64e:
  
Fix issue 356: properly skip a sparse file entry in a tar file.
  
  PR:   201506
  MFC after:3 days
  Relnotes: yes

Added:
  
head/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse_skip_entry.c
 - copied, changed from r285970, 
vendor/libarchive/dist/libarchive/test/test_read_format_gtar_sparse_skip_entry.c
  
head/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse_skip_entry.tar.Z.uu
 - copied unchanged from r285970, 
vendor/libarchive/dist/libarchive/test/test_read_format_gtar_sparse_skip_entry.tar.Z.uu
Modified:
  head/contrib/libarchive/libarchive/archive_read_support_format_tar.c
  head/lib/libarchive/test/Makefile
Directory Properties:
  head/contrib/libarchive/   (props changed)
  head/contrib/libarchive/libarchive/   (props changed)

Modified: head/contrib/libarchive/libarchive/archive_read_support_format_tar.c
==
--- head/contrib/libarchive/libarchive/archive_read_support_format_tar.c
Tue Jul 28 18:37:23 2015(r285971)
+++ head/contrib/libarchive/libarchive/archive_read_support_format_tar.c
Tue Jul 28 18:41:28 2015(r285972)
@@ -585,13 +585,23 @@ static int
 archive_read_format_tar_skip(struct archive_read *a)
 {
int64_t bytes_skipped;
+   int64_t request;
+   struct sparse_block *p;
struct tar* tar;
 
tar = (struct tar *)(a->format->data);
 
-   bytes_skipped = __archive_read_consume(a,
-   tar->entry_bytes_remaining + tar->entry_padding + 
-   tar->entry_bytes_unconsumed);
+   /* Do not consume the hole of a sparse file. */
+   request = 0;
+   for (p = tar->sparse_list; p != NULL; p = p->next) {
+   if (!p->hole)
+   request += p->remaining;
+   }
+   if (request > tar->entry_bytes_remaining)
+   request = tar->entry_bytes_remaining;
+   request += tar->entry_padding + tar->entry_bytes_unconsumed;
+
+   bytes_skipped = __archive_read_consume(a, request);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
 

Copied and modified: 
head/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse_skip_entry.c
 (from r285970, 
vendor/libarchive/dist/libarchive/test/test_read_format_gtar_sparse_skip_entry.c)
==
--- 
vendor/libarchive/dist/libarchive/test/test_read_format_gtar_sparse_skip_entry.c
Tue Jul 28 17:48:34 2015(r285970, copy source)
+++ 
head/contrib/libarchive/libarchive/test/test_read_format_gtar_sparse_skip_entry.c
   Tue Jul 28 18:41:28 2015(r285972)
@@ -30,14 +30,22 @@ __FBSDID("$FreeBSD");
  */
 DEFINE_TEST(test_read_format_gtar_sparse_skip_entry)
 {
+#ifndef __FreeBSD__ /* Backport test. */
const char *refname = 
"test_read_format_gtar_sparse_skip_entry.tar.Z.uu";
+#else
+   const char *refname = "test_read_format_gtar_sparse_skip_entry.tar.Z";
+#endif
struct archive *a;
struct archive_entry *ae;
const void *p;
size_t s;
int64_t o;
 
+#ifndef __FreeBSD__ /* Backport test. */
copy_reference_file(refname);
+#else
+   extract_reference_file(refname);
+#endif
assert((a = archive_read_new()) != NULL);
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
@@ -48,17 +56,21 @@ DEFINE_TEST(test_read_format_gtar_sparse
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("a", archive_entry_pathname(ae));
assertEqualInt(10737418244, archive_entry_size(ae));
+#ifndef __FreeBSD__ /* Backport test. */
assertEqualInt(archive_entry_is_encrypted(ae), 0);
assertEqualIntA(a, archive_read_has_encrypted_entries(a),
ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
+#endif
 
/* Verify regular second file. */
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("b", archive_entry_pathname(ae));
assertEqualInt(4, archive_entry_size(ae));
+#ifndef __FreeBSD__ /* Backport test. */
assertEqualInt(archive_entry_is_encrypted(ae), 0);
assertEqualIntA(a, archive_read_has_encrypted_entries(a),
ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED);
+#endif
 
 
/* End of archive. */
@@ -87,9 +99,11 @@ DEFINE_TEST(test_read_format_gtar_sparse
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
assertEqualString("a", archive_entry_pathname(ae));
assertEqualInt(10737418244, archive_entry_size(ae));
+#ifndef __FreeBSD__ /* Backport test. */
assertEqualInt(arch

svn commit: r285971 - stable/10/sys/kern

2015-07-28 Thread Conrad E. Meyer
Author: cem
Date: Tue Jul 28 18:37:23 2015
New Revision: 285971
URL: https://svnweb.freebsd.org/changeset/base/285971

Log:
  MFC r285483: pipe_direct_write: Fix mismatched pipelock/unlock
  
  If a signal is caught in pipelock, causing it to fail, pipe_direct_write
  should not try to pipeunlock.
  
  Approved by:  markj (mentor)
  Sponsored by: EMC / Isilon Storage Division

Modified:
  stable/10/sys/kern/sys_pipe.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/sys_pipe.c
==
--- stable/10/sys/kern/sys_pipe.c   Tue Jul 28 17:48:34 2015
(r285970)
+++ stable/10/sys/kern/sys_pipe.c   Tue Jul 28 18:37:23 2015
(r285971)
@@ -945,9 +945,10 @@ pipe_direct_write(wpipe, uio)
 retry:
PIPE_LOCK_ASSERT(wpipe, MA_OWNED);
error = pipelock(wpipe, 1);
-   if (wpipe->pipe_state & PIPE_EOF)
+   if (error != 0)
+   goto error1;
+   if ((wpipe->pipe_state & PIPE_EOF) != 0) {
error = EPIPE;
-   if (error) {
pipeunlock(wpipe);
goto error1;
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285970 - in vendor/libarchive/dist: . libarchive libarchive/test

2015-07-28 Thread Bryan Drewery
Author: bdrewery
Date: Tue Jul 28 17:48:34 2015
New Revision: 285970
URL: https://svnweb.freebsd.org/changeset/base/285970

Log:
  Apply upstream changeset bf4f6ec64e:
  
  Fix issue 356: properly skip a sparse file entry in a tar file.

Added:
  
vendor/libarchive/dist/libarchive/test/test_read_format_gtar_sparse_skip_entry.c
   (contents, props changed)
  
vendor/libarchive/dist/libarchive/test/test_read_format_gtar_sparse_skip_entry.tar.Z.uu
Modified:
  vendor/libarchive/dist/Makefile.am
  vendor/libarchive/dist/libarchive/archive_read_support_format_tar.c
  vendor/libarchive/dist/libarchive/test/CMakeLists.txt

Modified: vendor/libarchive/dist/Makefile.am
==
--- vendor/libarchive/dist/Makefile.am  Tue Jul 28 17:32:14 2015
(r285969)
+++ vendor/libarchive/dist/Makefile.am  Tue Jul 28 17:48:34 2015
(r285970)
@@ -395,6 +395,7 @@ libarchive_test_SOURCES=
\
libarchive/test/test_read_format_gtar_gz.c  \
libarchive/test/test_read_format_gtar_lzma.c\
libarchive/test/test_read_format_gtar_sparse.c  \
+   libarchive/test/test_read_format_gtar_sparse_skip_entry.c \
libarchive/test/test_read_format_iso_Z.c\
libarchive/test/test_read_format_iso_multi_extent.c \
libarchive/test/test_read_format_iso_xorriso.c  \
@@ -622,6 +623,7 @@ libarchive_test_EXTRA_DIST=\
libarchive/test/test_read_format_gtar_sparse_1_17_posix01.tar.uu \
libarchive/test/test_read_format_gtar_sparse_1_17_posix10.tar.uu \

libarchive/test/test_read_format_gtar_sparse_1_17_posix10_modified.tar.uu \
+   libarchive/test/test_read_format_gtar_sparse_skip_entry.tar.Z.uu \
libarchive/test/test_read_format_iso.iso.Z.uu   \
libarchive/test/test_read_format_iso_2.iso.Z.uu \
libarchive/test/test_read_format_iso_joliet.iso.Z.uu\

Modified: vendor/libarchive/dist/libarchive/archive_read_support_format_tar.c
==
--- vendor/libarchive/dist/libarchive/archive_read_support_format_tar.c Tue Jul 
28 17:32:14 2015(r285969)
+++ vendor/libarchive/dist/libarchive/archive_read_support_format_tar.c Tue Jul 
28 17:48:34 2015(r285970)
@@ -585,13 +585,23 @@ static int
 archive_read_format_tar_skip(struct archive_read *a)
 {
int64_t bytes_skipped;
+   int64_t request;
+   struct sparse_block *p;
struct tar* tar;
 
tar = (struct tar *)(a->format->data);
 
-   bytes_skipped = __archive_read_consume(a,
-   tar->entry_bytes_remaining + tar->entry_padding + 
-   tar->entry_bytes_unconsumed);
+   /* Do not consume the hole of a sparse file. */
+   request = 0;
+   for (p = tar->sparse_list; p != NULL; p = p->next) {
+   if (!p->hole)
+   request += p->remaining;
+   }
+   if (request > tar->entry_bytes_remaining)
+   request = tar->entry_bytes_remaining;
+   request += tar->entry_padding + tar->entry_bytes_unconsumed;
+
+   bytes_skipped = __archive_read_consume(a, request);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
 

Modified: vendor/libarchive/dist/libarchive/test/CMakeLists.txt
==
--- vendor/libarchive/dist/libarchive/test/CMakeLists.txt   Tue Jul 28 
17:32:14 2015(r285969)
+++ vendor/libarchive/dist/libarchive/test/CMakeLists.txt   Tue Jul 28 
17:48:34 2015(r285970)
@@ -110,6 +110,7 @@ IF(ENABLE_TEST)
 test_read_format_gtar_gz.c
 test_read_format_gtar_lzma.c
 test_read_format_gtar_sparse.c
+test_read_format_gtar_sparse_skip_entry.c
 test_read_format_iso_Z.c
 test_read_format_iso_multi_extent.c
 test_read_format_iso_xorriso.c

Added: 
vendor/libarchive/dist/libarchive/test/test_read_format_gtar_sparse_skip_entry.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
vendor/libarchive/dist/libarchive/test/test_read_format_gtar_sparse_skip_entry.c
Tue Jul 28 17:48:34 2015(r285970)
@@ -0,0 +1,119 @@
+/*-
+ * Copyright (c) 2014 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribu

svn commit: r285969 - in head/contrib/libarchive: . libarchive

2015-07-28 Thread Bryan Drewery
Author: bdrewery
Date: Tue Jul 28 17:32:14 2015
New Revision: 285969
URL: https://svnweb.freebsd.org/changeset/base/285969

Log:
  Mark vendor r285968 merged for r280870.

Modified:
Directory Properties:
  head/contrib/libarchive/   (props changed)
  head/contrib/libarchive/libarchive/   (props changed)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285967 - stable/10/sys/kern

2015-07-28 Thread Konstantin Belousov
Author: kib
Date: Tue Jul 28 17:12:41 2015
New Revision: 285967
URL: https://svnweb.freebsd.org/changeset/base/285967

Log:
  MFC r284956:
  Do not calculate the stack's bottom address twice.

Modified:
  stable/10/sys/kern/kern_exec.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_exec.c
==
--- stable/10/sys/kern/kern_exec.c  Tue Jul 28 17:08:32 2015
(r285966)
+++ stable/10/sys/kern/kern_exec.c  Tue Jul 28 17:12:41 2015
(r285967)
@@ -1116,7 +1116,7 @@ exec_new_vmspace(imgp, sv)
 * process stack so we can check the stack rlimit.
 */
vmspace->vm_ssize = sgrowsiz >> PAGE_SHIFT;
-   vmspace->vm_maxsaddr = (char *)sv->sv_usrstack - ssiz;
+   vmspace->vm_maxsaddr = (char *)stack_addr;
 
return (0);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285968 - vendor/libarchive/dist/libarchive

2015-07-28 Thread Bryan Drewery
Author: bdrewery
Date: Tue Jul 28 17:20:35 2015
New Revision: 285968
URL: https://svnweb.freebsd.org/changeset/base/285968

Log:
  Apply upstream changeset fa9e61:
  
  Fix --one-file-system to include the directory encountered rather than
  excluding it.

Modified:
  vendor/libarchive/dist/libarchive/archive_read_disk_posix.c

Modified: vendor/libarchive/dist/libarchive/archive_read_disk_posix.c
==
--- vendor/libarchive/dist/libarchive/archive_read_disk_posix.c Tue Jul 28 
17:12:41 2015(r285967)
+++ vendor/libarchive/dist/libarchive/archive_read_disk_posix.c Tue Jul 28 
17:20:35 2015(r285968)
@@ -974,7 +974,7 @@ next_entry(struct archive_read_disk *a, 
t->initial_filesystem_id = t->current_filesystem_id;
if (!a->traverse_mount_points) {
if (t->initial_filesystem_id != t->current_filesystem_id)
-   return (ARCHIVE_RETRY);
+   descend = 0;
}
t->descend = descend;
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285966 - stable/10/sys/kern

2015-07-28 Thread Konstantin Belousov
Author: kib
Date: Tue Jul 28 17:08:32 2015
New Revision: 285966
URL: https://svnweb.freebsd.org/changeset/base/285966

Log:
  MFC r285039:
  Remove asserts which might reference freed memory.

Modified:
  stable/10/sys/kern/vfs_mount.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/vfs_mount.c
==
--- stable/10/sys/kern/vfs_mount.c  Tue Jul 28 17:06:13 2015
(r285965)
+++ stable/10/sys/kern/vfs_mount.c  Tue Jul 28 17:08:32 2015
(r285966)
@@ -1108,9 +1108,6 @@ vfs_domount(
} else
error = vfs_domount_update(td, vp, fsflags, optlist);
 
-   ASSERT_VI_UNLOCKED(vp, __func__);
-   ASSERT_VOP_UNLOCKED(vp, __func__);
-
return (error);
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285965 - stable/10/share/man/man9

2015-07-28 Thread Konstantin Belousov
Author: kib
Date: Tue Jul 28 17:06:13 2015
New Revision: 285965
URL: https://svnweb.freebsd.org/changeset/base/285965

Log:
  MFC r285173:
  Document the locking context for the directly dispatched callouts.
  Cross-reference timeout(9).

Modified:
  stable/10/share/man/man9/locking.9
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/share/man/man9/locking.9
==
--- stable/10/share/man/man9/locking.9  Tue Jul 28 17:00:03 2015
(r285964)
+++ stable/10/share/man/man9/locking.9  Tue Jul 28 17:06:13 2015
(r285965)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 30, 2013
+.Dd July 5, 2015
 .Dt LOCKING 9
 .Os
 .Sh NAME
@@ -387,6 +387,7 @@ At this time this is a rather easy to re
 .It interrupt filter:  Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no
 .It interrupt thread:  Ta \&ok Ta \&ok Ta \&ok Ta \&no Ta \&no Ta \&no
 .It callout:Ta \&ok Ta \&ok Ta \&ok Ta \&no Ta \&no Ta \&no
+.It direct callout:  Ta \&ok Ta \&no Ta \&no Ta \&no Ta \&no Ta \&no
 .It system call:Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok Ta \&ok
 .El
 .Sh SEE ALSO
@@ -400,6 +401,7 @@ At this time this is a rather easy to re
 .Xr sema 9 ,
 .Xr sleep 9 ,
 .Xr sx 9 ,
+.Xr timeout 9 ,
 .Xr BUS_SETUP_INTR 9 ,
 .Xr LOCK_PROFILING 9
 .Sh HISTORY
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285964 - releng/10.2/sys/kern

2015-07-28 Thread Konstantin Belousov
Author: kib
Date: Tue Jul 28 17:00:03 2015
New Revision: 285964
URL: https://svnweb.freebsd.org/changeset/base/285964

Log:
  MFC r285134 (by mjg):
  fd: de-k&r-ify functions + some whitespace fixes
  
  MFC r285269:
  Handle copyout for the fcntl(F_OGETLK) using oflock structure.
  
  Approved by:  re (gjb)

Modified:
  releng/10.2/sys/kern/kern_descrip.c
Directory Properties:
  releng/10.2/   (props changed)

Modified: releng/10.2/sys/kern/kern_descrip.c
==
--- releng/10.2/sys/kern/kern_descrip.c Tue Jul 28 16:39:36 2015
(r285963)
+++ releng/10.2/sys/kern/kern_descrip.c Tue Jul 28 17:00:03 2015
(r285964)
@@ -418,9 +418,10 @@ kern_fcntl_freebsd(struct thread *td, in
struct flock fl;
struct __oflock ofl;
intptr_t arg1;
-   int error;
+   int error, newcmd;
 
error = 0;
+   newcmd = cmd;
switch (cmd) {
case F_OGETLK:
case F_OSETLK:
@@ -438,31 +439,31 @@ kern_fcntl_freebsd(struct thread *td, in
 
switch (cmd) {
case F_OGETLK:
-   cmd = F_GETLK;
-   break;
+   newcmd = F_GETLK;
+   break;
case F_OSETLK:
-   cmd = F_SETLK;
-   break;
+   newcmd = F_SETLK;
+   break;
case F_OSETLKW:
-   cmd = F_SETLKW;
-   break;
+   newcmd = F_SETLKW;
+   break;
}
arg1 = (intptr_t)&fl;
break;
-case F_GETLK:
-case F_SETLK:
-case F_SETLKW:
+   case F_GETLK:
+   case F_SETLK:
+   case F_SETLKW:
case F_SETLK_REMOTE:
-error = copyin((void *)(intptr_t)arg, &fl, sizeof(fl));
-arg1 = (intptr_t)&fl;
-break;
+   error = copyin((void *)(intptr_t)arg, &fl, sizeof(fl));
+   arg1 = (intptr_t)&fl;
+   break;
default:
arg1 = arg;
break;
}
if (error)
return (error);
-   error = kern_fcntl(td, fd, cmd, arg1);
+   error = kern_fcntl(td, fd, newcmd, arg1);
if (error)
return (error);
if (cmd == F_OGETLK) {
@@ -746,7 +747,7 @@ kern_fcntl(struct thread *td, int fd, in
if ((flp->l_start > 0 &&
foffset > OFF_MAX - flp->l_start) ||
(flp->l_start < 0 &&
-foffset < OFF_MIN - flp->l_start)) {
+   foffset < OFF_MIN - flp->l_start)) {
FILEDESC_SUNLOCK(fdp);
error = EOVERFLOW;
fdrop(fp, td);
@@ -954,13 +955,13 @@ funsetown(struct sigio **sigiop)
struct pgrp *pg = (sigio)->sio_pgrp;
PGRP_LOCK(pg);
SLIST_REMOVE(&sigio->sio_pgrp->pg_sigiolst, sigio,
-sigio, sio_pgsigio);
+   sigio, sio_pgsigio);
PGRP_UNLOCK(pg);
} else {
struct proc *p = (sigio)->sio_proc;
PROC_LOCK(p);
SLIST_REMOVE(&sigio->sio_proc->p_sigiolst, sigio,
-sigio, sio_pgsigio);
+   sigio, sio_pgsigio);
PROC_UNLOCK(p);
}
SIGIO_UNLOCK();
@@ -1214,18 +1215,14 @@ struct close_args {
 #endif
 /* ARGSUSED */
 int
-sys_close(td, uap)
-   struct thread *td;
-   struct close_args *uap;
+sys_close(struct thread *td, struct close_args *uap)
 {
 
return (kern_close(td, uap->fd));
 }
 
 int
-kern_close(td, fd)
-   struct thread *td;
-   int fd;
+kern_close(struct thread *td, int fd)
 {
struct filedesc *fdp;
struct file *fp;
@@ -2312,10 +2309,10 @@ closef(struct file *fp, struct thread *t
fdp = td->td_proc->p_fd;
FILEDESC_XLOCK(fdp);
for (fdtol = fdtol->fdl_next;
-fdtol != td->td_proc->p_fdtol;
-fdtol = fdtol->fdl_next) {
+   fdtol != td->td_proc->p_fdtol;
+   fdtol = fdtol->fdl_next) {
if ((fdtol->fdl_leader->p_flag &
-P_ADVLOCK) == 0)
+   P_ADVLOCK) == 0)
continue;
fdtol->fdl_holdcount++;
FILEDESC_XUNLOCK(fdp);
@@ -2933,8 +2930,7 @@ filedesc_to_leader_alloc(struct filedesc
struct filedesc_to_leader *fdtol;
 
fdtol = malloc(sizeof(struct filedesc_to_leader),
-  M_FILEDESC_TO_LEADER,

svn commit: r285963 - stable/10/sys/kern

2015-07-28 Thread Konstantin Belousov
Author: kib
Date: Tue Jul 28 16:39:36 2015
New Revision: 285963
URL: https://svnweb.freebsd.org/changeset/base/285963

Log:
  MFC r285134 (by mjg):
  fd: de-k&r-ify functions + some whitespace fixes
  
  MFC r285269:
  Handle copyout for the fcntl(F_OGETLK) using oflock structure.

Modified:
  stable/10/sys/kern/kern_descrip.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_descrip.c
==
--- stable/10/sys/kern/kern_descrip.c   Tue Jul 28 15:05:19 2015
(r285962)
+++ stable/10/sys/kern/kern_descrip.c   Tue Jul 28 16:39:36 2015
(r285963)
@@ -418,9 +418,10 @@ kern_fcntl_freebsd(struct thread *td, in
struct flock fl;
struct __oflock ofl;
intptr_t arg1;
-   int error;
+   int error, newcmd;
 
error = 0;
+   newcmd = cmd;
switch (cmd) {
case F_OGETLK:
case F_OSETLK:
@@ -438,31 +439,31 @@ kern_fcntl_freebsd(struct thread *td, in
 
switch (cmd) {
case F_OGETLK:
-   cmd = F_GETLK;
-   break;
+   newcmd = F_GETLK;
+   break;
case F_OSETLK:
-   cmd = F_SETLK;
-   break;
+   newcmd = F_SETLK;
+   break;
case F_OSETLKW:
-   cmd = F_SETLKW;
-   break;
+   newcmd = F_SETLKW;
+   break;
}
arg1 = (intptr_t)&fl;
break;
-case F_GETLK:
-case F_SETLK:
-case F_SETLKW:
+   case F_GETLK:
+   case F_SETLK:
+   case F_SETLKW:
case F_SETLK_REMOTE:
-error = copyin((void *)(intptr_t)arg, &fl, sizeof(fl));
-arg1 = (intptr_t)&fl;
-break;
+   error = copyin((void *)(intptr_t)arg, &fl, sizeof(fl));
+   arg1 = (intptr_t)&fl;
+   break;
default:
arg1 = arg;
break;
}
if (error)
return (error);
-   error = kern_fcntl(td, fd, cmd, arg1);
+   error = kern_fcntl(td, fd, newcmd, arg1);
if (error)
return (error);
if (cmd == F_OGETLK) {
@@ -746,7 +747,7 @@ kern_fcntl(struct thread *td, int fd, in
if ((flp->l_start > 0 &&
foffset > OFF_MAX - flp->l_start) ||
(flp->l_start < 0 &&
-foffset < OFF_MIN - flp->l_start)) {
+   foffset < OFF_MIN - flp->l_start)) {
FILEDESC_SUNLOCK(fdp);
error = EOVERFLOW;
fdrop(fp, td);
@@ -954,13 +955,13 @@ funsetown(struct sigio **sigiop)
struct pgrp *pg = (sigio)->sio_pgrp;
PGRP_LOCK(pg);
SLIST_REMOVE(&sigio->sio_pgrp->pg_sigiolst, sigio,
-sigio, sio_pgsigio);
+   sigio, sio_pgsigio);
PGRP_UNLOCK(pg);
} else {
struct proc *p = (sigio)->sio_proc;
PROC_LOCK(p);
SLIST_REMOVE(&sigio->sio_proc->p_sigiolst, sigio,
-sigio, sio_pgsigio);
+   sigio, sio_pgsigio);
PROC_UNLOCK(p);
}
SIGIO_UNLOCK();
@@ -1214,18 +1215,14 @@ struct close_args {
 #endif
 /* ARGSUSED */
 int
-sys_close(td, uap)
-   struct thread *td;
-   struct close_args *uap;
+sys_close(struct thread *td, struct close_args *uap)
 {
 
return (kern_close(td, uap->fd));
 }
 
 int
-kern_close(td, fd)
-   struct thread *td;
-   int fd;
+kern_close(struct thread *td, int fd)
 {
struct filedesc *fdp;
struct file *fp;
@@ -2312,10 +2309,10 @@ closef(struct file *fp, struct thread *t
fdp = td->td_proc->p_fd;
FILEDESC_XLOCK(fdp);
for (fdtol = fdtol->fdl_next;
-fdtol != td->td_proc->p_fdtol;
-fdtol = fdtol->fdl_next) {
+   fdtol != td->td_proc->p_fdtol;
+   fdtol = fdtol->fdl_next) {
if ((fdtol->fdl_leader->p_flag &
-P_ADVLOCK) == 0)
+   P_ADVLOCK) == 0)
continue;
fdtol->fdl_holdcount++;
FILEDESC_XUNLOCK(fdp);
@@ -2933,8 +2930,7 @@ filedesc_to_leader_alloc(struct filedesc
struct filedesc_to_leader *fdtol;
 
fdtol = malloc(sizeof(struct filedesc_to_leader),
-  M_FILEDESC_TO_LEADER,
-  M_WAITOK);
+   

Re: svn commit: r284959 - in head: . share/man/man4 share/man/man9 sys/conf sys/dev/glxsb sys/dev/hifn sys/dev/random sys/dev/rndtest sys/dev/safe sys/dev/syscons sys/dev/ubsec sys/dev/virtio/random s

2015-07-28 Thread Alexey Dokuchaev
On Sat, Jul 25, 2015 at 10:30:55AM -0700, John-Mark Gurney wrote:
> Alexey Dokuchaev wrote this message on Sat, Jul 25, 2015 at 14:36 +:
> > On Fri, Jul 24, 2015 at 07:59:35AM +0100, Mark R V Murray wrote:
> > > [...]
> > > > Heck, piping in mic data to /dev/random is a good way to seed the
> > > > rng on many machines.
> > > 
> > > Well, sure, but what if you don't have microphone? I want lots
> > > of choices, in anticipation of only a subset being usable.
> > 
> > I like the microphone idea.  Not just it adds another hard-to-mess-with
> > (?) entropy source, it can also be a nice "reference" example for people
> > wanting to write their own sources and plug them into the RNG framework.
> 
> Shouldn't be done in kernel, just do it from userland, by adding the
> following to cron:
> 3 *   *   *   *   rootsleep $(jot -r 1 120 1); dd 
> if=/dev/dsp bs=512 count=5 2>/dev/null | sha512  > /dev/random

Hey, that's nice, thanks!  I didn't realize from reading random(4) that it
can be fed like this.  Perhaps manpage should be updated (the cron trick
could be a nice candidate for EXAMPLES section or something)...

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


Re: svn commit: r285782 - head/usr.bin/netstat

2015-07-28 Thread Jason Unovitch
On Jul 28, 2015 10:31 AM, "Gleb Smirnoff"  wrote:
>
>   Mark, Jason,
>
> On Tue, Jul 21, 2015 at 11:57:39PM +, Mark Johnston wrote:
> M>   Fix counter reads on platforms where sizeof(uint64_t) !=
sizeof(uint64_t *).
> M>
> M>   In the kernel, structs such as tcpstat are manipulated as an array of
> M>   counter_u64_t (uint64_t *), but made visible to userland as an array
of
> M>   uint64_t. kread_counters() was previously copying the counter array
into
> M>   user space and sequentially overwriting each counter with its value.
This
> M>   mostly affects IPsec counters, as other counters are exported via
sysctl.
> M>
> M>   PR:201700
> M>   Tested by: Jason Unovitch
>
> Thanks for fixing the bug after me.
>
> One question, though: why do you use sizeof(u_long) instead of size of a
> pointer?
>

Gleb,
Mark will have to provide more details on the choice of using
sizeof(u_long). I had tested the end result of the fix. All of our
discussion on the matter was in the PR.
https://bugs.freebsd.org/201700

It hasn't been MFC'd so I'd be more than happy to test the revision so we
can MFC both commits for the fix.

> M>@
==
> M> --- head/usr.bin/netstat/main.c  Tue Jul 21 23:44:36 2015
(r285781)
> M> +++ head/usr.bin/netstat/main.c  Tue Jul 21 23:57:38 2015
(r285782)
> M> @@ -776,19 +776,31 @@ kread_counter(u_long addr)
> M>  int
> M>  kread_counters(u_long addr, void *buf, size_t size)
> M>  {
> M> -uint64_t *c = buf;
> M> +uint64_t *c;
> M> +u_long *counters;
> M> +size_t i, n;
> M>
> M>  if (kvmd_init() < 0)
> M>  return (-1);
> M>
> M> -if (kread(addr, buf, size) < 0)
> M> +if (size % sizeof(uint64_t) != 0) {
> M> +xo_warnx("kread_counters: invalid counter set size");
> M>  return (-1);
> M> +}
> M>
> M> -while (size != 0) {
> M> -*c = kvm_counter_u64_fetch(kvmd, *c);
> M> -size -= sizeof(*c);
> M> -c++;
> M> +n = size / sizeof(uint64_t);
> M> +if ((counters = malloc(n * sizeof(u_long))) == NULL)
> M> +xo_err(-1, "malloc");
> M> +if (kread(addr, counters, n * sizeof(u_long)) < 0) {
> M> +free(counters);
> M> +return (-1);
> M>  }
> M> +
> M> +c = buf;
> M> +for (i = 0; i < n; i++)
> M> +c[i] = kvm_counter_u64_fetch(kvmd, counters[i]);
> M> +
> M> +free(counters);
> M>  return (0);
> M>  }
>
> --
> Totus tuus, Glebius.

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


svn commit: r285962 - releng/10.2/release/doc/en_US.ISO8859-1/relnotes

2015-07-28 Thread Glen Barber
Author: gjb
Date: Tue Jul 28 15:05:19 2015
New Revision: 285962
URL: https://svnweb.freebsd.org/changeset/base/285962

Log:
  Fix the description for r274486.
  
  Submitted by: glebius
  Approved by:  re (implicit)
  Sponsored by: The FreeBSD Foundation

Modified:
  releng/10.2/release/doc/en_US.ISO8859-1/relnotes/article.xml

Modified: releng/10.2/release/doc/en_US.ISO8859-1/relnotes/article.xml
==
--- releng/10.2/release/doc/en_US.ISO8859-1/relnotes/article.xmlTue Jul 
28 15:03:56 2015(r285961)
+++ releng/10.2/release/doc/en_US.ISO8859-1/relnotes/article.xmlTue Jul 
28 15:05:19 2015(r285962)
@@ -504,7 +504,7 @@
 
   Network Drivers
 
-  The &man.pfil.9; interface default hash
+  The &man.pf.4; interface default hash
has been changed from Jenkins to
Murmur3, providing a 3-percent performance
increase in packets-per-second.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285961 - stable/10/release/doc/en_US.ISO8859-1/relnotes

2015-07-28 Thread Glen Barber
Author: gjb
Date: Tue Jul 28 15:03:56 2015
New Revision: 285961
URL: https://svnweb.freebsd.org/changeset/base/285961

Log:
  Fix the description for r274486.
  
  Submitted by: glebius
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml

Modified: stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml
==
--- stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml  Tue Jul 28 
14:59:29 2015(r285960)
+++ stable/10/release/doc/en_US.ISO8859-1/relnotes/article.xml  Tue Jul 28 
15:03:56 2015(r285961)
@@ -483,7 +483,7 @@
 
   Network Drivers
 
-  The &man.pfil.9; interface default hash
+  The &man.pf.4; interface default hash
has been changed from Jenkins to
Murmur3, providing a 3-percent performance
increase in packets-per-second.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285960 - head/sys/netpfil/pf

2015-07-28 Thread Renato Botelho
Author: garga (ports committer)
Date: Tue Jul 28 14:59:29 2015
New Revision: 285960
URL: https://svnweb.freebsd.org/changeset/base/285960

Log:
  Simplify logic added in r285945 as suggested by glebius
  
  Approved by:  glebius
  MFC after:3 days
  Sponsored by: Netgate

Modified:
  head/sys/netpfil/pf/pf.c

Modified: head/sys/netpfil/pf/pf.c
==
--- head/sys/netpfil/pf/pf.cTue Jul 28 14:20:33 2015(r285959)
+++ head/sys/netpfil/pf/pf.cTue Jul 28 14:59:29 2015(r285960)
@@ -5895,8 +5895,7 @@ done:
!((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
action = PF_DROP;
REASON_SET(&reason, PFRES_IPOPTIONS);
-   if (r->log)
-   log = 1;
+   log = r->log;
DPFPRINTF(PF_DEBUG_MISC,
("pf: dropping packet with ip options\n"));
}
@@ -6330,8 +6329,7 @@ done:
!((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
action = PF_DROP;
REASON_SET(&reason, PFRES_IPOPTIONS);
-   if (r->log)
-   log = 1;
+   log = r->log;
DPFPRINTF(PF_DEBUG_MISC,
("pf: dropping packet with dangerous v6 headers\n"));
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r285945 - head/sys/netpfil/pf

2015-07-28 Thread Gleb Smirnoff
  Renato,

On Tue, Jul 28, 2015 at 10:18:57AM -0300, Renato Botelho wrote:
R> Thanks for pointing this out. Do you approve the following patch?
R> 
R> Index: sys/netpfil/pf/pf.c
R> ===
R> --- sys/netpfil/pf/pf.c  (revision 285945)
R> +++ sys/netpfil/pf/pf.c  (working copy)
R> @@ -5895,8 +5895,7 @@
R>  !((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
R>  action = PF_DROP;
R>  REASON_SET(&reason, PFRES_IPOPTIONS);
R> -if (r->log)
R> -log = 1;
R> +log = r->log;
R>  DPFPRINTF(PF_DEBUG_MISC,
R>  ("pf: dropping packet with ip options\n"));
R>  }
R> @@ -6330,8 +6329,7 @@
R>  !((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
R>  action = PF_DROP;
R>  REASON_SET(&reason, PFRES_IPOPTIONS);
R> -if (r->log)
R> -log = 1;
R> +log = r->log;
R>  DPFPRINTF(PF_DEBUG_MISC,
R>  ("pf: dropping packet with dangerous v6 headers\n"));
R>  }

Yes, this looks better. Thanks.

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


Re: svn commit: r285782 - head/usr.bin/netstat

2015-07-28 Thread Gleb Smirnoff
  Mark, Jason,

On Tue, Jul 21, 2015 at 11:57:39PM +, Mark Johnston wrote:
M>   Fix counter reads on platforms where sizeof(uint64_t) != sizeof(uint64_t 
*).
M>   
M>   In the kernel, structs such as tcpstat are manipulated as an array of
M>   counter_u64_t (uint64_t *), but made visible to userland as an array of
M>   uint64_t. kread_counters() was previously copying the counter array into
M>   user space and sequentially overwriting each counter with its value. This
M>   mostly affects IPsec counters, as other counters are exported via sysctl.
M>   
M>   PR:201700
M>   Tested by: Jason Unovitch

Thanks for fixing the bug after me.

One question, though: why do you use sizeof(u_long) instead of size of a
pointer?

M> 
==
M> --- head/usr.bin/netstat/main.c  Tue Jul 21 23:44:36 2015
(r285781)
M> +++ head/usr.bin/netstat/main.c  Tue Jul 21 23:57:38 2015
(r285782)
M> @@ -776,19 +776,31 @@ kread_counter(u_long addr)
M>  int
M>  kread_counters(u_long addr, void *buf, size_t size)
M>  {
M> -uint64_t *c = buf;
M> +uint64_t *c;
M> +u_long *counters;
M> +size_t i, n;
M>  
M>  if (kvmd_init() < 0)
M>  return (-1);
M>  
M> -if (kread(addr, buf, size) < 0)
M> +if (size % sizeof(uint64_t) != 0) {
M> +xo_warnx("kread_counters: invalid counter set size");
M>  return (-1);
M> +}
M>  
M> -while (size != 0) {
M> -*c = kvm_counter_u64_fetch(kvmd, *c);
M> -size -= sizeof(*c);
M> -c++;
M> +n = size / sizeof(uint64_t);
M> +if ((counters = malloc(n * sizeof(u_long))) == NULL)
M> +xo_err(-1, "malloc");
M> +if (kread(addr, counters, n * sizeof(u_long)) < 0) {
M> +free(counters);
M> +return (-1);
M>  }
M> +
M> +c = buf;
M> +for (i = 0; i < n; i++)
M> +c[i] = kvm_counter_u64_fetch(kvmd, counters[i]);
M> +
M> +free(counters);
M>  return (0);
M>  }

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


svn commit: r285959 - head/sys/contrib/alpine-hal

2015-07-28 Thread Zbigniew Bodek
Author: zbb
Date: Tue Jul 28 14:20:33 2015
New Revision: 285959
URL: https://svnweb.freebsd.org/changeset/base/285959

Log:
  Import Annapurna Labs Alpine HAL to sys/contrib/
  
  Import from vendor-sys/alpine-hal/2.7
  SVN rev.: 285432
  HAL version: 2.7
  
  Obtained from:  Semihalf
  Sponsored by:   Annapurna Labs

Added:
  head/sys/contrib/alpine-hal/
 - copied from r285958, vendor-sys/alpine-hal/2.7/
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285958 - head/release/doc/en_US.ISO8859-1/relnotes

2015-07-28 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jul 28 13:48:19 2015
New Revision: 285958
URL: https://svnweb.freebsd.org/changeset/base/285958

Log:
  Fix the r272906 description.

Modified:
  head/release/doc/en_US.ISO8859-1/relnotes/article.xml

Modified: head/release/doc/en_US.ISO8859-1/relnotes/article.xml
==
--- head/release/doc/en_US.ISO8859-1/relnotes/article.xml   Tue Jul 28 
13:16:08 2015(r285957)
+++ head/release/doc/en_US.ISO8859-1/relnotes/article.xml   Tue Jul 28 
13:48:19 2015(r285958)
@@ -1049,7 +1049,7 @@
   The &man.alc.4; driver has been updated
to support AR816x and AR817x ethernet controllers.
 
-  The &man.pfil.9; interface default hash
+  The &man.pf.4; packet filter default hash
has been changed from Jenkins to
Murmur3, providing a 3-percent performance
increase in packets-per-second.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r285945 - head/sys/netpfil/pf

2015-07-28 Thread Renato Botelho
> On Jul 28, 2015, at 08:20, Gleb Smirnoff  wrote:
> 
>  Renato,
> 
> On Tue, Jul 28, 2015 at 10:31:35AM +, Renato Botelho wrote:
> R> Author: garga (ports committer)
> R> Date: Tue Jul 28 10:31:34 2015
> R> New Revision: 285945
> R> URL: https://svnweb.freebsd.org/changeset/base/285945
> R> 
> R> Log:
> R>   Respect pf rule log option before log dropped packets with IP options or
> R>   dangerous v6 headers
> R>   
> R>   Reviewed by: gnn, eri
> R>   Approved by: gnn
> R>   Obtained from:   pfSense
> R>   MFC after:   3 days
> R>   Sponsored by:Netgate
> R>   Differential Revision:   https://reviews.freebsd.org/D3222
> R> 
> R> Modified:
> R>   head/sys/netpfil/pf/pf.c
> R> 
> R> Modified: head/sys/netpfil/pf/pf.c
> R> 
> ==
> R> --- head/sys/netpfil/pf/pf.c   Tue Jul 28 09:36:26 2015
> (r285944)
> R> +++ head/sys/netpfil/pf/pf.c   Tue Jul 28 10:31:34 2015
> (r285945)
> R> @@ -5895,7 +5895,8 @@ done:
> R>!((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
> R>action = PF_DROP;
> R>REASON_SET(&reason, PFRES_IPOPTIONS);
> R> -  log = 1;
> R> +  if (r->log)
> R> +  log = 1;
> R>DPFPRINTF(PF_DEBUG_MISC,
> R>("pf: dropping packet with ip options\n"));
> R>}
> R> @@ -6329,7 +6330,8 @@ done:
> R>!((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
> R>action = PF_DROP;
> R>REASON_SET(&reason, PFRES_IPOPTIONS);
> R> -  log = 1;
> R> +  if (r->log)
> R> +  log = 1;
> R>DPFPRINTF(PF_DEBUG_MISC,
> R>("pf: dropping packet with dangerous v6 headers\n"));
> R>}
> 
> Why not simply:
> 
>   log = r->log;
> 
> ?
> 
> That would also match the style of the function, since it already has:
> 
>   log = s->log;

Thanks for pointing this out. Do you approve the following patch?

Index: sys/netpfil/pf/pf.c
===
--- sys/netpfil/pf/pf.c (revision 285945)
+++ sys/netpfil/pf/pf.c (working copy)
@@ -5895,8 +5895,7 @@
!((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
action = PF_DROP;
REASON_SET(&reason, PFRES_IPOPTIONS);
-   if (r->log)
-   log = 1;
+   log = r->log;
DPFPRINTF(PF_DEBUG_MISC,
("pf: dropping packet with ip options\n"));
}
@@ -6330,8 +6329,7 @@
!((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
action = PF_DROP;
REASON_SET(&reason, PFRES_IPOPTIONS);
-   if (r->log)
-   log = 1;
+   log = r->log;
DPFPRINTF(PF_DEBUG_MISC,
("pf: dropping packet with dangerous v6 headers\n"));
}

--
Renato Botelho

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


svn commit: r285957 - head/sys/dev/ofw

2015-07-28 Thread Zbigniew Bodek
Author: zbb
Date: Tue Jul 28 13:16:08 2015
New Revision: 285957
URL: https://svnweb.freebsd.org/changeset/base/285957

Log:
  Limit ofw_cpu_early_foreach() to CPUs only
  
  On some platforms, the /cpus node contains cpu-to-cluster
  map which deffinitely is not a CPU node. Its presence was
  causing incrementing of "id" variable and reporting more
  CPUs available than it should.
  To make "id" valid, increment it only when an entry really
  is a CPU device.
  
  Reviewed by:   andrew
  Obtained from: Semihalf
  Sponsored by:  The FreeBSD Foundation
  Differential Revision: https://reviews.freebsd.org/D3216

Modified:
  head/sys/dev/ofw/ofw_cpu.c

Modified: head/sys/dev/ofw/ofw_cpu.c
==
--- head/sys/dev/ofw/ofw_cpu.c  Tue Jul 28 13:11:31 2015(r285956)
+++ head/sys/dev/ofw/ofw_cpu.c  Tue Jul 28 13:16:08 2015(r285957)
@@ -281,11 +281,13 @@ ofw_cpu_early_foreach(ofw_cpu_foreach_cb
phandle_t node, child;
pcell_t addr_cells, reg[2];
char status[16];
-   u_int id;
+   char device_type[16];
+   u_int id, next_id;
int count, rv;
 
count = 0;
id = 0;
+   next_id = 0;
 
node = OF_finddevice("/cpus");
if (node == -1)
@@ -296,7 +298,21 @@ ofw_cpu_early_foreach(ofw_cpu_foreach_cb
sizeof(addr_cells)) < 0)
return (-1);
 
-   for (child = OF_child(node); child != 0; child = OF_peer(child), id++) {
+   for (child = OF_child(node); child != 0; child = OF_peer(child),
+   id = next_id) {
+
+   /* Check if child is a CPU */
+   memset(device_type, 0, sizeof(device_type));
+   rv = OF_getprop(child, "device_type", device_type,
+   sizeof(device_type) - 1);
+   if (rv < 0)
+   continue;
+   if (strcmp(device_type, "cpu") != 0)
+   continue;
+
+   /* We're processing CPU, update next_id used in the next 
iteration */
+   next_id++;
+
/*
 * If we are filtering by runnable then limit to only
 * those that have been enabled.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285956 - releng/10.2/sys/boot/efi/libefi

2015-07-28 Thread Ed Maste
Author: emaste
Date: Tue Jul 28 13:11:31 2015
New Revision: 285956
URL: https://svnweb.freebsd.org/changeset/base/285956

Log:
  MFS r285951: Avoid creating invalid UEFI device path
  
  The UEFI loader on the 10.1 release install disk (disc1) modifies an
  existing EFI_DEVICE_PATH_PROTOCOL instance in an apparent attempt to
  truncate the device path.  In doing so it creates an invalid device
  path.
  
  Perform the equivalent action without modification of structures
  allocated by firmware.
  
  PR:   197641
  Submitted by: Chris Ruffin 
  Approved by:  re (gjb)

Modified:
  releng/10.2/sys/boot/efi/libefi/efipart.c
Directory Properties:
  releng/10.2/   (props changed)

Modified: releng/10.2/sys/boot/efi/libefi/efipart.c
==
--- releng/10.2/sys/boot/efi/libefi/efipart.c   Tue Jul 28 13:09:16 2015
(r285955)
+++ releng/10.2/sys/boot/efi/libefi/efipart.c   Tue Jul 28 13:11:31 2015
(r285956)
@@ -63,13 +63,14 @@ static int
 efipart_init(void) 
 {
EFI_BLOCK_IO *blkio;
-   EFI_DEVICE_PATH *devpath, *node;
+   EFI_DEVICE_PATH *devpath, *devpathcpy, *tmpdevpath, *node;
EFI_HANDLE *hin, *hout, *aliases, handle;
EFI_STATUS status;
UINTN sz;
CHAR16 *path;
u_int n, nin, nout;
int err;
+   size_t devpathlen;
 
sz = 0;
hin = NULL;
@@ -98,9 +99,15 @@ efipart_init(void) 
if (EFI_ERROR(status)) {
continue;
}
+
node = devpath;
-   while (!IsDevicePathEnd(NextDevicePathNode(node)))
+   devpathlen = DevicePathNodeLength(node);
+   while (!IsDevicePathEnd(NextDevicePathNode(node))) {
node = NextDevicePathNode(node);
+   devpathlen += DevicePathNodeLength(node);
+   }
+   devpathlen += DevicePathNodeLength(NextDevicePathNode(node));
+
status = BS->HandleProtocol(hin[n], &blkio_guid,
(void**)&blkio);
if (EFI_ERROR(status))
@@ -117,10 +124,16 @@ efipart_init(void) 
 */
if (DevicePathType(node) == MEDIA_DEVICE_PATH &&
DevicePathSubType(node) == MEDIA_CDROM_DP) {
-   node->Type = END_DEVICE_PATH_TYPE;
-   node->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
-   status = BS->LocateDevicePath(&blkio_guid, &devpath,
+   devpathcpy = malloc(devpathlen);
+   memcpy(devpathcpy, devpath, devpathlen);
+   node = devpathcpy;
+   while (!IsDevicePathEnd(NextDevicePathNode(node)))
+   node = NextDevicePathNode(node);
+   SetDevicePathEndNode(node);
+   tmpdevpath = devpathcpy;
+   status = BS->LocateDevicePath(&blkio_guid, &tmpdevpath,
&handle);
+   free(devpathcpy);
if (EFI_ERROR(status))
continue;
hout[nout] = handle;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285955 - head/contrib/llvm/tools/lldb/docs

2015-07-28 Thread Ed Maste
Author: emaste
Date: Tue Jul 28 13:09:16 2015
New Revision: 285955
URL: https://svnweb.freebsd.org/changeset/base/285955

Log:
  Remove claim that the OS is Darwin from lldb(1)
  
  Reported by:  bapt

Modified:
  head/contrib/llvm/tools/lldb/docs/lldb.1

Modified: head/contrib/llvm/tools/lldb/docs/lldb.1
==
--- head/contrib/llvm/tools/lldb/docs/lldb.1Tue Jul 28 12:57:19 2015
(r285954)
+++ head/contrib/llvm/tools/lldb/docs/lldb.1Tue Jul 28 13:09:16 2015
(r285955)
@@ -1,6 +1,6 @@
 .Dd June 7, 2012 \" DATE
 .Dt LLDB 1   \" Program name and manual section number
-.Os Darwin   \" Operating System
+.Os
 .Sh NAME \" Section Header - required - don't modify
 .Nm lldb
 .Nd The debugger
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2015-07-28 Thread Ed Schouten
Author: ed
Date: Tue Jul 28 12:57:19 2015
New Revision: 285954
URL: https://svnweb.freebsd.org/changeset/base/285954

Log:
  Implement file attribute modification system calls for CloudABI.
  
  CloudABI uses a system call interface to modify file attributes that is
  more similar to KPI's/FUSE, namely where a stat structure is passed back
  to the kernel, together with a bitmask of attributes that should be
  changed. This would allow us to update any set of attributes atomically.
  
  That said, I'd rather not go as far as to actually implement it that
  way, as it would require us to duplicate more code than strictly needed.
  Let's just stick to the combinations that are actually used by
  cloudlibc.
  
  Obtained from:https://github.com/NuxiNL/freebsd

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

Modified: head/sys/compat/cloudabi/cloudabi_file.c
==
--- head/sys/compat/cloudabi/cloudabi_file.cTue Jul 28 12:52:22 2015
(r285953)
+++ head/sys/compat/cloudabi/cloudabi_file.cTue Jul 28 12:57:19 2015
(r285954)
@@ -292,13 +292,64 @@ cloudabi_sys_file_stat_fget(struct threa
return (copyout(&csb, uap->buf, sizeof(csb)));
 }
 
+/* Converts timestamps to arguments to futimens() and utimensat(). */
+static void
+convert_utimens_arguments(const cloudabi_filestat_t *fs,
+cloudabi_fsflags_t flags, struct timespec *ts)
+{
+
+   if ((flags & CLOUDABI_FILESTAT_ATIM_NOW) != 0) {
+   ts[0].tv_nsec = UTIME_NOW;
+   } else if ((flags & CLOUDABI_FILESTAT_ATIM) != 0) {
+   ts[0].tv_sec = fs->st_atim / 10;
+   ts[0].tv_nsec = fs->st_atim % 10;
+   } else {
+   ts[0].tv_nsec = UTIME_OMIT;
+   }
+
+   if ((flags & CLOUDABI_FILESTAT_MTIM_NOW) != 0) {
+   ts[1].tv_nsec = UTIME_NOW;
+   } else if ((flags & CLOUDABI_FILESTAT_MTIM) != 0) {
+   ts[1].tv_sec = fs->st_mtim / 10;
+   ts[1].tv_nsec = fs->st_mtim % 10;
+   } else {
+   ts[1].tv_nsec = UTIME_OMIT;
+   }
+}
+
 int
 cloudabi_sys_file_stat_fput(struct thread *td,
 struct cloudabi_sys_file_stat_fput_args *uap)
 {
+   cloudabi_filestat_t fs;
+   struct timespec ts[2];
+   int error;
+
+   error = copyin(uap->buf, &fs, sizeof(fs));
+   if (error != 0)
+   return (error);
 
-   /* Not implemented. */
-   return (ENOSYS);
+   /*
+* Only support truncation and timestamp modification separately
+* for now, to prevent unnecessary code duplication.
+*/
+   if ((uap->flags & CLOUDABI_FILESTAT_SIZE) != 0) {
+   /* Call into kern_ftruncate() for file truncation. */
+   if ((uap->flags & ~CLOUDABI_FILESTAT_SIZE) != 0)
+   return (EINVAL);
+   return (kern_ftruncate(td, uap->fd, fs.st_size));
+   } else if ((uap->flags & (CLOUDABI_FILESTAT_ATIM |
+   CLOUDABI_FILESTAT_ATIM_NOW | CLOUDABI_FILESTAT_MTIM |
+   CLOUDABI_FILESTAT_MTIM_NOW)) != 0) {
+   /* Call into kern_futimens() for timestamp modification. */
+   if ((uap->flags & ~(CLOUDABI_FILESTAT_ATIM |
+   CLOUDABI_FILESTAT_ATIM_NOW | CLOUDABI_FILESTAT_MTIM |
+   CLOUDABI_FILESTAT_MTIM_NOW)) != 0)
+   return (EINVAL);
+   convert_utimens_arguments(&fs, uap->flags, ts);
+   return (kern_futimens(td, uap->fd, ts, UIO_SYSSPACE));
+   }
+   return (EINVAL);
 }
 
 int
@@ -347,9 +398,33 @@ int
 cloudabi_sys_file_stat_put(struct thread *td,
 struct cloudabi_sys_file_stat_put_args *uap)
 {
+   cloudabi_filestat_t fs;
+   struct timespec ts[2];
+   char *path;
+   int error;
+
+   /*
+* Only support timestamp modification for now, as there is no
+* truncateat().
+*/
+   if ((uap->flags & ~(CLOUDABI_FILESTAT_ATIM |
+   CLOUDABI_FILESTAT_ATIM_NOW | CLOUDABI_FILESTAT_MTIM |
+   CLOUDABI_FILESTAT_MTIM_NOW)) != 0)
+   return (EINVAL);
 
-   /* Not implemented. */
-   return (ENOSYS);
+   error = copyin(uap->buf, &fs, sizeof(fs));
+   if (error != 0)
+   return (error);
+   error = copyin_path(uap->path, uap->pathlen, &path);
+   if (error != 0)
+   return (error);
+
+   convert_utimens_arguments(&fs, uap->flags, ts);
+   error = kern_utimensat(td, uap->fd, path, UIO_SYSSPACE, ts,
+   UIO_SYSSPACE, (uap->fd & CLOUDABI_LOOKUP_SYMLINK_FOLLOW) != 0 ?
+   0 : AT_SYMLINK_NOFOLLOW);
+   cloudabi_freestr(path);
+   return (error);
 }
 
 int
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285953 - releng/10.2/usr.sbin/mfiutil

2015-07-28 Thread Ed Maste
Author: emaste
Date: Tue Jul 28 12:52:22 2015
New Revision: 285953
URL: https://svnweb.freebsd.org/changeset/base/285953

Log:
  MFS r285950: mfiutil: increase buffer size to accommodate sprintf string
  
  PR:   201289
  Approved by:  re (gjb)

Modified:
  releng/10.2/usr.sbin/mfiutil/mfi_foreign.c
Directory Properties:
  releng/10.2/   (props changed)

Modified: releng/10.2/usr.sbin/mfiutil/mfi_foreign.c
==
--- releng/10.2/usr.sbin/mfiutil/mfi_foreign.c  Tue Jul 28 12:46:37 2015
(r285952)
+++ releng/10.2/usr.sbin/mfiutil/mfi_foreign.c  Tue Jul 28 12:52:22 2015
(r285953)
@@ -110,7 +110,7 @@ static int
 foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic)
 {
struct mfi_config_data *config;
-   char prefix[26];
+   char prefix[64];
int error;
uint8_t mbox[4];
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285952 - stable/10/usr.bin/clang/lldb

2015-07-28 Thread Ed Maste
Author: emaste
Date: Tue Jul 28 12:46:37 2015
New Revision: 285952
URL: https://svnweb.freebsd.org/changeset/base/285952

Log:
  MFC r285248: lldb: use .PATH to find man page instead of symlinking it

Modified:
  stable/10/usr.bin/clang/lldb/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/clang/lldb/Makefile
==
--- stable/10/usr.bin/clang/lldb/Makefile   Tue Jul 28 12:45:08 2015
(r285951)
+++ stable/10/usr.bin/clang/lldb/Makefile   Tue Jul 28 12:46:37 2015
(r285952)
@@ -13,8 +13,8 @@ SRCDIR=   tools/lldb/tools/driver
 SRCS=  Driver.cpp \
Platform.cpp
 
-lldb.1:
-   ln -fs ${LLDB_SRCS}/docs/lldb.1 ${.TARGET}
+# Man page directory
+.PATH: ${LLDB_SRCS}/docs
 
 DPADD= ${LIBEDIT} ${LIBNCURSESW} ${LIBEXECINFO} ${LIBPANEL}
 LDADD= -ledit -lncursesw -lexecinfo -lpanel
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285951 - stable/10/sys/boot/efi/libefi

2015-07-28 Thread Ed Maste
Author: emaste
Date: Tue Jul 28 12:45:08 2015
New Revision: 285951
URL: https://svnweb.freebsd.org/changeset/base/285951

Log:
  MFC r285246: Avoid creating invalid UEFI device path
  
  The UEFI loader on the 10.1 release install disk (disc1) modifies an
  existing EFI_DEVICE_PATH_PROTOCOL instance in an apparent attempt to
  truncate the device path.  In doing so it creates an invalid device
  path.
  
  Perform the equivalent action without modification of structures
  allocated by firmware.
  
  PR:   197641
  Submitted by: Chris Ruffin 

Modified:
  stable/10/sys/boot/efi/libefi/efipart.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/boot/efi/libefi/efipart.c
==
--- stable/10/sys/boot/efi/libefi/efipart.c Tue Jul 28 12:40:41 2015
(r285950)
+++ stable/10/sys/boot/efi/libefi/efipart.c Tue Jul 28 12:45:08 2015
(r285951)
@@ -63,13 +63,14 @@ static int
 efipart_init(void) 
 {
EFI_BLOCK_IO *blkio;
-   EFI_DEVICE_PATH *devpath, *node;
+   EFI_DEVICE_PATH *devpath, *devpathcpy, *tmpdevpath, *node;
EFI_HANDLE *hin, *hout, *aliases, handle;
EFI_STATUS status;
UINTN sz;
CHAR16 *path;
u_int n, nin, nout;
int err;
+   size_t devpathlen;
 
sz = 0;
hin = NULL;
@@ -98,9 +99,15 @@ efipart_init(void) 
if (EFI_ERROR(status)) {
continue;
}
+
node = devpath;
-   while (!IsDevicePathEnd(NextDevicePathNode(node)))
+   devpathlen = DevicePathNodeLength(node);
+   while (!IsDevicePathEnd(NextDevicePathNode(node))) {
node = NextDevicePathNode(node);
+   devpathlen += DevicePathNodeLength(node);
+   }
+   devpathlen += DevicePathNodeLength(NextDevicePathNode(node));
+
status = BS->HandleProtocol(hin[n], &blkio_guid,
(void**)&blkio);
if (EFI_ERROR(status))
@@ -117,10 +124,16 @@ efipart_init(void) 
 */
if (DevicePathType(node) == MEDIA_DEVICE_PATH &&
DevicePathSubType(node) == MEDIA_CDROM_DP) {
-   node->Type = END_DEVICE_PATH_TYPE;
-   node->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
-   status = BS->LocateDevicePath(&blkio_guid, &devpath,
+   devpathcpy = malloc(devpathlen);
+   memcpy(devpathcpy, devpath, devpathlen);
+   node = devpathcpy;
+   while (!IsDevicePathEnd(NextDevicePathNode(node)))
+   node = NextDevicePathNode(node);
+   SetDevicePathEndNode(node);
+   tmpdevpath = devpathcpy;
+   status = BS->LocateDevicePath(&blkio_guid, &tmpdevpath,
&handle);
+   free(devpathcpy);
if (EFI_ERROR(status))
continue;
hout[nout] = handle;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2015-07-28 Thread Gleb Smirnoff
  Ermal,

  see comments inlined,

On Thu, Jul 02, 2015 at 06:10:42PM +, Ermal Luçi wrote:
E> Author: eri
E> Date: Thu Jul  2 18:10:41 2015
E> New Revision: 285051
E> URL: https://svnweb.freebsd.org/changeset/base/285051
E> 
E> Log:
E>   Avoid doing multiple route lookups for the same destination IP during 
forwarding
E>   
E>   ip_forward() does a route lookup for testing this packet can be sent to a 
known destination,
E>   it also can do another route lookup if it detects that an ICMP redirect is 
needed,
E>   it forgets all of this and handovers to ip_output() to do the same lookup 
yet again.
E>   
E>   This optimisation just does one route lookup during the forwarding path 
and handovers that to be considered by ip_output().
E>   
E>   Differential Revision: https://reviews.freebsd.org/D2964
E>   Approved by:   ae, gnn(mentor)
E>   MFC after: 1 week
E> 
E> Modified:
E>   head/sys/netinet/ip_input.c
E> 
E> Modified: head/sys/netinet/ip_input.c
E> 
==
E> --- head/sys/netinet/ip_input.c  Thu Jul  2 17:30:59 2015
(r285050)
E> +++ head/sys/netinet/ip_input.c  Thu Jul  2 18:10:41 2015
(r285051)
E> @@ -897,6 +897,7 @@ ip_forward(struct mbuf *m, int srcrt)
E>  struct ip *ip = mtod(m, struct ip *);
E>  struct in_ifaddr *ia;
E>  struct mbuf *mcopy;
E> +struct sockaddr_in *sin;
E>  struct in_addr dest;
E>  struct route ro;
E>  int error, type = 0, code = 0, mtu = 0;
E> @@ -925,7 +926,22 @@ ip_forward(struct mbuf *m, int srcrt)
E>  }
E>  #endif
E>  
E> -ia = ip_rtaddr(ip->ip_dst, M_GETFIB(m));
E> +bzero(&ro, sizeof(ro));
E> +sin = (struct sockaddr_in *)&ro.ro_dst;
E> +sin->sin_family = AF_INET;
E> +sin->sin_len = sizeof(*sin);
E> +sin->sin_addr = ip->ip_dst;
E> +#ifdef RADIX_MPATH
E> +rtalloc_mpath_fib(&ro,
E> +ntohl(ip->ip_src.s_addr ^ ip->ip_dst.s_addr),
E> +M_GETFIB(m));
E> +#else
E> +in_rtalloc_ign(&ro, 0, M_GETFIB(m));
E> +#endif
E> +if (ro.ro_rt != NULL) {
E> +ia = ifatoia(ro.ro_rt->rt_ifa);
E> +ifa_ref(&ia->ia_ifa);
E> +}
E>  #ifndef IPSEC
E>  /*
E>   * 'ia' may be NULL if there is no route for this destination.
E> @@ -934,6 +950,7 @@ ip_forward(struct mbuf *m, int srcrt)
E>   */
E>  if (!srcrt && ia == NULL) {
E>  icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, 0, 0);
E> +RO_RTFREE(&ro);
E>  return;
E>  }

Here the ifa reference is leaked upon return.


But don't hurry with fixing that :) Actually you don't need to ifa_ref()
in this function. You acquired a reference on rtentry in in_rtalloc_ign()
and hold it until RO_RTFREE(). And the rtentry itself always holds a
reference on the ifa. So, there is no reason to put extra reference on
the ifa.

The ip_output() was already improved in r262747. And ip_forward() can
also be. The only place that touches ia after RO_RTFREE() is EMSGSIZE
handling, this can be moved up before RO_RTFREE().

Here is suggested patch. Ermal and Oliver, can you please test/benchmark
it?

-- 
Totus tuus, Glebius.
Index: ip_input.c
===
--- ip_input.c	(revision 285945)
+++ ip_input.c	(working copy)
@@ -938,10 +938,9 @@ ip_forward(struct mbuf *m, int srcrt)
 #else
 	in_rtalloc_ign(&ro, 0, M_GETFIB(m));
 #endif
-	if (ro.ro_rt != NULL) {
+	if (ro.ro_rt != NULL)
 		ia = ifatoia(ro.ro_rt->rt_ifa);
-		ifa_ref(&ia->ia_ifa);
-	} else
+	else
 		ia = NULL;
 #ifndef IPSEC
 	/*
@@ -1031,9 +1030,33 @@ ip_forward(struct mbuf *m, int srcrt)
 	}
 
 	error = ip_output(m, NULL, &ro, IP_FORWARDING, NULL, NULL);
-
-	if (error == EMSGSIZE && ro.ro_rt)
-		mtu = ro.ro_rt->rt_mtu;
+	if (error == EMSGSIZE) {
+		if (ro.ro_rt != NULL)
+			mtu = ro.ro_rt->rt_mtu;
+#ifdef IPSEC
+		/* 
+		 * If IPsec is configured for this path,
+		 * override any possibly mtu value set by ip_output.
+		 */ 
+		mtu = ip_ipsec_mtu(mcopy, mtu);
+#endif /* IPSEC */
+		/*
+		 * If the MTU was set before make sure we are below the
+		 * interface MTU.
+		 * If the MTU wasn't set before use the interface mtu or
+		 * fall back to the next smaller mtu step compared to the
+		 * current packet size.
+		 */
+		if (mtu != 0) {
+			if (ia != NULL)
+mtu = min(mtu, ia->ia_ifp->if_mtu);
+		} else {
+			if (ia != NULL)
+mtu = ia->ia_ifp->if_mtu;
+			else
+mtu = ip_next_mtu(ntohs(ip->ip_len), 0);
+		}
+	}
 	RO_RTFREE(&ro);
 
 	if (error)
@@ -1045,16 +1068,11 @@ ip_forward(struct mbuf *m, int srcrt)
 		else {
 			if (mcopy)
 m_freem(mcopy);
-			if (ia != NULL)
-ifa_free(&ia->ia_ifa);
 			return;
 		}
 	}
-	if (mcopy == NULL) {
-		if (ia != NULL)
-			ifa_free(&ia->ia_ifa);
+	if (mcopy == NULL)
 		return;
-	}
 
 	switch (error) {
 
@@ -1074,30 +1092,6 @@ ip_forward(struct mbuf *m, int srcrt)
 	case EMSGSIZE:
 		type = ICMP_UNREACH;
 		code = ICMP_UNREACH_NEEDFRAG;
-
-#ifdef IPSEC
-		/* 
-		 * I

svn commit: r285950 - stable/10/usr.sbin/mfiutil

2015-07-28 Thread Ed Maste
Author: emaste
Date: Tue Jul 28 12:40:41 2015
New Revision: 285950
URL: https://svnweb.freebsd.org/changeset/base/285950

Log:
  MFC r201289: mfiutil: increase buffer size to accommodate sprintf string
  
  PR:   201289

Modified:
  stable/10/usr.sbin/mfiutil/mfi_foreign.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/mfiutil/mfi_foreign.c
==
--- stable/10/usr.sbin/mfiutil/mfi_foreign.cTue Jul 28 12:40:09 2015
(r285949)
+++ stable/10/usr.sbin/mfiutil/mfi_foreign.cTue Jul 28 12:40:41 2015
(r285950)
@@ -110,7 +110,7 @@ static int
 foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic)
 {
struct mfi_config_data *config;
-   char prefix[26];
+   char prefix[64];
int error;
uint8_t mbox[4];
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285949 - stable/9/usr.sbin/mfiutil

2015-07-28 Thread Ed Maste
Author: emaste
Date: Tue Jul 28 12:40:09 2015
New Revision: 285949
URL: https://svnweb.freebsd.org/changeset/base/285949

Log:
  MFC r285067: mfiutil: increase buffer size to accommodate sprintf string
  
  PR:   201289

Modified:
  stable/9/usr.sbin/mfiutil/mfi_foreign.c
Directory Properties:
  stable/9/usr.sbin/mfiutil/   (props changed)

Modified: stable/9/usr.sbin/mfiutil/mfi_foreign.c
==
--- stable/9/usr.sbin/mfiutil/mfi_foreign.c Tue Jul 28 12:20:57 2015
(r285948)
+++ stable/9/usr.sbin/mfiutil/mfi_foreign.c Tue Jul 28 12:40:09 2015
(r285949)
@@ -110,7 +110,7 @@ static int
 foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic)
 {
struct mfi_config_data *config;
-   char prefix[26];
+   char prefix[64];
int error;
uint8_t mbox[4];
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2015-07-28 Thread Baptiste Daroussin
Author: bapt
Date: Tue Jul 28 12:20:57 2015
New Revision: 285948
URL: https://svnweb.freebsd.org/changeset/base/285948

Log:
  when -n is passed to any pw subcommand it is always expected to be considered 
as
  a name so do not try to convert it to an id if it is a numeric value
  
  PR:   31933
  Reported by:  t...@impulse.net
  Sponsored by: gandi.net

Modified:
  head/usr.sbin/pw/pw.c
  head/usr.sbin/pw/tests/pw_userdel.sh

Modified: head/usr.sbin/pw/pw.c
==
--- head/usr.sbin/pw/pw.c   Tue Jul 28 11:21:33 2015(r285947)
+++ head/usr.sbin/pw/pw.c   Tue Jul 28 12:20:57 2015(r285948)
@@ -287,14 +287,7 @@ main(int argc, char *argv[])
errstr);
break;
case 'n':
-   if (strspn(optarg, "0123456789") != strlen(optarg)) {
-   name = optarg;
-   break;
-   }
-   id = strtonum(optarg, 0, LONG_MAX, &errstr);
-   if (errstr != NULL)
-   errx(EX_USAGE, "Bad id '%s': %s", optarg,
-   errstr);
+   name = optarg;
break;
case 'H':
if (conf.fd != -1)

Modified: head/usr.sbin/pw/tests/pw_userdel.sh
==
--- head/usr.sbin/pw/tests/pw_userdel.shTue Jul 28 11:21:33 2015
(r285947)
+++ head/usr.sbin/pw/tests/pw_userdel.shTue Jul 28 12:20:57 2015
(r285948)
@@ -50,8 +50,18 @@ delete_files_body() {
fi
 }
 
+atf_test_case delete_numeric_name
+delete_numeric_name_body() {
+   populate_etc_skel
+
+   atf_check ${PW} useradd -n foo -u 4001
+   atf_check -e inline:"pw: no such user \`4001'\n" -s exit:67 \
+   ${PW} userdel -n 4001
+}
+
 atf_init_test_cases() {
atf_add_test_case rmuser_seperate_group
atf_add_test_case user_do_not_try_to_delete_root_if_user_unknown
atf_add_test_case delete_files
+   atf_add_test_case delete_numeric_name
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285947 - head

2015-07-28 Thread Steven Hartland
Author: smh
Date: Tue Jul 28 11:21:33 2015
New Revision: 285947
URL: https://svnweb.freebsd.org/changeset/base/285947

Log:
  Correct typo in UPDATING message
  
  MFC after:3 days
  Sponsored by: Multiplay

Modified:
  head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Tue Jul 28 11:19:38 2015(r285946)
+++ head/UPDATING   Tue Jul 28 11:21:33 2015(r285947)
@@ -32,7 +32,7 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
 20150728:
-   As ZFS requires a more kernel stack pages than is the default on some
+   As ZFS requires more kernel stack pages than is the default on some
architectures e.g. i386, it now warns if KSTACK_PAGES is less than
ZFS_MIN_KSTACK_PAGES (which is 4 at the time of writing).
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r285945 - head/sys/netpfil/pf

2015-07-28 Thread Gleb Smirnoff
  Renato,

On Tue, Jul 28, 2015 at 10:31:35AM +, Renato Botelho wrote:
R> Author: garga (ports committer)
R> Date: Tue Jul 28 10:31:34 2015
R> New Revision: 285945
R> URL: https://svnweb.freebsd.org/changeset/base/285945
R> 
R> Log:
R>   Respect pf rule log option before log dropped packets with IP options or
R>   dangerous v6 headers
R>   
R>   Reviewed by:   gnn, eri
R>   Approved by:   gnn
R>   Obtained from: pfSense
R>   MFC after: 3 days
R>   Sponsored by:  Netgate
R>   Differential Revision: https://reviews.freebsd.org/D3222
R> 
R> Modified:
R>   head/sys/netpfil/pf/pf.c
R> 
R> Modified: head/sys/netpfil/pf/pf.c
R> 
==
R> --- head/sys/netpfil/pf/pf.c Tue Jul 28 09:36:26 2015(r285944)
R> +++ head/sys/netpfil/pf/pf.c Tue Jul 28 10:31:34 2015(r285945)
R> @@ -5895,7 +5895,8 @@ done:
R>  !((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
R>  action = PF_DROP;
R>  REASON_SET(&reason, PFRES_IPOPTIONS);
R> -log = 1;
R> +if (r->log)
R> +log = 1;
R>  DPFPRINTF(PF_DEBUG_MISC,
R>  ("pf: dropping packet with ip options\n"));
R>  }
R> @@ -6329,7 +6330,8 @@ done:
R>  !((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
R>  action = PF_DROP;
R>  REASON_SET(&reason, PFRES_IPOPTIONS);
R> -log = 1;
R> +if (r->log)
R> +log = 1;
R>  DPFPRINTF(PF_DEBUG_MISC,
R>  ("pf: dropping packet with dangerous v6 headers\n"));
R>  }

Why not simply:

log = r->log;

?

That would also match the style of the function, since it already has:

log = s->log;

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


svn commit: r285946 - in head: . sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2015-07-28 Thread Steven Hartland
Author: smh
Date: Tue Jul 28 11:19:38 2015
New Revision: 285946
URL: https://svnweb.freebsd.org/changeset/base/285946

Log:
  Add warning about low KSTACK_PAGES for ZFS use
  
  As ZFS requires a more kernel stack pages than is the default on some
  architectures e.g. i386, warn if KSTACK_PAGES is less than
  ZFS_MIN_KSTACK_PAGES (which is 4 at the time of writing).
  
  MFC after:3 days
  Sponsored by: Multiplay

Modified:
  head/UPDATING
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c

Modified: head/UPDATING
==
--- head/UPDATING   Tue Jul 28 10:31:34 2015(r285945)
+++ head/UPDATING   Tue Jul 28 11:19:38 2015(r285946)
@@ -31,6 +31,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20150728:
+   As ZFS requires a more kernel stack pages than is the default on some
+   architectures e.g. i386, it now warns if KSTACK_PAGES is less than
+   ZFS_MIN_KSTACK_PAGES (which is 4 at the time of writing).
+
+   Please consider using 'options KSTACK_PAGES=X' where X is greater
+   than or equal to ZFS_MIN_KSTACK_PAGES i.e. 4 in such configurations.
+
 20150706:
sendmail has been updated to 8.15.2.  Starting with FreeBSD 11.0
and sendmail 8.15, sendmail uses uncompressed IPv6 addresses by

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Jul 
28 10:31:34 2015(r285945)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Tue Jul 
28 11:19:38 2015(r285946)
@@ -6491,10 +6491,18 @@ static void zfs_shutdown(void *, int);
 
 static eventhandler_tag zfs_shutdown_event_tag;
 
+#define ZFS_MIN_KSTACK_PAGES 4
+
 int
 zfs__init(void)
 {
 
+#if KSTACK_PAGES < ZFS_MIN_KSTACK_PAGES
+   printf("ZFS NOTICE: KSTACK_PAGES is %d which could result in stack "
+   "overflow panic!\nPlease consider adding "
+   "'options KSTACK_PAGES=%d' to your kernel config\n", KSTACK_PAGES,
+   ZFS_MIN_KSTACK_PAGES);
+#endif
zfs_root_token = root_mount_hold("ZFS");
 
mutex_init(&zfs_share_lock, NULL, MUTEX_DEFAULT, NULL);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285945 - head/sys/netpfil/pf

2015-07-28 Thread Renato Botelho
Author: garga (ports committer)
Date: Tue Jul 28 10:31:34 2015
New Revision: 285945
URL: https://svnweb.freebsd.org/changeset/base/285945

Log:
  Respect pf rule log option before log dropped packets with IP options or
  dangerous v6 headers
  
  Reviewed by:  gnn, eri
  Approved by:  gnn
  Obtained from:pfSense
  MFC after:3 days
  Sponsored by: Netgate
  Differential Revision:https://reviews.freebsd.org/D3222

Modified:
  head/sys/netpfil/pf/pf.c

Modified: head/sys/netpfil/pf/pf.c
==
--- head/sys/netpfil/pf/pf.cTue Jul 28 09:36:26 2015(r285944)
+++ head/sys/netpfil/pf/pf.cTue Jul 28 10:31:34 2015(r285945)
@@ -5895,7 +5895,8 @@ done:
!((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
action = PF_DROP;
REASON_SET(&reason, PFRES_IPOPTIONS);
-   log = 1;
+   if (r->log)
+   log = 1;
DPFPRINTF(PF_DEBUG_MISC,
("pf: dropping packet with ip options\n"));
}
@@ -6329,7 +6330,8 @@ done:
!((s && s->state_flags & PFSTATE_ALLOWOPTS) || r->allow_opts)) {
action = PF_DROP;
REASON_SET(&reason, PFRES_IPOPTIONS);
-   log = 1;
+   if (r->log)
+   log = 1;
DPFPRINTF(PF_DEBUG_MISC,
("pf: dropping packet with dangerous v6 headers\n"));
}
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285944 - head/sys/netpfil/pf

2015-07-28 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jul 28 09:36:26 2015
New Revision: 285944
URL: https://svnweb.freebsd.org/changeset/base/285944

Log:
  Fix a typo in r280169. Of course we are interested in deleting nsn only
  if we have just created it and we were the last reference.
  
  Submitted by: dhartmei

Modified:
  head/sys/netpfil/pf/pf.c

Modified: head/sys/netpfil/pf/pf.c
==
--- head/sys/netpfil/pf/pf.cTue Jul 28 09:21:19 2015(r285943)
+++ head/sys/netpfil/pf/pf.cTue Jul 28 09:36:26 2015(r285944)
@@ -3681,7 +3681,7 @@ csfailed:
 
sh = &V_pf_srchash[pf_hashsrc(&nsn->addr, nsn->af)];
PF_HASHROW_LOCK(sh);
-   if (--nsn->states == 1 && nsn->expire == 0) {
+   if (--nsn->states == 0 && nsn->expire == 0) {
pf_unlink_src_node(nsn);
uma_zfree(V_pf_sources_z, nsn);
counter_u64_add(
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285942 - in stable: 10/sys/dev/cxgb/ulp/iw_cxgb 7/sys/dev/cxgb/ulp/iw_cxgb 8/sys/dev/cxgb/ulp/iw_cxgb 9/sys/dev/cxgb/ulp/iw_cxgb

2015-07-28 Thread Dimitry Andric
Author: dim
Date: Tue Jul 28 09:19:04 2015
New Revision: 285942
URL: https://svnweb.freebsd.org/changeset/base/285942

Log:
  MFC r285340:
  
  Fix swapped copyin(9) arguments in cxgb's iwch_arm_cq() function.
  Detected by clang 3.7.0 with the warning:
  
  sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c:309:18: error: variable
  'rptr' is uninitialized when used here [-Werror,-Wuninitialized]
chp->cq.rptr = rptr;
   ^~~~

Modified:
  stable/8/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
Directory Properties:
  stable/8/   (props changed)
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/cxgb/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
  stable/7/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
  stable/9/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
Directory Properties:
  stable/10/   (props changed)
  stable/7/   (props changed)
  stable/7/sys/   (props changed)
  stable/9/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/8/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
==
--- stable/8/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.cTue Jul 28 
09:16:54 2015(r285941)
+++ stable/8/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.cTue Jul 28 
09:19:04 2015(r285942)
@@ -340,7 +340,7 @@ iwch_arm_cq(struct ib_cq *ibcq, enum ib_
else
cq_op = CQ_ARM_AN;
if (chp->user_rptr_addr) {
-   if (copyin(&rptr, chp->user_rptr_addr, 4))
+   if (copyin(chp->user_rptr_addr, &rptr, sizeof(rptr)))
return (-EFAULT);
mtx_lock(&chp->lock);
chp->cq.rptr = rptr;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285943 - stable/10/sys/netpfil/pf

2015-07-28 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jul 28 09:21:19 2015
New Revision: 285943
URL: https://svnweb.freebsd.org/changeset/base/285943

Log:
  Merge r283106:
During module unload unlock rules before destroying UMA zones, which
may sleep in uma_drain(). It is safe to unlock here, since we are already
dehooked from pfil(9) and all pf threads had quit.

Modified:
  stable/10/sys/netpfil/pf/pf_ioctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/pf/pf_ioctl.c
==
--- stable/10/sys/netpfil/pf/pf_ioctl.c Tue Jul 28 09:19:04 2015
(r285942)
+++ stable/10/sys/netpfil/pf/pf_ioctl.c Tue Jul 28 09:21:19 2015
(r285943)
@@ -3750,6 +3750,7 @@ pf_unload(void)
wakeup_one(pf_purge_thread);
rw_sleep(pf_purge_thread, &pf_rules_lock, 0, "pftmo", 0);
}
+   PF_RULES_WUNLOCK();
pf_normalize_cleanup();
pfi_cleanup();
pfr_cleanup();
@@ -3757,7 +3758,6 @@ pf_unload(void)
pf_cleanup();
if (IS_DEFAULT_VNET(curvnet))
pf_mtag_cleanup();
-   PF_RULES_WUNLOCK();
destroy_dev(pf_dev);
rw_destroy(&pf_rules_lock);
sx_destroy(&pf_ioctl_lock);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285942 - in stable: 10/sys/dev/cxgb/ulp/iw_cxgb 7/sys/dev/cxgb/ulp/iw_cxgb 8/sys/dev/cxgb/ulp/iw_cxgb 9/sys/dev/cxgb/ulp/iw_cxgb

2015-07-28 Thread Dimitry Andric
Author: dim
Date: Tue Jul 28 09:19:04 2015
New Revision: 285942
URL: https://svnweb.freebsd.org/changeset/base/285942

Log:
  MFC r285340:
  
  Fix swapped copyin(9) arguments in cxgb's iwch_arm_cq() function.
  Detected by clang 3.7.0 with the warning:
  
  sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c:309:18: error: variable
  'rptr' is uninitialized when used here [-Werror,-Wuninitialized]
chp->cq.rptr = rptr;
   ^~~~

Modified:
  stable/7/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
Directory Properties:
  stable/7/   (props changed)
  stable/7/sys/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
  stable/8/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
  stable/9/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
Directory Properties:
  stable/10/   (props changed)
  stable/8/   (props changed)
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/cxgb/   (props changed)
  stable/9/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/7/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
==
--- stable/7/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.cTue Jul 28 
09:16:54 2015(r285941)
+++ stable/7/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.cTue Jul 28 
09:19:04 2015(r285942)
@@ -355,7 +355,7 @@ iwch_arm_cq(struct ib_cq *ibcq, enum ib_
else
cq_op = CQ_ARM_AN;
if (chp->user_rptr_addr) {
-   if (copyin(&rptr, chp->user_rptr_addr, 4))
+   if (copyin(chp->user_rptr_addr, &rptr, sizeof(rptr)))
return (-EFAULT);
mtx_lock(&chp->lock);
chp->cq.rptr = rptr;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285942 - in stable: 10/sys/dev/cxgb/ulp/iw_cxgb 7/sys/dev/cxgb/ulp/iw_cxgb 8/sys/dev/cxgb/ulp/iw_cxgb 9/sys/dev/cxgb/ulp/iw_cxgb

2015-07-28 Thread Dimitry Andric
Author: dim
Date: Tue Jul 28 09:19:04 2015
New Revision: 285942
URL: https://svnweb.freebsd.org/changeset/base/285942

Log:
  MFC r285340:
  
  Fix swapped copyin(9) arguments in cxgb's iwch_arm_cq() function.
  Detected by clang 3.7.0 with the warning:
  
  sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c:309:18: error: variable
  'rptr' is uninitialized when used here [-Werror,-Wuninitialized]
chp->cq.rptr = rptr;
   ^~~~

Modified:
  stable/10/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
Directory Properties:
  stable/10/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/7/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
  stable/8/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
  stable/9/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
Directory Properties:
  stable/7/   (props changed)
  stable/7/sys/   (props changed)
  stable/8/   (props changed)
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/cxgb/   (props changed)
  stable/9/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/10/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
==
--- stable/10/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c   Tue Jul 28 
09:16:54 2015(r285941)
+++ stable/10/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c   Tue Jul 28 
09:19:04 2015(r285942)
@@ -302,7 +302,7 @@ iwch_arm_cq(struct ib_cq *ibcq, enum ib_
else
cq_op = CQ_ARM_AN;
if (chp->user_rptr_addr) {
-   if (copyin(&rptr, chp->user_rptr_addr, 4))
+   if (copyin(chp->user_rptr_addr, &rptr, sizeof(rptr)))
return (-EFAULT);
mtx_lock(&chp->lock);
chp->cq.rptr = rptr;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285942 - in stable: 10/sys/dev/cxgb/ulp/iw_cxgb 7/sys/dev/cxgb/ulp/iw_cxgb 8/sys/dev/cxgb/ulp/iw_cxgb 9/sys/dev/cxgb/ulp/iw_cxgb

2015-07-28 Thread Dimitry Andric
Author: dim
Date: Tue Jul 28 09:19:04 2015
New Revision: 285942
URL: https://svnweb.freebsd.org/changeset/base/285942

Log:
  MFC r285340:
  
  Fix swapped copyin(9) arguments in cxgb's iwch_arm_cq() function.
  Detected by clang 3.7.0 with the warning:
  
  sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c:309:18: error: variable
  'rptr' is uninitialized when used here [-Werror,-Wuninitialized]
chp->cq.rptr = rptr;
   ^~~~

Modified:
  stable/9/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
Directory Properties:
  stable/9/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
  stable/7/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
  stable/8/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
Directory Properties:
  stable/10/   (props changed)
  stable/7/   (props changed)
  stable/7/sys/   (props changed)
  stable/8/   (props changed)
  stable/8/sys/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/cxgb/   (props changed)

Modified: stable/9/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.c
==
--- stable/9/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.cTue Jul 28 
09:16:54 2015(r285941)
+++ stable/9/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb_provider.cTue Jul 28 
09:19:04 2015(r285942)
@@ -302,7 +302,7 @@ iwch_arm_cq(struct ib_cq *ibcq, enum ib_
else
cq_op = CQ_ARM_AN;
if (chp->user_rptr_addr) {
-   if (copyin(&rptr, chp->user_rptr_addr, 4))
+   if (copyin(chp->user_rptr_addr, &rptr, sizeof(rptr)))
return (-EFAULT);
mtx_lock(&chp->lock);
chp->cq.rptr = rptr;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285941 - stable/10/sys/netpfil/pf

2015-07-28 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jul 28 09:16:54 2015
New Revision: 285941
URL: https://svnweb.freebsd.org/changeset/base/285941

Log:
  Merge r283061, r283063: don't dereference NULL is pf_get_mtag() fails.
  
  PR:   200222

Modified:
  stable/10/sys/netpfil/pf/pf.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/pf/pf.c
==
--- stable/10/sys/netpfil/pf/pf.c   Tue Jul 28 09:13:55 2015
(r285940)
+++ stable/10/sys/netpfil/pf/pf.c   Tue Jul 28 09:16:54 2015
(r285941)
@@ -5912,13 +5912,14 @@ done:
((pd.pf_mtag = pf_get_mtag(m)) == NULL)) {
action = PF_DROP;
REASON_SET(&reason, PFRES_MEMORY);
+   } else {
+   if (pqid || (pd.tos & IPTOS_LOWDELAY))
+   pd.pf_mtag->qid = r->pqid;
+   else
+   pd.pf_mtag->qid = r->qid;
+   /* Add hints for ecn. */
+   pd.pf_mtag->hdr = h;
}
-   if (pqid || (pd.tos & IPTOS_LOWDELAY))
-   pd.pf_mtag->qid = r->pqid;
-   else
-   pd.pf_mtag->qid = r->qid;
-   /* add hints for ecn */
-   pd.pf_mtag->hdr = h;
 
}
 #endif /* ALTQ */
@@ -5957,9 +5958,11 @@ done:
log = 1;
DPFPRINTF(PF_DEBUG_MISC,
("pf: failed to allocate tag\n"));
+   } else {
+   pd.pf_mtag->flags |=
+   PF_FASTFWD_OURS_PRESENT;
+   m->m_flags &= ~M_FASTFWD_OURS;
}
-   pd.pf_mtag->flags |= PF_FASTFWD_OURS_PRESENT;
-   m->m_flags &= ~M_FASTFWD_OURS;
}
ip_divert_ptr(*m0, dir ==  PF_IN ? DIR_IN : DIR_OUT);
*m0 = NULL;
@@ -6341,13 +6344,14 @@ done:
((pd.pf_mtag = pf_get_mtag(m)) == NULL)) {
action = PF_DROP;
REASON_SET(&reason, PFRES_MEMORY);
+   } else {
+   if (pd.tos & IPTOS_LOWDELAY)
+   pd.pf_mtag->qid = r->pqid;
+   else
+   pd.pf_mtag->qid = r->qid;
+   /* Add hints for ecn. */
+   pd.pf_mtag->hdr = h;
}
-   if (pd.tos & IPTOS_LOWDELAY)
-   pd.pf_mtag->qid = r->pqid;
-   else
-   pd.pf_mtag->qid = r->qid;
-   /* add hints for ecn */
-   pd.pf_mtag->hdr = h;
}
 #endif /* ALTQ */
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285940 - in stable/10/sys: net netpfil/pf

2015-07-28 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jul 28 09:13:55 2015
New Revision: 285940
URL: https://svnweb.freebsd.org/changeset/base/285940

Log:
  Merge 280169: always lock the hash row of a source node when updating
  its 'states' counter.
  
  PR:   182401

Modified:
  stable/10/sys/net/pfvar.h
  stable/10/sys/netpfil/pf/pf.c
  stable/10/sys/netpfil/pf/pf_ioctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/net/pfvar.h
==
--- stable/10/sys/net/pfvar.h   Tue Jul 28 09:09:01 2015(r285939)
+++ stable/10/sys/net/pfvar.h   Tue Jul 28 09:13:55 2015(r285940)
@@ -1549,7 +1549,6 @@ extern struct pf_state*pf_find_state_a
 extern struct pf_src_node  *pf_find_src_node(struct pf_addr *,
struct pf_rule *, sa_family_t, int);
 extern void pf_unlink_src_node(struct pf_src_node *);
-extern void pf_unlink_src_node_locked(struct pf_src_node 
*);
 extern u_intpf_free_src_nodes(struct pf_src_node_list *);
 extern void pf_print_state(struct pf_state *);
 extern void pf_print_flags(u_int8_t);

Modified: stable/10/sys/netpfil/pf/pf.c
==
--- stable/10/sys/netpfil/pf/pf.c   Tue Jul 28 09:09:01 2015
(r285939)
+++ stable/10/sys/netpfil/pf/pf.c   Tue Jul 28 09:13:55 2015
(r285940)
@@ -655,7 +655,10 @@ pf_find_src_node(struct pf_addr *src, st
((af == AF_INET && n->addr.v4.s_addr == src->v4.s_addr) ||
(af == AF_INET6 && bcmp(&n->addr, src, sizeof(*src)) == 0)))
break;
-   if (n != NULL || returnlocked == 0)
+   if (n != NULL) {
+   n->states++;
+   PF_HASHROW_UNLOCK(sh);
+   } else if (returnlocked == 0)
PF_HASHROW_UNLOCK(sh);
 
return (n);
@@ -699,6 +702,7 @@ pf_insert_src_node(struct pf_src_node **
LIST_INSERT_HEAD(&sh->nodes, *sn, entry);
(*sn)->creation = time_uptime;
(*sn)->ruletype = rule->action;
+   (*sn)->states = 1;
if ((*sn)->rule.ptr != NULL)
counter_u64_add((*sn)->rule.ptr->src_nodes, 1);
PF_HASHROW_UNLOCK(sh);
@@ -715,37 +719,13 @@ pf_insert_src_node(struct pf_src_node **
 }
 
 void
-pf_unlink_src_node_locked(struct pf_src_node *src)
+pf_unlink_src_node(struct pf_src_node *src)
 {
-#ifdef INVARIANTS
-   struct pf_srchash *sh;
 
-   sh = &V_pf_srchash[pf_hashsrc(&src->addr, src->af)];
-   PF_HASHROW_ASSERT(sh);
-#endif
+   PF_HASHROW_ASSERT(&V_pf_srchash[pf_hashsrc(&src->addr, src->af)]);
LIST_REMOVE(src, entry);
if (src->rule.ptr)
counter_u64_add(src->rule.ptr->src_nodes, -1);
-   counter_u64_add(V_pf_status.scounters[SCNT_SRC_NODE_REMOVALS], 1);
-}
-
-void
-pf_unlink_src_node(struct pf_src_node *src)
-{
-   struct pf_srchash *sh;
-
-   sh = &V_pf_srchash[pf_hashsrc(&src->addr, src->af)];
-   PF_HASHROW_LOCK(sh);
-   pf_unlink_src_node_locked(src);
-   PF_HASHROW_UNLOCK(sh);
-}
-
-static void
-pf_free_src_node(struct pf_src_node *sn)
-{
-
-   KASSERT(sn->states == 0, ("%s: %p has refs", __func__, sn));
-   uma_zfree(V_pf_sources_z, sn);
 }
 
 u_int
@@ -755,10 +735,12 @@ pf_free_src_nodes(struct pf_src_node_lis
u_int count = 0;
 
LIST_FOREACH_SAFE(sn, head, entry, tmp) {
-   pf_free_src_node(sn);
+   uma_zfree(V_pf_sources_z, sn);
count++;
}
 
+   counter_u64_add(V_pf_status.scounters[SCNT_SRC_NODE_REMOVALS], count);
+
return (count);
 }
 
@@ -1550,7 +1532,7 @@ pf_purge_expired_src_nodes()
PF_HASHROW_LOCK(sh);
LIST_FOREACH_SAFE(cur, &sh->nodes, entry, next)
if (cur->states == 0 && cur->expire <= time_uptime) {
-   pf_unlink_src_node_locked(cur);
+   pf_unlink_src_node(cur);
LIST_INSERT_HEAD(&freelist, cur, entry);
} else if (cur->rule.ptr != NULL)
cur->rule.ptr->rule_flag |= PFRULE_REFS;
@@ -1565,27 +1547,31 @@ pf_purge_expired_src_nodes()
 static void
 pf_src_tree_remove_state(struct pf_state *s)
 {
-   u_int32_t timeout;
+   struct pf_src_node *sn;
+   struct pf_srchash *sh;
+   uint32_t timeout;
+
+   timeout = s->rule.ptr->timeout[PFTM_SRC_NODE] ?
+   s->rule.ptr->timeout[PFTM_SRC_NODE] :
+   V_pf_default_rule.timeout[PFTM_SRC_NODE];
 
if (s->src_node != NULL) {
+   sn = s->src_node;
+   sh = &V_pf_srchash[pf_hashsrc(&sn->addr, sn->af)];
+   PF_HASHROW_LOCK(sh);
if (s->src.tcp_est)
-   --s->src_node->conn;
-   

svn commit: r285939 - stable/10/sys/netpfil/pf

2015-07-28 Thread Gleb Smirnoff
Author: glebius
Date: Tue Jul 28 09:09:01 2015
New Revision: 285939
URL: https://svnweb.freebsd.org/changeset/base/285939

Log:
  Merge r271458:
- Provide a sleepable lock to protect against ioctl() vs ioctl() races.
- Use the new lock to protect against simultaneous DIOCSTART and/or
  DIOCSTOP ioctls.

Modified:
  stable/10/sys/netpfil/pf/pf_ioctl.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netpfil/pf/pf_ioctl.c
==
--- stable/10/sys/netpfil/pf/pf_ioctl.c Tue Jul 28 08:50:13 2015
(r285938)
+++ stable/10/sys/netpfil/pf/pf_ioctl.c Tue Jul 28 09:09:01 2015
(r285939)
@@ -188,6 +188,7 @@ static volatile VNET_DEFINE(int, pf_pfil
 VNET_DEFINE(int,   pf_end_threads);
 
 struct rwlock  pf_rules_lock;
+struct sx  pf_ioctl_lock;
 
 /* pfsync */
 pfsync_state_import_t  *pfsync_state_import_ptr = NULL;
@@ -1090,20 +1091,18 @@ pfioctl(struct cdev *dev, u_long cmd, ca
 
switch (cmd) {
case DIOCSTART:
-   PF_RULES_WLOCK();
+   sx_xlock(&pf_ioctl_lock);
if (V_pf_status.running)
error = EEXIST;
else {
int cpu;
 
-   PF_RULES_WUNLOCK();
error = hook_pf();
if (error) {
DPFPRINTF(PF_DEBUG_MISC,
("pf: pfil registration failed\n"));
break;
}
-   PF_RULES_WLOCK();
V_pf_status.running = 1;
V_pf_status.since = time_second;
 
@@ -1112,27 +,23 @@ pfioctl(struct cdev *dev, u_long cmd, ca
 
DPFPRINTF(PF_DEBUG_MISC, ("pf: started\n"));
}
-   PF_RULES_WUNLOCK();
break;
 
case DIOCSTOP:
-   PF_RULES_WLOCK();
+   sx_xlock(&pf_ioctl_lock);
if (!V_pf_status.running)
error = ENOENT;
else {
V_pf_status.running = 0;
-   PF_RULES_WUNLOCK();
error = dehook_pf();
if (error) {
V_pf_status.running = 1;
DPFPRINTF(PF_DEBUG_MISC,
("pf: pfil unregistration failed\n"));
}
-   PF_RULES_WLOCK();
V_pf_status.since = time_second;
DPFPRINTF(PF_DEBUG_MISC, ("pf: stopped\n"));
}
-   PF_RULES_WUNLOCK();
break;
 
case DIOCADDRULE: {
@@ -3256,6 +3251,8 @@ DIOCCHANGEADDR_error:
break;
}
 fail:
+   if (sx_xlocked(&pf_ioctl_lock))
+   sx_xunlock(&pf_ioctl_lock);
CURVNET_RESTORE();
 
return (error);
@@ -3728,6 +3725,7 @@ pf_load(void)
VNET_LIST_RUNLOCK();
 
rw_init(&pf_rules_lock, "pf rulesets");
+   sx_init(&pf_ioctl_lock, "pf ioctl");
 
pf_dev = make_dev(&pf_cdevsw, 0, 0, 0, 0600, PF_NAME);
if ((error = pfattach()) != 0)
@@ -3741,9 +3739,7 @@ pf_unload(void)
 {
int error = 0;
 
-   PF_RULES_WLOCK();
V_pf_status.running = 0;
-   PF_RULES_WUNLOCK();
swi_remove(V_pf_swi_cookie);
error = dehook_pf();
if (error) {
@@ -3772,6 +3768,7 @@ pf_unload(void)
PF_RULES_WUNLOCK();
destroy_dev(pf_dev);
rw_destroy(&pf_rules_lock);
+   sx_destroy(&pf_ioctl_lock);
 
return (error);
 }
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285938 - head/sys/netinet

2015-07-28 Thread Michael Tuexen
Author: tuexen
Date: Tue Jul 28 08:50:13 2015
New Revision: 285938
URL: https://svnweb.freebsd.org/changeset/base/285938

Log:
  Fix a typo reported by Erik Cederstrand.
  
  MFC after:1 week

Modified:
  head/sys/netinet/sctp_indata.c

Modified: head/sys/netinet/sctp_indata.c
==
--- head/sys/netinet/sctp_indata.c  Tue Jul 28 08:25:49 2015
(r285937)
+++ head/sys/netinet/sctp_indata.c  Tue Jul 28 08:50:13 2015
(r285938)
@@ -2490,7 +2490,7 @@ sctp_process_data(struct mbuf **mm, int 
struct mbuf *op_err;
char msg[SCTP_DIAG_INFO_LEN];
 
-   snprintf(msg, sizeof(msg), "DATA chunk 
followwd by chunk of type %2.2x",
+   snprintf(msg, sizeof(msg), "DATA chunk 
followed by chunk of type %2.2x",
ch->ch.chunk_type);
op_err = 
sctp_generate_cause(SCTP_CAUSE_PROTOCOL_VIOLATION, msg);
sctp_abort_association(inp, stcb,
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285937 - stable/9/sbin/geom/class/part

2015-07-28 Thread Andrey V. Elsukov
Author: ae
Date: Tue Jul 28 08:25:49 2015
New Revision: 285937
URL: https://svnweb.freebsd.org/changeset/base/285937

Log:
  MFC r285735:
lseek() allows an offset to be set beyond the end of file. Using
it to check that partition has enough space to write bootcode doesn't
work. Use the known size of provider instead.
  
PR: 201504

Modified:
  stable/9/sbin/geom/class/part/geom_part.c
Directory Properties:
  stable/9/sbin/geom/class/part/   (props changed)

Modified: stable/9/sbin/geom/class/part/geom_part.c
==
--- stable/9/sbin/geom/class/part/geom_part.c   Tue Jul 28 08:22:50 2015
(r285936)
+++ stable/9/sbin/geom/class/part/geom_part.c   Tue Jul 28 08:25:49 2015
(r285937)
@@ -1095,14 +1095,11 @@ gpart_write_partcode(struct ggeom *gp, i
 
if (pp != NULL) {
snprintf(dsf, sizeof(dsf), "/dev/%s", pp->lg_name);
+   if (pp->lg_mediasize < size)
+   errx(EXIT_FAILURE, "%s: not enough space", dsf);
fd = open(dsf, O_WRONLY);
if (fd == -1)
err(EXIT_FAILURE, "%s", dsf);
-   if (lseek(fd, size, SEEK_SET) != size)
-   errx(EXIT_FAILURE, "%s: not enough space", dsf);
-   if (lseek(fd, 0, SEEK_SET) != 0)
-   err(EXIT_FAILURE, "%s", dsf);
-
/*
 * When writing to a disk device, the write must be
 * sector aligned and not write to any partial sectors,
@@ -1141,11 +1138,11 @@ gpart_write_partcode_vtoc8(struct ggeom 
if (pp->lg_sectorsize != sizeof(struct vtoc8))
errx(EXIT_FAILURE, "%s: unexpected sector "
"size (%d)\n", dsf, pp->lg_sectorsize);
+   if (pp->lg_mediasize < VTOC_BOOTSIZE)
+   continue;
fd = open(dsf, O_WRONLY);
if (fd == -1)
err(EXIT_FAILURE, "%s", dsf);
-   if (lseek(fd, VTOC_BOOTSIZE, SEEK_SET) != VTOC_BOOTSIZE)
-   continue;
/*
 * We ignore the first VTOC_BOOTSIZE bytes of boot code in
 * order to avoid overwriting the label.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285936 - stable/10/sbin/geom/class/part

2015-07-28 Thread Andrey V. Elsukov
Author: ae
Date: Tue Jul 28 08:22:50 2015
New Revision: 285936
URL: https://svnweb.freebsd.org/changeset/base/285936

Log:
  MFC r285735:
lseek() allows an offset to be set beyond the end of file. Using
it to check that partition has enough space to write bootcode doesn't
work. Use the known size of provider instead.
  
PR: 201504

Modified:
  stable/10/sbin/geom/class/part/geom_part.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sbin/geom/class/part/geom_part.c
==
--- stable/10/sbin/geom/class/part/geom_part.c  Tue Jul 28 07:30:07 2015
(r285935)
+++ stable/10/sbin/geom/class/part/geom_part.c  Tue Jul 28 08:22:50 2015
(r285936)
@@ -1095,14 +1095,11 @@ gpart_write_partcode(struct ggeom *gp, i
 
if (pp != NULL) {
snprintf(dsf, sizeof(dsf), "/dev/%s", pp->lg_name);
+   if (pp->lg_mediasize < size)
+   errx(EXIT_FAILURE, "%s: not enough space", dsf);
fd = open(dsf, O_WRONLY);
if (fd == -1)
err(EXIT_FAILURE, "%s", dsf);
-   if (lseek(fd, size, SEEK_SET) != size)
-   errx(EXIT_FAILURE, "%s: not enough space", dsf);
-   if (lseek(fd, 0, SEEK_SET) != 0)
-   err(EXIT_FAILURE, "%s", dsf);
-
/*
 * When writing to a disk device, the write must be
 * sector aligned and not write to any partial sectors,
@@ -1141,11 +1138,11 @@ gpart_write_partcode_vtoc8(struct ggeom 
if (pp->lg_sectorsize != sizeof(struct vtoc8))
errx(EXIT_FAILURE, "%s: unexpected sector "
"size (%d)\n", dsf, pp->lg_sectorsize);
+   if (pp->lg_mediasize < VTOC_BOOTSIZE)
+   continue;
fd = open(dsf, O_WRONLY);
if (fd == -1)
err(EXIT_FAILURE, "%s", dsf);
-   if (lseek(fd, VTOC_BOOTSIZE, SEEK_SET) != VTOC_BOOTSIZE)
-   continue;
/*
 * We ignore the first VTOC_BOOTSIZE bytes of boot code in
 * order to avoid overwriting the label.
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r285935 - head/sys/dev/usb/controller

2015-07-28 Thread Hans Petter Selasky
Author: hselasky
Date: Tue Jul 28 07:30:07 2015
New Revision: 285935
URL: https://svnweb.freebsd.org/changeset/base/285935

Log:
  Optimise the DWC OTG host mode driver's receive path:
  
  Remove NAKing limit and pause IN and OUT transactions for 125us in
  case of NAK response for BULK and CONTROL endpoints. This gets the
  receive latency down and improves USB network throughput at the cost
  of some CPU usage.
  
  MFC after:1 month

Modified:
  head/sys/dev/usb/controller/dwc_otg.c
  head/sys/dev/usb/controller/dwc_otg.h

Modified: head/sys/dev/usb/controller/dwc_otg.c
==
--- head/sys/dev/usb/controller/dwc_otg.c   Tue Jul 28 07:04:51 2015
(r285934)
+++ head/sys/dev/usb/controller/dwc_otg.c   Tue Jul 28 07:30:07 2015
(r285935)
@@ -453,8 +453,12 @@ static void
 dwc_otg_enable_sof_irq(struct dwc_otg_softc *sc)
 {
/* In device mode we don't use the SOF interrupt */
-   if (sc->sc_flags.status_device_mode != 0 ||
-   (sc->sc_irq_mask & GINTMSK_SOFMSK) != 0)
+   if (sc->sc_flags.status_device_mode != 0)
+   return;
+   /* Ensure the SOF interrupt is not disabled */
+   sc->sc_needsof = 1;
+   /* Check if the SOF interrupt is already enabled */
+   if ((sc->sc_irq_mask & GINTMSK_SOFMSK) != 0)
return;
sc->sc_irq_mask |= GINTMSK_SOFMSK;
DWC_OTG_WRITE_4(sc, DOTG_GINTMSK, sc->sc_irq_mask);
@@ -775,7 +779,7 @@ check_state:
 
case DWC_CHAN_ST_WAIT_ANE:
if (hcint & (HCINT_RETRY | HCINT_ERRORS)) {
-   td->did_nak++;
+   td->did_nak = 1;
td->tt_scheduled = 0;
goto send_pkt;
} else if (hcint & (HCINT_ACK | HCINT_NYET)) {
@@ -789,7 +793,7 @@ check_state:
 
case DWC_CHAN_ST_WAIT_S_ANE:
if (hcint & (HCINT_RETRY | HCINT_ERRORS)) {
-   td->did_nak++;
+   td->did_nak = 1;
td->tt_scheduled = 0;
goto send_pkt;
} else if (hcint & (HCINT_ACK | HCINT_NYET)) {
@@ -801,7 +805,7 @@ check_state:
if (hcint & HCINT_NYET) {
goto send_cpkt;
} else if (hcint & (HCINT_RETRY | HCINT_ERRORS)) {
-   td->did_nak++;
+   td->did_nak = 1;
td->tt_scheduled = 0;
goto send_pkt;
} else if (hcint & HCINT_ACK) {
@@ -1069,8 +1073,17 @@ dwc_otg_host_rate_check(struct dwc_otg_s
if (!td->tt_scheduled)
goto busy;
td->tt_scheduled = 0;
-   } else if (td->did_nak >= DWC_OTG_NAK_MAX) {
-   goto busy;
+   } else if (td->did_nak != 0) {
+   uint8_t frame_num = (uint8_t)sc->sc_last_frame_num;
+   /* check if we should pause sending queries for 125us */
+   if (td->tmr_res == frame_num) {
+   /* wait a bit */
+   dwc_otg_enable_sof_irq(sc);
+   goto busy;
+   }
+   /* query for data one more time */
+   td->tmr_res = frame_num;
+   td->did_nak = 0;
} else if (td->set_toggle) {
td->set_toggle = 0;
td->toggle = 1;
@@ -1257,7 +1270,7 @@ dwc_otg_host_data_rx(struct dwc_otg_soft
goto receive_pkt;
}
}
-   td->did_nak++;
+   td->did_nak = 1;
td->tt_scheduled = 0;
if (td->hcsplt != 0)
goto receive_spkt;
@@ -1312,7 +1325,7 @@ dwc_otg_host_data_rx(struct dwc_otg_soft
 * case of interrupt and isochronous transfers:
 */ 
if (hcint & (HCINT_RETRY | HCINT_ERRORS)) {
-   td->did_nak++;
+   td->did_nak = 1;
td->tt_scheduled = 0;
goto receive_spkt;
} else if (hcint & HCINT_NYET) {
@@ -1638,7 +1651,7 @@ dwc_otg_host_data_tx(struct dwc_otg_soft
 
case DWC_CHAN_ST_WAIT_ANE:
if (hcint & (HCINT_RETRY | HCINT_ERRORS)) {
-   td->did_nak++;
+   td->did_nak = 1;
td->tt_scheduled = 0;
goto send_pkt;
} else if (hcint & (HCINT_ACK | HCINT_NYET)) {
@@ -1664,7 +1677,7 @@ dwc_otg_host_data_tx(struct dwc_otg_soft
 
case DWC_CHAN_ST_WAIT_S_ANE:
if (hcint & (HCINT_RETRY | HCINT_ERRORS)) {
-   td->did_nak++;
+   td->did_nak = 1;
td->tt_scheduled = 0;
got

Re: svn commit: r285926 - in head: libexec/ypxfr usr.bin/ypcat usr.bin/ypmatch usr.bin/ypwhich usr.sbin/yp_mkdb usr.sbin/yppush usr.sbin/ypserv

2015-07-28 Thread Marcelo Araujo
2015-07-28 15:05 GMT+08:00 Ed Schouten :

> Hi Marcelo,
>
> Thanks for working on this!
>
> 2015-07-28 4:32 GMT+02:00 Marcelo Araujo :
> > -struct ypalias {
> > +const struct ypalias {
> > char *alias, *name;
> > -} ypaliases[] = {
> > +} static ypaliases[] = {
> > { "passwd", "passwd.byname" },
> > { "master.passwd", "master.passwd.byname" },
> > { "shadow", "shadow.byname" },
>
> I seem to remember that certain compilers (Intel?) are pretty picky
> about the ordering of 'static' and 'const'.
>
> const static int i; // Compiler error.
>
> It's also inconsistent with the rest of our codebase, where we
> typically put 'static' in front of the type. Could you please change
> this to the following?
>
> static const struct ypalias {
>...
> } ypaliases[] = {
>...
> };
>
> Thanks!
>

Hello Ed,

Thanks to point it out. I got a problem with sparc64, exactly because of
that.
I will fix it later.


All the best.

-- 
Marcelo Araujo(__)ara...@freebsd.org
\\\'',)http://www.FreeBSD.org    \/  \ ^
Power To Server. .\. /_)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r285926 - in head: libexec/ypxfr usr.bin/ypcat usr.bin/ypmatch usr.bin/ypwhich usr.sbin/yp_mkdb usr.sbin/yppush usr.sbin/ypserv

2015-07-28 Thread Ed Schouten
Hi Marcelo,

Thanks for working on this!

2015-07-28 4:32 GMT+02:00 Marcelo Araujo :
> -struct ypalias {
> +const struct ypalias {
> char *alias, *name;
> -} ypaliases[] = {
> +} static ypaliases[] = {
> { "passwd", "passwd.byname" },
> { "master.passwd", "master.passwd.byname" },
> { "shadow", "shadow.byname" },

I seem to remember that certain compilers (Intel?) are pretty picky
about the ordering of 'static' and 'const'.

const static int i; // Compiler error.

It's also inconsistent with the rest of our codebase, where we
typically put 'static' in front of the type. Could you please change
this to the following?

static const struct ypalias {
   ...
} ypaliases[] = {
   ...
};

Thanks!

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


svn commit: r285934 - head/sys/amd64/include

2015-07-28 Thread Konstantin Belousov
Author: kib
Date: Tue Jul 28 07:04:51 2015
New Revision: 285934
URL: https://svnweb.freebsd.org/changeset/base/285934

Log:
  Remove full barrier from the amd64 atomic_load_acq_*().  Strong
  ordering semantic of x86 CPUs makes only the compiler barrier
  neccessary to give the acquire behaviour.
  
  Existing implementation ensured sequentially consistent semantic for
  load_acq, making much stronger guarantee than required by standard's
  definition of the load acquire.  Consumers which depend on the barrier
  are believed to be identified and already fixed to use proper
  operations.
  
  Noted by: alc (long time ago)
  Reviewed by:  alc, bde
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks

Modified:
  head/sys/amd64/include/atomic.h

Modified: head/sys/amd64/include/atomic.h
==
--- head/sys/amd64/include/atomic.h Tue Jul 28 06:58:10 2015
(r285933)
+++ head/sys/amd64/include/atomic.h Tue Jul 28 07:04:51 2015
(r285934)
@@ -269,13 +269,13 @@ atomic_testandset_long(volatile u_long *
  * IA32 memory model, a simple store guarantees release semantics.
  *
  * However, a load may pass a store if they are performed on distinct
- * addresses, so for atomic_load_acq we introduce a Store/Load barrier
- * before the load in SMP kernels.  We use "lock addl $0,mem", as
- * recommended by the AMD Software Optimization Guide, and not mfence.
- * In the kernel, we use a private per-cpu cache line as the target
- * for the locked addition, to avoid introducing false data
- * dependencies.  In userspace, a word in the red zone on the stack
- * (-8(%rsp)) is utilized.
+ * addresses, so we need a Store/Load barrier for sequentially
+ * consistent fences in SMP kernels.  We use "lock addl $0,mem" for a
+ * Store/Load barrier, as recommended by the AMD Software Optimization
+ * Guide, and not mfence.  In the kernel, we use a private per-cpu
+ * cache line as the target for the locked addition, to avoid
+ * introducing false data dependencies.  In user space, we use a word
+ * in the stack's red zone (-8(%rsp)).
  *
  * For UP kernels, however, the memory of the single processor is
  * always consistent, so we only need to stop the compiler from
@@ -319,22 +319,12 @@ __storeload_barrier(void)
 }
 #endif /* _KERNEL*/
 
-/*
- * C11-standard acq/rel semantics only apply when the variable in the
- * call is the same for acq as it is for rel.  However, our previous
- * (x86) implementations provided much stronger ordering than required
- * (essentially what is called seq_cst order in C11).  This
- * implementation provides the historical strong ordering since some
- * callers depend on it.
- */
-
 #defineATOMIC_LOAD(TYPE)   \
 static __inline u_##TYPE   \
 atomic_load_acq_##TYPE(volatile u_##TYPE *p)   \
 {  \
u_##TYPE res;   \
\
-   __storeload_barrier();  \
res = *p;   \
__compiler_membar();\
return (res);   \
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"