svn commit: r367478 - head/usr.sbin/bhyve
Author: olivier (ports committer) Date: Sun Nov 8 07:49:39 2020 New Revision: 367478 URL: https://svnweb.freebsd.org/changeset/base/367478 Log: Return the same value for smbios.chassis.maker as smbios.system.maker (and prevents returning a space character). Reviewed by: grehan Approved by: grehan Sponsored by: Netflix Differential Revision:https://reviews.freebsd.org/D27123 Modified: head/usr.sbin/bhyve/smbiostbl.c Modified: head/usr.sbin/bhyve/smbiostbl.c == --- head/usr.sbin/bhyve/smbiostbl.c Sun Nov 8 04:24:29 2020 (r367477) +++ head/usr.sbin/bhyve/smbiostbl.c Sun Nov 8 07:49:39 2020 (r367478) @@ -374,7 +374,7 @@ struct smbios_table_type3 smbios_type3_template = { }; const char *smbios_type3_strings[] = { - " ",/* manufacturer string */ + "FreeBSD", /* manufacturer string */ "1.0", /* version string */ "None", /* serial number string */ "None", /* asset tag string */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367477 - in head/sys: kern sys
Author: kevans Date: Sun Nov 8 04:24:29 2020 New Revision: 367477 URL: https://svnweb.freebsd.org/changeset/base/367477 Log: imgact_binmisc: limit the extent of match on incoming entries imgact_binmisc matches magic/mask from imgp->image_header, which is only a single page in size mapped from the first page of an image. One can specify an interpreter that matches on, e.g., --offset 4096 --size 256 to read up to 256 bytes past the mapped first page. The limitation is that we cannot specify a magic string that exceeds a single page, and we can't allow offset + size to exceed a single page either. A static assert has been added in case someone finds it useful to try and expand the size, but it does seem a little unlikely. While this looks kind of exploitable at a sideways squinty-glance, there are a couple of mitigating factors: 1.) imgact_binmisc is not enabled by default, 2.) entries may only be added by the superuser, 3.) trying to exploit this information to read what's mapped past the end would be worse than a root canal or some other relatably painful experience, and 4.) there's no way one could pull this off without it being completely obvious. The first page is mapped out of an sf_buf, the implementation of which (or lack thereof) depends on your platform. MFC after:1 week Modified: head/sys/kern/imgact_binmisc.c head/sys/sys/imgact_binmisc.h Modified: head/sys/kern/imgact_binmisc.c == --- head/sys/kern/imgact_binmisc.c Sun Nov 8 02:50:34 2020 (r367476) +++ head/sys/kern/imgact_binmisc.c Sun Nov 8 04:24:29 2020 (r367477) @@ -236,6 +236,8 @@ imgact_binmisc_add_entry(ximgact_binmisc_entry_t *xbe) if (xbe->xbe_msize > IBE_MAGIC_MAX) return (EINVAL); + if (xbe->xbe_moffset + xbe->xbe_msize > IBE_MATCH_MAX) + return (EINVAL); for(cnt = 0, p = xbe->xbe_name; *p != 0; cnt++, p++) if (cnt >= IBE_NAME_MAX || !isascii((int)*p)) Modified: head/sys/sys/imgact_binmisc.h == --- head/sys/sys/imgact_binmisc.h Sun Nov 8 02:50:34 2020 (r367476) +++ head/sys/sys/imgact_binmisc.h Sun Nov 8 04:24:29 2020 (r367477) @@ -47,6 +47,11 @@ #defineIBE_INTERP_LEN_MAX (MAXPATHLEN + IBE_ARG_LEN_MAX) #defineIBE_MAX_ENTRIES 64 /* Max number of interpreter entries. */ +/* We only map the first page for identification purposes. */ +#defineIBE_MATCH_MAX PAGE_SIZE +_Static_assert(IBE_MAGIC_MAX <= IBE_MATCH_MAX, +"Cannot identify binaries past the first page."); + /* * Imgact bin misc interpreter entry flags. */ ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367476 - in head: include/xlocale lib/libc/locale share/colldef tools/tools/locale tools/tools/locale/tools usr.bin/localedef usr.bin/localedef/bootstrap
Author: tmunro Date: Sun Nov 8 02:50:34 2020 New Revision: 367476 URL: https://svnweb.freebsd.org/changeset/base/367476 Log: Add collation version support to querylocale(3). Provide a way to ask for an opaque version string for a locale_t, so that potential changes in sort order can be detected. Similar to ICU's ucol_getVersion() and Windows' GetNLSVersionEx(), this API is intended to allow databases to detect when text order-based indexes might need to be rebuilt. The CLDR version is extracted from CLDR source data by the Makefile under tools/tools/locale, written into the machine-generated Makefile under shared/colldef, passed to localedef -V, and then written into LC_COLLATE file headers. The initial version is 34.0. tools/tools/locale was recently updated to pull down 35.0, but the output hasn't been committed under share/colldef yet, so that will provide the first observable change when it happens. Other versioning schemes are possible in future, because the format is unspecified. Reviewed by: bapt, 0mp, kib, yuripv (albeit a long time ago) Differential Revision:https://reviews.freebsd.org/D17166 Modified: head/include/xlocale/_locale.h head/lib/libc/locale/collate.c head/lib/libc/locale/collate.h head/lib/libc/locale/querylocale.3 head/lib/libc/locale/xlocale.c head/lib/libc/locale/xlocale_private.h head/share/colldef/Makefile head/tools/tools/locale/Makefile head/tools/tools/locale/tools/cldr2def.pl head/usr.bin/localedef/bootstrap/bootstrap_xlocale_private.h head/usr.bin/localedef/collate.c head/usr.bin/localedef/localedef.1 head/usr.bin/localedef/localedef.c head/usr.bin/localedef/localedef.h Modified: head/include/xlocale/_locale.h == --- head/include/xlocale/_locale.h Sun Nov 8 02:46:04 2020 (r367475) +++ head/include/xlocale/_locale.h Sun Nov 8 02:50:34 2020 (r367476) @@ -43,6 +43,7 @@ #define LC_MESSAGES_MASK (1<<5) #define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | \ LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK) +#define LC_VERSION_MASK (1<<6) #define LC_GLOBAL_LOCALE ((locale_t)-1) #ifndef _LOCALE_T_DEFINED Modified: head/lib/libc/locale/collate.c == --- head/lib/libc/locale/collate.c Sun Nov 8 02:46:04 2020 (r367475) +++ head/lib/libc/locale/collate.c Sun Nov 8 02:50:34 2020 (r367476) @@ -140,7 +140,9 @@ __collate_load_tables_l(const char *encoding, struct x (void) _close(fd); return (_LDP_ERROR); } - if (sbuf.st_size < (COLLATE_STR_LEN + sizeof (info))) { + if (sbuf.st_size < (COLLATE_FMT_VERSION_LEN + + XLOCALE_DEF_VERSION_LEN + + sizeof (info))) { (void) _close(fd); errno = EINVAL; return (_LDP_ERROR); @@ -151,12 +153,14 @@ __collate_load_tables_l(const char *encoding, struct x return (_LDP_ERROR); } - if (strncmp(TMP, COLLATE_VERSION, COLLATE_STR_LEN) != 0) { + if (strncmp(TMP, COLLATE_FMT_VERSION, COLLATE_FMT_VERSION_LEN) != 0) { (void) munmap(map, sbuf.st_size); errno = EINVAL; return (_LDP_ERROR); } - TMP += COLLATE_STR_LEN; + TMP += COLLATE_FMT_VERSION_LEN; + strlcat(table->header.version, TMP, sizeof (table->header.version)); + TMP += XLOCALE_DEF_VERSION_LEN; info = (void *)TMP; TMP += sizeof (*info); Modified: head/lib/libc/locale/collate.h == --- head/lib/libc/locale/collate.h Sun Nov 8 02:46:04 2020 (r367475) +++ head/lib/libc/locale/collate.h Sun Nov 8 02:50:34 2020 (r367476) @@ -53,8 +53,10 @@ #endif #defineCOLLATE_STR_LEN 24 /* should be 64-bit multiple */ -#defineCOLLATE_VERSION "BSD 1.0\n" +#defineCOLLATE_FMT_VERSION_LEN 12 +#defineCOLLATE_FMT_VERSION "BSD 1.0\n" + #defineCOLLATE_MAX_PRIORITY(0x7fff)/* max signed value */ #defineCOLLATE_SUBST_PRIORITY (0x4000)/* bit indicates subst table */ @@ -69,7 +71,8 @@ /* * The collate file format is as follows: * - * charversion[COLLATE_STR_LEN]; // must be COLLATE_VERSION + * charfmt_version[COLLATE_FMT_VERSION_LEN]; // must be COLLATE_FMT_VERSION + * chardef_version[XLOCALE_DEF_VERSION_LEN]; // NUL-terminated, may be empty * collate_info_t info; // see below, includes padding * collate_char_pri_t char_data[256]; // 8 bit char values * collate_subst_t subst[*]; // 0 or more sub
svn commit: r367475 - head
Author: imp Date: Sun Nov 8 02:46:04 2020 New Revision: 367475 URL: https://svnweb.freebsd.org/changeset/base/367475 Log: Also mention PORTS_MODULES PORTS_MODULES is also an effective way to update the tree. Also a minor rejustify on this an an adjacent paragraph. Suggested by: David Wolfskill Modified: head/UPDATING Modified: head/UPDATING == --- head/UPDATING Sun Nov 8 02:20:21 2020(r367474) +++ head/UPDATING Sun Nov 8 02:46:04 2020(r367475) @@ -2303,14 +2303,16 @@ COMMON ITEMS: messages there. If in doubt, please track -stable which has much fewer pitfalls. - [1] If you have third party modules, such as vmware, you - should disable them at this point so they don't crash your - system on reboot. Alternatively, you should rebuild all the - modules you have in your system and install them as well. If - you are running -current, you should seriously consider - placing all sources to all the modules for your system (or - symlinks to them) in /usr/local/sys/modules so this happens - automatically... + [1] If you have third party modules, such as vmware, you should disable + them at this point so they don't crash your system on + reboot. Alternatively, you should rebuild all the modules you have in + your system and install them as well. If you are running -current, you + should seriously consider placing all sources to all the modules for + your system (or symlinks to them) in /usr/local/sys/modules so this + happens automatically. If all your modules come from ports, then adding + the port origin directories to PORTS_MODULES instead is also automatic + and effective, eg: +PORTS_MODULES+=x11/nvidia-driver [3] From the bootblocks, boot -s, and then do fsck -p @@ -2319,8 +2321,8 @@ COMMON ITEMS: sh /etc/rc.d/zfs start # mount zfs filesystem, if needed cd src # full path to source adjkerntz -i# if CMOS is wall time - Also, when doing a major release upgrade, it is required that - you boot into single user mode to do the installworld. + Also, when doing a major release upgrade, it is required that you boot + into single user mode to do the installworld. [4] Note: This step is non-optional. Failure to do this step can result in a significant reduction in the functionality of the ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367474 - head
Author: imp Date: Sun Nov 8 02:20:21 2020 New Revision: 367474 URL: https://svnweb.freebsd.org/changeset/base/367474 Log: Be explicit about recompiling all the modules... Add a note about always recompiling all modules on every new kernel change / update. In addition, suggest using /usr/local/sys/modules so this happens automatically. Modified: head/UPDATING Modified: head/UPDATING == --- head/UPDATING Sun Nov 8 01:02:40 2020(r367473) +++ head/UPDATING Sun Nov 8 02:20:21 2020(r367474) @@ -2305,7 +2305,12 @@ COMMON ITEMS: [1] If you have third party modules, such as vmware, you should disable them at this point so they don't crash your - system on reboot. + system on reboot. Alternatively, you should rebuild all the + modules you have in your system and install them as well. If + you are running -current, you should seriously consider + placing all sources to all the modules for your system (or + symlinks to them) in /usr/local/sys/modules so this happens + automatically... [3] From the bootblocks, boot -s, and then do fsck -p ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367465 - in head: contrib/bmake contrib/bmake/filemon contrib/bmake/mk contrib/bmake/unit-tests usr.bin/bmake usr.bin/bmake/unit-tests
Author: sjg Date: Sat Nov 7 21:46:27 2020 New Revision: 367465 URL: https://svnweb.freebsd.org/changeset/base/367465 Log: Update to bmake-20201101 Lots of new unit-tests increase code coverage. Lots of refactoring, cleanup and simlpification to reduce code size. Fixes for Bug 223564 and 245807 Updates to dirdeps.mk and meta2deps.py Added: head/contrib/bmake/unit-tests/cond-cmp-unary.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/cond-cmp-unary.exp head/contrib/bmake/unit-tests/cond-cmp-unary.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/cond-cmp-unary.mk head/contrib/bmake/unit-tests/cond-undef-lint.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/cond-undef-lint.exp head/contrib/bmake/unit-tests/cond-undef-lint.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/cond-undef-lint.mk head/contrib/bmake/unit-tests/counter-append.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/counter-append.exp head/contrib/bmake/unit-tests/counter-append.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/counter-append.mk head/contrib/bmake/unit-tests/dep-colon-bug-cross-file.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/dep-colon-bug-cross-file.exp head/contrib/bmake/unit-tests/dep-colon-bug-cross-file.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/dep-colon-bug-cross-file.mk head/contrib/bmake/unit-tests/dep-double-colon-indep.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/dep-double-colon-indep.exp head/contrib/bmake/unit-tests/dep-double-colon-indep.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/dep-double-colon-indep.mk head/contrib/bmake/unit-tests/dep-percent.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/dep-percent.exp head/contrib/bmake/unit-tests/dep-percent.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/dep-percent.mk head/contrib/bmake/unit-tests/depsrc-end.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/depsrc-end.exp head/contrib/bmake/unit-tests/depsrc-end.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/depsrc-end.mk head/contrib/bmake/unit-tests/deptgt-end-jobs.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/deptgt-end-jobs.exp head/contrib/bmake/unit-tests/deptgt-end-jobs.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/deptgt-end-jobs.mk head/contrib/bmake/unit-tests/directive-dinclude.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-dinclude.exp head/contrib/bmake/unit-tests/directive-dinclude.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-dinclude.mk head/contrib/bmake/unit-tests/directive-export-gmake.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-export-gmake.exp head/contrib/bmake/unit-tests/directive-export-gmake.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-export-gmake.mk head/contrib/bmake/unit-tests/directive-hyphen-include.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-hyphen-include.exp head/contrib/bmake/unit-tests/directive-hyphen-include.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-hyphen-include.mk head/contrib/bmake/unit-tests/directive-include-fatal.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-include-fatal.exp head/contrib/bmake/unit-tests/directive-include-fatal.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-include-fatal.mk head/contrib/bmake/unit-tests/directive-include.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-include.exp head/contrib/bmake/unit-tests/directive-include.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-include.mk head/contrib/bmake/unit-tests/directive-sinclude.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-sinclude.exp head/contrib/bmake/unit-tests/directive-sinclude.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/directive-sinclude.mk head/contrib/bmake/unit-tests/hanoi-include.exp - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/hanoi-include.exp head/contrib/bmake/unit-tests/hanoi-include.mk - copied unchanged from r367461, vendor/NetBSD/bmake/dist/unit-tests/hanoi-include.mk head/contrib/bmake/unit-tests/job-output-long-lines.exp - copied unchanged from r367461, vendor/NetBSD/
svn commit: r367464 - head/sys/kern
Author: tuexen Date: Sat Nov 7 21:17:49 2020 New Revision: 367464 URL: https://svnweb.freebsd.org/changeset/base/367464 Log: The ioctl() calls using FIONREAD, FIONWRITE, FIONSPACE, and SIOCATMARK access the socket send or receive buffer. This is not possible for listening sockets since r319722. Because send()/recv() calls fail on listening sockets, fail also ioctl() indicating EINVAL. PR: 250366 Reported by: Yong-Hao Zou Reviewed by: glebius, rscheff MFC after:1 week Sponsored by: Netflix, Inc. Differential Revision:https://reviews.freebsd.org/D26897 Modified: head/sys/kern/sys_socket.c Modified: head/sys/kern/sys_socket.c == --- head/sys/kern/sys_socket.c Sat Nov 7 19:57:19 2020(r367463) +++ head/sys/kern/sys_socket.c Sat Nov 7 21:17:49 2020(r367464) @@ -207,21 +207,34 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, str case FIONREAD: /* Unlocked read. */ - *(int *)data = sbavail(&so->so_rcv); + if (SOLISTENING(so)) { + error = EINVAL; + } else { + *(int *)data = sbavail(&so->so_rcv); + } break; case FIONWRITE: /* Unlocked read. */ - *(int *)data = sbavail(&so->so_snd); + if (SOLISTENING(so)) { + error = EINVAL; + } else { + *(int *)data = sbavail(&so->so_snd); + } break; case FIONSPACE: /* Unlocked read. */ - if ((so->so_snd.sb_hiwat < sbused(&so->so_snd)) || - (so->so_snd.sb_mbmax < so->so_snd.sb_mbcnt)) - *(int *)data = 0; - else - *(int *)data = sbspace(&so->so_snd); + if (SOLISTENING(so)) { + error = EINVAL; + } else { + if ((so->so_snd.sb_hiwat < sbused(&so->so_snd)) || + (so->so_snd.sb_mbmax < so->so_snd.sb_mbcnt)) { + *(int *)data = 0; + } else { + *(int *)data = sbspace(&so->so_snd); + } + } break; case FIOSETOWN: @@ -242,7 +255,11 @@ soo_ioctl(struct file *fp, u_long cmd, void *data, str case SIOCATMARK: /* Unlocked read. */ - *(int *)data = (so->so_rcv.sb_state & SBS_RCVATMARK) != 0; + if (SOLISTENING(so)) { + error = EINVAL; + } else { + *(int *)data = (so->so_rcv.sb_state & SBS_RCVATMARK) != 0; + } break; default: /* ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367459 - head/usr.sbin/syslogd
Author: cy Date: Sat Nov 7 19:17:37 2020 New Revision: 367459 URL: https://svnweb.freebsd.org/changeset/base/367459 Log: Fix build post-r367455. MFC after:2 weeks X-MFC with: r367455 Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c == --- head/usr.sbin/syslogd/syslogd.c Sat Nov 7 18:15:29 2020 (r367458) +++ head/usr.sbin/syslogd/syslogd.c Sat Nov 7 19:17:37 2020 (r367459) @@ -1873,7 +1873,7 @@ fprintlog_write(struct filed *f, struct iovlist *il, i continue; if (sl->sl_sa == NULL || sl->sl_family == AF_UNSPEC || - sl->sl_family == AF_LOCAL) { + sl->sl_family == AF_LOCAL) continue; lsent = sendmsg(sl->sl_socket, &msghdr, 0); if (lsent == (ssize_t)il->totalsize) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367456 - head/sys/kern
Author: kevans Date: Sat Nov 7 18:07:55 2020 New Revision: 367456 URL: https://svnweb.freebsd.org/changeset/base/367456 Log: imgact_binmisc: move some calculations out of the exec path The offset we need to account for in the interpreter string comes in two variants: 1. Fixed - macros other than #a that will not vary from invocation to invocation 2. Variable - #a, which is substitued with the argv0 that we're replacing Note that we don't have a mechanism to modify an existing entry. By recording both of these offset requirements when the interpreter is added, we can avoid some unnecessary calculations in the exec path. Most importantly, we can know up-front whether we need to grab calculate/grab the the filename for this interpreter. We also get to avoid walking the string a first time looking for macros. For most invocations, it's a swift exit as they won't have any, but there's no point entering a loop and searching for the macro indicator if we already know there will not be one. While we're here, go ahead and only calculate the argv0 name length once per invocation. While it's unlikely that we'll have more than one #a, there's no reason to recalculate it every time we encounter an #a when it will not change. I have not bothered trying to benchmark this at all, because it's arguably a minor and straightforward/obvious improvement. MFC after:1 week Modified: head/sys/kern/imgact_binmisc.c Modified: head/sys/kern/imgact_binmisc.c == --- head/sys/kern/imgact_binmisc.c Sat Nov 7 17:18:44 2020 (r367455) +++ head/sys/kern/imgact_binmisc.c Sat Nov 7 18:07:55 2020 (r367456) @@ -63,8 +63,10 @@ typedef struct imgact_binmisc_entry { uint8_t *ibe_magic; uint8_t *ibe_mask; uint8_t *ibe_interpreter; + ssize_t ibe_interp_offset; uint32_t ibe_interp_argcnt; uint32_t ibe_interp_length; + uint32_t ibe_argv0_cnt; uint32_t ibe_flags; uint32_t ibe_moffset; uint32_t ibe_msize; @@ -154,7 +156,8 @@ imgact_binmisc_populate_interp(char *str, imgact_binmi * Allocate memory and populate a new entry for the interpreter table. */ static imgact_binmisc_entry_t * -imgact_binmisc_new_entry(ximgact_binmisc_entry_t *xbe) +imgact_binmisc_new_entry(ximgact_binmisc_entry_t *xbe, ssize_t interp_offset, +int argv0_cnt) { imgact_binmisc_entry_t *ibe = NULL; size_t namesz = min(strlen(xbe->xbe_name) + 1, IBE_NAME_MAX); @@ -175,7 +178,8 @@ imgact_binmisc_new_entry(ximgact_binmisc_entry_t *xbe) ibe->ibe_moffset = xbe->xbe_moffset; ibe->ibe_msize = xbe->xbe_msize; ibe->ibe_flags = xbe->xbe_flags; - + ibe->ibe_interp_offset = interp_offset; + ibe->ibe_argv0_cnt = argv0_cnt; return (ibe); } @@ -227,7 +231,8 @@ imgact_binmisc_add_entry(ximgact_binmisc_entry_t *xbe) { imgact_binmisc_entry_t *ibe; char *p; - int cnt; + ssize_t interp_offset; + int argv0_cnt, cnt; if (xbe->xbe_msize > IBE_MAGIC_MAX) return (EINVAL); @@ -242,23 +247,21 @@ imgact_binmisc_add_entry(ximgact_binmisc_entry_t *xbe) /* Make sure we don't have any invalid #'s. */ p = xbe->xbe_interpreter; - while (1) { - p = strchr(p, '#'); - if (!p) - break; - + interp_offset = 0; + argv0_cnt = 0; + while ((p = strchr(p, '#')) != NULL) { p++; switch(*p) { case ISM_POUND: /* "##" */ p++; + interp_offset--; break; - case ISM_OLD_ARGV0: /* "#a" */ p++; + argv0_cnt++; break; - case 0: default: /* Anything besides the above is invalid. */ @@ -273,7 +276,7 @@ imgact_binmisc_add_entry(ximgact_binmisc_entry_t *xbe) } /* Preallocate a new entry. */ - ibe = imgact_binmisc_new_entry(xbe); + ibe = imgact_binmisc_new_entry(xbe, interp_offset, argv0_cnt); SLIST_INSERT_HEAD(&interpreter_list, ibe, link); interp_list_entry_count++; @@ -586,12 +589,16 @@ imgact_binmisc_exec(struct image_params *imgp) const char *image_header = imgp->image_header; const char *fname = NULL; int error = 0; - size_t offset, l; +#ifdef INVARIANTS + int argv0_cnt = 0; +#endif + size_t namelen, offset; imgact_binmi
Re: svn commit: r367455 - head/usr.sbin/syslogd
In message <202011071718.0a7hijdy003...@repo.freebsd.org>, Bryan Drewery writes : > Author: bdrewery > Date: Sat Nov 7 17:18:44 2020 > New Revision: 367455 > URL: https://svnweb.freebsd.org/changeset/base/367455 > > Log: > syslogd: Stop trying to send remote messages through special sockets > > Specifically this was causing the /dev/klog fd and the signal pipe > handling fd to get a sendmsg(2) called on them and always returned > [ENOTSOCK]. > > r310350 combined these sockets into the main socket list and properly > skipped AF_UNSPEC at the sendmsg(2) call but later in r344739 it was > broken such that these special sockets were no longer excluded since > the AF_UNSPEC check specifically excluded these special sockets. Only > these special sockets have sl_sa = NULL. The sl_family checks should > be redundant now but are left in case of future changes so the intent > is clearer. > > MFC after: 2 weeks > > Modified: > head/usr.sbin/syslogd/syslogd.c > > Modified: head/usr.sbin/syslogd/syslogd.c > = > = > --- head/usr.sbin/syslogd/syslogd.c Sat Nov 7 16:58:38 2020(r36745 > 4) > +++ head/usr.sbin/syslogd/syslogd.c Sat Nov 7 17:18:44 2020(r36745 > 5) > @@ -1871,9 +1871,9 @@ fprintlog_write(struct filed *f, struct iovlist *il, i > STAILQ_FOREACH(sl, &shead, next) { > if (sl->sl_socket < 0) > continue; > - if (sl->sl_sa != NULL && > - (sl->sl_family == AF_LOCAL || > - sl->sl_family == AF_UNSPEC)) > + if (sl->sl_sa == NULL || > + sl->sl_family == AF_UNSPEC || > + sl->sl_family == AF_LOCAL) { The extraneous left brace broke the build. > continue; > lsent = sendmsg(sl->sl_socket, &msghdr, 0); > if (lsent == (ssize_t)il->totalsize) > -- Cheers, Cy Schubert FreeBSD UNIX: Web: https://FreeBSD.org NTP: Web: https://nwtime.org The need of the many outweighs the greed of the few. ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367455 - head/usr.sbin/syslogd
Author: bdrewery Date: Sat Nov 7 17:18:44 2020 New Revision: 367455 URL: https://svnweb.freebsd.org/changeset/base/367455 Log: syslogd: Stop trying to send remote messages through special sockets Specifically this was causing the /dev/klog fd and the signal pipe handling fd to get a sendmsg(2) called on them and always returned [ENOTSOCK]. r310350 combined these sockets into the main socket list and properly skipped AF_UNSPEC at the sendmsg(2) call but later in r344739 it was broken such that these special sockets were no longer excluded since the AF_UNSPEC check specifically excluded these special sockets. Only these special sockets have sl_sa = NULL. The sl_family checks should be redundant now but are left in case of future changes so the intent is clearer. MFC after:2 weeks Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c == --- head/usr.sbin/syslogd/syslogd.c Sat Nov 7 16:58:38 2020 (r367454) +++ head/usr.sbin/syslogd/syslogd.c Sat Nov 7 17:18:44 2020 (r367455) @@ -1871,9 +1871,9 @@ fprintlog_write(struct filed *f, struct iovlist *il, i STAILQ_FOREACH(sl, &shead, next) { if (sl->sl_socket < 0) continue; - if (sl->sl_sa != NULL && - (sl->sl_family == AF_LOCAL || -sl->sl_family == AF_UNSPEC)) + if (sl->sl_sa == NULL || + sl->sl_family == AF_UNSPEC || + sl->sl_family == AF_LOCAL) { continue; lsent = sendmsg(sl->sl_socket, &msghdr, 0); if (lsent == (ssize_t)il->totalsize) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367454 - head/sys/contrib/openzfs/module/os/freebsd/zfs
Author: mjg Date: Sat Nov 7 16:58:38 2020 New Revision: 367454 URL: https://svnweb.freebsd.org/changeset/base/367454 Log: zfs: remove 2 assertions that teardown lock is not held They are not very useful and hard to implement with rms. This has a side effect of simplying the code. Modified: head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops.c Modified: head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops.c == --- head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops.c Sat Nov 7 16:57:53 2020(r367453) +++ head/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops.c Sat Nov 7 16:58:38 2020(r367454) @@ -1451,10 +1451,6 @@ zfs_lookup_lock(vnode_t *dvp, vnode_t *vp, const char if (zfsvfs->z_replay == B_FALSE) ASSERT_VOP_LOCKED(dvp, __func__); -#ifdef DIAGNOSTIC - if ((zdp->z_pflags & ZFS_XATTR) == 0) - VERIFY(!ZFS_TEARDOWN_HELD(zfsvfs)); -#endif if (name[0] == 0 || (name[0] == '.' && name[1] == 0)) { ASSERT3P(dvp, ==, vp); @@ -6523,39 +6519,6 @@ zfs_vptocnp(struct vop_vptocnp_args *ap) return (error); } -#ifdef DIAGNOSTIC -#ifndef _SYS_SYSPROTO_H_ -struct vop_lock1_args { - struct vnode *a_vp; - int a_flags; - char *file; - int line; -}; -#endif - -static int -zfs_lock(struct vop_lock1_args *ap) -{ - vnode_t *vp; - znode_t *zp; - int err; - -#if __FreeBSD_version >= 1300064 - err = vop_lock(ap); -#else - err = vop_stdlock(ap); -#endif - if (err == 0 && (ap->a_flags & LK_NOWAIT) == 0) { - vp = ap->a_vp; - zp = vp->v_data; - if (vp->v_mount != NULL && !VN_IS_DOOMED(vp) && - zp != NULL && (zp->z_pflags & ZFS_XATTR) == 0) - VERIFY(!ZFS_TEARDOWN_HELD(zp->z_zfsvfs)); - } - return (err); -} -#endif - struct vop_vector zfs_vnodeops; struct vop_vector zfs_fifoops; struct vop_vector zfs_shareops; @@ -6606,17 +6569,9 @@ struct vop_vector zfs_vnodeops = { .vop_putpages = zfs_freebsd_putpages, .vop_vptocnp = zfs_vptocnp, #if __FreeBSD_version >= 1300064 -#ifdef DIAGNOSTIC - .vop_lock1 =zfs_lock, -#else .vop_lock1 =vop_lock, -#endif .vop_unlock = vop_unlock, .vop_islocked = vop_islocked, -#else -#ifdef DIAGNOSTIC - .vop_lock1 =zfs_lock, -#endif #endif }; VFS_VOP_VECTOR_REGISTER(zfs_vnodeops); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367453 - in head/sys: kern sys
Author: mjg Date: Sat Nov 7 16:57:53 2020 New Revision: 367453 URL: https://svnweb.freebsd.org/changeset/base/367453 Log: rms: several cleanups + debug read lockers handling This adds a dedicated counter updated with atomics when INVARIANTS is used. As a side effect one can reliably determine the lock is held for reading by at least one thread, but it's still not possible to find out whether curthread has the lock in said mode. This should be good enough in practice. Problem spotted by avg. Modified: head/sys/kern/kern_rmlock.c head/sys/sys/_rmlock.h head/sys/sys/rmlock.h Modified: head/sys/kern/kern_rmlock.c == --- head/sys/kern/kern_rmlock.c Sat Nov 7 16:41:59 2020(r367452) +++ head/sys/kern/kern_rmlock.c Sat Nov 7 16:57:53 2020(r367453) @@ -878,10 +878,105 @@ db_show_rm(const struct lock_object *lock) * problem at some point. The easiest way to lessen it is to provide a bitmap. */ +#define rms_int_membar() __compiler_membar() + #defineRMS_NOOWNER ((void *)0x1) #defineRMS_TRANSIENT ((void *)0x2) #defineRMS_FLAGMASK0xf +struct rmslock_pcpu { + int influx; + int readers; +}; + +_Static_assert(sizeof(struct rmslock_pcpu) == 8, "bad size"); + +/* + * Internal routines + */ +static struct rmslock_pcpu * +rms_int_pcpu(struct rmslock *rms) +{ + + CRITICAL_ASSERT(curthread); + return (zpcpu_get(rms->pcpu)); +} + +static struct rmslock_pcpu * +rms_int_remote_pcpu(struct rmslock *rms, int cpu) +{ + + return (zpcpu_get_cpu(rms->pcpu, cpu)); +} + +static void +rms_int_influx_enter(struct rmslock *rms, struct rmslock_pcpu *pcpu) +{ + + CRITICAL_ASSERT(curthread); + MPASS(pcpu->influx == 0); + pcpu->influx = 1; +} + +static void +rms_int_influx_exit(struct rmslock *rms, struct rmslock_pcpu *pcpu) +{ + + CRITICAL_ASSERT(curthread); + MPASS(pcpu->influx == 1); + pcpu->influx = 0; +} + +#ifdef INVARIANTS +static void +rms_int_debug_readers_inc(struct rmslock *rms) +{ + int old; + old = atomic_fetchadd_int(&rms->debug_readers, 1); + KASSERT(old >= 0, ("%s: bad readers count %d\n", __func__, old)); +} + +static void +rms_int_debug_readers_dec(struct rmslock *rms) +{ + int old; + + old = atomic_fetchadd_int(&rms->debug_readers, -1); + KASSERT(old > 0, ("%s: bad readers count %d\n", __func__, old)); +} +#else +static void +rms_int_debug_readers_inc(struct rmslock *rms) +{ +} + +static void +rms_int_debug_readers_dec(struct rmslock *rms) +{ +} +#endif + +static void +rms_int_readers_inc(struct rmslock *rms, struct rmslock_pcpu *pcpu) +{ + + CRITICAL_ASSERT(curthread); + rms_int_debug_readers_inc(rms); + pcpu->readers++; +} + +static void +rms_int_readers_dec(struct rmslock *rms, struct rmslock_pcpu *pcpu) +{ + + CRITICAL_ASSERT(curthread); + rms_int_debug_readers_dec(rms); + pcpu->readers--; +} + +/* + * Public API + */ void rms_init(struct rmslock *rms, const char *name) { @@ -889,9 +984,9 @@ rms_init(struct rmslock *rms, const char *name) rms->owner = RMS_NOOWNER; rms->writers = 0; rms->readers = 0; + rms->debug_readers = 0; mtx_init(&rms->mtx, name, NULL, MTX_DEF | MTX_NEW); - rms->readers_pcpu = uma_zalloc_pcpu(pcpu_zone_4, M_WAITOK | M_ZERO); - rms->readers_influx = uma_zalloc_pcpu(pcpu_zone_4, M_WAITOK | M_ZERO); + rms->pcpu = uma_zalloc_pcpu(pcpu_zone_8, M_WAITOK | M_ZERO); } void @@ -901,23 +996,21 @@ rms_destroy(struct rmslock *rms) MPASS(rms->writers == 0); MPASS(rms->readers == 0); mtx_destroy(&rms->mtx); - uma_zfree_pcpu(pcpu_zone_4, rms->readers_pcpu); - uma_zfree_pcpu(pcpu_zone_4, rms->readers_influx); + uma_zfree_pcpu(pcpu_zone_8, rms->pcpu); } static void __noinline rms_rlock_fallback(struct rmslock *rms) { - zpcpu_set_protected(rms->readers_influx, 0); + rms_int_influx_exit(rms, rms_int_pcpu(rms)); critical_exit(); mtx_lock(&rms->mtx); - MPASS(*zpcpu_get(rms->readers_pcpu) == 0); while (rms->writers > 0) msleep(&rms->readers, &rms->mtx, PUSER - 1, mtx_name(&rms->mtx), 0); critical_enter(); - zpcpu_add_protected(rms->readers_pcpu, 1); + rms_int_readers_inc(rms, rms_int_pcpu(rms)); mtx_unlock(&rms->mtx); critical_exit(); } @@ -925,43 +1018,46 @@ rms_rlock_fallback(struct rmslock *rms) void rms_rlock(struct rmslock *rms) { + struct rmslock_pcpu *pcpu; WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__); MPASS(atomic_load_ptr(&rms->owner) != curthread); critical_enter(); - zpcpu_set_protected(rms->readers_influx, 1); - __compiler_membar(); + pcpu = rms_int_pcpu(rms); + rms_int_influx_enter(rms, pcpu); + rms_int_membar();
svn commit: r367452 - head/sys/kern
Author: kevans Date: Sat Nov 7 16:41:59 2020 New Revision: 367452 URL: https://svnweb.freebsd.org/changeset/base/367452 Log: imgact_binmisc: reorder members of struct imgact_binmisc_entry (NFC) This doesn't change anything at the moment since the out-of-order elements were a pair of uint32_t, but future additions may have caused unnecessary padding by following the existing precedent. MFC after:1 week Modified: head/sys/kern/imgact_binmisc.c Modified: head/sys/kern/imgact_binmisc.c == --- head/sys/kern/imgact_binmisc.c Sat Nov 7 16:35:48 2020 (r367451) +++ head/sys/kern/imgact_binmisc.c Sat Nov 7 16:41:59 2020 (r367452) @@ -58,16 +58,16 @@ __FBSDID("$FreeBSD$"); * Node of the interpreter list. */ typedef struct imgact_binmisc_entry { + SLIST_ENTRY(imgact_binmisc_entry) link; char *ibe_name; uint8_t *ibe_magic; - uint32_t ibe_moffset; - uint32_t ibe_msize; uint8_t *ibe_mask; uint8_t *ibe_interpreter; uint32_t ibe_interp_argcnt; uint32_t ibe_interp_length; uint32_t ibe_flags; - SLIST_ENTRY(imgact_binmisc_entry) link; + uint32_t ibe_moffset; + uint32_t ibe_msize; } imgact_binmisc_entry_t; /* ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367448 - head/sys/dev/vt
Author: kevans Date: Sat Nov 7 15:38:01 2020 New Revision: 367448 URL: https://svnweb.freebsd.org/changeset/base/367448 Log: vt: resolve conflict between VT_ALT_TO_ESC_HACK and DBG When using the ALT+CTRL+ESC sequence to break into kdb, the keyboard is completely borked when you return. watch(8) shows that it's working, but it's inserting escape sequences. Further investigation revealed that VT_ALT_TO_ESC_HACK is the default and directly conflicts with this sequence, so upon return from the debugger ALKED is set. If they triggered the break to debugger, it's safe to assume they didn't mean to use VT_ALT_TO_ESC_HACK, so just unset it to reduce the surprise when the keyboard seems non-functional upon return. Reviewed by: tsoome MFC after:1 week Differential Revision:https://reviews.freebsd.org/D27109 Modified: head/sys/dev/vt/vt_core.c Modified: head/sys/dev/vt/vt_core.c == --- head/sys/dev/vt/vt_core.c Sat Nov 7 14:58:01 2020(r367447) +++ head/sys/dev/vt/vt_core.c Sat Nov 7 15:38:01 2020(r367448) @@ -725,13 +725,22 @@ vt_scroll(struct vt_window *vw, int offset, int whence } static int -vt_machine_kbdevent(int c) +vt_machine_kbdevent(struct vt_device *vd, int c) { switch (c) { case SPCLKEY | DBG: /* kbdmap(5) keyword `debug`. */ - if (vt_kbd_debug) + if (vt_kbd_debug) { kdb_enter(KDB_WHY_BREAK, "manual escape to debugger"); +#if VT_ALT_TO_ESC_HACK + /* +* There's an unfortunate conflict between SPCLKEY|DBG +* and VT_ALT_TO_ESC_HACK. Just assume they didn't mean +* it if we got to here. +*/ + vd->vd_kbstate &= ~ALKED; +#endif + } return (1); case SPCLKEY | HALT: /* kbdmap(5) keyword `halt`. */ if (vt_kbd_halt) @@ -864,7 +873,7 @@ vt_processkey(keyboard_t *kbd, struct vt_device *vd, i return (0); #endif - if (vt_machine_kbdevent(c)) + if (vt_machine_kbdevent(vd, c)) return (0); if (vw->vw_flags & VWF_SCROLL) { ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367447 - in head/sys: kern sys
Author: mmel Date: Sat Nov 7 14:58:01 2020 New Revision: 367447 URL: https://svnweb.freebsd.org/changeset/base/367447 Log: Add a method to determine whether given interrupt is per CPU or not. MFC after:2 weeks Modified: head/sys/kern/subr_intr.c head/sys/sys/intr.h Modified: head/sys/kern/subr_intr.c == --- head/sys/kern/subr_intr.c Sat Nov 7 13:16:11 2020(r367446) +++ head/sys/kern/subr_intr.c Sat Nov 7 14:58:01 2020(r367447) @@ -946,6 +946,21 @@ intr_resolve_irq(device_t dev, intptr_t xref, struct i } } +bool +intr_is_per_cpu(struct resource *res) +{ + u_int res_id; + struct intr_irqsrc *isrc; + + res_id = (u_int)rman_get_start(res); + isrc = intr_map_get_isrc(res_id); + + if (isrc == NULL) + panic("Attempt to get isrc for non-active resource id: %u\n", + res_id); + return ((isrc->isrc_flags & INTR_ISRCF_PPI) != 0); +} + int intr_activate_irq(device_t dev, struct resource *res) { Modified: head/sys/sys/intr.h == --- head/sys/sys/intr.h Sat Nov 7 13:16:11 2020(r367446) +++ head/sys/sys/intr.h Sat Nov 7 14:58:01 2020(r367447) @@ -115,6 +115,7 @@ int intr_pic_deregister(device_t, intptr_t); int intr_pic_claim_root(device_t, intptr_t, intr_irq_filter_t *, void *, u_int); struct intr_pic *intr_pic_add_handler(device_t, struct intr_pic *, intr_child_irq_filter_t *, void *, uintptr_t, uintptr_t); +bool intr_is_per_cpu(struct resource *); extern device_t intr_irq_root_dev; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r367445 - head/sys/kern
Author: trasz Date: Sat Nov 7 13:09:51 2020 New Revision: 367445 URL: https://svnweb.freebsd.org/changeset/base/367445 Log: Move TDB_USERWR check under 'if (traced)'. If we hadn't been traced in the first place when syscallenter() started executing, we can ignore TDB_USERWR. TDB_USERWR can get set, sure, but if it does, it's because the debugger raced with the syscall, and it cannot depend on winning that race. Reviewed by: kib MFC after:2 weeks Sponsored by: EPSRC Differential Revision:https://reviews.freebsd.org/D26585 Modified: head/sys/kern/subr_syscall.c Modified: head/sys/kern/subr_syscall.c == --- head/sys/kern/subr_syscall.cSat Nov 7 05:10:46 2020 (r367444) +++ head/sys/kern/subr_syscall.cSat Nov 7 13:09:51 2020 (r367445) @@ -97,21 +97,22 @@ syscallenter(struct thread *td) if (p->p_ptevents & PTRACE_SCE) ptracestop((td), SIGTRAP, NULL); PROC_UNLOCK(p); - } - if (__predict_false((td->td_dbgflags & TDB_USERWR) != 0)) { - /* -* Reread syscall number and arguments if debugger -* modified registers or memory. -*/ - error = (p->p_sysent->sv_fetch_syscall_args)(td); - se = sa->callp; + + if ((td->td_dbgflags & TDB_USERWR) != 0) { + /* +* Reread syscall number and arguments if debugger +* modified registers or memory. +*/ + error = (p->p_sysent->sv_fetch_syscall_args)(td); + se = sa->callp; #ifdef KTRACE - if (KTRPOINT(td, KTR_SYSCALL)) - ktrsyscall(sa->code, se->sy_narg, sa->args); + if (KTRPOINT(td, KTR_SYSCALL)) + ktrsyscall(sa->code, se->sy_narg, sa->args); #endif - if (error != 0) { - td->td_errno = error; - goto retval; + if (error != 0) { + td->td_errno = error; + goto retval; + } } } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"