svn commit: r349380 - head/lib/libbe

2019-06-25 Thread Kyle Evans
Author: kevans
Date: Tue Jun 25 18:13:39 2019
New Revision: 349380
URL: https://svnweb.freebsd.org/changeset/base/349380

Log:
  libbe(3): mount: the BE dataset is mounted at /
  
  Other parts of libbe(3) were fairly strict on the mountpoint property of the
  BE dataset, and be_mount was not much better. It was improved in r347027 to
  allow mountpoint=none for depth==0, but this bit was still sensitive to
  mountpoint != / and mountpoint != none. Given that other parts of libbe(3)
  no longer restrict the mountpoint property here, and the rest of the base
  system is generally OK and will assume that a BE is mounted at /, let's do
  the same.
  
  Reported by:  ler
  MFC after:3 days

Modified:
  head/lib/libbe/be_access.c

Modified: head/lib/libbe/be_access.c
==
--- head/lib/libbe/be_access.c  Tue Jun 25 17:27:37 2019(r349379)
+++ head/lib/libbe/be_access.c  Tue Jun 25 18:13:39 2019(r349380)
@@ -96,7 +96,7 @@ be_mount_iter(zfs_handle_t *zfs_hdl, void *data)
NULL, NULL, 0, 1))
return (1);
 
