svn commit: r367673 - head/sys/compat/linuxkpi/common/include/linux
Author: wulf Date: Sat Nov 14 10:34:18 2020 New Revision: 367673 URL: https://svnweb.freebsd.org/changeset/base/367673 Log: LinuxKPI: Exclude linux/acpi.h content on non-ACPI archs. LinuxKPI ACPI support is based on FreeBSD import of ACPICA which can be compiled only on aarch64, amd64 and i386. Ifdef-out broken parts on our side to avoid patching of vendor code. This fixes drm-devel-kmod build on powerpc64(le). Reported by: pkubaj Modified: head/sys/compat/linuxkpi/common/include/linux/acpi.h Modified: head/sys/compat/linuxkpi/common/include/linux/acpi.h == --- head/sys/compat/linuxkpi/common/include/linux/acpi.hSat Nov 14 05:30:10 2020(r367672) +++ head/sys/compat/linuxkpi/common/include/linux/acpi.hSat Nov 14 10:34:18 2020(r367673) @@ -33,10 +33,14 @@ #include +#if defined(__aarch64__) || defined(__amd64__) || defined(__i386__) + #include #include #defineACPI_HANDLE(dev)\ ((dev)->bsddev != NULL ? bsd_acpi_get_handle((dev)->bsddev) : NULL) + +#endif #endif /* _LINUX_ACPI_H_ */ ___ 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: r367674 - head/stand/common
Author: tsoome Date: Sat Nov 14 10:56:40 2020 New Revision: 367674 URL: https://svnweb.freebsd.org/changeset/base/367674 Log: loader: cstyle cleanup of console.c cstyle cleanup only, no functional changes intended. Modified: head/stand/common/console.c Modified: head/stand/common/console.c == --- head/stand/common/console.c Sat Nov 14 10:34:18 2020(r367673) +++ head/stand/common/console.c Sat Nov 14 10:56:40 2020(r367674) @@ -49,97 +49,102 @@ static int twiddle_set(struct env_var *ev, int flags, void cons_probe(void) { -intcons; -intactive; -char *prefconsole; + int cons; + int active; + char*prefconsole; -/* We want a callback to install the new value when this var changes. */ -env_setenv("twiddle_divisor", EV_VOLATILE, "1", twiddle_set, env_nounset); + /* We want a callback to install the new value when this var changes. */ + env_setenv("twiddle_divisor", EV_VOLATILE, "1", twiddle_set, + env_nounset); -/* Do all console probes */ -for (cons = 0; consoles[cons] != NULL; cons++) { - consoles[cons]->c_flags = 0; - consoles[cons]->c_probe(consoles[cons]); -} -/* Now find the first working one */ -active = -1; -for (cons = 0; consoles[cons] != NULL && active == -1; cons++) { - consoles[cons]->c_flags = 0; - consoles[cons]->c_probe(consoles[cons]); - if (consoles[cons]->c_flags == (C_PRESENTIN | C_PRESENTOUT)) - active = cons; -} -/* Force a console even if all probes failed */ -if (active == -1) - active = 0; + /* Do all console probes */ + for (cons = 0; consoles[cons] != NULL; cons++) { + consoles[cons]->c_flags = 0; + consoles[cons]->c_probe(consoles[cons]); + } + /* Now find the first working one */ + active = -1; + for (cons = 0; consoles[cons] != NULL && active == -1; cons++) { + consoles[cons]->c_flags = 0; + consoles[cons]->c_probe(consoles[cons]); + if (consoles[cons]->c_flags == (C_PRESENTIN | C_PRESENTOUT)) + active = cons; + } + /* Force a console even if all probes failed */ + if (active == -1) + active = 0; -/* Check to see if a console preference has already been registered */ -prefconsole = getenv("console"); -if (prefconsole != NULL) - prefconsole = strdup(prefconsole); -if (prefconsole != NULL) { - unsetenv("console");/* we want to replace this */ - cons_change(prefconsole); -} else { - consoles[active]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT; - consoles[active]->c_init(0); - prefconsole = strdup(consoles[active]->c_name); -} + /* Check to see if a console preference has already been registered */ + prefconsole = getenv("console"); + if (prefconsole != NULL) + prefconsole = strdup(prefconsole); + if (prefconsole != NULL) { + unsetenv("console");/* we want to replace this */ + cons_change(prefconsole); + } else { + consoles[active]->c_flags |= C_ACTIVEIN | C_ACTIVEOUT; + consoles[active]->c_init(0); + prefconsole = strdup(consoles[active]->c_name); + } -printf("Consoles: "); -for (cons = 0; consoles[cons] != NULL; cons++) - if (consoles[cons]->c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) - printf("%s ", consoles[cons]->c_desc); -printf("\n"); + printf("Consoles: "); + for (cons = 0; consoles[cons] != NULL; cons++) + if (consoles[cons]->c_flags & (C_ACTIVEIN | C_ACTIVEOUT)) + printf("%s ", consoles[cons]->c_desc); + printf("\n"); -if (prefconsole != NULL) { - env_setenv("console", EV_VOLATILE, prefconsole, cons_set, - env_nounset); - free(prefconsole); -} + if (prefconsole != NULL) { + env_setenv("console", EV_VOLATILE, prefconsole, cons_set, + env_nounset); + free(prefconsole); + } } int getchar(void) { -intcons; -intrv; + int cons; + int rv; -/* Loop forever polling all active consoles */ -for(;;) - for (cons = 0; consoles[cons] != NULL; cons++) - if ((consoles[cons]->c_flags & (C_PRESENTIN | C_ACTIVEIN)) == - (C_PRESENTIN | C_ACTIVEIN) && - ((rv = consoles[cons]->c_in()) != -1)) - return(rv); + /* Loop forever polling all active consoles */ + for (;;) { + for (cons = 0; consoles[cons] != NULL; cons++) { + if ((consoles[cons]->c_flags & + (C_PR
svn commit: r367678 - head/usr.sbin/freebsd-update
Author: 0mp (doc,ports committer) Date: Sat Nov 14 13:07:41 2020 New Revision: 367678 URL: https://svnweb.freebsd.org/changeset/base/367678 Log: Document the PAGER environment variable Sometimes users want to use freebsd-update(8) in a non-interactive way and what they often miss is that they have to set PAGER to cat(1) in order to avoid interactive prompts from less(1). MFC after:4 weeks Modified: head/usr.sbin/freebsd-update/freebsd-update.8 Modified: head/usr.sbin/freebsd-update/freebsd-update.8 == --- head/usr.sbin/freebsd-update/freebsd-update.8 Sat Nov 14 12:02:50 2020(r367677) +++ head/usr.sbin/freebsd-update/freebsd-update.8 Sat Nov 14 13:07:41 2020(r367678) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd September 24, 2019 +.Dd November 14, 2020 .Dt FREEBSD-UPDATE 8 .Os .Sh NAME @@ -193,6 +193,20 @@ System", since if the system has been tampered with it cannot be trusted to operate correctly. If you intend to use this command for intrusion-detection purposes, make sure you boot from a secure disk (e.g., a CD). +.El +.Sh ENVIRONMENT +.Bl -tag -width "PAGER" +.It Ev PAGER +The pager program used to present various reports during the execution. +.Po +Default: +.Dq Pa /usr/bin/less . +.Pc +.Pp +.Ev PAGER +can be set to +.Dq cat +when a non-interactive pager is desired. .El .Sh FILES .Bl -tag -width "/etc/freebsd-update.conf" ___ 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: r367680 - head/sys/netinet6
Author: jtl Date: Sat Nov 14 14:50:34 2020 New Revision: 367680 URL: https://svnweb.freebsd.org/changeset/base/367680 Log: Fix implicit automatic local port selection for IPv6 during connect calls. When a user creates a TCP socket and tries to connect to the socket without explicitly binding the socket to a local address, the connect call implicitly chooses an appropriate local port. When evaluating candidate local ports, the algorithm checks for conflicts with existing ports by doing a lookup in the connection hash table. In this circumstance, both the IPv4 and IPv6 code look for exact matches in the hash table. However, the IPv4 code goes a step further and checks whether the proposed 4-tuple will match wildcard (e.g. TCP "listen") entries. The IPv6 code has no such check. The missing wildcard check can cause problems when connecting to a local server. It is possible that the algorithm will choose the same value for the local port as the foreign port uses. This results in a connection with identical source and destination addresses and ports. Changing the IPv6 code to align with the IPv4 code's behavior fixes this problem. Reviewed by: tuexen Sponsored by: Netflix Differential Revision:https://reviews.freebsd.org/D27164 Modified: head/sys/netinet6/in6_pcb.c Modified: head/sys/netinet6/in6_pcb.c == --- head/sys/netinet6/in6_pcb.c Sat Nov 14 14:15:49 2020(r367679) +++ head/sys/netinet6/in6_pcb.c Sat Nov 14 14:50:34 2020(r367680) @@ -464,7 +464,8 @@ in6_pcbconnect_mbuf(struct inpcb *inp, struct sockaddr rehash = false; error = in_pcb_lport_dest(inp, (struct sockaddr *) &laddr6, &inp->inp_lport, - (struct sockaddr *) sin6, sin6->sin6_port, cred, 0); + (struct sockaddr *) sin6, sin6->sin6_port, cred, + INPLOOKUP_WILDCARD); if (error) return (error); } ___ 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: r367685 - head/tests/sys/netinet
Author: jtl Date: Sat Nov 14 15:44:28 2020 New Revision: 367685 URL: https://svnweb.freebsd.org/changeset/base/367685 Log: Add a regression test for the port-selection behavior fixed in r367680. Reviewed by: markj, olivier, tuexen Sponsored by: Netflix Differential Revision:https://reviews.freebsd.org/D27173 Added: head/tests/sys/netinet/tcp_connect_port_test.c (contents, props changed) Modified: head/tests/sys/netinet/Makefile Modified: head/tests/sys/netinet/Makefile == --- head/tests/sys/netinet/Makefile Sat Nov 14 15:33:39 2020 (r367684) +++ head/tests/sys/netinet/Makefile Sat Nov 14 15:44:28 2020 (r367685) @@ -7,7 +7,8 @@ BINDIR= ${TESTSDIR} ATF_TESTS_C= ip_reass_test \ so_reuseport_lb_test \ - socket_afinet + socket_afinet \ + tcp_connect_port_test ATF_TESTS_SH= carp fibs fibs_test redirect divert forward output lpm TEST_METADATA.output+= required_programs="python" Added: head/tests/sys/netinet/tcp_connect_port_test.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/netinet/tcp_connect_port_test.c Sat Nov 14 15:44:28 2020(r367685) @@ -0,0 +1,334 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2020 Netflix, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in + *the documentation and/or other materials provided with the + *distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include + +#defineSYSCTLBAKFILE "tmp.net.inet.ip.portrange.randomized" + +/* + * Check if port allocation is randomized. If so, update it. Save the old + * value of the sysctl so it can be updated later. + */ +static void +disable_random_ports(void) +{ + int error, fd, random_new, random_save; + size_t sysctlsz; + + /* +* Pre-emptively unlink our restoration file, so we will do no +* restoration on error. +*/ + unlink(SYSCTLBAKFILE); + + /* +* Disable the net.inet.ip.portrange.randomized sysctl. Save the +* old value so we can restore it, if necessary. +*/ + random_new = 0; + sysctlsz = sizeof(random_save); + error = sysctlbyname("net.inet.ip.portrange.randomized", &random_save, + &sysctlsz, &random_new, sizeof(random_new)); + if (error) { + warn("sysctlbyname(\"net.inet.ip.portrange.randomized\") " + "failed"); + atf_tc_skip("Unable to set sysctl"); + } + if (sysctlsz != sizeof(random_save)) { + fprintf(stderr, "Error: unexpected sysctl value size " + "(expected %zu, actual %zu)\n", sizeof(random_save), + sysctlsz); + goto restore_sysctl; + } + + /* Open the backup file, write the contents, and close it. */ + fd = open(SYSCTLBAKFILE, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, + S_IRUSR|S_IWUSR); + if (fd < 0) { + warn("error opening sysctl backup file"); + goto restore_sysctl; + } + error = write(fd, &random_save, sizeof(random_save)); + if (error < 0) { + warn("error writing saved value to sysctl backup file"); + goto cleanup_and_restore; + } + if (error != (int)sizeof(random_save)) { + fprintf(stderr, + "Error writing saved value to sysctl backup file: " + "(expected %zu, actual
Re: svn commit: r367678 - head/usr.sbin/freebsd-update
> Author: 0mp (doc,ports committer) > Date: Sat Nov 14 13:07:41 2020 > New Revision: 367678 > URL: https://svnweb.freebsd.org/changeset/base/367678 > > Log: > Document the PAGER environment variable > > Sometimes users want to use freebsd-update(8) in a non-interactive way and > what they often miss is that they have to set PAGER to cat(1) in order to > avoid interactive prompts from less(1). Which was caused by the change of invoking more(1) as less(1) causing this regression, as when invoked as more(1) it falls off the end of empty input and causes no such interactive prompt. Setting PAGER to more(1) also fixes this. > > MFC after: 4 weeks > > Modified: > head/usr.sbin/freebsd-update/freebsd-update.8 > > Modified: head/usr.sbin/freebsd-update/freebsd-update.8 > == > --- head/usr.sbin/freebsd-update/freebsd-update.8 Sat Nov 14 12:02:50 > 2020(r367677) > +++ head/usr.sbin/freebsd-update/freebsd-update.8 Sat Nov 14 13:07:41 > 2020(r367678) > @@ -25,7 +25,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd September 24, 2019 > +.Dd November 14, 2020 > .Dt FREEBSD-UPDATE 8 > .Os > .Sh NAME > @@ -193,6 +193,20 @@ System", since if the system has been tampered with > it cannot be trusted to operate correctly. > If you intend to use this command for intrusion-detection > purposes, make sure you boot from a secure disk (e.g., a CD). > +.El > +.Sh ENVIRONMENT > +.Bl -tag -width "PAGER" > +.It Ev PAGER > +The pager program used to present various reports during the execution. > +.Po > +Default: > +.Dq Pa /usr/bin/less . > +.Pc > +.Pp > +.Ev PAGER > +can be set to > +.Dq cat > +when a non-interactive pager is desired. > .El > .Sh FILES > .Bl -tag -width "/etc/freebsd-update.conf" > -- Rod Grimes rgri...@freebsd.org ___ 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"
Re: svn commit: r367678 - head/usr.sbin/freebsd-update
Hello Rodney, On 11/14/20 4:59 PM, Rodney W. Grimes wrote: Author: 0mp (doc,ports committer) Date: Sat Nov 14 13:07:41 2020 New Revision: 367678 URL: https://svnweb.freebsd.org/changeset/base/367678 Log: Document the PAGER environment variable Sometimes users want to use freebsd-update(8) in a non-interactive way and what they often miss is that they have to set PAGER to cat(1) in order to avoid interactive prompts from less(1). Which was caused by the change of invoking more(1) as less(1) causing this regression, as when invoked as more(1) it falls off the end of empty input and causes no such interactive prompt. Setting PAGER to more(1) also fixes this. Mmm, I'm not sure if that would work. If I run "jot 1000 | more" in my terminal I still get an interactive prompt. Could it be that you are referring to a different more(1) implementation? I'm clearly missing something. ___ 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"
Re: svn commit: r367678 - head/usr.sbin/freebsd-update
On Sat, Nov 14, 2020 at 11:20 AM Mateusz Piotrowski <0...@freebsd.org> wrote: > > Hello Rodney, > > On 11/14/20 4:59 PM, Rodney W. Grimes wrote: > >> Author: 0mp (doc,ports committer) > >> Date: Sat Nov 14 13:07:41 2020 > >> New Revision: 367678 > >> URL: https://svnweb.freebsd.org/changeset/base/367678 > >> > >> Log: > >>Document the PAGER environment variable > >> > >>Sometimes users want to use freebsd-update(8) in a non-interactive way > >> and > >>what they often miss is that they have to set PAGER to cat(1) in order > >> to > >>avoid interactive prompts from less(1). > > Which was caused by the change of invoking more(1) as less(1) causing > > this regression, as when invoked as more(1) it falls off the end of > > empty input and causes no such interactive prompt. > > > > Setting PAGER to more(1) also fixes this. > > Mmm, I'm not sure if that would work. If I run "jot 1000 | more" in my > terminal I still get an > interactive prompt. Could it be that you are referring to a different more(1) > implementation? I'm > clearly missing something. > more(1) is more or less like `less -E`, which is a default PAGER I had advocated for back when it changed. It can be mostly non-interactive as long as your diffs are small, but it's definitely much less painful. ___ 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: r367686 - head/lib/libutil
Author: scottl Date: Sat Nov 14 17:57:50 2020 New Revision: 367686 URL: https://svnweb.freebsd.org/changeset/base/367686 Log: Add the library function getlocalbase and its manual page. This helps to unify the retrieval of the various ways that the local software base directory, typically "/usr/local", is expressed in the system. Reviewed by: se Differential Revision:https://reviews.freebsd.org/D27022 Added: head/lib/libutil/getlocalbase.3 (contents, props changed) head/lib/libutil/getlocalbase.c (contents, props changed) Modified: head/lib/libutil/Makefile head/lib/libutil/libutil.h Modified: head/lib/libutil/Makefile == --- head/lib/libutil/Makefile Sat Nov 14 15:44:28 2020(r367685) +++ head/lib/libutil/Makefile Sat Nov 14 17:57:50 2020(r367686) @@ -12,7 +12,8 @@ PACKAGE= runtime LIB= util SHLIB_MAJOR= 9 -SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c gr_util.c \ +SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c \ + getlocalbase.c gr_util.c \ hexdump.c humanize_number.c kinfo_getfile.c \ kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \ kinfo_getvmobject.c kld.c \ @@ -30,7 +31,7 @@ CFLAGS+= -DINET6 CFLAGS+= -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/ -MAN+= expand_number.3 flopen.3 fparseln.3 hexdump.3 \ +MAN+= expand_number.3 flopen.3 fparseln.3 getlocalbase.3 hexdump.3 \ humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \ kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \ login_auth.3 login_cap.3 \ Added: head/lib/libutil/getlocalbase.3 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libutil/getlocalbase.3 Sat Nov 14 17:57:50 2020 (r367686) @@ -0,0 +1,110 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright 2020 Scott Long +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\"notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\"notice, this list of conditions and the following disclaimer in the +.\"documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd Oct 28, 2020 +.Dt GETLOCALBASE 3 +.Os +.Sh NAME +.Nm getlocalbase +.Nd "return the path to the local software directory" +.Sh LIBRARY +.Lb libutil +.Sh SYNOPSIS +.In libutil.h +.Ft ssize_t +.Fn getlocalbase "char *path" "size_t len" +.Sh DESCRIPTION +The +.Fn getlocalbase +function returns the path to the local software base directory. +Normally this is the +.Pa /usr/local +directory. +First the +.Ev LOCALBASE +environment variable is checked. +If that doesn't exist then the +.Va user.localbase +sysctl is checked. +If that also doesn't exist then the value of the +.Dv _PATH_LOCALBASE +compile-time variable is used. +If that is undefined then the default of +.Pa /usr/local +is used. +.Pp +The +.Fa path +argument points to a caller-supplied buffer to hold the resulting pathname. +The +.Fa len +argument is the length of the caller-supplied buffer. +.Sh IMPLEMENTATION NOTES +Calls to +.Fn getlocalpath +will perform a setugid check on the running binary before checking the +environment. +.Sh RETURN VALUES +If the request completes without error, the size of the string copied into the +buffer, including the terminating NUL, is returned. +If an error occurred or the buffer was too small to hold the string, +.Fn getlocalbase +returns -1 and sets +.Em errno +to indicate the error condition. +.Sh ENVIRONMENT +The +.Fn getlocalbase +library function retrieves the +.Ev LOCALBASE +environment variable. +.Sh ERRORS +The +.Fn getlocalbase +function will fail and set +.Va errno +for the following conditions: +.Bl -tag -width Er +.It Bq Er EINVAL +One of the passed in pa
svn commit: r367687 - in head: sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg
Author: scottl Date: Sat Nov 14 18:01:14 2020 New Revision: 367687 URL: https://svnweb.freebsd.org/changeset/base/367687 Log: Replace hardcoded references to _PATH_LOCALBASE with calls to getlocalbase.3 Reviewed by: imp, se Modified: head/sbin/nvmecontrol/comnd.c head/sbin/nvmecontrol/comnd.h head/sbin/nvmecontrol/nvmecontrol.c head/usr.sbin/mailwrapper/mailwrapper.c head/usr.sbin/pkg/Makefile head/usr.sbin/pkg/pkg.c Modified: head/sbin/nvmecontrol/comnd.c == --- head/sbin/nvmecontrol/comnd.c Sat Nov 14 17:57:50 2020 (r367686) +++ head/sbin/nvmecontrol/comnd.c Sat Nov 14 18:01:14 2020 (r367687) @@ -287,7 +287,7 @@ bad_arg: * Loads all the .so's from the specified directory. */ void -cmd_load_dir(const char *dir __unused, cmd_load_cb_t cb __unused, void *argp __unused) +cmd_load_dir(char *dir, cmd_load_cb_t cb, void *argp) { DIR *d; struct dirent *dent; Modified: head/sbin/nvmecontrol/comnd.h == --- head/sbin/nvmecontrol/comnd.h Sat Nov 14 17:57:50 2020 (r367686) +++ head/sbin/nvmecontrol/comnd.h Sat Nov 14 18:01:14 2020 (r367687) @@ -96,7 +96,7 @@ void cmd_register(struct cmd *, struct cmd *); int arg_parse(int argc, char * const *argv, const struct cmd *f); void arg_help(int argc, char * const *argv, const struct cmd *f); void cmd_init(void); -void cmd_load_dir(const char *dir, cmd_load_cb_t *cb, void *argp); +void cmd_load_dir(char *dir, cmd_load_cb_t *cb, void *argp); int cmd_dispatch(int argc, char *argv[], const struct cmd *); #endif /* COMND_H */ Modified: head/sbin/nvmecontrol/nvmecontrol.c == --- head/sbin/nvmecontrol/nvmecontrol.c Sat Nov 14 17:57:50 2020 (r367686) +++ head/sbin/nvmecontrol/nvmecontrol.c Sat Nov 14 18:01:14 2020 (r367687) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -178,11 +179,17 @@ get_nsid(int fd, char **ctrlr_str, uint32_t *nsid) int main(int argc, char *argv[]) { + char locallib[MAXPATHLEN]; + size_t len; cmd_init(); - cmd_load_dir("/lib/nvmecontrol", NULL, NULL); - cmd_load_dir(_PATH_LOCALBASE "/lib/nvmecontrol", NULL, NULL); + snprintf(locallib, MAXPATHLEN, "/lib/nvmecontrol"); + cmd_load_dir(locallib, NULL, NULL); + if ((len = getlocalbase(locallib, MAXPATHLEN)) > 0) { + strlcat(locallib, "/lib/nvmecontrol", MAXPATHLEN - len); + cmd_load_dir(locallib, NULL, NULL); + } cmd_dispatch(argc, argv, NULL); Modified: head/usr.sbin/mailwrapper/mailwrapper.c == --- head/usr.sbin/mailwrapper/mailwrapper.c Sat Nov 14 17:57:50 2020 (r367686) +++ head/usr.sbin/mailwrapper/mailwrapper.c Sat Nov 14 18:01:14 2020 (r367687) @@ -105,8 +105,10 @@ main(int argc, char *argv[], char *envp[]) initarg(&al); addarg(&al, argv[0]); - snprintf(localmailerconf, MAXPATHLEN, "%s/etc/mail/mailer.conf", - getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE); + if ((len = getlocalbase(localmailerconf, MAXPATHLEN)) != 0) + err(EX_OSERR, "cannot determine local path"); + + strlcat(localmailerconf, "/etc/mail/mailer.conf", MAXPATHLEN - len); mailerconf = localmailerconf; if ((config = fopen(localmailerconf, "r")) == NULL) Modified: head/usr.sbin/pkg/Makefile == --- head/usr.sbin/pkg/Makefile Sat Nov 14 17:57:50 2020(r367686) +++ head/usr.sbin/pkg/Makefile Sat Nov 14 18:01:14 2020(r367687) @@ -25,6 +25,6 @@ MAN= pkg.7 CFLAGS+=-I${SRCTOP}/contrib/libucl/include .PATH: ${SRCTOP}/contrib/libucl/include -LIBADD=archive fetch ucl sbuf crypto ssl +LIBADD=archive fetch ucl sbuf crypto ssl util .include Modified: head/usr.sbin/pkg/pkg.c == --- head/usr.sbin/pkg/pkg.c Sat Nov 14 17:57:50 2020(r367686) +++ head/usr.sbin/pkg/pkg.c Sat Nov 14 18:01:14 2020(r367687) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1037,6 +1038,7 @@ main(int argc, char *argv[]) { char pkgpath[MAXPATHLEN]; const char *pkgarg; + size_t len; int i; bool bootstrap_only, force, yes; @@ -1045,8 +1047,11 @@ main(int argc, char *argv[]) pkgarg = NULL; yes = false; - snprintf(pkgpath, MAXPATHLEN, "%s/sbin/pkg", - getenv("LOCALBASE") ? getenv("LOCALBASE") : _PATH_LOCALBASE); +
svn commit: r367688 - head
Author: kevans Date: Sat Nov 14 18:06:35 2020 New Revision: 367688 URL: https://svnweb.freebsd.org/changeset/base/367688 Log: Makefile: re-wordsmith the blurb about xtoolchain ports The new version only includes a specific version once, and uses the one that's currently advised by tinderbox: -gcc6. It also advises just installing the pkg, but mentions in a side-note at the end where to find the source in the ports tree. Reviewed by: jrtc27 Suggested by: jhb (use default from tinderbox) Differential Revision:https://reviews.freebsd.org/D26820 Modified: head/Makefile Modified: head/Makefile == --- head/Makefile Sat Nov 14 18:01:14 2020(r367687) +++ head/Makefile Sat Nov 14 18:06:35 2020(r367688) @@ -89,14 +89,16 @@ # 10. `reboot' # 11. `make delete-old-libs' (in case no 3rd party program uses them anymore) # -# For individuals wanting to build from source with GCC from ports, first build -# or install an appropriate flavor of devel/freebsd-gcc9. The packages produced -# by this port are named "${TARGET_ARCH}-gcc9" -- note that not all -# architectures supported by FreeBSD have an external gcc toolchain available. +# For individuals wanting to build from source with GCC from ports, first +# install the appropriate GCC cross toolchain package: +# `pkg install ${TARGET_ARCH}-gccN` # -# Once the appropriate freebsd-gcc package is installed, simply pass -# CROSS_TOOLCHAIN=${TARGET_ARCH}-gcc9 while building with the above steps, -# e.g., `make buildworld CROSS_TOOLCHAIN=amd64-gcc9`. +# Once you have installed the necessary cross toolchain, simply pass +# CROSS_TOOLCHAIN=${TARGET_ARCH}-gccN while building with the above steps, +# e.g., `make buildworld CROSS_TOOLCHAIN=amd64-gcc6`. +# +# The ${TARGET_ARCH}-gccN packages are provided as flavors of the +# devel/freebsd-gccN ports. # # See src/UPDATING `COMMON ITEMS' for more complete information. # ___ 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"
Re: svn commit: r367686 - head/lib/libutil
Hi Scott, this somehow breaks the build. - ===> lib/msun (obj,all,install) /tank/nfs_public/tiny/src/lib/libutil/getlocalbase.c:69:30: error: comparison of integers of different signs: 'size_t' (aka 'unsigned long') and 'ssize_t' (aka 'long') [-Werror,-Wsign-compare] if ((tmplen < 0) || (tmplen >= (ssize_t)pathlen)) { ~~ ^ 1 error generated. --- getlocalbase.o --- *** [getlocalbase.o] Error code 1 . Got this on arm64 with the following src.conf: WITH_MALLOC_PRODUCTION=1 WITH_EXTRA_TCP_STACKS=1 WITH_BEARSSL=1 WITH_PIE=1 WITH_RETPOLINE=1 --Gordon On Sat, Nov 14, 2020 at 05:57:50PM +, Scott Long wrote: > Author: scottl > Date: Sat Nov 14 17:57:50 2020 > New Revision: 367686 > URL: https://svnweb.freebsd.org/changeset/base/367686 > > Log: > Add the library function getlocalbase and its manual page. This helps to > unify the retrieval of the various ways that the local software base > directory, > typically "/usr/local", is expressed in the system. > > Reviewed by:se > Differential Revision: https://reviews.freebsd.org/D27022 > > Added: > head/lib/libutil/getlocalbase.3 (contents, props changed) > head/lib/libutil/getlocalbase.c (contents, props changed) > Modified: > head/lib/libutil/Makefile > head/lib/libutil/libutil.h > > Modified: head/lib/libutil/Makefile > == > --- head/lib/libutil/Makefile Sat Nov 14 15:44:28 2020(r367685) > +++ head/lib/libutil/Makefile Sat Nov 14 17:57:50 2020(r367686) > @@ -12,7 +12,8 @@ PACKAGE=runtime > LIB= util > SHLIB_MAJOR= 9 > > -SRCS=_secure_path.c auth.c expand_number.c flopen.c fparseln.c > gr_util.c \ > +SRCS=_secure_path.c auth.c expand_number.c flopen.c fparseln.c \ > + getlocalbase.c gr_util.c \ > hexdump.c humanize_number.c kinfo_getfile.c \ > kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \ > kinfo_getvmobject.c kld.c \ > @@ -30,7 +31,7 @@ CFLAGS+= -DINET6 > > CFLAGS+= -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/ > > -MAN+=expand_number.3 flopen.3 fparseln.3 hexdump.3 \ > +MAN+=expand_number.3 flopen.3 fparseln.3 getlocalbase.3 hexdump.3 \ > humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \ > kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \ > login_auth.3 login_cap.3 \ > > Added: head/lib/libutil/getlocalbase.3 > == > --- /dev/null 00:00:00 1970 (empty, because file is newly added) > +++ head/lib/libutil/getlocalbase.3 Sat Nov 14 17:57:50 2020 > (r367686) > @@ -0,0 +1,110 @@ > +.\" > +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD > +.\" > +.\" Copyright 2020 Scott Long > +.\" > +.\" Redistribution and use in source and binary forms, with or without > +.\" modification, are permitted provided that the following conditions > +.\" are met: > +.\" 1. Redistributions of source code must retain the above copyright > +.\"notice, this list of conditions and the following disclaimer. > +.\" 2. Redistributions in binary form must reproduce the above copyright > +.\"notice, this list of conditions and the following disclaimer in the > +.\"documentation and/or other materials provided with the distribution. > +.\" > +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR > PURPOSE > +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR > CONSEQUENTIAL > +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, > STRICT > +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > +.\" SUCH DAMAGE. > +.\" > +.\" $FreeBSD$ > +.\" > +.Dd Oct 28, 2020 > +.Dt GETLOCALBASE 3 > +.Os > +.Sh NAME > +.Nm getlocalbase > +.Nd "return the path to the local software directory" > +.Sh LIBRARY > +.Lb libutil > +.Sh SYNOPSIS > +.In libutil.h > +.Ft ssize_t > +.Fn getlocalbase "char *path" "size_t len" > +.Sh DESCRIPTION > +The > +.Fn getlocalbase > +function returns the path to the local software base directory. > +Normally this is the > +.Pa /usr/local > +directory. > +First the > +.Ev LOCALBASE > +environment variable is checked. > +If that doesn't exist then the > +.Va user.localbase > +sysctl is checked. > +If that also doesn't
Re: svn commit: r367686 - head/lib/libutil
Hi, Yeah, I’m working on a fix, sorry. I made a last minute change that I thought I had tested, but apparently hadn’t. Scott > On Nov 14, 2020, at 11:43 AM, Gordon Bergling wrote: > > Hi Scott, > > this somehow breaks the build. > > - > ===> lib/msun (obj,all,install) > /tank/nfs_public/tiny/src/lib/libutil/getlocalbase.c:69:30: error: comparison > of integers of different signs: 'size_t' (aka 'unsigned long') and 'ssize_t' > (aka 'long') [-Werror,-Wsign-compare] >if ((tmplen < 0) || (tmplen >= (ssize_t)pathlen)) { > ~~ ^ > 1 error generated. > --- getlocalbase.o --- > *** [getlocalbase.o] Error code 1 > . > > Got this on arm64 with the following src.conf: > > WITH_MALLOC_PRODUCTION=1 > WITH_EXTRA_TCP_STACKS=1 > WITH_BEARSSL=1 > WITH_PIE=1 > WITH_RETPOLINE=1 > > --Gordon > > On Sat, Nov 14, 2020 at 05:57:50PM +, Scott Long wrote: >> Author: scottl >> Date: Sat Nov 14 17:57:50 2020 >> New Revision: 367686 >> URL: https://svnweb.freebsd.org/changeset/base/367686 >> >> Log: >> Add the library function getlocalbase and its manual page. This helps to >> unify the retrieval of the various ways that the local software base >> directory, >> typically "/usr/local", is expressed in the system. >> >> Reviewed by:se >> Differential Revision: https://reviews.freebsd.org/D27022 >> >> Added: >> head/lib/libutil/getlocalbase.3 (contents, props changed) >> head/lib/libutil/getlocalbase.c (contents, props changed) >> Modified: >> head/lib/libutil/Makefile >> head/lib/libutil/libutil.h >> >> Modified: head/lib/libutil/Makefile >> == >> --- head/lib/libutil/MakefileSat Nov 14 15:44:28 2020 >> (r367685) >> +++ head/lib/libutil/MakefileSat Nov 14 17:57:50 2020 >> (r367686) >> @@ -12,7 +12,8 @@ PACKAGE= runtime >> LIB= util >> SHLIB_MAJOR= 9 >> >> -SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c >> gr_util.c \ >> +SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c \ >> +getlocalbase.c gr_util.c \ >> hexdump.c humanize_number.c kinfo_getfile.c \ >> kinfo_getallproc.c kinfo_getproc.c kinfo_getvmmap.c \ >> kinfo_getvmobject.c kld.c \ >> @@ -30,7 +31,7 @@ CFLAGS+= -DINET6 >> >> CFLAGS+= -I${.CURDIR} -I${SRCTOP}/lib/libc/gen/ >> >> -MAN+= expand_number.3 flopen.3 fparseln.3 hexdump.3 \ >> +MAN+= expand_number.3 flopen.3 fparseln.3 getlocalbase.3 hexdump.3 \ >> humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \ >> kinfo_getproc.3 kinfo_getvmmap.3 kinfo_getvmobject.3 kld.3 \ >> login_auth.3 login_cap.3 \ >> >> Added: head/lib/libutil/getlocalbase.3 >> == >> --- /dev/null00:00:00 1970 (empty, because file is newly added) >> +++ head/lib/libutil/getlocalbase.3 Sat Nov 14 17:57:50 2020 >> (r367686) >> @@ -0,0 +1,110 @@ >> +.\" >> +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD >> +.\" >> +.\" Copyright 2020 Scott Long >> +.\" >> +.\" Redistribution and use in source and binary forms, with or without >> +.\" modification, are permitted provided that the following conditions >> +.\" are met: >> +.\" 1. Redistributions of source code must retain the above copyright >> +.\"notice, this list of conditions and the following disclaimer. >> +.\" 2. Redistributions in binary form must reproduce the above copyright >> +.\"notice, this list of conditions and the following disclaimer in the >> +.\"documentation and/or other materials provided with the distribution. >> +.\" >> +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND >> +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >> +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >> PURPOSE >> +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE >> +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >> CONSEQUENTIAL >> +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS >> +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >> +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, >> STRICT >> +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY >> WAY >> +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >> +.\" SUCH DAMAGE. >> +.\" >> +.\" $FreeBSD$ >> +.\" >> +.Dd Oct 28, 2020 >> +.Dt GETLOCALBASE 3 >> +.Os >> +.Sh NAME >> +.Nm getlocalbase >> +.Nd "return the path to the local software directory" >> +.Sh LIBRARY >> +.Lb libutil >> +.Sh SYNOPSIS >> +.In libutil.h >> +.Ft ssize_t >> +.Fn getlocalbase "char *path" "size_t len
svn commit: r367689 - head/lib/libutil
Author: scottl Date: Sat Nov 14 19:04:36 2020 New Revision: 367689 URL: https://svnweb.freebsd.org/changeset/base/367689 Log: Fix a problem with r367686 related to the use of ssize_t. Not sure how this escaped prior testing, but it should be better now. Reported by: lots Modified: head/lib/libutil/getlocalbase.c head/lib/libutil/libutil.h Modified: head/lib/libutil/getlocalbase.c == --- head/lib/libutil/getlocalbase.c Sat Nov 14 18:06:35 2020 (r367688) +++ head/lib/libutil/getlocalbase.c Sat Nov 14 19:04:36 2020 (r367689) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -66,10 +67,16 @@ getlocalbase(char *path, size_t pathlen) #endif tmplen = strlcpy(path, tmppath, pathlen); - if ((tmplen < 0) || (tmplen >= (ssize_t)pathlen)) { + if ((tmplen < 0) || (tmplen >= pathlen)) { errno = ENOMEM; - tmplen = -1; + return (-1); } - return (tmplen); + /* It's unlikely that the buffer would be this big */ + if (tmplen >= SSIZE_MAX) { + errno = ENOMEM; + return (-1); + } + + return ((ssize_t)tmplen); } Modified: head/lib/libutil/libutil.h == --- head/lib/libutil/libutil.h Sat Nov 14 18:06:35 2020(r367688) +++ head/lib/libutil/libutil.h Sat Nov 14 19:04:36 2020(r367689) @@ -65,6 +65,11 @@ typedef __size_tsize_t; #define_SIZE_T_DECLARED #endif +#ifndef _SSIZE_T_DECLARED +typedef __ssize_t ssize_t; +#define _SSIZE_T_DECLARED +#endif + #ifndef _UID_T_DECLARED typedef__uid_t uid_t; #define_UID_T_DECLARED ___ 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: r367690 - head/usr.bin/login
Author: bapt Date: Sat Nov 14 19:16:39 2020 New Revision: 367690 URL: https://svnweb.freebsd.org/changeset/base/367690 Log: Change the default locale to C.UTF-8 The C.UTF-8 locales is the same as the actual C locale except it does support the unicode character set. But the collation etc are still the same as the C locale one. Reviewed by: many Approved by: many Differential Revision:https://reviews.freebsd.org/D26973 Modified: head/usr.bin/login/login.conf Modified: head/usr.bin/login/login.conf == --- head/usr.bin/login/login.conf Sat Nov 14 19:04:36 2020 (r367689) +++ head/usr.bin/login/login.conf Sat Nov 14 19:16:39 2020 (r367690) @@ -47,8 +47,9 @@ default:\ :umtxp=unlimited:\ :priority=0:\ :ignoretime@:\ - :umask=022: - + :umask=022:\ + :charset=UTF-8:\ + :lang=C.UTF-8: # # A collection of common class names - forward them all to '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: r367691 - head/sys/kern
Author: mjg Date: Sat Nov 14 19:19:27 2020 New Revision: 367691 URL: https://svnweb.freebsd.org/changeset/base/367691 Log: thread: pad tid lock On a kernel with other changes this bumps 104-way thread creation/destruction from 0.96 mln ops/s to 1.1 mln ops/s. Modified: head/sys/kern/kern_thread.c Modified: head/sys/kern/kern_thread.c == --- head/sys/kern/kern_thread.c Sat Nov 14 19:16:39 2020(r367690) +++ head/sys/kern/kern_thread.c Sat Nov 14 19:19:27 2020(r367691) @@ -135,7 +135,7 @@ static int thread_unsuspend_one(struct thread *td, str bool boundary); static void thread_free_batched(struct thread *td); -static struct mtx tid_lock; +static __exclusive_cache_line struct mtx tid_lock; static bitstr_t *tid_bitmap; static MALLOC_DEFINE(M_TIDHASH, "tidhash", "thread hash"); ___ 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: r367692 - head/sys/sys
Author: mjg Date: Sat Nov 14 19:20:37 2020 New Revision: 367692 URL: https://svnweb.freebsd.org/changeset/base/367692 Log: cred: reorder cr_audit to be closer to the lock This makes cr_uid avoid sharing. Modified: head/sys/sys/ucred.h Modified: head/sys/sys/ucred.h == --- head/sys/sys/ucred.hSat Nov 14 19:19:27 2020(r367691) +++ head/sys/sys/ucred.hSat Nov 14 19:20:37 2020(r367692) @@ -63,6 +63,7 @@ struct ucred { struct mtx cr_mtx; u_int cr_ref; /* (c) reference count */ u_int cr_users; /* (c) proc + thread using this cred */ + struct auditinfo_addr cr_audit; /* Audit properties. */ #definecr_startcopy cr_uid uid_t cr_uid; /* effective user id */ uid_t cr_ruid;/* real user id */ @@ -78,7 +79,6 @@ struct ucred { void*cr_pspare2[2]; /* general use 2 */ #definecr_endcopy cr_label struct label*cr_label; /* MAC label */ - struct auditinfo_addr cr_audit; /* Audit properties. */ gid_t *cr_groups; /* groups */ int cr_agroups; /* Available groups */ gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small groups */ ___ 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: r367693 - head/sys/kern
Author: mjg Date: Sat Nov 14 19:20:58 2020 New Revision: 367693 URL: https://svnweb.freebsd.org/changeset/base/367693 Log: thread: rework tid batch to use helpers Modified: head/sys/kern/kern_thread.c Modified: head/sys/kern/kern_thread.c == --- head/sys/kern/kern_thread.c Sat Nov 14 19:20:37 2020(r367692) +++ head/sys/kern/kern_thread.c Sat Nov 14 19:20:58 2020(r367693) @@ -259,6 +259,54 @@ tid_free_batch(lwpid_t *batch, int n) } /* + * Batching for thread reapping. + */ +struct tidbatch { + lwpid_t tab[16]; + int n; +}; + +static void +tidbatch_prep(struct tidbatch *tb) +{ + + tb->n = 0; +} + +static void +tidbatch_add(struct tidbatch *tb, struct thread *td) +{ + + KASSERT(tb->n < nitems(tb->tab), + ("%s: count too high %d", __func__, tb->n)); + tb->tab[tb->n] = td->td_tid; + tb->n++; +} + +static void +tidbatch_process(struct tidbatch *tb) +{ + + KASSERT(tb->n <= nitems(tb->tab), + ("%s: count too high %d", __func__, tb->n)); + if (tb->n == nitems(tb->tab)) { + tid_free_batch(tb->tab, tb->n); + tb->n = 0; + } +} + +static void +tidbatch_final(struct tidbatch *tb) +{ + + KASSERT(tb->n <= nitems(tb->tab), + ("%s: count too high %d", __func__, tb->n)); + if (tb->n != 0) { + tid_free_batch(tb->tab, tb->n); + } +} + +/* * Prepare a thread for use. */ static int @@ -487,8 +535,8 @@ void thread_reap(void) { struct thread *itd, *ntd; - lwpid_t tidbatch[16]; - int tidbatchn; + struct tidbatch tidbatch; + int tdcount; /* * Reading upfront is pessimal if followed by concurrent atomic_swap, @@ -499,24 +547,29 @@ thread_reap(void) itd = (struct thread *)atomic_swap_ptr((uintptr_t *)&thread_zombies, (uintptr_t)NULL); - tidbatchn = 0; + if (itd == NULL) + return; + + tidbatch_prep(&tidbatch); + tdcount = 0; while (itd != NULL) { ntd = itd->td_zombie; - tidbatch[tidbatchn] = itd->td_tid; - tidbatchn++; + EVENTHANDLER_DIRECT_INVOKE(thread_dtor, itd); + tidbatch_add(&tidbatch, itd); thread_cow_free(itd); thread_free_batched(itd); - if (tidbatchn == nitems(tidbatch)) { - tid_free_batch(tidbatch, tidbatchn); - thread_count_sub(tidbatchn); - tidbatchn = 0; + tidbatch_process(&tidbatch); + tdcount++; + if (tdcount == 32) { + thread_count_sub(tdcount); + tdcount = 0; } itd = ntd; } - if (tidbatchn != 0) { - tid_free_batch(tidbatch, tidbatchn); - thread_count_sub(tidbatchn); + tidbatch_final(&tidbatch); + if (tdcount != 0) { + thread_count_sub(tdcount); } } @@ -567,7 +620,6 @@ static void thread_free_batched(struct thread *td) { - EVENTHANDLER_DIRECT_INVOKE(thread_dtor, td); lock_profile_thread_exit(td); if (td->td_cpuset) cpuset_rel(td->td_cpuset); @@ -588,6 +640,7 @@ thread_free(struct thread *td) { lwpid_t tid; + EVENTHANDLER_DIRECT_INVOKE(thread_dtor, td); tid = td->td_tid; thread_free_batched(td); tid_free(tid); ___ 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: r367695 - in head/sys: kern sys
Author: mjg Date: Sat Nov 14 19:22:02 2020 New Revision: 367695 URL: https://svnweb.freebsd.org/changeset/base/367695 Log: thread: batch credential freeing Modified: head/sys/kern/kern_prot.c head/sys/kern/kern_thread.c head/sys/sys/ucred.h Modified: head/sys/kern/kern_prot.c == --- head/sys/kern/kern_prot.c Sat Nov 14 19:21:46 2020(r367694) +++ head/sys/kern/kern_prot.c Sat Nov 14 19:22:02 2020(r367695) @@ -86,6 +86,7 @@ static MALLOC_DEFINE(M_CRED, "cred", "credentials"); SYSCTL_NODE(_security, OID_AUTO, bsd, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "BSD security policy"); +static void crfree_final(struct ucred *cr); static void crsetgroups_locked(struct ucred *cr, int ngrp, gid_t *groups); @@ -1902,6 +1903,31 @@ crunuse(struct thread *td) return (crold); } +static void +crunusebatch(struct ucred *cr, int users, int ref) +{ + + KASSERT(users > 0, ("%s: passed users %d not > 0 ; cred %p", + __func__, users, cr)); + mtx_lock(&cr->cr_mtx); + KASSERT(cr->cr_users >= users, ("%s: users %d not > %d on cred %p", + __func__, cr->cr_users, users, cr)); + cr->cr_users -= users; + cr->cr_ref += ref; + cr->cr_ref -= users; + if (cr->cr_users > 0) { + mtx_unlock(&cr->cr_mtx); + return; + } + KASSERT(cr->cr_ref >= 0, ("%s: ref %d not >= 0 on cred %p", + __func__, cr->cr_ref, cr)); + if (cr->cr_ref > 0) { + mtx_unlock(&cr->cr_mtx); + return; + } + crfree_final(cr); +} + void crcowfree(struct thread *td) { @@ -1935,6 +1961,44 @@ crcowsync(void) } /* + * Batching. + */ +void +credbatch_add(struct credbatch *crb, struct thread *td) +{ + struct ucred *cr; + + MPASS(td->td_realucred != NULL); + MPASS(td->td_realucred == td->td_ucred); + MPASS(td->td_state == TDS_INACTIVE); + cr = td->td_realucred; + KASSERT(cr->cr_users > 0, ("%s: users %d not > 0 on cred %p", + __func__, cr->cr_users, cr)); + if (crb->cred != cr) { + if (crb->users > 0) { + MPASS(crb->cred != NULL); + crunusebatch(crb->cred, crb->users, crb->ref); + crb->users = 0; + crb->ref = 0; + } + } + crb->cred = cr; + crb->users++; + crb->ref += td->td_ucredref; + td->td_ucredref = 0; + td->td_realucred = NULL; +} + +void +credbatch_final(struct credbatch *crb) +{ + + MPASS(crb->cred != NULL); + MPASS(crb->users > 0); + crunusebatch(crb->cred, crb->users, crb->ref); +} + +/* * Allocate a zeroed cred structure. */ struct ucred * @@ -2007,6 +2071,17 @@ crfree(struct ucred *cr) mtx_unlock(&cr->cr_mtx); return; } + crfree_final(cr); +} + +static void +crfree_final(struct ucred *cr) +{ + + KASSERT(cr->cr_users == 0, ("%s: users %d not == 0 on cred %p", + __func__, cr->cr_users, cr)); + KASSERT(cr->cr_ref == 0, ("%s: ref %d not == 0 on cred %p", + __func__, cr->cr_ref, cr)); /* * Some callers of crget(), such as nfs_statfs(), allocate a temporary * credential, but don't allocate a uidinfo structure. Modified: head/sys/kern/kern_thread.c == --- head/sys/kern/kern_thread.c Sat Nov 14 19:21:46 2020(r367694) +++ head/sys/kern/kern_thread.c Sat Nov 14 19:22:02 2020(r367695) @@ -536,6 +536,7 @@ thread_reap(void) { struct thread *itd, *ntd; struct tidbatch tidbatch; + struct credbatch credbatch; int tdcount; struct plimit *lim; int limcount; @@ -553,6 +554,7 @@ thread_reap(void) return; tidbatch_prep(&tidbatch); + credbatch_prep(&credbatch); tdcount = 0; lim = NULL; limcount = 0; @@ -560,8 +562,7 @@ thread_reap(void) ntd = itd->td_zombie; EVENTHANDLER_DIRECT_INVOKE(thread_dtor, itd); tidbatch_add(&tidbatch, itd); - MPASS(itd->td_realucred != NULL); - crcowfree(itd); + credbatch_add(&credbatch, itd); MPASS(itd->td_limit != NULL); if (lim != itd->td_limit) { if (limcount != 0) { @@ -573,6 +574,7 @@ thread_reap(void) limcount++; thread_free_batched(itd); tidbatch_process(&tidbatch); + credbatch_process(&credbatch); tdcount++; if (tdcount == 32) { thread_count_sub(tdcount); @@ -582,6 +584,7 @@ thread_reap(void) } tidbatch_final(&tidbatch); + credbatch_final(&credbatch); if (tdcount != 0) {
svn commit: r367694 - in head/sys: kern sys
Author: mjg Date: Sat Nov 14 19:21:46 2020 New Revision: 367694 URL: https://svnweb.freebsd.org/changeset/base/367694 Log: thread: batch resource limit free calls Modified: head/sys/kern/kern_resource.c head/sys/kern/kern_thread.c head/sys/sys/resourcevar.h Modified: head/sys/kern/kern_resource.c == --- head/sys/kern/kern_resource.c Sat Nov 14 19:20:58 2020 (r367693) +++ head/sys/kern/kern_resource.c Sat Nov 14 19:21:46 2020 (r367694) @@ -1236,6 +1236,14 @@ lim_free(struct plimit *limp) free((void *)limp, M_PLIMIT); } +void +lim_freen(struct plimit *limp, int n) +{ + + if (refcount_releasen(&limp->pl_refcnt, n)) + free((void *)limp, M_PLIMIT); +} + /* * Make a copy of the plimit structure. * We share these structures copy-on-write after fork. Modified: head/sys/kern/kern_thread.c == --- head/sys/kern/kern_thread.c Sat Nov 14 19:20:58 2020(r367693) +++ head/sys/kern/kern_thread.c Sat Nov 14 19:21:46 2020(r367694) @@ -537,6 +537,8 @@ thread_reap(void) struct thread *itd, *ntd; struct tidbatch tidbatch; int tdcount; + struct plimit *lim; + int limcount; /* * Reading upfront is pessimal if followed by concurrent atomic_swap, @@ -552,11 +554,23 @@ thread_reap(void) tidbatch_prep(&tidbatch); tdcount = 0; + lim = NULL; + limcount = 0; while (itd != NULL) { ntd = itd->td_zombie; EVENTHANDLER_DIRECT_INVOKE(thread_dtor, itd); tidbatch_add(&tidbatch, itd); - thread_cow_free(itd); + MPASS(itd->td_realucred != NULL); + crcowfree(itd); + MPASS(itd->td_limit != NULL); + if (lim != itd->td_limit) { + if (limcount != 0) { + lim_freen(lim, limcount); + limcount = 0; + } + } + lim = itd->td_limit; + limcount++; thread_free_batched(itd); tidbatch_process(&tidbatch); tdcount++; @@ -571,6 +585,8 @@ thread_reap(void) if (tdcount != 0) { thread_count_sub(tdcount); } + MPASS(limcount != 0); + lim_freen(lim, limcount); } /* Modified: head/sys/sys/resourcevar.h == --- head/sys/sys/resourcevar.h Sat Nov 14 19:20:58 2020(r367693) +++ head/sys/sys/resourcevar.h Sat Nov 14 19:21:46 2020(r367694) @@ -145,6 +145,7 @@ rlim_t lim_cur(struct thread *td, int which); rlim_t lim_cur_proc(struct proc *p, int which); voidlim_fork(struct proc *p1, struct proc *p2); voidlim_free(struct plimit *limp); +voidlim_freen(struct plimit *limp, int n); struct plimit *lim_hold(struct plimit *limp); rlim_t lim_max(struct thread *td, int which); ___ 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: r367696 - head/sys/contrib/openzfs/module/zfs
Author: mjg Date: Sat Nov 14 19:23:07 2020 New Revision: 367696 URL: https://svnweb.freebsd.org/changeset/base/367696 Log: zfs: disable periodic arc updates They are only there to provide less innacurate statistics for debuggers. However, this is quite heavy-weight and instead it would be better to teach debuggers how to obtain the necessary information. Modified: head/sys/contrib/openzfs/module/zfs/arc.c Modified: head/sys/contrib/openzfs/module/zfs/arc.c == --- head/sys/contrib/openzfs/module/zfs/arc.c Sat Nov 14 19:22:02 2020 (r367695) +++ head/sys/contrib/openzfs/module/zfs/arc.c Sat Nov 14 19:23:07 2020 (r367696) @@ -4791,8 +4791,10 @@ arc_evict_cb_check(void *arg, zthr_t *zthr) * arc_state_t structures can be queried directly if more * accurate information is needed. */ +#ifndef __FreeBSD__ if (arc_ksp != NULL) arc_ksp->ks_update(arc_ksp, KSTAT_READ); +#endif /* * We have to rely on arc_wait_for_eviction() to tell us when to ___ 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"
Re: svn commit: r367689 - head/lib/libutil
On 14 Nov 2020, at 19:04, Scott Long wrote: > @@ -66,10 +67,16 @@ getlocalbase(char *path, size_t pathlen) > #endif > > tmplen = strlcpy(path, tmppath, pathlen); > - if ((tmplen < 0) || (tmplen >= (ssize_t)pathlen)) { > + if ((tmplen < 0) || (tmplen >= pathlen)) { I'd expect the LHS to give a compiler warning still. Jess ___ 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: r367697 - head/sys/sys
Author: mjg Date: Sat Nov 14 19:56:11 2020 New Revision: 367697 URL: https://svnweb.freebsd.org/changeset/base/367697 Log: cred: annotate credbatch_process argument as unused Fixes libprocstat compilation as zfs defines _KERNEL. Modified: head/sys/sys/ucred.h Modified: head/sys/sys/ucred.h == --- head/sys/sys/ucred.hSat Nov 14 19:23:07 2020(r367696) +++ head/sys/sys/ucred.hSat Nov 14 19:56:11 2020(r367697) @@ -129,7 +129,7 @@ credbatch_prep(struct credbatch *crb) } void credbatch_add(struct credbatch *crb, struct thread *td); static inline void -credbatch_process(struct credbatch *crb) +credbatch_process(struct credbatch *crb __unused) { } ___ 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"
Re: svn commit: r367692 - head/sys/sys
On Sat, Nov 14, 2020 at 07:20:37PM +, Mateusz Guzik wrote: > Author: mjg > Date: Sat Nov 14 19:20:37 2020 > New Revision: 367692 > URL: https://svnweb.freebsd.org/changeset/base/367692 > > Log: > cred: reorder cr_audit to be closer to the lock > > This makes cr_uid avoid sharing. > > Modified: > head/sys/sys/ucred.h > > Modified: head/sys/sys/ucred.h > == > --- head/sys/sys/ucred.h Sat Nov 14 19:19:27 2020(r367691) > +++ head/sys/sys/ucred.h Sat Nov 14 19:20:37 2020(r367692) > @@ -63,6 +63,7 @@ struct ucred { > struct mtx cr_mtx; > u_int cr_ref; /* (c) reference count */ > u_int cr_users; /* (c) proc + thread using this cred */ > + struct auditinfo_addr cr_audit; /* Audit properties. */ > #define cr_startcopy cr_uid > uid_t cr_uid; /* effective user id */ > uid_t cr_ruid;/* real user id */ > @@ -78,7 +79,6 @@ struct ucred { > void*cr_pspare2[2]; /* general use 2 */ > #define cr_endcopy cr_label > struct label*cr_label; /* MAC label */ > - struct auditinfo_addr cr_audit; /* Audit properties. */ > gid_t *cr_groups; /* groups */ > int cr_agroups; /* Available groups */ > gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small groups */ Hey Mateusz, Since this changes KBI, does __FreeBSD_version need bumping? Thanks, -- Shawn Webb Cofounder / Security Engineer HardenedBSD GPG Key ID: 0xFF2E67A277F8E1FA GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 0FB2 https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc signature.asc Description: PGP signature
Re: svn commit: r367692 - head/sys/sys
I don't think so, it does not change any APIs On 11/14/20, Shawn Webb wrote: > On Sat, Nov 14, 2020 at 07:20:37PM +, Mateusz Guzik wrote: >> Author: mjg >> Date: Sat Nov 14 19:20:37 2020 >> New Revision: 367692 >> URL: https://svnweb.freebsd.org/changeset/base/367692 >> >> Log: >> cred: reorder cr_audit to be closer to the lock >> >> This makes cr_uid avoid sharing. >> >> Modified: >> head/sys/sys/ucred.h >> >> Modified: head/sys/sys/ucred.h >> == >> --- head/sys/sys/ucred.h Sat Nov 14 19:19:27 2020(r367691) >> +++ head/sys/sys/ucred.h Sat Nov 14 19:20:37 2020(r367692) >> @@ -63,6 +63,7 @@ struct ucred { >> struct mtx cr_mtx; >> u_int cr_ref; /* (c) reference count */ >> u_int cr_users; /* (c) proc + thread using this cred */ >> +struct auditinfo_addr cr_audit; /* Audit properties. */ >> #define cr_startcopy cr_uid >> uid_t cr_uid; /* effective user id */ >> uid_t cr_ruid;/* real user id */ >> @@ -78,7 +79,6 @@ struct ucred { >> void*cr_pspare2[2]; /* general use 2 */ >> #define cr_endcopy cr_label >> struct label*cr_label; /* MAC label */ >> -struct auditinfo_addr cr_audit; /* Audit properties. */ >> gid_t *cr_groups; /* groups */ >> int cr_agroups; /* Available groups */ >> gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small groups */ > > Hey Mateusz, > > Since this changes KBI, does __FreeBSD_version need bumping? > > Thanks, > > -- > Shawn Webb > Cofounder / Security Engineer > HardenedBSD > > GPG Key ID: 0xFF2E67A277F8E1FA > GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 0FB2 > https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc > -- Mateusz Guzik ___ 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"
Re: svn commit: r367692 - head/sys/sys
Are there any kernel modules (in base, in ports, or out-of-both-trees) that access struct ucred? On Sat, Nov 14, 2020 at 09:51:47PM +0100, Mateusz Guzik wrote: > I don't think so, it does not change any APIs > > On 11/14/20, Shawn Webb wrote: > > On Sat, Nov 14, 2020 at 07:20:37PM +, Mateusz Guzik wrote: > >> Author: mjg > >> Date: Sat Nov 14 19:20:37 2020 > >> New Revision: 367692 > >> URL: https://svnweb.freebsd.org/changeset/base/367692 > >> > >> Log: > >> cred: reorder cr_audit to be closer to the lock > >> > >> This makes cr_uid avoid sharing. > >> > >> Modified: > >> head/sys/sys/ucred.h > >> > >> Modified: head/sys/sys/ucred.h > >> == > >> --- head/sys/sys/ucred.h Sat Nov 14 19:19:27 2020(r367691) > >> +++ head/sys/sys/ucred.h Sat Nov 14 19:20:37 2020(r367692) > >> @@ -63,6 +63,7 @@ struct ucred { > >>struct mtx cr_mtx; > >>u_int cr_ref; /* (c) reference count */ > >>u_int cr_users; /* (c) proc + thread using this cred */ > >> + struct auditinfo_addr cr_audit; /* Audit properties. */ > >> #define cr_startcopy cr_uid > >>uid_t cr_uid; /* effective user id */ > >>uid_t cr_ruid;/* real user id */ > >> @@ -78,7 +79,6 @@ struct ucred { > >>void*cr_pspare2[2]; /* general use 2 */ > >> #define cr_endcopy cr_label > >>struct label*cr_label; /* MAC label */ > >> - struct auditinfo_addr cr_audit; /* Audit properties. */ > >>gid_t *cr_groups; /* groups */ > >>int cr_agroups; /* Available groups */ > >>gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small groups */ > > > > Hey Mateusz, > > > > Since this changes KBI, does __FreeBSD_version need bumping? > > > > Thanks, > > > > -- > > Shawn Webb > > Cofounder / Security Engineer > > HardenedBSD > > > > GPG Key ID: 0xFF2E67A277F8E1FA > > GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 0FB2 > > https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc > > > > > -- > Mateusz Guzik -- Shawn Webb Cofounder / Security Engineer HardenedBSD GPG Key ID: 0xFF2E67A277F8E1FA GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 0FB2 https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc signature.asc Description: PGP signature
Re: svn commit: r367692 - head/sys/sys
you are expected to recompile all your kernel modules every time you update head On 11/14/20, Shawn Webb wrote: > Are there any kernel modules (in base, in ports, or out-of-both-trees) > that access struct ucred? > > On Sat, Nov 14, 2020 at 09:51:47PM +0100, Mateusz Guzik wrote: >> I don't think so, it does not change any APIs >> >> On 11/14/20, Shawn Webb wrote: >> > On Sat, Nov 14, 2020 at 07:20:37PM +, Mateusz Guzik wrote: >> >> Author: mjg >> >> Date: Sat Nov 14 19:20:37 2020 >> >> New Revision: 367692 >> >> URL: https://svnweb.freebsd.org/changeset/base/367692 >> >> >> >> Log: >> >> cred: reorder cr_audit to be closer to the lock >> >> >> >> This makes cr_uid avoid sharing. >> >> >> >> Modified: >> >> head/sys/sys/ucred.h >> >> >> >> Modified: head/sys/sys/ucred.h >> >> == >> >> --- head/sys/sys/ucred.h Sat Nov 14 19:19:27 2020(r367691) >> >> +++ head/sys/sys/ucred.h Sat Nov 14 19:20:37 2020(r367692) >> >> @@ -63,6 +63,7 @@ struct ucred { >> >> struct mtx cr_mtx; >> >> u_int cr_ref; /* (c) reference count */ >> >> u_int cr_users; /* (c) proc + thread using this cred */ >> >> + struct auditinfo_addr cr_audit; /* Audit properties. */ >> >> #define cr_startcopy cr_uid >> >> uid_t cr_uid; /* effective user id */ >> >> uid_t cr_ruid;/* real user id */ >> >> @@ -78,7 +79,6 @@ struct ucred { >> >> void*cr_pspare2[2]; /* general use 2 */ >> >> #define cr_endcopy cr_label >> >> struct label*cr_label; /* MAC label */ >> >> - struct auditinfo_addr cr_audit; /* Audit properties. */ >> >> gid_t *cr_groups; /* groups */ >> >> int cr_agroups; /* Available groups */ >> >> gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small groups */ >> > >> > Hey Mateusz, >> > >> > Since this changes KBI, does __FreeBSD_version need bumping? >> > >> > Thanks, >> > >> > -- >> > Shawn Webb >> > Cofounder / Security Engineer >> > HardenedBSD >> > >> > GPG Key ID: 0xFF2E67A277F8E1FA >> > GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 0FB2 >> > https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc >> > >> >> >> -- >> Mateusz Guzik > > -- > Shawn Webb > Cofounder / Security Engineer > HardenedBSD > > GPG Key ID: 0xFF2E67A277F8E1FA > GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 0FB2 > https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc > -- Mateusz Guzik ___ 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"
Re: svn commit: r367692 - head/sys/sys
true, but a version bump forces that and versions are cheap enough... Warner On Sat, Nov 14, 2020 at 1:58 PM Mateusz Guzik wrote: > you are expected to recompile all your kernel modules every time you > update head > > On 11/14/20, Shawn Webb wrote: > > Are there any kernel modules (in base, in ports, or out-of-both-trees) > > that access struct ucred? > > > > On Sat, Nov 14, 2020 at 09:51:47PM +0100, Mateusz Guzik wrote: > >> I don't think so, it does not change any APIs > >> > >> On 11/14/20, Shawn Webb wrote: > >> > On Sat, Nov 14, 2020 at 07:20:37PM +, Mateusz Guzik wrote: > >> >> Author: mjg > >> >> Date: Sat Nov 14 19:20:37 2020 > >> >> New Revision: 367692 > >> >> URL: https://svnweb.freebsd.org/changeset/base/367692 > >> >> > >> >> Log: > >> >> cred: reorder cr_audit to be closer to the lock > >> >> > >> >> This makes cr_uid avoid sharing. > >> >> > >> >> Modified: > >> >> head/sys/sys/ucred.h > >> >> > >> >> Modified: head/sys/sys/ucred.h > >> >> > == > >> >> --- head/sys/sys/ucred.h Sat Nov 14 19:19:27 2020(r367691) > >> >> +++ head/sys/sys/ucred.h Sat Nov 14 19:20:37 2020(r367692) > >> >> @@ -63,6 +63,7 @@ struct ucred { > >> >> struct mtx cr_mtx; > >> >> u_int cr_ref; /* (c) reference count */ > >> >> u_int cr_users; /* (c) proc + thread using this > cred */ > >> >> + struct auditinfo_addr cr_audit; /* Audit properties. */ > >> >> #define cr_startcopy cr_uid > >> >> uid_t cr_uid; /* effective user id */ > >> >> uid_t cr_ruid;/* real user id */ > >> >> @@ -78,7 +79,6 @@ struct ucred { > >> >> void*cr_pspare2[2]; /* general use 2 */ > >> >> #define cr_endcopy cr_label > >> >> struct label*cr_label; /* MAC label */ > >> >> - struct auditinfo_addr cr_audit; /* Audit properties. */ > >> >> gid_t *cr_groups; /* groups */ > >> >> int cr_agroups; /* Available groups */ > >> >> gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small > groups */ > >> > > >> > Hey Mateusz, > >> > > >> > Since this changes KBI, does __FreeBSD_version need bumping? > >> > > >> > Thanks, > >> > > >> > -- > >> > Shawn Webb > >> > Cofounder / Security Engineer > >> > HardenedBSD > >> > > >> > GPG Key ID: 0xFF2E67A277F8E1FA > >> > GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 > 0FB2 > >> > > https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc > >> > > >> > >> > >> -- > >> Mateusz Guzik > > > > -- > > Shawn Webb > > Cofounder / Security Engineer > > HardenedBSD > > > > GPG Key ID: 0xFF2E67A277F8E1FA > > GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 0FB2 > > > https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc > > > > > -- > Mateusz Guzik > ___ 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"
Re: svn commit: r367692 - head/sys/sys
There are "KBI" breaking changes happening all the time and version bumps only sometimes happen. The build process already has infrastructure to rebuild all port kmods as well -- see PORTS_MODULES in make.conf(5) Perhaps it would be beneficial to add checking that the kernel is older than the to-be-loaded module and refuse otherwise. Can be overwritten by a loader.conf knob, then people who run into problems explicitly asked for it. But it's not clear to me if "older" should mean build date or revision or something else. Still, I suspect it will be mostly annoying to developers. Regardless, I have no intention to working on any of this. Maybe PORTS_MODULES is just not advertised enough. On 11/14/20, Warner Losh wrote: > true, but a version bump forces that and versions are cheap enough... > > Warner > > On Sat, Nov 14, 2020 at 1:58 PM Mateusz Guzik wrote: > >> you are expected to recompile all your kernel modules every time you >> update head >> >> On 11/14/20, Shawn Webb wrote: >> > Are there any kernel modules (in base, in ports, or out-of-both-trees) >> > that access struct ucred? >> > >> > On Sat, Nov 14, 2020 at 09:51:47PM +0100, Mateusz Guzik wrote: >> >> I don't think so, it does not change any APIs >> >> >> >> On 11/14/20, Shawn Webb wrote: >> >> > On Sat, Nov 14, 2020 at 07:20:37PM +, Mateusz Guzik wrote: >> >> >> Author: mjg >> >> >> Date: Sat Nov 14 19:20:37 2020 >> >> >> New Revision: 367692 >> >> >> URL: https://svnweb.freebsd.org/changeset/base/367692 >> >> >> >> >> >> Log: >> >> >> cred: reorder cr_audit to be closer to the lock >> >> >> >> >> >> This makes cr_uid avoid sharing. >> >> >> >> >> >> Modified: >> >> >> head/sys/sys/ucred.h >> >> >> >> >> >> Modified: head/sys/sys/ucred.h >> >> >> >> == >> >> >> --- head/sys/sys/ucred.h Sat Nov 14 19:19:27 2020(r367691) >> >> >> +++ head/sys/sys/ucred.h Sat Nov 14 19:20:37 2020(r367692) >> >> >> @@ -63,6 +63,7 @@ struct ucred { >> >> >> struct mtx cr_mtx; >> >> >> u_int cr_ref; /* (c) reference count */ >> >> >> u_int cr_users; /* (c) proc + thread using this >> cred */ >> >> >> + struct auditinfo_addr cr_audit; /* Audit properties. */ >> >> >> #define cr_startcopy cr_uid >> >> >> uid_t cr_uid; /* effective user id */ >> >> >> uid_t cr_ruid;/* real user id */ >> >> >> @@ -78,7 +79,6 @@ struct ucred { >> >> >> void*cr_pspare2[2]; /* general use 2 */ >> >> >> #define cr_endcopy cr_label >> >> >> struct label*cr_label; /* MAC label */ >> >> >> - struct auditinfo_addr cr_audit; /* Audit properties. */ >> >> >> gid_t *cr_groups; /* groups */ >> >> >> int cr_agroups; /* Available groups */ >> >> >> gid_t cr_smallgroups[XU_NGROUPS]; /* storage for small >> groups */ >> >> > >> >> > Hey Mateusz, >> >> > >> >> > Since this changes KBI, does __FreeBSD_version need bumping? >> >> > >> >> > Thanks, >> >> > >> >> > -- >> >> > Shawn Webb >> >> > Cofounder / Security Engineer >> >> > HardenedBSD >> >> > >> >> > GPG Key ID: 0xFF2E67A277F8E1FA >> >> > GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 >> 0FB2 >> >> > >> https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc >> >> > >> >> >> >> >> >> -- >> >> Mateusz Guzik >> > >> > -- >> > Shawn Webb >> > Cofounder / Security Engineer >> > HardenedBSD >> > >> > GPG Key ID: 0xFF2E67A277F8E1FA >> > GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9 3633 C85B 0AF8 AB23 0FB2 >> > >> https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc >> > >> >> >> -- >> Mateusz Guzik >> > -- Mateusz Guzik ___ 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: r367700 - head/sys/kern
Author: mjg Date: Sun Nov 15 01:54:44 2020 New Revision: 367700 URL: https://svnweb.freebsd.org/changeset/base/367700 Log: sched: fix an incorrect comparison in sched_lend_user_prio_cond Compare with sched_lend_user_prio. Modified: head/sys/kern/sched_4bsd.c head/sys/kern/sched_ule.c Modified: head/sys/kern/sched_4bsd.c == --- head/sys/kern/sched_4bsd.c Sat Nov 14 20:45:12 2020(r367699) +++ head/sys/kern/sched_4bsd.c Sun Nov 15 01:54:44 2020(r367700) @@ -952,7 +952,7 @@ sched_lend_user_prio_cond(struct thread *td, u_char pr goto lend; if (td->td_user_pri != min(prio, td->td_base_user_pri)) goto lend; - if (td->td_priority >= td->td_user_pri) + if (td->td_priority != td->td_user_pri) goto lend; return; Modified: head/sys/kern/sched_ule.c == --- head/sys/kern/sched_ule.c Sat Nov 14 20:45:12 2020(r367699) +++ head/sys/kern/sched_ule.c Sun Nov 15 01:54:44 2020(r367700) @@ -1900,7 +1900,7 @@ sched_lend_user_prio_cond(struct thread *td, u_char pr goto lend; if (td->td_user_pri != min(prio, td->td_base_user_pri)) goto lend; - if (td->td_priority >= td->td_user_pri) + if (td->td_priority != td->td_user_pri) goto lend; return; ___ 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: r367701 - head/lib/libutil
Author: scottl Date: Sun Nov 15 07:48:52 2020 New Revision: 367701 URL: https://svnweb.freebsd.org/changeset/base/367701 Log: Because getlocalbase() returns -1 on error, it needs to use a signed type internally. Do that, and make sure that conversations between signed and unsigned don't overflow Modified: head/lib/libutil/getlocalbase.c Modified: head/lib/libutil/getlocalbase.c == --- head/lib/libutil/getlocalbase.c Sun Nov 15 01:54:44 2020 (r367700) +++ head/lib/libutil/getlocalbase.c Sun Nov 15 07:48:52 2020 (r367701) @@ -41,7 +41,7 @@ __FBSDID("$FreeBSD$"); ssize_t getlocalbase(char *path, size_t pathlen) { - size_t tmplen; + ssize_t tmplen; const char *tmppath; if ((pathlen == 0) || (path == NULL)) { @@ -49,13 +49,20 @@ getlocalbase(char *path, size_t pathlen) return (-1); } + /* It's unlikely that the buffer would be this big */ + if (pathlen > SSIZE_MAX) { + errno = ENOMEM; + return (-1); + } + tmppath = NULL; - tmplen = pathlen; + tmplen = (size_t)pathlen; if (issetugid() == 0) tmppath = getenv("LOCALBASE"); if ((tmppath == NULL) && - (sysctlbyname("user.localbase", path, &tmplen, NULL, 0) == 0)) { + (sysctlbyname("user.localbase", path, (size_t *)&tmplen, NULL, + 0) == 0)) { return (tmplen); } @@ -67,13 +74,13 @@ getlocalbase(char *path, size_t pathlen) #endif tmplen = strlcpy(path, tmppath, pathlen); - if ((tmplen < 0) || (tmplen >= pathlen)) { + if ((tmplen < 0) || (tmplen >= (ssize_t)pathlen)) { errno = ENOMEM; return (-1); } /* It's unlikely that the buffer would be this big */ - if (tmplen >= SSIZE_MAX) { + if (tmplen > SSIZE_MAX) { errno = ENOMEM; return (-1); } ___ 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: r367702 - in head: sbin/nvmecontrol usr.sbin/mailwrapper usr.sbin/pkg
Author: scottl Date: Sun Nov 15 07:50:29 2020 New Revision: 367702 URL: https://svnweb.freebsd.org/changeset/base/367702 Log: Fix the previous revision, it suffered from an incomplete change to the getlocalbase API. Also don't erroneously subtract the lenth from the buffer a second time. Modified: head/sbin/nvmecontrol/nvmecontrol.c head/usr.sbin/mailwrapper/mailwrapper.c head/usr.sbin/pkg/pkg.c Modified: head/sbin/nvmecontrol/nvmecontrol.c == --- head/sbin/nvmecontrol/nvmecontrol.c Sun Nov 15 07:48:52 2020 (r367701) +++ head/sbin/nvmecontrol/nvmecontrol.c Sun Nov 15 07:50:29 2020 (r367702) @@ -187,7 +187,7 @@ main(int argc, char *argv[]) snprintf(locallib, MAXPATHLEN, "/lib/nvmecontrol"); cmd_load_dir(locallib, NULL, NULL); if ((len = getlocalbase(locallib, MAXPATHLEN)) > 0) { - strlcat(locallib, "/lib/nvmecontrol", MAXPATHLEN - len); + strlcat(locallib, "/lib/nvmecontrol", MAXPATHLEN); cmd_load_dir(locallib, NULL, NULL); } Modified: head/usr.sbin/mailwrapper/mailwrapper.c == --- head/usr.sbin/mailwrapper/mailwrapper.c Sun Nov 15 07:48:52 2020 (r367701) +++ head/usr.sbin/mailwrapper/mailwrapper.c Sun Nov 15 07:50:29 2020 (r367702) @@ -105,10 +105,10 @@ main(int argc, char *argv[], char *envp[]) initarg(&al); addarg(&al, argv[0]); - if ((len = getlocalbase(localmailerconf, MAXPATHLEN)) != 0) + if ((len = getlocalbase(localmailerconf, MAXPATHLEN)) <= 0) err(EX_OSERR, "cannot determine local path"); - strlcat(localmailerconf, "/etc/mail/mailer.conf", MAXPATHLEN - len); + strlcat(localmailerconf, "/etc/mail/mailer.conf", MAXPATHLEN); mailerconf = localmailerconf; if ((config = fopen(localmailerconf, "r")) == NULL) Modified: head/usr.sbin/pkg/pkg.c == --- head/usr.sbin/pkg/pkg.c Sun Nov 15 07:48:52 2020(r367701) +++ head/usr.sbin/pkg/pkg.c Sun Nov 15 07:50:29 2020(r367702) @@ -1047,11 +1047,11 @@ main(int argc, char *argv[]) pkgarg = NULL; yes = false; - if ((len = getlocalbase(pkgpath, MAXPATHLEN)) != 0) { + if ((len = getlocalbase(pkgpath, MAXPATHLEN)) <= 0) { fprintf(stderr, "Cannot determine local path\n"); exit(EXIT_FAILURE); } - strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN - len); + strlcat(pkgpath, "/sbin/pkg", MAXPATHLEN); if (argc > 1 && strcmp(argv[1], "bootstrap") == 0) { bootstrap_only = true; ___ 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"