svn commit: r339802 - head/stand/efi/loader

2018-10-26 Thread Warner Losh
Author: imp
Date: Fri Oct 26 23:44:50 2018
New Revision: 339802
URL: https://svnweb.freebsd.org/changeset/base/339802

Log:
  Fix pointer arithmetic
  
  Pointer math to find the size in bytes only works with char types.
  Use correct pointer math to determine if we have enough of a header to
  look at or not.
  
  MFC After: 3 days
  X-MFX-With: r339800
  Noticed by: jhb@
  Sponsored by: Netflix, Inc

Modified:
  head/stand/efi/loader/main.c

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cFri Oct 26 23:44:39 2018
(r339801)
+++ head/stand/efi/loader/main.cFri Oct 26 23:44:50 2018
(r339802)
@@ -298,6 +298,8 @@ fix_dosisms(char *p)
}
 }
 
+#define SIZE(dp, edp) (size_t)((intptr_t)(void *)edp - (intptr_t)(void *)dp)
+
 enum { BOOT_INFO_OK = 0, BAD_CHOICE = 1, NOT_SPECIFIC = 2  };
 static int
 match_boot_info(EFI_LOADED_IMAGE *img __unused, char *boot_info, size_t bisz)
@@ -349,7 +351,7 @@ match_boot_info(EFI_LOADED_IMAGE *img __unused, char *
edp = (EFI_DEVICE_PATH *)(walker + fplen);
if ((char *)edp > ep)
return NOT_SPECIFIC;
-   while (dp < edp && (size_t)(edp - dp) > sizeof(EFI_DEVICE_PATH)) {
+   while (dp < edp && SIZE(dp, edp) > sizeof(EFI_DEVICE_PATH)) {
text = efi_devpath_name(dp);
if (text != NULL) {
printf("   BootInfo Path: %S\n", text);
___
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: r339801 - head/usr.sbin/efivar

2018-10-26 Thread Warner Losh
Author: imp
Date: Fri Oct 26 23:44:39 2018
New Revision: 339801
URL: https://svnweb.freebsd.org/changeset/base/339801

Log:
  Fix pointer arithmetic botch.
  
  Pointer subtraction to find size only works with char pointers.
  
  Noticed by: jhb@
  Sponsored by: Netflix, Inc

Modified:
  head/usr.sbin/efivar/efiutil.c

Modified: head/usr.sbin/efivar/efiutil.c
==
--- head/usr.sbin/efivar/efiutil.c  Fri Oct 26 23:08:22 2018
(r339800)
+++ head/usr.sbin/efivar/efiutil.c  Fri Oct 26 23:44:39 2018
(r339801)
@@ -116,6 +116,8 @@ bindump(uint8_t *data, size_t datalen)
 
 #define LOAD_OPTION_ACTIVE 1
 
+#define SIZE(dp, edp) (size_t)((intptr_t)(void *)edp - (intptr_t)(void *)dp)
+
 void
 efi_print_load_option(uint8_t *data, size_t datalen, int Aflag, int bflag, int 
uflag)
 {
@@ -159,9 +161,8 @@ efi_print_load_option(uint8_t *data, size_t datalen, i
ucs2_to_utf8(descr, );
printf("%s", str);
free(str);
-   while (dp < edp && (size_t)(edp - dp) > sizeof(efidp_header)) {
-   efidp_format_device_path(buf, sizeof(buf), dp,
-   (intptr_t)(void *)edp - (intptr_t)(void *)dp);
+   while (dp < edp && SIZE(dp, edp) > sizeof(efidp_header)) {
+   efidp_format_device_path(buf, sizeof(buf), dp, SIZE(dp, edp));
dp = (efidp)((char *)dp + efidp_size(dp));
printf(" %s\n", buf);
}
___
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: r339800 - head/stand/efi/loader

2018-10-26 Thread Warner Losh
Author: imp
Date: Fri Oct 26 23:08:22 2018
New Revision: 339800
URL: https://svnweb.freebsd.org/changeset/base/339800

Log:
  Ensure we have a full EFI_DEVICE_PATH header before we try to look at
  its length. Some BIOSes pad the length of the device path to an even
  amount. When we had a device path that was somehow an odd length, we'd
  wind up having 1 byte left that we were bogusly interpreting as a full
  device path. We'd then dereference 2 bytes into that to get a length
  of the node, which had undefined (and quite undesired) effects.
  
  Sponsored by: Netflix, Inc
  MFC After: 3 days

Modified:
  head/stand/efi/loader/main.c

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cFri Oct 26 22:49:36 2018
(r339799)
+++ head/stand/efi/loader/main.cFri Oct 26 23:08:22 2018
(r339800)
@@ -349,7 +349,7 @@ match_boot_info(EFI_LOADED_IMAGE *img __unused, char *
edp = (EFI_DEVICE_PATH *)(walker + fplen);
if ((char *)edp > ep)
return NOT_SPECIFIC;
-   while (dp < edp) {
+   while (dp < edp && (size_t)(edp - dp) > sizeof(EFI_DEVICE_PATH)) {
text = efi_devpath_name(dp);
if (text != NULL) {
printf("   BootInfo Path: %S\n", text);
___
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: r339799 - head/lib/libefivar

2018-10-26 Thread Warner Losh
Author: imp
Date: Fri Oct 26 22:49:36 2018
New Revision: 339799
URL: https://svnweb.freebsd.org/changeset/base/339799

Log:
  Ensure that the device path is sane before trying to decode and print
  it.
  
  Sponsored by: Netflix, Inc

Modified:
  head/lib/libefivar/efivar-dp-format.c

Modified: head/lib/libefivar/efivar-dp-format.c
==
--- head/lib/libefivar/efivar-dp-format.c   Fri Oct 26 22:49:25 2018
(r339798)
+++ head/lib/libefivar/efivar-dp-format.c   Fri Oct 26 22:49:36 2018
(r339799)
@@ -2413,12 +2413,19 @@ UefiDevicePathLibConvertDevicePathToText (
   }
 }
 
-
 ssize_t
 efidp_format_device_path(char *buf, size_t len, const_efidp dp, ssize_t max)
 {
char *str;
ssize_t retval;
+
+   /*
+* Basic sanity check on the device path.
+*/
+   if (!IsDevicePathValid((CONST EFI_DEVICE_PATH_PROTOCOL *) dp, max)) {
+   *buf = '\0';
+   return 0;
+   }
 
str = UefiDevicePathLibConvertDevicePathToText (
__DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
___
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: r339798 - head/usr.sbin/efivar

2018-10-26 Thread Warner Losh
Author: imp
Date: Fri Oct 26 22:49:25 2018
New Revision: 339798
URL: https://svnweb.freebsd.org/changeset/base/339798

Log:
  Require that we have at least a device path header before
  trying to decode the next device path.
  
  Sponsored by: Netflix, Inc

Modified:
  head/usr.sbin/efivar/efiutil.c

Modified: head/usr.sbin/efivar/efiutil.c
==
--- head/usr.sbin/efivar/efiutil.c  Fri Oct 26 22:13:40 2018
(r339797)
+++ head/usr.sbin/efivar/efiutil.c  Fri Oct 26 22:49:25 2018
(r339798)
@@ -159,7 +159,7 @@ efi_print_load_option(uint8_t *data, size_t datalen, i
ucs2_to_utf8(descr, );
printf("%s", str);
free(str);
-   while (dp < edp) {
+   while (dp < edp && (size_t)(edp - dp) > sizeof(efidp_header)) {
efidp_format_device_path(buf, sizeof(buf), dp,
(intptr_t)(void *)edp - (intptr_t)(void *)dp);
dp = (efidp)((char *)dp + efidp_size(dp));
___
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: r339797 - head/usr.sbin/efivar

2018-10-26 Thread Warner Losh
Author: imp
Date: Fri Oct 26 22:13:40 2018
New Revision: 339797
URL: https://svnweb.freebsd.org/changeset/base/339797

Log:
  Implenent --fromfile to read variable values when printing variables
  
  So
  
  ./efivar --fromfile Boot0001.bin --print --load-option
  
  will take the value from Boot0001.bin file and then decode it as if it
  were a load-option. This is useful for debugging handling of such
  variables that may be hanging the boot for some people.
  
  Sponsored by: Netflix, Inc

Modified:
  head/usr.sbin/efivar/efivar.8
  head/usr.sbin/efivar/efivar.c

Modified: head/usr.sbin/efivar/efivar.8
==
--- head/usr.sbin/efivar/efivar.8   Fri Oct 26 21:57:22 2018
(r339796)
+++ head/usr.sbin/efivar/efivar.8   Fri Oct 26 22:13:40 2018
(r339797)
@@ -86,8 +86,17 @@ This flag implies
 .Fl -write
 unless the
 .Fl -append
-flag is given.
-This behavior is not well understood and is currently unimplemented.
+or
+.Fl -print
+flags are given.
+This behavior is not well understood and is currently unimplemented
+for writes.
+When
+.Fl -print
+is specified, the contents of the file are used as the value to
+print using any other specified flags.
+This is used primarily for testing purposes for more complicated
+variable decoding.
 .It Fl a Fl -append
 Append the specified value to the UEFI variable rather than replacing
 it.

Modified: head/usr.sbin/efivar/efivar.c
==
--- head/usr.sbin/efivar/efivar.c   Fri Oct 26 21:57:22 2018
(r339796)
+++ head/usr.sbin/efivar/efivar.c   Fri Oct 26 22:13:40 2018
(r339797)
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -70,6 +71,7 @@ static struct option longopts[] = {
 static int aflag, Aflag, bflag, dflag, Dflag, gflag, Hflag, Nflag,
lflag, Lflag, Rflag, wflag, pflag, uflag, load_opt_flag;
 static char *varname;
+static char *fromfile;
 static u_long attrib = EFI_VARIABLE_NON_VOLATILE | 
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
 
 static void
@@ -183,16 +185,32 @@ print_var(efi_guid_t *guid, char *name)
uint32_t att;
uint8_t *data;
size_t datalen;
-   char *gname;
+   char *gname = NULL;
int rv;
 
-   pretty_guid(guid, );
-   if (pflag) {
-   rv = efi_get_variable(*guid, name, , , );
+   if (guid)
+   pretty_guid(guid, );
+   if (pflag || fromfile) {
+   if (fromfile) {
+   int fd;
 
-   if (rv < 0)
-   err(1, "%s-%s", gname, name);
+   fd = open(fromfile, O_RDONLY);
+   if (fd < 0)
+   err(1, "open %s", fromfile);
+   data = malloc(64 * 1024);
+   if (data == NULL)
+   err(1, "malloc");
+   datalen = read(fd, data, 64 * 1024);
+   if (datalen <= 0)
+   err(1, "read");
+   close(fd);
+   } else {
+   rv = efi_get_variable(*guid, name, , , 
);
+   if (rv < 0)
+   err(1, "fetching %s-%s", gname, name);
+   }
 
+
if (!Nflag)
printf("%s-%s\n", gname, name);
if (load_opt_flag)
@@ -310,6 +328,9 @@ parse_args(int argc, char **argv)
wflag++;
break;
case 'f':
+   free(fromfile);
+   fromfile = strdup(optarg);
+   break;
case 0:
errx(1, "unknown or unimplemented option\n");
break;
@@ -343,7 +364,10 @@ parse_args(int argc, char **argv)
write_variable(varname, NULL);
else if (Lflag)
print_known_guid();
-   else if (varname) {
+   else if (fromfile) {
+   Nflag = 1;
+   print_var(NULL, NULL);
+   } else if (varname) {
pflag++;
print_variable(varname);
} else if (argc > 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: r339796 - head/stand/efi/libefi

2018-10-26 Thread Rebecca Cran
Author: bcran
Date: Fri Oct 26 21:57:22 2018
New Revision: 339796
URL: https://svnweb.freebsd.org/changeset/base/339796

Log:
  Simplify the EFI delay() function by calling BS->Stall()
  
  Differential Revision: https://reviews.freebsd.org/D16753

Modified:
  head/stand/efi/libefi/delay.c

Modified: head/stand/efi/libefi/delay.c
==
--- head/stand/efi/libefi/delay.c   Fri Oct 26 21:20:04 2018
(r339795)
+++ head/stand/efi/libefi/delay.c   Fri Oct 26 21:57:22 2018
(r339796)
@@ -33,15 +33,5 @@ __FBSDID("$FreeBSD$");
 void
 delay(int usecs)
 {
-   static EFI_EVENT ev = 0;
-   UINTN junk;
-
-   if (!ev) {
-   if (BS->CreateEvent(EVT_TIMER, TPL_APPLICATION, 0, 0, )
-   != EFI_SUCCESS)
-   return;
-   }
-
-   BS->SetTimer(ev, TimerRelative, usecs * 10);
-   BS->WaitForEvent(1, , );
+   BS->Stall(usecs);
 }
___
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: r339795 - head/tests/sys/acl

2018-10-26 Thread Mark Johnston
Author: markj
Date: Fri Oct 26 21:20:04 2018
New Revision: 339795
URL: https://svnweb.freebsd.org/changeset/base/339795

Log:
  Add a very basic regression test for setfacl -R with NFSv4 ACLs.
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/tests/sys/acl/tools-nfs4-psarc.test
  head/tests/sys/acl/tools-nfs4.test

Modified: head/tests/sys/acl/tools-nfs4-psarc.test
==
--- head/tests/sys/acl/tools-nfs4-psarc.testFri Oct 26 21:17:50 2018
(r339794)
+++ head/tests/sys/acl/tools-nfs4-psarc.testFri Oct 26 21:20:04 2018
(r339795)
@@ -557,6 +557,29 @@ $ rmdir yyy
 $ rm xxx
 $ cd ..
 $ rmdir ddd
-
 $ rm xxx
 
+# Test basic recursive setting of ACLs.
+$ mkdir ddd
+$ touch ddd/xxx
+$ mkdir ddd/eee
+$ touch ddd/eee/yyy
+$ setfacl -R -m 
owner@:full_set:f:allow,group@:full_set::allow,everyone@:full_set::allow ddd
+$ getfacl -q ddd
+> owner@:rwxpDdaARWcCos:f--:allow
+> group@:rwxpDdaARWcCos:---:allow
+>  everyone@:rwxpDdaARWcCos:---:allow
+$ getfacl -q ddd/xxx
+> owner@:rwxpDdaARWcCos:---:allow
+> group@:rwxpDdaARWcCos:---:allow
+>  everyone@:rwxpDdaARWcCos:---:allow
+$ getfacl -q ddd/eee
+> owner@:rwxpDdaARWcCos:f--:allow
+> group@:rwxpDdaARWcCos:---:allow
+>  everyone@:rwxpDdaARWcCos:---:allow
+$ getfacl -q ddd/eee/yyy
+> owner@:rwxpDdaARWcCos:---:allow
+> group@:rwxpDdaARWcCos:---:allow
+>  everyone@:rwxpDdaARWcCos:---:allow
+
+$ rm -r ddd

Modified: head/tests/sys/acl/tools-nfs4.test
==
--- head/tests/sys/acl/tools-nfs4.test  Fri Oct 26 21:17:50 2018
(r339794)
+++ head/tests/sys/acl/tools-nfs4.test  Fri Oct 26 21:20:04 2018
(r339795)
@@ -823,6 +823,41 @@ $ rmdir yyy
 $ rm xxx
 $ cd ..
 $ rmdir ddd
-
 $ rm xxx
 
+# Test basic recursive setting of ACLs.
+$ mkdir ddd
+$ touch ddd/xxx
+$ mkdir ddd/eee
+$ touch ddd/eee/yyy
+$ setfacl -R -m 
owner@:full_set:f:allow,group@:full_set::allow,everyone@:full_set::allow ddd
+$ getfacl -q ddd
+> owner@:--:---:deny
+> owner@:rwxpDdaARWcCos:f--:allow
+> group@:-w-p--:---:deny
+> group@:rwxpDdaARWcCos:---:allow
+>  everyone@:-w-p---A-W-Co-:---:deny
+>  everyone@:rwxpDdaARWcCos:---:allow
+$ getfacl -q ddd/xxx
+> owner@:--x---:---:deny
+> owner@:rwxpDdaARWcCos:---:allow
+> group@:-wxp--:---:deny
+> group@:rwxpDdaARWcCos:---:allow
+>  everyone@:-wxp---A-W-Co-:---:deny
+>  everyone@:rwxpDdaARWcCos:---:allow
+$ getfacl -q ddd/eee
+> owner@:--:---:deny
+> owner@:rwxpDdaARWcCos:f--:allow
+> group@:-w-p--:---:deny
+> group@:rwxpDdaARWcCos:---:allow
+>  everyone@:-w-p---A-W-Co-:---:deny
+>  everyone@:rwxpDdaARWcCos:---:allow
+$ getfacl -q ddd/eee/yyy
+> owner@:--x---:---:deny
+> owner@:rwxpDdaARWcCos:---:allow
+> group@:-wxp--:---:deny
+> group@:rwxpDdaARWcCos:---:allow
+>  everyone@:-wxp---A-W-Co-:---:deny
+>  everyone@:rwxpDdaARWcCos:---:allow
+
+$ rm -r ddd
___
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: r339794 - head/contrib/libarchive/libarchive

2018-10-26 Thread Martin Matuska
Author: mm
Date: Fri Oct 26 21:17:50 2018
New Revision: 339794
URL: https://svnweb.freebsd.org/changeset/base/339794

Log:
  MFV r339792:
  Sync libarchive with vendor.
  
  Relevant vendor changes:
RAR5 reader: more maybe-uninitialized size_t fixes for riscv64
 FreeBSD build
  
  MFC after:1 month

Modified:
  head/contrib/libarchive/libarchive/archive_read_support_format_rar5.c
Directory Properties:
  head/contrib/libarchive/   (props changed)

Modified: head/contrib/libarchive/libarchive/archive_read_support_format_rar5.c
==
--- head/contrib/libarchive/libarchive/archive_read_support_format_rar5.c   
Fri Oct 26 21:17:06 2018(r339793)
+++ head/contrib/libarchive/libarchive/archive_read_support_format_rar5.c   
Fri Oct 26 21:17:50 2018(r339794)
@@ -1281,8 +1281,12 @@ static int process_head_file(struct archive_read* a, s
 struct archive_entry* entry, size_t block_flags)
 {
 ssize_t extra_data_size = 0;
-size_t data_size, file_flags, file_attr, compression_info, host_os,
-   name_size;
+size_t data_size = 0;
+size_t file_flags = 0;
+size_t file_attr = 0;
+size_t compression_info = 0;
+size_t host_os = 0;
+size_t name_size = 0;
 uint64_t unpacked_size;
 uint32_t mtime = 0, crc;
 int c_method = 0, c_version = 0, is_dir;
@@ -1297,7 +1301,7 @@ static int process_head_file(struct archive_read* a, s
 }
 
 if(block_flags & HFL_EXTRA_DATA) {
-size_t edata_size;
+size_t edata_size = 0;
 if(!read_var_sized(a, _size, NULL))
 return ARCHIVE_EOF;
 
___
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: r339793 - head/bin/setfacl

2018-10-26 Thread Mark Johnston
Author: markj
Date: Fri Oct 26 21:17:06 2018
New Revision: 339793
URL: https://svnweb.freebsd.org/changeset/base/339793

Log:
  Don't set NFSv4 ACL inheritance flags on non-directories.
  
  They only make sense in the context of directory ACLs, and attempting
  to set them on regular files results in errors, causing a recursive
  setfacl invocation to abort.
  
  This is derived from patches by Shawn Webb 
  and Mitchell Horne .
  
  PR:   155163
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D15061

Modified:
  head/bin/setfacl/setfacl.1
  head/bin/setfacl/setfacl.c

Modified: head/bin/setfacl/setfacl.1
==
--- head/bin/setfacl/setfacl.1  Fri Oct 26 21:15:36 2018(r339792)
+++ head/bin/setfacl/setfacl.1  Fri Oct 26 21:17:06 2018(r339793)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 10, 2018
+.Dd October 26, 2018
 .Dt SETFACL 1
 .Os
 .Sh NAME
@@ -136,6 +136,8 @@ option is specified, no symbolic links are followed.
 This is the default.
 .It Fl R
 Perform the action recursively on any specified directories.
+When modifying or adding NFSv4 ACL entries, inheritance flags
+are applied only to directories.
 .It Fl x Ar entries | position
 If
 .Ar entries

Modified: head/bin/setfacl/setfacl.c
==
--- head/bin/setfacl/setfacl.c  Fri Oct 26 21:15:36 2018(r339792)
+++ head/bin/setfacl/setfacl.c  Fri Oct 26 21:17:06 2018(r339793)
@@ -27,9 +27,7 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
 #include 
-#include 
 #include 
 #include 
 
@@ -73,6 +71,7 @@ static bool need_mask;
 static acl_type_t acl_type = ACL_TYPE_ACCESS;
 
 static int handle_file(FTS *ftsp, FTSENT *file);
+static acl_t   clear_inheritance_flags(acl_t acl);
 static char**stdin_files(void);
 static voidusage(void);
 
@@ -124,10 +123,57 @@ stdin_files(void)
return (files_list);
 }
 
+/*
+ * Remove any inheritance flags from NFSv4 ACLs when running in recursive
+ * mode.  This is to avoid files being assigned identical ACLs to their
+ * parent directory while also being set to inherit them.
+ *
+ * The acl argument is assumed to be valid.
+ */
+static acl_t
+clear_inheritance_flags(acl_t acl)
+{
+   acl_t nacl;
+   acl_entry_t acl_entry;
+   acl_flagset_t acl_flagset;
+   int acl_brand, entry_id;
+
+   (void)acl_get_brand_np(acl, _brand);
+   if (acl_brand != ACL_BRAND_NFS4)
+   return (acl);
+
+   nacl = acl_dup(acl);
+   if (nacl == NULL) {
+   warn("acl_dup() failed");
+   return (acl);
+   }
+
+   entry_id = ACL_FIRST_ENTRY;
+   while (acl_get_entry(nacl, entry_id, _entry) == 1) {
+   entry_id = ACL_NEXT_ENTRY;
+   if (acl_get_flagset_np(acl_entry, _flagset) != 0) {
+   warn("acl_get_flagset_np() failed");
+   continue;
+   }
+   if (acl_get_flag_np(acl_flagset, ACL_ENTRY_INHERIT_ONLY) == 1) {
+   if (acl_delete_entry(nacl, acl_entry) != 0)
+   warn("acl_delete_entry() failed");
+   continue;
+   }
+   if (acl_delete_flag_np(acl_flagset,
+   ACL_ENTRY_FILE_INHERIT |
+   ACL_ENTRY_DIRECTORY_INHERIT |
+   ACL_ENTRY_NO_PROPAGATE_INHERIT) != 0)
+   warn("acl_delete_flag_np() failed");
+   }
+
+   return (nacl);
+}
+
 static int
 handle_file(FTS *ftsp, FTSENT *file)
 {
-   acl_t acl;
+   acl_t acl, nacl;
acl_entry_t unused_entry;
int local_error, ret;
struct sf_entry *entry;
@@ -193,17 +239,20 @@ handle_file(FTS *ftsp, FTSENT *file)
 
/* Cycle through each option. */
TAILQ_FOREACH(entry, , next) {
-   if (local_error)
-   continue;
-
-   switch(entry->op) {
+   nacl = entry->acl;
+   switch (entry->op) {
case OP_ADD_ACL:
-   local_error += add_acl(entry->acl, entry->entry_number,
-   , file->fts_path);
+   if (R_flag && file->fts_info != FTS_D &&
+   acl_type == ACL_TYPE_NFS4)
+   nacl = clear_inheritance_flags(nacl);
+   local_error += add_acl(nacl, entry->entry_number, ,
+   file->fts_path);
break;
case OP_MERGE_ACL:
-   local_error += merge_acl(entry->acl, ,
-   file->fts_path);
+   if (R_flag && file->fts_info != FTS_D &&
+   acl_type == ACL_TYPE_NFS4)
+   nacl = 

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

2018-10-26 Thread Martin Matuska
Author: mm
Date: Fri Oct 26 21:15:36 2018
New Revision: 339792
URL: https://svnweb.freebsd.org/changeset/base/339792

Log:
  Update vendor/libarchive/dist to git d661131393def793a9919d1e3fd54c9992888bd6
  
  Relevant vendor changes:
RAR5 reader: more maybe-uninitialized size_t fixes for riscv64
 FreeBSD build

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

Modified: vendor/libarchive/dist/libarchive/archive_read_support_format_rar5.c
==
--- vendor/libarchive/dist/libarchive/archive_read_support_format_rar5.c
Fri Oct 26 21:04:17 2018(r339791)
+++ vendor/libarchive/dist/libarchive/archive_read_support_format_rar5.c
Fri Oct 26 21:15:36 2018(r339792)
@@ -1281,8 +1281,12 @@ static int process_head_file(struct archive_read* a, s
 struct archive_entry* entry, size_t block_flags)
 {
 ssize_t extra_data_size = 0;
-size_t data_size, file_flags, file_attr, compression_info, host_os,
-   name_size;
+size_t data_size = 0;
+size_t file_flags = 0;
+size_t file_attr = 0;
+size_t compression_info = 0;
+size_t host_os = 0;
+size_t name_size = 0;
 uint64_t unpacked_size;
 uint32_t mtime = 0, crc;
 int c_method = 0, c_version = 0, is_dir;
@@ -1297,7 +1301,7 @@ static int process_head_file(struct archive_read* a, s
 }
 
 if(block_flags & HFL_EXTRA_DATA) {
-size_t edata_size;
+size_t edata_size = 0;
 if(!read_var_sized(a, _size, NULL))
 return ARCHIVE_EOF;
 
___
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: r339791 - in head: share/man/man4 sys/netinet

2018-10-26 Thread Michael Tuexen
Author: tuexen
Date: Fri Oct 26 21:04:17 2018
New Revision: 339791
URL: https://svnweb.freebsd.org/changeset/base/339791

Log:
  Add initial descriptions for SCTP related MIB variable.
  This work was mostly done by Marie-Helene Kvello-Aune.
  
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D3583

Modified:
  head/share/man/man4/sctp.4
  head/sys/netinet/sctp_sysctl.h

Modified: head/share/man/man4/sctp.4
==
--- head/share/man/man4/sctp.4  Fri Oct 26 21:03:57 2018(r339790)
+++ head/share/man/man4/sctp.4  Fri Oct 26 21:04:17 2018(r339791)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 15, 2006
+.Dd October 10, 2018
 .Dt SCTP 4
 .Os
 .Sh NAME
@@ -145,7 +145,7 @@ with no regard to the ordering of any other message.
 The FreeBSD implementation of
 .Tn SCTP
 also supports the following extensions:
-.Bl -hang -width indent
+.Bl -tag -width "sctp partial reliability"
 .It "sctp partial reliability"
 This extension allows one to have message be skipped and
 not delivered based on some user specified parameters.
@@ -168,7 +168,7 @@ utilization.
 This extension allows a user on either side to reset the
 stream sequence numbers used by any or all streams.
 .El
-.Pp
+.Ss Socket Options
 .Tn SCTP
 supports a number of socket options which can be set with
 .Xr setsockopt 2
@@ -176,7 +176,7 @@ and tested with
 .Xr getsockopt 2
 or
 .Xr sctp_opt_info 3 :
-.Bl -tag -width ".Dv SCTP_SET_PEER_PRIMARY_ADDR"
+.Bl -tag -indent
 .It Dv SCTP_NODELAY
 Under most circumstances,
 .Tn SCTP
@@ -409,6 +409,191 @@ Note that the peer
 endpoint must also support the stream reset extension
 as well.
 .El
+.Ss MIB Variables
+The
+.Tn SCTP
+protocol implements a number of variables in the
+.Va net.inet.sctp
+branch of the
+.Xr sysctl 3
+MIB.
+.Bl -ohang
+.It Sy Congestion Control
+.Bl -tag -width indent
+.It Va default_cc_module
+Default congestion control module.
+Default value is 0.
+The minimum is 0, and the maximum is 3.
+A value of 0 enables the default congestion control algorithm.
+A value of 1 enables the High Speed congestion control algorithm.
+A value of 2 enables the HTCP congestion control algorithm.
+A value of 3 enables the data center congestion control (DCCC) algorithm.
+.It Va initial_cwnd
+Defines the initial congestion window size in MTUs.
+.It Va cwnd_maxburst
+Use congestion control instead of 'blind' logic to limit maximum burst when 
sending.
+Default value is 1. May be set to 0 or 1.
+.It Va ecn_enable
+Enable Explicit Congestion Notification (ECN).
+Default value is 1. May be set to 0 or 1.
+.It Va rttvar_steady_step
+Number of identical bandwidth measurements DCCC takes to try step down the 
congestion window.
+Default value is 20.
+The minimum is 0, and the maximum is 65535.
+.It Va rttvar_eqret
+Whether DCCC reduces the congestion window size when round-trip time and 
bandwidth remain unchanged.
+Default value is 0.
+May be set to 0 or 1.
+.It Va rttvar_bw
+Shift amount DCCC uses for bandwidth smoothing on round-trip-time calculation.
+Default value is 4.
+The minimum is 0, and the maximum is 32.
+.It Va rttvar_rtt
+Shift amount DCCC uses for round-trip-time smoothing on round-trip-time 
calculation.
+Default value is 5.
+The minimum is 0, and the maximum is 32.
+.It Va use_dcccecn
+Enable ECN when using DCCC.
+Default value is 1.
+May be set to 0 or 1.
+.El
+.It Sy Misc
+.Bl -tag -width indent
+.It Va getcred
+Get the ucred of a SCTP connection.
+.It Va assoclist
+List of active SCTP associations.
+.It Va stats
+SCTP statistics (struct sctp_stat).
+.It Va diag_info_code
+Diagnostic information error cause code.
+.It Va blackhole
+Enable SCTP blackholing.
+See
+.Xr blackhole 4
+for more details.
+.It Va buffer_splitting
+Enable send/receive buffer splitting.
+.It Va vtag_time_wait
+Vtag wait time in seconds, 0 to disable.
+.It Va nat_friendly_init
+Enable sending of the NAT-friendly SCTP option on INITs.
+.It Va enable_sack_immediately
+Enable sending of the SACK-IMMEDIATELY bit.
+.It Va udp_tunneling_port
+Set the SCTP/UDP tunneling port.
+.It Va mobility_fasthandoff
+Enable SCTP fast handoff.
+.It Va mobility_base
+Enable SCTP base mobility
+.It Va default_frag_interleave
+Default fragment interleave level.
+.It Va default_ss_module
+Default stream scheduling module.
+.It Va log_level
+Ltrace/KTR trace logging level.
+.It Va max_retran_chunk
+Number of retransmissions of a DATA chunk before an association is aborted.
+.It Va min_residual
+Minimum residual data chunk in second part of split.
+.It Va strict_data_order
+Enforce strict data ordering, abort if control inside data.
+.It Va abort_at_limit
+Abort when one-to-one hits qlimit.
+.It Va hb_max_burst
+Confirmation heartbeat max burst.
+.It Va do_sctp_drain
+Flush chunks in receive queues with TSN higher than the cumulative TSN if the
+system is low on mbufs.
+.It Va max_chained_mbufs
+Default max number of small 

svn commit: r339790 - head/sys/dev/random

2018-10-26 Thread Conrad Meyer
Author: cem
Date: Fri Oct 26 21:03:57 2018
New Revision: 339790
URL: https://svnweb.freebsd.org/changeset/base/339790

Log:
  Fortuna: Add failpoints to simulate initial seeding conditions
  
  Set debug.fail_point.random_fortuna_pre_read=return(1) and
  debug.fail_point.random_fortuna_seeded=return(1) to return to unseeded
  status (sort of).  See the Differential URL for more detail.
  
  The goal is to reproduce e.g. Lev's recent CURRENT report[1] about failing
  newfs arc4random(3) usage (fixed in r338542).
  
  No functional change when failpoints are not set.
  
  [1]: 
https://lists.freebsd.org/pipermail/freebsd-current/2018-September/071067.html
  
  Reported by:  lev
  Reviewed by:  delphij, markm
  Approved by:  secteam (delphij)
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D17047

Modified:
  head/sys/dev/random/fortuna.c

Modified: head/sys/dev/random/fortuna.c
==
--- head/sys/dev/random/fortuna.c   Fri Oct 26 21:00:26 2018
(r339789)
+++ head/sys/dev/random/fortuna.c   Fri Oct 26 21:03:57 2018
(r339790)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 
 #ifdef _KERNEL
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -385,6 +386,18 @@ random_fortuna_pre_read(void)
}
 
 #ifdef _KERNEL
+   /*
+* When set, pretend we do not have enough entropy to reseed yet.
+*/
+   KFAIL_POINT_CODE(DEBUG_FP, random_fortuna_pre_read, {
+   if (RETURN_VALUE != 0) {
+   RANDOM_RESEED_UNLOCK();
+   return;
+   }
+   });
+#endif
+
+#ifdef _KERNEL
fortuna_state.fs_lasttime = now;
 #endif
 
@@ -441,6 +454,14 @@ random_fortuna_read(uint8_t *buf, u_int bytecount)
 bool
 random_fortuna_seeded(void)
 {
+
+#ifdef _KERNEL
+   /* When set, act as if we are not seeded. */
+   KFAIL_POINT_CODE(DEBUG_FP, random_fortuna_seeded, {
+   if (RETURN_VALUE != 0)
+   fortuna_state.fs_counter = UINT128_ZERO;
+   });
+#endif
 
return (!uint128_is_zero(fortuna_state.fs_counter));
 }
___
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: r339789 - head/sys/dev/random

2018-10-26 Thread Conrad Meyer
Author: cem
Date: Fri Oct 26 21:00:26 2018
New Revision: 339789
URL: https://svnweb.freebsd.org/changeset/base/339789

Log:
  fortuna: Drop global lock to zero stack variables
  
  Also drop explicit zeroing of hash context -- hash finish() operation is
  expected to do this.
  
  PR:   230877
  Suggested by: delphij@
  Reviewed by:  delphij, markm
  Approved by:  secteam (delphij)
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D16986

Modified:
  head/sys/dev/random/fortuna.c

Modified: head/sys/dev/random/fortuna.c
==
--- head/sys/dev/random/fortuna.c   Fri Oct 26 20:55:01 2018
(r339788)
+++ head/sys/dev/random/fortuna.c   Fri Oct 26 21:00:26 2018
(r339789)
@@ -374,47 +374,50 @@ random_fortuna_pre_read(void)
now = getsbinuptime();
 #endif
 
-   if (fortuna_state.fs_pool[0].fsp_length >= fortuna_state.fs_minpoolsize
+   if (fortuna_state.fs_pool[0].fsp_length < fortuna_state.fs_minpoolsize
 #ifdef _KERNEL
/* FS - Use 'getsbinuptime()' to prevent reseed-spamming. */
-   && (now - fortuna_state.fs_lasttime > SBT_1S/10)
+   || (now - fortuna_state.fs_lasttime <= SBT_1S/10)
 #endif
) {
+   RANDOM_RESEED_UNLOCK();
+   return;
+   }
+
 #ifdef _KERNEL
-   fortuna_state.fs_lasttime = now;
+   fortuna_state.fs_lasttime = now;
 #endif
 
-   /* FS - ReseedCNT = ReseedCNT + 1 */
-   fortuna_state.fs_reseedcount++;
-   /* s = \epsilon at start */
-   for (i = 0; i < RANDOM_FORTUNA_NPOOLS; i++) {
-   /* FS - if Divides(ReseedCnt, 2^i) ... */
-   if ((fortuna_state.fs_reseedcount % (1 << i)) == 0) {
-   /*-
-* FS - temp = (P_i)
-*  - P_i = \epsilon
-*  - s = s|H(temp)
-*/
-   
randomdev_hash_finish(_state.fs_pool[i].fsp_hash, temp);
-   
randomdev_hash_init(_state.fs_pool[i].fsp_hash);
-   fortuna_state.fs_pool[i].fsp_length = 0;
-   randomdev_hash_init();
-   randomdev_hash_iterate(, temp, 
RANDOM_KEYSIZE);
-   randomdev_hash_finish(, s + 
i*RANDOM_KEYSIZE_WORDS);
-   } else
-   break;
-   }
+   /* FS - ReseedCNT = ReseedCNT + 1 */
+   fortuna_state.fs_reseedcount++;
+   /* s = \epsilon at start */
+   for (i = 0; i < RANDOM_FORTUNA_NPOOLS; i++) {
+   /* FS - if Divides(ReseedCnt, 2^i) ... */
+   if ((fortuna_state.fs_reseedcount % (1 << i)) == 0) {
+   /*-
+   * FS - temp = (P_i)
+   *  - P_i = \epsilon
+   *  - s = s|H(temp)
+   */
+   
randomdev_hash_finish(_state.fs_pool[i].fsp_hash, temp);
+   randomdev_hash_init(_state.fs_pool[i].fsp_hash);
+   fortuna_state.fs_pool[i].fsp_length = 0;
+   randomdev_hash_init();
+   randomdev_hash_iterate(, temp, RANDOM_KEYSIZE);
+   randomdev_hash_finish(, s + 
i*RANDOM_KEYSIZE_WORDS);
+   } else
+   break;
+   }
 #ifdef _KERNEL
-   SDT_PROBE2(random, fortuna, event_processor, debug, 
fortuna_state.fs_reseedcount, fortuna_state.fs_pool);
+   SDT_PROBE2(random, fortuna, event_processor, debug, 
fortuna_state.fs_reseedcount, fortuna_state.fs_pool);
 #endif
-   /* FS */
-   random_fortuna_reseed_internal(s, i);
-   /* Clean up and secure */
-   explicit_bzero(s, sizeof(s));
-   explicit_bzero(temp, sizeof(temp));
-   explicit_bzero(, sizeof(context));
-   }
+   /* FS */
+   random_fortuna_reseed_internal(s, i);
RANDOM_RESEED_UNLOCK();
+
+   /* Clean up and secure */
+   explicit_bzero(s, sizeof(s));
+   explicit_bzero(temp, sizeof(temp));
 }
 
 /*-
___
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: r339788 - head/sys/dev/random

2018-10-26 Thread Conrad Meyer
Author: cem
Date: Fri Oct 26 20:55:01 2018
New Revision: 339788
URL: https://svnweb.freebsd.org/changeset/base/339788

Log:
  Fortuna: fix a correctness issue in reseed (fortuna_pre_read)
  
  'i' counts the number of pools included in the array 's'.  Passing 'i+1' to
  reseed_internal() as the number of blocks in 's' is a bogus overrun of the
  initialized portion of 's' -- technically UB.
  
  I found this via code inspection, referencing ยง9.5.2 "Pools" of the Fortuna
  chapter, but I would expect Coverity to notice the same issue.
  Unfortunately, it doesn't appear to.
  
  Reviewed by:  markm
  Approved by:  secteam (gordon)
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D16985

Modified:
  head/sys/dev/random/fortuna.c

Modified: head/sys/dev/random/fortuna.c
==
--- head/sys/dev/random/fortuna.c   Fri Oct 26 20:53:01 2018
(r339787)
+++ head/sys/dev/random/fortuna.c   Fri Oct 26 20:55:01 2018
(r339788)
@@ -408,7 +408,7 @@ random_fortuna_pre_read(void)
SDT_PROBE2(random, fortuna, event_processor, debug, 
fortuna_state.fs_reseedcount, fortuna_state.fs_pool);
 #endif
/* FS */
-   random_fortuna_reseed_internal(s, i < RANDOM_FORTUNA_NPOOLS ? i 
+ 1 : RANDOM_FORTUNA_NPOOLS);
+   random_fortuna_reseed_internal(s, i);
/* Clean up and secure */
explicit_bzero(s, sizeof(s));
explicit_bzero(temp, sizeof(temp));
___
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: r339787 - head/sys/crypto/rijndael

2018-10-26 Thread Conrad Meyer
Author: cem
Date: Fri Oct 26 20:53:01 2018
New Revision: 339787
URL: https://svnweb.freebsd.org/changeset/base/339787

Log:
  rijndael (AES): Avoid leaking sensitive data on kernel stack
  
  Noticed this investigating Fortuna.  Remove useless duplicate stack copies
  of sensitive contents when possible, or if not possible, be sure to zero
  them out when we're finished.
  
  Approved by:  secteam (gordon)
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D16935

Modified:
  head/sys/crypto/rijndael/rijndael-api-fst.c

Modified: head/sys/crypto/rijndael/rijndael-api-fst.c
==
--- head/sys/crypto/rijndael/rijndael-api-fst.c Fri Oct 26 20:07:46 2018
(r339786)
+++ head/sys/crypto/rijndael/rijndael-api-fst.c Fri Oct 26 20:53:01 2018
(r339787)
@@ -36,7 +36,6 @@ typedef u_int8_t  BYTE;
 
 int rijndael_makeKey(keyInstance *key, BYTE direction, int keyLen,
const char *keyMaterial) {
-   u_int8_t cipherKey[RIJNDAEL_MAXKB];
 
if (key == NULL) {
return BAD_KEY_INSTANCE;
@@ -59,13 +58,12 @@ int rijndael_makeKey(keyInstance *key, BYTE direction,
}
 
/* initialize key schedule: */
-   memcpy(cipherKey, key->keyMaterial, keyLen/8);
if (direction == DIR_ENCRYPT) {
-   key->Nr = rijndaelKeySetupEnc(key->rk, cipherKey, keyLen);
+   key->Nr = rijndaelKeySetupEnc(key->rk, key->keyMaterial, 
keyLen);
} else {
-   key->Nr = rijndaelKeySetupDec(key->rk, cipherKey, keyLen);
+   key->Nr = rijndaelKeySetupDec(key->rk, key->keyMaterial, 
keyLen);
}
-   rijndaelKeySetupEnc(key->ek, cipherKey, keyLen);
+   rijndaelKeySetupEnc(key->ek, key->keyMaterial, keyLen);
return TRUE;
 }
 
@@ -186,6 +184,7 @@ int rijndael_blockEncrypt(cipherInstance *cipher, keyI
return BAD_CIPHER_STATE;
}
 
+   explicit_bzero(block, sizeof(block));
return 128*numBlocks;
 }
 
@@ -258,6 +257,7 @@ int rijndael_padEncrypt(cipherInstance *cipher, keyIns
return BAD_CIPHER_STATE;
}
 
+   explicit_bzero(block, sizeof(block));
return 16*(numBlocks + 1);
 }
 
@@ -357,12 +357,13 @@ int rijndael_blockDecrypt(cipherInstance *cipher, keyI
return BAD_CIPHER_STATE;
}
 
+   explicit_bzero(block, sizeof(block));
return 128*numBlocks;
 }
 
 int rijndael_padDecrypt(cipherInstance *cipher, keyInstance *key,
const BYTE *input, int inputOctets, BYTE *outBuffer) {
-   int i, numBlocks, padLen;
+   int i, numBlocks, padLen, rval;
u_int8_t block[16];
u_int32_t iv[4];
 
@@ -392,11 +393,13 @@ int rijndael_padDecrypt(cipherInstance *cipher, keyIns
rijndaelDecrypt(key->rk, key->Nr, input, block);
padLen = block[15];
if (padLen >= 16) {
-   return BAD_DATA;
+   rval = BAD_DATA;
+   goto out;
}
for (i = 16 - padLen; i < 16; i++) {
if (block[i] != padLen) {
-   return BAD_DATA;
+   rval = BAD_DATA;
+   goto out;
}
}
memcpy(outBuffer, block, 16 - padLen);
@@ -424,11 +427,13 @@ int rijndael_padDecrypt(cipherInstance *cipher, keyIns
((u_int32_t*)block)[3] ^= iv[3];
padLen = block[15];
if (padLen <= 0 || padLen > 16) {
-   return BAD_DATA;
+   rval = BAD_DATA;
+   goto out;
}
for (i = 16 - padLen; i < 16; i++) {
if (block[i] != padLen) {
-   return BAD_DATA;
+   rval = BAD_DATA;
+   goto out;
}
}
memcpy(outBuffer, block, 16 - padLen);
@@ -438,5 +443,9 @@ int rijndael_padDecrypt(cipherInstance *cipher, keyIns
return BAD_CIPHER_STATE;
}
 
-   return 16*numBlocks - padLen;
+   rval = 16*numBlocks - padLen;
+
+out:
+   explicit_bzero(block, sizeof(block));
+   return rval;
 }
___
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: r339786 - head/sys/kern

2018-10-26 Thread Conrad Meyer
Author: cem
Date: Fri Oct 26 20:07:46 2018
New Revision: 339786
URL: https://svnweb.freebsd.org/changeset/base/339786

Log:
  poll: Unify userspace pollfd pointer name
  
  Some of the poll code used 'fds' and some used 'ufds' to refer to the
  uap->fds userspace pointer that was passed around to subroutines.  Some of
  the poll code used 'fds' to refer to the kernel memory pollfd arrays, which
  seemed unnecessarily confusing.
  
  Unify on 'ufds' to refer to the userspace pollfd array.
  
  Additionally, 'bits' is not an accurate description of the kernel pollfd
  array in kern_poll, so rename that to 'kfds'.  Finally, clean up some logic
  with mallocarray() and nitems().
  
  No functional change.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D17670

Modified:
  head/sys/kern/sys_generic.c

Modified: head/sys/kern/sys_generic.c
==
--- head/sys/kern/sys_generic.c Fri Oct 26 20:03:59 2018(r339785)
+++ head/sys/kern/sys_generic.c Fri Oct 26 20:07:46 2018(r339786)
@@ -1304,16 +1304,15 @@ sys_poll(struct thread *td, struct poll_args *uap)
 }
 
 int
-kern_poll(struct thread *td, struct pollfd *fds, u_int nfds,
+kern_poll(struct thread *td, struct pollfd *ufds, u_int nfds,
 struct timespec *tsp, sigset_t *uset)
 {
-   struct pollfd *bits;
-   struct pollfd smallbits[32];
+   struct pollfd *kfds;
+   struct pollfd stackfds[32];
sbintime_t sbt, precision, tmp;
time_t over;
struct timespec ts;
int error;
-   size_t ni;
 
precision = 0;
if (tsp != NULL) {
@@ -1342,12 +1341,11 @@ kern_poll(struct thread *td, struct pollfd *fds, u_int
 
if (nfds > maxfilesperproc && nfds > FD_SETSIZE) 
return (EINVAL);
-   ni = nfds * sizeof(struct pollfd);
-   if (ni > sizeof(smallbits))
-   bits = malloc(ni, M_TEMP, M_WAITOK);
+   if (nfds > nitems(stackfds))
+   kfds = mallocarray(nfds, sizeof(*kfds), M_TEMP, M_WAITOK);
else
-   bits = smallbits;
-   error = copyin(fds, bits, ni);
+   kfds = stackfds;
+   error = copyin(ufds, kfds, nfds * sizeof(*kfds));
if (error)
goto done;
 
@@ -1370,7 +1368,7 @@ kern_poll(struct thread *td, struct pollfd *fds, u_int
seltdinit(td);
/* Iterate until the timeout expires or descriptors become ready. */
for (;;) {
-   error = pollscan(td, bits, nfds);
+   error = pollscan(td, kfds, nfds);
if (error || td->td_retval[0] != 0)
break;
error = seltdwait(td, sbt, precision);
@@ -1389,13 +1387,13 @@ done:
if (error == EWOULDBLOCK)
error = 0;
if (error == 0) {
-   error = pollout(td, bits, fds, nfds);
+   error = pollout(td, kfds, ufds, nfds);
if (error)
goto out;
}
 out:
-   if (ni > sizeof(smallbits))
-   free(bits, M_TEMP);
+   if (nfds > nitems(stackfds))
+   free(kfds, M_TEMP);
return (error);
 }
 
___
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: r339785 - head/sbin/dumpon

2018-10-26 Thread Conrad Meyer
Author: cem
Date: Fri Oct 26 20:03:59 2018
New Revision: 339785
URL: https://svnweb.freebsd.org/changeset/base/339785

Log:
  dumpon.8: Significantly revamp page
  
  Start with a short summary and cover the options in a standard list style.
  
  Organize sections by common focus and prioritize more useful information
  closer to the top.
  
  Flesh out authors, history, caveats, and security considerations sections.
  
  Reviewed by:  markj, eadler (previous version)
  Differential Revision:https://reviews.freebsd.org/D17679

Modified:
  head/sbin/dumpon/dumpon.8

Modified: head/sbin/dumpon/dumpon.8
==
--- head/sbin/dumpon/dumpon.8   Fri Oct 26 19:53:59 2018(r339784)
+++ head/sbin/dumpon/dumpon.8   Fri Oct 26 20:03:59 2018(r339785)
@@ -59,27 +59,120 @@
 .Sh DESCRIPTION
 The
 .Nm
-utility is used to specify a device where the kernel can save a crash
-dump in the case of a panic.
+utility is used to configure where the kernel can save a crash dump in the case
+of a panic.
 .Pp
-Calls to
+System administrators should typically configure
 .Nm
-normally occur from the system multi-user initialization file
-.Pa /etc/rc ,
-controlled by the
-.Dq dumpdev
+in a persistent fashion using the
+.Xr rc.conf 5
+variables
+.Va dumpdev
 and
-.Dq dumpon_flags
-variables in the boot time configuration file
-.Pa /etc/rc.conf .
+.Va dumpon_flags .
+For more information on this usage, see
+.Xr rc.conf 5 .
+.Ss General options
+.Bl -tag -width _k_pubkey
+.It Fl k Ar pubkey
+Configure encrypted kernel dumps.
 .Pp
+A random, one-time symmetric key is automatically generated for bulk kernel
+dump encryption every time
+.Nm
+is used.
+The provided
+.Ar pubkey
+is used to encrypt a copy of the symmetric key.
+The encrypted dump contents consist of a standard dump header, the
+pubkey-encrypted symmetric key contents, and the symmetric key encrypted core
+dump contents.
+.Pp
+As a result, only someone with the corresponding private key can decrypt the 
symmetric key.
+The symmetric key is necessary to decrypt the kernel core.
+The goal of the mechanism is to provide confidentiality.
+.Pp
+The
+.Va pubkey
+file should be a PEM-formatted RSA key of at least 1024 bits.
+.It Fl l
+List the currently configured dump device, or /dev/null if no device is
+configured.
+.It Fl v
+Enable verbose mode.
+.It Fl Z
+Enable compression (Zstandard).
+.It Fl z
+Enable compression (gzip).
+Only one compression method may be enabled at a time, so
+.Fl z
+is incompatible with
+.Fl Z .
+.Pp
+Zstandard provides superior compression ratio and performance.
+.El
+.Ss Netdump
+.Nm
+may also configure the kernel to dump to a remote
+.Xr netdumpd 8
+server.
+(The
+.Xr netdumpd 8
+server is available in ports.)
+.Xr netdump 4
+eliminates the need to reserve space for crash dumps.
+It is especially useful in diskless environments.
+When
+.Nm
+is used to configure netdump, the
+.Ar device
+(or
+.Ar iface )
+parameter should specify a network interface (e.g.,
+.Va igb1 ) .
+The specified NIC must be up (online) to configure netdump.
+.Pp
+.Xr netdump 4
+specific options include:
+.Bl -tag -width _g_gateway
+.It Fl c Ar client
+The local IP address of the
+.Xr netdump 4
+client.
+.It Fl g Ar gateway
+Optional.
+If not specified, it is assumed that the
+.Ar server
+is on the same link as the
+.Ar client .
+.Pp
+If specified,
+.Ar gateway
+is the address of the first-hop router between the
+.Ar client
+and the
+.Ar server .
+The special value
+.Dv Dq default
+indicates that the currently configured system default route should be used.
+.It Fl s Ar server
+The IP address of the
+.Xr netdumpd 8
+server.
+.El
+.Pp
+All of these options can be specified in the
+.Xr rc.conf 5
+variable
+.Va dumpon_flags .
+.Ss Minidumps
 The default type of kernel crash dump is the mini crash dump.
 Mini crash dumps hold only memory pages in use by the kernel.
 Alternatively, full memory dumps can be enabled by setting the
 .Va debug.minidump
 .Xr sysctl 8
 variable to 0.
-.Pp
+.Ss Full dumps
 For systems using full memory dumps, the size of the specified dump
 device must be at least the size of physical memory.
 Even though an additional 64 kB header is added to the dump, the BIOS for a
@@ -93,155 +186,18 @@ total amount of physical memory as reported by the
 .Va hw.physmem
 .Xr sysctl 8
 variable.
-.Pp
-.Nm
-is used to configure a local storage device as the dump device.
-With additional parameters, the kernel can instead be configured to
-transmit a dump to a remote server using
-.Xr netdump 4 .
-This eliminates the need to reserve space for saving crash dumps and
-is especially useful in diskless environments.
-The
-.Xr netdump 4
-server address is specified with
-.Fl s Ar server ,
-and the local address is specified with
-.Fl c Ar client .
-The
-.Fl g Ar gateway
-parameter may be used to specify a first-hop router to the server,
-or to specify that the currently configured default 

svn commit: r339784 - head/sbin/dumpon

2018-10-26 Thread Conrad Meyer
Author: cem
Date: Fri Oct 26 19:53:59 2018
New Revision: 339784
URL: https://svnweb.freebsd.org/changeset/base/339784

Log:
  dumpon(8): Provide seatbelt against weak RSA keys
  
  The premise of dumpon -k foo.pem is that dump contents will be confidential
  except to anyone holding the corresponding RSA private key.
  
  This guarantee breaks down when weak RSA keys are used.  Small RSA keys
  (e.g. 512 bits) can be broken on a single personal computer in tractible
  time.  Marginal RSA keys (768 bits) can be broken by EC2 and a few dollars.
  Even 1024 bit keys can probably be broken by sophisticated and wealthy
  attackers.
  
  NIST SP800-57 (2016) recommends a minimum of 2048 bit RSA keys, and
  estimates this provides 112 bits of security.
  
  It would also be good to protect users from weak values of 'e' (i.e., 3) and
  perhaps sanity check that their public key .pem does not accidentally
  contain their private key as well.  These considerations are left as future
  work.
  
  Reviewed by:  markj, darius AT dons.net.au (previous version)
  Discussed with:   bjk
  Differential Revision:https://reviews.freebsd.org/D17678

Modified:
  head/sbin/dumpon/dumpon.8
  head/sbin/dumpon/dumpon.c

Modified: head/sbin/dumpon/dumpon.8
==
--- head/sbin/dumpon/dumpon.8   Fri Oct 26 19:16:17 2018(r339783)
+++ head/sbin/dumpon/dumpon.8   Fri Oct 26 19:53:59 2018(r339784)
@@ -28,7 +28,7 @@
 .\" From: @(#)swapon.8 8.1 (Berkeley) 6/5/93
 .\" $FreeBSD$
 .\"
-.Dd June 13, 2018
+.Dd October 26, 2018
 .Dt DUMPON 8
 .Os
 .Sh NAME
@@ -348,3 +348,15 @@ is taken, it is not possible to send crash dumps direc
 It is currently not possible to configure both compression and encryption.
 The encrypted dump format assumes that the kernel dump size is a multiple
 of the cipher block size, which may not be true when the dump is compressed.
+.Sh SECURITY CONSIDERATIONS
+RSA keys smaller than 1024 bits are practical to factor and therefore weak.
+Even 1024 bit keys may not be large enough to ensure privacy for many
+years, so NIST recommends a minimum of 2048 bit RSA keys.
+As a seatbelt,
+.Nm
+prevents users from configuring encrypted kernel dumps with weak RSA keys.
+If you do not care for cryptographic privacy guarantees, just use
+.Nm
+without specifying a
+.Fl k Ar pubkey
+option.

Modified: head/sbin/dumpon/dumpon.c
==
--- head/sbin/dumpon/dumpon.c   Fri Oct 26 19:16:17 2018(r339783)
+++ head/sbin/dumpon/dumpon.c   Fri Oct 26 19:53:59 2018(r339784)
@@ -243,6 +243,30 @@ genkey(const char *pubkeyfile, struct diocskerneldump_
if (pubkey == NULL)
errx(1, "Unable to read data from %s.", pubkeyfile);
 
+   /*
+* RSA keys under ~1024 bits are trivially factorable (2018).  OpenSSL
+* provides an API for RSA keys to estimate the symmetric-cipher
+* "equivalent" bits of security (defined in NIST SP800-57), which as
+* of this writing equates a 2048-bit RSA key to 112 symmetric cipher
+* bits.
+*
+* Use this API as a seatbelt to avoid suggesting to users that their
+* privacy is protected by encryption when the key size is insufficient
+* to prevent compromise via factoring.
+*
+* Future work: Sanity check for weak 'e', and sanity check for absence
+* of 'd' (i.e., the supplied key is a public key rather than a full
+* keypair).
+*/
+#if OPENSSL_VERSION_NUMBER >= 0x1010L
+   if (RSA_security_bits(pubkey) < 112)
+#else
+   if (RSA_size(pubkey) * 8 < 2048)
+#endif
+   errx(1, "Small RSA keys (you provided: %db) can be "
+   "factored cheaply.  Please generate a larger key.",
+   RSA_size(pubkey) * 8);
+
kdap->kda_encryptedkeysize = RSA_size(pubkey);
if (kdap->kda_encryptedkeysize > KERNELDUMP_ENCKEY_MAX_SIZE) {
errx(1, "Public key has to be at most %db long.",
___
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: r339783 - head/usr.sbin/ngctl

2018-10-26 Thread Devin Teske
Author: dteske
Date: Fri Oct 26 19:16:17 2018
New Revision: 339783
URL: https://svnweb.freebsd.org/changeset/base/339783

Log:
  Add blank line after each item in "ngctl ls -l"
  
  The output of "ngctl ls -l" is hard to read. To make it easier, add a blank
  line after each listed item much how traditional "ls -l" does when listing
  the contents of multiple directories.
  
  Sponsored by: Smule, Inc.

Modified:
  head/usr.sbin/ngctl/list.c

Modified: head/usr.sbin/ngctl/list.c
==
--- head/usr.sbin/ngctl/list.c  Fri Oct 26 19:03:30 2018(r339782)
+++ head/usr.sbin/ngctl/list.c  Fri Oct 26 19:16:17 2018(r339783)
@@ -125,6 +125,8 @@ ListCmd(int ac, char **av)
break;
ninfo++;
nlist->numnames--;
+   if (nlist->numnames > 0)
+   printf("\n");
}
} else {
while (nlist->numnames > 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: r339782 - head/tests/sys/acl

2018-10-26 Thread Mark Johnston
Author: markj
Date: Fri Oct 26 19:03:30 2018
New Revision: 339782
URL: https://svnweb.freebsd.org/changeset/base/339782

Log:
  Update and re-enable ACL tests following r332396 and r339781.
  
  PR:   229930
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/tests/sys/acl/Makefile
  head/tests/sys/acl/tools-nfs4-psarc.test
  head/tests/sys/acl/tools-nfs4.test
  head/tests/sys/acl/tools-posix.test

Modified: head/tests/sys/acl/Makefile
==
--- head/tests/sys/acl/Makefile Fri Oct 26 19:01:52 2018(r339781)
+++ head/tests/sys/acl/Makefile Fri Oct 26 19:03:30 2018(r339782)
@@ -14,11 +14,9 @@ ${PACKAGE}FILES+=tools-posix.test
 
 SCRIPTS+=  run
 
-# Disable 00 and 02 until they've been updated for setfacl's new behavior
-# PR 229930 tests/sys/acl/00:main fails in CI due to unexpected error message
-# TAP_TESTS_SH+=   00
-# TAP_TESTS_SH+=   02
+TAP_TESTS_SH+= 00
 TAP_TESTS_SH+= 01
+TAP_TESTS_SH+= 02
 TAP_TESTS_SH+= 03
 TAP_TESTS_SH+= 04
 

Modified: head/tests/sys/acl/tools-nfs4-psarc.test
==
--- head/tests/sys/acl/tools-nfs4-psarc.testFri Oct 26 19:01:52 2018
(r339781)
+++ head/tests/sys/acl/tools-nfs4-psarc.testFri Oct 26 19:03:30 2018
(r339782)
@@ -186,7 +186,7 @@ $ ls -l xxx yyy zzz | cut -d' ' -f1
 > -rw-r--r--
 
 $ setfacl -m u:42:x:allow,g:43:w:allow nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory
@@ -215,7 +215,7 @@ $ getfacl -nq nnn xxx yyy zzz
 >  everyone@:r-a-R-c--s:---:allow
 
 $ setfacl -b nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory

Modified: head/tests/sys/acl/tools-nfs4.test
==
--- head/tests/sys/acl/tools-nfs4.test  Fri Oct 26 19:01:52 2018
(r339781)
+++ head/tests/sys/acl/tools-nfs4.test  Fri Oct 26 19:03:30 2018
(r339782)
@@ -214,7 +214,7 @@ $ ls -l xxx yyy zzz | cut -d' ' -f1
 > -rw-r--r--
 
 $ setfacl -m u:42:x:allow,g:43:w:allow nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory
@@ -252,7 +252,7 @@ $ getfacl -nq nnn xxx yyy zzz
 >  everyone@:r-a-R-c--s:---:allow
 
 $ setfacl -b nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory

Modified: head/tests/sys/acl/tools-posix.test
==
--- head/tests/sys/acl/tools-posix.test Fri Oct 26 19:01:52 2018
(r339781)
+++ head/tests/sys/acl/tools-posix.test Fri Oct 26 19:03:30 2018
(r339782)
@@ -226,7 +226,7 @@ $ ls -l xxx yyy zzz | cut -d' ' -f1
 > -rw-r--r--
 
 $ setfacl -m u:42:x,g:43:w nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory
@@ -258,7 +258,7 @@ $ getfacl -nq nnn xxx yyy zzz
 > other::r--
 
 $ setfacl -b nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory
@@ -267,7 +267,7 @@ $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > -rw-r--r--+
 
 $ setfacl -bn nnn xxx yyy zzz
-> setfacl: nnn: stat() failed: No such file or directory
+> setfacl: nnn: acl_get_file() failed: No such file or directory
 
 $ ls -l nnn xxx yyy zzz | cut -d' ' -f1
 > ls: nnn: No such file or directory
___
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: r339781 - head/bin/setfacl

2018-10-26 Thread Mark Johnston
Author: markj
Date: Fri Oct 26 19:01:52 2018
New Revision: 339781
URL: https://svnweb.freebsd.org/changeset/base/339781

Log:
  Don't print pathconf() errors if the target file doesn't exist.
  
  The subsequent acl_get_file(3) call will simply echo the same error.
  
  PR:   229930
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/bin/setfacl/setfacl.c

Modified: head/bin/setfacl/setfacl.c
==
--- head/bin/setfacl/setfacl.c  Fri Oct 26 18:56:58 2018(r339780)
+++ head/bin/setfacl/setfacl.c  Fri Oct 26 19:01:52 2018(r339781)
@@ -174,8 +174,8 @@ handle_file(FTS *ftsp, FTSENT *file)
} else if (ret == 0) {
if (acl_type == ACL_TYPE_NFS4)
acl_type = ACL_TYPE_ACCESS;
-   } else if (ret < 0 && errno != EINVAL) {
-   warn("%s: pathconf(..., _PC_ACL_NFS4) failed",
+   } else if (ret < 0 && errno != EINVAL && errno != ENOENT) {
+   warn("%s: pathconf(_PC_ACL_NFS4) failed",
file->fts_path);
}
 
___
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: r339780 - head/bin/setfacl

2018-10-26 Thread Mark Johnston
Author: markj
Date: Fri Oct 26 18:56:58 2018
New Revision: 339780
URL: https://svnweb.freebsd.org/changeset/base/339780

Log:
  Avoid leaking memory in error paths.
  
  CID:  1390906
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/bin/setfacl/setfacl.c

Modified: head/bin/setfacl/setfacl.c
==
--- head/bin/setfacl/setfacl.c  Fri Oct 26 17:59:25 2018(r339779)
+++ head/bin/setfacl/setfacl.c  Fri Oct 26 18:56:58 2018(r339780)
@@ -252,6 +252,8 @@ handle_file(FTS *ftsp, FTSENT *file)
}
}
 
+   ret = 0;
+
/*
 * Don't try to set an empty default ACL; it will always fail.
 * Use acl_delete_def_file(3) instead.
@@ -261,34 +263,33 @@ handle_file(FTS *ftsp, FTSENT *file)
if (acl_delete_def_file(file->fts_accpath) == -1) {
warn("%s: acl_delete_def_file() failed",
file->fts_path);
-   return (1);
+   ret = 1;
}
-   return (0);
+   goto out;
}
 
/* Don't bother setting the ACL if something is broken. */
if (local_error) {
-   return (1);
-   }
-
-   if (acl_type != ACL_TYPE_NFS4 && need_mask &&
+   ret = 1;
+   } else if (acl_type != ACL_TYPE_NFS4 && need_mask &&
set_acl_mask(, file->fts_path) == -1) {
warnx("%s: failed to set ACL mask", file->fts_path);
-   return (1);
+   ret = 1;
} else if (follow_symlink) {
if (acl_set_file(file->fts_accpath, acl_type, acl) == -1) {
warn("%s: acl_set_file() failed", file->fts_path);
-   return (1);
+   ret = 1;
}
} else {
if (acl_set_link_np(file->fts_accpath, acl_type, acl) == -1) {
warn("%s: acl_set_link_np() failed", file->fts_path);
-   return (1);
+   ret = 1;
}
}
 
+out:
acl_free(acl);
-   return (0);
+   return (ret);
 }
 
 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: r339779 - in head/sys: compat/freebsd32 fs/devfs kern sys

2018-10-26 Thread Brooks Davis
Author: brooks
Date: Fri Oct 26 17:59:25 2018
New Revision: 339779
URL: https://svnweb.freebsd.org/changeset/base/339779

Log:
  Move 32-bit compat support for FIODGNAME to the right place.
  
  ioctl(2) commands only have meaning in the context of a file descriptor
  so translating them in the syscall layer is incorrect.
  
  The new handler users an accessor to retrieve/construct a pointer from
  the last member of the passed structure and relies on type punning to
  access the other member which requires no translation.
  
  Unlike r339174 this change supports both places FIODGNAME is handled.
  
  Reviewed by:  kib
  Obtained from:CheriBSD
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D17475

Modified:
  head/sys/compat/freebsd32/freebsd32_ioctl.c
  head/sys/compat/freebsd32/freebsd32_ioctl.h
  head/sys/fs/devfs/devfs_vnops.c
  head/sys/kern/tty_pts.c
  head/sys/sys/filio.h

Modified: head/sys/compat/freebsd32/freebsd32_ioctl.c
==
--- head/sys/compat/freebsd32/freebsd32_ioctl.c Fri Oct 26 16:34:19 2018
(r339778)
+++ head/sys/compat/freebsd32/freebsd32_ioctl.c Fri Oct 26 17:59:25 2018
(r339779)
@@ -59,22 +59,6 @@ __FBSDID("$FreeBSD$");
 CTASSERT(sizeof(struct mem_range_op32) == 12);
 
 static int
-freebsd32_ioctl_fiodgname(struct thread *td,
-struct freebsd32_ioctl_args *uap, struct file *fp)
-{
-   struct fiodgname_arg fgn;
-   struct fiodgname_arg32 fgn32;
-   int error;
-
-   if ((error = copyin(uap->data, , sizeof fgn32)) != 0)
-   return (error);
-   CP(fgn32, fgn, len);
-   PTRIN_CP(fgn32, fgn, buf);
-   error = fo_ioctl(fp, FIODGNAME, (caddr_t), td->td_ucred, td);
-   return (error);
-}
-
-static int
 freebsd32_ioctl_memrange(struct thread *td,
 struct freebsd32_ioctl_args *uap, struct file *fp)
 {
@@ -237,10 +221,6 @@ freebsd32_ioctl(struct thread *td, struct freebsd32_io
}
 
switch (uap->com) {
-   case FIODGNAME_32:
-   error = freebsd32_ioctl_fiodgname(td, uap, fp);
-   break;
-
case MEMRANGE_GET32:/* FALLTHROUGH */
case MEMRANGE_SET32:
error = freebsd32_ioctl_memrange(td, uap, fp);

Modified: head/sys/compat/freebsd32/freebsd32_ioctl.h
==
--- head/sys/compat/freebsd32/freebsd32_ioctl.h Fri Oct 26 16:34:19 2018
(r339778)
+++ head/sys/compat/freebsd32/freebsd32_ioctl.h Fri Oct 26 17:59:25 2018
(r339779)
@@ -38,11 +38,6 @@
 
 typedef __uint32_t caddr_t32;
 
-struct fiodgname_arg32 {
-   int len;
-   caddr_t32   buf;
-};
-
 struct mem_range_op32
 {
caddr_t32   mo_desc;
@@ -60,7 +55,6 @@ struct pci_bar_mmap32 {
int pbm_memattr;
 };
 
-#defineFIODGNAME_32_IOW('f', 120, struct fiodgname_arg32)
 #defineMEMRANGE_GET32  _IOWR('m', 50, struct mem_range_op32)
 #defineMEMRANGE_SET32  _IOW('m', 51, struct mem_range_op32)
 #defineSG_IO_32_IOWR(SGIOC, 0x85, struct sg_io_hdr32)

Modified: head/sys/fs/devfs/devfs_vnops.c
==
--- head/sys/fs/devfs/devfs_vnops.c Fri Oct 26 16:34:19 2018
(r339778)
+++ head/sys/fs/devfs/devfs_vnops.c Fri Oct 26 17:59:25 2018
(r339779)
@@ -767,6 +767,29 @@ devfs_ioctl_f(struct file *fp, u_long com, void *data,
return (error);
 }
 
+void *
+fiodgname_buf_get_ptr(void *fgnp, u_long com)
+{
+   union {
+   struct fiodgname_argfgn;
+#ifdef COMPAT_FREEBSD32
+   struct fiodgname_arg32  fgn32;
+#endif
+   } *fgnup;
+
+   fgnup = fgnp;
+   switch (com) {
+   case FIODGNAME:
+   return (fgnup->fgn.buf);
+#ifdef COMPAT_FREEBSD32
+   case FIODGNAME_32:
+   return ((void *)(uintptr_t)fgnup->fgn32.buf);
+#endif
+   default:
+   panic("Unhandled ioctl command %ld", com);
+   }
+}
+
 static int
 devfs_ioctl(struct vop_ioctl_args *ap)
 {
@@ -789,24 +812,27 @@ devfs_ioctl(struct vop_ioctl_args *ap)
KASSERT(dev->si_refcount > 0,
("devfs: un-referenced struct cdev *(%s)", devtoname(dev)));
 
-   if (com == FIODTYPE) {
+   switch (com) {
+   case FIODTYPE:
*(int *)ap->a_data = dsw->d_flags & D_TYPEMASK;
error = 0;
-   goto out;
-   } else if (com == FIODGNAME) {
+   break;
+   case FIODGNAME:
+#ifdef COMPAT_FREEBSD32
+   case FIODGNAME_32:
+#endif
fgn = ap->a_data;
p = devtoname(dev);
i = strlen(p) + 1;
if (i > fgn->len)
error = EINVAL;
else
-   error = copyout(p, fgn->buf, i);
-   goto out;
+

svn commit: r339778 - in head/sys: dev/joy modules/joy

2018-10-26 Thread Warner Losh
Author: imp
Date: Fri Oct 26 16:34:19 2018
New Revision: 339778
URL: https://svnweb.freebsd.org/changeset/base/339778

Log:
  Remove empty directories after r339776.
  
  git svn won't remove empty directories without --rmdir which I
  forgot in r339776.

Deleted:
  head/sys/dev/joy/
  head/sys/modules/joy/
___
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: r339777 - in head/sys/cam: ata nvme scsi

2018-10-26 Thread Warner Losh
Author: imp
Date: Fri Oct 26 16:23:51 2018
New Revision: 339777
URL: https://svnweb.freebsd.org/changeset/base/339777

Log:
  Add statistics for TRIM comands
  
  Add a counter for the LBAs, Ranges and hardware commands so that we
  can provide additional color to the statistics we provide to vendors.
  
  Sponsored by: Netflix, Inc

Modified:
  head/sys/cam/ata/ata_da.c
  head/sys/cam/nvme/nvme_da.c
  head/sys/cam/scsi/scsi_da.c

Modified: head/sys/cam/ata/ata_da.c
==
--- head/sys/cam/ata/ata_da.c   Fri Oct 26 16:03:30 2018(r339776)
+++ head/sys/cam/ata/ata_da.c   Fri Oct 26 16:23:51 2018(r339777)
@@ -251,6 +251,9 @@ struct ada_softc {
struct sysctl_oid   *sysctl_tree;
struct callout  sendordered_c;
struct trim_request trim_req;
+   uint64_ttrim_count;
+   uint64_ttrim_ranges;
+   uint64_ttrim_lbas;
 #ifdef CAM_IO_STATS
struct sysctl_ctx_list  sysctl_stats_ctx;
struct sysctl_oid   *sysctl_stats_tree;
@@ -1440,6 +1443,18 @@ adasysctlinit(void *context, int pending)
OID_AUTO, "delete_method", CTLTYPE_STRING | CTLFLAG_RW,
softc, 0, adadeletemethodsysctl, "A",
"BIO_DELETE execution method");
+   SYSCTL_ADD_UQUAD(>sysctl_ctx,
+   SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO,
+   "trim_count", CTLFLAG_RD, >trim_count,
+   "Total number of dsm commands sent");
+   SYSCTL_ADD_UQUAD(>sysctl_ctx,
+   SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO,
+   "trim_ranges", CTLFLAG_RD, >trim_ranges,
+   "Total number of ranges in dsm commands");
+   SYSCTL_ADD_UQUAD(>sysctl_ctx,
+   SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO,
+   "trim_lbas", CTLFLAG_RD, >trim_lbas,
+   "Total lbas in the dsm commands sent");
SYSCTL_ADD_INT(>sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "read_ahead", CTLFLAG_RW | CTLFLAG_MPSAFE,
>read_ahead, 0, "Enable disk read ahead.");
@@ -1918,7 +1933,7 @@ adaregister(struct cam_periph *periph, void *arg)
 static int
 ada_dsmtrim_req_create(struct ada_softc *softc, struct bio *bp, struct 
trim_request *req)
 {
-   uint64_t lastlba = (uint64_t)-1;
+   uint64_t lastlba = (uint64_t)-1, lbas = 0;
int c, lastcount = 0, off, ranges = 0;
 
bzero(req, sizeof(*req));
@@ -1937,6 +1952,7 @@ ada_dsmtrim_req_create(struct ada_softc *softc, struct
(lastcount >> 8) & 0xff;
count -= c;
lba += c;
+   lbas += c;
}
 
while (count > 0) {
@@ -1951,6 +1967,7 @@ ada_dsmtrim_req_create(struct ada_softc *softc, struct
req->data[off + 6] = c & 0xff;
req->data[off + 7] = (c >> 8) & 0xff;
lba += c;
+   lbas += c;
count -= c;
lastcount = c;
ranges++;
@@ -1972,6 +1989,9 @@ ada_dsmtrim_req_create(struct ada_softc *softc, struct
break;
}
} while (1);
+   softc->trim_count++;
+   softc->trim_ranges += ranges;
+   softc->trim_lbas += lbas;
 
return (ranges);
 }

Modified: head/sys/cam/nvme/nvme_da.c
==
--- head/sys/cam/nvme/nvme_da.c Fri Oct 26 16:03:30 2018(r339776)
+++ head/sys/cam/nvme/nvme_da.c Fri Oct 26 16:23:51 2018(r339777)
@@ -105,12 +105,14 @@ struct nda_softc {
nda_quirks  quirks;
int unmappedio;
quad_t  deletes;
-   quad_t  dsm_req;
uint32_tnsid;   /* Namespace ID for 
this nda device */
struct disk *disk;
struct task sysctl_task;
struct sysctl_ctx_list  sysctl_ctx;
struct sysctl_oid   *sysctl_tree;
+   uint64_ttrim_count;
+   uint64_ttrim_ranges;
+   uint64_ttrim_lbas;
 #ifdef CAM_TEST_FAILURE
int force_read_error;
int force_write_error;
@@ -637,9 +639,18 @@ ndasysctlinit(void *context, int pending)
OID_AUTO, "deletes", CTLFLAG_RD,
>deletes, "Number of BIO_DELETE requests");
 
-   SYSCTL_ADD_QUAD(>sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
-   OID_AUTO, "dsm_req", CTLFLAG_RD,
-   >dsm_req, "Number of DSM requests sent to SIM");
+   SYSCTL_ADD_UQUAD(>sysctl_ctx,
+   SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO,
+   "trim_count", CTLFLAG_RD, 

svn commit: r339776 - in head: . share/man/man4 sys/conf sys/dev/joy sys/modules/joy tools/kerneldoc/subsys

2018-10-26 Thread Warner Losh
Author: imp
Date: Fri Oct 26 16:03:30 2018
New Revision: 339776
URL: https://svnweb.freebsd.org/changeset/base/339776

Log:
  Redo r339563: Remove joy(4) driver.
  
  This driver was marked as gone in 12. We're at 13 now. Remove it.
  Data from nycbug's dmesg cache shows only one potential user,
  suggesting it never was used much. However, even though this device
  has been obsolete for 15 years at least, sys/joystick.h is included in
  a number of graphics packages still, so that remains. A full exprun
  is needed before that can be removed.
  
  RelNotes: yes
  Differential Revision: https://reviews.freebsd.org/D17629

Deleted:
  head/share/man/man4/joy.4
  head/sys/dev/joy/joy.c
  head/sys/dev/joy/joy_isa.c
  head/sys/dev/joy/joyvar.h
  head/sys/modules/joy/Makefile
  head/tools/kerneldoc/subsys/Doxyfile-dev_joy
Modified:
  head/ObsoleteFiles.inc
  head/share/man/man4/Makefile
  head/sys/conf/NOTES
  head/sys/conf/files

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Fri Oct 26 14:27:37 2018(r339775)
+++ head/ObsoleteFiles.inc  Fri Oct 26 16:03:30 2018(r339776)
@@ -38,6 +38,8 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20181026: joy(4) removal
+OLD_FILES+=usr/share/man/man4/joy.4.gz
 # 20181025: OpenSSL libraries version bump to avoid conflict with ports
 OLD_LIBS+=lib/libcrypto.so.9
 OLD_LIBS+=usr/lib/libssl.so.9

Modified: head/share/man/man4/Makefile
==
--- head/share/man/man4/MakefileFri Oct 26 14:27:37 2018
(r339775)
+++ head/share/man/man4/MakefileFri Oct 26 16:03:30 2018
(r339776)
@@ -239,7 +239,6 @@ MAN=aac.4 \
ixl.4 \
jedec_dimm.4 \
jme.4 \
-   joy.4 \
kbdmux.4 \
keyboard.4 \
kld.4 \

Modified: head/sys/conf/NOTES
==
--- head/sys/conf/NOTES Fri Oct 26 14:27:37 2018(r339775)
+++ head/sys/conf/NOTES Fri Oct 26 16:03:30 2018(r339776)
@@ -2313,12 +2313,8 @@ options  SND_OLDSTEREO
 # Miscellaneous hardware:
 #
 # bktr: Brooktree bt848/848a/849a/878/879 video capture and TV Tuner board
-# joy: joystick (including IO DATA PCJOY PC Card joystick)
 # cmx: OmniKey CardMan 4040 pccard smartcard reader
 
-device joy # PnP aware, hints for non-PnP only
-hint.joy.0.at="isa"
-hint.joy.0.port="0x201"
 device cmx
 
 #

Modified: head/sys/conf/files
==
--- head/sys/conf/files Fri Oct 26 14:27:37 2018(r339775)
+++ head/sys/conf/files Fri Oct 26 16:03:30 2018(r339776)
@@ -2294,8 +2294,6 @@ dev/ixgbe/ixgbe_dcb_82599.c   optional ix inet | ixv 
ine
compile-with "${NORMAL_C} -I$S/dev/ixgbe"
 dev/jedec_dimm/jedec_dimm.coptional jedec_dimm smbus
 dev/jme/if_jme.c   optional jme pci
-dev/joy/joy.c  optional joy
-dev/joy/joy_isa.c  optional joy isa
 dev/kbd/kbd.c  optional atkbd | pckbd | sc | ukbd | vt
 dev/kbdmux/kbdmux.coptional kbdmux
 dev/ksyms/ksyms.c  optional ksyms
___
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: r339775 - head/sys/dev/nvme

2018-10-26 Thread Warner Losh
Author: imp
Date: Fri Oct 26 14:27:37 2018
New Revision: 339775
URL: https://svnweb.freebsd.org/changeset/base/339775

Log:
  Put a workaround in for command timeout malfunctioning
  
  At least one NVMe drive has a bug that makeing the Command Time Out
  PCIe feature unreliable. The workaround is to disable this
  feature. The driver wouldn't deal correctly with a timeout anyway.
  Only do this for drives that are known bad.
  
  Sponsored by: Netflix, Inc
  Differential Revision: https://reviews.freebsd.org/D17708

Modified:
  head/sys/dev/nvme/nvme.c
  head/sys/dev/nvme/nvme_private.h

Modified: head/sys/dev/nvme/nvme.c
==
--- head/sys/dev/nvme/nvme.cFri Oct 26 12:27:07 2018(r339774)
+++ head/sys/dev/nvme/nvme.cFri Oct 26 14:27:37 2018(r339775)
@@ -106,6 +106,7 @@ static struct _pcsid
{ 0x05401c5f,   0, 0, "Memblaze Pblaze4", 
QUIRK_DELAY_B4_CHK_RDY },
{ 0xa821144d,   0, 0, "Samsung PM1725", QUIRK_DELAY_B4_CHK_RDY 
},
{ 0xa822144d,   0, 0, "Samsung PM1725a", QUIRK_DELAY_B4_CHK_RDY 
},
+   { 0x01161179,   0, 0, "Toshiba XG5", QUIRK_DISABLE_TIMEOUT },
{ 0x,   0, 0, NULL  }
 };
 
@@ -276,6 +277,25 @@ nvme_attach(device_t dev)
if (status != 0) {
nvme_ctrlr_destruct(ctrlr, dev);
return (status);
+   }
+
+   /*
+* Some drives do not implement the completion timeout feature
+* correctly. There's a WAR from the manufacturer to just disable it.
+* The driver wouldn't respond correctly to a timeout anyway.
+*/
+   if (ep->quirks & QUIRK_DISABLE_TIMEOUT) {
+   int ptr;
+   uint16_t devctl2;
+
+   status = pci_find_cap(dev, PCIY_EXPRESS, );
+   if (status) {
+   device_printf(dev, "Can't locate PCIe capability?");
+   return (status);
+   }
+   devctl2 = pci_read_config(dev, ptr + PCIER_DEVICE_CTL2, 
sizeof(devctl2));
+   devctl2 |= PCIEM_CTL2_COMP_TIMO_DISABLE;
+   pci_write_config(dev, ptr + PCIER_DEVICE_CTL2, devctl2, 
sizeof(devctl2));
}
 
/*

Modified: head/sys/dev/nvme/nvme_private.h
==
--- head/sys/dev/nvme/nvme_private.hFri Oct 26 12:27:07 2018
(r339774)
+++ head/sys/dev/nvme/nvme_private.hFri Oct 26 14:27:37 2018
(r339775)
@@ -247,7 +247,8 @@ struct nvme_controller {
 
uint32_tready_timeout_in_ms;
uint32_tquirks;
-#define QUIRK_DELAY_B4_CHK_RDY 1   /* Can't touch MMIO on disable 
*/
+#defineQUIRK_DELAY_B4_CHK_RDY  1   /* Can't touch MMIO on 
disable */
+#defineQUIRK_DISABLE_TIMEOUT   2   /* Disable broken 
completion timeout feature */
 
bus_space_tag_t bus_tag;
bus_space_handle_t  bus_handle;
___
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: r339563 - in head: . share/man/man4 sys/conf sys/dev/joy sys/modules sys/modules/joy sys/sys tools/kerneldoc/subsys

2018-10-26 Thread Ian Lepore
On Fri, 2018-10-26 at 05:30 +0200, Jan Beich wrote:
> > Your tone is not acceptable. Please try again, only this time with
> the
> > required level of professionalism. I'm not an idiot, and you will
> treat me
> > with respect.
> 
> Apologies for the snide remark. I've expected someone with ports/
> commit bit to be a bit more careful.

It isn't much of an appology if you use it as an opportunity to tack on
another insult.

-- Ian
___
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: r339751 - head/contrib/libarchive/libarchive

2018-10-26 Thread Ed Maste
On Thu, 25 Oct 2018 at 19:13, Martin Matuska  wrote:
>
> Author: mm
> Date: Thu Oct 25 23:13:19 2018
> New Revision: 339751
> URL: https://svnweb.freebsd.org/changeset/base/339751
>
> Log:
>   MFV r339750:
>   Sync libarchive with vendor.
>
>   Relevant vendor changes:
> RAR5 reader: FreeBSD build platform fixes for powerpc(64), mips(64),
>  sparc64 and riscv64

It looks like riscv64 is still broken (at r339774,
https://ci.freebsd.org/job/FreeBSD-head-riscv64-build/11025/console)

12:35:54 
/workspace/src/contrib/libarchive/libarchive/archive_read_support_format_rar5.c:
In function 'process_head_file':
12:35:54 
/workspace/src/contrib/libarchive/libarchive/archive_read_support_format_rar5.c:1422:5:
error: 'name_size' may be used uninitialized in this function
[-Werror=maybe-uninitialized]
12:35:54  memcpy(name_utf8_buf, p, name_size);
12:35:54  ^~~
...
___
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: r339774 - head/sys/riscv/riscv

2018-10-26 Thread Ruslan Bukin
Author: br
Date: Fri Oct 26 12:27:07 2018
New Revision: 339774
URL: https://svnweb.freebsd.org/changeset/base/339774

Log:
  o Add pmap lock around pmap_fault_fixup() to ensure other thread will not
modify l3 pte after we loaded old value and before we stored new value.
  o Preset A(accessed), D(dirty) bits for kernel mappings.
  
  Reported by:  kib
  Reviewed by:  markj
  Discussed with:   jhb
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/riscv/riscv/pmap.c

Modified: head/sys/riscv/riscv/pmap.c
==
--- head/sys/riscv/riscv/pmap.c Fri Oct 26 11:53:20 2018(r339773)
+++ head/sys/riscv/riscv/pmap.c Fri Oct 26 12:27:07 2018(r339774)
@@ -2015,16 +2015,21 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_
pt_entry_t orig_l3;
pt_entry_t new_l3;
pt_entry_t *l3;
+   int rv;
 
+   rv = 0;
+
+   PMAP_LOCK(pmap);
+
l3 = pmap_l3(pmap, va);
if (l3 == NULL)
-   return (0);
+   goto done;
 
orig_l3 = pmap_load(l3);
if ((orig_l3 & PTE_V) == 0 ||
((prot & VM_PROT_WRITE) != 0 && (orig_l3 & PTE_W) == 0) ||
((prot & VM_PROT_READ) != 0 && (orig_l3 & PTE_R) == 0))
-   return (0);
+   goto done;
 
new_l3 = orig_l3 | PTE_A;
if ((prot & VM_PROT_WRITE) != 0)
@@ -2033,7 +2038,8 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_
if (orig_l3 != new_l3) {
pmap_load_store(l3, new_l3);
pmap_invalidate_page(pmap, va);
-   return (1);
+   rv = 1;
+   goto done;
}
 
/*  
@@ -2041,7 +2047,10 @@ pmap_fault_fixup(pmap_t pmap, vm_offset_t va, vm_prot_
 * the PTE shouldn't have resulted in a fault.
 */
 
-   return (0);
+done:
+   PMAP_UNLOCK(pmap);
+
+   return (rv);
 }
 
 /*
@@ -2084,6 +2093,8 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, v
new_l3 |= PTE_W;
if ((va >> 63) == 0)
new_l3 |= PTE_U;
+   else
+   new_l3 |= PTE_A | PTE_D;
 
new_l3 |= (pn << PTE_PPN0_S);
if ((flags & PMAP_ENTER_WIRED) != 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: r339773 - head/lib/csu/common

2018-10-26 Thread Andrew Turner
Author: andrew
Date: Fri Oct 26 11:53:20 2018
New Revision: 339773
URL: https://svnweb.freebsd.org/changeset/base/339773

Log:
  Add __dso_handle to the BSD crtbegin. This is used to identify shared
  objects.
  
  MFC with: r339738
  Sponsored by: DARPA, AFRL

Modified:
  head/lib/csu/common/crtbegin.c

Modified: head/lib/csu/common/crtbegin.c
==
--- head/lib/csu/common/crtbegin.c  Fri Oct 26 10:20:03 2018
(r339772)
+++ head/lib/csu/common/crtbegin.c  Fri Oct 26 11:53:20 2018
(r339773)
@@ -30,6 +30,14 @@ __FBSDID("$FreeBSD$");
 
 typedef void (*crt_func)(void);
 
+extern void *__dso_handle __hidden;
+
+#ifdef SHARED
+void *__dso_handle = &__dso_handle;
+#else
+void *__dso_handle = 0;
+#endif
+
 /*
  * On some architectures and toolchains we may need to call the .dtors.
  * These are called in the order they are in the ELF file.
___
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: r339772 - stable/12/sys/net

2018-10-26 Thread Andrey V. Elsukov
Author: ae
Date: Fri Oct 26 10:20:03 2018
New Revision: 339772
URL: https://svnweb.freebsd.org/changeset/base/339772

Log:
  MFC r339532 (by glebius):
Fix exiting an epoch(9) we never entered. May happen only with MAC.
  
  Approved by:  re (kib)

Modified:
  stable/12/sys/net/if_gif.c
  stable/12/sys/net/if_gre.c
  stable/12/sys/net/if_me.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/net/if_gif.c
==
--- stable/12/sys/net/if_gif.c  Fri Oct 26 08:52:22 2018(r339771)
+++ stable/12/sys/net/if_gif.c  Fri Oct 26 10:20:03 2018(r339772)
@@ -272,6 +272,7 @@ gif_transmit(struct ifnet *ifp, struct mbuf *m)
uint8_t proto, ecn;
int error;
 
+   GIF_RLOCK();
 #ifdef MAC
error = mac_ifnet_check_transmit(ifp, m);
if (error) {
@@ -280,7 +281,6 @@ gif_transmit(struct ifnet *ifp, struct mbuf *m)
}
 #endif
error = ENETDOWN;
-   GIF_RLOCK();
sc = ifp->if_softc;
if ((ifp->if_flags & IFF_MONITOR) != 0 ||
(ifp->if_flags & IFF_UP) == 0 ||

Modified: stable/12/sys/net/if_gre.c
==
--- stable/12/sys/net/if_gre.c  Fri Oct 26 08:52:22 2018(r339771)
+++ stable/12/sys/net/if_gre.c  Fri Oct 26 10:20:03 2018(r339772)
@@ -550,6 +550,7 @@ gre_transmit(struct ifnet *ifp, struct mbuf *m)
uint16_t proto;
 
len = 0;
+   GRE_RLOCK();
 #ifdef MAC
error = mac_ifnet_check_transmit(ifp, m);
if (error) {
@@ -558,7 +559,6 @@ gre_transmit(struct ifnet *ifp, struct mbuf *m)
}
 #endif
error = ENETDOWN;
-   GRE_RLOCK();
sc = ifp->if_softc;
if ((ifp->if_flags & IFF_MONITOR) != 0 ||
(ifp->if_flags & IFF_UP) == 0 ||

Modified: stable/12/sys/net/if_me.c
==
--- stable/12/sys/net/if_me.c   Fri Oct 26 08:52:22 2018(r339771)
+++ stable/12/sys/net/if_me.c   Fri Oct 26 10:20:03 2018(r339772)
@@ -479,13 +479,13 @@ me_transmit(struct ifnet *ifp, struct mbuf *m)
uint32_t af;
int error, hlen, plen;
 
+   ME_RLOCK();
 #ifdef MAC
error = mac_ifnet_check_transmit(ifp, m);
if (error != 0)
goto drop;
 #endif
error = ENETDOWN;
-   ME_RLOCK();
sc = ifp->if_softc;
if (sc == NULL || !ME_READY(sc) ||
(ifp->if_flags & IFF_MONITOR) != 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: r339771 - stable/11/sys/dev/hwpmc

2018-10-26 Thread Matt Macy
Author: mmacy
Date: Fri Oct 26 08:52:22 2018
New Revision: 339771
URL: https://svnweb.freebsd.org/changeset/base/339771

Log:
  fix up more issues introduced by failing to have run TB
  before r339767

Modified:
  stable/11/sys/dev/hwpmc/hwpmc_amd.c

Modified: stable/11/sys/dev/hwpmc/hwpmc_amd.c
==
--- stable/11/sys/dev/hwpmc/hwpmc_amd.c Fri Oct 26 08:12:28 2018
(r339770)
+++ stable/11/sys/dev/hwpmc/hwpmc_amd.c Fri Oct 26 08:52:22 2018
(r339771)
@@ -816,11 +816,12 @@ amd_intr(int cpu, struct trapframe *tf)
v   = pm->pm_sc.pm_reloadcount;
config  = rdmsr(evsel);
 
+
KASSERT((config & ~AMD_PMC_ENABLE) ==
(pm->pm_md.pm_amd.pm_amd_evsel & ~AMD_PMC_ENABLE),
-   ("[amd,%d] config mismatch reg=0x%x pm=0x%x", __LINE__,
-   config, pm->pm_md.pm_amd.pm_amd_evsel));
-
+   ("[amd,%d] config mismatch reg=0x%jx pm=0x%jx", __LINE__,
+(uintmax_t)config, 
(uintmax_t)pm->pm_md.pm_amd.pm_amd_evsel));
+   
wrmsr(evsel, config & ~AMD_PMC_ENABLE);
wrmsr(perfctr, AMD_RELOAD_COUNT_TO_PERFCTR_VALUE(v));
 
@@ -1195,9 +1196,12 @@ pmc_amd_finalize(struct pmc_mdep *md)
} else if (AMD_cpufamily == 0x17)  {
classindex = PMC_MDEP_CLASS_INDEX_F17H;
pmcclass = PMC_CLASS_F17H;
-   } else
+   } else {
+   classindex = PMC_MDEP_CLASS_INDEX_K8;
+   pmcclass = PMC_CLASS_K8;
(void) printf("pmc:AMD CPU family unknown.\n");
-
+   }
+   
}
 
KASSERT(md->pmd_classdep[classindex].pcd_class == pmcclass,
___
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: r339738 - in head: gnu/lib lib/csu lib/csu/aarch64 lib/csu/amd64 lib/csu/common lib/csu/i386 lib/csu/powerpc64 lib/csu/tests lib/csu/tests/dynamic lib/csu/tests/static share/mk tools/b

2018-10-26 Thread Andrew Turner


> On 26 Oct 2018, at 03:40, Kyle Evans  wrote:
> 
> On Thu, Oct 25, 2018 at 12:40 PM Andrew Turner  > wrote:
>> 
>> Author: andrew
>> Date: Thu Oct 25 17:39:41 2018
>> New Revision: 339738
>> URL: https://svnweb.freebsd.org/changeset/base/339738
>> 
>> Log:
>>  Implement a BSD licensed crtbegin/crtend
>> 
>>  These are needed for .ctors/.dtors and .jcr handling. The former needs
>>  all the function pointers to be called in the correct order from the
>>  .init/.fini section. The latter just needs to call a gcj specific function
>>  if it exists with a pointer to the start of the .jcr section.
>> 
>>  This is currently disabled until __dso_handle support is added.
>> 
>>  Reviewed by:  emaste
>>  MFC after:1 month
>>  Sponsored by: DARPA, AFRL
>>  Differential Revision:https://reviews.freebsd.org/D17587
>> 
>> Added:
>>  head/lib/csu/aarch64/crt.h   (contents, props changed)
>>  head/lib/csu/amd64/crt.h   (contents, props changed)
>>  head/lib/csu/common/crtbegin.c   (contents, props changed)
>>  head/lib/csu/common/crtend.c   (contents, props changed)
>>  head/lib/csu/i386/crt.h   (contents, props changed)
>>  head/lib/csu/powerpc64/crt.h   (contents, props changed)
>>  head/lib/csu/tests/
>>  head/lib/csu/tests/Makefile   (contents, props changed)
>>  head/lib/csu/tests/Makefile.inc   (contents, props changed)
>>  head/lib/csu/tests/Makefile.tests   (contents, props changed)
>>  head/lib/csu/tests/cxx_constructors.cc   (contents, props changed)
>>  head/lib/csu/tests/dynamic/
>>  head/lib/csu/tests/dynamic/Makefile   (contents, props changed)
>>  head/lib/csu/tests/fini_test.c   (contents, props changed)
>>  head/lib/csu/tests/init_test.c   (contents, props changed)
>>  head/lib/csu/tests/static/
>>  head/lib/csu/tests/static/Makefile   (contents, props changed)
>>  head/tools/build/options/WITHOUT_BSD_CRTBEGIN   (contents, props changed)
>>  head/tools/build/options/WITH_BSD_CRTBEGIN   (contents, props changed)
>> Modified:
>>  head/gnu/lib/Makefile
>>  head/lib/csu/Makefile
>>  head/lib/csu/Makefile.inc
>>  head/share/mk/src.opts.mk
>> 
> 
> Hi,
> 
> The tests seems to have given CI some heartburn on ppc64/riscv64 after
> they were enabled:
> https://ci.freebsd.org/job/FreeBSD-head-powerpc64-build/7811/console 
> 

This should be fixed in r339770

Andrew

___
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: r339770 - in head/lib/csu/tests: . dynamic static

2018-10-26 Thread Andrew Turner
Author: andrew
Date: Fri Oct 26 08:12:28 2018
New Revision: 339770
URL: https://svnweb.freebsd.org/changeset/base/339770

Log:
  Drop the csu tests WARNS to 5 to fix the powerpc64 build.
  
  MFC with: r339738
  Sponsored by: DARPA, AFRL

Modified:
  head/lib/csu/tests/Makefile.tests
  head/lib/csu/tests/dynamic/Makefile
  head/lib/csu/tests/static/Makefile

Modified: head/lib/csu/tests/Makefile.tests
==
--- head/lib/csu/tests/Makefile.tests   Fri Oct 26 06:12:56 2018
(r339769)
+++ head/lib/csu/tests/Makefile.tests   Fri Oct 26 08:12:28 2018
(r339770)
@@ -4,6 +4,8 @@ ATF_TESTS_C+=   init_test
 ATF_TESTS_C+=  fini_test
 ATF_TESTS_CXX+=cxx_constructors
 
+WARNS?=5
+
 .if exists(${.CURDIR:H:H}/${MACHINE_ARCH})
 CFLAGS+= -I${.CURDIR:H:H}/${MACHINE_ARCH}
 .else

Modified: head/lib/csu/tests/dynamic/Makefile
==
--- head/lib/csu/tests/dynamic/Makefile Fri Oct 26 06:12:56 2018
(r339769)
+++ head/lib/csu/tests/dynamic/Makefile Fri Oct 26 08:12:28 2018
(r339770)
@@ -1,7 +1,6 @@
 # $FreeBSD$
 
 .PATH: ${.CURDIR:H}
-WARNS?=6
 
 .include "../Makefile.tests"
 .include 

Modified: head/lib/csu/tests/static/Makefile
==
--- head/lib/csu/tests/static/Makefile  Fri Oct 26 06:12:56 2018
(r339769)
+++ head/lib/csu/tests/static/Makefile  Fri Oct 26 08:12:28 2018
(r339770)
@@ -2,7 +2,6 @@
 
 .PATH: ${.CURDIR:H}
 NO_SHARED=
-WARNS?=6
 
 .include "../Makefile.tests"
 .include 
___
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: r339769 - in stable/11/sys: dev/hwpmc i386/include

2018-10-26 Thread Matt Macy
Author: mmacy
Date: Fri Oct 26 06:12:56 2018
New Revision: 339769
URL: https://svnweb.freebsd.org/changeset/base/339769

Log:
  fix i386 breakage caused by r339767

Modified:
  stable/11/sys/dev/hwpmc/hwpmc_amd.c
  stable/11/sys/i386/include/pmc_mdep.h

Modified: stable/11/sys/dev/hwpmc/hwpmc_amd.c
==
--- stable/11/sys/dev/hwpmc/hwpmc_amd.c Fri Oct 26 05:25:22 2018
(r339768)
+++ stable/11/sys/dev/hwpmc/hwpmc_amd.c Fri Oct 26 06:12:56 2018
(r339769)
@@ -130,11 +130,7 @@ static  struct amd_descr amd_pmcdesc[AMD_NPMCS] =
 
 struct amd_event_code_map {
enum pmc_event  pe_ev;   /* enum value */
-#ifdefined(__i386__)
-   uint8_t pe_code; /* encoded event mask */
-#elif  defined(__amd64__)
uint16_tpe_code; /* encoded event mask */
-#endif
uint8_t pe_mask; /* bits allowed in unit mask */
 };
 
@@ -532,7 +528,6 @@ amd_allocate_pmc(int cpu, int ri, struct pmc *pm,
 {
int i;
uint32_t allowed_unitmask, caps, unitmask;
-   uint16_t eventval, extevent;
enum pmc_event pe;
const struct pmc_descr *pd;
 
@@ -541,6 +536,7 @@ amd_allocate_pmc(int cpu, int ri, struct pmc *pm,
uint32_t config;
 #elif  defined(__amd64__)
uint64_t config;
+   uint16_t eventval, extevent;
 #endif
 
KASSERT(cpu >= 0 && cpu < pmc_cpu_max(),

Modified: stable/11/sys/i386/include/pmc_mdep.h
==
--- stable/11/sys/i386/include/pmc_mdep.h   Fri Oct 26 05:25:22 2018
(r339768)
+++ stable/11/sys/i386/include/pmc_mdep.h   Fri Oct 26 06:12:56 2018
(r339769)
@@ -69,6 +69,7 @@ struct pmc_mdep;
 #definePMC_MDEP_CLASS_INDEX_TSC1
 #definePMC_MDEP_CLASS_INDEX_K7 2
 #definePMC_MDEP_CLASS_INDEX_K8 2
+#definePMC_MDEP_CLASS_INDEX_F17H   2
 #definePMC_MDEP_CLASS_INDEX_P4 2
 #definePMC_MDEP_CLASS_INDEX_P5 2
 #definePMC_MDEP_CLASS_INDEX_P6 2
___
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"