-   if (strcmp("none", zfs_mnt) == 0) {
+   if (strcmp("none", zfs_mnt) == 0 || info->depth == 0) {
/*
 * mountpoint=none; we'll mount it at info->mountpoint assuming
 * we're at the root.  If we're not at the root, we're likely
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r349383 - head/lib/libbe

2019-06-25 Thread Kyle Evans
Author: kevans
Date: Tue Jun 25 18:47:40 2019
New Revision: 349383
URL: https://svnweb.freebsd.org/changeset/base/349383

Log:
  libbe(3): restructure be_mount, skip canmount check for BE dataset
  
  Further cleanup after r349380; loader and kernel will both ignore canmount
  on the root dataset as well, so we should not be so strict about it when
  mounting it. be_mount is restructured to make it more clear that depth==0 is
  special, and to not try fetching these properties that we won't care about.
  
  MFC after:3 days

Modified:
  head/lib/libbe/be_access.c

Modified: head/lib/libbe/be_access.c
==
--- head/lib/libbe/be_access.c  Tue Jun 25 18:36:11 2019(r349382)
+++ head/lib/libbe/be_access.c  Tue Jun 25 18:47:40 2019(r349383)
@@ -89,25 +89,31 @@ be_mount_iter(zfs_handle_t *zfs_hdl, void *data)
return (0);
}
 
-   if (zfs_prop_get_int(zfs_hdl, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_OFF)
-   return (0);
+   /*
+* canmount and mountpoint are both ignored for the BE dataset, because
+* the rest of the system (kernel and loader) will effectively do the
+* same.
+*/
+   if (info->depth == 0) {
+   snprintf(tmp, BE_MAXPATHLEN, "%s", info->mountpoint);
+   } else {
+   if (zfs_prop_get_int(zfs_hdl, ZFS_PROP_CANMOUNT) ==
+   ZFS_CANMOUNT_OFF)
+   return (0);
 
-   if (zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, zfs_mnt, BE_MAXPATHLEN,
-   NULL, NULL, 0, 1))
-   return (1);
+   if (zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, zfs_mnt,
+   BE_MAXPATHLEN, NULL, NULL, 0, 1))
+   return (1);
 
-   if (strcmp("none", zfs_mnt) == 0 || info->depth == 0) {
/*
-* mountpoint=none; we'll mount it at info->mountpoint assuming
-* we're at the root.  If we're not at the root, we're likely
-* at some intermediate dataset (e.g. zroot/var) that will have
-* children that may need to be mounted.
+* We've encountered mountpoint=none at some intermediate
+* dataset (e.g. zroot/var) that will have children that may
+* need to be mounted.  Skip mounting it, but iterate through
+* the children.
 */
-   if (info->depth > 0)
+   if (strcmp("none", zfs_mnt) == 0)
goto skipmount;
 
-   snprintf(tmp, BE_MAXPATHLEN, "%s", info->mountpoint);
-   } else {
mountpoint = be_mountpoint_augmented(info->lbh, zfs_mnt);
snprintf(tmp, BE_MAXPATHLEN, "%s%s", info->mountpoint,
mountpoint);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r349455 - in head/sbin/bectl: . tests

2019-06-27 Thread Kyle Evans
Author: kevans
Date: Thu Jun 27 14:03:32 2019
New Revision: 349455
URL: https://svnweb.freebsd.org/changeset/base/349455

Log:
  bectl(8): create non-recursive boot environments
  
  bectl advertises that it has the ability to create recursive and
  non-recursive boot environments. This patch implements that functionality
  using the be_create_depth API provided by libbe. With this patch, bectl now
  works as bectl(8) describes in regards to creating recursive/non-recursive
  boot environments.
  
  Submitted by: Rob Fairbanks  (with minor changes)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D20240

Modified:
  head/sbin/bectl/bectl.c
  head/sbin/bectl/tests/bectl_test.sh

Modified: head/sbin/bectl/bectl.c
==
--- head/sbin/bectl/bectl.c Thu Jun 27 13:37:34 2019(r349454)
+++ head/sbin/bectl/bectl.c Thu Jun 27 14:03:32 2019(r349455)
@@ -184,7 +184,8 @@ bectl_cmd_activate(int argc, char *argv[])
 static int
 bectl_cmd_create(int argc, char *argv[])
 {
-   char *atpos, *bootenv, *snapname, *source;
+   char snapshot[BE_MAXPATHLEN];
+   char *atpos, *bootenv, *snapname;
int err, opt;
bool recursive;
 
@@ -214,6 +215,8 @@ bectl_cmd_create(int argc, char *argv[])
}
 
bootenv = *argv;
+
+   err = BE_ERR_SUCCESS;
if ((atpos = strchr(bootenv, '@')) != NULL) {
/*
 * This is the "create a snapshot variant". No new boot
@@ -221,24 +224,22 @@ bectl_cmd_create(int argc, char *argv[])
 */
*atpos++ = '\0';
err = be_snapshot(be, bootenv, atpos, recursive, NULL);
-   } else if (snapname != NULL) {
-   if (strchr(snapname, '@') != NULL)
-   err = be_create_from_existing_snap(be, bootenv,
-   snapname);
-   else
-   err = be_create_from_existing(be, bootenv, snapname);
} else {
-   if ((snapname = strchr(bootenv, '@')) != NULL) {
-   *(snapname++) = '\0';
-   if ((err = be_snapshot(be, be_active_path(be),
-   snapname, true, NULL)) != BE_ERR_SUCCESS)
-   fprintf(stderr, "failed to create snapshot\n");
-   asprintf(&source, "%s@%s", be_active_path(be), 
snapname);
-   err = be_create_from_existing_snap(be, bootenv,
-   source);
-   return (err);
-   } else
-   err = be_create(be, bootenv);
+   if (snapname == NULL)
+   /* Create from currently booted BE */
+   err = be_snapshot(be, be_active_path(be), NULL,
+   recursive, snapshot);
+   else if (strchr(snapname, '@') != NULL)
+   /* Create from given snapshot */
+   strlcpy(snapshot, snapname, sizeof(snapshot));
+   else
+   /* Create from given BE */
+   err = be_snapshot(be, snapname, NULL, recursive,
+   snapshot);
+
+   if (err == BE_ERR_SUCCESS)
+   err = be_create_depth(be, bootenv, snapshot,
+ recursive == true ? -1 : 0);
}
 
switch (err) {

Modified: head/sbin/bectl/tests/bectl_test.sh
==
--- head/sbin/bectl/tests/bectl_test.sh Thu Jun 27 13:37:34 2019
(r349454)
+++ head/sbin/bectl/tests/bectl_test.sh Thu Jun 27 14:03:32 2019
(r349455)
@@ -99,11 +99,35 @@ bectl_create_body()
mount=${cwd}/mnt
 
bectl_create_setup ${zpool} ${disk} ${mount}
+
+   # Create a child dataset that will be used to test creation
+   # of recursive and non-recursive boot environments.
+   atf_check zfs create -o mountpoint=/usr -o canmount=noauto \
+   ${zpool}/ROOT/default/usr
+
# Test standard creation, creation of a snapshot, and creation from a
# snapshot.
atf_check bectl -r ${zpool}/ROOT create -e default default2
atf_check bectl -r ${zpool}/ROOT create default2@test_snap
atf_check bectl -r ${zpool}/ROOT create -e default2@test_snap default3
+
+   # Test standard creation, creation of a snapshot, and creation from a
+   # snapshot for recursive boot environments.
+   atf_check bectl -r ${zpool}/ROOT create -r -e default recursive
+   atf_check bectl -r ${zpool}/ROOT create -r recursive@test_snap
+   atf_check bectl -r ${zpool}/ROOT create -r -e recursive@test_snap 
recursive-snap
+
+   # Test that non-recursive boot environments have no child datasets.
+   atf_check -e not-empty -s not-exit:0 \
+   zfs list "${zpoo

Re: svn commit: r350256 - in stable/12: . contrib/compiler-rt/lib/sanitizer_common contrib/libunwind/src contrib/llvm/lib/DebugInfo/DWARF contrib/llvm/lib/MC contrib/llvm/lib/Object contrib/llvm/lib/T

2019-07-23 Thread Kyle Evans
On Tue, Jul 23, 2019 at 1:41 PM Dimitry Andric  wrote:
>
> Author: dim
> Date: Tue Jul 23 18:40:32 2019
> New Revision: 350256
> URL: https://svnweb.freebsd.org/changeset/base/350256
>
> Log:
>   MFC r348504 (by kevans):
>
>   llvm-symbolizer: Move out of CLANG_EXTRAS, into CLANG
>
>   ASAN reports become a lot more useful with llvm-symbolizer in $PATH, and the
>   build is not much more time-consuming. The added benefit is that the
>   resulting reports will actually include symbol information; without, thread
>   trace information includes a bunch of addresses that immediately resolve to
>   an inline function in
>   ^/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common.h and take a
>   little more effort to examine.
>
>   Reviewed by:  emaste
>   Differential Revision:https://reviews.freebsd.org/D20484
>

Ahh, r348689 also needs to be shipped back to stable along with this
one -- I had missed moving the man page out into the CLANG knob.

Thanks,

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


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

2019-07-25 Thread Kyle Evans
On Thu, Jul 25, 2019 at 11:46 AM Shawn Webb  wrote:
>
> Hey Rick,
>
> On Thu, Jul 25, 2019 at 05:46:17AM +, Rick Macklem wrote:
> > Author: rmacklem
> > Date: Thu Jul 25 05:46:16 2019
> > New Revision: 350315
> > URL: https://svnweb.freebsd.org/changeset/base/350315
> >
> > Log:
> >   Add kernel support for a Linux compatible copy_file_range(2) syscall.
> >
> >   This patch adds support to the kernel for a Linux compatible
> >   copy_file_range(2) syscall and the related VOP_COPY_FILE_RANGE(9).
> >   This syscall/VOP can be used by the NFSv4.2 client to implement the
> >   Copy operation against an NFSv4.2 server to do file copies locally on
> >   the server.
> >   The vn_generic_copy_file_range() function in this patch can be used
> >   by the NFSv4.2 server to implement the Copy operation.
> >   Fuse may also me able to use the VOP_COPY_FILE_RANGE() method.
> >
> >   vn_generic_copy_file_range() attempts to maintain holes in the output
> >   file in the range to be copied, but may fail to do so if the input and
> >   output files are on different file systems with different 
> > _PC_MIN_HOLE_SIZE
> >   values.
> >
> >   Separate commits will be done for the generated syscall files and userland
> >   changes. A commit for a compat32 syscall will be done later.
> >
> >   Reviewed by:kib, asomers (plus comments by brooks, jilles)
> >   Relnotes:   yes
> >   Differential Revision:  https://reviews.freebsd.org/D20584
> >
> > Modified:
> >   head/sys/kern/syscalls.master
> >   head/sys/kern/vfs_default.c
> >   head/sys/kern/vfs_syscalls.c
> >   head/sys/kern/vfs_vnops.c
> >   head/sys/kern/vnode_if.src
> >   head/sys/sys/syscallsubr.h
> >   head/sys/sys/vnode.h
> >
> > Modified: head/sys/kern/syscalls.master
> > ==
> > --- head/sys/kern/syscalls.master Thu Jul 25 03:55:05 2019
> > (r350314)
> > +++ head/sys/kern/syscalls.master Thu Jul 25 05:46:16 2019
> > (r350315)
> > @@ -3175,6 +3175,16 @@
> >   int flag
> >   );
> >   }
> > +569  AUE_NULLSTD {
> > + ssize_t copy_file_range(
> > + int infd,
> > + _Inout_opt_ off_t *inoffp,
> > + int outfd,
> > + _Inout_opt_ off_t *outoffp,
> > + size_t len,
> > + unsigned int flags
> > + );
> > + }
> >
> >  ; Please copy any additions and changes to the following compatability 
> > tables:
> >  ; sys/compat/freebsd32/syscalls.master
> >
> > Modified: head/sys/kern/vfs_default.c
> > ==
> > --- head/sys/kern/vfs_default.c   Thu Jul 25 03:55:05 2019
> > (r350314)
> > +++ head/sys/kern/vfs_default.c   Thu Jul 25 05:46:16 2019
> > (r350315)
> > @@ -83,6 +83,7 @@ static int  dirent_exists(struct vnode *vp, const char
> >  static int vop_stdis_text(struct vop_is_text_args *ap);
> >  static int vop_stdunset_text(struct vop_unset_text_args *ap);
> >  static int vop_stdadd_writecount(struct vop_add_writecount_args *ap);
> > +static int vop_stdcopy_file_range(struct vop_copy_file_range_args *ap);
> >  static int vop_stdfdatasync(struct vop_fdatasync_args *ap);
> >  static int vop_stdgetpages_async(struct vop_getpages_async_args *ap);
> >
> > @@ -140,6 +141,7 @@ struct vop_vector default_vnodeops = {
> >   .vop_set_text = vop_stdset_text,
> >   .vop_unset_text =   vop_stdunset_text,
> >   .vop_add_writecount =   vop_stdadd_writecount,
> > + .vop_copy_file_range =  vop_stdcopy_file_range,
> >  };
> >
> >  /*
> > @@ -1210,6 +1212,17 @@ vfs_stdnosync (mp, waitfor)
> >  {
> >
> >   return (0);
> > +}
> > +
> > +static int
> > +vop_stdcopy_file_range(struct vop_copy_file_range_args *ap)
> > +{
> > + int error;
> > +
> > + error = vn_generic_copy_file_range(ap->a_invp, ap->a_inoffp,
> > + ap->a_outvp, ap->a_outoffp, ap->a_lenp, ap->a_flags, ap->a_incred,
> > + ap->a_outcred, ap->a_fsizetd);
> > + return (error);
> >  }
> >
> >  int
> >
> > Modified: head/sys/kern/vfs_syscalls.c
> > ==
> > --- head/sys/kern/vfs_syscalls.c  Thu Jul 25 03:55:05 2019
> > (r350314)
> > +++ head/sys/kern/vfs_syscalls.c  Thu Jul 25 05:46:16 2019
> > (r350315)
> > @@ -4814,3 +4814,122 @@ sys_posix_fadvise(struct thread *td, struct 
> > posix_fadv
> >   uap->advice);
> >   return (kern_posix_error(td, error));
> >  }
> > +
> > +int
> > +kern_copy_file_range(struct thread *td, int infd, off_t *inoffp, int outfd,
> > +off_t *outoffp, size_t len, unsigned int flags)
> > +{
> > + struct file *infp, *outfp;
> > + struct vnode *invp, *outvp;
> > + int error;
> > + size_t retlen;
> > + void *rl_rcookie, *rl_wcookie;
> > + off_t savinoff, savoutoff;
> > +

svn commit: r350336 - head/sys/net

2019-07-25 Thread Kyle Evans
Author: kevans
Date: Thu Jul 25 22:23:34 2019
New Revision: 350336
URL: https://svnweb.freebsd.org/changeset/base/350336

Log:
  if_tuntap(4): Add TUNGIFNAME
  
  This effectively just moves TAPGIFNAME into common ioctl territory.
  
  MFC after:3 days

Modified:
  head/sys/net/if_tap.h
  head/sys/net/if_tun.h
  head/sys/net/if_tuntap.c

Modified: head/sys/net/if_tap.h
==
--- head/sys/net/if_tap.h   Thu Jul 25 22:02:55 2019(r350335)
+++ head/sys/net/if_tap.h   Thu Jul 25 22:23:34 2019(r350336)
@@ -55,7 +55,7 @@
 #defineTAPGDEBUG   TUNGDEBUG
 #defineTAPSIFINFO  TUNSIFINFO
 #defineTAPGIFINFO  TUNGIFINFO
-#defineTAPGIFNAME  _IOR('t', 93, struct ifreq)
+#defineTAPGIFNAME  TUNGIFNAME
 
 /* VMware ioctl's */
 #define VMIO_SIOCSIFFLAGS  _IOWINT('V', 0)

Modified: head/sys/net/if_tun.h
==
--- head/sys/net/if_tun.h   Thu Jul 25 22:02:55 2019(r350335)
+++ head/sys/net/if_tun.h   Thu Jul 25 22:23:34 2019(r350336)
@@ -40,6 +40,7 @@ struct tuninfo {
 #defineTUNSIFINFO  _IOW('t', 91, struct tuninfo)
 #defineTUNGIFINFO  _IOR('t', 92, struct tuninfo)
 #defineTUNSLMODE   _IOW('t', 93, int)
+#defineTUNGIFNAME  _IOR('t', 93, struct ifreq)
 #defineTUNSIFMODE  _IOW('t', 94, int)
 #defineTUNSIFPID   _IO('t', 95)
 #defineTUNSIFHEAD  _IOW('t', 96, int)

Modified: head/sys/net/if_tuntap.c
==
--- head/sys/net/if_tuntap.cThu Jul 25 22:02:55 2019(r350335)
+++ head/sys/net/if_tuntap.cThu Jul 25 22:23:34 2019(r350336)
@@ -1235,12 +1235,6 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, i
if (l2tun) {
/* tap specific ioctls */
switch(cmd) {
-   case TAPGIFNAME:
-   ifrp = (struct ifreq *)data;
-   strlcpy(ifrp->ifr_name, TUN2IFP(tp)->if_xname,
-   IFNAMSIZ);
-
-   return (0);
/* VMware/VMnet port ioctl's */
 #if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
 defined(COMPAT_FREEBSD4)
@@ -1337,6 +1331,11 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, i
}
 
switch (cmd) {
+   case TUNGIFNAME:
+   ifrp = (struct ifreq *)data;
+   strlcpy(ifrp->ifr_name, TUN2IFP(tp)->if_xname, IFNAMSIZ);
+
+   return (0);
case TUNSIFINFO:
tunp = (struct tuninfo *)data;
if (TUN2IFP(tp)->if_type != tunp->type)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350338 - in stable: 11/sbin/bectl 11/stand/libsa/zfs 12/sbin/bectl

2019-07-25 Thread Kyle Evans
Author: kevans
Date: Fri Jul 26 01:35:06 2019
New Revision: 350338
URL: https://svnweb.freebsd.org/changeset/base/350338

Log:
  MFC r348328: bectl(8): Address Coverity complaints
  
  CID 1400451: case 0 is missing a break/return and falling through to the
  default case.  waitpid(0, ...) makes little sense in the child, we likely
  wanted to terminate immediately.
  
  CID 1400453: size argument uses sizeof(char **) instead of sizeof(char *)
  and is assigned to a char **; sizeof's match but "this isn't a portable
  assumption".
  
  CID:  1400451, 1400453

Modified:
  stable/11/sbin/bectl/bectl_jail.c
  stable/11/stand/libsa/zfs/zfs.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sbin/bectl/bectl_jail.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sbin/bectl/bectl_jail.c
==
--- stable/11/sbin/bectl/bectl_jail.c   Fri Jul 26 00:27:47 2019
(r350337)
+++ stable/11/sbin/bectl/bectl_jail.c   Fri Jul 26 01:35:06 2019
(r350338)
@@ -155,7 +155,7 @@ build_jailcmd(char ***argvp, bool interactive, int arg
nargv += argc;
}
 
-   jargv = *argvp = calloc(nargv, sizeof(jargv));
+   jargv = *argvp = calloc(nargv, sizeof(*jargv));
if (jargv == NULL)
err(2, "calloc");
 
@@ -346,6 +346,7 @@ bectl_cmd_jail(int argc, char *argv[])
case 0:
execv("/usr/sbin/jail", jargv);
fprintf(stderr, "bectl jail: failed to execute\n");
+   return (1);
default:
waitpid(pid, NULL, 0);
}

Modified: stable/11/stand/libsa/zfs/zfs.c
==
--- stable/11/stand/libsa/zfs/zfs.c Fri Jul 26 00:27:47 2019
(r350337)
+++ stable/11/stand/libsa/zfs/zfs.c Fri Jul 26 01:35:06 2019
(r350338)
@@ -578,11 +578,10 @@ zfs_probe_dev(const char *devname, uint64_t *pool_guid
pa.fd = open(devname, O_RDONLY);
if (pa.fd == -1)
return (ENXIO);
-   /*
-* We will not probe the whole disk, we can not boot from such
-* disks and some systems will misreport the disk sizes and will
-* hang while accessing the disk.
-*/
+   /* Probe the whole disk */
+   ret = zfs_probe(pa.fd, pool_guid);
+   if (ret == 0)
+   return (0);
if (archsw.arch_getdev((void **)&dev, devname, NULL) == 0) {
int partition = dev->d_partition;
int slice = dev->d_slice;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350338 - in stable: 11/sbin/bectl 11/stand/libsa/zfs 12/sbin/bectl

2019-07-25 Thread Kyle Evans
Author: kevans
Date: Fri Jul 26 01:35:06 2019
New Revision: 350338
URL: https://svnweb.freebsd.org/changeset/base/350338

Log:
  MFC r348328: bectl(8): Address Coverity complaints
  
  CID 1400451: case 0 is missing a break/return and falling through to the
  default case.  waitpid(0, ...) makes little sense in the child, we likely
  wanted to terminate immediately.
  
  CID 1400453: size argument uses sizeof(char **) instead of sizeof(char *)
  and is assigned to a char **; sizeof's match but "this isn't a portable
  assumption".
  
  CID:  1400451, 1400453

Modified:
  stable/12/sbin/bectl/bectl_jail.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sbin/bectl/bectl_jail.c
  stable/11/stand/libsa/zfs/zfs.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sbin/bectl/bectl_jail.c
==
--- stable/12/sbin/bectl/bectl_jail.c   Fri Jul 26 00:27:47 2019
(r350337)
+++ stable/12/sbin/bectl/bectl_jail.c   Fri Jul 26 01:35:06 2019
(r350338)
@@ -155,7 +155,7 @@ build_jailcmd(char ***argvp, bool interactive, int arg
nargv += argc;
}
 
-   jargv = *argvp = calloc(nargv, sizeof(jargv));
+   jargv = *argvp = calloc(nargv, sizeof(*jargv));
if (jargv == NULL)
err(2, "calloc");
 
@@ -346,6 +346,7 @@ bectl_cmd_jail(int argc, char *argv[])
case 0:
execv("/usr/sbin/jail", jargv);
fprintf(stderr, "bectl jail: failed to execute\n");
+   return (1);
default:
waitpid(pid, NULL, 0);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350339 - in stable/11: sbin/bectl stand/libsa/zfs

2019-07-25 Thread Kyle Evans
Author: kevans
Date: Fri Jul 26 01:38:24 2019
New Revision: 350339
URL: https://svnweb.freebsd.org/changeset/base/350339

Log:
  Partial revert r350338: stable/11 part
  
  The stand/libsa changes were not supposed to ride along with this revision;
  backing out the stable/11 part and re-applying the MFC.
  
  Pointy hat:   kevans

Modified:
  stable/11/sbin/bectl/bectl_jail.c
  stable/11/stand/libsa/zfs/zfs.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/bectl/bectl_jail.c
==
--- stable/11/sbin/bectl/bectl_jail.c   Fri Jul 26 01:35:06 2019
(r350338)
+++ stable/11/sbin/bectl/bectl_jail.c   Fri Jul 26 01:38:24 2019
(r350339)
@@ -155,7 +155,7 @@ build_jailcmd(char ***argvp, bool interactive, int arg
nargv += argc;
}
 
-   jargv = *argvp = calloc(nargv, sizeof(*jargv));
+   jargv = *argvp = calloc(nargv, sizeof(jargv));
if (jargv == NULL)
err(2, "calloc");
 
@@ -346,7 +346,6 @@ bectl_cmd_jail(int argc, char *argv[])
case 0:
execv("/usr/sbin/jail", jargv);
fprintf(stderr, "bectl jail: failed to execute\n");
-   return (1);
default:
waitpid(pid, NULL, 0);
}

Modified: stable/11/stand/libsa/zfs/zfs.c
==
--- stable/11/stand/libsa/zfs/zfs.c Fri Jul 26 01:35:06 2019
(r350338)
+++ stable/11/stand/libsa/zfs/zfs.c Fri Jul 26 01:38:24 2019
(r350339)
@@ -578,10 +578,11 @@ zfs_probe_dev(const char *devname, uint64_t *pool_guid
pa.fd = open(devname, O_RDONLY);
if (pa.fd == -1)
return (ENXIO);
-   /* Probe the whole disk */
-   ret = zfs_probe(pa.fd, pool_guid);
-   if (ret == 0)
-   return (0);
+   /*
+* We will not probe the whole disk, we can not boot from such
+* disks and some systems will misreport the disk sizes and will
+* hang while accessing the disk.
+*/
if (archsw.arch_getdev((void **)&dev, devname, NULL) == 0) {
int partition = dev->d_partition;
int slice = dev->d_slice;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350340 - stable/11/sbin/bectl

2019-07-25 Thread Kyle Evans
Author: kevans
Date: Fri Jul 26 01:42:24 2019
New Revision: 350340
URL: https://svnweb.freebsd.org/changeset/base/350340

Log:
  MFC r348328: bectl(8): Address Coverity complaints
  
  CID 1400451: case 0 is missing a break/return and falling through to the
  default case.  waitpid(0, ...) makes little sense in the child, we likely
  wanted to terminate immediately.
  
  CID 1400453: size argument uses sizeof(char **) instead of sizeof(char *)
  and is assigned to a char **; sizeof's match but "this isn't a portable
  assumption".
  
  CID:  1400451, 1400453

Modified:
  stable/11/sbin/bectl/bectl_jail.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/bectl/bectl_jail.c
==
--- stable/11/sbin/bectl/bectl_jail.c   Fri Jul 26 01:38:24 2019
(r350339)
+++ stable/11/sbin/bectl/bectl_jail.c   Fri Jul 26 01:42:24 2019
(r350340)
@@ -155,7 +155,7 @@ build_jailcmd(char ***argvp, bool interactive, int arg
nargv += argc;
}
 
-   jargv = *argvp = calloc(nargv, sizeof(jargv));
+   jargv = *argvp = calloc(nargv, sizeof(*jargv));
if (jargv == NULL)
err(2, "calloc");
 
@@ -346,6 +346,7 @@ bectl_cmd_jail(int argc, char *argv[])
case 0:
execv("/usr/sbin/jail", jargv);
fprintf(stderr, "bectl jail: failed to execute\n");
+   return (1);
default:
waitpid(pid, NULL, 0);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350341 - stable/12/stand/libsa/zfs

2019-07-25 Thread Kyle Evans
Author: kevans
Date: Fri Jul 26 01:45:00 2019
New Revision: 350341
URL: https://svnweb.freebsd.org/changeset/base/350341

Log:
  MFC r344226, r344234: stand: zfs memory corruption bug
  
  r344226:
  Fix memory corruption bug introduced in r325310
  
  The bug occurred when a bounce buffer was used and the requested read
  size was greater than the size of the bounce buffer.  This commit also
  rewrites the read logic so that it is easier to systematically verify
  all alignment and size cases.
  
  r344234:
  It turns out r344226 narrowed the overrun bug but did not eliminate it 
entirely
  
  This commit fixes a remaining output buffer overrun in the
  single-sector case when there is a non-zero tail.

Modified:
  stable/12/stand/libsa/zfs/zfs.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/stand/libsa/zfs/zfs.c
==
--- stable/12/stand/libsa/zfs/zfs.c Fri Jul 26 01:42:24 2019
(r350340)
+++ stable/12/stand/libsa/zfs/zfs.c Fri Jul 26 01:45:00 2019
(r350341)
@@ -363,51 +363,100 @@ static int
 vdev_read(vdev_t *vdev, void *priv, off_t offset, void *buf, size_t bytes)
 {
int fd, ret;
-   size_t res, size, remainder, rb_size, blksz;
-   unsigned secsz;
-   off_t off;
-   char *bouncebuf, *rb_buf;
+   size_t res, head, tail, total_size, full_sec_size;
+   unsigned secsz, do_tail_read;
+   off_t start_sec;
+   char *outbuf, *bouncebuf;
 
fd = (uintptr_t) priv;
+   outbuf = (char *) buf;
bouncebuf = NULL;
 
ret = ioctl(fd, DIOCGSECTORSIZE, &secsz);
if (ret != 0)
return (ret);
 
-   off = offset / secsz;
-   remainder = offset % secsz;
-   if (lseek(fd, off * secsz, SEEK_SET) == -1)
-   return (errno);
+   /*
+* Handling reads of arbitrary offset and size - multi-sector case
+* and single-sector case.
+*
+*Multi-sector Case
+*(do_tail_read = true if tail > 0)
+*
+*   |<--total_size->|
+*   |   |
+*   |<--head-->|<--bytes>|<--tail-->|
+*   |  | |  |
+*   |  |   |<~full_sec_size~>|   |  |
+*   +--+ +--+
+*   |  |0101010| .  .  . |0101011|  |
+*   +--+ +--+
+* start_sec start_sec + n
+*
+*
+*  Single-sector Case
+*(do_tail_read = false)
+*
+*  |<--total_size = secsz->|
+*  |   |
+*  |<-head->|<---bytes--->|<-tail->|
+*  +---+
+*  ||0101010101010||
+*  +---+
+*  start_sec
+*/
+   start_sec = offset / secsz;
+   head = offset % secsz;
+   total_size = roundup2(head + bytes, secsz);
+   tail = total_size - (head + bytes);
+   do_tail_read = ((tail > 0) && (head + bytes > secsz));
+   full_sec_size = total_size;
+   if (head > 0)
+   full_sec_size -= secsz;
+   if (do_tail_read)
+   full_sec_size -= secsz;
 
-   rb_buf = buf;
-   rb_size = bytes;
-   size = roundup2(bytes + remainder, secsz);
-   blksz = size;
-   if (remainder != 0 || size != bytes) {
+   /* Return of partial sector data requires a bounce buffer. */
+   if ((head > 0) || do_tail_read) {
bouncebuf = zfs_alloc(secsz);
if (bouncebuf == NULL) {
printf("vdev_read: out of memory\n");
return (ENOMEM);
}
-   rb_buf = bouncebuf;
-   blksz = rb_size - remainder;
}
 
-   while (bytes > 0) {
-   res = read(fd, rb_buf, rb_size);
-   if (res != rb_size) {
+   if (lseek(fd, start_sec * secsz, SEEK_SET) == -1)
+   return (errno);
+
+   /* Partial data return from first sector */
+   if (head > 0) {
+   res = read(fd, bouncebuf, secsz);
+   if (res != secsz) {
ret = EIO;
goto error;
}
-   if (bytes < blksz)
-   blksz = bytes;
-   if (bouncebuf != NULL)
-   memcpy(buf, rb_buf + remainder, blksz);
-   buf = (void *)((uintptr_t)buf + blksz);
-   bytes -= blksz;
- 

svn commit: r350342 - in stable: 11/stand/libsa/zfs 12/stand/libsa/zfs

2019-07-25 Thread Kyle Evans
Author: kevans
Date: Fri Jul 26 01:47:20 2019
New Revision: 350342
URL: https://svnweb.freebsd.org/changeset/base/350342

Log:
  MFC r348471: stand: zfs: Free bouncebuf on error path in vdev_read
  
  r344226 inadvertently added this path in which we return from failure on an
  lseek and do not free bouncebuf on the way out.

Modified:
  stable/12/stand/libsa/zfs/zfs.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/stand/libsa/zfs/zfs.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/stand/libsa/zfs/zfs.c
==
--- stable/12/stand/libsa/zfs/zfs.c Fri Jul 26 01:45:00 2019
(r350341)
+++ stable/12/stand/libsa/zfs/zfs.c Fri Jul 26 01:47:20 2019
(r350342)
@@ -425,8 +425,10 @@ vdev_read(vdev_t *vdev, void *priv, off_t offset, void
}
}
 
-   if (lseek(fd, start_sec * secsz, SEEK_SET) == -1)
-   return (errno);
+   if (lseek(fd, start_sec * secsz, SEEK_SET) == -1) {
+   ret = errno;
+   goto error;
+   }
 
/* Partial data return from first sector */
if (head > 0) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350342 - in stable: 11/stand/libsa/zfs 12/stand/libsa/zfs

2019-07-25 Thread Kyle Evans
Author: kevans
Date: Fri Jul 26 01:47:20 2019
New Revision: 350342
URL: https://svnweb.freebsd.org/changeset/base/350342

Log:
  MFC r348471: stand: zfs: Free bouncebuf on error path in vdev_read
  
  r344226 inadvertently added this path in which we return from failure on an
  lseek and do not free bouncebuf on the way out.

Modified:
  stable/11/stand/libsa/zfs/zfs.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/stand/libsa/zfs/zfs.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/stand/libsa/zfs/zfs.c
==
--- stable/11/stand/libsa/zfs/zfs.c Fri Jul 26 01:45:00 2019
(r350341)
+++ stable/11/stand/libsa/zfs/zfs.c Fri Jul 26 01:47:20 2019
(r350342)
@@ -425,8 +425,10 @@ vdev_read(vdev_t *vdev, void *priv, off_t offset, void
}
}
 
-   if (lseek(fd, start_sec * secsz, SEEK_SET) == -1)
-   return (errno);
+   if (lseek(fd, start_sec * secsz, SEEK_SET) == -1) {
+   ret = errno;
+   goto error;
+   }
 
/* Partial data return from first sector */
if (head > 0) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350344 - in stable: 11/lib/libbe 11/sbin/bectl 11/sbin/bectl/tests 12/lib/libbe 12/sbin/bectl 12/sbin/bectl/tests

2019-07-25 Thread Kyle Evans
Author: kevans
Date: Fri Jul 26 01:49:58 2019
New Revision: 350344
URL: https://svnweb.freebsd.org/changeset/base/350344

Log:
  MFC r349380, r349383, r349455: bectl(8)/libbe(3) fixes
  
  r349380:
  libbe(3): mount: the BE dataset is mounted at /
  
  Other parts of libbe(3) were fairly strict on the mountpoint property of the
  BE dataset, and be_mount was not much better. It was improved in r347027 to
  allow mountpoint=none for depth==0, but this bit was still sensitive to
  mountpoint != / and mountpoint != none. Given that other parts of libbe(3)
  no longer restrict the mountpoint property here, and the rest of the base
  system is generally OK and will assume that a BE is mounted at /, let's do
  the same.
  
  r349383:
  libbe(3): restructure be_mount, skip canmount check for BE dataset
  
  Further cleanup after r349380; loader and kernel will both ignore canmount
  on the root dataset as well, so we should not be so strict about it when
  mounting it. be_mount is restructured to make it more clear that depth==0 is
  special, and to not try fetching these properties that we won't care about.
  
  r349455:
  bectl(8): create non-recursive boot environments
  
  bectl advertises that it has the ability to create recursive and
  non-recursive boot environments. This patch implements that functionality
  using the be_create_depth API provided by libbe. With this patch, bectl now
  works as bectl(8) describes in regards to creating recursive/non-recursive
  boot environments.

Modified:
  stable/11/lib/libbe/be_access.c
  stable/11/sbin/bectl/bectl.c
  stable/11/sbin/bectl/tests/bectl_test.sh
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/lib/libbe/be_access.c
  stable/12/sbin/bectl/bectl.c
  stable/12/sbin/bectl/tests/bectl_test.sh
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/lib/libbe/be_access.c
==
--- stable/11/lib/libbe/be_access.c Fri Jul 26 01:49:28 2019
(r350343)
+++ stable/11/lib/libbe/be_access.c Fri Jul 26 01:49:58 2019
(r350344)
@@ -89,25 +89,31 @@ be_mount_iter(zfs_handle_t *zfs_hdl, void *data)
return (0);
}
 
-   if (zfs_prop_get_int(zfs_hdl, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_OFF)
-   return (0);
+   /*
+* canmount and mountpoint are both ignored for the BE dataset, because
+* the rest of the system (kernel and loader) will effectively do the
+* same.
+*/
+   if (info->depth == 0) {
+   snprintf(tmp, BE_MAXPATHLEN, "%s", info->mountpoint);
+   } else {
+   if (zfs_prop_get_int(zfs_hdl, ZFS_PROP_CANMOUNT) ==
+   ZFS_CANMOUNT_OFF)
+   return (0);
 
-   if (zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, zfs_mnt, BE_MAXPATHLEN,
-   NULL, NULL, 0, 1))
-   return (1);
+   if (zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, zfs_mnt,
+   BE_MAXPATHLEN, NULL, NULL, 0, 1))
+   return (1);
 
-   if (strcmp("none", zfs_mnt) == 0) {
/*
-* mountpoint=none; we'll mount it at info->mountpoint assuming
-* we're at the root.  If we're not at the root, we're likely
-* at some intermediate dataset (e.g. zroot/var) that will have
-* children that may need to be mounted.
+* We've encountered mountpoint=none at some intermediate
+* dataset (e.g. zroot/var) that will have children that may
+* need to be mounted.  Skip mounting it, but iterate through
+* the children.
 */
-   if (info->depth > 0)
+   if (strcmp("none", zfs_mnt) == 0)
goto skipmount;
 
-   snprintf(tmp, BE_MAXPATHLEN, "%s", info->mountpoint);
-   } else {
mountpoint = be_mountpoint_augmented(info->lbh, zfs_mnt);
snprintf(tmp, BE_MAXPATHLEN, "%s%s", info->mountpoint,
mountpoint);

Modified: stable/11/sbin/bectl/bectl.c
==
--- stable/11/sbin/bectl/bectl.cFri Jul 26 01:49:28 2019
(r350343)
+++ stable/11/sbin/bectl/bectl.cFri Jul 26 01:49:58 2019
(r350344)
@@ -184,7 +184,8 @@ bectl_cmd_activate(int argc, char *argv[])
 static int
 bectl_cmd_create(int argc, char *argv[])
 {
-   char *atpos, *bootenv, *snapname, *source;
+   char snapshot[BE_MAXPATHLEN];
+   char *atpos, *bootenv, *snapname;
int err, opt;
bool recursive;
 
@@ -214,6 +215,8 @@ bectl_cmd_create(int argc, char *argv[])
}
 
bootenv = *argv;
+
+   err = BE_ERR_SUCCESS;
if ((atpos = strchr(bootenv, '@')) != NULL) {
/*

svn commit: r350344 - in stable: 11/lib/libbe 11/sbin/bectl 11/sbin/bectl/tests 12/lib/libbe 12/sbin/bectl 12/sbin/bectl/tests

2019-07-25 Thread Kyle Evans
Author: kevans
Date: Fri Jul 26 01:49:58 2019
New Revision: 350344
URL: https://svnweb.freebsd.org/changeset/base/350344

Log:
  MFC r349380, r349383, r349455: bectl(8)/libbe(3) fixes
  
  r349380:
  libbe(3): mount: the BE dataset is mounted at /
  
  Other parts of libbe(3) were fairly strict on the mountpoint property of the
  BE dataset, and be_mount was not much better. It was improved in r347027 to
  allow mountpoint=none for depth==0, but this bit was still sensitive to
  mountpoint != / and mountpoint != none. Given that other parts of libbe(3)
  no longer restrict the mountpoint property here, and the rest of the base
  system is generally OK and will assume that a BE is mounted at /, let's do
  the same.
  
  r349383:
  libbe(3): restructure be_mount, skip canmount check for BE dataset
  
  Further cleanup after r349380; loader and kernel will both ignore canmount
  on the root dataset as well, so we should not be so strict about it when
  mounting it. be_mount is restructured to make it more clear that depth==0 is
  special, and to not try fetching these properties that we won't care about.
  
  r349455:
  bectl(8): create non-recursive boot environments
  
  bectl advertises that it has the ability to create recursive and
  non-recursive boot environments. This patch implements that functionality
  using the be_create_depth API provided by libbe. With this patch, bectl now
  works as bectl(8) describes in regards to creating recursive/non-recursive
  boot environments.

Modified:
  stable/12/lib/libbe/be_access.c
  stable/12/sbin/bectl/bectl.c
  stable/12/sbin/bectl/tests/bectl_test.sh
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/lib/libbe/be_access.c
  stable/11/sbin/bectl/bectl.c
  stable/11/sbin/bectl/tests/bectl_test.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/lib/libbe/be_access.c
==
--- stable/12/lib/libbe/be_access.c Fri Jul 26 01:49:28 2019
(r350343)
+++ stable/12/lib/libbe/be_access.c Fri Jul 26 01:49:58 2019
(r350344)
@@ -89,25 +89,31 @@ be_mount_iter(zfs_handle_t *zfs_hdl, void *data)
return (0);
}
 
-   if (zfs_prop_get_int(zfs_hdl, ZFS_PROP_CANMOUNT) == ZFS_CANMOUNT_OFF)
-   return (0);
+   /*
+* canmount and mountpoint are both ignored for the BE dataset, because
+* the rest of the system (kernel and loader) will effectively do the
+* same.
+*/
+   if (info->depth == 0) {
+   snprintf(tmp, BE_MAXPATHLEN, "%s", info->mountpoint);
+   } else {
+   if (zfs_prop_get_int(zfs_hdl, ZFS_PROP_CANMOUNT) ==
+   ZFS_CANMOUNT_OFF)
+   return (0);
 
-   if (zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, zfs_mnt, BE_MAXPATHLEN,
-   NULL, NULL, 0, 1))
-   return (1);
+   if (zfs_prop_get(zfs_hdl, ZFS_PROP_MOUNTPOINT, zfs_mnt,
+   BE_MAXPATHLEN, NULL, NULL, 0, 1))
+   return (1);
 
-   if (strcmp("none", zfs_mnt) == 0) {
/*
-* mountpoint=none; we'll mount it at info->mountpoint assuming
-* we're at the root.  If we're not at the root, we're likely
-* at some intermediate dataset (e.g. zroot/var) that will have
-* children that may need to be mounted.
+* We've encountered mountpoint=none at some intermediate
+* dataset (e.g. zroot/var) that will have children that may
+* need to be mounted.  Skip mounting it, but iterate through
+* the children.
 */
-   if (info->depth > 0)
+   if (strcmp("none", zfs_mnt) == 0)
goto skipmount;
 
-   snprintf(tmp, BE_MAXPATHLEN, "%s", info->mountpoint);
-   } else {
mountpoint = be_mountpoint_augmented(info->lbh, zfs_mnt);
snprintf(tmp, BE_MAXPATHLEN, "%s%s", info->mountpoint,
mountpoint);

Modified: stable/12/sbin/bectl/bectl.c
==
--- stable/12/sbin/bectl/bectl.cFri Jul 26 01:49:28 2019
(r350343)
+++ stable/12/sbin/bectl/bectl.cFri Jul 26 01:49:58 2019
(r350344)
@@ -184,7 +184,8 @@ bectl_cmd_activate(int argc, char *argv[])
 static int
 bectl_cmd_create(int argc, char *argv[])
 {
-   char *atpos, *bootenv, *snapname, *source;
+   char snapshot[BE_MAXPATHLEN];
+   char *atpos, *bootenv, *snapname;
int err, opt;
bool recursive;
 
@@ -214,6 +215,8 @@ bectl_cmd_create(int argc, char *argv[])
}
 
bootenv = *argv;
+
+   err = BE_ERR_SUCCESS;
if ((atpos = strchr(bootenv, '@')) != NULL) {
/*

svn commit: r350464 - in head/sys: compat/cloudabi kern

2019-07-31 Thread Kyle Evans
Author: kevans
Date: Wed Jul 31 15:16:51 2019
New Revision: 350464
URL: https://svnweb.freebsd.org/changeset/base/350464

Log:
  kern_shm_open: push O_CLOEXEC into caller control
  
  The motivation for this change is to allow wrappers around shm to be written
  that don't set CLOEXEC. kern_shm_open currently accepts O_CLOEXEC but sets
  it unconditionally. kern_shm_open is used by the shm_open(2) syscall, which
  is mandated by POSIX to set CLOEXEC, and CloudABI's sys_fd_create1().
  Presumably O_CLOEXEC is intended in the latter caller, but it's unclear from
  the context.
  
  sys_shm_open() now unconditionally sets O_CLOEXEC to meet POSIX
  requirements, and a comment has been dropped in to kern_fd_open() to explain
  the situation and add a pointer to where O_CLOEXEC setting is maintained for
  shm_open(2) correctness. CloudABI's sys_fd_create1() also unconditionally
  sets O_CLOEXEC to match previous behavior.
  
  This also has the side-effect of making flags correctly reflect the
  O_CLOEXEC status on this fd for the rest of kern_shm_open(), but a
  glance-over leads me to believe that it didn't really matter.
  
  Reviewed by:  kib, markj
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D21119

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

Modified: head/sys/compat/cloudabi/cloudabi_fd.c
==
--- head/sys/compat/cloudabi/cloudabi_fd.c  Wed Jul 31 05:38:39 2019
(r350463)
+++ head/sys/compat/cloudabi/cloudabi_fd.c  Wed Jul 31 15:16:51 2019
(r350464)
@@ -94,7 +94,8 @@ cloudabi_sys_fd_create1(struct thread *td,
case CLOUDABI_FILETYPE_SHARED_MEMORY:
cap_rights_init(&fcaps.fc_rights, CAP_FSTAT, CAP_FTRUNCATE,
CAP_MMAP_RWX);
-   return (kern_shm_open(td, SHM_ANON, O_RDWR, 0, &fcaps));
+   return (kern_shm_open(td, SHM_ANON, O_RDWR | O_CLOEXEC, 0,
+   &fcaps));
default:
return (EINVAL);
}

Modified: head/sys/kern/uipc_shm.c
==
--- head/sys/kern/uipc_shm.cWed Jul 31 05:38:39 2019(r350463)
+++ head/sys/kern/uipc_shm.cWed Jul 31 15:16:51 2019(r350464)
@@ -729,7 +729,14 @@ kern_shm_open(struct thread *td, const char *userpath,
fdp = td->td_proc->p_fd;
cmode = (mode & ~fdp->fd_cmask) & ACCESSPERMS;
 
-   error = falloc_caps(td, &fp, &fd, O_CLOEXEC, fcaps);
+   /*
+* shm_open(2) created shm should always have O_CLOEXEC set, as mandated
+* by POSIX.  We allow it to be unset here so that an in-kernel
+* interface may be written as a thin layer around shm, optionally not
+* setting CLOEXEC.  For shm_open(2), O_CLOEXEC is set unconditionally
+* in sys_shm_open() to keep this implementation compliant.
+*/
+   error = falloc_caps(td, &fp, &fd, flags & O_CLOEXEC, fcaps);
if (error)
return (error);
 
@@ -844,7 +851,8 @@ int
 sys_shm_open(struct thread *td, struct shm_open_args *uap)
 {
 
-   return (kern_shm_open(td, uap->path, uap->flags, uap->mode, NULL));
+   return (kern_shm_open(td, uap->path, uap->flags | O_CLOEXEC, uap->mode,
+   NULL));
 }
 
 int
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350465 - in stable: 11/sys/net 12/sys/net

2019-07-31 Thread Kyle Evans
Author: kevans
Date: Wed Jul 31 15:56:40 2019
New Revision: 350465
URL: https://svnweb.freebsd.org/changeset/base/350465

Log:
  MFC r350336: if_tun(4): Add TUNGIFNAME
  
  This is effectively a direct commit to stable branches as tun/tap have been
  merged in head. The code here is identical, just in a slightly different
  context.

Modified:
  stable/11/sys/net/if_tun.c
  stable/11/sys/net/if_tun.h
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sys/net/if_tun.c
  stable/12/sys/net/if_tun.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sys/net/if_tun.c
==
--- stable/11/sys/net/if_tun.c  Wed Jul 31 15:16:51 2019(r350464)
+++ stable/11/sys/net/if_tun.c  Wed Jul 31 15:56:40 2019(r350465)
@@ -735,12 +735,16 @@ staticint
 tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag,
 struct thread *td)
 {
-   struct ifreq ifr;
+   struct ifreq ifr, *ifrp;
struct tun_softc *tp = dev->si_drv1;
struct tuninfo *tunp;
int error;
 
switch (cmd) {
+   case TUNGIFNAME:
+   ifrp = (struct ifreq *)data;
+   strlcpy(ifrp->ifr_name, TUN2IFP(tp)->if_xname, IFNAMSIZ);
+   break;
case TUNSIFINFO:
tunp = (struct tuninfo *)data;
if (TUN2IFP(tp)->if_type != tunp->type)

Modified: stable/11/sys/net/if_tun.h
==
--- stable/11/sys/net/if_tun.h  Wed Jul 31 15:16:51 2019(r350464)
+++ stable/11/sys/net/if_tun.h  Wed Jul 31 15:56:40 2019(r350465)
@@ -40,6 +40,7 @@ struct tuninfo {
 #defineTUNSIFINFO  _IOW('t', 91, struct tuninfo)
 #defineTUNGIFINFO  _IOR('t', 92, struct tuninfo)
 #defineTUNSLMODE   _IOW('t', 93, int)
+#defineTUNGIFNAME  _IOR('t', 93, struct ifreq)
 #defineTUNSIFMODE  _IOW('t', 94, int)
 #defineTUNSIFPID   _IO('t', 95)
 #defineTUNSIFHEAD  _IOW('t', 96, int)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350465 - in stable: 11/sys/net 12/sys/net

2019-07-31 Thread Kyle Evans
Author: kevans
Date: Wed Jul 31 15:56:40 2019
New Revision: 350465
URL: https://svnweb.freebsd.org/changeset/base/350465

Log:
  MFC r350336: if_tun(4): Add TUNGIFNAME
  
  This is effectively a direct commit to stable branches as tun/tap have been
  merged in head. The code here is identical, just in a slightly different
  context.

Modified:
  stable/12/sys/net/if_tun.c
  stable/12/sys/net/if_tun.h
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/net/if_tun.c
  stable/11/sys/net/if_tun.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sys/net/if_tun.c
==
--- stable/12/sys/net/if_tun.c  Wed Jul 31 15:16:51 2019(r350464)
+++ stable/12/sys/net/if_tun.c  Wed Jul 31 15:56:40 2019(r350465)
@@ -735,12 +735,16 @@ staticint
 tunioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag,
 struct thread *td)
 {
-   struct ifreq ifr;
+   struct ifreq ifr, *ifrp;
struct tun_softc *tp = dev->si_drv1;
struct tuninfo *tunp;
int error;
 
switch (cmd) {
+   case TUNGIFNAME:
+   ifrp = (struct ifreq *)data;
+   strlcpy(ifrp->ifr_name, TUN2IFP(tp)->if_xname, IFNAMSIZ);
+   break;
case TUNSIFINFO:
tunp = (struct tuninfo *)data;
if (TUN2IFP(tp)->if_type != tunp->type)

Modified: stable/12/sys/net/if_tun.h
==
--- stable/12/sys/net/if_tun.h  Wed Jul 31 15:16:51 2019(r350464)
+++ stable/12/sys/net/if_tun.h  Wed Jul 31 15:56:40 2019(r350465)
@@ -40,6 +40,7 @@ struct tuninfo {
 #defineTUNSIFINFO  _IOW('t', 91, struct tuninfo)
 #defineTUNGIFINFO  _IOR('t', 92, struct tuninfo)
 #defineTUNSLMODE   _IOW('t', 93, int)
+#defineTUNGIFNAME  _IOR('t', 93, struct ifreq)
 #defineTUNSIFMODE  _IOW('t', 94, int)
 #defineTUNSIFPID   _IO('t', 95)
 #defineTUNSIFHEAD  _IOW('t', 96, int)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350576 - head/sbin/ipfw

2019-08-04 Thread Kyle Evans
Author: kevans
Date: Mon Aug  5 00:08:25 2019
New Revision: 350576
URL: https://svnweb.freebsd.org/changeset/base/350576

Log:
  ipfw: fix jail option after r348215
  
  r348215 changed jail_getid(3) to validate passed-in jids as active jails
  (as the function is documented to return -1 if the jail does not exist).
  This broke the jail option (in some cases?) as the jail historically hasn't
  needed to exist at the time of rule parsing; jids will get stored and later
  applied.
  
  Fix this caller to attempt to parse *av as a number first and just use it
  as-is to match historical behavior. jail_getid(3) must still be used in
  order for name arguments to work, but it's strictly a fallback in case we
  weren't given a number.
  
  Reported and tested by:   Ari Suutari 
  Reviewed by:  ae
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D21128

Modified:
  head/sbin/ipfw/ipfw2.c

Modified: head/sbin/ipfw/ipfw2.c
==
--- head/sbin/ipfw/ipfw2.c  Sun Aug  4 21:43:34 2019(r350575)
+++ head/sbin/ipfw/ipfw2.c  Mon Aug  5 00:08:25 2019(r350576)
@@ -4674,12 +4674,27 @@ read_options:
case TOK_JAIL:
NEED1("jail requires argument");
{
+   char *end;
int jid;
 
cmd->opcode = O_JAIL;
-   jid = jail_getid(*av);
-   if (jid < 0)
-   errx(EX_DATAERR, "%s", jail_errmsg);
+   /*
+* If av is a number, then we'll just pass it as-is.  If
+* it's a name, try to resolve that to a jid.
+*
+* We save the jail_getid(3) call for a fallback because
+* it entails an unconditional trip to the kernel to
+* either validate a jid or resolve a name to a jid.
+* This specific token doesn't currently require a
+* jid to be an active jail, so we save a transition
+* by simply using a number that we're given.
+*/
+   jid = strtoul(*av, &end, 10);
+   if (*end != '\0') {
+   jid = jail_getid(*av);
+   if (jid < 0)
+   errx(EX_DATAERR, "%s", jail_errmsg);
+   }
cmd32->d[0] = (uint32_t)jid;
cmd->len |= F_INSN_SIZE(ipfw_insn_u32);
av++;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350630 - head/sys/dev/oce

2019-08-06 Thread Kyle Evans
Author: kevans
Date: Tue Aug  6 13:09:20 2019
New Revision: 350630
URL: https://svnweb.freebsd.org/changeset/base/350630

Log:
  oce(4): potential out of bounds access before vector validation
  
  Submitted by: Augustin Cavalier 
  Obtained from:Haiku (ec2b89264cfc63e05e611cce82cc449197403aa4)
  MFC after:3 days

Modified:
  head/sys/dev/oce/oce_if.c

Modified: head/sys/dev/oce/oce_if.c
==
--- head/sys/dev/oce/oce_if.c   Tue Aug  6 12:19:09 2019(r350629)
+++ head/sys/dev/oce/oce_if.c   Tue Aug  6 13:09:20 2019(r350630)
@@ -836,11 +836,13 @@ oce_fast_isr(void *arg)
 static int
 oce_alloc_intr(POCE_SOFTC sc, int vector, void (*isr) (void *arg, int pending))
 {
-   POCE_INTR_INFO ii = &sc->intrs[vector];
+   POCE_INTR_INFO ii;
int rc = 0, rr;
 
if (vector >= OCE_MAX_EQ)
return (EINVAL);
+
+   ii = &sc->intrs[vector];
 
/* Set the resource id for the interrupt.
 * MSIx is vector + 1 for the resource id,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r350657 - head/sys/dev/ral

2019-08-06 Thread Kyle Evans
Author: kevans
Date: Tue Aug  6 20:21:57 2019
New Revision: 350657
URL: https://svnweb.freebsd.org/changeset/base/350657

Log:
  ral: rt2860: fix wcid2ni access/size issue
  
  RT2860_WCID_MAX is supposed to describe the max STA index for wcid2ni, and
  was instead being used as the size -- off-by-one.
  
  rt2860_drain_stats_fifo was range-checking wcid only after accessing
  out-of-bounds potentially.
  
  Submitted by: Augustin Cavalier  (basically)
  Obtained from:Haiku (58d16d9fe2d5a209cf22823359a8407d138e1a87)
  Differential Revision:3 days

Modified:
  head/sys/dev/ral/rt2860.c
  head/sys/dev/ral/rt2860var.h

Modified: head/sys/dev/ral/rt2860.c
==
--- head/sys/dev/ral/rt2860.c   Tue Aug  6 20:13:28 2019(r350656)
+++ head/sys/dev/ral/rt2860.c   Tue Aug  6 20:21:57 2019(r350657)
@@ -1092,10 +1092,12 @@ rt2860_drain_stats_fifo(struct rt2860_softc *sc)
DPRINTFN(4, ("tx stat 0x%08x\n", stat));
 
wcid = (stat >> RT2860_TXQ_WCID_SHIFT) & 0xff;
+   if (wcid > RT2860_WCID_MAX)
+   continue;
ni = sc->wcid2ni[wcid];
 
/* if no ACK was requested, no feedback is available */
-   if (!(stat & RT2860_TXQ_ACKREQ) || wcid == 0xff || ni == NULL)
+   if (!(stat & RT2860_TXQ_ACKREQ) || ni == NULL)
continue;
 
/* update per-STA AMRR stats */

Modified: head/sys/dev/ral/rt2860var.h
==
--- head/sys/dev/ral/rt2860var.hTue Aug  6 20:13:28 2019
(r350656)
+++ head/sys/dev/ral/rt2860var.hTue Aug  6 20:21:57 2019
(r350657)
@@ -142,7 +142,7 @@ struct rt2860_softc {
 #define RT2860_PCIE(1 << 2)
 #defineRT2860_RUNNING  (1 << 3)
 
-   struct ieee80211_node   *wcid2ni[RT2860_WCID_MAX];
+   struct ieee80211_node   *wcid2ni[RT2860_WCID_MAX + 1];
 
struct rt2860_tx_ring   txq[6];
struct rt2860_rx_ring   rxq;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r347241 - in head: . sbin/ifconfig share/man/man4 sys/amd64/conf sys/arm/conf sys/arm64/conf sys/conf sys/i386/conf sys/mips/conf sys/modules sys/modules/if_tap sys/modules/if_tun sys/m...

2019-05-07 Thread Kyle Evans
   */
-   short   mtu;/* maximum transmission unit */
-   u_char  type;   /* ethernet, tokenring, etc. */
-   u_char  dummy;  /* place holder  */
-};
+#definetapinfo tuninfo
 
-/* ioctl's for get/set debug */
-#defineTAPSDEBUG   _IOW('t', 90, int)
-#defineTAPGDEBUG   _IOR('t', 89, int)
-#defineTAPSIFINFO  _IOW('t', 91, struct tapinfo)
-#defineTAPGIFINFO  _IOR('t', 92, struct tapinfo)
+/*
+ * ioctl's for get/set debug; these are aliases of TUN* ioctls, see 
net/if_tun.h
+ * for details.
+ */
+#defineTAPSDEBUG   TUNSDEBUG
+#defineTAPGDEBUG   TUNGDEBUG
+#defineTAPSIFINFO  TUNSIFINFO
+#defineTAPGIFINFO  TUNGIFINFO
 #defineTAPGIFNAME  _IOR('t', 93, struct ifreq)
 
 /* VMware ioctl's */

Copied and modified: head/sys/net/if_tuntap.c (from r347240, 
head/sys/net/if_tun.c)
==
--- head/sys/net/if_tun.c   Wed May  8 01:35:43 2019(r347240, copy 
source)
+++ head/sys/net/if_tuntap.cWed May  8 02:32:11 2019(r347241)
@@ -1,6 +1,36 @@
 /* $NetBSD: if_tun.c,v 1.14 1994/06/29 06:36:25 cgd Exp $  */
-
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (C) 1999-2000 by Maksim Yevmenkin 
+ * All rights reserved.
+ * Copyright (c) 2019 Kyle Evans 
+ *
+ * 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 THE AUTHOR 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 THE AUTHOR 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.
+ *
+ * BASED ON:
+ * -
+ *
  * Copyright (c) 1988, Julian Onions 
  * Nottingham University 1987.
  *
@@ -45,9 +75,12 @@
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -56,20 +89,22 @@
 #include 
 #endif
 #include 
+#include 
 #include 
 
 #include 
 #include 
-
 #include 
 
+struct tuntap_driver;
+
 /*
  * tun_list is protected by global tunmtx.  Other mutable fields are
  * protected by tun->tun_mtx, or by their owning subsystem.  tun_dev is
  * static for the duration of a tunnel interface.
  */
-struct tun_softc {
-   TAILQ_ENTRY(tun_softc)  tun_list;
+struct tuntap_softc {
+   TAILQ_ENTRY(tuntap_softc)   tun_list;
struct cdev *tun_dev;
u_short tun_flags;  /* misc flags */
 #defineTUN_OPEN0x0001
@@ -82,60 +117,88 @@ struct tun_softc {
 #defineTUN_ASYNC   0x0080
 #defineTUN_IFHEAD  0x0100
 #defineTUN_DYING   0x0200
+#defineTUN_L2  0x0400
+#defineTUN_VMNET   0x0800
 
 #define TUN_READY   (TUN_OPEN | TUN_INITED)
 
pid_t   tun_pid;/* owning pid */
struct  ifnet *tun_ifp; /* the interface */
struct  sigio *tun_sigio;   /* information for async I/O */
+   struct  tuntap_driver *tun_drv; /* appropriate driver */
struct  selinfo tun_rsel;   /* read select */
struct mtx  tun_mtx;/* protect mutable softc fields */
struct cv   tun_cv; /* protect against ref'd dev destroy */
+   struct ether_addr   tun_ether;  /* remote address */
 };
 #define TUN2IFP(sc)((sc)->tun_ifp)
 
 #define TUNDEBUG   if (tundebug) if_printf
 
+#defineTUN_LOCK(tp)mtx_lock(&(tp)->tun_mtx)
+#defineTUN_UNLOCK(tp)  mtx_unlock(&(tp)->tun_mtx)
+
+#defineTUN_VMIO_FLAG_MASK  0x0fff
+
 /*
  * All mutable global variables in if_tun are lock

svn commit: r347376 - stable/11/sys/net

2019-05-08 Thread Kyle Evans
Author: kevans
Date: Thu May  9 01:16:03 2019
New Revision: 347376
URL: https://svnweb.freebsd.org/changeset/base/347376

Log:
  MFC r339121 (tuexen): Use strlcpy() instead of strncpy().
  
  CID:  1395980, 1395981

Modified:
  stable/11/sys/net/if_tap.c
  stable/11/sys/net/if_tun.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/net/if_tap.c
==
--- stable/11/sys/net/if_tap.c  Wed May  8 23:39:24 2019(r347375)
+++ stable/11/sys/net/if_tap.c  Thu May  9 01:16:03 2019(r347376)
@@ -742,7 +742,7 @@ tapioctl(struct cdev *dev, u_long cmd, caddr_t data, i
return (EPROTOTYPE);
mtx_lock(&tp->tap_mtx);
if (ifp->if_mtu != tapp->mtu) {
-   strncpy(ifr.ifr_name, if_name(ifp), IFNAMSIZ);
+   strlcpy(ifr.ifr_name, if_name(ifp), IFNAMSIZ);
ifr.ifr_mtu = tapp->mtu;
CURVNET_SET(ifp->if_vnet);
error = ifhwioctl(SIOCSIFMTU, ifp,

Modified: stable/11/sys/net/if_tun.c
==
--- stable/11/sys/net/if_tun.c  Wed May  8 23:39:24 2019(r347375)
+++ stable/11/sys/net/if_tun.c  Thu May  9 01:16:03 2019(r347376)
@@ -729,7 +729,7 @@ tunioctl(struct cdev *dev, u_long cmd, caddr_t data, i
return (EPROTOTYPE);
mtx_lock(&tp->tun_mtx);
if (TUN2IFP(tp)->if_mtu != tunp->mtu) {
-   strncpy(ifr.ifr_name, if_name(TUN2IFP(tp)), IFNAMSIZ);
+   strlcpy(ifr.ifr_name, if_name(TUN2IFP(tp)), IFNAMSIZ);
ifr.ifr_mtu = tunp->mtu;
CURVNET_SET(TUN2IFP(tp)->if_vnet);
error = ifhwioctl(SIOCSIFMTU, TUN2IFP(tp),
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r347378 - in stable: 11/sys/geom 11/sys/net 12/sys/geom 12/sys/net

2019-05-08 Thread Kyle Evans
Author: kevans
Date: Thu May  9 03:51:34 2019
New Revision: 347378
URL: https://svnweb.freebsd.org/changeset/base/347378

Log:
  MFC r346602, r346670-r346671, r347183: tun/tap race fixes
  
  r346602:
  tun(4): Defer clearing TUN_OPEN until much later
  
  tun destruction will not continue until TUN_OPEN is cleared. There are brief
  moments in tunclose where the mutex is dropped and we've already cleared
  TUN_OPEN, so tun_destroy would be able to proceed while we're in the middle
  of cleaning up the tun still. tun_destroy should be blocked until these
  parts (address/route purges, mostly) are complete.
  
  r346670:
  tun/tap: close race between destroy/ioctl handler
  
  It seems that there should be a better way to handle this, but this seems to
  be the more common approach and it should likely get replaced in all of the
  places it happens... Basically, thread 1 is in the process of destroying the
  tun/tap while thread 2 is executing one of the ioctls that requires the
  tun/tap mutex and the mutex is destroyed before the ioctl handler can
  acquire it.
  
  This is only one of the races described/found in PR 233955.
  
  r346671:
  tun(4): Don't allow open of open or dying devices
  
  Previously, a pid check was used to prevent open of the tun(4); this works,
  but may not make the most sense as we don't prevent the owner process from
  opening the tun device multiple times.
  
  The potential race described near tun_pid should not be an issue: if a
  tun(4) is to be handed off, its fd has to have been sent via control message
  or some other mechanism that duplicates the fd to the receiving process so
  that it may set the pid. Otherwise, the pid gets cleared when the original
  process closes it and you have no effective handoff mechanism.
  
  Close up another potential issue with handing a tun(4) off by not clobbering
  state if the closer isn't the controller anymore. If we want some state to
  be cleared, we should do that a little more surgically.
  
  Additionally, nothing prevents a dying tun(4) from being "reopened" in the
  middle of tun_destroy as soon as the mutex is unlocked, quickly leading to a
  bad time. Return EBUSY if we're marked for destruction, as well, and the
  consumer will need to deal with it. The associated character device will be
  destroyed in short order.
  
  r347183:
  geom: fix initialization order
  
  There's a race between the initialization of devsoftc.mtx (by devinit)
  and the creation of the geom worker thread g_run_events, which calls
  devctl_queue_data_f. Both of those are initialized at SI_SUB_DRIVERS
  and SI_ORDER_FIRST, which means the geom worked thread can be created
  before the mutex has been initialized, leading to the panic below:
  
   wpanic: mtx_lock() of spin mutex (null) @ 
/usr/home/osstest/build.135317.build-amd64-freebsd/freebsd/sys/kern/subr_bus.c:620
   cpuid = 3
   time = 1
   KDB: stack backtrace:
   db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 
0xfe003b968710
   vpanic() at vpanic+0x19d/frame 0xfe003b968760
   panic() at panic+0x43/frame 0xfe003b9687c0
   __mtx_lock_flags() at __mtx_lock_flags+0x145/frame 0xfe003b968810
   devctl_queue_data_f() at devctl_queue_data_f+0x6a/frame 0xfe003b968840
   g_dev_taste() at g_dev_taste+0x463/frame 0xfe003b968a00
   g_load_class() at g_load_class+0x1bc/frame 0xfe003b968a30
   g_run_events() at g_run_events+0x197/frame 0xfe003b968a70
   fork_exit() at fork_exit+0x84/frame 0xfe003b968ab0
   fork_trampoline() at fork_trampoline+0xe/frame 0xfe003b968ab0
   --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
   KDB: enter: panic
   [ thread pid 13 tid 100029 ]
   Stopped at  kdb_enter+0x3b: movq$0,kdb_why
  
  Fix this by initializing geom at SI_ORDER_SECOND instead of
  SI_ORDER_FIRST.
  
  PR:   233955

Modified:
  stable/11/sys/geom/geom.h
  stable/11/sys/net/if_tap.c
  stable/11/sys/net/if_tun.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sys/geom/geom.h
  stable/12/sys/net/if_tap.c
  stable/12/sys/net/if_tun.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sys/geom/geom.h
==
--- stable/11/sys/geom/geom.h   Thu May  9 01:16:34 2019(r347377)
+++ stable/11/sys/geom/geom.h   Thu May  9 03:51:34 2019(r347378)
@@ -400,7 +400,7 @@ g_free(void *ptr)
static moduledata_t name##_mod = {  \
#name, g_modevent, &class   \
};  \
-   DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
+   DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND);
 
 int g_is_geom_thread(struct thread *td);
 

Modified: stable/11/sys/net/if_tap.c
==

svn commit: r347378 - in stable: 11/sys/geom 11/sys/net 12/sys/geom 12/sys/net

2019-05-08 Thread Kyle Evans
Author: kevans
Date: Thu May  9 03:51:34 2019
New Revision: 347378
URL: https://svnweb.freebsd.org/changeset/base/347378

Log:
  MFC r346602, r346670-r346671, r347183: tun/tap race fixes
  
  r346602:
  tun(4): Defer clearing TUN_OPEN until much later
  
  tun destruction will not continue until TUN_OPEN is cleared. There are brief
  moments in tunclose where the mutex is dropped and we've already cleared
  TUN_OPEN, so tun_destroy would be able to proceed while we're in the middle
  of cleaning up the tun still. tun_destroy should be blocked until these
  parts (address/route purges, mostly) are complete.
  
  r346670:
  tun/tap: close race between destroy/ioctl handler
  
  It seems that there should be a better way to handle this, but this seems to
  be the more common approach and it should likely get replaced in all of the
  places it happens... Basically, thread 1 is in the process of destroying the
  tun/tap while thread 2 is executing one of the ioctls that requires the
  tun/tap mutex and the mutex is destroyed before the ioctl handler can
  acquire it.
  
  This is only one of the races described/found in PR 233955.
  
  r346671:
  tun(4): Don't allow open of open or dying devices
  
  Previously, a pid check was used to prevent open of the tun(4); this works,
  but may not make the most sense as we don't prevent the owner process from
  opening the tun device multiple times.
  
  The potential race described near tun_pid should not be an issue: if a
  tun(4) is to be handed off, its fd has to have been sent via control message
  or some other mechanism that duplicates the fd to the receiving process so
  that it may set the pid. Otherwise, the pid gets cleared when the original
  process closes it and you have no effective handoff mechanism.
  
  Close up another potential issue with handing a tun(4) off by not clobbering
  state if the closer isn't the controller anymore. If we want some state to
  be cleared, we should do that a little more surgically.
  
  Additionally, nothing prevents a dying tun(4) from being "reopened" in the
  middle of tun_destroy as soon as the mutex is unlocked, quickly leading to a
  bad time. Return EBUSY if we're marked for destruction, as well, and the
  consumer will need to deal with it. The associated character device will be
  destroyed in short order.
  
  r347183:
  geom: fix initialization order
  
  There's a race between the initialization of devsoftc.mtx (by devinit)
  and the creation of the geom worker thread g_run_events, which calls
  devctl_queue_data_f. Both of those are initialized at SI_SUB_DRIVERS
  and SI_ORDER_FIRST, which means the geom worked thread can be created
  before the mutex has been initialized, leading to the panic below:
  
   wpanic: mtx_lock() of spin mutex (null) @ 
/usr/home/osstest/build.135317.build-amd64-freebsd/freebsd/sys/kern/subr_bus.c:620
   cpuid = 3
   time = 1
   KDB: stack backtrace:
   db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 
0xfe003b968710
   vpanic() at vpanic+0x19d/frame 0xfe003b968760
   panic() at panic+0x43/frame 0xfe003b9687c0
   __mtx_lock_flags() at __mtx_lock_flags+0x145/frame 0xfe003b968810
   devctl_queue_data_f() at devctl_queue_data_f+0x6a/frame 0xfe003b968840
   g_dev_taste() at g_dev_taste+0x463/frame 0xfe003b968a00
   g_load_class() at g_load_class+0x1bc/frame 0xfe003b968a30
   g_run_events() at g_run_events+0x197/frame 0xfe003b968a70
   fork_exit() at fork_exit+0x84/frame 0xfe003b968ab0
   fork_trampoline() at fork_trampoline+0xe/frame 0xfe003b968ab0
   --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
   KDB: enter: panic
   [ thread pid 13 tid 100029 ]
   Stopped at  kdb_enter+0x3b: movq$0,kdb_why
  
  Fix this by initializing geom at SI_ORDER_SECOND instead of
  SI_ORDER_FIRST.
  
  PR:   233955

Modified:
  stable/12/sys/geom/geom.h
  stable/12/sys/net/if_tap.c
  stable/12/sys/net/if_tun.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/geom/geom.h
  stable/11/sys/net/if_tap.c
  stable/11/sys/net/if_tun.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sys/geom/geom.h
==
--- stable/12/sys/geom/geom.h   Thu May  9 01:16:34 2019(r347377)
+++ stable/12/sys/geom/geom.h   Thu May  9 03:51:34 2019(r347378)
@@ -415,7 +415,7 @@ g_free(void *ptr)
static moduledata_t name##_mod = {  \
#name, g_modevent, &class   \
};  \
-   DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_FIRST);
+   DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND);
 
 int g_is_geom_thread(struct thread *td);
 

Modified: stable/12/sys/net/if_tap.c
==

svn commit: r347392 - head/sbin/ifconfig

2019-05-09 Thread Kyle Evans
Author: kevans
Date: Thu May  9 12:58:33 2019
New Revision: 347392
URL: https://svnweb.freebsd.org/changeset/base/347392

Log:
  ifconfig(8): Partial revert of r347241
  
  r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet
  can autoload the correct module on use. It also inadvertently made bogus
  some previously valid uses of sizeof().
  
  Revert back to ifkind on the stack for simplicity sake. This reduces the
  diff from the previous version of ifmaybeload for easiser auditing.

Modified:
  head/sbin/ifconfig/ifconfig.c

Modified: head/sbin/ifconfig/ifconfig.c
==
--- head/sbin/ifconfig/ifconfig.c   Thu May  9 12:14:52 2019
(r347391)
+++ head/sbin/ifconfig/ifconfig.c   Thu May  9 12:58:33 2019
(r347392)
@@ -1433,7 +1433,7 @@ ifmaybeload(const char *name)
 #define MOD_PREFIX_LEN 3   /* "if_" */
struct module_stat mstat;
int i, fileid, modid;
-   char ifname[IFNAMSIZ], *ifkind, *dp;
+   char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp;
const char *cp;
struct module_map_entry *mme;
 
@@ -1450,21 +1450,17 @@ ifmaybeload(const char *name)
}
 
/* Either derive it from the map or guess otherwise */
-   ifkind = NULL;
+   *ifkind = '\0';
for (i = 0; i < nitems(module_map); ++i) {
mme = &module_map[i];
if (strcmp(mme->ifname, ifname) == 0) {
-   ifkind = strdup(mme->kldname);
-   if (ifkind == NULL)
-   err(EXIT_FAILURE, "ifmaybeload");
+   strlcpy(ifkind, mme->kldname, sizeof(ifkind));
break;
}
}
 
/* We didn't have an alias for it... we'll guess. */
-   if (ifkind == NULL) {
-   ifkind = malloc(IFNAMSIZ + MOD_PREFIX_LEN);
-
+   if (*ifkind == '\0') {
/* turn interface and unit into module name */
strlcpy(ifkind, "if_", sizeof(ifkind));
strlcat(ifkind, ifname, sizeof(ifkind));
@@ -1487,7 +1483,7 @@ ifmaybeload(const char *name)
/* already loaded? */
if (strcmp(ifname, cp) == 0 ||
strcmp(ifkind, cp) == 0)
-   goto out;
+   return;
}
}
 
@@ -1496,8 +1492,6 @@ ifmaybeload(const char *name)
 * infer the names of all drivers (eg mlx4en(4)).
 */
(void) kldload(ifkind);
-out:
-   free(ifkind);
 }
 
 static struct cmd basic_cmds[] = {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r347394 - head/sys/net

2019-05-09 Thread Kyle Evans
Author: kevans
Date: Thu May  9 14:06:24 2019
New Revision: 347394
URL: https://svnweb.freebsd.org/changeset/base/347394

Log:
  tuntap: Properly detach tap ifp

Modified:
  head/sys/net/if_tuntap.c

Modified: head/sys/net/if_tuntap.c
==
--- head/sys/net/if_tuntap.cThu May  9 13:12:43 2019(r347393)
+++ head/sys/net/if_tuntap.cThu May  9 14:06:24 2019(r347394)
@@ -529,7 +529,6 @@ out:
 static void
 tun_destroy(struct tuntap_softc *tp)
 {
-   struct cdev *dev;
 
TUN_LOCK(tp);
tp->tun_flags |= TUN_DYING;
@@ -543,15 +542,18 @@ tun_destroy(struct tuntap_softc *tp)
TUN2IFP(tp)->if_softc = NULL;
sx_xunlock(&tun_ioctl_sx);
 
-   dev = tp->tun_dev;
-   bpfdetach(TUN2IFP(tp));
-   if_detach(TUN2IFP(tp));
-   free_unr(tp->tun_drv->unrhdr, TUN2IFP(tp)->if_dunit);
-   if_free(TUN2IFP(tp));
-   destroy_dev(dev);
+   destroy_dev(tp->tun_dev);
seldrain(&tp->tun_rsel);
knlist_clear(&tp->tun_rsel.si_note, 0);
knlist_destroy(&tp->tun_rsel.si_note);
+   if ((tp->tun_flags & TUN_L2) != 0) {
+   ether_ifdetach(TUN2IFP(tp));
+   } else {
+   bpfdetach(TUN2IFP(tp));
+   if_detach(TUN2IFP(tp));
+   }
+   free_unr(tp->tun_drv->unrhdr, TUN2IFP(tp)->if_dunit);
+   if_free(TUN2IFP(tp));
mtx_destroy(&tp->tun_mtx);
cv_destroy(&tp->tun_cv);
free(tp, M_TUN);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r347392 - head/sbin/ifconfig

2019-05-09 Thread Kyle Evans
On Thu, May 9, 2019 at 12:27 PM Enji Cooper (yaneurabeya)
 wrote:
>
>
> > On May 9, 2019, at 05:58, Kyle Evans  wrote:
> >
> > Author: kevans
> > Date: Thu May  9 12:58:33 2019
> > New Revision: 347392
> > URL: https://svnweb.freebsd.org/changeset/base/347392
> >
> > Log:
> >  ifconfig(8): Partial revert of r347241
> >
> >  r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet
> >  can autoload the correct module on use. It also inadvertently made bogus
> >  some previously valid uses of sizeof().
> >
> >  Revert back to ifkind on the stack for simplicity sake. This reduces the
> >  diff from the previous version of ifmaybeload for easiser auditing.
>
> Hi Kyle,
> Thank you for this revert. This change fixed the FreeBSD test suite 
> runs, which are once again green after this change. A number of tests which 
> use ifconfig were failing because they couldn’t configure interfaces: 
> https://ci.freebsd.org/job/FreeBSD-head-amd64-test/11134/testReport/ .
> Cheers!
> -Enji

Hi,

Sorry- I failed in the commit message. =(

Reported by: ci (via lwhsu)

lwhsu clued me in this morning. =)

Thanks!

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


Re: svn commit: r347402 - head/sys/modules/ipsec

2019-05-09 Thread Kyle Evans
On Thu, May 9, 2019 at 1:06 PM Andrey V. Elsukov  wrote:
>
> Author: ae
> Date: Thu May  9 18:06:11 2019
> New Revision: 347402
> URL: https://svnweb.freebsd.org/changeset/base/347402
>
> Log:
>   Add if_ipsec.ko symlink to ipsec.ko kernel module.
>
>   This add ability to automatically load ipsec kernel module, when
>   if_ipsec(4) virtual interface is created using ifconfig(8).
>
>   Reviewed by:  gallatin
>   MFC after:1 week
>   Differential Revision:https://reviews.freebsd.org/D20169
>

Hi,

Any chance the mechanism I introduced for ifconfig mapping ifname <->
kld in r347241 would solve the same set of problems this would?
(unsure if there are any non-ifconfig(8) problems in consideration) If
we have more consumers of it than just vmnet (from a stable/ point of
view) then I'd be more than happy to MFC that separately from the rest
of the commit.

Thanks,

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


svn commit: r347404 - head/sys/net

2019-05-09 Thread Kyle Evans
Author: kevans
Date: Thu May  9 18:54:29 2019
New Revision: 347404
URL: https://svnweb.freebsd.org/changeset/base/347404

Log:
  tuntap: Don't down tap interfaces if LINK0 is set

Modified:
  head/sys/net/if_tuntap.c

Modified: head/sys/net/if_tuntap.c
==
--- head/sys/net/if_tuntap.cThu May  9 18:23:09 2019(r347403)
+++ head/sys/net/if_tuntap.cThu May  9 18:54:29 2019(r347404)
@@ -947,7 +947,8 @@ tunclose(struct cdev *dev, int foo, int bar, struct th
}
 
/* For vmnet, we won't do most of the address/route bits */
-   if ((tp->tun_flags & TUN_VMNET) != 0)
+   if ((tp->tun_flags & TUN_VMNET) != 0 ||
+   (l2tun && (ifp->if_flags & IFF_LINK0) != 0))
goto out;
 
if (ifp->if_flags & IFF_UP) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r347402 - head/sys/modules/ipsec

2019-05-09 Thread Kyle Evans
On Thu, May 9, 2019 at 1:43 PM Andrey V. Elsukov  wrote:
>
> On 09.05.2019 21:36, Kyle Evans wrote:
> > Any chance the mechanism I introduced for ifconfig mapping ifname <->
> > kld in r347241 would solve the same set of problems this would?
> > (unsure if there are any non-ifconfig(8) problems in consideration) If
> > we have more consumers of it than just vmnet (from a stable/ point of
> > view) then I'd be more than happy to MFC that separately from the rest
> > of the commit.
> >
>
> Hi,
>
> there is two IPsec related interfaces that have problem with automatic
> loading - if_enc and if_ipsec. So, if you add both to the mapping list,
> this will be useful. CAM enc driver has conflicting name and prevents to
> automatic loading of if_enc(4). It is probably always build in the
> kernel, but renaming it into "ses" may break some third-party device
> drivers.
>

I think you want something like [0] to add both of these to the map
and stop ifconfig(8) from bailing on loading if_enc because 'enc' is
loaded. This is safe at least for the set of modules currently mapped.

Thanks,

Kyle Evans

[0] https://people.freebsd.org/~kevans/ipsec.diff
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r347429 - head/sbin/ifconfig

2019-05-10 Thread Kyle Evans
Author: kevans
Date: Fri May 10 13:18:22 2019
New Revision: 347429
URL: https://svnweb.freebsd.org/changeset/base/347429

Log:
  ifconfig(8): Add kld mappings for ipsec/enc
  
  Additionally, providing mappings makes the comparison for already loaded
  modules a little more strict. This should have been done at initial
  introduction, but there was no real reason- however, it proves necessary for
  enc which has a standard enc -> if_enc mapping but there also exists an
  'enc' module that's actually CAM. The mapping lets us unambiguously
  determine the correct module.
  
  Discussed with:   ae
  MFC after:4 days

Modified:
  head/sbin/ifconfig/ifconfig.c

Modified: head/sbin/ifconfig/ifconfig.c
==
--- head/sbin/ifconfig/ifconfig.c   Fri May 10 12:33:42 2019
(r347428)
+++ head/sbin/ifconfig/ifconfig.c   Fri May 10 13:18:22 2019
(r347429)
@@ -71,6 +71,7 @@ static const char rcsid[] =
 #ifdef JAIL
 #include 
 #endif
+#include 
 #include 
 #include 
 #include 
@@ -146,6 +147,20 @@ static struct module_map_entry {
.ifname = "vmnet",
.kldname = "if_tuntap",
},
+   {
+   .ifname = "ipsec",
+   .kldname = "ipsec",
+   },
+   {
+   /*
+* This mapping exists because there is a conflicting enc module
+* in CAM.  ifconfig's guessing behavior will attempt to match
+* the ifname to a module as well as if_${ifname} and clash with
+* CAM enc.  This is an assertion of the correct module to load.
+*/
+   .ifname = "enc",
+   .kldname = "if_enc",
+   },
 };
 
 
@@ -1436,6 +1451,7 @@ ifmaybeload(const char *name)
char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp;
const char *cp;
struct module_map_entry *mme;
+   bool found;
 
/* loading suppressed by the user */
if (noload)
@@ -1451,16 +1467,18 @@ ifmaybeload(const char *name)
 
/* Either derive it from the map or guess otherwise */
*ifkind = '\0';
+   found = false;
for (i = 0; i < nitems(module_map); ++i) {
mme = &module_map[i];
if (strcmp(mme->ifname, ifname) == 0) {
strlcpy(ifkind, mme->kldname, sizeof(ifkind));
+   found = true;
break;
}
}
 
/* We didn't have an alias for it... we'll guess. */
-   if (*ifkind == '\0') {
+   if (!found) {
/* turn interface and unit into module name */
strlcpy(ifkind, "if_", sizeof(ifkind));
strlcat(ifkind, ifname, sizeof(ifkind));
@@ -1480,8 +1498,12 @@ ifmaybeload(const char *name)
} else {
cp = mstat.name;
}
-   /* already loaded? */
-   if (strcmp(ifname, cp) == 0 ||
+   /*
+* Is it already loaded?  Don't compare with ifname if
+* we were specifically told which kld to use.  Doing
+* so could lead to conflicts not trivially solved.
+*/
+   if ((!found && strcmp(ifname, cp) == 0) ||
strcmp(ifkind, cp) == 0)
return;
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r347402 - head/sys/modules/ipsec

2019-05-10 Thread Kyle Evans
On Fri, May 10, 2019 at 2:46 AM Andrey V. Elsukov  wrote:
>
> On 09.05.2019 22:13, Kyle Evans wrote:
> >> there is two IPsec related interfaces that have problem with automatic
> >> loading - if_enc and if_ipsec. So, if you add both to the mapping list,
> >> this will be useful. CAM enc driver has conflicting name and prevents to
> >> automatic loading of if_enc(4). It is probably always build in the
> >> kernel, but renaming it into "ses" may break some third-party device
> >> drivers.
> >>
> >
> > I think you want something like [0] to add both of these to the map
> > and stop ifconfig(8) from bailing on loading if_enc because 'enc' is
> > loaded. This is safe at least for the set of modules currently mapped.
> >
> > Thanks,
> >
> > Kyle Evans
> >
> > [0] https://people.freebsd.org/~kevans/ipsec.diff
>
> It looks good to me.
>
> --
> WBR, Andrey V. Elsukov
>

Committed as r347429 -- any objection to reverting this link created
in r347402 now?

Thanks!

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


svn commit: r347483 - head/sys/net

2019-05-10 Thread Kyle Evans
Author: kevans
Date: Sat May 11 04:18:06 2019
New Revision: 347483
URL: https://svnweb.freebsd.org/changeset/base/347483

Log:
  tuntap: Improve style
  
  No functional change.
  
  tun_flags of the tuntap_driver was renamed to ident_flags to reflect the
  fact that it's a subset of the tun_flags that identifies a tuntap device.
  This maps more easily (visually) to the TUN_DRIVER_IDENT_MASK that masks off
  the bits of tun_flags that are applicable to tuntap driver ident. This is a
  purely cosmetic change.

Modified:
  head/sys/net/if_tuntap.c

Modified: head/sys/net/if_tuntap.c
==
--- head/sys/net/if_tuntap.cSat May 11 03:41:58 2019(r347482)
+++ head/sys/net/if_tuntap.cSat May 11 04:18:06 2019(r347483)
@@ -104,9 +104,9 @@ struct tuntap_driver;
  * static for the duration of a tunnel interface.
  */
 struct tuntap_softc {
-   TAILQ_ENTRY(tuntap_softc)   tun_list;
-   struct cdev *tun_dev;
-   u_short tun_flags;  /* misc flags */
+   TAILQ_ENTRY(tuntap_softc)tun_list;
+   struct cdev *tun_dev;
+   u_short  tun_flags; /* misc flags */
 #defineTUN_OPEN0x0001
 #defineTUN_INITED  0x0002
 #defineTUN_RCOLL   0x0004
@@ -120,20 +120,21 @@ struct tuntap_softc {
 #defineTUN_L2  0x0400
 #defineTUN_VMNET   0x0800
 
-#define TUN_READY   (TUN_OPEN | TUN_INITED)
+#defineTUN_DRIVER_IDENT_MASK   (TUN_L2 | TUN_VMNET)
+#defineTUN_READY   (TUN_OPEN | TUN_INITED)
 
-   pid_t   tun_pid;/* owning pid */
-   struct  ifnet *tun_ifp; /* the interface */
-   struct  sigio *tun_sigio;   /* information for async I/O */
-   struct  tuntap_driver *tun_drv; /* appropriate driver */
-   struct  selinfo tun_rsel;   /* read select */
-   struct mtx  tun_mtx;/* protect mutable softc fields */
-   struct cv   tun_cv; /* protect against ref'd dev destroy */
-   struct ether_addr   tun_ether;  /* remote address */
+   pid_ttun_pid;   /* owning pid */
+   struct ifnet*tun_ifp;   /* the interface */
+   struct sigio*tun_sigio; /* async I/O info */
+   struct tuntap_driver*tun_drv;   /* appropriate driver */
+   struct selinfo   tun_rsel;  /* read select */
+   struct mtx   tun_mtx;   /* softc field mutex */
+   struct cvtun_cv;/* for ref'd dev destroy */
+   struct ether_addrtun_ether; /* remote address */
 };
-#define TUN2IFP(sc)((sc)->tun_ifp)
+#defineTUN2IFP(sc) ((sc)->tun_ifp)
 
-#define TUNDEBUG   if (tundebug) if_printf
+#defineTUNDEBUGif (tundebug) if_printf
 
 #defineTUN_LOCK(tp)mtx_lock(&(tp)->tun_mtx)
 #defineTUN_UNLOCK(tp)  mtx_unlock(&(tp)->tun_mtx)
@@ -153,8 +154,8 @@ static const char vmnetname[] = "vmnet";
 static MALLOC_DEFINE(M_TUN, tunname, "Tunnel Interface");
 static int tundebug = 0;
 static int tundclone = 1;
-static int tap_allow_uopen = 0;/* allow user open() */
-static int tapuponopen = 0;/* IFF_UP on open() */
+static int tap_allow_uopen = 0;/* allow user open() */
+static int tapuponopen = 0;/* IFF_UP on open() */
 static int tapdclone = 1;  /* enable devfs cloning */
 
 static TAILQ_HEAD(,tuntap_softc)   tunhead = 
TAILQ_HEAD_INITIALIZER(tunhead);
@@ -174,11 +175,11 @@ SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTL
 static SYSCTL_NODE(_net_link, OID_AUTO, tap, CTLFLAG_RW, 0,
 "Ethernet tunnel software network interface");
 SYSCTL_INT(_net_link_tap, OID_AUTO, user_open, CTLFLAG_RW, &tap_allow_uopen, 0,
-   "Allow user to open /dev/tap (based on node permissions)");
+"Allow user to open /dev/tap (based on node permissions)");
 SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0,
-   "Bring interface up when /dev/tap is opened");
+"Bring interface up when /dev/tap is opened");
 SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tapdclone, 
0,
-   "Enable legacy devfs interface creation");
+"Enable legacy devfs interface creation");
 SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tundebug, 0, "");
 
 static int tuntap_name2info(const char *name, int *unit, int *flags);
@@ -226,19 +227,17 @@ static struct filterops tun_write_filterops = {
.f_event =  tunkqwrite,
 };
 
-#defineTUN_DRIVER_IDENT_MASK   (TUN_L2 | TUN_VMNET)
-
 static struct tuntap_driver {
-   int  tun_flags;
-   struct unrhdr   *unrhdr;
struct cdevswcdevsw;
+   int  ident_flags;
+   struct unrhdr   *unrhdr;
struct clonedevs  

svn commit: r347557 - in stable: 11/sbin/ifconfig 12/sbin/ifconfig

2019-05-13 Thread Kyle Evans
Author: kevans
Date: Tue May 14 02:00:12 2019
New Revision: 347557
URL: https://svnweb.freebsd.org/changeset/base/347557

Log:
  MFC r347241 (partial), r347392, r347429: ifconfig(8) ifname <-> kld mapping
  
  MFC r347241 (partial): Initial mechanism for mapping ifname <-> kld
  
  if_tun/if_tap mappings have been removed and the vmnet mapping has been
  updated to the if_tap module.
  
  MFC r347392: ifconfig(8): Partial revert of r347241
  
  r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet
  can autoload the correct module on use. It also inadvertently made bogus
  some previously valid uses of sizeof().
  
  Revert back to ifkind on the stack for simplicity sake. This reduces the
  diff from the previous version of ifmaybeload for easiser auditing.
  
  MFC r347429: ifconfig(8): Add kld mappings for ipsec/enc
  
  Additionally, providing mappings makes the comparison for already loaded
  modules a little more strict. This should have been done at initial
  introduction, but there was no real reason- however, it proves necessary for
  enc which has a standard enc -> if_enc mapping but there also exists an
  'enc' module that's actually CAM. The mapping lets us unambiguously
  determine the correct module.

Modified:
  stable/11/sbin/ifconfig/ifconfig.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sbin/ifconfig/ifconfig.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sbin/ifconfig/ifconfig.c
==
--- stable/11/sbin/ifconfig/ifconfig.c  Tue May 14 00:34:08 2019
(r347556)
+++ stable/11/sbin/ifconfig/ifconfig.c  Tue May 14 02:00:12 2019
(r347557)
@@ -69,6 +69,7 @@ static const char rcsid[] =
 #ifdef JAIL
 #include 
 #endif
+#include 
 #include 
 #include 
 #include 
@@ -125,6 +126,31 @@ struct ifa_order_elt {
 
 TAILQ_HEAD(ifa_queue, ifa_order_elt);
 
+static struct module_map_entry {
+   const char *ifname;
+   const char *kldname;
+} module_map[] = {
+   {
+   .ifname = "vmnet",
+   .kldname = "if_tap",
+   },
+   {
+   .ifname = "ipsec",
+   .kldname = "ipsec",
+   },
+   {
+   /*
+* This mapping exists because there is a conflicting enc module
+* in CAM.  ifconfig's guessing behavior will attempt to match
+* the ifname to a module as well as if_${ifname} and clash with
+* CAM enc.  This is an assertion of the correct module to load.
+*/
+   .ifname = "enc",
+   .kldname = "if_enc",
+   },
+};
+
+
 void
 opt_register(struct option *p)
 {
@@ -1371,9 +1397,11 @@ ifmaybeload(const char *name)
 {
 #define MOD_PREFIX_LEN 3   /* "if_" */
struct module_stat mstat;
-   int fileid, modid;
+   int i, fileid, modid;
char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp;
const char *cp;
+   struct module_map_entry *mme;
+   bool found;
 
/* loading suppressed by the user */
if (noload)
@@ -1387,10 +1415,25 @@ ifmaybeload(const char *name)
break;
}
 
-   /* turn interface and unit into module name */
-   strlcpy(ifkind, "if_", sizeof(ifkind));
-   strlcat(ifkind, ifname, sizeof(ifkind));
+   /* Either derive it from the map or guess otherwise */
+   *ifkind = '\0';
+   found = false;
+   for (i = 0; i < nitems(module_map); ++i) {
+   mme = &module_map[i];
+   if (strcmp(mme->ifname, ifname) == 0) {
+   strlcpy(ifkind, mme->kldname, sizeof(ifkind));
+   found = true;
+   break;
+   }
+   }
 
+   /* We didn't have an alias for it... we'll guess. */
+   if (!found) {
+   /* turn interface and unit into module name */
+   strlcpy(ifkind, "if_", sizeof(ifkind));
+   strlcat(ifkind, ifname, sizeof(ifkind));
+   }
+
/* scan files in kernel */
mstat.version = sizeof(struct module_stat);
for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) {
@@ -1405,8 +1448,12 @@ ifmaybeload(const char *name)
} else {
cp = mstat.name;
}
-   /* already loaded? */
-   if (strcmp(ifname, cp) == 0 ||
+   /*
+* Is it already loaded?  Don't compare with ifname if
+* we were specifically told which kld to use.  Doing
+* so could lead to conflicts not trivially solved.
+*/
+   if ((!found && strcmp(ifname, cp) == 0) ||
strcmp(ifkind, cp) == 0)

svn commit: r347557 - in stable: 11/sbin/ifconfig 12/sbin/ifconfig

2019-05-13 Thread Kyle Evans
Author: kevans
Date: Tue May 14 02:00:12 2019
New Revision: 347557
URL: https://svnweb.freebsd.org/changeset/base/347557

Log:
  MFC r347241 (partial), r347392, r347429: ifconfig(8) ifname <-> kld mapping
  
  MFC r347241 (partial): Initial mechanism for mapping ifname <-> kld
  
  if_tun/if_tap mappings have been removed and the vmnet mapping has been
  updated to the if_tap module.
  
  MFC r347392: ifconfig(8): Partial revert of r347241
  
  r347241 introduced an ifname <-> kld mapping table, mostly so tun/tap/vmnet
  can autoload the correct module on use. It also inadvertently made bogus
  some previously valid uses of sizeof().
  
  Revert back to ifkind on the stack for simplicity sake. This reduces the
  diff from the previous version of ifmaybeload for easiser auditing.
  
  MFC r347429: ifconfig(8): Add kld mappings for ipsec/enc
  
  Additionally, providing mappings makes the comparison for already loaded
  modules a little more strict. This should have been done at initial
  introduction, but there was no real reason- however, it proves necessary for
  enc which has a standard enc -> if_enc mapping but there also exists an
  'enc' module that's actually CAM. The mapping lets us unambiguously
  determine the correct module.

Modified:
  stable/12/sbin/ifconfig/ifconfig.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sbin/ifconfig/ifconfig.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sbin/ifconfig/ifconfig.c
==
--- stable/12/sbin/ifconfig/ifconfig.c  Tue May 14 00:34:08 2019
(r347556)
+++ stable/12/sbin/ifconfig/ifconfig.c  Tue May 14 02:00:12 2019
(r347557)
@@ -71,6 +71,7 @@ static const char rcsid[] =
 #ifdef JAIL
 #include 
 #endif
+#include 
 #include 
 #include 
 #include 
@@ -130,6 +131,31 @@ struct ifa_order_elt {
 
 TAILQ_HEAD(ifa_queue, ifa_order_elt);
 
+static struct module_map_entry {
+   const char *ifname;
+   const char *kldname;
+} module_map[] = {
+   {
+   .ifname = "vmnet",
+   .kldname = "if_tap",
+   },
+   {
+   .ifname = "ipsec",
+   .kldname = "ipsec",
+   },
+   {
+   /*
+* This mapping exists because there is a conflicting enc module
+* in CAM.  ifconfig's guessing behavior will attempt to match
+* the ifname to a module as well as if_${ifname} and clash with
+* CAM enc.  This is an assertion of the correct module to load.
+*/
+   .ifname = "enc",
+   .kldname = "if_enc",
+   },
+};
+
+
 void
 opt_register(struct option *p)
 {
@@ -1413,9 +1439,11 @@ ifmaybeload(const char *name)
 {
 #define MOD_PREFIX_LEN 3   /* "if_" */
struct module_stat mstat;
-   int fileid, modid;
+   int i, fileid, modid;
char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp;
const char *cp;
+   struct module_map_entry *mme;
+   bool found;
 
/* loading suppressed by the user */
if (noload)
@@ -1429,10 +1457,25 @@ ifmaybeload(const char *name)
break;
}
 
-   /* turn interface and unit into module name */
-   strlcpy(ifkind, "if_", sizeof(ifkind));
-   strlcat(ifkind, ifname, sizeof(ifkind));
+   /* Either derive it from the map or guess otherwise */
+   *ifkind = '\0';
+   found = false;
+   for (i = 0; i < nitems(module_map); ++i) {
+   mme = &module_map[i];
+   if (strcmp(mme->ifname, ifname) == 0) {
+   strlcpy(ifkind, mme->kldname, sizeof(ifkind));
+   found = true;
+   break;
+   }
+   }
 
+   /* We didn't have an alias for it... we'll guess. */
+   if (!found) {
+   /* turn interface and unit into module name */
+   strlcpy(ifkind, "if_", sizeof(ifkind));
+   strlcat(ifkind, ifname, sizeof(ifkind));
+   }
+
/* scan files in kernel */
mstat.version = sizeof(struct module_stat);
for (fileid = kldnext(0); fileid > 0; fileid = kldnext(fileid)) {
@@ -1447,8 +1490,12 @@ ifmaybeload(const char *name)
} else {
cp = mstat.name;
}
-   /* already loaded? */
-   if (strcmp(ifname, cp) == 0 ||
+   /*
+* Is it already loaded?  Don't compare with ifname if
+* we were specifically told which kld to use.  Doing
+* so could lead to conflicts not trivially solved.
+*/
+   if ((!found && strcmp(ifname, cp) == 0) ||
strcmp(ifkind, cp) == 0)

svn commit: r347578 - head/sys/net

2019-05-14 Thread Kyle Evans
Author: kevans
Date: Tue May 14 20:32:29 2019
New Revision: 347578
URL: https://svnweb.freebsd.org/changeset/base/347578

Log:
  tuntap: Defer clearing if_softc until after if_detach
  
  r346670 added an sx to close a race between the ifioctl handler and
  interface destruction. Unfortunately, it clears if_softc immediately after
  the interface is closed, but before if_detach has been invoked.
  
  Any time before detachment, an interface that's part of a bridge may still
  receive traffic that's pushed through tunstart/tunstart_l2 and promptly
  lead to a panic because if_softc is now NULL.
  
  Fix it by deferring the clearing of if_softc until after the interface has
  detached and thus been removed from the bridge. if_softc still gets cleared
  in case another thread has already entered the ioctl handler before it's
  replaced with ifdead_ioctl.
  
  Reported by:  markj
  MFC after:3 days

Modified:
  head/sys/net/if_tuntap.c

Modified: head/sys/net/if_tuntap.c
==
--- head/sys/net/if_tuntap.cTue May 14 20:31:06 2019(r347577)
+++ head/sys/net/if_tuntap.cTue May 14 20:32:29 2019(r347578)
@@ -537,9 +537,6 @@ tun_destroy(struct tuntap_softc *tp)
TUN_UNLOCK(tp);
 
CURVNET_SET(TUN2IFP(tp)->if_vnet);
-   sx_xlock(&tun_ioctl_sx);
-   TUN2IFP(tp)->if_softc = NULL;
-   sx_xunlock(&tun_ioctl_sx);
 
destroy_dev(tp->tun_dev);
seldrain(&tp->tun_rsel);
@@ -551,6 +548,9 @@ tun_destroy(struct tuntap_softc *tp)
bpfdetach(TUN2IFP(tp));
if_detach(TUN2IFP(tp));
}
+   sx_xlock(&tun_ioctl_sx);
+   TUN2IFP(tp)->if_softc = NULL;
+   sx_xunlock(&tun_ioctl_sx);
free_unr(tp->tun_drv->unrhdr, TUN2IFP(tp)->if_dunit);
if_free(TUN2IFP(tp));
mtx_destroy(&tp->tun_mtx);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r347640 - head/lib/libbe

2019-05-15 Thread Kyle Evans
Author: kevans
Date: Thu May 16 02:11:33 2019
New Revision: 347640
URL: https://svnweb.freebsd.org/changeset/base/347640

Log:
  libbe(3): Descend into children of datasets w/ mountpoint=none
  
  These datasets will generally be canmount=noauto,mountpoint=none (e.g.
  zroot/var) but have children that may need to be mounted. Instead of
  skipping that segment for no good reason, descend.
  
  Submitted by: Wes Maag
  Reported by:  Wes Maag
  MFC after:3 days

Modified:
  head/lib/libbe/be_access.c

Modified: head/lib/libbe/be_access.c
==
--- head/lib/libbe/be_access.c  Thu May 16 01:32:54 2019(r347639)
+++ head/lib/libbe/be_access.c  Thu May 16 02:11:33 2019(r347640)
@@ -99,13 +99,12 @@ be_mount_iter(zfs_handle_t *zfs_hdl, void *data)
if (strcmp("none", zfs_mnt) == 0) {
/*
 * mountpoint=none; we'll mount it at info->mountpoint assuming
-* we're at the root.  If we're not at the root... that's less
-* than stellar and not entirely sure what to do with that.
-* For now, we won't treat it as an error condition -- we just
-* won't mount it, and we'll continue on.
+* we're at the root.  If we're not at the root, we're likely
+* at some intermediate dataset (e.g. zroot/var) that will have
+* children that may need to be mounted.
 */
if (info->depth > 0)
-   return (0);
+   goto skipmount;
 
snprintf(tmp, BE_MAXPATHLEN, "%s", info->mountpoint);
} else {
@@ -136,6 +135,7 @@ be_mount_iter(zfs_handle_t *zfs_hdl, void *data)
if (!info->deepmount)
return (0);
 
+skipmount:
++info->depth;
err = zfs_iter_filesystems(zfs_hdl, be_mount_iter, info);
--info->depth;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348124 - stable/12/sys/net

2019-05-22 Thread Kyle Evans
Author: kevans
Date: Wed May 22 22:34:35 2019
New Revision: 348124
URL: https://svnweb.freebsd.org/changeset/base/348124

Log:
  MFC r347578: tun/tap: Defer clearing if_softc until after if_detach
  
  (Commit massaged to match stable structure; tun and tap have been merged in
  head)
  
  r346670 added an sx to close a race between the ifioctl handler and
  interface destruction. Unfortunately, it clears if_softc immediately after
  the interface is closed, but before if_detach has been invoked.
  
  Any time before detachment, an interface that's part of a bridge may still
  receive traffic that's pushed through tunstart/tunstart_l2 and promptly
  lead to a panic because if_softc is now NULL.
  
  Fix it by deferring the clearing of if_softc until after the interface has
  detached and thus been removed from the bridge. if_softc still gets cleared
  in case another thread has already entered the ioctl handler before it's
  replaced with ifdead_ioctl.

Modified:
  stable/12/sys/net/if_tap.c
  stable/12/sys/net/if_tun.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/net/if_tap.c
==
--- stable/12/sys/net/if_tap.c  Wed May 22 21:47:26 2019(r348123)
+++ stable/12/sys/net/if_tap.c  Wed May 22 22:34:35 2019(r348124)
@@ -223,15 +223,17 @@ tap_destroy(struct tap_softc *tp)
struct ifnet *ifp = tp->tap_ifp;
 
CURVNET_SET(ifp->if_vnet);
-   sx_xlock(&tap_ioctl_sx);
-   ifp->if_softc = NULL;
-   sx_xunlock(&tap_ioctl_sx);
 
destroy_dev(tp->tap_dev);
seldrain(&tp->tap_rsel);
knlist_clear(&tp->tap_rsel.si_note, 0);
knlist_destroy(&tp->tap_rsel.si_note);
ether_ifdetach(ifp);
+
+   sx_xlock(&tap_ioctl_sx);
+   ifp->if_softc = NULL;
+   sx_xunlock(&tap_ioctl_sx);
+
if_free(ifp);
 
mtx_destroy(&tp->tap_mtx);

Modified: stable/12/sys/net/if_tun.c
==
--- stable/12/sys/net/if_tun.c  Wed May 22 21:47:26 2019(r348123)
+++ stable/12/sys/net/if_tun.c  Wed May 22 22:34:35 2019(r348124)
@@ -278,13 +278,15 @@ tun_destroy(struct tun_softc *tp)
mtx_unlock(&tp->tun_mtx);
 
CURVNET_SET(TUN2IFP(tp)->if_vnet);
-   sx_xlock(&tun_ioctl_sx);
-   TUN2IFP(tp)->if_softc = NULL;
-   sx_xunlock(&tun_ioctl_sx);
 
dev = tp->tun_dev;
bpfdetach(TUN2IFP(tp));
if_detach(TUN2IFP(tp));
+
+   sx_xlock(&tun_ioctl_sx);
+   TUN2IFP(tp)->if_softc = NULL;
+   sx_xunlock(&tun_ioctl_sx);
+
free_unr(tun_unrhdr, TUN2IFP(tp)->if_dunit);
if_free(TUN2IFP(tp));
destroy_dev(dev);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348125 - stable/12/lib/libbe

2019-05-22 Thread Kyle Evans
Author: kevans
Date: Wed May 22 22:55:27 2019
New Revision: 348125
URL: https://svnweb.freebsd.org/changeset/base/348125

Log:
  MFC r347640: libbe(3): Descend into children of datasets w/ mountpoint=none
  
  These datasets will generally be canmount=noauto,mountpoint=none (e.g.
  zroot/var) but have children that may need to be mounted. Instead of
  skipping that segment for no good reason, descend.

Modified:
  stable/12/lib/libbe/be_access.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libbe/be_access.c
==
--- stable/12/lib/libbe/be_access.c Wed May 22 22:34:35 2019
(r348124)
+++ stable/12/lib/libbe/be_access.c Wed May 22 22:55:27 2019
(r348125)
@@ -99,13 +99,12 @@ be_mount_iter(zfs_handle_t *zfs_hdl, void *data)
if (strcmp("none", zfs_mnt) == 0) {
/*
 * mountpoint=none; we'll mount it at info->mountpoint assuming
-* we're at the root.  If we're not at the root... that's less
-* than stellar and not entirely sure what to do with that.
-* For now, we won't treat it as an error condition -- we just
-* won't mount it, and we'll continue on.
+* we're at the root.  If we're not at the root, we're likely
+* at some intermediate dataset (e.g. zroot/var) that will have
+* children that may need to be mounted.
 */
if (info->depth > 0)
-   return (0);
+   goto skipmount;
 
snprintf(tmp, BE_MAXPATHLEN, "%s", info->mountpoint);
} else {
@@ -136,6 +135,7 @@ be_mount_iter(zfs_handle_t *zfs_hdl, void *data)
if (!info->deepmount)
return (0);
 
+skipmount:
++info->depth;
err = zfs_iter_filesystems(zfs_hdl, be_mount_iter, info);
--info->depth;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348126 - stable/11/sys/net

2019-05-22 Thread Kyle Evans
Author: kevans
Date: Wed May 22 22:56:05 2019
New Revision: 348126
URL: https://svnweb.freebsd.org/changeset/base/348126

Log:
  MFC r347578: tun/tap: Defer clearing if_softc until after if_detach
  
  (Commit massaged to match stable structure; tun and tap have been merged in
  head)
  
  r346670 added an sx to close a race between the ifioctl handler and
  interface destruction. Unfortunately, it clears if_softc immediately after
  the interface is closed, but before if_detach has been invoked.
  
  Any time before detachment, an interface that's part of a bridge may still
  receive traffic that's pushed through tunstart/tunstart_l2 and promptly
  lead to a panic because if_softc is now NULL.
  
  Fix it by deferring the clearing of if_softc until after the interface has
  detached and thus been removed from the bridge. if_softc still gets cleared
  in case another thread has already entered the ioctl handler before it's
  replaced with ifdead_ioctl.
  
  Approved by:  re (kib)

Modified:
  stable/11/sys/net/if_tap.c
  stable/11/sys/net/if_tun.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/net/if_tap.c
==
--- stable/11/sys/net/if_tap.c  Wed May 22 22:55:27 2019(r348125)
+++ stable/11/sys/net/if_tap.c  Wed May 22 22:56:05 2019(r348126)
@@ -223,15 +223,17 @@ tap_destroy(struct tap_softc *tp)
struct ifnet *ifp = tp->tap_ifp;
 
CURVNET_SET(ifp->if_vnet);
-   sx_xlock(&tap_ioctl_sx);
-   ifp->if_softc = NULL;
-   sx_xunlock(&tap_ioctl_sx);
 
destroy_dev(tp->tap_dev);
seldrain(&tp->tap_rsel);
knlist_clear(&tp->tap_rsel.si_note, 0);
knlist_destroy(&tp->tap_rsel.si_note);
ether_ifdetach(ifp);
+
+   sx_xlock(&tap_ioctl_sx);
+   ifp->if_softc = NULL;
+   sx_xunlock(&tap_ioctl_sx);
+
if_free(ifp);
 
mtx_destroy(&tp->tap_mtx);

Modified: stable/11/sys/net/if_tun.c
==
--- stable/11/sys/net/if_tun.c  Wed May 22 22:55:27 2019(r348125)
+++ stable/11/sys/net/if_tun.c  Wed May 22 22:56:05 2019(r348126)
@@ -278,13 +278,15 @@ tun_destroy(struct tun_softc *tp)
mtx_unlock(&tp->tun_mtx);
 
CURVNET_SET(TUN2IFP(tp)->if_vnet);
-   sx_xlock(&tun_ioctl_sx);
-   TUN2IFP(tp)->if_softc = NULL;
-   sx_xunlock(&tun_ioctl_sx);
 
dev = tp->tun_dev;
bpfdetach(TUN2IFP(tp));
if_detach(TUN2IFP(tp));
+
+   sx_xlock(&tun_ioctl_sx);
+   TUN2IFP(tp)->if_softc = NULL;
+   sx_xunlock(&tun_ioctl_sx);
+
free_unr(tun_unrhdr, TUN2IFP(tp)->if_dunit);
if_free(TUN2IFP(tp));
destroy_dev(dev);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348127 - head/sbin/bectl

2019-05-22 Thread Kyle Evans
Author: kevans
Date: Wed May 22 23:07:40 2019
New Revision: 348127
URL: https://svnweb.freebsd.org/changeset/base/348127

Log:
  bectl(8): add description for create subcommand
  
  In commit r345845, a portion of documentation for the create subcommand was
  removed. Specifically, for creating a snapshot of an existing boot
  environment. bectl even has a test-case for this functionality.
  
  Removing the sub-command description was discussed in PR 235850.
  
  This patch brings back the second "create" description that was originally
  in place. Albeit, with a few wording/clarifying changes.
  
  Submitted by: Rob Fairbanks 
  Reviewed by:  kevans
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D20249

Modified:
  head/sbin/bectl/bectl.8

Modified: head/sbin/bectl/bectl.8
==
--- head/sbin/bectl/bectl.8 Wed May 22 22:56:05 2019(r348126)
+++ head/sbin/bectl/bectl.8 Wed May 22 23:07:40 2019(r348127)
@@ -18,7 +18,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 3, 2019
+.Dd May 12, 2019
 .Dt BECTL 8
 .Os
 .Sh NAME
@@ -35,6 +35,10 @@
 .Op Fl e Brq Ar nonActiveBe | Ar beName Ns Cm @ Ns Ar snapshot
 .Ar newBeName
 .Nm
+.Cm create
+.Op Fl r
+.Ar beName@snapshot
+.Nm
 .Cm destroy
 .Op Fl \&Fo
 .Ar beName Ns Op Cm @ Ns Ar snapshot
@@ -120,6 +124,20 @@ Otherwise, the new environment will be created from th
 If
 .Nm
 is creating from another boot environment, a snapshot of that boot environment 
will be created to clone from.
+.It Xo
+.Cm create
+.Op Fl r
+.Ar beName@snapshot
+.Xc
+Create a snapshot of the boot environment named
+.Ar beName .
+.Pp
+If the
+.Fl r
+flag is given, a recursive snapshot of the boot environment will be created.
+A snapshot is created for each descendant dataset of the boot environment.
+.Pp
+No new boot environment is created with this command.
 .It Xo
 .Cm destroy
 .Op Fl \&Fo
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348133 - stable/11/lib/libbe

2019-05-22 Thread Kyle Evans
Author: kevans
Date: Wed May 22 23:34:41 2019
New Revision: 348133
URL: https://svnweb.freebsd.org/changeset/base/348133

Log:
  MFC r347640: libbe(3): Descend into children of datasets w/ mountpoint=none
  
  These datasets will generally be canmount=noauto,mountpoint=none (e.g.
  zroot/var) but have children that may need to be mounted. Instead of
  skipping that segment for no good reason, descend.
  
  Approved by:  re (kib)

Modified:
  stable/11/lib/libbe/be_access.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libbe/be_access.c
==
--- stable/11/lib/libbe/be_access.c Wed May 22 23:30:51 2019
(r348132)
+++ stable/11/lib/libbe/be_access.c Wed May 22 23:34:41 2019
(r348133)
@@ -99,13 +99,12 @@ be_mount_iter(zfs_handle_t *zfs_hdl, void *data)
if (strcmp("none", zfs_mnt) == 0) {
/*
 * mountpoint=none; we'll mount it at info->mountpoint assuming
-* we're at the root.  If we're not at the root... that's less
-* than stellar and not entirely sure what to do with that.
-* For now, we won't treat it as an error condition -- we just
-* won't mount it, and we'll continue on.
+* we're at the root.  If we're not at the root, we're likely
+* at some intermediate dataset (e.g. zroot/var) that will have
+* children that may need to be mounted.
 */
if (info->depth > 0)
-   return (0);
+   goto skipmount;
 
snprintf(tmp, BE_MAXPATHLEN, "%s", info->mountpoint);
} else {
@@ -136,6 +135,7 @@ be_mount_iter(zfs_handle_t *zfs_hdl, void *data)
if (!info->deepmount)
return (0);
 
+skipmount:
++info->depth;
err = zfs_iter_filesystems(zfs_hdl, be_mount_iter, info);
--info->depth;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348215 - head/lib/libjail

2019-05-23 Thread Kyle Evans
Author: kevans
Date: Fri May 24 01:28:07 2019
New Revision: 348215
URL: https://svnweb.freebsd.org/changeset/base/348215

Log:
  jail_getid(3): validate jid string input
  
  Currently, if jail_getid(3) is passed in a numeric string, it assumes that
  this is a jid string and passes it back converted to an int without checking
  that it's a valid/existing jid. This breaks consumers that might use
  jail_getid(3) to see if it can trivially grab a jid from a name if that name
  happens to be numeric but not actually the name/jid of the jail. Instead of
  returning -1 for the jail not existing, it'll return the int version of the
  input and the consumer will not fallback to trying other methods.
  
  Pass the numeric input to jail_get(2) as the jid for validation, rather than
  the name. This works well- the kernel enforces that jid=name if name is
  numeric, so doing the safe thing and checking numeric input as a jid will
  still DTRT based on the description of jail_getid.
  
  Reported by:  Wes Maag
  Reviewed by:  jamie, Wes Maag
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D20388

Modified:
  head/lib/libjail/jail_getid.c

Modified: head/lib/libjail/jail_getid.c
==
--- head/lib/libjail/jail_getid.c   Fri May 24 00:56:50 2019
(r348214)
+++ head/lib/libjail/jail_getid.c   Fri May 24 01:28:07 2019
(r348215)
@@ -53,13 +53,18 @@ jail_getid(const char *name)
struct iovec jiov[4];
 
jid = strtoul(name, &ep, 10);
-   if (*name && !*ep)
-   return jid;
-   jiov[0].iov_base = __DECONST(char *, "name");
-   jiov[0].iov_len = sizeof("name");
-   jiov[1].iov_len = strlen(name) + 1;
-   jiov[1].iov_base = alloca(jiov[1].iov_len);
-   strcpy(jiov[1].iov_base, name);
+   if (*name && !*ep) {
+   jiov[0].iov_base = __DECONST(char *, "jid");
+   jiov[0].iov_len = sizeof("jid");
+   jiov[1].iov_base = &jid;
+   jiov[1].iov_len = sizeof(jid);
+   } else {
+   jiov[0].iov_base = __DECONST(char *, "name");
+   jiov[0].iov_len = sizeof("name");
+   jiov[1].iov_len = strlen(name) + 1;
+   jiov[1].iov_base = alloca(jiov[1].iov_len);
+   strcpy(jiov[1].iov_base, name);
+   }
jiov[2].iov_base = __DECONST(char *, "errmsg");
jiov[2].iov_len = sizeof("errmsg");
jiov[3].iov_base = jail_errmsg;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348219 - head/sbin/bectl/tests

2019-05-23 Thread Kyle Evans
Author: kevans
Date: Fri May 24 01:53:45 2019
New Revision: 348219
URL: https://svnweb.freebsd.org/changeset/base/348219

Log:
  bectl(8): Add a test for jail/unjail of numeric BE names
  
  Fixed by r348215, bectl ujail first attempts the trivial fetch of a jid by
  passing the first argument to 'ujail' to jail_getid(3) in case a jid/name
  have been passed in instead of a BE name. For numerically named BEs, this
  was doing the wrong thing: instead of failing to locate the jid specified
  and falling back to mountpath search, jail_getid(3) would return the input
  as-is.
  
  While here, I've fixed bectl_jail_cleanup which still used a hard-coded pool
  name that was overlooked w.r.t. other work that was in-flight around the
  same time.
  
  MFC after:3 days

Modified:
  head/sbin/bectl/tests/bectl_test.sh

Modified: head/sbin/bectl/tests/bectl_test.sh
==
--- head/sbin/bectl/tests/bectl_test.sh Fri May 24 01:51:58 2019
(r348218)
+++ head/sbin/bectl/tests/bectl_test.sh Fri May 24 01:53:45 2019
(r348219)
@@ -294,9 +294,16 @@ bectl_jail_body()
atf_check cp /rescue/rescue ${root}/rescue/rescue
atf_check bectl -r ${zpool}/ROOT umount default
 
-   # Prepare a second boot environment
+   # Prepare some more boot environments
atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT create -e default 
target
+   atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT create -e default 
1234
 
+   # Attempt to unjail a BE with numeric name; jail_getid at one point
+   # did not validate that the input was a valid jid before returning the
+   # jid.
+   atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT jail -b 1234
+   atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT unjail 1234
+
# When a jail name is not explicit, it should match the jail id.
atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT jail -b -o 
jid=233637 default
atf_check -o inline:"233637\n" -s exit:0 -x "jls -j 233637 name"
@@ -340,9 +347,10 @@ bectl_jail_body()
 # attempts to destroy the zpool.
 bectl_jail_cleanup()
 {
-   for bootenv in "default" "target"; do
+   zpool=$(get_zpool_name)
+   for bootenv in "default" "target" "1234"; do
# mountpoint of the boot environment
-   mountpoint="$(bectl -r bectl_test/ROOT list -H | grep 
${bootenv} | awk '{print $3}')"
+   mountpoint="$(bectl -r ${zpool}/ROOT list -H | grep ${bootenv} 
| awk '{print $3}')"
 
# see if any jail paths match the boot environment mountpoint
jailid="$(jls | grep ${mountpoint} | awk '{print $1}')"
@@ -353,7 +361,7 @@ bectl_jail_cleanup()
jail -r ${jailid}
done;
 
-   bectl_cleanup $(get_zpool_name)
+   bectl_cleanup ${zpool}
 }
 
 atf_init_test_cases()
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348220 - vendor-sys/libfdt/dist

2019-05-23 Thread Kyle Evans
Author: kevans
Date: Fri May 24 02:10:16 2019
New Revision: 348220
URL: https://svnweb.freebsd.org/changeset/base/348220

Log:
  Import libfdt from dtc 1.5.0

Modified:
  vendor-sys/libfdt/dist/Makefile.libfdt
  vendor-sys/libfdt/dist/fdt_addresses.c
  vendor-sys/libfdt/dist/libfdt.h

Modified: vendor-sys/libfdt/dist/Makefile.libfdt
==
--- vendor-sys/libfdt/dist/Makefile.libfdt  Fri May 24 01:53:45 2019
(r348219)
+++ vendor-sys/libfdt/dist/Makefile.libfdt  Fri May 24 02:10:16 2019
(r348220)
@@ -9,3 +9,7 @@ LIBFDT_VERSION = version.lds
 LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c 
fdt_empty_tree.c \
fdt_addresses.c fdt_overlay.c
 LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
+
+libfdt_clean:
+   @$(VECHO) CLEAN "(libfdt)"
+   rm -f $(STD_CLEANFILES:%=$(LIBFDT_dir)/%)

Modified: vendor-sys/libfdt/dist/fdt_addresses.c
==
--- vendor-sys/libfdt/dist/fdt_addresses.c  Fri May 24 01:53:45 2019
(r348219)
+++ vendor-sys/libfdt/dist/fdt_addresses.c  Fri May 24 02:10:16 2019
(r348220)
@@ -64,7 +64,7 @@ static int fdt_cells(const void *fdt, int nodeoffset, 
 
c = fdt_getprop(fdt, nodeoffset, name, &len);
if (!c)
-   return 2;
+   return len;
 
if (len != sizeof(*c))
return -FDT_ERR_BADNCELLS;
@@ -78,10 +78,20 @@ static int fdt_cells(const void *fdt, int nodeoffset, 
 
 int fdt_address_cells(const void *fdt, int nodeoffset)
 {
-   return fdt_cells(fdt, nodeoffset, "#address-cells");
+   int val;
+
+   val = fdt_cells(fdt, nodeoffset, "#address-cells");
+   if (val == -FDT_ERR_NOTFOUND)
+   return 2;
+   return val;
 }
 
 int fdt_size_cells(const void *fdt, int nodeoffset)
 {
-   return fdt_cells(fdt, nodeoffset, "#size-cells");
+   int val;
+
+   val = fdt_cells(fdt, nodeoffset, "#size-cells");
+   if (val == -FDT_ERR_NOTFOUND)
+   return 1;
+   return val;
 }

Modified: vendor-sys/libfdt/dist/libfdt.h
==
--- vendor-sys/libfdt/dist/libfdt.h Fri May 24 01:53:45 2019
(r348219)
+++ vendor-sys/libfdt/dist/libfdt.h Fri May 24 02:10:16 2019
(r348220)
@@ -163,18 +163,26 @@ uint32_t fdt_next_tag(const void *fdt, int offset, int
 
 static inline uint32_t fdt32_ld(const fdt32_t *p)
 {
-   fdt32_t v;
+   const uint8_t *bp = (const uint8_t *)p;
 
-   memcpy(&v, p, sizeof(v));
-   return fdt32_to_cpu(v);
+   return ((uint32_t)bp[0] << 24)
+   | ((uint32_t)bp[1] << 16)
+   | ((uint32_t)bp[2] << 8)
+   | bp[3];
 }
 
 static inline uint64_t fdt64_ld(const fdt64_t *p)
 {
-   fdt64_t v;
+   const uint8_t *bp = (const uint8_t *)p;
 
-   memcpy(&v, p, sizeof(v));
-   return fdt64_to_cpu(v);
+   return ((uint64_t)bp[0] << 56)
+   | ((uint64_t)bp[1] << 48)
+   | ((uint64_t)bp[2] << 40)
+   | ((uint64_t)bp[3] << 32)
+   | ((uint64_t)bp[4] << 24)
+   | ((uint64_t)bp[5] << 16)
+   | ((uint64_t)bp[6] << 8)
+   | bp[7];
 }
 
 /**/
@@ -219,7 +227,7 @@ int fdt_next_subnode(const void *fdt, int offset);
  * ...
  * }
  *
- * if ((node < 0) && (node != -FDT_ERR_NOT_FOUND)) {
+ * if ((node < 0) && (node != -FDT_ERR_NOTFOUND)) {
  * Error handling
  * }
  *
@@ -558,7 +566,7 @@ int fdt_next_property_offset(const void *fdt, int offs
  * ...
  * }
  *
- * if ((property < 0) && (property != -FDT_ERR_NOT_FOUND)) {
+ * if ((property < 0) && (property != -FDT_ERR_NOTFOUND)) {
  * Error handling
  * }
  *
@@ -661,7 +669,7 @@ static inline struct fdt_property *fdt_get_property_w(
 /**
  * fdt_getprop_by_offset - retrieve the value of a property at a given offset
  * @fdt: pointer to the device tree blob
- * @ffset: offset of the property to read
+ * @offset: offset of the property to read
  * @namep: pointer to a string variable (will be overwritten) or NULL
  * @lenp: pointer to an integer variable (will be overwritten) or NULL
  *
@@ -1145,7 +1153,7 @@ int fdt_address_cells(const void *fdt, int nodeoffset)
  *
  * returns:
  * 0 <= n < FDT_MAX_NCELLS, on success
- *  2, if the node has no #size-cells property
+ *  1, if the node has no #size-cells property
  *  -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid
  * #size-cells property
  * -FDT_ERR_BADMAGIC,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freeb

svn commit: r348221 - vendor-sys/libfdt/1.5.0

2019-05-23 Thread Kyle Evans
Author: kevans
Date: Fri May 24 02:10:51 2019
New Revision: 348221
URL: https://svnweb.freebsd.org/changeset/base/348221

Log:
  Tag libfdt 1.5.0

Added:
  vendor-sys/libfdt/1.5.0/
 - copied from r348220, vendor-sys/libfdt/dist/
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348296 - stable/12/sbin/bectl

2019-05-26 Thread Kyle Evans
Author: kevans
Date: Mon May 27 02:17:41 2019
New Revision: 348296
URL: https://svnweb.freebsd.org/changeset/base/348296

Log:
  MFC r348127: bectl(8): add description for create subcommand
  
  In commit r345845, a portion of documentation for the create subcommand was
  removed. Specifically, for creating a snapshot of an existing boot
  environment. bectl even has a test-case for this functionality.
  
  Removing the sub-command description was discussed in PR 235850.
  
  This patch brings back the second "create" description that was originally
  in place. Albeit, with a few wording/clarifying changes.

Modified:
  stable/12/sbin/bectl/bectl.8
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/bectl/bectl.8
==
--- stable/12/sbin/bectl/bectl.8Mon May 27 00:55:46 2019
(r348295)
+++ stable/12/sbin/bectl/bectl.8Mon May 27 02:17:41 2019
(r348296)
@@ -18,7 +18,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 10, 2019
+.Dd May 12, 2019
 .Dt BECTL 8
 .Os
 .Sh NAME
@@ -122,6 +122,20 @@ Creates a snapshot of the existing boot environment na
 If the
 .Fl r
 flag is given, a recursive boot environment will be made.
+.It Xo
+.Cm create
+.Op Fl r
+.Ar beName@snapshot
+.Xc
+Create a snapshot of the boot environment named
+.Ar beName .
+.Pp
+If the
+.Fl r
+flag is given, a recursive snapshot of the boot environment will be created.
+A snapshot is created for each descendant dataset of the boot environment.
+.Pp
+No new boot environment is created with this command.
 .It Xo
 .Cm destroy
 .Op Fl \&Fo
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348297 - in stable/12: lib/libjail sbin/bectl/tests

2019-05-26 Thread Kyle Evans
Author: kevans
Date: Mon May 27 02:18:33 2019
New Revision: 348297
URL: https://svnweb.freebsd.org/changeset/base/348297

Log:
  MFC r348215, r348219: fix bectl(8) jail w/ numeric BE names
  
  r348215:
  jail_getid(3): validate jid string input
  
  Currently, if jail_getid(3) is passed in a numeric string, it assumes that
  this is a jid string and passes it back converted to an int without checking
  that it's a valid/existing jid. This breaks consumers that might use
  jail_getid(3) to see if it can trivially grab a jid from a name if that name
  happens to be numeric but not actually the name/jid of the jail. Instead of
  returning -1 for the jail not existing, it'll return the int version of the
  input and the consumer will not fallback to trying other methods.
  
  Pass the numeric input to jail_get(2) as the jid for validation, rather than
  the name. This works well- the kernel enforces that jid=name if name is
  numeric, so doing the safe thing and checking numeric input as a jid will
  still DTRT based on the description of jail_getid.
  
  r348219:
  bectl(8): Add a test for jail/unjail of numeric BE names
  
  Fixed by r348215, bectl ujail first attempts the trivial fetch of a jid by
  passing the first argument to 'ujail' to jail_getid(3) in case a jid/name
  have been passed in instead of a BE name. For numerically named BEs, this
  was doing the wrong thing: instead of failing to locate the jid specified
  and falling back to mountpath search, jail_getid(3) would return the input
  as-is.
  
  While here, I've fixed bectl_jail_cleanup which still used a hard-coded pool
  name that was overlooked w.r.t. other work that was in-flight around the
  same time.

Modified:
  stable/12/lib/libjail/jail_getid.c
  stable/12/sbin/bectl/tests/bectl_test.sh
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libjail/jail_getid.c
==
--- stable/12/lib/libjail/jail_getid.c  Mon May 27 02:17:41 2019
(r348296)
+++ stable/12/lib/libjail/jail_getid.c  Mon May 27 02:18:33 2019
(r348297)
@@ -53,13 +53,18 @@ jail_getid(const char *name)
struct iovec jiov[4];
 
jid = strtoul(name, &ep, 10);
-   if (*name && !*ep)
-   return jid;
-   jiov[0].iov_base = __DECONST(char *, "name");
-   jiov[0].iov_len = sizeof("name");
-   jiov[1].iov_len = strlen(name) + 1;
-   jiov[1].iov_base = alloca(jiov[1].iov_len);
-   strcpy(jiov[1].iov_base, name);
+   if (*name && !*ep) {
+   jiov[0].iov_base = __DECONST(char *, "jid");
+   jiov[0].iov_len = sizeof("jid");
+   jiov[1].iov_base = &jid;
+   jiov[1].iov_len = sizeof(jid);
+   } else {
+   jiov[0].iov_base = __DECONST(char *, "name");
+   jiov[0].iov_len = sizeof("name");
+   jiov[1].iov_len = strlen(name) + 1;
+   jiov[1].iov_base = alloca(jiov[1].iov_len);
+   strcpy(jiov[1].iov_base, name);
+   }
jiov[2].iov_base = __DECONST(char *, "errmsg");
jiov[2].iov_len = sizeof("errmsg");
jiov[3].iov_base = jail_errmsg;

Modified: stable/12/sbin/bectl/tests/bectl_test.sh
==
--- stable/12/sbin/bectl/tests/bectl_test.shMon May 27 02:17:41 2019
(r348296)
+++ stable/12/sbin/bectl/tests/bectl_test.shMon May 27 02:18:33 2019
(r348297)
@@ -294,9 +294,16 @@ bectl_jail_body()
atf_check cp /rescue/rescue ${root}/rescue/rescue
atf_check bectl -r ${zpool}/ROOT umount default
 
-   # Prepare a second boot environment
+   # Prepare some more boot environments
atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT create -e default 
target
+   atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT create -e default 
1234
 
+   # Attempt to unjail a BE with numeric name; jail_getid at one point
+   # did not validate that the input was a valid jid before returning the
+   # jid.
+   atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT jail -b 1234
+   atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT unjail 1234
+
# When a jail name is not explicit, it should match the jail id.
atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT jail -b -o 
jid=233637 default
atf_check -o inline:"233637\n" -s exit:0 -x "jls -j 233637 name"
@@ -340,9 +347,10 @@ bectl_jail_body()
 # attempts to destroy the zpool.
 bectl_jail_cleanup()
 {
-   for bootenv in "default" "target"; do
+   zpool=$(get_zpool_name)
+   for bootenv in "default" "target" "1234"; do
# mountpoint of the boot environment
-   mountpoint="$(bectl -r bectl_test/ROOT list -H | grep 
${bootenv} | awk '{print $3}')"
+   mountpoint="$(bectl -r ${zpool}/ROOT list -H | grep ${bootenv} 
| awk '{print $3}')"
 
# s

svn commit: r348304 - in stable/11: lib/libjail sbin/bectl/tests

2019-05-27 Thread Kyle Evans
Author: kevans
Date: Mon May 27 13:12:51 2019
New Revision: 348304
URL: https://svnweb.freebsd.org/changeset/base/348304

Log:
  MFC r348215, r348219: fix bectl(8) jail w/ numeric BE names
  
  r348215:
  jail_getid(3): validate jid string input
  
  Currently, if jail_getid(3) is passed in a numeric string, it assumes that
  this is a jid string and passes it back converted to an int without checking
  that it's a valid/existing jid. This breaks consumers that might use
  jail_getid(3) to see if it can trivially grab a jid from a name if that name
  happens to be numeric but not actually the name/jid of the jail. Instead of
  returning -1 for the jail not existing, it'll return the int version of the
  input and the consumer will not fallback to trying other methods.
  
  Pass the numeric input to jail_get(2) as the jid for validation, rather than
  the name. This works well- the kernel enforces that jid=name if name is
  numeric, so doing the safe thing and checking numeric input as a jid will
  still DTRT based on the description of jail_getid.
  
  r348219:
  bectl(8): Add a test for jail/unjail of numeric BE names
  
  Fixed by r348215, bectl ujail first attempts the trivial fetch of a jid by
  passing the first argument to 'ujail' to jail_getid(3) in case a jid/name
  have been passed in instead of a BE name. For numerically named BEs, this
  was doing the wrong thing: instead of failing to locate the jid specified
  and falling back to mountpath search, jail_getid(3) would return the input
  as-is.
  
  While here, I've fixed bectl_jail_cleanup which still used a hard-coded pool
  name that was overlooked w.r.t. other work that was in-flight around the
  same time.
  
  Approved by:  re (marius)

Modified:
  stable/11/lib/libjail/jail_getid.c
  stable/11/sbin/bectl/tests/bectl_test.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libjail/jail_getid.c
==
--- stable/11/lib/libjail/jail_getid.c  Mon May 27 12:41:41 2019
(r348303)
+++ stable/11/lib/libjail/jail_getid.c  Mon May 27 13:12:51 2019
(r348304)
@@ -51,13 +51,18 @@ jail_getid(const char *name)
struct iovec jiov[4];
 
jid = strtoul(name, &ep, 10);
-   if (*name && !*ep)
-   return jid;
-   jiov[0].iov_base = __DECONST(char *, "name");
-   jiov[0].iov_len = sizeof("name");
-   jiov[1].iov_len = strlen(name) + 1;
-   jiov[1].iov_base = alloca(jiov[1].iov_len);
-   strcpy(jiov[1].iov_base, name);
+   if (*name && !*ep) {
+   jiov[0].iov_base = __DECONST(char *, "jid");
+   jiov[0].iov_len = sizeof("jid");
+   jiov[1].iov_base = &jid;
+   jiov[1].iov_len = sizeof(jid);
+   } else {
+   jiov[0].iov_base = __DECONST(char *, "name");
+   jiov[0].iov_len = sizeof("name");
+   jiov[1].iov_len = strlen(name) + 1;
+   jiov[1].iov_base = alloca(jiov[1].iov_len);
+   strcpy(jiov[1].iov_base, name);
+   }
jiov[2].iov_base = __DECONST(char *, "errmsg");
jiov[2].iov_len = sizeof("errmsg");
jiov[3].iov_base = jail_errmsg;

Modified: stable/11/sbin/bectl/tests/bectl_test.sh
==
--- stable/11/sbin/bectl/tests/bectl_test.shMon May 27 12:41:41 2019
(r348303)
+++ stable/11/sbin/bectl/tests/bectl_test.shMon May 27 13:12:51 2019
(r348304)
@@ -294,9 +294,16 @@ bectl_jail_body()
atf_check cp /rescue/rescue ${root}/rescue/rescue
atf_check bectl -r ${zpool}/ROOT umount default
 
-   # Prepare a second boot environment
+   # Prepare some more boot environments
atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT create -e default 
target
+   atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT create -e default 
1234
 
+   # Attempt to unjail a BE with numeric name; jail_getid at one point
+   # did not validate that the input was a valid jid before returning the
+   # jid.
+   atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT jail -b 1234
+   atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT unjail 1234
+
# When a jail name is not explicit, it should match the jail id.
atf_check -o empty -s exit:0 bectl -r ${zpool}/ROOT jail -b -o 
jid=233637 default
atf_check -o inline:"233637\n" -s exit:0 -x "jls -j 233637 name"
@@ -340,9 +347,10 @@ bectl_jail_body()
 # attempts to destroy the zpool.
 bectl_jail_cleanup()
 {
-   for bootenv in "default" "target"; do
+   zpool=$(get_zpool_name)
+   for bootenv in "default" "target" "1234"; do
# mountpoint of the boot environment
-   mountpoint="$(bectl -r bectl_test/ROOT list -H | grep 
${bootenv} | awk '{print $3}')"
+   mountpoint="$(bectl -r ${zpool}/ROOT list -H | grep ${bootenv} 
| awk '{pri

svn commit: r348305 - stable/11/sbin/bectl

2019-05-27 Thread Kyle Evans
Author: kevans
Date: Mon May 27 13:14:22 2019
New Revision: 348305
URL: https://svnweb.freebsd.org/changeset/base/348305

Log:
  MFC r348127: bectl(8): add description for create subcommand
  
  In commit r345845, a portion of documentation for the create subcommand was
  removed. Specifically, for creating a snapshot of an existing boot
  environment. bectl even has a test-case for this functionality.
  
  Removing the sub-command description was discussed in PR 235850.
  
  This patch brings back the second "create" description that was originally
  in place. Albeit, with a few wording/clarifying changes.
  
  Approved by:  re (marius)

Modified:
  stable/11/sbin/bectl/bectl.8
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/bectl/bectl.8
==
--- stable/11/sbin/bectl/bectl.8Mon May 27 13:12:51 2019
(r348304)
+++ stable/11/sbin/bectl/bectl.8Mon May 27 13:14:22 2019
(r348305)
@@ -18,7 +18,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 3, 2019
+.Dd May 12, 2019
 .Dt BECTL 8
 .Os
 .Sh NAME
@@ -35,6 +35,10 @@
 .Op Fl e Brq Ar nonActiveBe | Ar beName Ns Cm @ Ns Ar snapshot
 .Ar newBeName
 .Nm
+.Cm create
+.Op Fl r
+.Ar beName@snapshot
+.Nm
 .Cm destroy
 .Op Fl \&Fo
 .Ar beName Ns Op Cm @ Ns Ar snapshot
@@ -120,6 +124,20 @@ Otherwise, the new environment will be created from th
 If
 .Nm
 is creating from another boot environment, a snapshot of that boot environment 
will be created to clone from.
+.It Xo
+.Cm create
+.Op Fl r
+.Ar beName@snapshot
+.Xc
+Create a snapshot of the boot environment named
+.Ar beName .
+.Pp
+If the
+.Fl r
+flag is given, a recursive snapshot of the boot environment will be created.
+A snapshot is created for each descendant dataset of the boot environment.
+.Pp
+No new boot environment is created with this command.
 .It Xo
 .Cm destroy
 .Op Fl \&Fo
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348328 - head/sbin/bectl

2019-05-28 Thread Kyle Evans
Author: kevans
Date: Tue May 28 16:12:16 2019
New Revision: 348328
URL: https://svnweb.freebsd.org/changeset/base/348328

Log:
  bectl(8): Address Coverity complaints
  
  CID 1400451: case 0 is missing a break/return and falling through to the
  default case.  waitpid(0, ...) makes little sense in the child, we likely
  wanted to terminate immediately.
  
  CID 1400453: size argument uses sizeof(char **) instead of sizeof(char *)
  and is assigned to a char **; sizeof's match but "this isn't a portable
  assumption".
  
  CID:  1400451, 1400453
  MFC after:3 days

Modified:
  head/sbin/bectl/bectl_jail.c

Modified: head/sbin/bectl/bectl_jail.c
==
--- head/sbin/bectl/bectl_jail.cTue May 28 15:47:00 2019
(r348327)
+++ head/sbin/bectl/bectl_jail.cTue May 28 16:12:16 2019
(r348328)
@@ -155,7 +155,7 @@ build_jailcmd(char ***argvp, bool interactive, int arg
nargv += argc;
}
 
-   jargv = *argvp = calloc(nargv, sizeof(jargv));
+   jargv = *argvp = calloc(nargv, sizeof(*jargv));
if (jargv == NULL)
err(2, "calloc");
 
@@ -346,6 +346,7 @@ bectl_cmd_jail(int argc, char *argv[])
case 0:
execv("/usr/sbin/jail", jargv);
fprintf(stderr, "bectl jail: failed to execute\n");
+   return (1);
default:
waitpid(pid, NULL, 0);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348346 - head/sys/net

2019-05-28 Thread Kyle Evans
Author: kevans
Date: Wed May 29 01:08:30 2019
New Revision: 348346
URL: https://svnweb.freebsd.org/changeset/base/348346

Log:
  if_bridge(4): Complete bpf auditing of local traffic over the bridge
  
  There were two remaining "gaps" in auditing local bridge traffic with
  bpf(4):
  
  Locally originated outbound traffic from a member interface is invisible to
  the bridge's bpf(4) interface. Inbound traffic locally destined to a member
  interface is invisible to the member's bpf(4) interface -- this traffic has
  no chance after bridge_input to otherwise pass it over, and it wasn't
  originally received on this interface.
  
  I call these "gaps" because they don't affect conventional bridge setups.
  Alas, being able to establish an audit trail of all locally destined traffic
  for setups that can function like this is useful in some scenarios.
  
  Reviewed by:  kp
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D19757

Modified:
  head/sys/net/if_bridge.c

Modified: head/sys/net/if_bridge.c
==
--- head/sys/net/if_bridge.cWed May 29 00:54:49 2019(r348345)
+++ head/sys/net/if_bridge.cWed May 29 01:08:30 2019(r348346)
@@ -2000,7 +2000,7 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struc
 struct rtentry *rt)
 {
struct ether_header *eh;
-   struct ifnet *dst_if;
+   struct ifnet *bifp, *dst_if;
struct bridge_softc *sc;
uint16_t vlan;
 
@@ -2015,13 +2015,14 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struc
vlan = VLANTAGOF(m);
 
BRIDGE_LOCK(sc);
+   bifp = sc->sc_ifp;
 
/*
 * If bridge is down, but the original output interface is up,
 * go ahead and send out that interface.  Otherwise, the packet
 * is dropped below.
 */
-   if ((sc->sc_ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
+   if ((bifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {
dst_if = ifp;
goto sendunicast;
}
@@ -2034,6 +2035,9 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struc
dst_if = NULL;
else
dst_if = bridge_rtlookup(sc, eh->ether_dhost, vlan);
+   /* Tap any traffic not passing back out the originating interface */
+   if (dst_if != ifp)
+   ETHER_BPF_MTAP(bifp, m);
if (dst_if == NULL) {
struct bridge_iflist *bif;
struct mbuf *mc;
@@ -2071,7 +2075,7 @@ bridge_output(struct ifnet *ifp, struct mbuf *m, struc
} else {
mc = m_copypacket(m, M_NOWAIT);
if (mc == NULL) {
-   if_inc_counter(sc->sc_ifp, 
IFCOUNTER_OERRORS, 1);
+   if_inc_counter(bifp, IFCOUNTER_OERRORS, 
1);
continue;
}
}
@@ -2450,6 +2454,8 @@ bridge_input(struct ifnet *ifp, struct mbuf *m)
return (NULL);  \
}   \
}   \
+   if ((iface) != bifp)\
+   ETHER_BPF_MTAP(iface, m);   \
BRIDGE_UNLOCK(sc);  \
return (m); \
}   \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348471 - head/stand/libsa/zfs

2019-05-31 Thread Kyle Evans
Author: kevans
Date: Fri May 31 17:44:22 2019
New Revision: 348471
URL: https://svnweb.freebsd.org/changeset/base/348471

Log:
  stand: zfs: Free bouncebuf on error path in vdev_read
  
  r344226 inadvertently added this path in which we return from failure on an
  lseek and do not free bouncebuf on the way out.
  
  MFC after:3 days

Modified:
  head/stand/libsa/zfs/zfs.c

Modified: head/stand/libsa/zfs/zfs.c
==
--- head/stand/libsa/zfs/zfs.c  Fri May 31 17:18:09 2019(r348470)
+++ head/stand/libsa/zfs/zfs.c  Fri May 31 17:44:22 2019(r348471)
@@ -425,8 +425,10 @@ vdev_read(vdev_t *vdev, void *priv, off_t offset, void
}
}
 
-   if (lseek(fd, start_sec * secsz, SEEK_SET) == -1)
-   return (errno);
+   if (lseek(fd, start_sec * secsz, SEEK_SET) == -1) {
+   ret = errno;
+   goto error;
+   }
 
/* Partial data return from first sector */
if (head > 0) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348503 - head/usr.bin/grep

2019-06-01 Thread Kyle Evans
Author: kevans
Date: Sun Jun  2 02:38:44 2019
New Revision: 348503
URL: https://svnweb.freebsd.org/changeset/base/348503

Log:
  grep: Move lone 'r'grep case into the adjacent switch
  
  This 'r' case should have belonged to the switch in the first place, but
  I had somehow missed the switch when initially adding the rgrep link. The
  zgrep script later came along and faithfully left this case standing alone,
  so we will now go ahead and join it.
  
  Nearby comment also adjusted a tad bit for wording and style.
  
  Reported by:  Daniel Ebdrup
  MFC after:3 days

Modified:
  head/usr.bin/grep/grep.c

Modified: head/usr.bin/grep/grep.c
==
--- head/usr.bin/grep/grep.cSun Jun  2 01:00:17 2019(r348502)
+++ head/usr.bin/grep/grep.cSun Jun  2 02:38:44 2019(r348503)
@@ -343,20 +343,22 @@ main(int argc, char *argv[])
 
setlocale(LC_ALL, "");
 
-   /* Check what is the program name of the binary.  In this
-  way we can have all the funcionalities in one binary
-  without the need of scripting and using ugly hacks. */
+   /*
+* Check how we've bene invoked to determine the behavior we should
+* exhibit. In this way we can have all the functionalities in one
+* binary without the need of scripting and using ugly hacks.
+*/
pn = getprogname();
-   if (pn[0] == 'r') {
-   dirbehave = DIR_RECURSE;
-   Hflag = true;
-   }
switch (pn[0]) {
case 'e':
grepbehave = GREP_EXTENDED;
break;
case 'f':
grepbehave = GREP_FIXED;
+   break;
+   case 'r':
+   dirbehave = DIR_RECURSE;
+   Hflag = true;
break;
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348504 - in head: lib/clang/libllvm tools/build/mk usr.bin/clang

2019-06-01 Thread Kyle Evans
Author: kevans
Date: Sun Jun  2 04:04:21 2019
New Revision: 348504
URL: https://svnweb.freebsd.org/changeset/base/348504

Log:
  llvm-symbolizer: Move out of CLANG_EXTRAS, into CLANG
  
  ASAN reports become a lot more useful with llvm-symbolizer in $PATH, and the
  build is not much more time-consuming. The added benefit is that the
  resulting reports will actually include symbol information; without, thread
  trace information includes a bunch of addresses that immediately resolve to
  an inline function in
  ^/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common.h and take a
  little more effort to examine.
  
  Reviewed by:  emaste
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D20484

Modified:
  head/lib/clang/libllvm/Makefile
  head/tools/build/mk/OptionalObsoleteFiles.inc
  head/usr.bin/clang/Makefile

Modified: head/lib/clang/libllvm/Makefile
==
--- head/lib/clang/libllvm/Makefile Sun Jun  2 02:38:44 2019
(r348503)
+++ head/lib/clang/libllvm/Makefile Sun Jun  2 04:04:21 2019
(r348504)
@@ -523,7 +523,7 @@ SRCS_EXT+=  DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp
 SRCS_EXT+= DebugInfo/PDB/PDBSymbolUnknown.cpp
 SRCS_EXT+= DebugInfo/PDB/PDBSymbolUsingNamespace.cpp
 SRCS_EXT+= DebugInfo/PDB/UDTLayout.cpp
-SRCS_EXT+= DebugInfo/Symbolize/DIPrinter.cpp
+SRCS_MIW+= DebugInfo/Symbolize/DIPrinter.cpp
 SRCS_MIW+= DebugInfo/Symbolize/SymbolizableObjectFile.cpp
 SRCS_MIW+= DebugInfo/Symbolize/Symbolize.cpp
 SRCS_MIN+= Demangle/ItaniumDemangle.cpp
@@ -779,7 +779,7 @@ SRCS_MIN+=  Support/BinaryStreamWriter.cpp
 SRCS_MIN+= Support/BlockFrequency.cpp
 SRCS_MIN+= Support/BranchProbability.cpp
 SRCS_MIN+= Support/BuryPointer.cpp
-SRCS_EXT+= Support/COM.cpp
+SRCS_MIW+= Support/COM.cpp
 SRCS_MIN+= Support/CachePruning.cpp
 SRCS_MIN+= Support/Chrono.cpp
 SRCS_MIN+= Support/CodeGenCoverage.cpp

Modified: head/tools/build/mk/OptionalObsoleteFiles.inc
==
--- head/tools/build/mk/OptionalObsoleteFiles.inc   Sun Jun  2 02:38:44 
2019(r348503)
+++ head/tools/build/mk/OptionalObsoleteFiles.inc   Sun Jun  2 04:04:21 
2019(r348504)
@@ -1372,6 +1372,7 @@ OLD_FILES+=usr/bin/clang++
 OLD_FILES+=usr/bin/clang-cpp
 OLD_FILES+=usr/bin/clang-tblgen
 OLD_FILES+=usr/bin/llvm-objdump
+OLD_FILES+=usr/bin/llvm-symbolizer
 OLD_FILES+=usr/bin/llvm-tblgen
 OLD_FILES+=usr/lib/clang/8.0.0/include/sanitizer/allocator_interface.h
 OLD_FILES+=usr/lib/clang/8.0.0/include/sanitizer/asan_interface.h
@@ -1561,7 +1562,6 @@ OLD_FILES+=usr/bin/llvm-objcopy
 OLD_FILES+=usr/bin/llvm-pdbutil
 OLD_FILES+=usr/bin/llvm-ranlib
 OLD_FILES+=usr/bin/llvm-rtdyld
-OLD_FILES+=usr/bin/llvm-symbolizer
 OLD_FILES+=usr/bin/llvm-xray
 OLD_FILES+=usr/bin/opt
 OLD_FILES+=usr/share/man/man1/bugpoint.1.gz

Modified: head/usr.bin/clang/Makefile
==
--- head/usr.bin/clang/Makefile Sun Jun  2 02:38:44 2019(r348503)
+++ head/usr.bin/clang/Makefile Sun Jun  2 04:04:21 2019(r348504)
@@ -8,6 +8,7 @@ SUBDIR+=llvm-tblgen
 
 .if !defined(TOOLS_PREFIX)
 SUBDIR+=   llvm-objdump
+SUBDIR+=   llvm-symbolizer
 
 .if ${MK_CLANG_EXTRAS} != "no"
 SUBDIR+=   bugpoint
@@ -33,7 +34,6 @@ SUBDIR+=  llvm-nm
 SUBDIR+=   llvm-objcopy
 SUBDIR+=   llvm-pdbutil
 SUBDIR+=   llvm-rtdyld
-SUBDIR+=   llvm-symbolizer
 SUBDIR+=   llvm-xray
 SUBDIR+=   opt
 .endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348509 - head/lib/libjail

2019-06-02 Thread Kyle Evans
Author: kevans
Date: Sun Jun  2 14:03:56 2019
New Revision: 348509
URL: https://svnweb.freebsd.org/changeset/base/348509

Log:
  jail_getid(3): add special-case immediate return for jid 0
  
  As depicted in the comment: jid 0 always exists, but the lookup will fail as
  it does not appear in the kernel's alljails list being a special jail. Some
  callers will expect/rely on this, and we have no reason to lie because it
  does always exist.
  
  Reported by:  Stefan Hegnauer 
  MFC after:soon (regression, breaks inspecting jail host bits, partial
  revert)

Modified:
  head/lib/libjail/jail_getid.c

Modified: head/lib/libjail/jail_getid.c
==
--- head/lib/libjail/jail_getid.c   Sun Jun  2 09:28:50 2019
(r348508)
+++ head/lib/libjail/jail_getid.c   Sun Jun  2 14:03:56 2019
(r348509)
@@ -54,6 +54,15 @@ jail_getid(const char *name)
 
jid = strtoul(name, &ep, 10);
if (*name && !*ep) {
+   /*
+* jid == 0 is a special case; it will not appear in the
+* kernel's jail list, but naturally processes will be assigned
+* to it because it is prison 0.  Trivially return this one
+* without a trip to the kernel, because it always exists but
+* the lookup won't succeed.
+*/
+   if (jid == 0)
+   return jid;
jiov[0].iov_base = __DECONST(char *, "jid");
jiov[0].iov_len = sizeof("jid");
jiov[1].iov_base = &jid;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348510 - head/sbin/bectl

2019-06-02 Thread Kyle Evans
Author: kevans
Date: Sun Jun  2 14:05:51 2019
New Revision: 348510
URL: https://svnweb.freebsd.org/changeset/base/348510

Log:
  bectl(8): Don't accept jid=0 from jail_getid
  
  This will trivially exist, but we don't want it - none of our jailed BEs
  will have jid=0.
  
  MFC after:3 days

Modified:
  head/sbin/bectl/bectl_jail.c

Modified: head/sbin/bectl/bectl_jail.c
==
--- head/sbin/bectl/bectl_jail.cSun Jun  2 14:03:56 2019
(r348509)
+++ head/sbin/bectl/bectl_jail.cSun Jun  2 14:05:51 2019
(r348510)
@@ -411,7 +411,12 @@ bectl_locate_jail(const char *ident)
 
/* Try the easy-match first */
jid = jail_getid(ident);
-   if (jid != -1)
+   /*
+* jail_getid(0) will always return 0, because this prison does exist.
+* bectl(8) knows that this is not what it wants, so we should fall
+* back to mount point search.
+*/
+   if (jid > 0)
return (jid);
 
/* Attempt to try it as a BE name, first */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r348504 - in head: lib/clang/libllvm tools/build/mk usr.bin/clang

2019-06-02 Thread Kyle Evans
On Sun, Jun 2, 2019 at 6:56 AM Shawn Webb  wrote:
>
> On Sun, Jun 02, 2019 at 04:04:21AM +, Kyle Evans wrote:
> > Author: kevans
> > Date: Sun Jun  2 04:04:21 2019
> > New Revision: 348504
> > URL: https://svnweb.freebsd.org/changeset/base/348504
> >
> > Log:
> >   llvm-symbolizer: Move out of CLANG_EXTRAS, into CLANG
> >
> >   ASAN reports become a lot more useful with llvm-symbolizer in $PATH, and 
> > the
> >   build is not much more time-consuming. The added benefit is that the
> >   resulting reports will actually include symbol information; without, 
> > thread
> >   trace information includes a bunch of addresses that immediately resolve 
> > to
> >   an inline function in
> >   ^/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common.h and take a
> >   little more effort to examine.
> >
> >   Reviewed by:emaste
> >   MFC after:  1 week
> >   Differential Revision:  https://reviews.freebsd.org/D20484
> >
> > Modified:
> >   head/lib/clang/libllvm/Makefile
> >   head/tools/build/mk/OptionalObsoleteFiles.inc
> >   head/usr.bin/clang/Makefile
> >
> > Modified: head/lib/clang/libllvm/Makefile
> > ==
> > --- head/lib/clang/libllvm/Makefile   Sun Jun  2 02:38:44 2019
> > (r348503)
> > +++ head/lib/clang/libllvm/Makefile   Sun Jun  2 04:04:21 2019
> > (r348504)
> > @@ -523,7 +523,7 @@ SRCS_EXT+=
> > DebugInfo/PDB/PDBSymbolTypeVTableShape.cpp
> >  SRCS_EXT+=   DebugInfo/PDB/PDBSymbolUnknown.cpp
> >  SRCS_EXT+=   DebugInfo/PDB/PDBSymbolUsingNamespace.cpp
> >  SRCS_EXT+=   DebugInfo/PDB/UDTLayout.cpp
> > -SRCS_EXT+=   DebugInfo/Symbolize/DIPrinter.cpp
> > +SRCS_MIW+=   DebugInfo/Symbolize/DIPrinter.cpp
> >  SRCS_MIW+=   DebugInfo/Symbolize/SymbolizableObjectFile.cpp
> >  SRCS_MIW+=   DebugInfo/Symbolize/Symbolize.cpp
>
> Is SRCS_MIW the right spelling?
>

Yup. Here's my understanding from looking at usage:

SRCS_MIN = Absolute minimum set of src to build libllvm for bootstrap
tools (MIN = MINimum)
SRCS_MIW = Anything else needed to build libllvm for world tools (MIW
= MIn World)

Thanks,

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


svn commit: r348538 - stable/12/lib/libjail

2019-06-03 Thread Kyle Evans
Author: kevans
Date: Mon Jun  3 15:28:37 2019
New Revision: 348538
URL: https://svnweb.freebsd.org/changeset/base/348538

Log:
  MFC r348509: jail_getid(3): add special-case immediate return for jid 0
  
  As depicted in the comment: jid 0 always exists, but the lookup will fail as
  it does not appear in the kernel's alljails list being a special jail. Some
  callers will expect/rely on this, and we have no reason to lie because it
  does always exist.
  
  Approved by:  re (early MFC)

Modified:
  stable/12/lib/libjail/jail_getid.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libjail/jail_getid.c
==
--- stable/12/lib/libjail/jail_getid.c  Mon Jun  3 15:25:12 2019
(r348537)
+++ stable/12/lib/libjail/jail_getid.c  Mon Jun  3 15:28:37 2019
(r348538)
@@ -54,6 +54,15 @@ jail_getid(const char *name)
 
jid = strtoul(name, &ep, 10);
if (*name && !*ep) {
+   /*
+* jid == 0 is a special case; it will not appear in the
+* kernel's jail list, but naturally processes will be assigned
+* to it because it is prison 0.  Trivially return this one
+* without a trip to the kernel, because it always exists but
+* the lookup won't succeed.
+*/
+   if (jid == 0)
+   return jid;
jiov[0].iov_base = __DECONST(char *, "jid");
jiov[0].iov_len = sizeof("jid");
jiov[1].iov_base = &jid;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348546 - stable/11/lib/libjail

2019-06-03 Thread Kyle Evans
Author: kevans
Date: Mon Jun  3 16:47:51 2019
New Revision: 348546
URL: https://svnweb.freebsd.org/changeset/base/348546

Log:
  MFC r348509: jail_getid(3): add special-case immediate return for jid 0
  
  As depicted in the comment: jid 0 always exists, but the lookup will fail as
  it does not appear in the kernel's alljails list being a special jail. Some
  callers will expect/rely on this, and we have no reason to lie because it
  does always exist.
  
  Approved by:  re (gjb)

Modified:
  stable/11/lib/libjail/jail_getid.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libjail/jail_getid.c
==
--- stable/11/lib/libjail/jail_getid.c  Mon Jun  3 16:47:00 2019
(r348545)
+++ stable/11/lib/libjail/jail_getid.c  Mon Jun  3 16:47:51 2019
(r348546)
@@ -52,6 +52,15 @@ jail_getid(const char *name)
 
jid = strtoul(name, &ep, 10);
if (*name && !*ep) {
+   /*
+* jid == 0 is a special case; it will not appear in the
+* kernel's jail list, but naturally processes will be assigned
+* to it because it is prison 0.  Trivially return this one
+* without a trip to the kernel, because it always exists but
+* the lookup won't succeed.
+*/
+   if (jid == 0)
+   return jid;
jiov[0].iov_base = __DECONST(char *, "jid");
jiov[0].iov_len = sizeof("jid");
jiov[1].iov_base = &jid;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r348610 - in head: lib/clang/libllvm usr.bin/clang

2019-06-04 Thread Kyle Evans
On Tue, Jun 4, 2019 at 7:07 PM John Baldwin  wrote:
>
> On 6/4/19 6:00 AM, Ed Maste wrote:
> > Author: emaste
> > Date: Tue Jun  4 13:00:49 2019
> > New Revision: 348610
> > URL: https://svnweb.freebsd.org/changeset/base/348610
> >
> > Log:
> >   build llvm-ar and llvm-nm with Clang (promote out of CLANG_EXTRAS)
> >
> >   To facilitate experimentation with LTO we require an ar that supports
> >   LLVM IR, and to a lesser degree also an nm.  As a first step always
> >   install llvm-ar and llvm-nm.
> >
> >   Sponsored by:   The FreeBSD Foundation
> >
> > Modified:
> >   head/lib/clang/libllvm/Makefile
> >   head/usr.bin/clang/Makefile
>
> I think you missed updating OptionalObsoleteFiles.inc or ObsoleteFiles.inc or
> some such because 'make delete-old' wants to delete these after they have been
> installed.
>
> Possibly the same for the recently-enabled llvm-symbolizer as well.
>

Just to confirm... the commit for llvm-symbolizer included the move
from MK_CLANG_EXTRAS to MK_CLANG in OptionalObsoleteFiles.

Thanks,

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


Re: svn commit: r348610 - in head: lib/clang/libllvm usr.bin/clang

2019-06-05 Thread Kyle Evans
On Wed, Jun 5, 2019 at 9:09 AM Ed Maste  wrote:
>
> On Tue, 4 Jun 2019 at 21:35, Kyle Evans  wrote:
> >
> > Just to confirm... the commit for llvm-symbolizer included the move
> > from MK_CLANG_EXTRAS to MK_CLANG in OptionalObsoleteFiles.
>
> Not the man page though, it turns out - I moved it now in r348689.

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


svn commit: r348862 - stable/12/sbin/bectl

2019-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 10 14:35:04 2019
New Revision: 348862
URL: https://svnweb.freebsd.org/changeset/base/348862

Log:
  MFC r348510: bectl(8): Don't accept jid=0 from jail_getid
  
  This will trivially exist, but we don't want it - none of our jailed BEs
  will have jid=0.

Modified:
  stable/12/sbin/bectl/bectl_jail.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/bectl/bectl_jail.c
==
--- stable/12/sbin/bectl/bectl_jail.c   Mon Jun 10 14:31:18 2019
(r348861)
+++ stable/12/sbin/bectl/bectl_jail.c   Mon Jun 10 14:35:04 2019
(r348862)
@@ -410,7 +410,12 @@ bectl_locate_jail(const char *ident)
 
/* Try the easy-match first */
jid = jail_getid(ident);
-   if (jid != -1)
+   /*
+* jail_getid(0) will always return 0, because this prison does exist.
+* bectl(8) knows that this is not what it wants, so we should fall
+* back to mount point search.
+*/
+   if (jid > 0)
return (jid);
 
/* Attempt to try it as a BE name, first */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348863 - stable/11/sbin/bectl

2019-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 10 14:47:56 2019
New Revision: 348863
URL: https://svnweb.freebsd.org/changeset/base/348863

Log:
  MFC r348510: bectl(8): Don't accept jid=0 from jail_getid
  
  This will trivially exist, but we don't want it - none of our jailed BEs
  will have jid=0.
  
  Approved by:  re (gjb)

Modified:
  stable/11/sbin/bectl/bectl_jail.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/bectl/bectl_jail.c
==
--- stable/11/sbin/bectl/bectl_jail.c   Mon Jun 10 14:35:04 2019
(r348862)
+++ stable/11/sbin/bectl/bectl_jail.c   Mon Jun 10 14:47:56 2019
(r348863)
@@ -410,7 +410,12 @@ bectl_locate_jail(const char *ident)
 
/* Try the easy-match first */
jid = jail_getid(ident);
-   if (jid != -1)
+   /*
+* jail_getid(0) will always return 0, because this prison does exist.
+* bectl(8) knows that this is not what it wants, so we should fall
+* back to mount point search.
+*/
+   if (jid > 0)
return (jid);
 
/* Attempt to try it as a BE name, first */
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348865 - in stable/12/stand: common i386/zfsboot

2019-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 10 15:46:19 2019
New Revision: 348865
URL: https://svnweb.freebsd.org/changeset/base/348865

Log:
  MFC r348569: [zfsboot] Fix boot env back compat (#190)
  
  * Fix boot env back compat
  
  zfsboot must try zfsloader before loader in order to remain compatible
  with boot environments created prior to zfs functionality being rolled
  into loader proper.
  
  * Improve comments in zfsboot
  
  Explain the significance of the load path order, and put the comment
  about looping through the paths in the appropriate scope.

Modified:
  stable/12/stand/common/paths.h
  stable/12/stand/i386/zfsboot/zfsboot.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/stand/common/paths.h
==
--- stable/12/stand/common/paths.h  Mon Jun 10 15:44:09 2019
(r348864)
+++ stable/12/stand/common/paths.h  Mon Jun 10 15:46:19 2019
(r348865)
@@ -33,6 +33,7 @@
 #define PATH_CONFIG"/boot/config"
 #define PATH_LOADER"/boot/loader"
 #define PATH_LOADER_EFI"/boot/loader.efi"
+#define PATH_LOADER_ZFS"/boot/zfsloader"
 #define PATH_KERNEL"/boot/kernel/kernel"
 
 #endif /* _PATHS_H_ */

Modified: stable/12/stand/i386/zfsboot/zfsboot.c
==
--- stable/12/stand/i386/zfsboot/zfsboot.c  Mon Jun 10 15:44:09 2019
(r348864)
+++ stable/12/stand/i386/zfsboot/zfsboot.c  Mon Jun 10 15:46:19 2019
(r348865)
@@ -87,6 +87,24 @@ static const unsigned char flags[NOPT] = {
 };
 uint32_t opts;
 
+/*
+ * Paths to try loading before falling back to the boot2 prompt.
+ *
+ * /boot/zfsloader must be tried before /boot/loader in order to remain
+ * backward compatible with ZFS boot environments where /boot/loader exists
+ * but does not have ZFS support, which was the case before FreeBSD 12.
+ *
+ * If no loader is found, try to load a kernel directly instead.
+ */
+static const struct string {
+const char *p;
+size_t len;
+} loadpath[] = {
+{ PATH_LOADER_ZFS, sizeof(PATH_LOADER_ZFS) },
+{ PATH_LOADER, sizeof(PATH_LOADER) },
+{ PATH_KERNEL, sizeof(PATH_KERNEL) },
+};
+
 static const unsigned char dev_maj[NDEV] = {30, 4, 2};
 
 static char cmd[512];
@@ -838,16 +856,17 @@ main(void)
 if (nextboot && !autoboot)
reboot();
 
-/*
- * Try to exec /boot/loader. If interrupted by a keypress,
- * or in case of failure, try to load a kernel directly instead.
- */
-
 if (autoboot && !*kname) {
-   memcpy(kname, PATH_LOADER, sizeof(PATH_LOADER));
-   if (!keyhit(3)) {
+   /*
+* Iterate through the list of loader and kernel paths, trying to load.
+* If interrupted by a keypress, or in case of failure, drop the user
+* to the boot2 prompt.
+*/
+   for (i = 0; i < nitems(loadpath); i++) {
+   memcpy(kname, loadpath[i].p, loadpath[i].len);
+   if (keyhit(3))
+   break;
load();
-   memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
}
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348866 - in stable/11/stand: common i386/zfsboot

2019-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 10 15:55:38 2019
New Revision: 348866
URL: https://svnweb.freebsd.org/changeset/base/348866

Log:
  MFC r348569: [zfsboot] Fix boot env back compat (#190)
  
  * Fix boot env back compat
  
  zfsboot must try zfsloader before loader in order to remain compatible
  with boot environments created prior to zfs functionality being rolled
  into loader proper.
  
  * Improve comments in zfsboot
  
  Explain the significance of the load path order, and put the comment
  about looping through the paths in the appropriate scope.
  
  Approved by:  re (gjb)

Modified:
  stable/11/stand/common/paths.h
  stable/11/stand/i386/zfsboot/zfsboot.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/stand/common/paths.h
==
--- stable/11/stand/common/paths.h  Mon Jun 10 15:46:19 2019
(r348865)
+++ stable/11/stand/common/paths.h  Mon Jun 10 15:55:38 2019
(r348866)
@@ -33,6 +33,7 @@
 #define PATH_CONFIG"/boot/config"
 #define PATH_LOADER"/boot/loader"
 #define PATH_LOADER_EFI"/boot/loader.efi"
+#define PATH_LOADER_ZFS"/boot/zfsloader"
 #define PATH_KERNEL"/boot/kernel/kernel"
 
 #endif /* _PATHS_H_ */

Modified: stable/11/stand/i386/zfsboot/zfsboot.c
==
--- stable/11/stand/i386/zfsboot/zfsboot.c  Mon Jun 10 15:46:19 2019
(r348865)
+++ stable/11/stand/i386/zfsboot/zfsboot.c  Mon Jun 10 15:55:38 2019
(r348866)
@@ -87,6 +87,24 @@ static const unsigned char flags[NOPT] = {
 };
 uint32_t opts;
 
+/*
+ * Paths to try loading before falling back to the boot2 prompt.
+ *
+ * /boot/zfsloader must be tried before /boot/loader in order to remain
+ * backward compatible with ZFS boot environments where /boot/loader exists
+ * but does not have ZFS support, which was the case before FreeBSD 12.
+ *
+ * If no loader is found, try to load a kernel directly instead.
+ */
+static const struct string {
+const char *p;
+size_t len;
+} loadpath[] = {
+{ PATH_LOADER_ZFS, sizeof(PATH_LOADER_ZFS) },
+{ PATH_LOADER, sizeof(PATH_LOADER) },
+{ PATH_KERNEL, sizeof(PATH_KERNEL) },
+};
+
 static const unsigned char dev_maj[NDEV] = {30, 4, 2};
 
 static char cmd[512];
@@ -838,16 +856,17 @@ main(void)
 if (nextboot && !autoboot)
reboot();
 
-/*
- * Try to exec /boot/loader. If interrupted by a keypress,
- * or in case of failure, try to load a kernel directly instead.
- */
-
 if (autoboot && !*kname) {
-   memcpy(kname, PATH_LOADER, sizeof(PATH_LOADER));
-   if (!keyhit(3)) {
+   /*
+* Iterate through the list of loader and kernel paths, trying to load.
+* If interrupted by a keypress, or in case of failure, drop the user
+* to the boot2 prompt.
+*/
+   for (i = 0; i < nitems(loadpath); i++) {
+   memcpy(kname, loadpath[i].p, loadpath[i].len);
+   if (keyhit(3))
+   break;
load();
-   memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
}
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348867 - stable/11/sys/cddl/boot/zfs

2019-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 10 16:36:31 2019
New Revision: 348867
URL: https://svnweb.freebsd.org/changeset/base/348867

Log:
  MFC r342747 (mmacy): zfsboot: support newer ZFS versions
  
  declare v3 objset size/layout to fix userboot and possibly other loader
  issues
  
  - fix for userboot assertion failure in zfs_dev_close in free due to out of
bounds write
  - fix for zfs_alloc / zfs_free mismatch assertion failure when booting GPT
on BIOS
  
  Approved by:  re (gjb)

Modified:
  stable/11/sys/cddl/boot/zfs/zfsimpl.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/boot/zfs/zfsimpl.h
==
--- stable/11/sys/cddl/boot/zfs/zfsimpl.h   Mon Jun 10 15:55:38 2019
(r348866)
+++ stable/11/sys/cddl/boot/zfs/zfsimpl.h   Mon Jun 10 16:36:31 2019
(r348867)
@@ -1121,6 +1121,8 @@ typedef struct sa_hdr_phys {
 #defineSA_PARENT_OFFSET40
 #defineSA_SYMLINK_OFFSET   160
 
+#defineZIO_OBJSET_MAC_LEN  32
+
 /*
  * Intent log header - this on disk structure holds fields to manage
  * the log.  All fields are 64 bit to easily handle cross architectures.
@@ -1133,17 +1135,24 @@ typedef struct zil_header {
uint64_t zh_pad[5];
 } zil_header_t;
 
-#defineOBJSET_PHYS_SIZE 2048
+#defineOBJSET_PHYS_SIZE_V2 2048
+#defineOBJSET_PHYS_SIZE_V3 4096
 
 typedef struct objset_phys {
dnode_phys_t os_meta_dnode;
zil_header_t os_zil_header;
uint64_t os_type;
uint64_t os_flags;
-   char os_pad[OBJSET_PHYS_SIZE - sizeof (dnode_phys_t)*3 -
-   sizeof (zil_header_t) - sizeof (uint64_t)*2];
+   uint8_t os_portable_mac[ZIO_OBJSET_MAC_LEN];
+   uint8_t os_local_mac[ZIO_OBJSET_MAC_LEN];
+   char os_pad0[OBJSET_PHYS_SIZE_V2 - sizeof (dnode_phys_t)*3 -
+   sizeof (zil_header_t) - sizeof (uint64_t)*2 -
+   2*ZIO_OBJSET_MAC_LEN];
dnode_phys_t os_userused_dnode;
dnode_phys_t os_groupused_dnode;
+   dnode_phys_t os_projectused_dnode;
+   char os_pad1[OBJSET_PHYS_SIZE_V3 - OBJSET_PHYS_SIZE_V2 -
+   sizeof (dnode_phys_t)];
 } objset_phys_t;
 
 typedef struct dsl_dir_phys {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r340722 - head/lib/libbe

2018-11-21 Thread Kyle Evans
On Wed, Nov 21, 2018 at 10:19 AM Rodney W. Grimes
 wrote:
>
> > Author: 0mp (ports committer)
> > Date: Wed Nov 21 11:22:44 2018
> > New Revision: 340722
> > URL: https://svnweb.freebsd.org/changeset/base/340722
> >
> > Log:
> >   libbe(3): Put each error value in separate line.
> >
> >   As requested by a TODO in the source code.
> >
> >   Reviewed by:bcr
> >   Approved by:krion (mentor, implicit), mat (mentor, implicit)
> >   Differential Revision:  https://reviews.freebsd.org/D18063
>
> Who with a src bit approved the commit to src?
>

I do want to clarify- bcr approved it in the review (explicitly with
"... hereby approved!") -- are you mainly pointing out that he failed
to annotate this properly in the commit, or is doc bit approval for a
commit to a manpage in src insufficient?

As an aside, happy to approve any changes to these manpages as the
current bectl/libbe maintainer for anyone that wants to improve them.
=)

Thanks,

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


Re: svn commit: r340722 - head/lib/libbe

2018-11-21 Thread Kyle Evans
On Wed, Nov 21, 2018 at 10:54 AM Rodney W. Grimes
 wrote:
>
> > On Wed, Nov 21, 2018 at 10:19 AM Rodney W. Grimes
> >  wrote:
> > >
> > > > Author: 0mp (ports committer)
> > > > Date: Wed Nov 21 11:22:44 2018
> > > > New Revision: 340722
> > > > URL: https://svnweb.freebsd.org/changeset/base/340722
> > > >
> > > > Log:
> > > >   libbe(3): Put each error value in separate line.
> > > >
> > > >   As requested by a TODO in the source code.
> > > >
> > > >   Reviewed by:bcr
> > > >   Approved by:krion (mentor, implicit), mat (mentor, implicit)
> > > >   Differential Revision:  https://reviews.freebsd.org/D18063
> > >
> > > Who with a src bit approved the commit to src?
> > >
> >
> > I do want to clarify- bcr approved it in the review (explicitly with
> > "... hereby approved!") -- are you mainly pointing out that he failed
> > to annotate this properly in the commit, or is doc bit approval for a
> > commit to a manpage in src insufficient?
>
> That is defanitly a bit of a grey area, from reading and re-reading
> the commit bit page it is clear that a doc committer can commit
> to src documentation, it is not clear if they can approve a commit
> by someone else to the src tree, it does say
> ""Approved by" from a non-mentored committer
>  with the appropriate bit"
>
> It probably would be fine to have said Approved by: bcr.
>

Agreed- I think this is fine given that it's within the scope of bcr's doc bit.

> I still question what a out of scope commit that is
> approved by: (mentor, implicit).  I am not even sure
> what that means in this context.  Have his mentors
> said he can commit anything anyplace without them
> seeing it?  If so then release the mentor/mentee bit
> would be more appropriate?
>

I suspect it's that they're not interested in any doc changes he has,
because they're not doc people. Well, mat@ is, but mat isn't mentoring
him for docs, he's mentoring him for ports. Such approvals would just
be rubber stamps anyways, because they as mentors might not
necessarily be up-to-date on doc protocols.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340751 - in stable/12: etc/mtree lib/libbe sbin/bectl sbin/bectl/tests

2018-11-21 Thread Kyle Evans
Author: kevans
Date: Thu Nov 22 01:25:44 2018
New Revision: 340751
URL: https://svnweb.freebsd.org/changeset/base/340751

Log:
  MFC r340507-r340508, r340592-r340594, r340635-r340636: bectl(8) fixes
  
  r340507:
  libbe(3): rewrite init to support chroot usage
  
  libbe(3) currently uses zfs_be_root and locates which of its children is
  currently mounted at "/". This is reasonable, but not correct in the case of
  a chroot, for two reasons:
  
  - chroot root may be of a different zpool than zfs_be_root
  - chroot root will not show up as mounted at "/"
  
  Fix both of these by rewriting libbe_init to work from the rootfs down.
  zfs_path_to_zhandle on / will resolve to the dataset mounted at the new
  root, rather than the real root. From there, we can derive the BE root/pool
  and grab the bootfs off of the new pool. This does no harm in the average
  case, and opens up bectl to operating on different pools for scenarios where
  one may be, for instance, updating a pool that generally gets re-rooted into
  from a separate UFS root or zfs bootpool.
  
  While here, I've also:
  - Eliminated the check for /boot and / to be on the same partition. This
leaves one open to a setup where /boot (and consequently, kernel/modules)
are not included in the boot environment. This may very well be an
intentional setup done by someone that knows what they're doing, we should
not kill BE usage because of it.
  
  - Eliminated the validation bits of BEs and snapshots that enforced
'mountpoint' to be "/" -- this broke when trying to operate on an imported
pool with an altroot, but we need not be this picky.
  
  Reported by:  philip
  Reviewed by:  philip, allanjude (previous version)
  Tested by:philip
  Differential Revision:https://reviews.freebsd.org/D18012
  
  r340508:
  libbe(3): Rewrite be_unmount to stop mucking with getmntinfo(2)
  
  Go through the ZFS layer instead; given a BE, we can derive the dataset,
  zfs_open it, then zfs_unmount. ZFS takes care of the dirty details and
  likely gets it more correct than we did for more interesting setups.
  
  r340592:
  bectl(3)/libbe(3): Allow BE root to be specified
  
  Add an undocumented -r option preceding the bectl subcommand to specify a BE
  root to operate out of. This will remain undocumented for now, as some
  caveats apply:
  
  - BEs cannot be activated in the pool that doesn't contain the rootfs
  - bectl create cannot work out of the box without the -e option right now,
since it defaults to the rootfs and cross-pool cloning doesn't work like
that (IIRC)
  
  Plumb the BE root through to libbe(3) so that some things -can- be done to
  it, e.g.
  
  bectl -r tank/ROOT create -e default upgrade
  bectl -r tank/ROOT mount upgrade /mnt
  
  this aides in some upgrade setups where rootfs is not necessarily ZFS, and
  also makes it easier/possible to regression-test bectl when combined with a
  file-backed zpool.
  
  Differential Revision:https://reviews.freebsd.org/D18029
  
  r340593:
  libbe(3): Properly account for altroot when creating new BEs
  
  Previously we would blindly copy the 'mountpoint' property, which includes
  the altroot. The altroot needs to be snipped off prior to setting it on the
  new BE, though, or you'll end up with a new BE and a mountpoint of /mnt with
  altroot=/mnt
  
  r340594:
  bectl(8): Add some regression tests
  
  These tests operate on a file-backed zpool that gets created in the kyua
  temp dir. root and ZFS support are both required for these tests. Current
  tests cover create, destroy, export/import, jail, list (kind of), mount,
  rename, and jail.
  
  List tests should later be extended to cover formatting and the different
  list flags, but for now only covers basic "are create/destroy actually
  reflected properly"
  
  r340635:
  libbe(3): Handle non-ZFS rootfs better
  
  If rootfs isn't ZFS, current version will emit an error claiming so and fail
  to initialize libbe. As a consumer, bectl -r (undocumented) can be specified
  to operate on a BE independently of whether on a UFS or ZFS root.
  
  Unbreak this for the UFS case by only erroring out the init if we can't
  determine a ZFS dataset for rootfs and no BE root was specified. Consumers
  of libbe should take care to ensure that rootfs is non-empty if they're
  trying to use it, because this could certainly be the case.
  
  Some check is needed before zfs_path_to_zhandle because it will
  unconditionally emit to stderr if the path isn't a ZFS filesystem, which is
  unhelpful for our purposes.
  
  This should also unbreak the bectl(8) tests on a UFS root, as is the case in
  Jenkins' -test runs.
  
  r340636:
  bectl(8) tests: attempt to load the ZFS module
  
  Observed in a CI test image, bectl_create test will run and be marked as
  skipped because the module is not loaded. The first zpool invocation will
  automagically load the module, but bectl_create is still skipped. Subsequent
  tests all p

Re: svn commit: r339516 - head/sys/cddl/dev/dtrace/powerpc

2018-11-21 Thread Kyle Evans
On Sat, Oct 20, 2018 at 9:09 PM Justin Hibbits  wrote:
>
> Author: jhibbits
> Date: Sun Oct 21 02:08:57 2018
> New Revision: 339516
> URL: https://svnweb.freebsd.org/changeset/base/339516
>
> Log:
>   powerpc/dtrace: Use explicit bit numbers to mask out PSL_EE
>
>   There seems to be a race in CI, such that dtrace_asm.S might be assembled
>   before the genassym is completed.  This causes a build failure when PSL_EE
>   doesn't exist, and is read as 0.  Get around this by explicitly specifying
>   the bits in the mask instead.
>

Hi,

CI on the stable/12 branch still hits this, so I'm tempted to MFC this
if you don't object. OTOH, the correct solution should be a
`dependency "genassym.o"` in ^/sys/conf/files.powerpc for
dtrace_asm.S, no?

Thanks,

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


svn commit: r340752 - stable/12/tools/boot

2018-11-21 Thread Kyle Evans
Author: kevans
Date: Thu Nov 22 03:04:13 2018
New Revision: 340752
URL: https://svnweb.freebsd.org/changeset/base/340752

Log:
  MFC r339701: Update lualoader test script a little bit
  
  Use userboot.so from the test directory if possible, fall back to .OBJDIR.
  This avoids a problem that we've had since userboot coexistence was added,
  where userboot.so alone no longer exists in the .OBJDIR but is instead just
  a link installed later.
  Update lualo

Modified:
  stable/12/tools/boot/lua-test.sh
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tools/boot/lua-test.sh
==
--- stable/12/tools/boot/lua-test.shThu Nov 22 01:25:44 2018
(r340751)
+++ stable/12/tools/boot/lua-test.shThu Nov 22 03:04:13 2018
(r340752)
@@ -13,13 +13,16 @@ scriptdir=$(dirname $(realpath $0))
 cd $(make -V SRCTOP)/stand
 obj=$(make -V .OBJDIR)
 t=$obj/userboot/test/test
-u=$obj/userboot/userboot/userboot.so
 
 [ -n "$dir" ] || dir=/tmp/loadertest
 [ -d "$dir" ] || ${scriptdir}/lua-img.sh ${dir}
+# We'll try userboot.so from the test directory before plucking it straight out
+# of .OBJDIR.
+u=$dir/boot/userboot.so
+[ -f "$u" ] || u=$obj/userboot/userboot_lua/userboot_lua.so
 [ -f "$dir/boot/lua/loader.lua" ] || die "No boot/lua/loader.lua found"
 [ -f "$dir/boot/kernel/kernel" ] || die "No kernel to load"
 [ -x "$t" ] || die "no userboot test jig found ($t)"
-[ -x "$u" ] || die "no userboot.so ($u) found"
+[ -f "$u" ] || die "no userboot.so ($u) found"
 
 $t -h $dir -b $u
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r340753 - in releng/12.0: etc/mtree lib/libbe sbin/bectl sbin/bectl/tests

2018-11-21 Thread Kyle Evans
Author: kevans
Date: Thu Nov 22 04:39:06 2018
New Revision: 340753
URL: https://svnweb.freebsd.org/changeset/base/340753

Log:
  MFC r340507-r340508, r340592-r340594, r340635-r340636: bectl(8) fixes
  
  r340507:
  libbe(3): rewrite init to support chroot usage
  
  libbe(3) currently uses zfs_be_root and locates which of its children is
  currently mounted at "/". This is reasonable, but not correct in the case of
  a chroot, for two reasons:
  
  - chroot root may be of a different zpool than zfs_be_root
  - chroot root will not show up as mounted at "/"
  
  Fix both of these by rewriting libbe_init to work from the rootfs down.
  zfs_path_to_zhandle on / will resolve to the dataset mounted at the new
  root, rather than the real root. From there, we can derive the BE root/pool
  and grab the bootfs off of the new pool. This does no harm in the average
  case, and opens up bectl to operating on different pools for scenarios where
  one may be, for instance, updating a pool that generally gets re-rooted into
  from a separate UFS root or zfs bootpool.
  
  While here, I've also:
  - Eliminated the check for /boot and / to be on the same partition. This
leaves one open to a setup where /boot (and consequently, kernel/modules)
are not included in the boot environment. This may very well be an
intentional setup done by someone that knows what they're doing, we should
not kill BE usage because of it.
  
  - Eliminated the validation bits of BEs and snapshots that enforced
'mountpoint' to be "/" -- this broke when trying to operate on an imported
pool with an altroot, but we need not be this picky.
  
  Reported by:  philip
  Reviewed by:  philip, allanjude (previous version)
  Tested by:philip
  Differential Revision:https://reviews.freebsd.org/D18012
  
  r340508:
  libbe(3): Rewrite be_unmount to stop mucking with getmntinfo(2)
  
  Go through the ZFS layer instead; given a BE, we can derive the dataset,
  zfs_open it, then zfs_unmount. ZFS takes care of the dirty details and
  likely gets it more correct than we did for more interesting setups.
  
  r340592:
  bectl(3)/libbe(3): Allow BE root to be specified
  
  Add an undocumented -r option preceding the bectl subcommand to specify a BE
  root to operate out of. This will remain undocumented for now, as some
  caveats apply:
  
  - BEs cannot be activated in the pool that doesn't contain the rootfs
  - bectl create cannot work out of the box without the -e option right now,
since it defaults to the rootfs and cross-pool cloning doesn't work like
that (IIRC)
  
  Plumb the BE root through to libbe(3) so that some things -can- be done to
  it, e.g.
  
  bectl -r tank/ROOT create -e default upgrade
  bectl -r tank/ROOT mount upgrade /mnt
  
  this aides in some upgrade setups where rootfs is not necessarily ZFS, and
  also makes it easier/possible to regression-test bectl when combined with a
  file-backed zpool.
  
  Differential Revision:https://reviews.freebsd.org/D18029
  
  r340593:
  libbe(3): Properly account for altroot when creating new BEs
  
  Previously we would blindly copy the 'mountpoint' property, which includes
  the altroot. The altroot needs to be snipped off prior to setting it on the
  new BE, though, or you'll end up with a new BE and a mountpoint of /mnt with
  altroot=/mnt
  
  r340594:
  bectl(8): Add some regression tests
  
  These tests operate on a file-backed zpool that gets created in the kyua
  temp dir. root and ZFS support are both required for these tests. Current
  tests cover create, destroy, export/import, jail, list (kind of), mount,
  rename, and jail.
  
  List tests should later be extended to cover formatting and the different
  list flags, but for now only covers basic "are create/destroy actually
  reflected properly"
  
  r340635:
  libbe(3): Handle non-ZFS rootfs better
  
  If rootfs isn't ZFS, current version will emit an error claiming so and fail
  to initialize libbe. As a consumer, bectl -r (undocumented) can be specified
  to operate on a BE independently of whether on a UFS or ZFS root.
  
  Unbreak this for the UFS case by only erroring out the init if we can't
  determine a ZFS dataset for rootfs and no BE root was specified. Consumers
  of libbe should take care to ensure that rootfs is non-empty if they're
  trying to use it, because this could certainly be the case.
  
  Some check is needed before zfs_path_to_zhandle because it will
  unconditionally emit to stderr if the path isn't a ZFS filesystem, which is
  unhelpful for our purposes.
  
  This should also unbreak the bectl(8) tests on a UFS root, as is the case in
  Jenkins' -test runs.
  
  r340636:
  bectl(8) tests: attempt to load the ZFS module
  
  Observed in a CI test image, bectl_create test will run and be marked as
  skipped because the module is not loaded. The first zpool invocation will
  automagically load the module, but bectl_create is still skipped. Subsequent
  tests all p

Re: svn commit: r339516 - head/sys/cddl/dev/dtrace/powerpc

2018-11-21 Thread Kyle Evans
On Wed, Nov 21, 2018 at 9:42 PM Kyle Evans  wrote:
>
> On Sat, Oct 20, 2018 at 9:09 PM Justin Hibbits  wrote:
> >
> > Author: jhibbits
> > Date: Sun Oct 21 02:08:57 2018
> > New Revision: 339516
> > URL: https://svnweb.freebsd.org/changeset/base/339516
> >
> > Log:
> >   powerpc/dtrace: Use explicit bit numbers to mask out PSL_EE
> >
> >   There seems to be a race in CI, such that dtrace_asm.S might be assembled
> >   before the genassym is completed.  This causes a build failure when PSL_EE
> >   doesn't exist, and is read as 0.  Get around this by explicitly specifying
> >   the bits in the mask instead.
> >
>
> Hi,
>
> CI on the stable/12 branch still hits this, so I'm tempted to MFC this
> if you don't object. OTOH, the correct solution should be a
> `dependency "genassym.o"` in ^/sys/conf/files.powerpc for
> dtrace_asm.S, no?
>

Sorry, that should have read "genassym.inc" -- my naive understanding
of 'dependency' is that config(8) will turn it directly into a
makefile dependency that will alleviate this.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r339516 - head/sys/cddl/dev/dtrace/powerpc

2018-11-22 Thread Kyle Evans
On Thu, Nov 22, 2018 at 1:16 AM Mark Johnston  wrote:
>
> On Wed, Nov 21, 2018 at 10:02:15PM -0600, Kyle Evans wrote:
> > On Wed, Nov 21, 2018 at 9:42 PM Kyle Evans  wrote:
> > >
> > > On Sat, Oct 20, 2018 at 9:09 PM Justin Hibbits  
> > > wrote:
> > > >
> > > > Author: jhibbits
> > > > Date: Sun Oct 21 02:08:57 2018
> > > > New Revision: 339516
> > > > URL: https://svnweb.freebsd.org/changeset/base/339516
> > > >
> > > > Log:
> > > >   powerpc/dtrace: Use explicit bit numbers to mask out PSL_EE
> > > >
> > > >   There seems to be a race in CI, such that dtrace_asm.S might be 
> > > > assembled
> > > >   before the genassym is completed.  This causes a build failure when 
> > > > PSL_EE
> > > >   doesn't exist, and is read as 0.  Get around this by explicitly 
> > > > specifying
> > > >   the bits in the mask instead.
> > > >
> > >
> > > Hi,
> > >
> > > CI on the stable/12 branch still hits this, so I'm tempted to MFC this
> > > if you don't object. OTOH, the correct solution should be a
> > > `dependency "genassym.o"` in ^/sys/conf/files.powerpc for
> > > dtrace_asm.S, no?
>
> I believe that dtrace_asm.S will be built as part of dtrace.ko, not the
> kernel.  dtrace/Makefile already specifies a dependency on assym.inc.
> Maybe this is the same issue as PR 29?
>

Ah, indeed, this was the module rather than kernel build of
dtrace_asm.S -- sorry about that. That one is indeed not as simple of
a fix. =(
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r341644 - stable/11/sys/kern

2018-12-06 Thread Kyle Evans
Author: kevans
Date: Thu Dec  6 19:18:51 2018
New Revision: 341644
URL: https://svnweb.freebsd.org/changeset/base/341644

Log:
  Fix kenv handling in stable/11 following r337333
  
  The aforementioned commit merged revised static_env/static_hint handling to
  allow static_env and loader env to coexist with the variable
  loader_env.disabled=0. init_static_kenv had been rewritten slighly in an
  attempt to maintain historical behavior: the static environment and loader
  environment are mutually exclusive, unless the latter disables the former.
  
  The rewritten version botched this by only setting up the loader environment
  if the static environment was empty or if the loader environment was
  specifically enabled. It was never given a chance to disable the static
  environment, so the default behavior was broken unless the loader
  environment was specifically enabled by the static environment.
  
  Rewrite this again to do the right thing:
  - Setup the static environment and check loader_env.disabled; if it's
explicitly enabled, we're done.
  - Check static_{env,hints}.disabled and "empty out" the respective
environments as needed
  - Finally, check: if the static environment is not empty and we've not
explicitly re-enabled the static environment with loader_env.disabled=0,
we tear the loader environment (which was setup to 'keep things simple')
down again.
  
  Future commits to head (and subsequently MFC'd) will likely zero these
  environments out if they're disabled since this normally happens when
  they're merged into the dynamic environment.
  
  This is a direct commit to stable/11 because this particular bug does not
  apply to head.
  
  Fixes:r337333
  Reported by:  bde

Modified:
  stable/11/sys/kern/kern_environment.c

Modified: stable/11/sys/kern/kern_environment.c
==
--- stable/11/sys/kern/kern_environment.c   Thu Dec  6 18:59:33 2018
(r341643)
+++ stable/11/sys/kern/kern_environment.c   Thu Dec  6 19:18:51 2018
(r341644)
@@ -245,7 +245,7 @@ done:
 void
 init_static_kenv(char *buf, size_t len)
 {
-   char *eval;
+   char *eval, *loader_eval;
 
KASSERT(!dynamic_kenv, ("kenv: dynamic_kenv already initialized"));
/*
@@ -264,21 +264,43 @@ init_static_kenv(char *buf, size_t len)
 *
 * As a warning, the static environment may not be disabled in any way
 * if the static environment has disabled the loader environment.
+*
+* We're setting up the static environment early here because it will
+* either be used or empty.
 */
kern_envp = static_env;
-   eval = kern_getenv("loader_env.disabled");
-   if (*kern_envp == '\0' || (eval != NULL && strcmp(eval, "0") == 0)) {
-   md_envp = buf;
-   md_env_len = len;
-   md_env_pos = 0;
+   loader_eval = kern_getenv("loader_env.disabled");
+   if (loader_eval != NULL && strcmp(loader_eval, "1") == 0)
+   /* Bail out early, the loader environment is disabled. */
+   return;
 
-   eval = kern_getenv("static_env.disabled");
-   if (eval != NULL && strcmp(eval, "1") == 0)
-   *kern_envp = '\0';
-   }
+   /*
+* Next, the loader env is checked for the status of the static env.  We
+* are allowing static_env and static_hints to disable themselves here 
for
+* the sake of simplicity.
+*/
+   md_envp = buf;
+   md_env_len = len;
+   md_env_pos = 0;
+
+   eval = kern_getenv("static_env.disabled");
+   if (eval != NULL && strcmp(eval, "1") == 0)
+   *static_env = '\0';
+
eval = kern_getenv("static_hints.disabled");
if (eval != NULL && strcmp(eval, "1") == 0)
*static_hints = '\0';
+
+   /*
+* Now we see if we need to tear the loader environment back down due
+* to the presence of a non-empty static environment and lack of request
+* to keep it enabled.
+*/
+   if (*static_env != '\0' &&
+   (loader_eval == NULL || strcmp(loader_eval, "0") != 0)) {
+   md_envp = NULL;
+   md_env_len = 0;
+   }
 }
 
 static void
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r342362 - head/usr.sbin/config

2018-12-21 Thread Kyle Evans
Author: kevans
Date: Sat Dec 22 06:02:34 2018
New Revision: 342362
URL: https://svnweb.freebsd.org/changeset/base/342362

Log:
  config(8): Allow duplicate options to be specified
  
  config(8)'s option handling has been written to allow duplicate options; if
  the value changes, then the latest value is used and an informative message
  is printed to stderr like so:
  
  /usr/src/sys/amd64/conf/TEST: option "VERBOSE_SYSINIT" redefined from 0 to 1
  
  Currently, this is only a possibility for cpu types, MAXUSERS, and
  MACHINE_ARCH. Anything else duplicated in a config file will use the first
  value set and error about duplicated options on subsequent appearances,
  which is arguably unfriendly since one could specify:
  
  include GENERIC
  nooptions VERBOSE_SYSINIT
  options VERBOSE_SYSINIT
  
  to redefine the value later anyways.
  
  Reported by:  mmacy
  MFC after:1 week

Modified:
  head/usr.sbin/config/config.y

Modified: head/usr.sbin/config/config.y
==
--- head/usr.sbin/config/config.y   Fri Dec 21 23:33:28 2018
(r342361)
+++ head/usr.sbin/config/config.y   Sat Dec 22 06:02:34 2018
(r342362)
@@ -99,7 +99,7 @@ static void newdev(char *name);
 static void newfile(char *name);
 static void newenvvar(char *name, bool is_file);
 static void rmdev_schedule(struct device_head *dh, char *name);
-static void newopt(struct opt_head *list, char *name, char *value, int append);
+static void newopt(struct opt_head *list, char *name, char *value, int append, 
int dupe);
 static void rmopt_schedule(struct opt_head *list, char *name);
 
 static char *
@@ -212,7 +212,7 @@ System_spec:
  ;
 
 System_id:
-   Save_id { newopt(&mkopt, ns("KERNEL"), $1, 0); };
+   Save_id { newopt(&mkopt, ns("KERNEL"), $1, 0, 0); };
 
 System_parameter_list:
  System_parameter_list ID
@@ -232,13 +232,13 @@ NoOpt_list:
;
 Option:
Save_id {
-   newopt(&opt, $1, NULL, 0);
+   newopt(&opt, $1, NULL, 0, 1);
if (strchr($1, '=') != NULL)
errx(1, "%s:%d: The `=' in options should not be "
"quoted", yyfile, yyline);
  } |
Save_id EQUALS Opt_value {
-   newopt(&opt, $1, $3, 0);
+   newopt(&opt, $1, $3, 0, 1);
  } ;
 
 NoOption:
@@ -266,10 +266,10 @@ Mkopt_list:
;
 
 Mkoption:
-   Save_id { newopt(&mkopt, $1, ns(""), 0); } |
-   Save_id EQUALS { newopt(&mkopt, $1, ns(""), 0); } |
-   Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3, 0); } |
-   Save_id PLUSEQUALS Opt_value { newopt(&mkopt, $1, $3, 1); } ;
+   Save_id { newopt(&mkopt, $1, ns(""), 0, 0); } |
+   Save_id EQUALS { newopt(&mkopt, $1, ns(""), 0, 0); } |
+   Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3, 0, 0); } |
+   Save_id PLUSEQUALS Opt_value { newopt(&mkopt, $1, $3, 1, 0); } ;
 
 Dev:
ID { $$ = $1; }
@@ -295,7 +295,7 @@ NoDev_list:
 
 Device:
Dev {
-   newopt(&opt, devopt($1), ns("1"), 0);
+   newopt(&opt, devopt($1), ns("1"), 0, 0);
/* and the device part */
newdev($1);
}
@@ -432,7 +432,7 @@ findopt(struct opt_head *list, char *name)
  * Add an option to the list of options.
  */
 static void
-newopt(struct opt_head *list, char *name, char *value, int append)
+newopt(struct opt_head *list, char *name, char *value, int append, int dupe)
 {
struct opt *op, *op2;
 
@@ -445,7 +445,7 @@ newopt(struct opt_head *list, char *name, char *value,
}
 
op2 = findopt(list, name);
-   if (op2 != NULL && !append) {
+   if (op2 != NULL && !append && !dupe) {
fprintf(stderr,
"WARNING: duplicate option `%s' encountered.\n", name);
return;
@@ -458,9 +458,15 @@ newopt(struct opt_head *list, char *name, char *value,
op->op_ownfile = 0;
op->op_value = value;
if (op2 != NULL) {
-   while (SLIST_NEXT(op2, op_append) != NULL)
-   op2 = SLIST_NEXT(op2, op_append);
-   SLIST_NEXT(op2, op_append) = op;
+   if (append) {
+   while (SLIST_NEXT(op2, op_append) != NULL)
+   op2 = SLIST_NEXT(op2, op_append);
+   SLIST_NEXT(op2, op_append) = op;
+   } else {
+   while (SLIST_NEXT(op2, op_next) != NULL)
+   op2 = SLIST_NEXT(op2, op_next);
+   SLIST_NEXT(op2, op_next) = op;
+   }
} else
SLIST_INSERT_HEAD(list, op, op_next);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r342363 - head/usr.sbin/config

2018-12-21 Thread Kyle Evans
Author: kevans
Date: Sat Dec 22 06:08:06 2018
New Revision: 342363
URL: https://svnweb.freebsd.org/changeset/base/342363

Log:
  config(8): Remove all instances of an option when opting out
  
  Quick follow-up to r342362: options can appear multiple times now, so
  clean up all of them as needed. For non-OPTIONS options, this has no effect
  since they're already de-duplicated.
  
  MFC after:1 week
  X-MFC-With:   r342362

Modified:
  head/usr.sbin/config/config.y

Modified: head/usr.sbin/config/config.y
==
--- head/usr.sbin/config/config.y   Sat Dec 22 06:02:34 2018
(r342362)
+++ head/usr.sbin/config/config.y   Sat Dec 22 06:08:06 2018
(r342363)
@@ -479,8 +479,7 @@ rmopt_schedule(struct opt_head *list, char *name)
 {
struct opt *op;
 
-   op = findopt(list, name);
-   if (op != NULL) {
+   while ((op = findopt(list, name)) != NULL) {
SLIST_REMOVE(list, op, opt, op_next);
free(op->op_name);
free(op);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r342466 - in head/sbin/bectl: . tests

2018-12-25 Thread Kyle Evans
Author: kevans
Date: Tue Dec 25 15:18:41 2018
New Revision: 342466
URL: https://svnweb.freebsd.org/changeset/base/342466

Log:
  bectl: use jail id as the default jail name for a boot environment
  
  By default, bectl is setting the jail 'name' parameter to the boot
  environment name, which causes an error when the boot environment name is
  not a valid jail name. With the attached fix, when no name is supplied, the
  default jail name will be the jail id - this is is the same behavior as the
  jail command.
  
  Additionally, this commit addresses two other bugs that prevented unjailing
  in scenarios where the jail name does not match the boot environment name:
  
  1. In 'bectl_locate_jail', 'mountpoint' is used to resolve the boot
environment path, but really 'mounted' should be used. 'mountpoint' is the
path where the zfs dataset will be mounted. 'mounted' is the path where
the dataset is actually mounted.
  
  2. in 'bectl_search_jail_paths', 'jail_getv' would fail after the first
call. Which is fine, if the boot environment you're unjailing is the next
one up. According to 'man jail_getv', it's expecting name and value
strings. 'jail_getv' is being passed an integer for the lastjid, so amend
that to use a string instead.
  
  Test cases have been amended to reflect the bugs found.
  
  PR:   233637
  Submitted by: Rob 
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D18607

Modified:
  head/sbin/bectl/bectl.8
  head/sbin/bectl/bectl_jail.c
  head/sbin/bectl/tests/bectl_test.sh

Modified: head/sbin/bectl/bectl.8
==
--- head/sbin/bectl/bectl.8 Tue Dec 25 14:06:52 2018(r342465)
+++ head/sbin/bectl/bectl.8 Tue Dec 25 15:18:41 2018(r342466)
@@ -18,7 +18,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 21, 2018
+.Dd December 25, 2018
 .Dt BECTL 8
 .Os
 .Sh NAME
@@ -52,7 +52,6 @@
 .Cm jail
 .Brq Fl b | Fl U
 .Oo Bro Fl o Ar key Ns = Ns Ar value | Fl u Ar key Brc Oc Ns ...
-.Brq Ar jailID | jailName
 .Ar bootenv
 .Op Ar utility Op Ar argument ...
 .Nm
@@ -153,7 +152,6 @@ from
 .Cm jail
 .Brq Fl b | Fl U
 .Oo Bro Fl o Ar key Ns = Ns Ar value | Fl u Ar key Brc Oc Ns ...
-.Brq Ar jailID | jailName
 .Ao Ar bootenv Ac
 .Op Ar utility Op Ar argument ...
 .Xc
@@ -193,10 +191,7 @@ The
 .Va host.hostname ,
 and
 .Va path
-may not actually be unset.
-Attempts to unset any of these will revert them to the default values specified
-below, if they have been overwritten by
-.Fl o .
+must be set, the default values are specified below.
 .Pp
 All
 .Ar key Ns = Ns Ar value
@@ -207,7 +202,7 @@ The following default parameters are provided:
 .It Va allow.mount Ta Cm true
 .It Va allow.mount.devfs Ta Cm true
 .It Va enforce_statfs Ta Cm 1
-.It Va name Ta Va bootenv
+.It Va name Ta jail id
 .It Va host.hostname Ta Va bootenv
 .It Va path Ta Set to a path in /tmp generated by
 .Xr libbe 3 .

Modified: head/sbin/bectl/bectl_jail.c
==
--- head/sbin/bectl/bectl_jail.cTue Dec 25 14:06:52 2018
(r342465)
+++ head/sbin/bectl/bectl_jail.cTue Dec 25 15:18:41 2018
(r342466)
@@ -181,10 +181,10 @@ bectl_cmd_jail(int argc, char *argv[])
 {
char *bootenv, *mountpoint;
int jid, opt, ret;
-   bool default_hostname, default_name, interactive, unjail;
+   bool default_hostname, interactive, unjail;
pid_t pid;
 
-   default_hostname = default_name = interactive = unjail = true;
+   default_hostname = interactive = unjail = true;
jpcnt = INIT_PARAMCOUNT;
jp = malloc(jpcnt * sizeof(*jp));
if (jp == NULL)
@@ -206,8 +206,6 @@ bectl_cmd_jail(int argc, char *argv[])
 * optarg has been modified to null terminate
 * at the assignment operator.
 */
-   if (strcmp(optarg, "name") == 0)
-   default_name = false;
if (strcmp(optarg, "host.hostname") == 0)
default_hostname = false;
}
@@ -217,8 +215,6 @@ bectl_cmd_jail(int argc, char *argv[])
break;
case 'u':
if ((ret = jailparam_delarg(optarg)) == 0) {
-   if (strcmp(optarg, "name") == 0)
-   default_name = true;
if (strcmp(optarg, "host.hostname") == 0)
default_hostname = true;
} else if (ret != ENOENT) {
@@ -259,8 +255,6 @@ bectl_cmd_jail(int argc, char *argv[])
return (1);
}
 
-   if (default_name)
-   jailparam_add("name", bootenv);
if (default_hostname)
 

Re: svn commit: r334191 - in stable/11/stand: common ofw/libofw sparc64/loader

2018-05-24 Thread Kyle Evans
On Thu, May 24, 2018 at 6:11 PM, Marius Strobl  wrote:
> Author: marius
> Date: Thu May 24 23:11:25 2018
> New Revision: 334191
> URL: https://svnweb.freebsd.org/changeset/base/334191
>
> Log:
>   MFC: r333955
>
>   - Unbreak booting sparc64 kernels after the metadata unification in
> r329190 (MFCed to stable/11 in r332150); sparc64 kernels are always
> 64-bit but with that revision in place, the loader was treating them
> as 32-bit ones.
>   - In order to reduce the likelihood of this kind of breakage in the
> future, #ifdef out md_load() on sparc64 and make md_load_dual() -
> which is currently local to metadata.c anyway - static.
>   - Make md_getboothowto() - also local to metadata.c - static.
>   - Get rid of the unused DTB pointer on sparc64.
>

Huh, not sure how I missed that one... sorry about that. =/
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r334617 - in head: . etc

2018-06-04 Thread Kyle Evans
On Mon, Jun 4, 2018 at 10:17 AM, Brad Davis  wrote:
> Author: brd
> Date: Mon Jun  4 15:17:24 2018
> New Revision: 334617
> URL: https://svnweb.freebsd.org/changeset/base/334617
>
> Log:
>   Move /sys symlink creating out of etc/Makefile.
>
>   This is prep for etc/Makefile going away.
>
>   Approved by:  bapt (mentor)
>

Woah, woah, woah, woah. =) May I ask what your plan for etc/Makefile
is? Some of the NO_ROOT stuff there seems to be terribly broken and
needs to be fixed; this was on my 'some day to fix' list.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r334226 - head/lib/libpmcstat/pmu-events

2018-06-04 Thread Kyle Evans
On Fri, May 25, 2018 at 4:46 PM, Bryan Drewery  wrote:
> Author: bdrewery
> Date: Fri May 25 21:46:07 2018
> New Revision: 334226
> URL: https://svnweb.freebsd.org/changeset/base/334226
>
> Log:
>   Cleanup style
>
> Modified:
>   head/lib/libpmcstat/pmu-events/Makefile
>
> Modified: head/lib/libpmcstat/pmu-events/Makefile
> ==
> --- head/lib/libpmcstat/pmu-events/Makefile Fri May 25 20:42:28 2018  
>   (r334225)
> +++ head/lib/libpmcstat/pmu-events/Makefile Fri May 25 21:46:07 2018  
>   (r334226)
> @@ -1,9 +1,10 @@
>  # $FreeBSD$
>
> -PROG=jevents
> -SRCS=jevents.c jsmn.c json.c
> +PROG=  jevents
> +SRCS=  jevents.c jsmn.c json.c
>  CFLAGS+= -Wno-cast-qual
> -.PATH: ${.CURDIR}
> -build-tools: jevents
>  MAN=
> +
> +build-tools: jevents
> +
>  .include 
>

Hi Bryan,

Something about this appears to be subtly wrong, but I can't quite pin
down what. I'm getting a failure in the lib32 build of libpmc:

sh: ./pmu-events/jevents: not found

My observations are that ${OBJDIR}/lib/libpmc/pmu-events/jevents
exists, as does ${SRCTOP}/lib/libpmc/pmu-events/jevents.
${OBJDIR}/obj-lib32/lib/libpmc, OTOH, only contains _INCSINS.meta and
libpmc_events.c.meta. I'm guessing this is the problem- that
obj-lib32/... doesn't have the built jevents, but it's not obvious to
me why this is the case.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r334226 - head/lib/libpmcstat/pmu-events

2018-06-04 Thread Kyle Evans
On Mon, Jun 4, 2018 at 10:11 PM, Kyle Evans  wrote:
> On Fri, May 25, 2018 at 4:46 PM, Bryan Drewery  wrote:
>> Author: bdrewery
>> Date: Fri May 25 21:46:07 2018
>> New Revision: 334226
>> URL: https://svnweb.freebsd.org/changeset/base/334226
>>
>> Log:
>>   Cleanup style
>>
>> Modified:
>>   head/lib/libpmcstat/pmu-events/Makefile
>>
>> Modified: head/lib/libpmcstat/pmu-events/Makefile
>> ==
>> --- head/lib/libpmcstat/pmu-events/Makefile Fri May 25 20:42:28 2018 
>>(r334225)
>> +++ head/lib/libpmcstat/pmu-events/Makefile Fri May 25 21:46:07 2018 
>>(r334226)
>> @@ -1,9 +1,10 @@
>>  # $FreeBSD$
>>
>> -PROG=jevents
>> -SRCS=jevents.c jsmn.c json.c
>> +PROG=  jevents
>> +SRCS=  jevents.c jsmn.c json.c
>>  CFLAGS+= -Wno-cast-qual
>> -.PATH: ${.CURDIR}
>> -build-tools: jevents
>>  MAN=
>> +
>> +build-tools: jevents
>> +
>>  .include 
>>
>
> Hi Bryan,
>
> Something about this appears to be subtly wrong, but I can't quite pin
> down what. I'm getting a failure in the lib32 build of libpmc:
>
> sh: ./pmu-events/jevents: not found
>
> My observations are that ${OBJDIR}/lib/libpmc/pmu-events/jevents
> exists, as does ${SRCTOP}/lib/libpmc/pmu-events/jevents.
> ${OBJDIR}/obj-lib32/lib/libpmc, OTOH, only contains _INCSINS.meta and
> libpmc_events.c.meta. I'm guessing this is the problem- that
> obj-lib32/... doesn't have the built jevents, but it's not obvious to
> me why this is the case.

Some additional context:

SRCCONF is defined to a file that looks like this:

WITH_BSD_GREP="YES"
WITHOUT_BSD_GREP_FASTMATCH="YES"
WITH_LOADER_LUA="YES"
WITHOUT_FORTH="YES"

_SRC_ENV_CONF and __MAKE_CONF are set to /dev/null; all three set in
arguments to make(1). OBJDIR has been completely wiped before-hand.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334723 - head/stand/lua

2018-06-06 Thread Kyle Evans
Author: kevans
Date: Wed Jun  6 18:28:17 2018
New Revision: 334723
URL: https://svnweb.freebsd.org/changeset/base/334723

Log:
  lualoader: Add a loaded hook for others to execute upon config load
  
  This will not be executed on reload, though later work could allow for that.
  It's intended/expected that later work won't generally need to happen on
  every config load, just once (for, e.g., menu initialization) or just when
  config is reloaded but not upon the initial load.

Modified:
  head/stand/lua/config.lua

Modified: head/stand/lua/config.lua
==
--- head/stand/lua/config.lua   Wed Jun  6 16:47:33 2018(r334722)
+++ head/stand/lua/config.lua   Wed Jun  6 18:28:17 2018(r334723)
@@ -458,7 +458,7 @@ function config.selectKernel(kernel)
config.kernel_selected = kernel
 end
 
-function config.load(file)
+function config.load(file, reloading)
if not file then
file = "/boot/defaults/loader.conf"
end
@@ -485,13 +485,16 @@ function config.load(file)
config.module_path = loader.getenv("module_path")
local verbose = loader.getenv("verbose_loading") or "no"
config.verbose = verbose:lower() == "yes"
+   if not reloading then
+   hook.runAll("config.loaded")
+   end
 end
 
 -- Reload configuration
 function config.reload(file)
modules = {}
restoreEnv()
-   config.load(file)
+   config.load(file, true)
hook.runAll("config.reloaded")
 end
 
@@ -512,5 +515,6 @@ function config.loadelf()
end
 end
 
+hook.registerType("config.loaded")
 hook.registerType("config.reloaded")
 return config
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334803 - head/contrib/netbsd-tests/usr.bin/grep

2018-06-07 Thread Kyle Evans
Author: kevans
Date: Thu Jun  7 18:06:01 2018
New Revision: 334803
URL: https://svnweb.freebsd.org/changeset/base/334803

Log:
  netbsd-tests: grep(1): Add test for -c flag
  
  Someone might be inclined to accidentally break this. someone might have
  written said test because they broke it locally.

Modified:
  head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh

Modified: head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
==
--- head/contrib/netbsd-tests/usr.bin/grep/t_grep.shThu Jun  7 18:01:31 
2018(r334802)
+++ head/contrib/netbsd-tests/usr.bin/grep/t_grep.shThu Jun  7 18:06:01 
2018(r334803)
@@ -716,6 +716,22 @@ fgrep_oflag_body()
atf_check -s exit:1 grep -Fo "ghix" test1
atf_check -s exit:1 grep -Fo "abcdefghiklmnopqrstuvwxyz" test1
 }
+
+atf_test_case cflag
+cflag_head()
+{
+   atf_set "descr" "Check proper handling of -c"
+}
+cflag_body()
+{
+   printf "a\nb\nc\n" > test1
+
+   atf_check -o inline:"1\n" grep -Ec "a" test1
+   atf_check -o inline:"2\n" grep -Ec "a|b" test1
+   atf_check -o inline:"3\n" grep -Ec "a|b|c" test1
+
+   atf_check -o inline:"test1:2\n" grep -EHc "a|b" test1
+}
 # End FreeBSD
 
 atf_init_test_cases()
@@ -759,5 +775,6 @@ atf_init_test_cases()
atf_add_test_case fgrep_multipattern
atf_add_test_case fgrep_icase
atf_add_test_case fgrep_oflag
+   atf_add_test_case cflag
 # End FreeBSD
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334806 - head/usr.bin/grep

2018-06-07 Thread Kyle Evans
Author: kevans
Date: Thu Jun  7 18:27:58 2018
New Revision: 334806
URL: https://svnweb.freebsd.org/changeset/base/334806

Log:
  bsdgrep(1): Do some less dirty things with return types
  
  Neither procfile nor grep_tree return anything meaningful to their callers.
  None of the callers actually care about how many lines were matched in all
  of the files they processed; it's all about "did anything match?"
  
  This is generally just a light refactoring to remind me of what actually
  matters as I'm rewriting these bits to care less about 'stuff'.

Modified:
  head/usr.bin/grep/grep.c
  head/usr.bin/grep/grep.h
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/grep.c
==
--- head/usr.bin/grep/grep.cThu Jun  7 18:24:25 2018(r334805)
+++ head/usr.bin/grep/grep.cThu Jun  7 18:27:58 2018(r334806)
@@ -339,6 +339,7 @@ main(int argc, char *argv[])
long long l;
unsigned int aargc, eargc, i;
int c, lastc, needpattern, newarg, prevoptind;
+   bool matched;
 
setlocale(LC_ALL, "");
 
@@ -725,15 +726,16 @@ main(int argc, char *argv[])
exit(!procfile("-"));
 
if (dirbehave == DIR_RECURSE)
-   c = grep_tree(aargv);
+   matched = grep_tree(aargv);
else
-   for (c = 0; aargc--; ++aargv) {
+   for (matched = false; aargc--; ++aargv) {
if ((finclude || fexclude) && !file_matching(*aargv))
continue;
-   c+= procfile(*aargv);
+   if (procfile(*aargv))
+   matched = true;
}
 
/* Find out the correct return value according to the
   results and the command line option. */
-   exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1));
+   exit(matched ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1));
 }

Modified: head/usr.bin/grep/grep.h
==
--- head/usr.bin/grep/grep.hThu Jun  7 18:24:25 2018(r334805)
+++ head/usr.bin/grep/grep.hThu Jun  7 18:27:58 2018(r334806)
@@ -125,8 +125,8 @@ extern char  re_error[RE_ERROR_BUF + 1];/* Seems big 
 
 /* util.c */
 boolfile_matching(const char *fname);
-int procfile(const char *fn);
-int grep_tree(char **argv);
+boolprocfile(const char *fn);
+boolgrep_tree(char **argv);
 void   *grep_malloc(size_t size);
 void   *grep_calloc(size_t nmemb, size_t size);
 void   *grep_realloc(void *ptr, size_t size);

Modified: head/usr.bin/grep/util.c
==
--- head/usr.bin/grep/util.cThu Jun  7 18:24:25 2018(r334805)
+++ head/usr.bin/grep/util.cThu Jun  7 18:27:58 2018(r334806)
@@ -139,16 +139,17 @@ dir_matching(const char *dname)
  * Processes a directory when a recursive search is performed with
  * the -R option.  Each appropriate file is passed to procfile().
  */
-int
+bool
 grep_tree(char **argv)
 {
FTS *fts;
FTSENT *p;
int c, fts_flags;
-   bool ok;
+   bool matched, ok;
const char *wd[] = { ".", NULL };
 
c = fts_flags = 0;
+   matched = false;
 
switch(linkbehave) {
case LINK_EXPLICIT:
@@ -195,14 +196,14 @@ grep_tree(char **argv)
if (fexclude || finclude)
ok &= file_matching(p->fts_path);
 
-   if (ok)
-   c += procfile(p->fts_path);
+   if (ok && procfile(p->fts_path))
+   matched = true;
break;
}
}
 
fts_close(fts);
-   return (c);
+   return (matched);
 }
 
 static void
@@ -288,7 +289,7 @@ procmatches(struct mprintc *mc, struct parsec *pc, boo
  * Opens a file and processes it.  Each file is processed line-by-line
  * passing the lines to procline().
  */
-int
+bool
 procfile(const char *fn)
 {
struct parsec pc;
@@ -296,7 +297,7 @@ procfile(const char *fn)
struct file *f;
struct stat sb;
mode_t s;
-   int c, t;
+   int lines, t;
 
if (strcmp(fn, "-") == 0) {
fn = label != NULL ? label : errstr[1];
@@ -306,10 +307,10 @@ procfile(const char *fn)
/* Check if we need to process the file */
s = sb.st_mode & S_IFMT;
if (dirbehave == DIR_SKIP && s == S_IFDIR)
-   return (0);
+   return (false);
if (devbehave == DEV_SKIP && (s == S_IFIFO ||
s == S_IFCHR || s == S_IFBLK || s == S_IFSOCK))
-   return (0);
+   return (false);

svn commit: r334807 - head/usr.bin/grep

2018-06-07 Thread Kyle Evans
Author: kevans
Date: Thu Jun  7 18:36:12 2018
New Revision: 334807
URL: https://svnweb.freebsd.org/changeset/base/334807

Log:
  bsdgrep(1): whoops, garbage collect the now write-only variable

Modified:
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/util.c
==
--- head/usr.bin/grep/util.cThu Jun  7 18:27:58 2018(r334806)
+++ head/usr.bin/grep/util.cThu Jun  7 18:36:12 2018(r334807)
@@ -144,11 +144,11 @@ grep_tree(char **argv)
 {
FTS *fts;
FTSENT *p;
-   int c, fts_flags;
+   int fts_flags;
bool matched, ok;
const char *wd[] = { ".", NULL };
 
-   c = fts_flags = 0;
+   fts_flags = 0;
matched = false;
 
switch(linkbehave) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334808 - head/usr.bin/grep

2018-06-07 Thread Kyle Evans
Author: kevans
Date: Thu Jun  7 18:38:48 2018
New Revision: 334808
URL: https://svnweb.freebsd.org/changeset/base/334808

Log:
  bsdgrep(1): Don't initialize fts_flags twice
  
  Admittedly, this is a clang-scan complaint... but it wasn't wrong. fts_flags
  is initialized by all cases in the switch(), which should be fairly obvious.
  Annotate this anyways.

Modified:
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/util.c
==
--- head/usr.bin/grep/util.cThu Jun  7 18:36:12 2018(r334807)
+++ head/usr.bin/grep/util.cThu Jun  7 18:38:48 2018(r334808)
@@ -148,9 +148,9 @@ grep_tree(char **argv)
bool matched, ok;
const char *wd[] = { ".", NULL };
 
-   fts_flags = 0;
matched = false;
 
+   /* This switch effectively initializes 'fts_flags' */
switch(linkbehave) {
case LINK_EXPLICIT:
fts_flags = FTS_COMFOLLOW;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334809 - head/contrib/netbsd-tests/usr.bin/grep

2018-06-07 Thread Kyle Evans
Author: kevans
Date: Thu Jun  7 18:53:39 2018
New Revision: 334809
URL: https://svnweb.freebsd.org/changeset/base/334809

Log:
  netbsd-tests: bsdgrep(1): Add a test for -m, too

Modified:
  head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh

Modified: head/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
==
--- head/contrib/netbsd-tests/usr.bin/grep/t_grep.shThu Jun  7 18:38:48 
2018(r334808)
+++ head/contrib/netbsd-tests/usr.bin/grep/t_grep.shThu Jun  7 18:53:39 
2018(r334809)
@@ -732,6 +732,22 @@ cflag_body()
 
atf_check -o inline:"test1:2\n" grep -EHc "a|b" test1
 }
+
+atf_test_case mflag
+mflag_head()
+{
+   atf_set "descr" "Check proper handling of -m"
+}
+mflag_body()
+{
+   printf "a\nb\nc\nd\ne\nf\n" > test1
+
+   atf_check -o inline:"1\n" grep -m 1 -Ec "a" test1
+   atf_check -o inline:"2\n" grep -m 2 -Ec "a|b" test1
+   atf_check -o inline:"3\n" grep -m 3 -Ec "a|b|c|f" test1
+
+   atf_check -o inline:"test1:2\n" grep -m 2 -EHc "a|b|e|f" test1
+}
 # End FreeBSD
 
 atf_init_test_cases()
@@ -776,5 +792,6 @@ atf_init_test_cases()
atf_add_test_case fgrep_icase
atf_add_test_case fgrep_oflag
atf_add_test_case cflag
+   atf_add_test_case mflag
 # End FreeBSD
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334821 - head/usr.bin/grep

2018-06-07 Thread Kyle Evans
Author: kevans
Date: Fri Jun  8 01:25:07 2018
New Revision: 334821
URL: https://svnweb.freebsd.org/changeset/base/334821

Log:
  bsdgrep(1): Slooowly peel away the chunky onion
  
  (or peel off the band-aid, whatever floats your boat)
  
  This addresses two separate issues:
  
  1.) Nothing within bsdgrep actually knew whether it cared about line numbers
or not.
  
  2.) The file layer knew nothing about the context in which it was being
called.
  
  #1 is only important when we're *not* processing line-by-line. #2 is
  debatably a good idea; the parsing context is only handy because that's
  where we store current offset information and, as of this commit, whether or
  not it needs to be line-aware.

Modified:
  head/usr.bin/grep/file.c
  head/usr.bin/grep/grep.h
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/file.c
==
--- head/usr.bin/grep/file.cFri Jun  8 00:47:24 2018(r334820)
+++ head/usr.bin/grep/file.cFri Jun  8 01:25:07 2018(r334821)
@@ -95,7 +95,7 @@ grep_lnbufgrow(size_t newlen)
 }
 
 char *
-grep_fgetln(struct file *f, size_t *lenp)
+grep_fgetln(struct file *f, struct parsec *pc)
 {
unsigned char *p;
char *ret;
@@ -109,18 +109,18 @@ grep_fgetln(struct file *f, size_t *lenp)
 
if (bufrem == 0) {
/* Return zero length to indicate EOF */
-   *lenp = 0;
+   pc->ln.len= 0;
return (bufpos);
}
 
-   /* Look for a newline in the remaining part of the buffer */
+   /* Look for a newline in the remaining part of the [6rbuffer */
if ((p = memchr(bufpos, fileeol, bufrem)) != NULL) {
++p; /* advance over newline */
ret = bufpos;
len = p - bufpos;
bufrem -= len;
bufpos = p;
-   *lenp = len;
+   pc->ln.len = len;
return (ret);
}
 
@@ -155,11 +155,11 @@ grep_fgetln(struct file *f, size_t *lenp)
bufpos = p;
break;
}
-   *lenp = len;
+   pc->ln.len = len;
return (lnbuf);
 
 error:
-   *lenp = 0;
+   pc->ln.len = 0;
return (NULL);
 }
 

Modified: head/usr.bin/grep/grep.h
==
--- head/usr.bin/grep/grep.hFri Jun  8 00:47:24 2018(r334820)
+++ head/usr.bin/grep/grep.hFri Jun  8 01:25:07 2018(r334821)
@@ -97,6 +97,21 @@ struct epat {
int  mode;
 };
 
+/*
+ * Parsing context; used to hold things like matches made and
+ * other useful bits
+ */
+struct parsec {
+   regmatch_t  matches[MAX_MATCHES];   /* Matches made */
+   /* XXX TODO: This should be a chunk, not a line */
+   struct str  ln; /* Current line */
+   size_t  lnstart;/* Position in line */
+   size_t  matchidx;   /* Latest match index */
+   int printed;/* Metadata printed? */
+   boolbinary; /* Binary file? */
+   boolcntlines;   /* Count lines? */
+};
+
 /* Flags passed to regcomp() and regexec() */
 extern int  cflags, eflags;
 
@@ -141,4 +156,4 @@ void clearqueue(void);
 /* file.c */
 voidgrep_close(struct file *f);
 struct file*grep_open(const char *path);
-char   *grep_fgetln(struct file *f, size_t *len);
+char   *grep_fgetln(struct file *f, struct parsec *pc);

Modified: head/usr.bin/grep/util.c
==
--- head/usr.bin/grep/util.cFri Jun  8 00:47:24 2018(r334820)
+++ head/usr.bin/grep/util.cFri Jun  8 01:25:07 2018(r334821)
@@ -57,20 +57,6 @@ __FBSDID("$FreeBSD$");
 static bool first_match = true;
 
 /*
- * Parsing context; used to hold things like matches made and
- * other useful bits
- */
-struct parsec {
-   regmatch_t  matches[MAX_MATCHES];   /* Matches made */
-   /* XXX TODO: This should be a chunk, not a line */
-   struct str  ln; /* Current line */
-   size_t  lnstart;/* Position in line */
-   size_t  matchidx;   /* Latest match index */
-   int printed;/* Metadata printed? */
-   boolbinary; /* Binary file? */
-};
-
-/*
  * Match printing context
  */
 struct mprintc {
@@ -276,7 +262,7 @@ procmatches(struct mprintc *mc, struct parsec *pc, boo
if (mflag) {
/* XXX TODO: Decrement by number of matched lines */
mcount -= 1;
-   if (mflag && mcount <= 0

svn commit: r334837 - head/usr.bin/grep

2018-06-08 Thread Kyle Evans
Author: kevans
Date: Fri Jun  8 12:58:55 2018
New Revision: 334837
URL: https://svnweb.freebsd.org/changeset/base/334837

Log:
  bsdgrep(1): Evict character sequence that moved in
  
  Reported by:  trasz

Modified:
  head/usr.bin/grep/file.c

Modified: head/usr.bin/grep/file.c
==
--- head/usr.bin/grep/file.cFri Jun  8 10:09:30 2018(r334836)
+++ head/usr.bin/grep/file.cFri Jun  8 12:58:55 2018(r334837)
@@ -113,7 +113,7 @@ grep_fgetln(struct file *f, struct parsec *pc)
return (bufpos);
}
 
-   /* Look for a newline in the remaining part of the [6rbuffer */
+   /* Look for a newline in the remaining part of the buffer */
if ((p = memchr(bufpos, fileeol, bufrem)) != NULL) {
++p; /* advance over newline */
ret = bufpos;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334884 - head/stand/common

2018-06-09 Thread Kyle Evans
Author: kevans
Date: Sat Jun  9 15:28:37 2018
New Revision: 334884
URL: https://svnweb.freebsd.org/changeset/base/334884

Log:
  stand: Fix build after r334882
  
  Not sure how this was not caught in Universe.

Modified:
  head/stand/common/metadata.c

Modified: head/stand/common/metadata.c
==
--- head/stand/common/metadata.cSat Jun  9 15:10:49 2018
(r334883)
+++ head/stand/common/metadata.cSat Jun  9 15:28:37 2018
(r334884)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #if defined(LOADER_FDT_SUPPORT)
 #include 
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334878 - head/stand/libsa

2018-06-09 Thread Kyle Evans
Author: kevans
Date: Sat Jun  9 14:24:16 2018
New Revision: 334878
URL: https://svnweb.freebsd.org/changeset/base/334878

Log:
  libsa(3): Correct statement about FS Write-support, name change
  
  - jhb implemented UFS write support a little over 16 years ago.
  - Update the library name while we're here.
  
  Reviewed by:  jhb, rpokala
  Differential Revision:https://reviews.freebsd.org/D14476

Modified:
  head/stand/libsa/libsa.3

Modified: head/stand/libsa/libsa.3
==
--- head/stand/libsa/libsa.3Sat Jun  9 14:21:07 2018(r334877)
+++ head/stand/libsa/libsa.3Sat Jun  9 14:24:16 2018(r334878)
@@ -24,11 +24,11 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd February 1, 2018
-.Dt LIBSTAND 3
+.Dd February 22, 2018
+.Dt LIBSA 3
 .Os
 .Sh NAME
-.Nm libstand
+.Nm libsa
 .Nd support library for standalone executables
 .Sh SYNOPSIS
 .In stand.h
@@ -402,8 +402,8 @@ except that file creation is not supported, so the mod
 required.
 The
 .Fa flags
-argument may be one of O_RDONLY, O_WRONLY and O_RDWR (although no file systems
-currently support writing).
+argument may be one of O_RDONLY, O_WRONLY and O_RDWR.
+Only UFS currently supports writing.
 .It Xo
 .Ft int
 .Fn close "int fd"
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334882 - in head/stand: common efi/loader i386/libi386 userboot/userboot

2018-06-09 Thread Kyle Evans
Author: kevans
Date: Sat Jun  9 15:10:39 2018
New Revision: 334882
URL: https://svnweb.freebsd.org/changeset/base/334882

Log:
  stand: Consolidate checking for boot flags driven by environment vars
  
  e.g. boot_mute, boot_single, boot_verbose, and friends; we checked for these
  in multiple places, consolidate into common/ and allow a setting of "NO" for
  any of these to turn them off. This allows systems with multiple
  loader.conf(5) or loader.conf(5) overlay systems to easily turn off
  variables in later processed files by setting it to NO.
  
  Reported by:  Nick Wolff @ iXsystems
  Reviewed by:  imp

Modified:
  head/stand/common/boot.c
  head/stand/common/bootstrap.h
  head/stand/common/metadata.c
  head/stand/efi/loader/bootinfo.c
  head/stand/i386/libi386/bootinfo.c
  head/stand/userboot/userboot/bootinfo.c

Modified: head/stand/common/boot.c
==
--- head/stand/common/boot.cSat Jun  9 14:50:38 2018(r334881)
+++ head/stand/common/boot.cSat Jun  9 15:10:39 2018(r334882)
@@ -32,6 +32,8 @@ __FBSDID("$FreeBSD$");
  */
 
 #include 
+#include 
+#include 
 #include 
 
 #include "bootstrap.h"
@@ -156,6 +158,20 @@ autoboot_maybe()
cp = getenv("autoboot_delay");
if ((autoboot_tried == 0) && ((cp == NULL) || strcasecmp(cp, "NO")))
autoboot(-1, NULL); /* try to boot automatically */
+}
+
+int
+bootenv_flags()
+{
+   int i, howto;
+   char *val;
+
+   for (howto = 0, i = 0; howto_names[i].ev != NULL; i++) {
+   val = getenv(howto_names[i].ev);
+   if (val != NULL && strcasecmp(val, "no") != 0)
+   howto |= howto_names[i].mask;
+   }
+   return (howto);
 }
 
 static int

Modified: head/stand/common/bootstrap.h
==
--- head/stand/common/bootstrap.h   Sat Jun  9 14:50:38 2018
(r334881)
+++ head/stand/common/bootstrap.h   Sat Jun  9 15:10:39 2018
(r334882)
@@ -63,6 +63,7 @@ int   parse(int *argc, char ***argv, const char *str);
 /* boot.c */
 void   autoboot_maybe(void);
 intgetrootmount(char *rootdev);
+intbootenv_flags(void);
 
 /* misc.c */
 char   *unargv(int argc, char *argv[]);

Modified: head/stand/common/metadata.c
==
--- head/stand/common/metadata.cSat Jun  9 14:50:38 2018
(r334881)
+++ head/stand/common/metadata.cSat Jun  9 15:10:39 2018
(r334882)
@@ -31,9 +31,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
 #include 
-#include 
 #if defined(LOADER_FDT_SUPPORT)
 #include 
 #endif
@@ -100,7 +98,6 @@ md_getboothowto(char *kargs)
 char   *cp;
 inthowto;
 intactive;
-inti;
 
 /* Parse kargs */
 howto = 0;
@@ -153,10 +150,7 @@ md_getboothowto(char *kargs)
}
 }
 
-/* get equivalents from the environment */
-for (i = 0; howto_names[i].ev != NULL; i++)
-   if (getenv(howto_names[i].ev) != NULL)
-   howto |= howto_names[i].mask;
+howto |= bootenv_flags();
 #if defined(__sparc64__)
 if (md_bootserial() != -1)
howto |= RB_SERIAL;

Modified: head/stand/efi/loader/bootinfo.c
==
--- head/stand/efi/loader/bootinfo.cSat Jun  9 14:50:38 2018
(r334881)
+++ head/stand/efi/loader/bootinfo.cSat Jun  9 15:10:39 2018
(r334882)
@@ -32,9 +32,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -72,15 +71,9 @@ bi_getboothowto(char *kargs)
const char *sw;
char *opts;
char *console;
-   int howto, i;
+   int howto;
 
-   howto = 0;
-
-   /* Get the boot options from the environment first. */
-   for (i = 0; howto_names[i].ev != NULL; i++) {
-   if (getenv(howto_names[i].ev) != NULL)
-   howto |= howto_names[i].mask;
-   }
+   howto = bootenv_flags();
 
console = getenv("console");
if (console != NULL) {

Modified: head/stand/i386/libi386/bootinfo.c
==
--- head/stand/i386/libi386/bootinfo.c  Sat Jun  9 14:50:38 2018
(r334881)
+++ head/stand/i386/libi386/bootinfo.c  Sat Jun  9 15:10:39 2018
(r334882)
@@ -43,7 +43,6 @@ bi_getboothowto(char *kargs)
 char   *curpos, *next, *string;
 inthowto;
 intactive;
-inti;
 intvidconsole;
 
 /* Parse kargs */
@@ -96,10 +95,7 @@ bi_getboothowto(char *kargs)
cp++;
}
 }
-/* get equivalents from the environment */
-for (i = 0; howto_names[i].ev != NULL; i

svn commit: r334879 - head/stand/lua

2018-06-09 Thread Kyle Evans
Author: kevans
Date: Sat Jun  9 14:26:30 2018
New Revision: 334879
URL: https://svnweb.freebsd.org/changeset/base/334879

Log:
  lualoader: Add hook.lua(8) to tree
  
  Reviewed by:  rpokala (w/ "All Rights Reserved" previously added)
  Differential Revision:https://reviews.freebsd.org/D14815

Added:
  head/stand/lua/hook.lua.8   (contents, props changed)

Added: head/stand/lua/hook.lua.8
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/stand/lua/hook.lua.8   Sat Jun  9 14:26:30 2018(r334879)
@@ -0,0 +1,94 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+.\"
+.\" Copyright (c) 2018 Kyle Evans 
+.\"
+.\" 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 THE AUTHOR 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 THE AUTHOR 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd June 9, 2018
+.Dt HOOK.LUA 8
+.Os
+.Sh NAME
+.Nm hook.lua
+.Nd FreeBSD hook module
+.Sh DESCRIPTION
+.Nm
+contains functionality for defining hook types and attaching hooks.
+Hooks are functions used to attach custom behaviors at pre-defined points in
+loader execution.
+These pre-defined points are what we refer to as
+.Dq hook types .
+.Pp
+Before using the functionality provided by
+.Nm ,
+it must be included with a statement such as the following:
+.Pp
+.Dl local hook = require("hook")
+.Ss Exported functions
+The following functions are exported from
+.Nm :
+.Bl -tag -width hook.registerType -offset indent
+.It Fn hook.registerType hooktype
+Adds
+.Ev hooktype
+as a recognized hook type.
+This allows functions to be added to run when hooks of this type are invoked
+using
+.Fn hook.runAll hooktype .
+.It Fn hook.register hooktype hookfunc
+Register
+.Ev hookfunc
+to be run when hooks of type
+.Ev hooktype
+are invoked.
+.It Fn hook.runAll hooktype
+Invoke all hooks registered for type
+.Ev hooktype .
+Hooks are invoked in the order in which they are registered.
+.El
+.Ss Hook Naming Guidelines
+Hook names should consist of the name of the module they are defined in, as 
well
+as a verb describing when the hook is executed, separated by a period.
+For example,
+.Dq config.reloaded
+is defined in the
+.Xr config.lua 8
+module and run when the configuration is reloaded.
+.Sh EXAMPLES
+To register a hook to be run when configuration is reloaded:
+.Pp
+.Bd -literal -offset indent -compact
+local hook = require("hook")
+
+local function configuration_was_reloaded()
+   print("Configuration was reloaded!")
+end
+
+hook.register("config.reloaded", configuration_was_reloaded)
+.Ed
+.Sh AUTHORS
+The
+.Nm
+file was originally written by
+.An Kyle Evans Aq Mt kev...@freebsd.org .
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334885 - in head/stand: common efi/loader i386/libi386 userboot/userboot

2018-06-09 Thread Kyle Evans
Author: kevans
Date: Sat Jun  9 15:52:29 2018
New Revision: 334885
URL: https://svnweb.freebsd.org/changeset/base/334885

Log:
  stand: One more trivial consolidation (setting environment from howto)

Modified:
  head/stand/common/boot.c
  head/stand/common/bootstrap.h
  head/stand/efi/loader/main.c
  head/stand/i386/libi386/bootinfo.c
  head/stand/userboot/userboot/bootinfo.c

Modified: head/stand/common/boot.c
==
--- head/stand/common/boot.cSat Jun  9 15:28:37 2018(r334884)
+++ head/stand/common/boot.cSat Jun  9 15:52:29 2018(r334885)
@@ -174,6 +174,16 @@ bootenv_flags()
return (howto);
 }
 
+void
+bootenv_set(int howto)
+{
+   int i;
+
+   for (i = 0; howto_names[i].ev != NULL; i++)
+   if (howto & howto_names[i].mask)
+   setenv(howto_names[i].ev, "YES", 1);
+}
+
 static int
 autoboot(int timeout, char *prompt)
 {

Modified: head/stand/common/bootstrap.h
==
--- head/stand/common/bootstrap.h   Sat Jun  9 15:28:37 2018
(r334884)
+++ head/stand/common/bootstrap.h   Sat Jun  9 15:52:29 2018
(r334885)
@@ -64,6 +64,7 @@ int   parse(int *argc, char ***argv, const char *str);
 void   autoboot_maybe(void);
 intgetrootmount(char *rootdev);
 intbootenv_flags(void);
+void   bootenv_set(int);
 
 /* misc.c */
 char   *unargv(int argc, char *argv[]);

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cSat Jun  9 15:28:37 2018
(r334884)
+++ head/stand/efi/loader/main.cSat Jun  9 15:52:29 2018
(r334885)
@@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -549,9 +548,8 @@ main(int argc, CHAR16 *argv[])
}
}
}
-   for (i = 0; howto_names[i].ev != NULL; i++)
-   if (howto & howto_names[i].mask)
-   setenv(howto_names[i].ev, "YES", 1);
+
+   bootenv_set(howto);
 
/*
 * XXX we need fallback to this stuff after looking at the ConIn, 
ConOut and ConErr variables

Modified: head/stand/i386/libi386/bootinfo.c
==
--- head/stand/i386/libi386/bootinfo.c  Sat Jun  9 15:28:37 2018
(r334884)
+++ head/stand/i386/libi386/bootinfo.c  Sat Jun  9 15:52:29 2018
(r334885)
@@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include "bootstrap.h"
 #include "libi386.h"
 #include "btxv86.h"
@@ -130,11 +129,8 @@ bi_getboothowto(char *kargs)
 void
 bi_setboothowto(int howto)
 {
-inti;
 
-for (i = 0; howto_names[i].ev != NULL; i++)
-   if (howto & howto_names[i].mask)
-   setenv(howto_names[i].ev, "YES", 1);
+bootenv_set(howto);
 }
 
 /*

Modified: head/stand/userboot/userboot/bootinfo.c
==
--- head/stand/userboot/userboot/bootinfo.c Sat Jun  9 15:28:37 2018
(r334884)
+++ head/stand/userboot/userboot/bootinfo.c Sat Jun  9 15:52:29 2018
(r334885)
@@ -31,7 +31,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 
 #include "bootstrap.h"
 #include "libuserboot.h"
@@ -131,11 +130,8 @@ bi_getboothowto(char *kargs)
 void
 bi_setboothowto(int howto)
 {
-inti;
 
-for (i = 0; howto_names[i].ev != NULL; i++)
-   if (howto & howto_names[i].mask)
-   setenv(howto_names[i].ev, "YES", 1);
+bootenv_set(howto);
 }
 
 /*
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334889 - head/usr.bin/grep

2018-06-09 Thread Kyle Evans
Author: kevans
Date: Sat Jun  9 18:11:46 2018
New Revision: 334889
URL: https://svnweb.freebsd.org/changeset/base/334889

Log:
  bsdgrep(1): Some more int -> bool conversions and name changes
  
  Again motivated by upcoming work to rewrite a bunch of this- single-letter
  variable names and slightly misleading variable names ("lastmatches" to
  indicate that the last matched) are not helpful.

Modified:
  head/usr.bin/grep/util.c

Modified: head/usr.bin/grep/util.c
==
--- head/usr.bin/grep/util.cSat Jun  9 17:49:43 2018(r334888)
+++ head/usr.bin/grep/util.cSat Jun  9 18:11:46 2018(r334889)
@@ -74,7 +74,7 @@ static bool procmatches(struct mprintc *mc, struct par
 static int litexec(const struct pat *pat, const char *string,
 size_t nmatch, regmatch_t pmatch[]);
 #endif
-static int procline(struct parsec *pc);
+static bool procline(struct parsec *pc);
 static void printline(struct parsec *pc, int sep);
 static void printline_metadata(struct str *line, int sep);
 
@@ -210,7 +210,7 @@ procmatch_match(struct mprintc *mc, struct parsec *pc)
while (pc->matchidx >= MAX_MATCHES) {
/* Reset matchidx and try again */
pc->matchidx = 0;
-   if (procline(pc) == 0)
+   if (procline(pc))
printline(pc, ':');
else
break;
@@ -283,7 +283,8 @@ procfile(const char *fn)
struct file *f;
struct stat sb;
mode_t s;
-   int lines, t;
+   int lines;
+   bool line_matched;
 
if (strcmp(fn, "-") == 0) {
fn = label != NULL ? label : errstr[1];
@@ -316,6 +317,7 @@ procfile(const char *fn)
pc.cntlines = false;
memset(&mc, 0, sizeof(mc));
mc.printmatch = true;
+   line_matched = false;
if ((pc.binary && binbehave == BINFILE_BIN) || cflag || qflag ||
lflag || Lflag)
mc.printmatch = false;
@@ -354,11 +356,12 @@ procfile(const char *fn)
return (0);
}
 
-   if ((t = procline(&pc)) == 0)
+   line_matched = procline(&pc);
+   if (line_matched)
++lines;
 
/* Halt processing if we hit our match limit */
-   if (!procmatches(&mc, &pc, t == 0))
+   if (!procmatches(&mc, &pc, line_matched))
break;
}
if (Bflag > 0)
@@ -453,31 +456,33 @@ litexec(const struct pat *pat, const char *string, siz
  * matches.  The matching lines are passed to printline() to display the
  * appropriate output.
  */
-static int
+static bool
 procline(struct parsec *pc)
 {
regmatch_t pmatch, lastmatch, chkmatch;
wchar_t wbegin, wend;
size_t st, nst;
unsigned int i;
-   int c = 0, r = 0, lastmatches = 0, leflags = eflags;
+   int r = 0, leflags = eflags;
size_t startm = 0, matchidx;
unsigned int retry;
+   bool lastmatched, matched;
 
matchidx = pc->matchidx;
 
/* Special case: empty pattern with -w flag, check first character */
if (matchall && wflag) {
if (pc->ln.len == 0)
-   return (0);
+   return (true);
wend = L' ';
if (sscanf(&pc->ln.dat[0], "%lc", &wend) != 1 || iswword(wend))
-   return (1);
+   return (false);
else
-   return (0);
+   return (true);
} else if (matchall)
-   return (0);
+   return (true);
 
+   matched = false;
st = pc->lnstart;
nst = 0;
/* Initialize to avoid a false positive warning from GCC. */
@@ -485,7 +490,7 @@ procline(struct parsec *pc)
 
/* Loop to process the whole line */
while (st <= pc->ln.len) {
-   lastmatches = 0;
+   lastmatched = false;
startm = matchidx;
retry = 0;
if (st > 0 && pc->ln.dat[st - 1] != fileeol)
@@ -537,11 +542,11 @@ procline(struct parsec *pc)
if (r == REG_NOMATCH)
continue;
}
-   lastmatches++;
+   lastmatched = true;
lastmatch = pmatch;
 
if (matchidx == 0)
-   c++;
+   matched = true;
 
/*
 * Replace previous match if the new one is earlier
@@ -567,7 +572,7 @@ procline(struct parsec *pc)
if ((color == NULL && !oflag) || qflag || lflag ||
matchidx >= MAX_MATCHES) {
  

svn commit: r334891 - head/stand/lua

2018-06-09 Thread Kyle Evans
Author: kevans
Date: Sat Jun  9 19:51:09 2018
New Revision: 334891
URL: https://svnweb.freebsd.org/changeset/base/334891

Log:
  lualoader: Add cli.lua(8) to the tree
  
  Reviewed by:  rpokala
  Differential Revision:https://reviews.freebsd.org/D14818

Added:
  head/stand/lua/cli.lua.8   (contents, props changed)

Added: head/stand/lua/cli.lua.8
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/stand/lua/cli.lua.8Sat Jun  9 19:51:09 2018(r334891)
@@ -0,0 +1,112 @@
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+.\"
+.\" Copyright (c) 2018 Kyle Evans 
+.\"
+.\" 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 THE AUTHOR 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 THE AUTHOR 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd June 9, 2018
+.Dt CLI.LUA 8
+.Os
+.Sh NAME
+.Nm cli.lua
+.Nd FreeBSD Lua CLI module
+.Sh DESCRIPTION
+.Nm
+contains the main functionality required to add new CLI commands, which can be
+executed at the loader prompt.
+.Pp
+Before hooking into the functionality provided by
+.Nm ,
+it must be included with a statement such as the following:
+.Pp
+.Dl local cli = require("cli")
+.Ss Adding new commands
+New loader commands may be created by adding functions to the object returned 
by
+requiring the
+.Nm
+module.
+.Pp
+For instance:
+.Pp
+.Bd -literal -offset indent -compact
+local cli = require("cli")
+
+cli.foo = function(...)
+   -- Expand args to command name and the rest of argv.  These arguments
+   -- are pushed directly to the stack by loader, then handed off to
+   -- cli_execute.  cli_execute then passes them on to the invoked
+   -- function, where they appear as varargs that must be peeled apart into
+   -- their respective components.
+   local _, argv = cli.arguments(...)
+
+   print("This is the foo command!")
+   for k, v in ipairs(argv) do
+   print("arg #" .. tostring(k) .. ": '" .. v .. "'")
+   end
+   -- Perform a loader command directly.  This will not get dispatched back
+   -- to Lua, so it is acceptable to have a function of the exact same name
+   -- in loader.  Lua will have the first chance to handle any commands
+   -- executed at the loader prompt.
+   loader.perform("foo")
+end
+.Ed
+.Pp
+This function may be invoked by a user at the loader prompt by simply typing
+.Ic foo .
+Arguments may be passed to it as usual, space-delimited.
+.Ss Default Commands
+As of present, the
+.Nm
+module by default provides commands for
+.Ic autoboot
+and
+.Ic boot .
+In both cases, the
+.Xr core.lua 8
+module will load all ELF modules as-needed before executing the equivalent
+built-in loader commands.
+All non-kernel arguments to these commands are passed in the same order to the
+loader command.
+.Ss Exported Functions
+The following functions are exported from
+.Nm :
+.Bl -tag -width cli.arguments -offset indent
+.It Fn cli.arguments ...
+Takes varargs passed on the stack from
+.Xr loader 8
+to
+.Ic cli_execute ,
+splits them out into two return values: the command name, traditionally 
argv[0],
+and the rest of argv.
+.El
+.Sh SEE ALSO
+.Xr loader.conf 5 ,
+.Xr core.lua 8 ,
+.Xr loader 8
+.Sh AUTHORS
+The
+.Nm
+file was originally written by
+.An Kyle Evans Aq Mt kev...@freebsd.org .
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r334907 - head/stand/lua

2018-06-09 Thread Kyle Evans
Author: kevans
Date: Sun Jun 10 01:38:52 2018
New Revision: 334907
URL: https://svnweb.freebsd.org/changeset/base/334907

Log:
  lualoader: Process loader_conf_files properly
  
  loader.conf(5) documents loader_conf_files to mean "additional configuration
  files to be processed right after the present file." However, lualoader
  ignored loader_conf_files after processing /boot/defaults/loader.conf.
  
  Rewrite these bits to process loader_conf_files after each loaded file.

Modified:
  head/stand/lua/config.lua

Modified: head/stand/lua/config.lua
==
--- head/stand/lua/config.lua   Sun Jun 10 00:02:56 2018(r334906)
+++ head/stand/lua/config.lua   Sun Jun 10 01:38:52 2018(r334907)
@@ -250,7 +250,34 @@ local function loadModule(mod, silent)
return status
 end
 
+local function readConfFiles(loaded_files)
+   local f = loader.getenv("loader_conf_files")
+   if f ~= nil then
+   for name in f:gmatch("([%w%p]+)%s*") do
+   if loaded_files[name] ~= nil then
+   goto continue
+   end
 
+   local prefiles = loader.getenv("loader_conf_files")
+
+   print("Loading " .. name)
+   -- These may or may not exist, and that's ok. Do a
+   -- silent parse so that we complain on parse errors but
+   -- not for them simply not existing.
+   if not config.processFile(name, true) then
+   print(MSG_FAILPARSECFG:format(name))
+   end
+
+   loaded_files[name] = true
+   local newfiles = loader.getenv("loader_conf_files")
+   if prefiles ~= newfiles then
+   readConfFiles(loaded_files)
+   end
+   ::continue::
+   end
+   end
+end
+
 local function readFile(name, silent)
local f = io.open(name)
if f == nil then
@@ -467,17 +494,8 @@ function config.load(file, reloading)
print(MSG_FAILPARSECFG:format(file))
end
 
-   local f = loader.getenv("loader_conf_files")
-   if f ~= nil then
-   for name in f:gmatch("([%w%p]+)%s*") do
-   -- These may or may not exist, and that's ok. Do a
-   -- silent parse so that we complain on parse errors but
-   -- not for them simply not existing.
-   if not config.processFile(name, true) then
-   print(MSG_FAILPARSECFG:format(name))
-   end
-   end
-   end
+   local loaded_files = {file = true}
+   readConfFiles(loaded_files)
 
checkNextboot()
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


  1   2   3   4   5   6   7   8   9   10   >