diff options
181 files changed, 4401 insertions, 1489 deletions
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index f56ad74294f9..850133db608a 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -13587,9 +13587,6 @@ OLD_FILES+=usr/share/man/man1/rlog.1.gz OLD_FILES+=usr/share/man/man5/rcsfile.5.gz # 20161010: remove link to removed m_getclr(9) macro OLD_FILES+=usr/share/man/man9/m_getclr.9.gz -# 20161003: MK_ELFCOPY_AS_OBJCOPY option retired -OLD_FILES+=usr/bin/elfcopy -OLD_FILES+=usr/share/man/man1/elfcopy.1.gz # 20160906: libkqueue tests moved to /usr/tests/sys/kqueue/libkqueue OLD_FILES+=usr/tests/sys/kqueue/kqtest OLD_FILES+=usr/tests/sys/kqueue/kqueue_test @@ -2188,7 +2188,7 @@ FOOTNOTES: 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 + PORTS_MODULES+=graphics/drm-kmod graphics/nvidia-drm-kmod [3] From the bootblocks, boot -s, and then do fsck -p diff --git a/bin/pkill/tests/pkill-x_test.sh b/bin/pkill/tests/pkill-x_test.sh index 9247a85863c0..5fe751f9ec72 100644 --- a/bin/pkill/tests/pkill-x_test.sh +++ b/bin/pkill/tests/pkill-x_test.sh @@ -9,13 +9,13 @@ sleep=$(pwd)/sleep.txt ln -sf /bin/sleep $sleep $sleep 5 & sleep 0.3 -pkill -x slee -P $$ +pkill -P $$ -x slee if [ $? -ne 0 ]; then echo "ok 1 - $name" else echo "not ok 1 - $name" fi -pkill -x sleep -P $$ +pkill -P $$ -x sleep if [ $? -eq 0 ]; then echo "ok 2 - $name" else @@ -28,13 +28,13 @@ sleep=$(pwd)/sleep.txt ln -sf /bin/sleep $sleep $sleep 5 & sleep 0.3 -pkill -x -f "$sleep " -P $$ +pkill -P $$ -x -f "$sleep " if [ $? -ne 0 ]; then echo "ok 3 - $name" else echo "not ok 3 - $name" fi -pkill -x -f "$sleep 5" -P $$ +pkill -P $$ -x -f "$sleep 5" if [ $? -eq 0 ]; then echo "ok 4 - $name" else diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 5f3c6d122dbb..f90bf008a286 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -416,7 +416,7 @@ for details. The process scheduling increment (see .Xr setpriority 2 ) . .It Cm rss -the real memory (resident set) size of the process (in 1024 byte units). +the real memory (resident set) size of the process in Kbytes. .It Cm start The time the command started. If the command started less than 24 hours ago, the start time is @@ -668,7 +668,7 @@ real group ID .It Cm rgroup group name (from rgid) .It Cm rss -resident set size +resident set size (in Kbytes) .It Cm rtprio realtime priority (see .Xr rtprio 1) diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog index 212b0fcfaacb..15a58e2a0924 100644 --- a/contrib/bmake/ChangeLog +++ b/contrib/bmake/ChangeLog @@ -1,3 +1,20 @@ +2025-03-08 Simon J Gerraty <sjg@beast.crufty.net> + + * bsd.after-import.mk: by default generate makefiles + closer to BSD style. + + * VERSION (_MAKE_VERSION): 20250308 + Merge with NetBSD make, pick up + o clean up comments and code for parallel mode + o job.c: avoid SIGPIPE for children, call Job_Wait befor abort. + +2025-02-27 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20250225 + Merge with NetBSD make, pick up + o job.c: reliably remove targets on interrupt, + by passing signal to children first. + 2025-01-25 Simon J Gerraty <sjg@beast.crufty.net> * VERSION (_MAKE_VERSION): 20250125 diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile index 939b71c5e12c..ba2b2e742d35 100644 --- a/contrib/bmake/Makefile +++ b/contrib/bmake/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.132 2024/09/22 19:56:26 sjg Exp $ +# $Id: Makefile,v 1.133 2025/03/08 20:12:56 sjg Exp $ PROG = bmake @@ -65,7 +65,7 @@ COPTS.main.c += "-D$x=\"${$x}\"" USE_FILEMON ?= no .if ${USE_FILEMON:tl} != "no" .PATH: ${srcdir}/filemon -SRCS+= filemon_${USE_FILEMON}.c +SRCS += filemon_${USE_FILEMON}.c COPTS.meta.c += -DUSE_FILEMON -DUSE_FILEMON_${USE_FILEMON:tu} COPTS.job.c += ${COPTS.meta.c} @@ -134,7 +134,7 @@ SYMLINKS += ${PROG_NAME} ${BINDIR}/${PROG} .endif .endif -EXTRACT_MAN=no +EXTRACT_MAN = no # end-delete1 .if make(obj) || make(clean) @@ -182,7 +182,7 @@ SED_CMDS.${MAN} += -e 's/^\.Nx/NetBSD/' ${MAN}: ${SRCS.${MAN}} _GENFILES_USE all man beforeinstall: ${MAN} -_mfromdir=. +_mfromdir = . .endif .endif # MK_GEN_MAN diff --git a/contrib/bmake/VERSION b/contrib/bmake/VERSION index 9d1a987f65d6..d26469e64381 100644 --- a/contrib/bmake/VERSION +++ b/contrib/bmake/VERSION @@ -1,2 +1,2 @@ # keep this compatible with sh and make -_MAKE_VERSION=20250125 +_MAKE_VERSION=20250308 diff --git a/contrib/bmake/bmake.cat1 b/contrib/bmake/bmake.cat1 index 8a1909e684ed..7e6f25524a05 100644 --- a/contrib/bmake/bmake.cat1 +++ b/contrib/bmake/bmake.cat1 @@ -1793,4 +1793,4 @@ BBUUGGSS attempt to suppress a cascade of unnecessary errors, can result in a seemingly unexplained `*** Error code 6' -FreeBSD 14.1-RELEASE-p5 November 14, 2024 FreeBSD 14.1-RELEASE-p5 +FreeBSD 14.1-RELEASE-p7 November 14, 2024 FreeBSD 14.1-RELEASE-p7 diff --git a/contrib/bmake/bsd.after-import.mk b/contrib/bmake/bsd.after-import.mk index f2948b855753..74811e98f979 100644 --- a/contrib/bmake/bsd.after-import.mk +++ b/contrib/bmake/bsd.after-import.mk @@ -1,4 +1,4 @@ -# $Id: bsd.after-import.mk,v 1.19 2024/09/21 22:44:55 sjg Exp $ +# $Id: bsd.after-import.mk,v 1.22 2025/03/09 02:56:42 sjg Exp $ # This makefile is for use when integrating bmake into a BSD build # system. Use this makefile after importing bmake. @@ -9,6 +9,7 @@ # The goal is to allow the benefits of autoconf without # the overhead of running configure. +.MAIN: all all: _makefile _utmakefile all: after-import @@ -64,6 +65,18 @@ MAKEFILE_SED = sed -e '/^MACHINE/d' \ -e '/^\..*include *</ { s,<\([a-z]\),<bsd.\1,;/autoconf/d; }' \ -e 's,${SRCTOP},$${SRCTOP},g' +.ifdef WITH_SPACE_ASSIGN +.space := ${x x:L:S/x//Wg} +.else +.space = +# this line noise achieves the equivalent of negating +# /^(.if|.elif|#)|==/ +# +MAKEFILE_SED += \ + -e '/^\.[e ]*l*if/!{/^\#/!{/==/!s,^\([^[:space:]][^=]*\)[[:space:]][[:space:]]*\([!?:+]*=\),\1\2,;};}' \ + +.endif + # These are the simple files we want to capture configured_files= config.h Makefile.config unit-tests/Makefile.config @@ -86,37 +99,41 @@ after-import: bootstrap ${MAKEFILE} @(echo '# This is a generated file, do NOT edit!'; \ echo '# See ${_this:S,${SRCTOP}/,,}'; \ echo '#'; ${ECHO_TAG} '# $$${HOST_OS}$$'; echo; \ - echo 'SRCTOP?= $${.CURDIR:${${.CURDIR}/$f:L:H:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; echo; \ + echo 'SRCTOP${.space}?= $${.CURDIR:${${.CURDIR}/$f:L:H:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; echo; \ ${MAKEFILE_SED} ${HOST_OS}/$f ) > ${.CURDIR}/$f .endfor +.if make(all) +_makefile _utmakefile: bootstrap ${MAKEFILE} +.endif + # this needs the most work -_makefile: bootstrap ${MAKEFILE} +_makefile: @echo Generating ${.CURDIR}/Makefile @(echo '# This is a generated file, do NOT edit!'; \ echo '# See ${_this:S,${SRCTOP}/,,}'; \ echo '#'; ${ECHO_TAG} '# $$${HOST_OS}$$'; \ - echo; echo 'SRCTOP?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; \ + echo; echo 'SRCTOP${.space}?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; \ echo; echo '# look here first for config.h'; \ - echo 'CFLAGS+= -I$${.CURDIR}'; echo; \ + echo 'CFLAGS${.space}+= -I$${.CURDIR}'; echo; \ echo '# for after-import'; \ - echo 'CLEANDIRS+= ${HOST_OS}'; \ - echo 'CLEANFILES+= bootstrap'; echo; \ + echo 'CLEANDIRS${.space}+= ${HOST_OS}'; \ + echo 'CLEANFILES${.space}+= bootstrap'; echo; \ ${MAKEFILE_SED} \ ${1 2:L:@n@-e '/start-delete$n/,/end-delete$n/d'@} \ ${BMAKE_SRC}/Makefile; \ echo; echo '# override some simple things'; \ - echo 'BINDIR= /usr/bin'; \ - echo 'MANDIR= ${MANDIR:U/usr/share/man}'; \ + echo 'BINDIR${.space}= /usr/bin'; \ + echo 'MANDIR${.space}= ${MANDIR:U/usr/share/man}'; \ echo; echo '# make sure we get this'; \ - echo 'CFLAGS+= $${COPTS.$${.IMPSRC:T}}'; \ + echo 'CFLAGS${.space}+= $${COPTS.$${.IMPSRC:T}}'; \ echo; echo 'after-import: ${_this:S,${SRCTOP},\${SRCTOP},}'; \ echo ' cd $${.CURDIR} && $${.MAKE} -f ${_this:S,${SRCTOP},\${SRCTOP},}'; \ echo ) > ${.TARGET} @cmp -s ${.TARGET} ${.CURDIR}/Makefile || \ mv ${.TARGET} ${.CURDIR}/Makefile -_utmakefile: bootstrap ${MAKEFILE} +_utmakefile: @echo Generating ${.CURDIR}/unit-tests/Makefile @mkdir -p ${.CURDIR}/unit-tests @(echo '# This is a generated file, do NOT edit!'; \ diff --git a/contrib/bmake/job.c b/contrib/bmake/job.c index bd85e6d95fb8..d06b1570ba85 100644 --- a/contrib/bmake/job.c +++ b/contrib/bmake/job.c @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.485 2025/01/19 10:57:10 rillig Exp $ */ +/* $NetBSD: job.c,v 1.489 2025/03/08 20:15:03 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -102,10 +102,7 @@ * define the shell that is used for the creation * commands in jobs mode. * - * Job_Finish Perform any final processing which needs doing. - * This includes the execution of any commands - * which have been/were attached to the .END - * target. It should only be called when the + * Job_Finish Make the .END target. Should only be called when the * job table is empty. * * Job_AbortAll Abort all currently running jobs. Do not handle @@ -154,7 +151,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.485 2025/01/19 10:57:10 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.489 2025/03/08 20:15:03 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -689,7 +686,7 @@ JobPassSig_suspend(int signo) act.sa_flags = 0; (void)sigaction(signo, &act, NULL); - DEBUG1(JOB, "JobPassSig passing signal %d to self.\n", signo); + DEBUG1(JOB, "JobPassSig_suspend passing signal %d to self.\n", signo); (void)kill(getpid(), signo); @@ -1251,8 +1248,16 @@ JobFinish (Job *job, WAIT_T status) if (return_job_token) Job_TokenReturn(); - if (aborting == ABORT_ERROR && jobTokensRunning == 0) - Finish(job_errors); + if (aborting == ABORT_ERROR && jobTokensRunning == 0) { + if (shouldDieQuietly(NULL, -1)) { + /* + * TODO: better clean up properly, to avoid killing + * child processes by SIGPIPE. + */ + exit(2); + } + Fatal("%d error%s", job_errors, job_errors == 1 ? "" : "s"); + } } static void @@ -1962,27 +1967,14 @@ JobRun(GNode *targ) } } -/* - * Handle the exit of a child. Called from Make_Make. - * - * The job descriptor is removed from the list of children. - * - * Notes: - * We do waits, blocking or not, according to the wisdom of our - * caller, until there are no more children to report. For each - * job, call JobFinish to finish things off. - */ void Job_CatchChildren(void) { - int pid; /* pid of dead child */ - WAIT_T status; /* Exit/termination status */ + int pid; + WAIT_T status; - /* Don't even bother if we know there's no one around. */ if (jobTokensRunning == 0) return; - - /* Have we received SIGCHLD since last call? */ if (caught_sigchld == 0) return; caught_sigchld = 0; @@ -2001,21 +1993,19 @@ Job_CatchChildren(void) void JobReapChild(pid_t pid, WAIT_T status, bool isJobs) { - Job *job; /* job descriptor for dead child */ + Job *job; - /* Don't even bother if we know there's no one around. */ if (jobTokensRunning == 0) return; job = JobFindPid(pid, JOB_ST_RUNNING, isJobs); if (job == NULL) { - if (isJobs) { - if (!lurking_children) - Error("Child (%d) status %x not in table?", - pid, status); - } - return; /* not ours */ + if (isJobs && !lurking_children) + Error("Child (%d) status %x not in table?", + pid, status); + return; } + if (WIFSTOPPED(status)) { DEBUG2(JOB, "Process %d (%s) stopped.\n", job->pid, job->node->name); @@ -2047,12 +2037,6 @@ JobReapChild(pid_t pid, WAIT_T status, bool isJobs) JobFinish(job, status); } -/* - * Catch the output from our children, if we're using pipes do so. Otherwise - * just block time until we get a signal(most likely a SIGCHLD) since there's - * no point in just spinning when there's nothing to do and the reaping of a - * child can wait for a while. - */ void Job_CatchOutput(void) { @@ -2062,7 +2046,7 @@ Job_CatchOutput(void) (void)fflush(stdout); - /* The first fd in the list is the job token pipe */ + /* Skip the first fd in the list, as it is the job token pipe. */ do { nready = poll(fds + 1 - wantToken, fdsLen - 1 + wantToken, POLL_MSEC); @@ -2073,13 +2057,12 @@ Job_CatchOutput(void) if (nready > 0 && readyfd(&childExitJob)) { char token = 0; - ssize_t count; - count = read(childExitJob.inPipe, &token, 1); + ssize_t count = read(childExitJob.inPipe, &token, 1); if (count == 1) { if (token == DO_JOB_RESUME[0]) /* * Complete relay requested from our SIGCONT - * handler + * handler. */ JobRestartJobs(); } else if (count == 0) @@ -2160,10 +2143,7 @@ Shell_Init(void) } } -/* - * Return the string literal that is used in the current command shell - * to produce a newline character. - */ +/* Return the shell string literal that results in a newline character. */ const char * Shell_GetNewline(void) { @@ -2192,12 +2172,11 @@ AddSig(int sig, SignalProc handler) } } -/* Initialize the process module. */ void Job_Init(void) { Job_SetPrefix(); - /* Allocate space for all the job info */ + job_table = bmake_malloc((size_t)opts.maxJobs * sizeof *job_table); memset(job_table, 0, (size_t)opts.maxJobs * sizeof *job_table); job_table_end = job_table + opts.maxJobs; @@ -2214,8 +2193,8 @@ Job_Init(void) /* - * There is a non-zero chance that we already have children. - * eg after 'make -f- <<EOF' + * There is a non-zero chance that we already have children, + * e.g. after 'make -f- <<EOF'. * Since their termination causes a 'Child (pid) not in table' * message, Collect the status of any that are already dead, and * suppress the error message if there are any undead ones. @@ -2237,7 +2216,6 @@ Job_Init(void) JobCreatePipe(&childExitJob, 3); { - /* Preallocate enough for the maximum number of jobs. */ size_t nfds = (npseudojobs + (size_t)opts.maxJobs) * nfds_per_job(); fds = bmake_malloc(sizeof *fds * nfds); @@ -2249,24 +2227,19 @@ Job_Init(void) watchfd(&childExitJob); sigemptyset(&caught_signals); - /* Install a SIGCHLD handler. */ (void)bmake_signal(SIGCHLD, JobChildSig); sigaddset(&caught_signals, SIGCHLD); - /* - * Catch the four signals that POSIX specifies if they aren't ignored. - * JobPassSig will take care of calling JobInterrupt if appropriate. - */ + /* Handle the signals specified by POSIX. */ AddSig(SIGINT, JobPassSig_int); AddSig(SIGHUP, JobPassSig_term); AddSig(SIGTERM, JobPassSig_term); AddSig(SIGQUIT, JobPassSig_term); /* - * There are additional signals that need to be caught and passed if - * either the export system wants to be told directly of signals or if - * we're giving each job its own process group (since then it won't get - * signals from the terminal driver as we own the terminal) + * These signals need to be passed to the jobs, as each job has its + * own process group and thus the terminal driver doesn't forward the + * signals itself. */ AddSig(SIGTSTP, JobPassSig_suspend); AddSig(SIGTTOU, JobPassSig_suspend); @@ -2275,10 +2248,7 @@ Job_Init(void) AddSig(SIGCONT, JobContinueSig); (void)Job_RunTarget(".BEGIN", NULL); - /* - * Create the .END node now, even though no code in the unit tests - * depends on it. See also Targ_GetEndNode in Compat_MakeAll. - */ + /* Create the .END node, see Targ_GetEndNode in Compat_MakeAll. */ (void)Targ_GetEndNode(); } @@ -2304,7 +2274,6 @@ JobSigReset(void) (void)bmake_signal(SIGCHLD, SIG_DFL); } -/* Find a shell in 'shells' given its name, or return NULL. */ static Shell * FindShellByName(const char *name) { @@ -2326,40 +2295,35 @@ FindShellByName(const char *name) * line The shell spec * * Results: - * false if the specification was incorrect. - * - * Side Effects: - * 'shell' points to a Shell structure (either predefined or - * created from the shell spec), shellPath is the full path of the - * shell described by 'shell', while shellName is just the - * final component of shellPath. + * Returns false if the specification was incorrect. + * If successful, 'shell' is usable, shellPath is the full path of the + * shell described by 'shell', and shellName is the final component of + * shellPath. * * Notes: - * A shell specification consists of a .SHELL target, with dependency - * operator, followed by a series of blank-separated words. Double - * quotes can be used to use blanks in words. A backslash escapes + * A shell specification has the form ".SHELL: keyword=value...". Double + * quotes can be used to enclose blanks in words. A backslash escapes * anything (most notably a double-quote and a space) and - * provides the functionality it does in C. Each word consists of - * keyword and value separated by an equal sign. There should be no - * unnecessary spaces in the word. The keywords are as follows: + * provides the usual escape sequences from C. There should be no + * unnecessary spaces in the word. The keywords are: * name Name of shell. * path Location of shell. * quiet Command to turn off echoing. * echo Command to turn echoing on - * filter Result of turning off echoing that shouldn't be - * printed. - * echoFlag Flag to turn echoing on at the start - * errFlag Flag to turn error checking on at the start - * hasErrCtl True if shell has error checking control - * newline String literal to represent a newline char - * check Command to turn on error checking if hasErrCtl - * is true or template of command to echo a command - * for which error checking is off if hasErrCtl is - * false. - * ignore Command to turn off error checking if hasErrCtl - * is true or template of command to execute a - * command so as to ignore any errors it returns if - * hasErrCtl is false. + * filter The output from the shell command that turns off + * echoing, to be filtered from the final output. + * echoFlag Flag to turn echoing on at the start. + * errFlag Flag to turn error checking on at the start. + * hasErrCtl True if the shell has error checking control. + * newline String literal to represent a newline character. + * check If hasErrCtl is true: The command to turn on error + * checking. If hasErrCtl is false: The template for a + * shell command that echoes a command for which error + * checking is off. + * ignore If hasErrCtl is true: The command to turn off error + * checking. If hasErrCtl is false: The template for a + * shell command that executes a command so as to ignore + * any errors it returns. */ bool Job_ParseShell(char *line) @@ -2380,7 +2344,6 @@ Job_ParseShell(char *line) memset(&newShell, 0, sizeof newShell); - /* Parse the specification by keyword. */ wordsList = Str_Words(line, true); words = wordsList.words; argc = wordsList.len; @@ -2444,12 +2407,6 @@ Job_ParseShell(char *line) } if (path == NULL) { - /* - * If no path was given, the user wants one of the - * pre-defined shells, yes? So we find the one s/he wants - * with the help of FindShellByName and set things up the - * right way. shellPath will be set up by Shell_Init. - */ if (newShell.name == NULL) { Parse_Error(PARSE_FATAL, "Neither path nor name specified"); @@ -2465,10 +2422,6 @@ Job_ParseShell(char *line) shell = sh; shellName = newShell.name; if (shellPath != NULL) { - /* - * Shell_Init has already been called! - * Do it again. - */ free(shellPath); shellPath = NULL; Shell_Init(); @@ -2491,7 +2444,7 @@ Job_ParseShell(char *line) shell = bmake_malloc(sizeof *shell); *shell = newShell; } - /* this will take care of shellErrFlag */ + /* This will take care of shellErrFlag. */ Shell_Init(); } @@ -2506,7 +2459,7 @@ Job_ParseShell(char *line) } /* - * Do not free up the words themselves, since they might be in use + * Do not free up the words themselves, since they may be in use * by the shell specification. */ free(words); @@ -2514,36 +2467,22 @@ Job_ParseShell(char *line) } /* - * Handle the receipt of an interrupt. - * - * All children are killed. Another job will be started if the .INTERRUPT - * target is defined. - * - * Input: - * runINTERRUPT Non-zero if commands for the .INTERRUPT target - * should be executed - * signo signal received + * After receiving an interrupt signal, terminate all child processes and if + * necessary make the .INTERRUPT target. */ static void JobInterrupt(bool runINTERRUPT, int signo) { - Job *job; /* job descriptor in that element */ - GNode *interrupt; /* the node describing the .INTERRUPT target */ + Job *job; + GNode *interrupt; sigset_t mask; - GNode *gn; aborting = ABORT_INTERRUPT; JobSigLock(&mask); for (job = job_table; job < job_table_end; job++) { - if (job->status != JOB_ST_RUNNING) - continue; - - gn = job->node; - - JobDeleteTarget(gn); - if (job->pid != 0) { + if (job->status == JOB_ST_RUNNING && job->pid != 0) { DEBUG2(JOB, "JobInterrupt passing signal %d to child %d.\n", signo, job->pid); @@ -2551,6 +2490,14 @@ JobInterrupt(bool runINTERRUPT, int signo) } } + for (job = job_table; job < job_table_end; job++) { + if (job->status == JOB_ST_RUNNING && job->pid != 0) { + int status; + (void)waitpid(job->pid, &status, 0); + JobDeleteTarget(job->node); + } + } + JobSigUnlock(&mask); if (runINTERRUPT && !opts.touch) { @@ -2564,11 +2511,7 @@ JobInterrupt(bool runINTERRUPT, int signo) exit(signo); /* XXX: why signo? */ } -/* - * Do the final processing, i.e. run the commands attached to the .END target. - * - * Return the number of errors reported. - */ +/* Make the .END target, returning the number of job-related errors. */ int Job_Finish(void) { @@ -2584,7 +2527,6 @@ Job_Finish(void) } #ifdef CLEANUP -/* Clean up any memory used by the jobs module. */ void Job_End(void) { @@ -2592,14 +2534,11 @@ Job_End(void) } #endif -/* - * Waits for all running jobs to finish and returns. - * Sets 'aborting' to ABORT_WAIT to prevent other jobs from starting. - */ +/* Waits for all running jobs to finish. */ void Job_Wait(void) { - aborting = ABORT_WAIT; + aborting = ABORT_WAIT; /* Prevent other jobs from starting. */ while (jobTokensRunning != 0) { Job_CatchOutput(); } @@ -2610,14 +2549,12 @@ Job_Wait(void) * Abort all currently running jobs without handling output or anything. * This function is to be called only in the event of a major error. * Most definitely NOT to be called from JobInterrupt. - * - * All children are killed, not just the firstborn. */ void Job_AbortAll(void) { - Job *job; /* the job descriptor in that element */ - WAIT_T foo; + Job *job; + WAIT_T status; aborting = ABORT_ERROR; @@ -2625,25 +2562,18 @@ Job_AbortAll(void) for (job = job_table; job < job_table_end; job++) { if (job->status != JOB_ST_RUNNING) continue; - /* - * kill the child process with increasingly drastic - * signals to make darn sure it's dead. - */ KILLPG(job->pid, SIGINT); KILLPG(job->pid, SIGKILL); } } - /* - * Catch as many children as want to report in at first, then give up - */ - while (waitpid((pid_t)-1, &foo, WNOHANG) > 0) + while (waitpid((pid_t)-1, &status, WNOHANG) > 0) continue; } /* * Tries to restart stopped jobs if there are slots available. - * Called in process context in response to a SIGCONT. + * Called in response to a SIGCONT. */ static void JobRestartJobs(void) @@ -2708,10 +2638,6 @@ clearfd(Job *job) fdsLen--; #if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) if (useMeta) { - /* - * Sanity check: there should be two fds per job, so the job's - * pollfd number should be even. - */ assert(nfds_per_job() == 2); if (i % 2 != 0) Punt("odd-numbered fd with meta"); @@ -2756,7 +2682,7 @@ JobTokenAdd(void) tok = '+'; /* no error token */ } - /* If we are depositing an error token flush everything else */ + /* If we are depositing an error token, flush everything else. */ while (tok != '+' && read(tokenWaitJob.inPipe, &tok1, 1) == 1) continue; @@ -2766,7 +2692,6 @@ JobTokenAdd(void) continue; } -/* Get a temp file */ int Job_TempFile(const char *pattern, char *tfile, size_t tfile_sz) { @@ -2782,7 +2707,7 @@ Job_TempFile(const char *pattern, char *tfile, size_t tfile_sz) return fd; } -/* Prep the job token pipe in the root make process. */ +/* Prepare the job token pipe in the root make process. */ void Job_ServerStart(int max_tokens, int jp_0, int jp_1) { @@ -2790,7 +2715,6 @@ Job_ServerStart(int max_tokens, int jp_0, int jp_1) char jobarg[64]; if (jp_0 >= 0 && jp_1 >= 0) { - /* Pipe passed in from parent */ tokenWaitJob.inPipe = jp_0; tokenWaitJob.outPipe = jp_1; (void)fcntl(jp_0, F_SETFD, FD_CLOEXEC); @@ -2832,7 +2756,7 @@ Job_TokenReturn(void) /* * Attempt to withdraw a token from the pool. * - * If pool is empty, set wantToken so that we wake up when a token is + * If the pool is empty, set wantToken so that we wake up when a token is * released. * * Returns true if a token was withdrawn, and false if the pool is currently @@ -2871,8 +2795,10 @@ Job_TokenWithdraw(void) while (write(tokenWaitJob.outPipe, &tok, 1) == -1 && errno == EAGAIN) continue; - if (shouldDieQuietly(NULL, 1)) - exit(6); /* we aborted */ + if (shouldDieQuietly(NULL, 1)) { + Job_Wait(); + exit(6); + } Fatal("A failure has been detected " "in another branch of the parallel make"); } @@ -2888,12 +2814,7 @@ Job_TokenWithdraw(void) return true; } -/* - * Run the named target if found. If a filename is specified, then set that - * to the sources. - * - * Exits if the target fails. - */ +/* Make the named target if found, exit if the target fails. */ bool Job_RunTarget(const char *target, const char *fname) { diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c index 0b48b2d59389..9577fb41ee7b 100644 --- a/contrib/bmake/main.c +++ b/contrib/bmake/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.638 2025/01/19 12:59:39 rillig Exp $ */ +/* $NetBSD: main.c,v 1.639 2025/03/07 06:50:34 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -83,9 +83,6 @@ * Fatal Print an error message and exit. * * Punt Abort all jobs and exit with a message. - * - * Finish Finish things up by printing the number of errors - * that occurred, and exit. */ #include <sys/types.h> @@ -111,7 +108,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.638 2025/01/19 12:59:39 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.639 2025/03/07 06:50:34 rillig Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1783,7 +1780,7 @@ Cmd_Exec(const char *cmd, char **error) int pipefds[2]; int cpid; /* Child PID */ int pid; /* PID from wait() */ - int status; /* command exit status */ + WAIT_T status; /* command exit status */ Buffer buf; /* buffer to store the result */ ssize_t bytes_read; char *output; @@ -1962,19 +1959,6 @@ DieHorribly(void) exit(2); /* Not 1 so -q can distinguish error */ } -/* - * Called when aborting due to errors in child shell to signal abnormal exit. - * The program exits. - * Errors is the number of errors encountered in Make_Make. - */ -void -Finish(int errs) -{ - if (shouldDieQuietly(NULL, -1)) - exit(2); - Fatal("%d error%s", errs, errs == 1 ? "" : "s"); -} - int unlink_file(const char *file) { diff --git a/contrib/bmake/make.h b/contrib/bmake/make.h index 05714ddfd151..33df57c58198 100644 --- a/contrib/bmake/make.h +++ b/contrib/bmake/make.h @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.349 2025/01/19 10:57:10 rillig Exp $ */ +/* $NetBSD: make.h,v 1.350 2025/03/07 06:50:34 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -889,7 +889,6 @@ void Error(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2); void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD; void Punt(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD; void DieHorribly(void) MAKE_ATTR_DEAD; -void Finish(int) MAKE_ATTR_DEAD; int unlink_file(const char *) MAKE_ATTR_USE; void execDie(const char *, const char *); char *getTmpdir(void) MAKE_ATTR_USE; diff --git a/contrib/bmake/mk/ChangeLog b/contrib/bmake/mk/ChangeLog index 4274d9d3483b..99f4b05be61c 100644 --- a/contrib/bmake/mk/ChangeLog +++ b/contrib/bmake/mk/ChangeLog @@ -1,3 +1,16 @@ +2025-03-14 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20250314 + + * meta.stage.mk: StageFiles --subdir: preserve the dir part of + each file under $dest + +2025-03-12 Simon J Gerraty <sjg@beast.crufty.net> + + * meta.autodep.mk: do a better job of handling MAKESYSPATH in + GENDIRDEPS_ENV. If we have MAKE_VERSION >= 20230123 we can just + use .SYSPATH, otherwise it is a bit more complicated. + 2025-01-10 Simon J Gerraty <sjg@beast.crufty.net> * rust.mk: use RUST_LIBS and RUST_PROGS diff --git a/contrib/bmake/mk/install-mk b/contrib/bmake/mk/install-mk index b455832b7726..d765fbba2251 100644 --- a/contrib/bmake/mk/install-mk +++ b/contrib/bmake/mk/install-mk @@ -59,9 +59,9 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: install-mk,v 1.262 2025/01/05 01:16:19 sjg Exp $ +# $Id: install-mk,v 1.263 2025/03/14 20:29:35 sjg Exp $ # -# @(#) Copyright (c) 1994-2024 Simon J. Gerraty +# @(#) Copyright (c) 1994-2025 Simon J. Gerraty # # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. @@ -74,7 +74,7 @@ # sjg@crufty.net # -MK_VERSION=20250101 +MK_VERSION=20250314 OWNER= GROUP= MODE=444 diff --git a/contrib/bmake/mk/jobs.mk b/contrib/bmake/mk/jobs.mk index f39f1eb178ae..e304e16a9c56 100644 --- a/contrib/bmake/mk/jobs.mk +++ b/contrib/bmake/mk/jobs.mk @@ -1,8 +1,8 @@ # SPDX-License-Identifier: BSD-2-Clause # -# $Id: jobs.mk,v 1.17 2024/02/17 17:26:57 sjg Exp $ +# $Id: jobs.mk,v 1.19 2025/02/03 21:18:44 sjg Exp $ # -# @(#) Copyright (c) 2012-2023, Simon J. Gerraty +# @(#) Copyright (c) 2012-2025, Simon J. Gerraty # # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. @@ -68,7 +68,7 @@ NEWLOG_SH := ${(type newlog.sh) 2> /dev/null:L:sh:M/*} .endif .endif .if !empty(NEWLOG_SH) && exists(${NEWLOG_SH}) -NEWLOG := sh ${NEWLOG_SH} +NEWLOG := ${.SHELL:Ush} ${NEWLOG_SH} JOB_NEWLOG_ARGS ?= -S -n ${JOB_LOG_GENS} .else NEWLOG = : diff --git a/contrib/bmake/mk/meta.autodep.mk b/contrib/bmake/mk/meta.autodep.mk index 55f2d66e56aa..b94891b1b93f 100644 --- a/contrib/bmake/mk/meta.autodep.mk +++ b/contrib/bmake/mk/meta.autodep.mk @@ -1,9 +1,9 @@ # SPDX-License-Identifier: BSD-2-Clause # -# $Id: meta.autodep.mk,v 1.63 2024/04/24 18:56:41 sjg Exp $ +# $Id: meta.autodep.mk,v 1.65 2025/03/14 20:28:42 sjg Exp $ # -# @(#) Copyright (c) 2010, Simon J. Gerraty +# @(#) Copyright (c) 2010-2025, Simon J. Gerraty # # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. @@ -281,14 +281,26 @@ META_FILES := ${META_XTRAS:U:O:u} ${META_FILES:U:T:O:u:${META_FILE_FILTER:ts:}} .export META_FILES .endif +_this_dir := ${_PARSEDIR} +.if ${MAKE_VERSION} < 20230123 # we might have .../ in MAKESYSPATH -_makesyspath:= ${_PARSEDIR} +_makesyspath := ${MAKESYSPATH:U${_this_dir}} +.if ${.MAKEFLAGS:M-m} != "" +_makesyspath := ${.MAKEFLAGS:S,-m ,-m,gW:M-m*:S,-m, ,:ts:}:${_makesyspath} +.endif +_makesyspath := ${_makesyspath:C,\.\.\./[^:]*,${_this_dir},} +GENDIRDEPS_ENV += MAKESYSPATH=${_makesyspath} +.else +# add this if not already there +.SYSPATH: ${_this_dir} +GENDIRDEPS_ENV += MAKESYSPATH=${.SYSPATH:ts:} +.endif + ${_DEPENDFILE}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} $${.MAKE.META.CREATED} @echo Checking $@: ${.OODATE:T:[1..8]} @(cd . && ${GENDIRDEPS_ENV} \ SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS:O:u}' \ DPADD='${FORCE_DPADD:O:u}' ${_gendirdeps_mutex} \ - MAKESYSPATH=${_makesyspath} \ ${.MAKE} -f gendirdeps.mk RELDIR=${RELDIR} _DEPENDFILE=${_DEPENDFILE}) @test -s $@ && touch $@; : .endif diff --git a/contrib/bmake/mk/meta.stage.mk b/contrib/bmake/mk/meta.stage.mk index 345df6aae16b..97e4dce83e5d 100644 --- a/contrib/bmake/mk/meta.stage.mk +++ b/contrib/bmake/mk/meta.stage.mk @@ -1,8 +1,8 @@ # SPDX-License-Identifier: BSD-2-Clause # -# $Id: meta.stage.mk,v 1.69 2024/02/17 17:26:57 sjg Exp $ +# $Id: meta.stage.mk,v 1.71 2025/03/14 20:28:42 sjg Exp $ # -# @(#) Copyright (c) 2011-2017, Simon J. Gerraty +# @(#) Copyright (c) 2011-2025, Simon J. Gerraty # # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. @@ -40,9 +40,11 @@ CLEANFILES+= .dirdep .if defined(NO_POSIX_SHELL) || ${type printf:L:sh:Mbuiltin} == "" _stage_file_basename = `basename $$f` +_stage_file_dirname = `dirname $$f` _stage_target_dirname = `dirname $$t` .else _stage_file_basename = $${f\#\#*/} +_stage_file_dirname = $${f%/*} _stage_target_dirname = $${t%/*} .endif @@ -86,22 +88,37 @@ STAGE_DIRDEP_SCRIPT = ${LN_CP_SCRIPT}; StageDirdep() { \ if [ -s $$t.dirdep ]; then \ cmp -s .dirdep $$t.dirdep && return; \ x=`cat $$t.dirdep`; \ - case "${RELDIR}:${_dirdep}" in $${x%.*}:$${x}*) ;; \ + case "${RELDIR}:${_dirdep}" in \ + $${x%.*}:$${x}*) ;; \ *) echo "${STAGE_CONFLICT}: $$t installed by $$x not ${_dirdep}" >&2; \ - ${STAGE_CONFLICT_ACTION} ;; esac; \ + ${STAGE_CONFLICT_ACTION} ;; \ + esac; \ fi; \ LnCp .dirdep $$t.dirdep || exit 1; } # common logic for staging files # this all relies on RELDIR being set to a subdir of SRCTOP # we use ln(1) if we can, else cp(1) +# if --subdir is given the dirname part of each file will be preserved STAGE_FILE_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageFiles() { \ - case "$$1" in "") return;; -m) mode=$$2; shift 2;; *) mode=;; esac; \ + mode= subdir=; \ + while : ; do \ + case "$$1" in \ + "") return;; \ + -m) mode=$$2; shift 2;; \ + --subdir) subdir=1; shift;; \ + *) break;; \ + esac; \ + done; \ dest=$$1; shift; \ mkdir -p $$dest; \ [ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \ for f in "$$@"; do \ - case "$$f" in */*) t=$$dest/${_stage_file_basename};; *) t=$$dest/$$f;; esac; \ + case "$$subdir,$$f" in \ + 1,*/*) t=$$dest/$$f; mkdir -p $$dest/${_stage_file_dirname};; \ + */*) t=$$dest/${_stage_file_basename};; \ + *) t=$$dest/$$f;; \ + esac; \ StageDirdep $$t; \ LnCp $$f $$t || exit 1; \ [ -z "$$mode" ] || chmod $$mode $$t; \ diff --git a/contrib/bmake/mk/sys.vars.mk b/contrib/bmake/mk/sys.vars.mk index 49d1a71b1d98..c3daf745fb5c 100644 --- a/contrib/bmake/mk/sys.vars.mk +++ b/contrib/bmake/mk/sys.vars.mk @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# $Id: sys.vars.mk,v 1.17 2024/09/28 04:06:47 sjg Exp $ +# $Id: sys.vars.mk,v 1.18 2025/03/09 02:47:59 sjg Exp $ # # @(#) Copyright (c) 2003-2023, Simon J. Gerraty # @@ -140,8 +140,9 @@ M_mtime = tW:S,^,${STAT:Ustat} -f %m ,:sh M_mtime = mtime${M_mtime_fallback:U} .endif -# This line noise allows doing .tab and .bel below +# This line noise allows doing .bel .space and .tab below # don't expect sane results if input is more than a single word M_CharLiteral = L:@c@$${x x:L:$${:Uts$$c}:S/x//Wg}@ -.tab := ${\t:${M_CharLiteral}} .bel := ${\007:${M_CharLiteral}} +.space := ${\040:${M_CharLiteral}} +.tab := ${\t:${M_CharLiteral}} diff --git a/contrib/bmake/os.sh b/contrib/bmake/os.sh index 8216c774cd96..13b0730464e9 100644..100755 --- a/contrib/bmake/os.sh +++ b/contrib/bmake/os.sh @@ -17,7 +17,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: os.sh,v 1.66 2024/09/25 18:16:09 sjg Exp $ +# $Id: os.sh,v 1.67 2025/02/13 21:04:34 sjg Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -38,8 +38,12 @@ _OS_SH=: OS=`uname` OSREL=`uname -r` OSMAJOR=`IFS=.; set $OSREL; echo $1` -MACHINE=`uname -m` -MACHINE_ARCH=`uname -p 2>/dev/null || echo $MACHINE` +# we want to retain the raw output from uname -m and -p +OS_MACHINE=`uname -m` +OS_MACHINE_ARCH=`uname -p 2>/dev/null || echo $OS_MACHINE` + +MACHINE=$OS_MACHINE +MACHINE_ARCH=$OS_MACHINE_ARCH # there is at least one case of `uname -p` # and even `uname -m` outputting usless info diff --git a/contrib/tzdata/NEWS b/contrib/tzdata/NEWS index a5d7ea89204e..8c0771641ef0 100644 --- a/contrib/tzdata/NEWS +++ b/contrib/tzdata/NEWS @@ -1,15 +1,40 @@ News for the tz database +Release 2025b - 2025-03-22 13:40:46 -0700 + + Briefly: + New zone for Aysén Region in Chile which moves from -04/-03 to -03. + + Changes to future timestamps + + Chile's Aysén Region moves from -04/-03 to -03 year-round, joining + Magallanes Region. The region will not change its clocks on + 2025-04-05 at 24:00, diverging from America/Santiago and creating a + new zone America/Coyhaique. (Thanks to Yonathan Dossow.) Model + this as a change to standard offset effective 2025-03-20. + + Changes to past timestamps + + Iran switched from +04 to +0330 on 1978-11-10 at 24:00, not at + year end. (Thanks to Roozbeh Pournader.) + + Changes to code + + 'zic -l TIMEZONE -d . -l /some/other/file/system' no longer + attempts to create an incorrect symlink, and no longer has a + read buffer underflow. (Problem reported by Evgeniy Gorbanev.) + + Release 2025a - 2025-01-15 10:47:24 -0800 Briefly: - Paraguay adopts permanent -03 starting spring 2024. + Paraguay adopted permanent -03 starting spring 2024. Improve pre-1991 data for the Philippines. Etc/Unknown is now reserved. Changes to future timestamps - Paraguay will stop changing its clocks after the spring-forward + Paraguay stopped changing its clocks after the spring-forward transition on 2024-10-06, so it is now permanently at -03. (Thanks to Heitor David Pinto and Even Scharning.) This affects timestamps starting 2025-03-22, as well as the diff --git a/contrib/tzdata/asia b/contrib/tzdata/asia index d4eb058053ed..d3d1059ac90d 100644 --- a/contrib/tzdata/asia +++ b/contrib/tzdata/asia @@ -1500,6 +1500,16 @@ Zone Asia/Jayapura 9:22:48 - LMT 1932 Nov # (UIT No. 143 17.XI.1977) and not 23 September (UIT No. 141 13.IX.1977). # UIT is the Operational Bulletin of International Telecommunication Union. +# From Roozbeh Pournader (2025-03-18): +# ... the exact time of Iran's transition from +0400 to +0330 ... was Friday +# 1357/8/19 AP=1978-11-10. Here's a newspaper clip from the Ettela'at +# newspaper, dated 1357/8/14 AP=1978-11-05, translated from Persian +# (at https://w.wiki/DUEY): +# Following the government's decision about returning the official time +# to the previous status, the spokesperson for the Ministry of Energy +# announced today: At the hour 24 of Friday 19th of Aban (=1978-11-10), +# the country's time will be pulled back half an hour. +# # From Roozbeh Pournader (2003-03-15): # This is an English translation of what I just found (originally in Persian). # The Gregorian dates in brackets are mine: @@ -1627,7 +1637,7 @@ Rule Iran 2021 2022 - Sep 21 24:00 0 - Zone Asia/Tehran 3:25:44 - LMT 1916 3:25:44 - TMT 1935 Jun 13 # Tehran Mean Time 3:30 Iran %z 1977 Oct 20 24:00 - 4:00 Iran %z 1979 + 4:00 Iran %z 1978 Nov 10 24:00 3:30 Iran %z diff --git a/contrib/tzdata/northamerica b/contrib/tzdata/northamerica index 8d356aa0069d..20b47b481ddd 100644 --- a/contrib/tzdata/northamerica +++ b/contrib/tzdata/northamerica @@ -1611,6 +1611,15 @@ Zone America/Moncton -4:19:08 - LMT 1883 Dec 9 # For more on Orillia, see: Daubs K. Bold attempt at daylight saving # time became a comic failure in Orillia. Toronto Star 2017-07-08. # https://www.thestar.com/news/insight/2017/07/08/bold-attempt-at-daylight-saving-time-became-a-comic-failure-in-orillia.html +# From Paul Eggert (2025-03-20): +# Also see the 1912-06-17 front page of The Evening Sunbeam, +# reproduced in: Richardson M. "Daylight saving was a confusing +# time in Orillia" in the 2025-03-15 Orillia Matters. Richardson writes, +# "The first Sunday after the switch was made, [DST proponent and +# Orillia mayor William Sword] Frost walked into church an hour late. +# This became a symbol of the downfall of daylight saving in Orillia." +# The mayor became known as "Daylight Bill". +# https://www.orilliamatters.com/local-news/column-daylight-saving-was-a-confusing-time-in-orillia-10377529 # From Mark Brader (2010-03-06): # diff --git a/contrib/tzdata/southamerica b/contrib/tzdata/southamerica index 1fcf65146785..06fee598baf4 100644 --- a/contrib/tzdata/southamerica +++ b/contrib/tzdata/southamerica @@ -1246,35 +1246,45 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # dates to 2014. # DST End: last Saturday of April 2014 (Sun 27 Apr 2014 03:00 UTC) # DST Start: first Saturday of September 2014 (Sun 07 Sep 2014 04:00 UTC) -# http://www.diariooficial.interior.gob.cl//media/2014/02/19/do-20140219.pdf +# From Tim Parenti (2025-03-22): +# Decreto 307 of 2014 of the Ministry of the Interior and Public Security, +# promulgated 2014-01-30 and published 2014-02-19: +# https://www.diariooficial.interior.gob.cl/media/2014/02/19/do-20140219.pdf#page=1 +# https://www.bcn.cl/leychile/navegar?idNorma=1059557 # From Eduardo Romero Urra (2015-03-03): # Today has been published officially that Chile will use the DST time # permanently until March 25 of 2017 -# http://www.diariooficial.interior.gob.cl/media/2015/03/03/1-large.jpg -# -# From Paul Eggert (2015-03-03): -# For now, assume that the extension will persist indefinitely. +# From Tim Parenti (2025-03-22): +# Decreto 106 of 2015 of the Ministry of the Interior and Public Security, +# promulgated 2015-01-27 and published 2015-03-03: +# https://www.diariooficial.interior.gob.cl/media/2015/03/03/do-20150303.pdf#page=1 +# https://www.bcn.cl/leychile/navegar?idNorma=1075157 # From Juan Correa (2016-03-18): -# The decree regarding DST has been published in today's Official Gazette: -# http://www.diariooficial.interior.gob.cl/versiones-anteriores/do/20160318/ -# http://www.leychile.cl/Navegar?idNorma=1088502 +# The decree regarding DST has been published in today's Official Gazette... # It does consider the second Saturday of May and August as the dates # for the transition; and it lists DST dates until 2019, but I think # this scheme will stick. -# # From Paul Eggert (2016-03-18): -# For now, assume the pattern holds for the indefinite future. # The decree says transitions occur at 24:00; in practice this appears # to mean 24:00 mainland time, not 24:00 local time, so that Easter # Island is always two hours behind the mainland. +# From Tim Parenti (2025-03-22): +# Decreto 253 of 2016 of the Ministry of the Interior and Public Security, +# promulgated 2016-03-16 and published 2016-03-18. +# https://www.diariooficial.interior.gob.cl/media/2016/03/18/do-20160318.pdf#page=1 +# https://www.bcn.cl/leychile/navegar?idNorma=1088502 # From Juan Correa (2016-12-04): # Magallanes region ... will keep DST (UTC -3) all year round.... # http://www.soychile.cl/Santiago/Sociedad/2016/12/04/433428/Bachelet-firmo-el-decreto-para-establecer-un-horario-unico-para-la-Region-de-Magallanes.aspx -# From Deborah Goldsmith (2017-01-19): -# http://www.diariooficial.interior.gob.cl/publicaciones/2017/01/17/41660/01/1169626.pdf +# From Tim Parenti (2025-03-22), via Deborah Goldsmith (2017-01-19): +# Decreto 1820 of 2016 of the Ministry of the Interior and Public Security, +# promulgated 2016-12-02 and published 2017-01-17: +# https://www.diariooficial.interior.gob.cl/publicaciones/2017/01/17/41660/01/1169626.pdf +# https://www.bcn.cl/leychile/Navegar?idNorma=1099217 +# Model this as a change to standard offset effective 2016-12-04. # From Juan Correa (2018-08-13): # As of moments ago, the Ministry of Energy in Chile has announced the new @@ -1293,13 +1303,20 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # https://twitter.com/MinEnergia/status/1029009354001973248 # "We will keep the new time policy unchanged for at least the next 4 years." # So we extend the new rules on Saturdays at 24:00 mainland time indefinitely. -# From Juan Correa (2019-02-04): -# http://www.diariooficial.interior.gob.cl/publicaciones/2018/11/23/42212/01/1498738.pdf +# From Tim Parenti (2025-03-22), via Juan Correa (2019-02-04): +# Decreto 1286 of 2018 of the Ministry of the Interior and Public Security, +# promulgated 2018-09-21 and published 2018-11-23: +# https://www.diariooficial.interior.gob.cl/publicaciones/2018/11/23/42212/01/1498738.pdf +# https://www.bcn.cl/leychile/Navegar?idNorma=1125760 # From Juan Correa (2022-04-02): # I found there was a decree published last Thursday that will keep -# Magallanes region to UTC -3 "indefinitely". The decree is available at +# Magallanes region to UTC -3 "indefinitely". +# From Tim Parenti (2025-03-22): +# Decreto 143 of 2022 of the Ministry of the Interior and Public Security, +# promulgated 2022-03-29 and published 2022-03-31: # https://www.diariooficial.interior.gob.cl/publicaciones/2022/03/31/43217-B/01/2108910.pdf +# https://www.bcn.cl/leychile/Navegar?idNorma=1174342 # From Juan Correa (2022-08-09): # the Internal Affairs Ministry (Ministerio del Interior) informed DST @@ -1308,13 +1325,36 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914 # will keep UTC -3 "indefinitely"... This is because on September 4th # we will have a voting whether to approve a new Constitution. # -# From Eduardo Romero Urra (2022-08-17): +# From Tim Parenti (2025-03-22), via Eduardo Romero Urra (2022-08-17): +# Decreto 224 of 2022 of the Ministry of the Interior and Public Security, +# promulgated 2022-07-14 and published 2022-08-13: # https://www.diariooficial.interior.gob.cl/publicaciones/2022/08/13/43327/01/2172567.pdf +# https://www.bcn.cl/leychile/navegar?idNorma=1179983 # # From Paul Eggert (2022-08-17): # Although the presidential decree stops at fall 2026, assume that # similar DST rules will continue thereafter. +# From Paul Eggert (2025-01-15): +# Diario Regional Aysén's Sebastián Martel reports that 94% of Aysén +# citizens polled in November favored changing the rules from +# -04/-03-with-DST to -03 all year... +# https://www.diarioregionalaysen.cl/noticia/actualidad/2024/12/presentan-decision-que-gano-la-votacion-sobre-el-cambio-del-huso-horario-en-aysen +# +# From Yonathan Dossow (2025-03-20): +# [T]oday we have more confirmation of the change. [Aysén] region will keep +# UTC-3 all year... +# https://www.cnnchile.com/pais/region-de-aysen-mantendra-horario-de-verano-todo-el-ano_20250320/ +# https://www.latercera.com/nacional/noticia/tras-consulta-ciudadana-region-de-aysen-mantendra-el-horario-de-verano-durante-todo-el-ano/ +# https://x.com/min_interior/status/1902692504270672098 +# +# From Tim Parenti (2025-03-22), via Eduardo Romero Urra (2025-03-20): +# Decreto 93 of 2025 of the Ministry of the Interior and Public Security, +# promulgated 2025-03-11 and published 2025-03-20: +# https://www.diariooficial.interior.gob.cl/publicaciones/2025/03/20/44104/01/2624263.pdf +# https://www.bcn.cl/leychile/Navegar?idNorma=1211955 +# Model this as a change to standard offset effective 2025-03-20. + # Rule NAME FROM TO - IN ON AT SAVE LETTER/S Rule Chile 1927 1931 - Sep 1 0:00 1:00 - Rule Chile 1928 1932 - Apr 1 0:00 0 - @@ -1371,6 +1411,20 @@ Zone America/Santiago -4:42:45 - LMT 1890 -5:00 1:00 %z 1947 Mar 31 24:00 -5:00 - %z 1947 May 21 23:00 -4:00 Chile %z +Zone America/Coyhaique -4:48:16 - LMT 1890 + -4:42:45 - SMT 1910 Jan 10 + -5:00 - %z 1916 Jul 1 + -4:42:45 - SMT 1918 Sep 10 + -4:00 - %z 1919 Jul 1 + -4:42:45 - SMT 1927 Sep 1 + -5:00 Chile %z 1932 Sep 1 + -4:00 - %z 1942 Jun 1 + -5:00 - %z 1942 Aug 1 + -4:00 - %z 1946 Aug 28 24:00 + -5:00 1:00 %z 1947 Mar 31 24:00 + -5:00 - %z 1947 May 21 23:00 + -4:00 Chile %z 2025 Mar 20 + -3:00 - %z Zone America/Punta_Arenas -4:43:40 - LMT 1890 -4:42:45 - SMT 1910 Jan 10 -5:00 - %z 1916 Jul 1 diff --git a/contrib/tzdata/version b/contrib/tzdata/version index 0846b7f265fa..ef468adcecf9 100644 --- a/contrib/tzdata/version +++ b/contrib/tzdata/version @@ -1 +1 @@ -2025a +2025b diff --git a/contrib/tzdata/zone.tab b/contrib/tzdata/zone.tab index d2be66359f3b..2626b0550341 100644 --- a/contrib/tzdata/zone.tab +++ b/contrib/tzdata/zone.tab @@ -139,7 +139,8 @@ CH +4723+00832 Europe/Zurich CI +0519-00402 Africa/Abidjan CK -2114-15946 Pacific/Rarotonga CL -3327-07040 America/Santiago most of Chile -CL -5309-07055 America/Punta_Arenas Region of Magallanes +CL -4534-07204 America/Coyhaique Aysen Region +CL -5309-07055 America/Punta_Arenas Magallanes Region CL -2709-10926 Pacific/Easter Easter Island CM +0403+00942 Africa/Douala CN +3114+12128 Asia/Shanghai Beijing Time diff --git a/contrib/tzdata/zone1970.tab b/contrib/tzdata/zone1970.tab index 3a5a71c508d4..814ed69e0468 100644 --- a/contrib/tzdata/zone1970.tab +++ b/contrib/tzdata/zone1970.tab @@ -125,7 +125,8 @@ CH,DE,LI +4723+00832 Europe/Zurich Büsingen CI,BF,GH,GM,GN,IS,ML,MR,SH,SL,SN,TG +0519-00402 Africa/Abidjan CK -2114-15946 Pacific/Rarotonga CL -3327-07040 America/Santiago most of Chile -CL -5309-07055 America/Punta_Arenas Region of Magallanes +CL -4534-07204 America/Coyhaique Aysén Region +CL -5309-07055 America/Punta_Arenas Magallanes Region CL -2709-10926 Pacific/Easter Easter Island CN +3114+12128 Asia/Shanghai Beijing Time CN +4348+08735 Asia/Urumqi Xinjiang Time diff --git a/contrib/tzdata/zonenow.tab b/contrib/tzdata/zonenow.tab index d2c1e48584f8..093f0a0cb749 100644 --- a/contrib/tzdata/zonenow.tab +++ b/contrib/tzdata/zonenow.tab @@ -104,7 +104,7 @@ XX +4439-06336 America/Halifax Atlantic ("AST/ADT") - Canada; Bermuda XX +4734-05243 America/St_Johns Newfoundland ("NST/NDT") # # -03 -XX -2332-04637 America/Sao_Paulo eastern South America +XX -2332-04637 America/Sao_Paulo eastern and southern South America # # -03/-02 (North America DST) XX +4703-05620 America/Miquelon St Pierre & Miquelon diff --git a/crypto/heimdal/lib/krb5/version-script.map b/crypto/heimdal/lib/krb5/version-script.map index 05fc0cef1bd9..348112cef190 100644 --- a/crypto/heimdal/lib/krb5/version-script.map +++ b/crypto/heimdal/lib/krb5/version-script.map @@ -743,6 +743,28 @@ HEIMDAL_KRB5_2.0 { # kinit helper krb5_get_init_creds_opt_set_pkinit_user_certs; krb5_pk_enterprise_cert; + krb5_auth_con_getrecvsubkey; + krb5_auth_con_getsendsubkey; + krb5_auth_con_setrecvsubkey; + krb5_auth_con_setsendsubkey; + krb5_c_random_make_octets; + krb5_cc_copy_creds; + krb5_cc_get_flags; + krb5_creds_get_ticket_flags; + krb5_get_validated_creds; + krb5_init_creds_free; + krb5_init_creds_get_creds; + krb5_init_creds_get_error; + krb5_init_creds_get; + krb5_init_creds_init; + krb5_init_creds_set_keyblock; + krb5_init_creds_set_keytab; + krb5_init_creds_set_password; + krb5_init_creds_set_service; + krb5_init_creds_step; + krb5_rd_req_out_get_server; + krb5_sockaddr_is_loopback; + krb5_ticket_get_flags; # testing _krb5_n_fold; diff --git a/lib/libc/tests/secure/Makefile b/lib/libc/tests/secure/Makefile index ccf89afb1ad5..beaa01457cfe 100644 --- a/lib/libc/tests/secure/Makefile +++ b/lib/libc/tests/secure/Makefile @@ -18,10 +18,18 @@ FORTIFY_TCATS+= unistd FORTIFY_TCATS+= wchar # Manually run after updating the test generator. -generate-tests: .PHONY +lint-generator: .PHONY + @if ! which luacheck>/dev/null; then \ + 1>&2 echo "devel/lua-luacheck is required to regenerate and lint these tests"; \ + exit 1; \ + fi + luacheck ${.CURDIR}/generate-fortify-tests.lua + +generate-tests: .PHONY lint-generator .for tcat in ${FORTIFY_TCATS} ATF_TESTS_C+= fortify_${tcat}_test +.ORDER: lint-generator generate-tests-${tcat} generate-tests: generate-tests-${tcat} generate-tests-${tcat}: .PHONY ${.CURDIR}/generate-fortify-tests.lua ${tcat} > ${.CURDIR}/fortify_${tcat}_test.c diff --git a/lib/libc/tests/secure/fortify_poll_test.c b/lib/libc/tests/secure/fortify_poll_test.c index dce0b0bb65ea..3810c16c122f 100644 --- a/lib/libc/tests/secure/fortify_poll_test.c +++ b/lib/libc/tests/secure/fortify_poll_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,10 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(poll_before_end); +ATF_TC(poll_before_end); +ATF_TC_HEAD(poll_before_end, tc) +{ +} ATF_TC_BODY(poll_before_end, tc) { #define BUF &__stack.__buf @@ -184,7 +188,10 @@ ATF_TC_BODY(poll_before_end, tc) } -ATF_TC_WITHOUT_HEAD(poll_end); +ATF_TC(poll_end); +ATF_TC_HEAD(poll_end, tc) +{ +} ATF_TC_BODY(poll_end, tc) { #define BUF &__stack.__buf @@ -206,7 +213,10 @@ ATF_TC_BODY(poll_end, tc) } -ATF_TC_WITHOUT_HEAD(poll_after_end); +ATF_TC(poll_after_end); +ATF_TC_HEAD(poll_after_end, tc) +{ +} ATF_TC_BODY(poll_after_end, tc) { #define BUF &__stack.__buf @@ -259,7 +269,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(poll_heap_before_end); +ATF_TC(poll_heap_before_end); +ATF_TC_HEAD(poll_heap_before_end, tc) +{ +} ATF_TC_BODY(poll_heap_before_end, tc) { #define BUF __stack.__buf @@ -282,7 +295,10 @@ ATF_TC_BODY(poll_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(poll_heap_end); +ATF_TC(poll_heap_end); +ATF_TC_HEAD(poll_heap_end, tc) +{ +} ATF_TC_BODY(poll_heap_end, tc) { #define BUF __stack.__buf @@ -305,7 +321,10 @@ ATF_TC_BODY(poll_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(poll_heap_after_end); +ATF_TC(poll_heap_after_end); +ATF_TC_HEAD(poll_heap_after_end, tc) +{ +} ATF_TC_BODY(poll_heap_after_end, tc) { #define BUF __stack.__buf @@ -359,7 +378,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(ppoll_before_end); +ATF_TC(ppoll_before_end); +ATF_TC_HEAD(ppoll_before_end, tc) +{ +} ATF_TC_BODY(ppoll_before_end, tc) { #define BUF &__stack.__buf @@ -382,7 +404,10 @@ ATF_TC_BODY(ppoll_before_end, tc) } -ATF_TC_WITHOUT_HEAD(ppoll_end); +ATF_TC(ppoll_end); +ATF_TC_HEAD(ppoll_end, tc) +{ +} ATF_TC_BODY(ppoll_end, tc) { #define BUF &__stack.__buf @@ -405,7 +430,10 @@ ATF_TC_BODY(ppoll_end, tc) } -ATF_TC_WITHOUT_HEAD(ppoll_after_end); +ATF_TC(ppoll_after_end); +ATF_TC_HEAD(ppoll_after_end, tc) +{ +} ATF_TC_BODY(ppoll_after_end, tc) { #define BUF &__stack.__buf @@ -459,7 +487,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(ppoll_heap_before_end); +ATF_TC(ppoll_heap_before_end); +ATF_TC_HEAD(ppoll_heap_before_end, tc) +{ +} ATF_TC_BODY(ppoll_heap_before_end, tc) { #define BUF __stack.__buf @@ -483,7 +514,10 @@ ATF_TC_BODY(ppoll_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(ppoll_heap_end); +ATF_TC(ppoll_heap_end); +ATF_TC_HEAD(ppoll_heap_end, tc) +{ +} ATF_TC_BODY(ppoll_heap_end, tc) { #define BUF __stack.__buf @@ -507,7 +541,10 @@ ATF_TC_BODY(ppoll_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(ppoll_heap_after_end); +ATF_TC(ppoll_heap_after_end); +ATF_TC_HEAD(ppoll_heap_after_end, tc) +{ +} ATF_TC_BODY(ppoll_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/fortify_random_test.c b/lib/libc/tests/secure/fortify_random_test.c index 7763607dd2ed..2f47c981b5ae 100644 --- a/lib/libc/tests/secure/fortify_random_test.c +++ b/lib/libc/tests/secure/fortify_random_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,10 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(getrandom_before_end); +ATF_TC(getrandom_before_end); +ATF_TC_HEAD(getrandom_before_end, tc) +{ +} ATF_TC_BODY(getrandom_before_end, tc) { #define BUF &__stack.__buf @@ -180,7 +184,10 @@ ATF_TC_BODY(getrandom_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getrandom_end); +ATF_TC(getrandom_end); +ATF_TC_HEAD(getrandom_end, tc) +{ +} ATF_TC_BODY(getrandom_end, tc) { #define BUF &__stack.__buf @@ -198,7 +205,10 @@ ATF_TC_BODY(getrandom_end, tc) } -ATF_TC_WITHOUT_HEAD(getrandom_heap_before_end); +ATF_TC(getrandom_heap_before_end); +ATF_TC_HEAD(getrandom_heap_before_end, tc) +{ +} ATF_TC_BODY(getrandom_heap_before_end, tc) { #define BUF __stack.__buf @@ -218,7 +228,10 @@ ATF_TC_BODY(getrandom_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getrandom_heap_end); +ATF_TC(getrandom_heap_end); +ATF_TC_HEAD(getrandom_heap_end, tc) +{ +} ATF_TC_BODY(getrandom_heap_end, tc) { #define BUF __stack.__buf @@ -238,7 +251,10 @@ ATF_TC_BODY(getrandom_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(getrandom_heap_after_end); +ATF_TC(getrandom_heap_after_end); +ATF_TC_HEAD(getrandom_heap_after_end, tc) +{ +} ATF_TC_BODY(getrandom_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/fortify_select_test.c b/lib/libc/tests/secure/fortify_select_test.c index dfafac7e4d6d..5ee97a352e2e 100644 --- a/lib/libc/tests/secure/fortify_select_test.c +++ b/lib/libc/tests/secure/fortify_select_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,10 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(FD_SET_before_end); +ATF_TC(FD_SET_before_end); +ATF_TC_HEAD(FD_SET_before_end, tc) +{ +} ATF_TC_BODY(FD_SET_before_end, tc) { #define BUF &__stack.__buf @@ -180,7 +184,10 @@ ATF_TC_BODY(FD_SET_before_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_SET_end); +ATF_TC(FD_SET_end); +ATF_TC_HEAD(FD_SET_end, tc) +{ +} ATF_TC_BODY(FD_SET_end, tc) { #define BUF &__stack.__buf @@ -198,7 +205,10 @@ ATF_TC_BODY(FD_SET_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_SET_after_end); +ATF_TC(FD_SET_after_end); +ATF_TC_HEAD(FD_SET_after_end, tc) +{ +} ATF_TC_BODY(FD_SET_after_end, tc) { #define BUF &__stack.__buf @@ -247,7 +257,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(FD_SET_heap_before_end); +ATF_TC(FD_SET_heap_before_end); +ATF_TC_HEAD(FD_SET_heap_before_end, tc) +{ +} ATF_TC_BODY(FD_SET_heap_before_end, tc) { #define BUF __stack.__buf @@ -267,7 +280,10 @@ ATF_TC_BODY(FD_SET_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_SET_heap_end); +ATF_TC(FD_SET_heap_end); +ATF_TC_HEAD(FD_SET_heap_end, tc) +{ +} ATF_TC_BODY(FD_SET_heap_end, tc) { #define BUF __stack.__buf @@ -287,7 +303,10 @@ ATF_TC_BODY(FD_SET_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_SET_heap_after_end); +ATF_TC(FD_SET_heap_after_end); +ATF_TC_HEAD(FD_SET_heap_after_end, tc) +{ +} ATF_TC_BODY(FD_SET_heap_after_end, tc) { #define BUF __stack.__buf @@ -338,7 +357,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(FD_CLR_before_end); +ATF_TC(FD_CLR_before_end); +ATF_TC_HEAD(FD_CLR_before_end, tc) +{ +} ATF_TC_BODY(FD_CLR_before_end, tc) { #define BUF &__stack.__buf @@ -356,7 +378,10 @@ ATF_TC_BODY(FD_CLR_before_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_CLR_end); +ATF_TC(FD_CLR_end); +ATF_TC_HEAD(FD_CLR_end, tc) +{ +} ATF_TC_BODY(FD_CLR_end, tc) { #define BUF &__stack.__buf @@ -374,7 +399,10 @@ ATF_TC_BODY(FD_CLR_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_CLR_after_end); +ATF_TC(FD_CLR_after_end); +ATF_TC_HEAD(FD_CLR_after_end, tc) +{ +} ATF_TC_BODY(FD_CLR_after_end, tc) { #define BUF &__stack.__buf @@ -423,7 +451,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(FD_CLR_heap_before_end); +ATF_TC(FD_CLR_heap_before_end); +ATF_TC_HEAD(FD_CLR_heap_before_end, tc) +{ +} ATF_TC_BODY(FD_CLR_heap_before_end, tc) { #define BUF __stack.__buf @@ -443,7 +474,10 @@ ATF_TC_BODY(FD_CLR_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_CLR_heap_end); +ATF_TC(FD_CLR_heap_end); +ATF_TC_HEAD(FD_CLR_heap_end, tc) +{ +} ATF_TC_BODY(FD_CLR_heap_end, tc) { #define BUF __stack.__buf @@ -463,7 +497,10 @@ ATF_TC_BODY(FD_CLR_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_CLR_heap_after_end); +ATF_TC(FD_CLR_heap_after_end); +ATF_TC_HEAD(FD_CLR_heap_after_end, tc) +{ +} ATF_TC_BODY(FD_CLR_heap_after_end, tc) { #define BUF __stack.__buf @@ -514,7 +551,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(FD_ISSET_before_end); +ATF_TC(FD_ISSET_before_end); +ATF_TC_HEAD(FD_ISSET_before_end, tc) +{ +} ATF_TC_BODY(FD_ISSET_before_end, tc) { #define BUF &__stack.__buf @@ -532,7 +572,10 @@ ATF_TC_BODY(FD_ISSET_before_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_ISSET_end); +ATF_TC(FD_ISSET_end); +ATF_TC_HEAD(FD_ISSET_end, tc) +{ +} ATF_TC_BODY(FD_ISSET_end, tc) { #define BUF &__stack.__buf @@ -550,7 +593,10 @@ ATF_TC_BODY(FD_ISSET_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_ISSET_after_end); +ATF_TC(FD_ISSET_after_end); +ATF_TC_HEAD(FD_ISSET_after_end, tc) +{ +} ATF_TC_BODY(FD_ISSET_after_end, tc) { #define BUF &__stack.__buf @@ -599,7 +645,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(FD_ISSET_heap_before_end); +ATF_TC(FD_ISSET_heap_before_end); +ATF_TC_HEAD(FD_ISSET_heap_before_end, tc) +{ +} ATF_TC_BODY(FD_ISSET_heap_before_end, tc) { #define BUF __stack.__buf @@ -619,7 +668,10 @@ ATF_TC_BODY(FD_ISSET_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_ISSET_heap_end); +ATF_TC(FD_ISSET_heap_end); +ATF_TC_HEAD(FD_ISSET_heap_end, tc) +{ +} ATF_TC_BODY(FD_ISSET_heap_end, tc) { #define BUF __stack.__buf @@ -639,7 +691,10 @@ ATF_TC_BODY(FD_ISSET_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(FD_ISSET_heap_after_end); +ATF_TC(FD_ISSET_heap_after_end); +ATF_TC_HEAD(FD_ISSET_heap_after_end, tc) +{ +} ATF_TC_BODY(FD_ISSET_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/fortify_socket_test.c b/lib/libc/tests/secure/fortify_socket_test.c index a2125d60fc2d..3d2dc86f4e1c 100644 --- a/lib/libc/tests/secure/fortify_socket_test.c +++ b/lib/libc/tests/secure/fortify_socket_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,10 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(getpeername_before_end); +ATF_TC(getpeername_before_end); +ATF_TC_HEAD(getpeername_before_end, tc) +{ +} ATF_TC_BODY(getpeername_before_end, tc) { #define BUF &__stack.__buf @@ -184,7 +188,10 @@ ATF_TC_BODY(getpeername_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getpeername_end); +ATF_TC(getpeername_end); +ATF_TC_HEAD(getpeername_end, tc) +{ +} ATF_TC_BODY(getpeername_end, tc) { #define BUF &__stack.__buf @@ -206,7 +213,10 @@ ATF_TC_BODY(getpeername_end, tc) } -ATF_TC_WITHOUT_HEAD(getpeername_heap_before_end); +ATF_TC(getpeername_heap_before_end); +ATF_TC_HEAD(getpeername_heap_before_end, tc) +{ +} ATF_TC_BODY(getpeername_heap_before_end, tc) { #define BUF __stack.__buf @@ -229,7 +239,10 @@ ATF_TC_BODY(getpeername_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getpeername_heap_end); +ATF_TC(getpeername_heap_end); +ATF_TC_HEAD(getpeername_heap_end, tc) +{ +} ATF_TC_BODY(getpeername_heap_end, tc) { #define BUF __stack.__buf @@ -252,7 +265,10 @@ ATF_TC_BODY(getpeername_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(getpeername_heap_after_end); +ATF_TC(getpeername_heap_after_end); +ATF_TC_HEAD(getpeername_heap_after_end, tc) +{ +} ATF_TC_BODY(getpeername_heap_after_end, tc) { #define BUF __stack.__buf @@ -306,7 +322,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(getsockname_before_end); +ATF_TC(getsockname_before_end); +ATF_TC_HEAD(getsockname_before_end, tc) +{ +} ATF_TC_BODY(getsockname_before_end, tc) { #define BUF &__stack.__buf @@ -328,7 +347,10 @@ ATF_TC_BODY(getsockname_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getsockname_end); +ATF_TC(getsockname_end); +ATF_TC_HEAD(getsockname_end, tc) +{ +} ATF_TC_BODY(getsockname_end, tc) { #define BUF &__stack.__buf @@ -350,7 +372,10 @@ ATF_TC_BODY(getsockname_end, tc) } -ATF_TC_WITHOUT_HEAD(getsockname_heap_before_end); +ATF_TC(getsockname_heap_before_end); +ATF_TC_HEAD(getsockname_heap_before_end, tc) +{ +} ATF_TC_BODY(getsockname_heap_before_end, tc) { #define BUF __stack.__buf @@ -373,7 +398,10 @@ ATF_TC_BODY(getsockname_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getsockname_heap_end); +ATF_TC(getsockname_heap_end); +ATF_TC_HEAD(getsockname_heap_end, tc) +{ +} ATF_TC_BODY(getsockname_heap_end, tc) { #define BUF __stack.__buf @@ -396,7 +424,10 @@ ATF_TC_BODY(getsockname_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(getsockname_heap_after_end); +ATF_TC(getsockname_heap_after_end); +ATF_TC_HEAD(getsockname_heap_after_end, tc) +{ +} ATF_TC_BODY(getsockname_heap_after_end, tc) { #define BUF __stack.__buf @@ -450,7 +481,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(recv_before_end); +ATF_TC(recv_before_end); +ATF_TC_HEAD(recv_before_end, tc) +{ +} ATF_TC_BODY(recv_before_end, tc) { #define BUF &__stack.__buf @@ -471,7 +505,10 @@ ATF_TC_BODY(recv_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recv_end); +ATF_TC(recv_end); +ATF_TC_HEAD(recv_end, tc) +{ +} ATF_TC_BODY(recv_end, tc) { #define BUF &__stack.__buf @@ -492,7 +529,10 @@ ATF_TC_BODY(recv_end, tc) } -ATF_TC_WITHOUT_HEAD(recv_heap_before_end); +ATF_TC(recv_heap_before_end); +ATF_TC_HEAD(recv_heap_before_end, tc) +{ +} ATF_TC_BODY(recv_heap_before_end, tc) { #define BUF __stack.__buf @@ -514,7 +554,10 @@ ATF_TC_BODY(recv_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recv_heap_end); +ATF_TC(recv_heap_end); +ATF_TC_HEAD(recv_heap_end, tc) +{ +} ATF_TC_BODY(recv_heap_end, tc) { #define BUF __stack.__buf @@ -536,7 +579,10 @@ ATF_TC_BODY(recv_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(recv_heap_after_end); +ATF_TC(recv_heap_after_end); +ATF_TC_HEAD(recv_heap_after_end, tc) +{ +} ATF_TC_BODY(recv_heap_after_end, tc) { #define BUF __stack.__buf @@ -589,7 +635,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(recvfrom_before_end); +ATF_TC(recvfrom_before_end); +ATF_TC_HEAD(recvfrom_before_end, tc) +{ +} ATF_TC_BODY(recvfrom_before_end, tc) { #define BUF &__stack.__buf @@ -610,7 +659,10 @@ ATF_TC_BODY(recvfrom_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvfrom_end); +ATF_TC(recvfrom_end); +ATF_TC_HEAD(recvfrom_end, tc) +{ +} ATF_TC_BODY(recvfrom_end, tc) { #define BUF &__stack.__buf @@ -631,7 +683,10 @@ ATF_TC_BODY(recvfrom_end, tc) } -ATF_TC_WITHOUT_HEAD(recvfrom_heap_before_end); +ATF_TC(recvfrom_heap_before_end); +ATF_TC_HEAD(recvfrom_heap_before_end, tc) +{ +} ATF_TC_BODY(recvfrom_heap_before_end, tc) { #define BUF __stack.__buf @@ -653,7 +708,10 @@ ATF_TC_BODY(recvfrom_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvfrom_heap_end); +ATF_TC(recvfrom_heap_end); +ATF_TC_HEAD(recvfrom_heap_end, tc) +{ +} ATF_TC_BODY(recvfrom_heap_end, tc) { #define BUF __stack.__buf @@ -675,7 +733,10 @@ ATF_TC_BODY(recvfrom_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(recvfrom_heap_after_end); +ATF_TC(recvfrom_heap_after_end); +ATF_TC_HEAD(recvfrom_heap_after_end, tc) +{ +} ATF_TC_BODY(recvfrom_heap_after_end, tc) { #define BUF __stack.__buf @@ -728,7 +789,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(recvfrom_sockaddr_before_end); +ATF_TC(recvfrom_sockaddr_before_end); +ATF_TC_HEAD(recvfrom_sockaddr_before_end, tc) +{ +} ATF_TC_BODY(recvfrom_sockaddr_before_end, tc) { #define BUF &__stack.__buf @@ -752,7 +816,10 @@ ATF_TC_BODY(recvfrom_sockaddr_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvfrom_sockaddr_end); +ATF_TC(recvfrom_sockaddr_end); +ATF_TC_HEAD(recvfrom_sockaddr_end, tc) +{ +} ATF_TC_BODY(recvfrom_sockaddr_end, tc) { #define BUF &__stack.__buf @@ -776,7 +843,10 @@ ATF_TC_BODY(recvfrom_sockaddr_end, tc) } -ATF_TC_WITHOUT_HEAD(recvfrom_sockaddr_heap_before_end); +ATF_TC(recvfrom_sockaddr_heap_before_end); +ATF_TC_HEAD(recvfrom_sockaddr_heap_before_end, tc) +{ +} ATF_TC_BODY(recvfrom_sockaddr_heap_before_end, tc) { #define BUF __stack.__buf @@ -801,7 +871,10 @@ ATF_TC_BODY(recvfrom_sockaddr_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvfrom_sockaddr_heap_end); +ATF_TC(recvfrom_sockaddr_heap_end); +ATF_TC_HEAD(recvfrom_sockaddr_heap_end, tc) +{ +} ATF_TC_BODY(recvfrom_sockaddr_heap_end, tc) { #define BUF __stack.__buf @@ -826,7 +899,10 @@ ATF_TC_BODY(recvfrom_sockaddr_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(recvfrom_sockaddr_heap_after_end); +ATF_TC(recvfrom_sockaddr_heap_after_end); +ATF_TC_HEAD(recvfrom_sockaddr_heap_after_end, tc) +{ +} ATF_TC_BODY(recvfrom_sockaddr_heap_after_end, tc) { #define BUF __stack.__buf @@ -882,7 +958,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_name_before_end); +ATF_TC(recvmsg_msg_name_before_end); +ATF_TC_HEAD(recvmsg_msg_name_before_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_name_before_end, tc) { #define BUF &__stack.__buf @@ -906,7 +985,10 @@ ATF_TC_BODY(recvmsg_msg_name_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_name_end); +ATF_TC(recvmsg_msg_name_end); +ATF_TC_HEAD(recvmsg_msg_name_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_name_end, tc) { #define BUF &__stack.__buf @@ -930,7 +1012,10 @@ ATF_TC_BODY(recvmsg_msg_name_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_name_heap_before_end); +ATF_TC(recvmsg_msg_name_heap_before_end); +ATF_TC_HEAD(recvmsg_msg_name_heap_before_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_name_heap_before_end, tc) { #define BUF __stack.__buf @@ -955,7 +1040,10 @@ ATF_TC_BODY(recvmsg_msg_name_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_name_heap_end); +ATF_TC(recvmsg_msg_name_heap_end); +ATF_TC_HEAD(recvmsg_msg_name_heap_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_name_heap_end, tc) { #define BUF __stack.__buf @@ -980,7 +1068,10 @@ ATF_TC_BODY(recvmsg_msg_name_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_name_heap_after_end); +ATF_TC(recvmsg_msg_name_heap_after_end); +ATF_TC_HEAD(recvmsg_msg_name_heap_after_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_name_heap_after_end, tc) { #define BUF __stack.__buf @@ -1036,7 +1127,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_iov_before_end); +ATF_TC(recvmsg_msg_iov_before_end); +ATF_TC_HEAD(recvmsg_msg_iov_before_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_iov_before_end, tc) { #define BUF &__stack.__buf @@ -1070,7 +1164,10 @@ ATF_TC_BODY(recvmsg_msg_iov_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_iov_end); +ATF_TC(recvmsg_msg_iov_end); +ATF_TC_HEAD(recvmsg_msg_iov_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_iov_end, tc) { #define BUF &__stack.__buf @@ -1104,7 +1201,10 @@ ATF_TC_BODY(recvmsg_msg_iov_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_iov_heap_before_end); +ATF_TC(recvmsg_msg_iov_heap_before_end); +ATF_TC_HEAD(recvmsg_msg_iov_heap_before_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_iov_heap_before_end, tc) { #define BUF __stack.__buf @@ -1139,7 +1239,10 @@ ATF_TC_BODY(recvmsg_msg_iov_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_iov_heap_end); +ATF_TC(recvmsg_msg_iov_heap_end); +ATF_TC_HEAD(recvmsg_msg_iov_heap_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_iov_heap_end, tc) { #define BUF __stack.__buf @@ -1174,7 +1277,10 @@ ATF_TC_BODY(recvmsg_msg_iov_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_iov_heap_after_end); +ATF_TC(recvmsg_msg_iov_heap_after_end); +ATF_TC_HEAD(recvmsg_msg_iov_heap_after_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_iov_heap_after_end, tc) { #define BUF __stack.__buf @@ -1240,7 +1346,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_control_before_end); +ATF_TC(recvmsg_msg_control_before_end); +ATF_TC_HEAD(recvmsg_msg_control_before_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_control_before_end, tc) { #define BUF &__stack.__buf @@ -1265,7 +1374,10 @@ ATF_TC_BODY(recvmsg_msg_control_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_control_end); +ATF_TC(recvmsg_msg_control_end); +ATF_TC_HEAD(recvmsg_msg_control_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_control_end, tc) { #define BUF &__stack.__buf @@ -1290,7 +1402,10 @@ ATF_TC_BODY(recvmsg_msg_control_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_control_heap_before_end); +ATF_TC(recvmsg_msg_control_heap_before_end); +ATF_TC_HEAD(recvmsg_msg_control_heap_before_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_control_heap_before_end, tc) { #define BUF __stack.__buf @@ -1316,7 +1431,10 @@ ATF_TC_BODY(recvmsg_msg_control_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_control_heap_end); +ATF_TC(recvmsg_msg_control_heap_end); +ATF_TC_HEAD(recvmsg_msg_control_heap_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_control_heap_end, tc) { #define BUF __stack.__buf @@ -1342,7 +1460,10 @@ ATF_TC_BODY(recvmsg_msg_control_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmsg_msg_control_heap_after_end); +ATF_TC(recvmsg_msg_control_heap_after_end); +ATF_TC_HEAD(recvmsg_msg_control_heap_after_end, tc) +{ +} ATF_TC_BODY(recvmsg_msg_control_heap_after_end, tc) { #define BUF __stack.__buf @@ -1399,7 +1520,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(recvmmsg_msgvec_before_end); +ATF_TC(recvmmsg_msgvec_before_end); +ATF_TC_HEAD(recvmmsg_msgvec_before_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msgvec_before_end, tc) { #define BUF &__stack.__buf @@ -1418,7 +1542,10 @@ ATF_TC_BODY(recvmmsg_msgvec_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmmsg_msgvec_end); +ATF_TC(recvmmsg_msgvec_end); +ATF_TC_HEAD(recvmmsg_msgvec_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msgvec_end, tc) { #define BUF &__stack.__buf @@ -1437,7 +1564,10 @@ ATF_TC_BODY(recvmmsg_msgvec_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmmsg_msgvec_after_end); +ATF_TC(recvmmsg_msgvec_after_end); +ATF_TC_HEAD(recvmmsg_msgvec_after_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msgvec_after_end, tc) { #define BUF &__stack.__buf @@ -1487,7 +1617,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(recvmmsg_msgvec_heap_before_end); +ATF_TC(recvmmsg_msgvec_heap_before_end); +ATF_TC_HEAD(recvmmsg_msgvec_heap_before_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msgvec_heap_before_end, tc) { #define BUF __stack.__buf @@ -1508,7 +1641,10 @@ ATF_TC_BODY(recvmmsg_msgvec_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmmsg_msgvec_heap_end); +ATF_TC(recvmmsg_msgvec_heap_end); +ATF_TC_HEAD(recvmmsg_msgvec_heap_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msgvec_heap_end, tc) { #define BUF __stack.__buf @@ -1529,7 +1665,10 @@ ATF_TC_BODY(recvmmsg_msgvec_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmmsg_msgvec_heap_after_end); +ATF_TC(recvmmsg_msgvec_heap_after_end); +ATF_TC_HEAD(recvmmsg_msgvec_heap_after_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msgvec_heap_after_end, tc) { #define BUF __stack.__buf @@ -1581,7 +1720,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(recvmmsg_msghdr_before_end); +ATF_TC(recvmmsg_msghdr_before_end); +ATF_TC_HEAD(recvmmsg_msghdr_before_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msghdr_before_end, tc) { #define BUF &__stack.__buf @@ -1610,7 +1752,10 @@ ATF_TC_BODY(recvmmsg_msghdr_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmmsg_msghdr_end); +ATF_TC(recvmmsg_msghdr_end); +ATF_TC_HEAD(recvmmsg_msghdr_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msghdr_end, tc) { #define BUF &__stack.__buf @@ -1639,7 +1784,10 @@ ATF_TC_BODY(recvmmsg_msghdr_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmmsg_msghdr_heap_before_end); +ATF_TC(recvmmsg_msghdr_heap_before_end); +ATF_TC_HEAD(recvmmsg_msghdr_heap_before_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msghdr_heap_before_end, tc) { #define BUF __stack.__buf @@ -1669,7 +1817,10 @@ ATF_TC_BODY(recvmmsg_msghdr_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmmsg_msghdr_heap_end); +ATF_TC(recvmmsg_msghdr_heap_end); +ATF_TC_HEAD(recvmmsg_msghdr_heap_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msghdr_heap_end, tc) { #define BUF __stack.__buf @@ -1699,7 +1850,10 @@ ATF_TC_BODY(recvmmsg_msghdr_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(recvmmsg_msghdr_heap_after_end); +ATF_TC(recvmmsg_msghdr_heap_after_end); +ATF_TC_HEAD(recvmmsg_msghdr_heap_after_end, tc) +{ +} ATF_TC_BODY(recvmmsg_msghdr_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/fortify_stdio_test.c b/lib/libc/tests/secure/fortify_stdio_test.c index a8764d646de2..17842393a740 100644 --- a/lib/libc/tests/secure/fortify_stdio_test.c +++ b/lib/libc/tests/secure/fortify_stdio_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,10 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(ctermid_before_end); +ATF_TC(ctermid_before_end); +ATF_TC_HEAD(ctermid_before_end, tc) +{ +} ATF_TC_BODY(ctermid_before_end, tc) { #define BUF &__stack.__buf @@ -180,7 +184,10 @@ ATF_TC_BODY(ctermid_before_end, tc) } -ATF_TC_WITHOUT_HEAD(ctermid_end); +ATF_TC(ctermid_end); +ATF_TC_HEAD(ctermid_end, tc) +{ +} ATF_TC_BODY(ctermid_end, tc) { #define BUF &__stack.__buf @@ -198,7 +205,10 @@ ATF_TC_BODY(ctermid_end, tc) } -ATF_TC_WITHOUT_HEAD(ctermid_heap_before_end); +ATF_TC(ctermid_heap_before_end); +ATF_TC_HEAD(ctermid_heap_before_end, tc) +{ +} ATF_TC_BODY(ctermid_heap_before_end, tc) { #define BUF __stack.__buf @@ -218,7 +228,10 @@ ATF_TC_BODY(ctermid_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(ctermid_heap_end); +ATF_TC(ctermid_heap_end); +ATF_TC_HEAD(ctermid_heap_end, tc) +{ +} ATF_TC_BODY(ctermid_heap_end, tc) { #define BUF __stack.__buf @@ -238,7 +251,10 @@ ATF_TC_BODY(ctermid_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(ctermid_heap_after_end); +ATF_TC(ctermid_heap_after_end); +ATF_TC_HEAD(ctermid_heap_after_end, tc) +{ +} ATF_TC_BODY(ctermid_heap_after_end, tc) { #define BUF __stack.__buf @@ -289,7 +305,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(ctermid_r_before_end); +ATF_TC(ctermid_r_before_end); +ATF_TC_HEAD(ctermid_r_before_end, tc) +{ +} ATF_TC_BODY(ctermid_r_before_end, tc) { #define BUF &__stack.__buf @@ -307,7 +326,10 @@ ATF_TC_BODY(ctermid_r_before_end, tc) } -ATF_TC_WITHOUT_HEAD(ctermid_r_end); +ATF_TC(ctermid_r_end); +ATF_TC_HEAD(ctermid_r_end, tc) +{ +} ATF_TC_BODY(ctermid_r_end, tc) { #define BUF &__stack.__buf @@ -325,7 +347,10 @@ ATF_TC_BODY(ctermid_r_end, tc) } -ATF_TC_WITHOUT_HEAD(ctermid_r_heap_before_end); +ATF_TC(ctermid_r_heap_before_end); +ATF_TC_HEAD(ctermid_r_heap_before_end, tc) +{ +} ATF_TC_BODY(ctermid_r_heap_before_end, tc) { #define BUF __stack.__buf @@ -345,7 +370,10 @@ ATF_TC_BODY(ctermid_r_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(ctermid_r_heap_end); +ATF_TC(ctermid_r_heap_end); +ATF_TC_HEAD(ctermid_r_heap_end, tc) +{ +} ATF_TC_BODY(ctermid_r_heap_end, tc) { #define BUF __stack.__buf @@ -365,7 +393,10 @@ ATF_TC_BODY(ctermid_r_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(ctermid_r_heap_after_end); +ATF_TC(ctermid_r_heap_after_end); +ATF_TC_HEAD(ctermid_r_heap_after_end, tc) +{ +} ATF_TC_BODY(ctermid_r_heap_after_end, tc) { #define BUF __stack.__buf @@ -416,7 +447,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(fread_before_end); +ATF_TC(fread_before_end); +ATF_TC_HEAD(fread_before_end, tc) +{ +} ATF_TC_BODY(fread_before_end, tc) { #define BUF &__stack.__buf @@ -436,7 +470,10 @@ ATF_TC_BODY(fread_before_end, tc) } -ATF_TC_WITHOUT_HEAD(fread_end); +ATF_TC(fread_end); +ATF_TC_HEAD(fread_end, tc) +{ +} ATF_TC_BODY(fread_end, tc) { #define BUF &__stack.__buf @@ -456,7 +493,10 @@ ATF_TC_BODY(fread_end, tc) } -ATF_TC_WITHOUT_HEAD(fread_heap_before_end); +ATF_TC(fread_heap_before_end); +ATF_TC_HEAD(fread_heap_before_end, tc) +{ +} ATF_TC_BODY(fread_heap_before_end, tc) { #define BUF __stack.__buf @@ -477,7 +517,10 @@ ATF_TC_BODY(fread_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(fread_heap_end); +ATF_TC(fread_heap_end); +ATF_TC_HEAD(fread_heap_end, tc) +{ +} ATF_TC_BODY(fread_heap_end, tc) { #define BUF __stack.__buf @@ -498,7 +541,10 @@ ATF_TC_BODY(fread_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(fread_heap_after_end); +ATF_TC(fread_heap_after_end); +ATF_TC_HEAD(fread_heap_after_end, tc) +{ +} ATF_TC_BODY(fread_heap_after_end, tc) { #define BUF __stack.__buf @@ -550,7 +596,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(fread_unlocked_before_end); +ATF_TC(fread_unlocked_before_end); +ATF_TC_HEAD(fread_unlocked_before_end, tc) +{ +} ATF_TC_BODY(fread_unlocked_before_end, tc) { #define BUF &__stack.__buf @@ -570,7 +619,10 @@ ATF_TC_BODY(fread_unlocked_before_end, tc) } -ATF_TC_WITHOUT_HEAD(fread_unlocked_end); +ATF_TC(fread_unlocked_end); +ATF_TC_HEAD(fread_unlocked_end, tc) +{ +} ATF_TC_BODY(fread_unlocked_end, tc) { #define BUF &__stack.__buf @@ -590,7 +642,10 @@ ATF_TC_BODY(fread_unlocked_end, tc) } -ATF_TC_WITHOUT_HEAD(fread_unlocked_heap_before_end); +ATF_TC(fread_unlocked_heap_before_end); +ATF_TC_HEAD(fread_unlocked_heap_before_end, tc) +{ +} ATF_TC_BODY(fread_unlocked_heap_before_end, tc) { #define BUF __stack.__buf @@ -611,7 +666,10 @@ ATF_TC_BODY(fread_unlocked_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(fread_unlocked_heap_end); +ATF_TC(fread_unlocked_heap_end); +ATF_TC_HEAD(fread_unlocked_heap_end, tc) +{ +} ATF_TC_BODY(fread_unlocked_heap_end, tc) { #define BUF __stack.__buf @@ -632,7 +690,10 @@ ATF_TC_BODY(fread_unlocked_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(fread_unlocked_heap_after_end); +ATF_TC(fread_unlocked_heap_after_end); +ATF_TC_HEAD(fread_unlocked_heap_after_end, tc) +{ +} ATF_TC_BODY(fread_unlocked_heap_after_end, tc) { #define BUF __stack.__buf @@ -684,7 +745,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(gets_s_before_end); +ATF_TC(gets_s_before_end); +ATF_TC_HEAD(gets_s_before_end, tc) +{ +} ATF_TC_BODY(gets_s_before_end, tc) { #define BUF &__stack.__buf @@ -704,7 +768,10 @@ ATF_TC_BODY(gets_s_before_end, tc) } -ATF_TC_WITHOUT_HEAD(gets_s_end); +ATF_TC(gets_s_end); +ATF_TC_HEAD(gets_s_end, tc) +{ +} ATF_TC_BODY(gets_s_end, tc) { #define BUF &__stack.__buf @@ -724,7 +791,10 @@ ATF_TC_BODY(gets_s_end, tc) } -ATF_TC_WITHOUT_HEAD(gets_s_heap_before_end); +ATF_TC(gets_s_heap_before_end); +ATF_TC_HEAD(gets_s_heap_before_end, tc) +{ +} ATF_TC_BODY(gets_s_heap_before_end, tc) { #define BUF __stack.__buf @@ -745,7 +815,10 @@ ATF_TC_BODY(gets_s_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(gets_s_heap_end); +ATF_TC(gets_s_heap_end); +ATF_TC_HEAD(gets_s_heap_end, tc) +{ +} ATF_TC_BODY(gets_s_heap_end, tc) { #define BUF __stack.__buf @@ -766,7 +839,10 @@ ATF_TC_BODY(gets_s_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(gets_s_heap_after_end); +ATF_TC(gets_s_heap_after_end); +ATF_TC_HEAD(gets_s_heap_after_end, tc) +{ +} ATF_TC_BODY(gets_s_heap_after_end, tc) { #define BUF __stack.__buf @@ -818,7 +894,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(sprintf_before_end); +ATF_TC(sprintf_before_end); +ATF_TC_HEAD(sprintf_before_end, tc) +{ +} ATF_TC_BODY(sprintf_before_end, tc) { #define BUF &__stack.__buf @@ -840,7 +919,10 @@ ATF_TC_BODY(sprintf_before_end, tc) } -ATF_TC_WITHOUT_HEAD(sprintf_end); +ATF_TC(sprintf_end); +ATF_TC_HEAD(sprintf_end, tc) +{ +} ATF_TC_BODY(sprintf_end, tc) { #define BUF &__stack.__buf @@ -862,7 +944,10 @@ ATF_TC_BODY(sprintf_end, tc) } -ATF_TC_WITHOUT_HEAD(sprintf_heap_before_end); +ATF_TC(sprintf_heap_before_end); +ATF_TC_HEAD(sprintf_heap_before_end, tc) +{ +} ATF_TC_BODY(sprintf_heap_before_end, tc) { #define BUF __stack.__buf @@ -885,7 +970,10 @@ ATF_TC_BODY(sprintf_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(sprintf_heap_end); +ATF_TC(sprintf_heap_end); +ATF_TC_HEAD(sprintf_heap_end, tc) +{ +} ATF_TC_BODY(sprintf_heap_end, tc) { #define BUF __stack.__buf @@ -908,7 +996,10 @@ ATF_TC_BODY(sprintf_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(sprintf_heap_after_end); +ATF_TC(sprintf_heap_after_end); +ATF_TC_HEAD(sprintf_heap_after_end, tc) +{ +} ATF_TC_BODY(sprintf_heap_after_end, tc) { #define BUF __stack.__buf @@ -962,7 +1053,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(snprintf_before_end); +ATF_TC(snprintf_before_end); +ATF_TC_HEAD(snprintf_before_end, tc) +{ +} ATF_TC_BODY(snprintf_before_end, tc) { #define BUF &__stack.__buf @@ -984,7 +1078,10 @@ ATF_TC_BODY(snprintf_before_end, tc) } -ATF_TC_WITHOUT_HEAD(snprintf_end); +ATF_TC(snprintf_end); +ATF_TC_HEAD(snprintf_end, tc) +{ +} ATF_TC_BODY(snprintf_end, tc) { #define BUF &__stack.__buf @@ -1006,7 +1103,10 @@ ATF_TC_BODY(snprintf_end, tc) } -ATF_TC_WITHOUT_HEAD(snprintf_heap_before_end); +ATF_TC(snprintf_heap_before_end); +ATF_TC_HEAD(snprintf_heap_before_end, tc) +{ +} ATF_TC_BODY(snprintf_heap_before_end, tc) { #define BUF __stack.__buf @@ -1029,7 +1129,10 @@ ATF_TC_BODY(snprintf_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(snprintf_heap_end); +ATF_TC(snprintf_heap_end); +ATF_TC_HEAD(snprintf_heap_end, tc) +{ +} ATF_TC_BODY(snprintf_heap_end, tc) { #define BUF __stack.__buf @@ -1052,7 +1155,10 @@ ATF_TC_BODY(snprintf_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(snprintf_heap_after_end); +ATF_TC(snprintf_heap_after_end); +ATF_TC_HEAD(snprintf_heap_after_end, tc) +{ +} ATF_TC_BODY(snprintf_heap_after_end, tc) { #define BUF __stack.__buf @@ -1106,7 +1212,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(tmpnam_before_end); +ATF_TC(tmpnam_before_end); +ATF_TC_HEAD(tmpnam_before_end, tc) +{ +} ATF_TC_BODY(tmpnam_before_end, tc) { #define BUF &__stack.__buf @@ -1124,7 +1233,10 @@ ATF_TC_BODY(tmpnam_before_end, tc) } -ATF_TC_WITHOUT_HEAD(tmpnam_end); +ATF_TC(tmpnam_end); +ATF_TC_HEAD(tmpnam_end, tc) +{ +} ATF_TC_BODY(tmpnam_end, tc) { #define BUF &__stack.__buf @@ -1142,7 +1254,10 @@ ATF_TC_BODY(tmpnam_end, tc) } -ATF_TC_WITHOUT_HEAD(tmpnam_heap_before_end); +ATF_TC(tmpnam_heap_before_end); +ATF_TC_HEAD(tmpnam_heap_before_end, tc) +{ +} ATF_TC_BODY(tmpnam_heap_before_end, tc) { #define BUF __stack.__buf @@ -1162,7 +1277,10 @@ ATF_TC_BODY(tmpnam_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(tmpnam_heap_end); +ATF_TC(tmpnam_heap_end); +ATF_TC_HEAD(tmpnam_heap_end, tc) +{ +} ATF_TC_BODY(tmpnam_heap_end, tc) { #define BUF __stack.__buf @@ -1182,7 +1300,10 @@ ATF_TC_BODY(tmpnam_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(tmpnam_heap_after_end); +ATF_TC(tmpnam_heap_after_end); +ATF_TC_HEAD(tmpnam_heap_after_end, tc) +{ +} ATF_TC_BODY(tmpnam_heap_after_end, tc) { #define BUF __stack.__buf @@ -1233,7 +1354,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(fgets_before_end); +ATF_TC(fgets_before_end); +ATF_TC_HEAD(fgets_before_end, tc) +{ +} ATF_TC_BODY(fgets_before_end, tc) { #define BUF &__stack.__buf @@ -1254,7 +1378,10 @@ ATF_TC_BODY(fgets_before_end, tc) } -ATF_TC_WITHOUT_HEAD(fgets_end); +ATF_TC(fgets_end); +ATF_TC_HEAD(fgets_end, tc) +{ +} ATF_TC_BODY(fgets_end, tc) { #define BUF &__stack.__buf @@ -1275,7 +1402,10 @@ ATF_TC_BODY(fgets_end, tc) } -ATF_TC_WITHOUT_HEAD(fgets_heap_before_end); +ATF_TC(fgets_heap_before_end); +ATF_TC_HEAD(fgets_heap_before_end, tc) +{ +} ATF_TC_BODY(fgets_heap_before_end, tc) { #define BUF __stack.__buf @@ -1297,7 +1427,10 @@ ATF_TC_BODY(fgets_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(fgets_heap_end); +ATF_TC(fgets_heap_end); +ATF_TC_HEAD(fgets_heap_end, tc) +{ +} ATF_TC_BODY(fgets_heap_end, tc) { #define BUF __stack.__buf @@ -1319,7 +1452,10 @@ ATF_TC_BODY(fgets_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(fgets_heap_after_end); +ATF_TC(fgets_heap_after_end); +ATF_TC_HEAD(fgets_heap_after_end, tc) +{ +} ATF_TC_BODY(fgets_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/fortify_stdlib_test.c b/lib/libc/tests/secure/fortify_stdlib_test.c index 11bb714151e1..ae021e8418f7 100644 --- a/lib/libc/tests/secure/fortify_stdlib_test.c +++ b/lib/libc/tests/secure/fortify_stdlib_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,10 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(arc4random_buf_before_end); +ATF_TC(arc4random_buf_before_end); +ATF_TC_HEAD(arc4random_buf_before_end, tc) +{ +} ATF_TC_BODY(arc4random_buf_before_end, tc) { #define BUF &__stack.__buf @@ -180,7 +184,10 @@ ATF_TC_BODY(arc4random_buf_before_end, tc) } -ATF_TC_WITHOUT_HEAD(arc4random_buf_end); +ATF_TC(arc4random_buf_end); +ATF_TC_HEAD(arc4random_buf_end, tc) +{ +} ATF_TC_BODY(arc4random_buf_end, tc) { #define BUF &__stack.__buf @@ -198,7 +205,10 @@ ATF_TC_BODY(arc4random_buf_end, tc) } -ATF_TC_WITHOUT_HEAD(arc4random_buf_heap_before_end); +ATF_TC(arc4random_buf_heap_before_end); +ATF_TC_HEAD(arc4random_buf_heap_before_end, tc) +{ +} ATF_TC_BODY(arc4random_buf_heap_before_end, tc) { #define BUF __stack.__buf @@ -218,7 +228,10 @@ ATF_TC_BODY(arc4random_buf_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(arc4random_buf_heap_end); +ATF_TC(arc4random_buf_heap_end); +ATF_TC_HEAD(arc4random_buf_heap_end, tc) +{ +} ATF_TC_BODY(arc4random_buf_heap_end, tc) { #define BUF __stack.__buf @@ -238,7 +251,10 @@ ATF_TC_BODY(arc4random_buf_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(arc4random_buf_heap_after_end); +ATF_TC(arc4random_buf_heap_after_end); +ATF_TC_HEAD(arc4random_buf_heap_after_end, tc) +{ +} ATF_TC_BODY(arc4random_buf_heap_after_end, tc) { #define BUF __stack.__buf @@ -289,7 +305,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(realpath_before_end); +ATF_TC(realpath_before_end); +ATF_TC_HEAD(realpath_before_end, tc) +{ +} ATF_TC_BODY(realpath_before_end, tc) { #define BUF &__stack.__buf @@ -307,7 +326,10 @@ ATF_TC_BODY(realpath_before_end, tc) } -ATF_TC_WITHOUT_HEAD(realpath_end); +ATF_TC(realpath_end); +ATF_TC_HEAD(realpath_end, tc) +{ +} ATF_TC_BODY(realpath_end, tc) { #define BUF &__stack.__buf @@ -325,7 +347,10 @@ ATF_TC_BODY(realpath_end, tc) } -ATF_TC_WITHOUT_HEAD(realpath_heap_before_end); +ATF_TC(realpath_heap_before_end); +ATF_TC_HEAD(realpath_heap_before_end, tc) +{ +} ATF_TC_BODY(realpath_heap_before_end, tc) { #define BUF __stack.__buf @@ -345,7 +370,10 @@ ATF_TC_BODY(realpath_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(realpath_heap_end); +ATF_TC(realpath_heap_end); +ATF_TC_HEAD(realpath_heap_end, tc) +{ +} ATF_TC_BODY(realpath_heap_end, tc) { #define BUF __stack.__buf @@ -365,7 +393,10 @@ ATF_TC_BODY(realpath_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(realpath_heap_after_end); +ATF_TC(realpath_heap_after_end); +ATF_TC_HEAD(realpath_heap_after_end, tc) +{ +} ATF_TC_BODY(realpath_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/fortify_string_test.c b/lib/libc/tests/secure/fortify_string_test.c index ae68c4b89a38..cfea261ff66f 100644 --- a/lib/libc/tests/secure/fortify_string_test.c +++ b/lib/libc/tests/secure/fortify_string_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,10 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(memcpy_before_end); +ATF_TC(memcpy_before_end); +ATF_TC_HEAD(memcpy_before_end, tc) +{ +} ATF_TC_BODY(memcpy_before_end, tc) { #define BUF &__stack.__buf @@ -181,7 +185,10 @@ ATF_TC_BODY(memcpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(memcpy_end); +ATF_TC(memcpy_end); +ATF_TC_HEAD(memcpy_end, tc) +{ +} ATF_TC_BODY(memcpy_end, tc) { #define BUF &__stack.__buf @@ -200,7 +207,10 @@ ATF_TC_BODY(memcpy_end, tc) } -ATF_TC_WITHOUT_HEAD(memcpy_heap_before_end); +ATF_TC(memcpy_heap_before_end); +ATF_TC_HEAD(memcpy_heap_before_end, tc) +{ +} ATF_TC_BODY(memcpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -221,7 +231,10 @@ ATF_TC_BODY(memcpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(memcpy_heap_end); +ATF_TC(memcpy_heap_end); +ATF_TC_HEAD(memcpy_heap_end, tc) +{ +} ATF_TC_BODY(memcpy_heap_end, tc) { #define BUF __stack.__buf @@ -242,7 +255,10 @@ ATF_TC_BODY(memcpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(memcpy_heap_after_end); +ATF_TC(memcpy_heap_after_end); +ATF_TC_HEAD(memcpy_heap_after_end, tc) +{ +} ATF_TC_BODY(memcpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -294,7 +310,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(mempcpy_before_end); +ATF_TC(mempcpy_before_end); +ATF_TC_HEAD(mempcpy_before_end, tc) +{ +} ATF_TC_BODY(mempcpy_before_end, tc) { #define BUF &__stack.__buf @@ -313,7 +332,10 @@ ATF_TC_BODY(mempcpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(mempcpy_end); +ATF_TC(mempcpy_end); +ATF_TC_HEAD(mempcpy_end, tc) +{ +} ATF_TC_BODY(mempcpy_end, tc) { #define BUF &__stack.__buf @@ -332,7 +354,10 @@ ATF_TC_BODY(mempcpy_end, tc) } -ATF_TC_WITHOUT_HEAD(mempcpy_heap_before_end); +ATF_TC(mempcpy_heap_before_end); +ATF_TC_HEAD(mempcpy_heap_before_end, tc) +{ +} ATF_TC_BODY(mempcpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -353,7 +378,10 @@ ATF_TC_BODY(mempcpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(mempcpy_heap_end); +ATF_TC(mempcpy_heap_end); +ATF_TC_HEAD(mempcpy_heap_end, tc) +{ +} ATF_TC_BODY(mempcpy_heap_end, tc) { #define BUF __stack.__buf @@ -374,7 +402,10 @@ ATF_TC_BODY(mempcpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(mempcpy_heap_after_end); +ATF_TC(mempcpy_heap_after_end); +ATF_TC_HEAD(mempcpy_heap_after_end, tc) +{ +} ATF_TC_BODY(mempcpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -426,7 +457,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(memmove_before_end); +ATF_TC(memmove_before_end); +ATF_TC_HEAD(memmove_before_end, tc) +{ +} ATF_TC_BODY(memmove_before_end, tc) { #define BUF &__stack.__buf @@ -445,7 +479,10 @@ ATF_TC_BODY(memmove_before_end, tc) } -ATF_TC_WITHOUT_HEAD(memmove_end); +ATF_TC(memmove_end); +ATF_TC_HEAD(memmove_end, tc) +{ +} ATF_TC_BODY(memmove_end, tc) { #define BUF &__stack.__buf @@ -464,7 +501,10 @@ ATF_TC_BODY(memmove_end, tc) } -ATF_TC_WITHOUT_HEAD(memmove_heap_before_end); +ATF_TC(memmove_heap_before_end); +ATF_TC_HEAD(memmove_heap_before_end, tc) +{ +} ATF_TC_BODY(memmove_heap_before_end, tc) { #define BUF __stack.__buf @@ -485,7 +525,10 @@ ATF_TC_BODY(memmove_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(memmove_heap_end); +ATF_TC(memmove_heap_end); +ATF_TC_HEAD(memmove_heap_end, tc) +{ +} ATF_TC_BODY(memmove_heap_end, tc) { #define BUF __stack.__buf @@ -506,7 +549,10 @@ ATF_TC_BODY(memmove_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(memmove_heap_after_end); +ATF_TC(memmove_heap_after_end); +ATF_TC_HEAD(memmove_heap_after_end, tc) +{ +} ATF_TC_BODY(memmove_heap_after_end, tc) { #define BUF __stack.__buf @@ -558,7 +604,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(memset_before_end); +ATF_TC(memset_before_end); +ATF_TC_HEAD(memset_before_end, tc) +{ +} ATF_TC_BODY(memset_before_end, tc) { #define BUF &__stack.__buf @@ -576,7 +625,10 @@ ATF_TC_BODY(memset_before_end, tc) } -ATF_TC_WITHOUT_HEAD(memset_end); +ATF_TC(memset_end); +ATF_TC_HEAD(memset_end, tc) +{ +} ATF_TC_BODY(memset_end, tc) { #define BUF &__stack.__buf @@ -594,7 +646,10 @@ ATF_TC_BODY(memset_end, tc) } -ATF_TC_WITHOUT_HEAD(memset_heap_before_end); +ATF_TC(memset_heap_before_end); +ATF_TC_HEAD(memset_heap_before_end, tc) +{ +} ATF_TC_BODY(memset_heap_before_end, tc) { #define BUF __stack.__buf @@ -614,7 +669,10 @@ ATF_TC_BODY(memset_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(memset_heap_end); +ATF_TC(memset_heap_end); +ATF_TC_HEAD(memset_heap_end, tc) +{ +} ATF_TC_BODY(memset_heap_end, tc) { #define BUF __stack.__buf @@ -634,7 +692,10 @@ ATF_TC_BODY(memset_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(memset_heap_after_end); +ATF_TC(memset_heap_after_end); +ATF_TC_HEAD(memset_heap_after_end, tc) +{ +} ATF_TC_BODY(memset_heap_after_end, tc) { #define BUF __stack.__buf @@ -685,7 +746,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(memset_explicit_before_end); +ATF_TC(memset_explicit_before_end); +ATF_TC_HEAD(memset_explicit_before_end, tc) +{ +} ATF_TC_BODY(memset_explicit_before_end, tc) { #define BUF &__stack.__buf @@ -703,7 +767,10 @@ ATF_TC_BODY(memset_explicit_before_end, tc) } -ATF_TC_WITHOUT_HEAD(memset_explicit_end); +ATF_TC(memset_explicit_end); +ATF_TC_HEAD(memset_explicit_end, tc) +{ +} ATF_TC_BODY(memset_explicit_end, tc) { #define BUF &__stack.__buf @@ -721,7 +788,10 @@ ATF_TC_BODY(memset_explicit_end, tc) } -ATF_TC_WITHOUT_HEAD(memset_explicit_heap_before_end); +ATF_TC(memset_explicit_heap_before_end); +ATF_TC_HEAD(memset_explicit_heap_before_end, tc) +{ +} ATF_TC_BODY(memset_explicit_heap_before_end, tc) { #define BUF __stack.__buf @@ -741,7 +811,10 @@ ATF_TC_BODY(memset_explicit_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(memset_explicit_heap_end); +ATF_TC(memset_explicit_heap_end); +ATF_TC_HEAD(memset_explicit_heap_end, tc) +{ +} ATF_TC_BODY(memset_explicit_heap_end, tc) { #define BUF __stack.__buf @@ -761,7 +834,10 @@ ATF_TC_BODY(memset_explicit_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(memset_explicit_heap_after_end); +ATF_TC(memset_explicit_heap_after_end); +ATF_TC_HEAD(memset_explicit_heap_after_end, tc) +{ +} ATF_TC_BODY(memset_explicit_heap_after_end, tc) { #define BUF __stack.__buf @@ -812,7 +888,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(stpcpy_before_end); +ATF_TC(stpcpy_before_end); +ATF_TC_HEAD(stpcpy_before_end, tc) +{ +} ATF_TC_BODY(stpcpy_before_end, tc) { #define BUF &__stack.__buf @@ -835,7 +914,10 @@ ATF_TC_BODY(stpcpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(stpcpy_end); +ATF_TC(stpcpy_end); +ATF_TC_HEAD(stpcpy_end, tc) +{ +} ATF_TC_BODY(stpcpy_end, tc) { #define BUF &__stack.__buf @@ -858,7 +940,10 @@ ATF_TC_BODY(stpcpy_end, tc) } -ATF_TC_WITHOUT_HEAD(stpcpy_heap_before_end); +ATF_TC(stpcpy_heap_before_end); +ATF_TC_HEAD(stpcpy_heap_before_end, tc) +{ +} ATF_TC_BODY(stpcpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -882,7 +967,10 @@ ATF_TC_BODY(stpcpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(stpcpy_heap_end); +ATF_TC(stpcpy_heap_end); +ATF_TC_HEAD(stpcpy_heap_end, tc) +{ +} ATF_TC_BODY(stpcpy_heap_end, tc) { #define BUF __stack.__buf @@ -906,7 +994,10 @@ ATF_TC_BODY(stpcpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(stpcpy_heap_after_end); +ATF_TC(stpcpy_heap_after_end); +ATF_TC_HEAD(stpcpy_heap_after_end, tc) +{ +} ATF_TC_BODY(stpcpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -961,7 +1052,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(stpncpy_before_end); +ATF_TC(stpncpy_before_end); +ATF_TC_HEAD(stpncpy_before_end, tc) +{ +} ATF_TC_BODY(stpncpy_before_end, tc) { #define BUF &__stack.__buf @@ -984,7 +1078,10 @@ ATF_TC_BODY(stpncpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(stpncpy_end); +ATF_TC(stpncpy_end); +ATF_TC_HEAD(stpncpy_end, tc) +{ +} ATF_TC_BODY(stpncpy_end, tc) { #define BUF &__stack.__buf @@ -1007,7 +1104,10 @@ ATF_TC_BODY(stpncpy_end, tc) } -ATF_TC_WITHOUT_HEAD(stpncpy_heap_before_end); +ATF_TC(stpncpy_heap_before_end); +ATF_TC_HEAD(stpncpy_heap_before_end, tc) +{ +} ATF_TC_BODY(stpncpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -1031,7 +1131,10 @@ ATF_TC_BODY(stpncpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(stpncpy_heap_end); +ATF_TC(stpncpy_heap_end); +ATF_TC_HEAD(stpncpy_heap_end, tc) +{ +} ATF_TC_BODY(stpncpy_heap_end, tc) { #define BUF __stack.__buf @@ -1055,7 +1158,10 @@ ATF_TC_BODY(stpncpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(stpncpy_heap_after_end); +ATF_TC(stpncpy_heap_after_end); +ATF_TC_HEAD(stpncpy_heap_after_end, tc) +{ +} ATF_TC_BODY(stpncpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -1110,7 +1216,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(strcat_before_end); +ATF_TC(strcat_before_end); +ATF_TC_HEAD(strcat_before_end, tc) +{ +} ATF_TC_BODY(strcat_before_end, tc) { #define BUF &__stack.__buf @@ -1133,7 +1242,10 @@ ATF_TC_BODY(strcat_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strcat_end); +ATF_TC(strcat_end); +ATF_TC_HEAD(strcat_end, tc) +{ +} ATF_TC_BODY(strcat_end, tc) { #define BUF &__stack.__buf @@ -1156,7 +1268,10 @@ ATF_TC_BODY(strcat_end, tc) } -ATF_TC_WITHOUT_HEAD(strcat_heap_before_end); +ATF_TC(strcat_heap_before_end); +ATF_TC_HEAD(strcat_heap_before_end, tc) +{ +} ATF_TC_BODY(strcat_heap_before_end, tc) { #define BUF __stack.__buf @@ -1180,7 +1295,10 @@ ATF_TC_BODY(strcat_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strcat_heap_end); +ATF_TC(strcat_heap_end); +ATF_TC_HEAD(strcat_heap_end, tc) +{ +} ATF_TC_BODY(strcat_heap_end, tc) { #define BUF __stack.__buf @@ -1204,7 +1322,10 @@ ATF_TC_BODY(strcat_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(strcat_heap_after_end); +ATF_TC(strcat_heap_after_end); +ATF_TC_HEAD(strcat_heap_after_end, tc) +{ +} ATF_TC_BODY(strcat_heap_after_end, tc) { #define BUF __stack.__buf @@ -1259,7 +1380,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(strlcat_before_end); +ATF_TC(strlcat_before_end); +ATF_TC_HEAD(strlcat_before_end, tc) +{ +} ATF_TC_BODY(strlcat_before_end, tc) { #define BUF &__stack.__buf @@ -1282,7 +1406,10 @@ ATF_TC_BODY(strlcat_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strlcat_end); +ATF_TC(strlcat_end); +ATF_TC_HEAD(strlcat_end, tc) +{ +} ATF_TC_BODY(strlcat_end, tc) { #define BUF &__stack.__buf @@ -1305,7 +1432,10 @@ ATF_TC_BODY(strlcat_end, tc) } -ATF_TC_WITHOUT_HEAD(strlcat_heap_before_end); +ATF_TC(strlcat_heap_before_end); +ATF_TC_HEAD(strlcat_heap_before_end, tc) +{ +} ATF_TC_BODY(strlcat_heap_before_end, tc) { #define BUF __stack.__buf @@ -1329,7 +1459,10 @@ ATF_TC_BODY(strlcat_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strlcat_heap_end); +ATF_TC(strlcat_heap_end); +ATF_TC_HEAD(strlcat_heap_end, tc) +{ +} ATF_TC_BODY(strlcat_heap_end, tc) { #define BUF __stack.__buf @@ -1353,7 +1486,10 @@ ATF_TC_BODY(strlcat_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(strlcat_heap_after_end); +ATF_TC(strlcat_heap_after_end); +ATF_TC_HEAD(strlcat_heap_after_end, tc) +{ +} ATF_TC_BODY(strlcat_heap_after_end, tc) { #define BUF __stack.__buf @@ -1408,7 +1544,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(strncat_before_end); +ATF_TC(strncat_before_end); +ATF_TC_HEAD(strncat_before_end, tc) +{ +} ATF_TC_BODY(strncat_before_end, tc) { #define BUF &__stack.__buf @@ -1431,7 +1570,10 @@ ATF_TC_BODY(strncat_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strncat_end); +ATF_TC(strncat_end); +ATF_TC_HEAD(strncat_end, tc) +{ +} ATF_TC_BODY(strncat_end, tc) { #define BUF &__stack.__buf @@ -1454,7 +1596,10 @@ ATF_TC_BODY(strncat_end, tc) } -ATF_TC_WITHOUT_HEAD(strncat_heap_before_end); +ATF_TC(strncat_heap_before_end); +ATF_TC_HEAD(strncat_heap_before_end, tc) +{ +} ATF_TC_BODY(strncat_heap_before_end, tc) { #define BUF __stack.__buf @@ -1478,7 +1623,10 @@ ATF_TC_BODY(strncat_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strncat_heap_end); +ATF_TC(strncat_heap_end); +ATF_TC_HEAD(strncat_heap_end, tc) +{ +} ATF_TC_BODY(strncat_heap_end, tc) { #define BUF __stack.__buf @@ -1502,7 +1650,10 @@ ATF_TC_BODY(strncat_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(strncat_heap_after_end); +ATF_TC(strncat_heap_after_end); +ATF_TC_HEAD(strncat_heap_after_end, tc) +{ +} ATF_TC_BODY(strncat_heap_after_end, tc) { #define BUF __stack.__buf @@ -1557,7 +1708,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(strcpy_before_end); +ATF_TC(strcpy_before_end); +ATF_TC_HEAD(strcpy_before_end, tc) +{ +} ATF_TC_BODY(strcpy_before_end, tc) { #define BUF &__stack.__buf @@ -1580,7 +1734,10 @@ ATF_TC_BODY(strcpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strcpy_end); +ATF_TC(strcpy_end); +ATF_TC_HEAD(strcpy_end, tc) +{ +} ATF_TC_BODY(strcpy_end, tc) { #define BUF &__stack.__buf @@ -1603,7 +1760,10 @@ ATF_TC_BODY(strcpy_end, tc) } -ATF_TC_WITHOUT_HEAD(strcpy_heap_before_end); +ATF_TC(strcpy_heap_before_end); +ATF_TC_HEAD(strcpy_heap_before_end, tc) +{ +} ATF_TC_BODY(strcpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -1627,7 +1787,10 @@ ATF_TC_BODY(strcpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strcpy_heap_end); +ATF_TC(strcpy_heap_end); +ATF_TC_HEAD(strcpy_heap_end, tc) +{ +} ATF_TC_BODY(strcpy_heap_end, tc) { #define BUF __stack.__buf @@ -1651,7 +1814,10 @@ ATF_TC_BODY(strcpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(strcpy_heap_after_end); +ATF_TC(strcpy_heap_after_end); +ATF_TC_HEAD(strcpy_heap_after_end, tc) +{ +} ATF_TC_BODY(strcpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -1706,7 +1872,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(strlcpy_before_end); +ATF_TC(strlcpy_before_end); +ATF_TC_HEAD(strlcpy_before_end, tc) +{ +} ATF_TC_BODY(strlcpy_before_end, tc) { #define BUF &__stack.__buf @@ -1729,7 +1898,10 @@ ATF_TC_BODY(strlcpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strlcpy_end); +ATF_TC(strlcpy_end); +ATF_TC_HEAD(strlcpy_end, tc) +{ +} ATF_TC_BODY(strlcpy_end, tc) { #define BUF &__stack.__buf @@ -1752,7 +1924,10 @@ ATF_TC_BODY(strlcpy_end, tc) } -ATF_TC_WITHOUT_HEAD(strlcpy_heap_before_end); +ATF_TC(strlcpy_heap_before_end); +ATF_TC_HEAD(strlcpy_heap_before_end, tc) +{ +} ATF_TC_BODY(strlcpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -1776,7 +1951,10 @@ ATF_TC_BODY(strlcpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strlcpy_heap_end); +ATF_TC(strlcpy_heap_end); +ATF_TC_HEAD(strlcpy_heap_end, tc) +{ +} ATF_TC_BODY(strlcpy_heap_end, tc) { #define BUF __stack.__buf @@ -1800,7 +1978,10 @@ ATF_TC_BODY(strlcpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(strlcpy_heap_after_end); +ATF_TC(strlcpy_heap_after_end); +ATF_TC_HEAD(strlcpy_heap_after_end, tc) +{ +} ATF_TC_BODY(strlcpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -1855,7 +2036,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(strncpy_before_end); +ATF_TC(strncpy_before_end); +ATF_TC_HEAD(strncpy_before_end, tc) +{ +} ATF_TC_BODY(strncpy_before_end, tc) { #define BUF &__stack.__buf @@ -1878,7 +2062,10 @@ ATF_TC_BODY(strncpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strncpy_end); +ATF_TC(strncpy_end); +ATF_TC_HEAD(strncpy_end, tc) +{ +} ATF_TC_BODY(strncpy_end, tc) { #define BUF &__stack.__buf @@ -1901,7 +2088,10 @@ ATF_TC_BODY(strncpy_end, tc) } -ATF_TC_WITHOUT_HEAD(strncpy_heap_before_end); +ATF_TC(strncpy_heap_before_end); +ATF_TC_HEAD(strncpy_heap_before_end, tc) +{ +} ATF_TC_BODY(strncpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -1925,7 +2115,10 @@ ATF_TC_BODY(strncpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(strncpy_heap_end); +ATF_TC(strncpy_heap_end); +ATF_TC_HEAD(strncpy_heap_end, tc) +{ +} ATF_TC_BODY(strncpy_heap_end, tc) { #define BUF __stack.__buf @@ -1949,7 +2142,10 @@ ATF_TC_BODY(strncpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(strncpy_heap_after_end); +ATF_TC(strncpy_heap_after_end); +ATF_TC_HEAD(strncpy_heap_after_end, tc) +{ +} ATF_TC_BODY(strncpy_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/fortify_strings_test.c b/lib/libc/tests/secure/fortify_strings_test.c index 69093bec04dd..9f7d37a2480e 100644 --- a/lib/libc/tests/secure/fortify_strings_test.c +++ b/lib/libc/tests/secure/fortify_strings_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,10 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(bcopy_before_end); +ATF_TC(bcopy_before_end); +ATF_TC_HEAD(bcopy_before_end, tc) +{ +} ATF_TC_BODY(bcopy_before_end, tc) { #define BUF &__stack.__buf @@ -181,7 +185,10 @@ ATF_TC_BODY(bcopy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(bcopy_end); +ATF_TC(bcopy_end); +ATF_TC_HEAD(bcopy_end, tc) +{ +} ATF_TC_BODY(bcopy_end, tc) { #define BUF &__stack.__buf @@ -200,7 +207,10 @@ ATF_TC_BODY(bcopy_end, tc) } -ATF_TC_WITHOUT_HEAD(bcopy_heap_before_end); +ATF_TC(bcopy_heap_before_end); +ATF_TC_HEAD(bcopy_heap_before_end, tc) +{ +} ATF_TC_BODY(bcopy_heap_before_end, tc) { #define BUF __stack.__buf @@ -221,7 +231,10 @@ ATF_TC_BODY(bcopy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(bcopy_heap_end); +ATF_TC(bcopy_heap_end); +ATF_TC_HEAD(bcopy_heap_end, tc) +{ +} ATF_TC_BODY(bcopy_heap_end, tc) { #define BUF __stack.__buf @@ -242,7 +255,10 @@ ATF_TC_BODY(bcopy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(bcopy_heap_after_end); +ATF_TC(bcopy_heap_after_end); +ATF_TC_HEAD(bcopy_heap_after_end, tc) +{ +} ATF_TC_BODY(bcopy_heap_after_end, tc) { #define BUF __stack.__buf @@ -294,7 +310,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(bzero_before_end); +ATF_TC(bzero_before_end); +ATF_TC_HEAD(bzero_before_end, tc) +{ +} ATF_TC_BODY(bzero_before_end, tc) { #define BUF &__stack.__buf @@ -312,7 +331,10 @@ ATF_TC_BODY(bzero_before_end, tc) } -ATF_TC_WITHOUT_HEAD(bzero_end); +ATF_TC(bzero_end); +ATF_TC_HEAD(bzero_end, tc) +{ +} ATF_TC_BODY(bzero_end, tc) { #define BUF &__stack.__buf @@ -330,7 +352,10 @@ ATF_TC_BODY(bzero_end, tc) } -ATF_TC_WITHOUT_HEAD(bzero_heap_before_end); +ATF_TC(bzero_heap_before_end); +ATF_TC_HEAD(bzero_heap_before_end, tc) +{ +} ATF_TC_BODY(bzero_heap_before_end, tc) { #define BUF __stack.__buf @@ -350,7 +375,10 @@ ATF_TC_BODY(bzero_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(bzero_heap_end); +ATF_TC(bzero_heap_end); +ATF_TC_HEAD(bzero_heap_end, tc) +{ +} ATF_TC_BODY(bzero_heap_end, tc) { #define BUF __stack.__buf @@ -370,7 +398,10 @@ ATF_TC_BODY(bzero_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(bzero_heap_after_end); +ATF_TC(bzero_heap_after_end); +ATF_TC_HEAD(bzero_heap_after_end, tc) +{ +} ATF_TC_BODY(bzero_heap_after_end, tc) { #define BUF __stack.__buf @@ -421,7 +452,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(explicit_bzero_before_end); +ATF_TC(explicit_bzero_before_end); +ATF_TC_HEAD(explicit_bzero_before_end, tc) +{ +} ATF_TC_BODY(explicit_bzero_before_end, tc) { #define BUF &__stack.__buf @@ -439,7 +473,10 @@ ATF_TC_BODY(explicit_bzero_before_end, tc) } -ATF_TC_WITHOUT_HEAD(explicit_bzero_end); +ATF_TC(explicit_bzero_end); +ATF_TC_HEAD(explicit_bzero_end, tc) +{ +} ATF_TC_BODY(explicit_bzero_end, tc) { #define BUF &__stack.__buf @@ -457,7 +494,10 @@ ATF_TC_BODY(explicit_bzero_end, tc) } -ATF_TC_WITHOUT_HEAD(explicit_bzero_heap_before_end); +ATF_TC(explicit_bzero_heap_before_end); +ATF_TC_HEAD(explicit_bzero_heap_before_end, tc) +{ +} ATF_TC_BODY(explicit_bzero_heap_before_end, tc) { #define BUF __stack.__buf @@ -477,7 +517,10 @@ ATF_TC_BODY(explicit_bzero_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(explicit_bzero_heap_end); +ATF_TC(explicit_bzero_heap_end); +ATF_TC_HEAD(explicit_bzero_heap_end, tc) +{ +} ATF_TC_BODY(explicit_bzero_heap_end, tc) { #define BUF __stack.__buf @@ -497,7 +540,10 @@ ATF_TC_BODY(explicit_bzero_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(explicit_bzero_heap_after_end); +ATF_TC(explicit_bzero_heap_after_end); +ATF_TC_HEAD(explicit_bzero_heap_after_end, tc) +{ +} ATF_TC_BODY(explicit_bzero_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/fortify_uio_test.c b/lib/libc/tests/secure/fortify_uio_test.c index 4a2637d75353..46b46ed2f7df 100644 --- a/lib/libc/tests/secure/fortify_uio_test.c +++ b/lib/libc/tests/secure/fortify_uio_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,10 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(readv_before_end); +ATF_TC(readv_before_end); +ATF_TC_HEAD(readv_before_end, tc) +{ +} ATF_TC_BODY(readv_before_end, tc) { #define BUF &__stack.__buf @@ -180,7 +184,10 @@ ATF_TC_BODY(readv_before_end, tc) } -ATF_TC_WITHOUT_HEAD(readv_end); +ATF_TC(readv_end); +ATF_TC_HEAD(readv_end, tc) +{ +} ATF_TC_BODY(readv_end, tc) { #define BUF &__stack.__buf @@ -198,7 +205,10 @@ ATF_TC_BODY(readv_end, tc) } -ATF_TC_WITHOUT_HEAD(readv_after_end); +ATF_TC(readv_after_end); +ATF_TC_HEAD(readv_after_end, tc) +{ +} ATF_TC_BODY(readv_after_end, tc) { #define BUF &__stack.__buf @@ -247,7 +257,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(readv_heap_before_end); +ATF_TC(readv_heap_before_end); +ATF_TC_HEAD(readv_heap_before_end, tc) +{ +} ATF_TC_BODY(readv_heap_before_end, tc) { #define BUF __stack.__buf @@ -267,7 +280,10 @@ ATF_TC_BODY(readv_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(readv_heap_end); +ATF_TC(readv_heap_end); +ATF_TC_HEAD(readv_heap_end, tc) +{ +} ATF_TC_BODY(readv_heap_end, tc) { #define BUF __stack.__buf @@ -287,7 +303,10 @@ ATF_TC_BODY(readv_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(readv_heap_after_end); +ATF_TC(readv_heap_after_end); +ATF_TC_HEAD(readv_heap_after_end, tc) +{ +} ATF_TC_BODY(readv_heap_after_end, tc) { #define BUF __stack.__buf @@ -338,7 +357,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(readv_iov_before_end); +ATF_TC(readv_iov_before_end); +ATF_TC_HEAD(readv_iov_before_end, tc) +{ +} ATF_TC_BODY(readv_iov_before_end, tc) { #define BUF &__stack.__buf @@ -362,7 +384,10 @@ ATF_TC_BODY(readv_iov_before_end, tc) } -ATF_TC_WITHOUT_HEAD(readv_iov_end); +ATF_TC(readv_iov_end); +ATF_TC_HEAD(readv_iov_end, tc) +{ +} ATF_TC_BODY(readv_iov_end, tc) { #define BUF &__stack.__buf @@ -386,7 +411,10 @@ ATF_TC_BODY(readv_iov_end, tc) } -ATF_TC_WITHOUT_HEAD(readv_iov_heap_before_end); +ATF_TC(readv_iov_heap_before_end); +ATF_TC_HEAD(readv_iov_heap_before_end, tc) +{ +} ATF_TC_BODY(readv_iov_heap_before_end, tc) { #define BUF __stack.__buf @@ -411,7 +439,10 @@ ATF_TC_BODY(readv_iov_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(readv_iov_heap_end); +ATF_TC(readv_iov_heap_end); +ATF_TC_HEAD(readv_iov_heap_end, tc) +{ +} ATF_TC_BODY(readv_iov_heap_end, tc) { #define BUF __stack.__buf @@ -436,7 +467,10 @@ ATF_TC_BODY(readv_iov_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(readv_iov_heap_after_end); +ATF_TC(readv_iov_heap_after_end); +ATF_TC_HEAD(readv_iov_heap_after_end, tc) +{ +} ATF_TC_BODY(readv_iov_heap_after_end, tc) { #define BUF __stack.__buf @@ -492,7 +526,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(preadv_before_end); +ATF_TC(preadv_before_end); +ATF_TC_HEAD(preadv_before_end, tc) +{ +} ATF_TC_BODY(preadv_before_end, tc) { #define BUF &__stack.__buf @@ -510,7 +547,10 @@ ATF_TC_BODY(preadv_before_end, tc) } -ATF_TC_WITHOUT_HEAD(preadv_end); +ATF_TC(preadv_end); +ATF_TC_HEAD(preadv_end, tc) +{ +} ATF_TC_BODY(preadv_end, tc) { #define BUF &__stack.__buf @@ -528,7 +568,10 @@ ATF_TC_BODY(preadv_end, tc) } -ATF_TC_WITHOUT_HEAD(preadv_after_end); +ATF_TC(preadv_after_end); +ATF_TC_HEAD(preadv_after_end, tc) +{ +} ATF_TC_BODY(preadv_after_end, tc) { #define BUF &__stack.__buf @@ -577,7 +620,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(preadv_heap_before_end); +ATF_TC(preadv_heap_before_end); +ATF_TC_HEAD(preadv_heap_before_end, tc) +{ +} ATF_TC_BODY(preadv_heap_before_end, tc) { #define BUF __stack.__buf @@ -597,7 +643,10 @@ ATF_TC_BODY(preadv_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(preadv_heap_end); +ATF_TC(preadv_heap_end); +ATF_TC_HEAD(preadv_heap_end, tc) +{ +} ATF_TC_BODY(preadv_heap_end, tc) { #define BUF __stack.__buf @@ -617,7 +666,10 @@ ATF_TC_BODY(preadv_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(preadv_heap_after_end); +ATF_TC(preadv_heap_after_end); +ATF_TC_HEAD(preadv_heap_after_end, tc) +{ +} ATF_TC_BODY(preadv_heap_after_end, tc) { #define BUF __stack.__buf @@ -668,7 +720,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(preadv_iov_before_end); +ATF_TC(preadv_iov_before_end); +ATF_TC_HEAD(preadv_iov_before_end, tc) +{ +} ATF_TC_BODY(preadv_iov_before_end, tc) { #define BUF &__stack.__buf @@ -692,7 +747,10 @@ ATF_TC_BODY(preadv_iov_before_end, tc) } -ATF_TC_WITHOUT_HEAD(preadv_iov_end); +ATF_TC(preadv_iov_end); +ATF_TC_HEAD(preadv_iov_end, tc) +{ +} ATF_TC_BODY(preadv_iov_end, tc) { #define BUF &__stack.__buf @@ -716,7 +774,10 @@ ATF_TC_BODY(preadv_iov_end, tc) } -ATF_TC_WITHOUT_HEAD(preadv_iov_heap_before_end); +ATF_TC(preadv_iov_heap_before_end); +ATF_TC_HEAD(preadv_iov_heap_before_end, tc) +{ +} ATF_TC_BODY(preadv_iov_heap_before_end, tc) { #define BUF __stack.__buf @@ -741,7 +802,10 @@ ATF_TC_BODY(preadv_iov_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(preadv_iov_heap_end); +ATF_TC(preadv_iov_heap_end); +ATF_TC_HEAD(preadv_iov_heap_end, tc) +{ +} ATF_TC_BODY(preadv_iov_heap_end, tc) { #define BUF __stack.__buf @@ -766,7 +830,10 @@ ATF_TC_BODY(preadv_iov_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(preadv_iov_heap_after_end); +ATF_TC(preadv_iov_heap_after_end); +ATF_TC_HEAD(preadv_iov_heap_after_end, tc) +{ +} ATF_TC_BODY(preadv_iov_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/fortify_unistd_test.c b/lib/libc/tests/secure/fortify_unistd_test.c index e467ba849bd4..b12ef2bbb8ea 100644 --- a/lib/libc/tests/secure/fortify_unistd_test.c +++ b/lib/libc/tests/secure/fortify_unistd_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,31 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(getcwd_before_end); +#define JAIL_HOSTNAME "host.example.com" +#define JAIL_DOMAINNAME "example.com" +static void +dhost_jail(void) +{ + struct iovec iov[4]; + int jid; + + iov[0].iov_base = __DECONST(char *, "host.hostname"); + iov[0].iov_len = sizeof("host.hostname"); + iov[1].iov_base = __DECONST(char *, JAIL_HOSTNAME); + iov[1].iov_len = sizeof(JAIL_HOSTNAME); + iov[2].iov_base = __DECONST(char *, "host.domainname"); + iov[2].iov_len = sizeof("host.domainname"); + iov[3].iov_base = __DECONST(char *, JAIL_DOMAINNAME); + iov[3].iov_len = sizeof(JAIL_DOMAINNAME); + + jid = jail_set(iov, nitems(iov), JAIL_CREATE | JAIL_ATTACH); + ATF_REQUIRE_MSG(jid > 0, "Jail creation failed: %s", strerror(errno)); +} + +ATF_TC(getcwd_before_end); +ATF_TC_HEAD(getcwd_before_end, tc) +{ +} ATF_TC_BODY(getcwd_before_end, tc) { #define BUF &__stack.__buf @@ -180,7 +205,10 @@ ATF_TC_BODY(getcwd_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getcwd_end); +ATF_TC(getcwd_end); +ATF_TC_HEAD(getcwd_end, tc) +{ +} ATF_TC_BODY(getcwd_end, tc) { #define BUF &__stack.__buf @@ -198,7 +226,10 @@ ATF_TC_BODY(getcwd_end, tc) } -ATF_TC_WITHOUT_HEAD(getcwd_heap_before_end); +ATF_TC(getcwd_heap_before_end); +ATF_TC_HEAD(getcwd_heap_before_end, tc) +{ +} ATF_TC_BODY(getcwd_heap_before_end, tc) { #define BUF __stack.__buf @@ -218,7 +249,10 @@ ATF_TC_BODY(getcwd_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getcwd_heap_end); +ATF_TC(getcwd_heap_end); +ATF_TC_HEAD(getcwd_heap_end, tc) +{ +} ATF_TC_BODY(getcwd_heap_end, tc) { #define BUF __stack.__buf @@ -238,7 +272,10 @@ ATF_TC_BODY(getcwd_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(getcwd_heap_after_end); +ATF_TC(getcwd_heap_after_end); +ATF_TC_HEAD(getcwd_heap_after_end, tc) +{ +} ATF_TC_BODY(getcwd_heap_after_end, tc) { #define BUF __stack.__buf @@ -289,7 +326,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(getgrouplist_before_end); +ATF_TC(getgrouplist_before_end); +ATF_TC_HEAD(getgrouplist_before_end, tc) +{ +} ATF_TC_BODY(getgrouplist_before_end, tc) { #define BUF &__stack.__buf @@ -308,7 +348,10 @@ ATF_TC_BODY(getgrouplist_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getgrouplist_end); +ATF_TC(getgrouplist_end); +ATF_TC_HEAD(getgrouplist_end, tc) +{ +} ATF_TC_BODY(getgrouplist_end, tc) { #define BUF &__stack.__buf @@ -327,7 +370,10 @@ ATF_TC_BODY(getgrouplist_end, tc) } -ATF_TC_WITHOUT_HEAD(getgrouplist_heap_before_end); +ATF_TC(getgrouplist_heap_before_end); +ATF_TC_HEAD(getgrouplist_heap_before_end, tc) +{ +} ATF_TC_BODY(getgrouplist_heap_before_end, tc) { #define BUF __stack.__buf @@ -348,7 +394,10 @@ ATF_TC_BODY(getgrouplist_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getgrouplist_heap_end); +ATF_TC(getgrouplist_heap_end); +ATF_TC_HEAD(getgrouplist_heap_end, tc) +{ +} ATF_TC_BODY(getgrouplist_heap_end, tc) { #define BUF __stack.__buf @@ -369,7 +418,10 @@ ATF_TC_BODY(getgrouplist_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(getgrouplist_heap_after_end); +ATF_TC(getgrouplist_heap_after_end); +ATF_TC_HEAD(getgrouplist_heap_after_end, tc) +{ +} ATF_TC_BODY(getgrouplist_heap_after_end, tc) { #define BUF __stack.__buf @@ -421,7 +473,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(getgroups_before_end); +ATF_TC(getgroups_before_end); +ATF_TC_HEAD(getgroups_before_end, tc) +{ +} ATF_TC_BODY(getgroups_before_end, tc) { #define BUF &__stack.__buf @@ -439,7 +494,10 @@ ATF_TC_BODY(getgroups_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getgroups_end); +ATF_TC(getgroups_end); +ATF_TC_HEAD(getgroups_end, tc) +{ +} ATF_TC_BODY(getgroups_end, tc) { #define BUF &__stack.__buf @@ -457,7 +515,10 @@ ATF_TC_BODY(getgroups_end, tc) } -ATF_TC_WITHOUT_HEAD(getgroups_heap_before_end); +ATF_TC(getgroups_heap_before_end); +ATF_TC_HEAD(getgroups_heap_before_end, tc) +{ +} ATF_TC_BODY(getgroups_heap_before_end, tc) { #define BUF __stack.__buf @@ -477,7 +538,10 @@ ATF_TC_BODY(getgroups_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getgroups_heap_end); +ATF_TC(getgroups_heap_end); +ATF_TC_HEAD(getgroups_heap_end, tc) +{ +} ATF_TC_BODY(getgroups_heap_end, tc) { #define BUF __stack.__buf @@ -497,7 +561,10 @@ ATF_TC_BODY(getgroups_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(getgroups_heap_after_end); +ATF_TC(getgroups_heap_after_end); +ATF_TC_HEAD(getgroups_heap_after_end, tc) +{ +} ATF_TC_BODY(getgroups_heap_after_end, tc) { #define BUF __stack.__buf @@ -548,7 +615,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(getloginclass_before_end); +ATF_TC(getloginclass_before_end); +ATF_TC_HEAD(getloginclass_before_end, tc) +{ +} ATF_TC_BODY(getloginclass_before_end, tc) { #define BUF &__stack.__buf @@ -566,7 +636,10 @@ ATF_TC_BODY(getloginclass_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getloginclass_end); +ATF_TC(getloginclass_end); +ATF_TC_HEAD(getloginclass_end, tc) +{ +} ATF_TC_BODY(getloginclass_end, tc) { #define BUF &__stack.__buf @@ -584,7 +657,10 @@ ATF_TC_BODY(getloginclass_end, tc) } -ATF_TC_WITHOUT_HEAD(getloginclass_heap_before_end); +ATF_TC(getloginclass_heap_before_end); +ATF_TC_HEAD(getloginclass_heap_before_end, tc) +{ +} ATF_TC_BODY(getloginclass_heap_before_end, tc) { #define BUF __stack.__buf @@ -604,7 +680,10 @@ ATF_TC_BODY(getloginclass_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getloginclass_heap_end); +ATF_TC(getloginclass_heap_end); +ATF_TC_HEAD(getloginclass_heap_end, tc) +{ +} ATF_TC_BODY(getloginclass_heap_end, tc) { #define BUF __stack.__buf @@ -624,7 +703,10 @@ ATF_TC_BODY(getloginclass_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(getloginclass_heap_after_end); +ATF_TC(getloginclass_heap_after_end); +ATF_TC_HEAD(getloginclass_heap_after_end, tc) +{ +} ATF_TC_BODY(getloginclass_heap_after_end, tc) { #define BUF __stack.__buf @@ -675,7 +757,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(pread_before_end); +ATF_TC(pread_before_end); +ATF_TC_HEAD(pread_before_end, tc) +{ +} ATF_TC_BODY(pread_before_end, tc) { #define BUF &__stack.__buf @@ -696,7 +781,10 @@ ATF_TC_BODY(pread_before_end, tc) } -ATF_TC_WITHOUT_HEAD(pread_end); +ATF_TC(pread_end); +ATF_TC_HEAD(pread_end, tc) +{ +} ATF_TC_BODY(pread_end, tc) { #define BUF &__stack.__buf @@ -717,7 +805,10 @@ ATF_TC_BODY(pread_end, tc) } -ATF_TC_WITHOUT_HEAD(pread_heap_before_end); +ATF_TC(pread_heap_before_end); +ATF_TC_HEAD(pread_heap_before_end, tc) +{ +} ATF_TC_BODY(pread_heap_before_end, tc) { #define BUF __stack.__buf @@ -739,7 +830,10 @@ ATF_TC_BODY(pread_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(pread_heap_end); +ATF_TC(pread_heap_end); +ATF_TC_HEAD(pread_heap_end, tc) +{ +} ATF_TC_BODY(pread_heap_end, tc) { #define BUF __stack.__buf @@ -761,7 +855,10 @@ ATF_TC_BODY(pread_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(pread_heap_after_end); +ATF_TC(pread_heap_after_end); +ATF_TC_HEAD(pread_heap_after_end, tc) +{ +} ATF_TC_BODY(pread_heap_after_end, tc) { #define BUF __stack.__buf @@ -814,7 +911,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(read_before_end); +ATF_TC(read_before_end); +ATF_TC_HEAD(read_before_end, tc) +{ +} ATF_TC_BODY(read_before_end, tc) { #define BUF &__stack.__buf @@ -835,7 +935,10 @@ ATF_TC_BODY(read_before_end, tc) } -ATF_TC_WITHOUT_HEAD(read_end); +ATF_TC(read_end); +ATF_TC_HEAD(read_end, tc) +{ +} ATF_TC_BODY(read_end, tc) { #define BUF &__stack.__buf @@ -856,7 +959,10 @@ ATF_TC_BODY(read_end, tc) } -ATF_TC_WITHOUT_HEAD(read_heap_before_end); +ATF_TC(read_heap_before_end); +ATF_TC_HEAD(read_heap_before_end, tc) +{ +} ATF_TC_BODY(read_heap_before_end, tc) { #define BUF __stack.__buf @@ -878,7 +984,10 @@ ATF_TC_BODY(read_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(read_heap_end); +ATF_TC(read_heap_end); +ATF_TC_HEAD(read_heap_end, tc) +{ +} ATF_TC_BODY(read_heap_end, tc) { #define BUF __stack.__buf @@ -900,7 +1009,10 @@ ATF_TC_BODY(read_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(read_heap_after_end); +ATF_TC(read_heap_after_end); +ATF_TC_HEAD(read_heap_after_end, tc) +{ +} ATF_TC_BODY(read_heap_after_end, tc) { #define BUF __stack.__buf @@ -953,7 +1065,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(readlink_before_end); +ATF_TC(readlink_before_end); +ATF_TC_HEAD(readlink_before_end, tc) +{ +} ATF_TC_BODY(readlink_before_end, tc) { #define BUF &__stack.__buf @@ -974,7 +1089,10 @@ ATF_TC_BODY(readlink_before_end, tc) } -ATF_TC_WITHOUT_HEAD(readlink_end); +ATF_TC(readlink_end); +ATF_TC_HEAD(readlink_end, tc) +{ +} ATF_TC_BODY(readlink_end, tc) { #define BUF &__stack.__buf @@ -995,7 +1113,10 @@ ATF_TC_BODY(readlink_end, tc) } -ATF_TC_WITHOUT_HEAD(readlink_heap_before_end); +ATF_TC(readlink_heap_before_end); +ATF_TC_HEAD(readlink_heap_before_end, tc) +{ +} ATF_TC_BODY(readlink_heap_before_end, tc) { #define BUF __stack.__buf @@ -1017,7 +1138,10 @@ ATF_TC_BODY(readlink_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(readlink_heap_end); +ATF_TC(readlink_heap_end); +ATF_TC_HEAD(readlink_heap_end, tc) +{ +} ATF_TC_BODY(readlink_heap_end, tc) { #define BUF __stack.__buf @@ -1039,7 +1163,10 @@ ATF_TC_BODY(readlink_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(readlink_heap_after_end); +ATF_TC(readlink_heap_after_end); +ATF_TC_HEAD(readlink_heap_after_end, tc) +{ +} ATF_TC_BODY(readlink_heap_after_end, tc) { #define BUF __stack.__buf @@ -1092,7 +1219,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(readlinkat_before_end); +ATF_TC(readlinkat_before_end); +ATF_TC_HEAD(readlinkat_before_end, tc) +{ +} ATF_TC_BODY(readlinkat_before_end, tc) { #define BUF &__stack.__buf @@ -1113,7 +1243,10 @@ ATF_TC_BODY(readlinkat_before_end, tc) } -ATF_TC_WITHOUT_HEAD(readlinkat_end); +ATF_TC(readlinkat_end); +ATF_TC_HEAD(readlinkat_end, tc) +{ +} ATF_TC_BODY(readlinkat_end, tc) { #define BUF &__stack.__buf @@ -1134,7 +1267,10 @@ ATF_TC_BODY(readlinkat_end, tc) } -ATF_TC_WITHOUT_HEAD(readlinkat_heap_before_end); +ATF_TC(readlinkat_heap_before_end); +ATF_TC_HEAD(readlinkat_heap_before_end, tc) +{ +} ATF_TC_BODY(readlinkat_heap_before_end, tc) { #define BUF __stack.__buf @@ -1156,7 +1292,10 @@ ATF_TC_BODY(readlinkat_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(readlinkat_heap_end); +ATF_TC(readlinkat_heap_end); +ATF_TC_HEAD(readlinkat_heap_end, tc) +{ +} ATF_TC_BODY(readlinkat_heap_end, tc) { #define BUF __stack.__buf @@ -1178,7 +1317,10 @@ ATF_TC_BODY(readlinkat_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(readlinkat_heap_after_end); +ATF_TC(readlinkat_heap_after_end); +ATF_TC_HEAD(readlinkat_heap_after_end, tc) +{ +} ATF_TC_BODY(readlinkat_heap_after_end, tc) { #define BUF __stack.__buf @@ -1231,53 +1373,57 @@ monitor: } -ATF_TC_WITHOUT_HEAD(getdomainname_before_end); +ATF_TC(getdomainname_before_end); +ATF_TC_HEAD(getdomainname_before_end, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(getdomainname_before_end, tc) { #define BUF &__stack.__buf struct { uint8_t padding_l; - unsigned char __buf[4]; + unsigned char __buf[12]; uint8_t padding_r; } __stack; const size_t __bufsz __unused = sizeof(__stack.__buf); - const size_t __len = 4 - 1; + const size_t __len = 12 - 1; const size_t __idx __unused = __len - 1; - char sysdomain[256]; - - (void)getdomainname(sysdomain, __len); - if (strlen(sysdomain) <= __len) - atf_tc_skip("domain name too short for testing"); + dhost_jail(); getdomainname(__stack.__buf, __len); #undef BUF } -ATF_TC_WITHOUT_HEAD(getdomainname_end); +ATF_TC(getdomainname_end); +ATF_TC_HEAD(getdomainname_end, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(getdomainname_end, tc) { #define BUF &__stack.__buf struct { uint8_t padding_l; - unsigned char __buf[4]; + unsigned char __buf[12]; uint8_t padding_r; } __stack; const size_t __bufsz __unused = sizeof(__stack.__buf); - const size_t __len = 4; + const size_t __len = 12; const size_t __idx __unused = __len - 1; - char sysdomain[256]; - - (void)getdomainname(sysdomain, __len); - if (strlen(sysdomain) <= __len) - atf_tc_skip("domain name too short for testing"); + dhost_jail(); getdomainname(__stack.__buf, __len); #undef BUF } -ATF_TC_WITHOUT_HEAD(getdomainname_heap_before_end); +ATF_TC(getdomainname_heap_before_end); +ATF_TC_HEAD(getdomainname_heap_before_end, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(getdomainname_heap_before_end, tc) { #define BUF __stack.__buf @@ -1286,15 +1432,11 @@ ATF_TC_BODY(getdomainname_heap_before_end, tc) unsigned char * __buf; uint8_t padding_r; } __stack; - const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4); - const size_t __len = 4 - 1; + const size_t __bufsz __unused = sizeof(*__stack.__buf) * (12); + const size_t __len = 12 - 1; const size_t __idx __unused = __len - 1; - char sysdomain[256]; - - (void)getdomainname(sysdomain, __len); - if (strlen(sysdomain) <= __len) - atf_tc_skip("domain name too short for testing"); + dhost_jail(); __stack.__buf = malloc(__bufsz); getdomainname(__stack.__buf, __len); @@ -1302,7 +1444,11 @@ ATF_TC_BODY(getdomainname_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getdomainname_heap_end); +ATF_TC(getdomainname_heap_end); +ATF_TC_HEAD(getdomainname_heap_end, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(getdomainname_heap_end, tc) { #define BUF __stack.__buf @@ -1311,15 +1457,11 @@ ATF_TC_BODY(getdomainname_heap_end, tc) unsigned char * __buf; uint8_t padding_r; } __stack; - const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4); - const size_t __len = 4; + const size_t __bufsz __unused = sizeof(*__stack.__buf) * (12); + const size_t __len = 12; const size_t __idx __unused = __len - 1; - char sysdomain[256]; - - (void)getdomainname(sysdomain, __len); - if (strlen(sysdomain) <= __len) - atf_tc_skip("domain name too short for testing"); + dhost_jail(); __stack.__buf = malloc(__bufsz); getdomainname(__stack.__buf, __len); @@ -1327,7 +1469,11 @@ ATF_TC_BODY(getdomainname_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(getdomainname_heap_after_end); +ATF_TC(getdomainname_heap_after_end); +ATF_TC_HEAD(getdomainname_heap_after_end, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(getdomainname_heap_after_end, tc) { #define BUF __stack.__buf @@ -1336,17 +1482,13 @@ ATF_TC_BODY(getdomainname_heap_after_end, tc) unsigned char * __buf; uint8_t padding_r; } __stack; - const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4); - const size_t __len = 4 + 1; + const size_t __bufsz __unused = sizeof(*__stack.__buf) * (12); + const size_t __len = 12 + 1; const size_t __idx __unused = __len - 1; pid_t __child; int __status; - char sysdomain[256]; - - (void)getdomainname(sysdomain, __len); - if (strlen(sysdomain) <= __len) - atf_tc_skip("domain name too short for testing"); + dhost_jail(); __child = fork(); ATF_REQUIRE(__child >= 0); if (__child > 0) @@ -1383,7 +1525,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(getentropy_before_end); +ATF_TC(getentropy_before_end); +ATF_TC_HEAD(getentropy_before_end, tc) +{ +} ATF_TC_BODY(getentropy_before_end, tc) { #define BUF &__stack.__buf @@ -1401,7 +1546,10 @@ ATF_TC_BODY(getentropy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getentropy_end); +ATF_TC(getentropy_end); +ATF_TC_HEAD(getentropy_end, tc) +{ +} ATF_TC_BODY(getentropy_end, tc) { #define BUF &__stack.__buf @@ -1419,7 +1567,10 @@ ATF_TC_BODY(getentropy_end, tc) } -ATF_TC_WITHOUT_HEAD(getentropy_heap_before_end); +ATF_TC(getentropy_heap_before_end); +ATF_TC_HEAD(getentropy_heap_before_end, tc) +{ +} ATF_TC_BODY(getentropy_heap_before_end, tc) { #define BUF __stack.__buf @@ -1439,7 +1590,10 @@ ATF_TC_BODY(getentropy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getentropy_heap_end); +ATF_TC(getentropy_heap_end); +ATF_TC_HEAD(getentropy_heap_end, tc) +{ +} ATF_TC_BODY(getentropy_heap_end, tc) { #define BUF __stack.__buf @@ -1459,7 +1613,10 @@ ATF_TC_BODY(getentropy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(getentropy_heap_after_end); +ATF_TC(getentropy_heap_after_end); +ATF_TC_HEAD(getentropy_heap_after_end, tc) +{ +} ATF_TC_BODY(getentropy_heap_after_end, tc) { #define BUF __stack.__buf @@ -1510,55 +1667,57 @@ monitor: } -ATF_TC_WITHOUT_HEAD(gethostname_before_end); +ATF_TC(gethostname_before_end); +ATF_TC_HEAD(gethostname_before_end, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(gethostname_before_end, tc) { #define BUF &__stack.__buf struct { uint8_t padding_l; - unsigned char __buf[4]; + unsigned char __buf[17]; uint8_t padding_r; } __stack; const size_t __bufsz __unused = sizeof(__stack.__buf); - const size_t __len = 4 - 1; + const size_t __len = 17 - 1; const size_t __idx __unused = __len - 1; - char syshost[256]; - int error; - - error = gethostname(syshost, __len); - if (error != 0 || strlen(syshost) <= __len) - atf_tc_skip("hostname too short for testing"); + dhost_jail(); gethostname(__stack.__buf, __len); #undef BUF } -ATF_TC_WITHOUT_HEAD(gethostname_end); +ATF_TC(gethostname_end); +ATF_TC_HEAD(gethostname_end, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(gethostname_end, tc) { #define BUF &__stack.__buf struct { uint8_t padding_l; - unsigned char __buf[4]; + unsigned char __buf[17]; uint8_t padding_r; } __stack; const size_t __bufsz __unused = sizeof(__stack.__buf); - const size_t __len = 4; + const size_t __len = 17; const size_t __idx __unused = __len - 1; - char syshost[256]; - int error; - - error = gethostname(syshost, __len); - if (error != 0 || strlen(syshost) <= __len) - atf_tc_skip("hostname too short for testing"); + dhost_jail(); gethostname(__stack.__buf, __len); #undef BUF } -ATF_TC_WITHOUT_HEAD(gethostname_heap_before_end); +ATF_TC(gethostname_heap_before_end); +ATF_TC_HEAD(gethostname_heap_before_end, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(gethostname_heap_before_end, tc) { #define BUF __stack.__buf @@ -1567,16 +1726,11 @@ ATF_TC_BODY(gethostname_heap_before_end, tc) unsigned char * __buf; uint8_t padding_r; } __stack; - const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4); - const size_t __len = 4 - 1; + const size_t __bufsz __unused = sizeof(*__stack.__buf) * (17); + const size_t __len = 17 - 1; const size_t __idx __unused = __len - 1; - char syshost[256]; - int error; - - error = gethostname(syshost, __len); - if (error != 0 || strlen(syshost) <= __len) - atf_tc_skip("hostname too short for testing"); + dhost_jail(); __stack.__buf = malloc(__bufsz); gethostname(__stack.__buf, __len); @@ -1584,7 +1738,11 @@ ATF_TC_BODY(gethostname_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(gethostname_heap_end); +ATF_TC(gethostname_heap_end); +ATF_TC_HEAD(gethostname_heap_end, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(gethostname_heap_end, tc) { #define BUF __stack.__buf @@ -1593,16 +1751,11 @@ ATF_TC_BODY(gethostname_heap_end, tc) unsigned char * __buf; uint8_t padding_r; } __stack; - const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4); - const size_t __len = 4; + const size_t __bufsz __unused = sizeof(*__stack.__buf) * (17); + const size_t __len = 17; const size_t __idx __unused = __len - 1; - char syshost[256]; - int error; - - error = gethostname(syshost, __len); - if (error != 0 || strlen(syshost) <= __len) - atf_tc_skip("hostname too short for testing"); + dhost_jail(); __stack.__buf = malloc(__bufsz); gethostname(__stack.__buf, __len); @@ -1610,7 +1763,11 @@ ATF_TC_BODY(gethostname_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(gethostname_heap_after_end); +ATF_TC(gethostname_heap_after_end); +ATF_TC_HEAD(gethostname_heap_after_end, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} ATF_TC_BODY(gethostname_heap_after_end, tc) { #define BUF __stack.__buf @@ -1619,18 +1776,13 @@ ATF_TC_BODY(gethostname_heap_after_end, tc) unsigned char * __buf; uint8_t padding_r; } __stack; - const size_t __bufsz __unused = sizeof(*__stack.__buf) * (4); - const size_t __len = 4 + 1; + const size_t __bufsz __unused = sizeof(*__stack.__buf) * (17); + const size_t __len = 17 + 1; const size_t __idx __unused = __len - 1; pid_t __child; int __status; - char syshost[256]; - int error; - - error = gethostname(syshost, __len); - if (error != 0 || strlen(syshost) <= __len) - atf_tc_skip("hostname too short for testing"); + dhost_jail(); __child = fork(); ATF_REQUIRE(__child >= 0); if (__child > 0) @@ -1667,7 +1819,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(getlogin_r_before_end); +ATF_TC(getlogin_r_before_end); +ATF_TC_HEAD(getlogin_r_before_end, tc) +{ +} ATF_TC_BODY(getlogin_r_before_end, tc) { #define BUF &__stack.__buf @@ -1685,7 +1840,10 @@ ATF_TC_BODY(getlogin_r_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getlogin_r_end); +ATF_TC(getlogin_r_end); +ATF_TC_HEAD(getlogin_r_end, tc) +{ +} ATF_TC_BODY(getlogin_r_end, tc) { #define BUF &__stack.__buf @@ -1703,7 +1861,10 @@ ATF_TC_BODY(getlogin_r_end, tc) } -ATF_TC_WITHOUT_HEAD(getlogin_r_heap_before_end); +ATF_TC(getlogin_r_heap_before_end); +ATF_TC_HEAD(getlogin_r_heap_before_end, tc) +{ +} ATF_TC_BODY(getlogin_r_heap_before_end, tc) { #define BUF __stack.__buf @@ -1723,7 +1884,10 @@ ATF_TC_BODY(getlogin_r_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(getlogin_r_heap_end); +ATF_TC(getlogin_r_heap_end); +ATF_TC_HEAD(getlogin_r_heap_end, tc) +{ +} ATF_TC_BODY(getlogin_r_heap_end, tc) { #define BUF __stack.__buf @@ -1743,7 +1907,10 @@ ATF_TC_BODY(getlogin_r_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(getlogin_r_heap_after_end); +ATF_TC(getlogin_r_heap_after_end); +ATF_TC_HEAD(getlogin_r_heap_after_end, tc) +{ +} ATF_TC_BODY(getlogin_r_heap_after_end, tc) { #define BUF __stack.__buf @@ -1794,7 +1961,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(ttyname_r_before_end); +ATF_TC(ttyname_r_before_end); +ATF_TC_HEAD(ttyname_r_before_end, tc) +{ +} ATF_TC_BODY(ttyname_r_before_end, tc) { #define BUF &__stack.__buf @@ -1817,7 +1987,10 @@ ATF_TC_BODY(ttyname_r_before_end, tc) } -ATF_TC_WITHOUT_HEAD(ttyname_r_end); +ATF_TC(ttyname_r_end); +ATF_TC_HEAD(ttyname_r_end, tc) +{ +} ATF_TC_BODY(ttyname_r_end, tc) { #define BUF &__stack.__buf @@ -1840,7 +2013,10 @@ ATF_TC_BODY(ttyname_r_end, tc) } -ATF_TC_WITHOUT_HEAD(ttyname_r_heap_before_end); +ATF_TC(ttyname_r_heap_before_end); +ATF_TC_HEAD(ttyname_r_heap_before_end, tc) +{ +} ATF_TC_BODY(ttyname_r_heap_before_end, tc) { #define BUF __stack.__buf @@ -1865,7 +2041,10 @@ ATF_TC_BODY(ttyname_r_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(ttyname_r_heap_end); +ATF_TC(ttyname_r_heap_end); +ATF_TC_HEAD(ttyname_r_heap_end, tc) +{ +} ATF_TC_BODY(ttyname_r_heap_end, tc) { #define BUF __stack.__buf @@ -1890,7 +2069,10 @@ ATF_TC_BODY(ttyname_r_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(ttyname_r_heap_after_end); +ATF_TC(ttyname_r_heap_after_end); +ATF_TC_HEAD(ttyname_r_heap_after_end, tc) +{ +} ATF_TC_BODY(ttyname_r_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/fortify_wchar_test.c b/lib/libc/tests/secure/fortify_wchar_test.c index 618cc74ade9a..43c7997bc6a3 100644 --- a/lib/libc/tests/secure/fortify_wchar_test.c +++ b/lib/libc/tests/secure/fortify_wchar_test.c @@ -4,6 +4,7 @@ #define TMPFILE_SIZE (1024 * 32) #include <sys/param.h> +#include <sys/jail.h> #include <sys/random.h> #include <sys/resource.h> #include <sys/select.h> @@ -162,7 +163,10 @@ replace_stdin(void) close(fd); } -ATF_TC_WITHOUT_HEAD(wmemcpy_before_end); +ATF_TC(wmemcpy_before_end); +ATF_TC_HEAD(wmemcpy_before_end, tc) +{ +} ATF_TC_BODY(wmemcpy_before_end, tc) { #define BUF &__stack.__buf @@ -181,7 +185,10 @@ ATF_TC_BODY(wmemcpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemcpy_end); +ATF_TC(wmemcpy_end); +ATF_TC_HEAD(wmemcpy_end, tc) +{ +} ATF_TC_BODY(wmemcpy_end, tc) { #define BUF &__stack.__buf @@ -200,7 +207,10 @@ ATF_TC_BODY(wmemcpy_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemcpy_heap_before_end); +ATF_TC(wmemcpy_heap_before_end); +ATF_TC_HEAD(wmemcpy_heap_before_end, tc) +{ +} ATF_TC_BODY(wmemcpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -221,7 +231,10 @@ ATF_TC_BODY(wmemcpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemcpy_heap_end); +ATF_TC(wmemcpy_heap_end); +ATF_TC_HEAD(wmemcpy_heap_end, tc) +{ +} ATF_TC_BODY(wmemcpy_heap_end, tc) { #define BUF __stack.__buf @@ -242,7 +255,10 @@ ATF_TC_BODY(wmemcpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemcpy_heap_after_end); +ATF_TC(wmemcpy_heap_after_end); +ATF_TC_HEAD(wmemcpy_heap_after_end, tc) +{ +} ATF_TC_BODY(wmemcpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -294,7 +310,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wmempcpy_before_end); +ATF_TC(wmempcpy_before_end); +ATF_TC_HEAD(wmempcpy_before_end, tc) +{ +} ATF_TC_BODY(wmempcpy_before_end, tc) { #define BUF &__stack.__buf @@ -313,7 +332,10 @@ ATF_TC_BODY(wmempcpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wmempcpy_end); +ATF_TC(wmempcpy_end); +ATF_TC_HEAD(wmempcpy_end, tc) +{ +} ATF_TC_BODY(wmempcpy_end, tc) { #define BUF &__stack.__buf @@ -332,7 +354,10 @@ ATF_TC_BODY(wmempcpy_end, tc) } -ATF_TC_WITHOUT_HEAD(wmempcpy_heap_before_end); +ATF_TC(wmempcpy_heap_before_end); +ATF_TC_HEAD(wmempcpy_heap_before_end, tc) +{ +} ATF_TC_BODY(wmempcpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -353,7 +378,10 @@ ATF_TC_BODY(wmempcpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wmempcpy_heap_end); +ATF_TC(wmempcpy_heap_end); +ATF_TC_HEAD(wmempcpy_heap_end, tc) +{ +} ATF_TC_BODY(wmempcpy_heap_end, tc) { #define BUF __stack.__buf @@ -374,7 +402,10 @@ ATF_TC_BODY(wmempcpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wmempcpy_heap_after_end); +ATF_TC(wmempcpy_heap_after_end); +ATF_TC_HEAD(wmempcpy_heap_after_end, tc) +{ +} ATF_TC_BODY(wmempcpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -426,7 +457,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wmemmove_before_end); +ATF_TC(wmemmove_before_end); +ATF_TC_HEAD(wmemmove_before_end, tc) +{ +} ATF_TC_BODY(wmemmove_before_end, tc) { #define BUF &__stack.__buf @@ -445,7 +479,10 @@ ATF_TC_BODY(wmemmove_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemmove_end); +ATF_TC(wmemmove_end); +ATF_TC_HEAD(wmemmove_end, tc) +{ +} ATF_TC_BODY(wmemmove_end, tc) { #define BUF &__stack.__buf @@ -464,7 +501,10 @@ ATF_TC_BODY(wmemmove_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemmove_heap_before_end); +ATF_TC(wmemmove_heap_before_end); +ATF_TC_HEAD(wmemmove_heap_before_end, tc) +{ +} ATF_TC_BODY(wmemmove_heap_before_end, tc) { #define BUF __stack.__buf @@ -485,7 +525,10 @@ ATF_TC_BODY(wmemmove_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemmove_heap_end); +ATF_TC(wmemmove_heap_end); +ATF_TC_HEAD(wmemmove_heap_end, tc) +{ +} ATF_TC_BODY(wmemmove_heap_end, tc) { #define BUF __stack.__buf @@ -506,7 +549,10 @@ ATF_TC_BODY(wmemmove_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemmove_heap_after_end); +ATF_TC(wmemmove_heap_after_end); +ATF_TC_HEAD(wmemmove_heap_after_end, tc) +{ +} ATF_TC_BODY(wmemmove_heap_after_end, tc) { #define BUF __stack.__buf @@ -558,7 +604,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wmemset_before_end); +ATF_TC(wmemset_before_end); +ATF_TC_HEAD(wmemset_before_end, tc) +{ +} ATF_TC_BODY(wmemset_before_end, tc) { #define BUF &__stack.__buf @@ -576,7 +625,10 @@ ATF_TC_BODY(wmemset_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemset_end); +ATF_TC(wmemset_end); +ATF_TC_HEAD(wmemset_end, tc) +{ +} ATF_TC_BODY(wmemset_end, tc) { #define BUF &__stack.__buf @@ -594,7 +646,10 @@ ATF_TC_BODY(wmemset_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemset_heap_before_end); +ATF_TC(wmemset_heap_before_end); +ATF_TC_HEAD(wmemset_heap_before_end, tc) +{ +} ATF_TC_BODY(wmemset_heap_before_end, tc) { #define BUF __stack.__buf @@ -614,7 +669,10 @@ ATF_TC_BODY(wmemset_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemset_heap_end); +ATF_TC(wmemset_heap_end); +ATF_TC_HEAD(wmemset_heap_end, tc) +{ +} ATF_TC_BODY(wmemset_heap_end, tc) { #define BUF __stack.__buf @@ -634,7 +692,10 @@ ATF_TC_BODY(wmemset_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wmemset_heap_after_end); +ATF_TC(wmemset_heap_after_end); +ATF_TC_HEAD(wmemset_heap_after_end, tc) +{ +} ATF_TC_BODY(wmemset_heap_after_end, tc) { #define BUF __stack.__buf @@ -685,7 +746,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wcpcpy_before_end); +ATF_TC(wcpcpy_before_end); +ATF_TC_HEAD(wcpcpy_before_end, tc) +{ +} ATF_TC_BODY(wcpcpy_before_end, tc) { #define BUF &__stack.__buf @@ -708,7 +772,10 @@ ATF_TC_BODY(wcpcpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcpcpy_end); +ATF_TC(wcpcpy_end); +ATF_TC_HEAD(wcpcpy_end, tc) +{ +} ATF_TC_BODY(wcpcpy_end, tc) { #define BUF &__stack.__buf @@ -731,7 +798,10 @@ ATF_TC_BODY(wcpcpy_end, tc) } -ATF_TC_WITHOUT_HEAD(wcpcpy_heap_before_end); +ATF_TC(wcpcpy_heap_before_end); +ATF_TC_HEAD(wcpcpy_heap_before_end, tc) +{ +} ATF_TC_BODY(wcpcpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -755,7 +825,10 @@ ATF_TC_BODY(wcpcpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcpcpy_heap_end); +ATF_TC(wcpcpy_heap_end); +ATF_TC_HEAD(wcpcpy_heap_end, tc) +{ +} ATF_TC_BODY(wcpcpy_heap_end, tc) { #define BUF __stack.__buf @@ -779,7 +852,10 @@ ATF_TC_BODY(wcpcpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wcpcpy_heap_after_end); +ATF_TC(wcpcpy_heap_after_end); +ATF_TC_HEAD(wcpcpy_heap_after_end, tc) +{ +} ATF_TC_BODY(wcpcpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -834,7 +910,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wcpncpy_before_end); +ATF_TC(wcpncpy_before_end); +ATF_TC_HEAD(wcpncpy_before_end, tc) +{ +} ATF_TC_BODY(wcpncpy_before_end, tc) { #define BUF &__stack.__buf @@ -857,7 +936,10 @@ ATF_TC_BODY(wcpncpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcpncpy_end); +ATF_TC(wcpncpy_end); +ATF_TC_HEAD(wcpncpy_end, tc) +{ +} ATF_TC_BODY(wcpncpy_end, tc) { #define BUF &__stack.__buf @@ -880,7 +962,10 @@ ATF_TC_BODY(wcpncpy_end, tc) } -ATF_TC_WITHOUT_HEAD(wcpncpy_heap_before_end); +ATF_TC(wcpncpy_heap_before_end); +ATF_TC_HEAD(wcpncpy_heap_before_end, tc) +{ +} ATF_TC_BODY(wcpncpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -904,7 +989,10 @@ ATF_TC_BODY(wcpncpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcpncpy_heap_end); +ATF_TC(wcpncpy_heap_end); +ATF_TC_HEAD(wcpncpy_heap_end, tc) +{ +} ATF_TC_BODY(wcpncpy_heap_end, tc) { #define BUF __stack.__buf @@ -928,7 +1016,10 @@ ATF_TC_BODY(wcpncpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wcpncpy_heap_after_end); +ATF_TC(wcpncpy_heap_after_end); +ATF_TC_HEAD(wcpncpy_heap_after_end, tc) +{ +} ATF_TC_BODY(wcpncpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -983,7 +1074,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wcscat_before_end); +ATF_TC(wcscat_before_end); +ATF_TC_HEAD(wcscat_before_end, tc) +{ +} ATF_TC_BODY(wcscat_before_end, tc) { #define BUF &__stack.__buf @@ -1006,7 +1100,10 @@ ATF_TC_BODY(wcscat_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcscat_end); +ATF_TC(wcscat_end); +ATF_TC_HEAD(wcscat_end, tc) +{ +} ATF_TC_BODY(wcscat_end, tc) { #define BUF &__stack.__buf @@ -1029,7 +1126,10 @@ ATF_TC_BODY(wcscat_end, tc) } -ATF_TC_WITHOUT_HEAD(wcscat_heap_before_end); +ATF_TC(wcscat_heap_before_end); +ATF_TC_HEAD(wcscat_heap_before_end, tc) +{ +} ATF_TC_BODY(wcscat_heap_before_end, tc) { #define BUF __stack.__buf @@ -1053,7 +1153,10 @@ ATF_TC_BODY(wcscat_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcscat_heap_end); +ATF_TC(wcscat_heap_end); +ATF_TC_HEAD(wcscat_heap_end, tc) +{ +} ATF_TC_BODY(wcscat_heap_end, tc) { #define BUF __stack.__buf @@ -1077,7 +1180,10 @@ ATF_TC_BODY(wcscat_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wcscat_heap_after_end); +ATF_TC(wcscat_heap_after_end); +ATF_TC_HEAD(wcscat_heap_after_end, tc) +{ +} ATF_TC_BODY(wcscat_heap_after_end, tc) { #define BUF __stack.__buf @@ -1132,7 +1238,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wcslcat_before_end); +ATF_TC(wcslcat_before_end); +ATF_TC_HEAD(wcslcat_before_end, tc) +{ +} ATF_TC_BODY(wcslcat_before_end, tc) { #define BUF &__stack.__buf @@ -1155,7 +1264,10 @@ ATF_TC_BODY(wcslcat_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcslcat_end); +ATF_TC(wcslcat_end); +ATF_TC_HEAD(wcslcat_end, tc) +{ +} ATF_TC_BODY(wcslcat_end, tc) { #define BUF &__stack.__buf @@ -1178,7 +1290,10 @@ ATF_TC_BODY(wcslcat_end, tc) } -ATF_TC_WITHOUT_HEAD(wcslcat_heap_before_end); +ATF_TC(wcslcat_heap_before_end); +ATF_TC_HEAD(wcslcat_heap_before_end, tc) +{ +} ATF_TC_BODY(wcslcat_heap_before_end, tc) { #define BUF __stack.__buf @@ -1202,7 +1317,10 @@ ATF_TC_BODY(wcslcat_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcslcat_heap_end); +ATF_TC(wcslcat_heap_end); +ATF_TC_HEAD(wcslcat_heap_end, tc) +{ +} ATF_TC_BODY(wcslcat_heap_end, tc) { #define BUF __stack.__buf @@ -1226,7 +1344,10 @@ ATF_TC_BODY(wcslcat_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wcslcat_heap_after_end); +ATF_TC(wcslcat_heap_after_end); +ATF_TC_HEAD(wcslcat_heap_after_end, tc) +{ +} ATF_TC_BODY(wcslcat_heap_after_end, tc) { #define BUF __stack.__buf @@ -1281,7 +1402,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wcsncat_before_end); +ATF_TC(wcsncat_before_end); +ATF_TC_HEAD(wcsncat_before_end, tc) +{ +} ATF_TC_BODY(wcsncat_before_end, tc) { #define BUF &__stack.__buf @@ -1304,7 +1428,10 @@ ATF_TC_BODY(wcsncat_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcsncat_end); +ATF_TC(wcsncat_end); +ATF_TC_HEAD(wcsncat_end, tc) +{ +} ATF_TC_BODY(wcsncat_end, tc) { #define BUF &__stack.__buf @@ -1327,7 +1454,10 @@ ATF_TC_BODY(wcsncat_end, tc) } -ATF_TC_WITHOUT_HEAD(wcsncat_heap_before_end); +ATF_TC(wcsncat_heap_before_end); +ATF_TC_HEAD(wcsncat_heap_before_end, tc) +{ +} ATF_TC_BODY(wcsncat_heap_before_end, tc) { #define BUF __stack.__buf @@ -1351,7 +1481,10 @@ ATF_TC_BODY(wcsncat_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcsncat_heap_end); +ATF_TC(wcsncat_heap_end); +ATF_TC_HEAD(wcsncat_heap_end, tc) +{ +} ATF_TC_BODY(wcsncat_heap_end, tc) { #define BUF __stack.__buf @@ -1375,7 +1508,10 @@ ATF_TC_BODY(wcsncat_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wcsncat_heap_after_end); +ATF_TC(wcsncat_heap_after_end); +ATF_TC_HEAD(wcsncat_heap_after_end, tc) +{ +} ATF_TC_BODY(wcsncat_heap_after_end, tc) { #define BUF __stack.__buf @@ -1430,7 +1566,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wcscpy_before_end); +ATF_TC(wcscpy_before_end); +ATF_TC_HEAD(wcscpy_before_end, tc) +{ +} ATF_TC_BODY(wcscpy_before_end, tc) { #define BUF &__stack.__buf @@ -1453,7 +1592,10 @@ ATF_TC_BODY(wcscpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcscpy_end); +ATF_TC(wcscpy_end); +ATF_TC_HEAD(wcscpy_end, tc) +{ +} ATF_TC_BODY(wcscpy_end, tc) { #define BUF &__stack.__buf @@ -1476,7 +1618,10 @@ ATF_TC_BODY(wcscpy_end, tc) } -ATF_TC_WITHOUT_HEAD(wcscpy_heap_before_end); +ATF_TC(wcscpy_heap_before_end); +ATF_TC_HEAD(wcscpy_heap_before_end, tc) +{ +} ATF_TC_BODY(wcscpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -1500,7 +1645,10 @@ ATF_TC_BODY(wcscpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcscpy_heap_end); +ATF_TC(wcscpy_heap_end); +ATF_TC_HEAD(wcscpy_heap_end, tc) +{ +} ATF_TC_BODY(wcscpy_heap_end, tc) { #define BUF __stack.__buf @@ -1524,7 +1672,10 @@ ATF_TC_BODY(wcscpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wcscpy_heap_after_end); +ATF_TC(wcscpy_heap_after_end); +ATF_TC_HEAD(wcscpy_heap_after_end, tc) +{ +} ATF_TC_BODY(wcscpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -1579,7 +1730,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wcslcpy_before_end); +ATF_TC(wcslcpy_before_end); +ATF_TC_HEAD(wcslcpy_before_end, tc) +{ +} ATF_TC_BODY(wcslcpy_before_end, tc) { #define BUF &__stack.__buf @@ -1602,7 +1756,10 @@ ATF_TC_BODY(wcslcpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcslcpy_end); +ATF_TC(wcslcpy_end); +ATF_TC_HEAD(wcslcpy_end, tc) +{ +} ATF_TC_BODY(wcslcpy_end, tc) { #define BUF &__stack.__buf @@ -1625,7 +1782,10 @@ ATF_TC_BODY(wcslcpy_end, tc) } -ATF_TC_WITHOUT_HEAD(wcslcpy_heap_before_end); +ATF_TC(wcslcpy_heap_before_end); +ATF_TC_HEAD(wcslcpy_heap_before_end, tc) +{ +} ATF_TC_BODY(wcslcpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -1649,7 +1809,10 @@ ATF_TC_BODY(wcslcpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcslcpy_heap_end); +ATF_TC(wcslcpy_heap_end); +ATF_TC_HEAD(wcslcpy_heap_end, tc) +{ +} ATF_TC_BODY(wcslcpy_heap_end, tc) { #define BUF __stack.__buf @@ -1673,7 +1836,10 @@ ATF_TC_BODY(wcslcpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wcslcpy_heap_after_end); +ATF_TC(wcslcpy_heap_after_end); +ATF_TC_HEAD(wcslcpy_heap_after_end, tc) +{ +} ATF_TC_BODY(wcslcpy_heap_after_end, tc) { #define BUF __stack.__buf @@ -1728,7 +1894,10 @@ monitor: } -ATF_TC_WITHOUT_HEAD(wcsncpy_before_end); +ATF_TC(wcsncpy_before_end); +ATF_TC_HEAD(wcsncpy_before_end, tc) +{ +} ATF_TC_BODY(wcsncpy_before_end, tc) { #define BUF &__stack.__buf @@ -1751,7 +1920,10 @@ ATF_TC_BODY(wcsncpy_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcsncpy_end); +ATF_TC(wcsncpy_end); +ATF_TC_HEAD(wcsncpy_end, tc) +{ +} ATF_TC_BODY(wcsncpy_end, tc) { #define BUF &__stack.__buf @@ -1774,7 +1946,10 @@ ATF_TC_BODY(wcsncpy_end, tc) } -ATF_TC_WITHOUT_HEAD(wcsncpy_heap_before_end); +ATF_TC(wcsncpy_heap_before_end); +ATF_TC_HEAD(wcsncpy_heap_before_end, tc) +{ +} ATF_TC_BODY(wcsncpy_heap_before_end, tc) { #define BUF __stack.__buf @@ -1798,7 +1973,10 @@ ATF_TC_BODY(wcsncpy_heap_before_end, tc) } -ATF_TC_WITHOUT_HEAD(wcsncpy_heap_end); +ATF_TC(wcsncpy_heap_end); +ATF_TC_HEAD(wcsncpy_heap_end, tc) +{ +} ATF_TC_BODY(wcsncpy_heap_end, tc) { #define BUF __stack.__buf @@ -1822,7 +2000,10 @@ ATF_TC_BODY(wcsncpy_heap_end, tc) } -ATF_TC_WITHOUT_HEAD(wcsncpy_heap_after_end); +ATF_TC(wcsncpy_heap_after_end); +ATF_TC_HEAD(wcsncpy_heap_after_end, tc) +{ +} ATF_TC_BODY(wcsncpy_heap_after_end, tc) { #define BUF __stack.__buf diff --git a/lib/libc/tests/secure/generate-fortify-tests.lua b/lib/libc/tests/secure/generate-fortify-tests.lua index 0e46b8867862..36ff01af7a17 100755 --- a/lib/libc/tests/secure/generate-fortify-tests.lua +++ b/lib/libc/tests/secure/generate-fortify-tests.lua @@ -62,6 +62,7 @@ local includes = { "sys/param.h", + "sys/jail.h", "sys/random.h", "sys/resource.h", "sys/select.h", @@ -87,6 +88,10 @@ local includes = { local tests_added = {} +-- Configuration for tests that want the host/domainname +local hostname = "host.example.com" +local domainname = "example.com" + -- Some of these will need to be excluded because clang sees the wrong size when -- an array is embedded inside a struct, we'll get something that looks more -- like __builtin_object_size(ptr, 0) than it does the correct @@ -858,18 +863,14 @@ local all_tests = { }, { func = "getdomainname", - bufsize = "4", + bufsize = #domainname + 1, arguments = { "__buf", "__len", }, + need_root = true, exclude = excludes_stack_overflow, - stackvars = "\tchar sysdomain[256];\n", - early_init = [[ - (void)getdomainname(sysdomain, __len); - if (strlen(sysdomain) <= __len) - atf_tc_skip("domain name too short for testing"); -]] + early_init = " dhost_jail();", }, { func = "getentropy", @@ -881,21 +882,14 @@ local all_tests = { }, { func = "gethostname", - bufsize = "4", + bufsize = #hostname + 1, arguments = { "__buf", "__len", }, + need_root = true, exclude = excludes_stack_overflow, - stackvars = [[ - char syshost[256]; - int error; -]], - early_init = [[ - error = gethostname(syshost, __len); - if (error != 0 || strlen(syshost) <= __len) - atf_tc_skip("hostname too short for testing"); -]] + early_init = " dhost_jail();", }, { func = "getlogin_r", @@ -1066,8 +1060,15 @@ local all_tests = { }, } -local function write_test_boilerplate(fh, name, body) - fh:write("ATF_TC_WITHOUT_HEAD(" .. name .. ");\n") +local function write_test_boilerplate(fh, name, body, def) + fh:write("ATF_TC(" .. name .. ");\n") + fh:write("ATF_TC_HEAD(" .. name .. ", tc)\n") + fh:write("{\n") + if def.need_root then + fh:write(" atf_tc_set_md_var(tc, \"require.user\", \"root\");\n") + end + fh:write("}\n") + fh:write("ATF_TC_BODY(" .. name .. ", tc)\n") fh:write("{\n" .. body .. "\n}\n\n") return name @@ -1113,7 +1114,7 @@ local function configurable(def, idx) end local function generate_stackframe(buftype, bufsize, disposition, heap, def) - local function len_offset(inverted, disposition) + local function len_offset(inverted) -- Tests that don't use __len in their arguments may use an -- inverted sense because we can't just specify a length that -- would induce an access just after the end. Instead, we have @@ -1128,7 +1129,7 @@ local function generate_stackframe(buftype, bufsize, disposition, heap, def) end end - local function test_uses_len(def) + local function test_uses_len() if def.uses_len then return true end @@ -1151,8 +1152,8 @@ local function generate_stackframe(buftype, bufsize, disposition, heap, def) local vars = "\tstruct {\n" vars = vars .. "\t\tuint8_t padding_l;\n" - local uses_len = test_uses_len(def) - local bufsize_offset = len_offset(not uses_len, disposition) + local uses_len = test_uses_len() + local bufsize_offset = len_offset(not uses_len) local buftype_elem = array_type(buftype) local size_expr = bufsize @@ -1230,7 +1231,7 @@ local function write_test(fh, func, disposition, heap, def) return end - local function need_addr(buftype) + local function need_addr() return not (buftype:match("%[%]") or buftype:match("%*")) end @@ -1292,7 +1293,7 @@ local function write_test(fh, func, disposition, heap, def) end if arg == "__buf" then - if not heap and need_addr(buftype) then + if not heap and need_addr() then body = body .. "&" end @@ -1342,7 +1343,7 @@ monitor: ::skip:: body = body .. "#undef BUF\n" - return write_test_boilerplate(fh, testname, body) + return write_test_boilerplate(fh, testname, body, def) end -- main() @@ -1508,6 +1509,32 @@ replace_stdin(void) ]]) +if tcat == "unistd" then + fh:write("#define JAIL_HOSTNAME \"" .. hostname .. "\"\n") + fh:write("#define JAIL_DOMAINNAME \"" .. domainname .. "\"\n") + fh:write([[ +static void +dhost_jail(void) +{ + struct iovec iov[4]; + int jid; + + iov[0].iov_base = __DECONST(char *, "host.hostname"); + iov[0].iov_len = sizeof("host.hostname"); + iov[1].iov_base = __DECONST(char *, JAIL_HOSTNAME); + iov[1].iov_len = sizeof(JAIL_HOSTNAME); + iov[2].iov_base = __DECONST(char *, "host.domainname"); + iov[2].iov_len = sizeof("host.domainname"); + iov[3].iov_base = __DECONST(char *, JAIL_DOMAINNAME); + iov[3].iov_len = sizeof(JAIL_DOMAINNAME); + + jid = jail_set(iov, nitems(iov), JAIL_CREATE | JAIL_ATTACH); + ATF_REQUIRE_MSG(jid > 0, "Jail creation failed: %s", strerror(errno)); +} + +]]) +end + for _, def in pairs(tests) do local func = def.func local function write_tests(heap) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index e93c79758428..d84a66063647 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -3188,3 +3188,139 @@ pfctl_del_table(struct pfctl_handle *h, struct pfr_table *table, return (e.error); } +static bool +snl_attr_get_uint64_into_int_array(struct snl_state *ss, struct nlattr *nla, + const void *arg, void *target) +{ + uint64_t *u64target; + struct snl_uint64_array a = { + .count = 0, + .max = (size_t)arg, + }; + bool error; + + u64target = malloc(a.max * sizeof(uint64_t)); + a.array = u64target; + + error = snl_parse_header(ss, NLA_DATA(nla), NLA_DATA_LEN(nla), &array_parser, &a); + if (! error) + return (error); + + for (size_t i = 0; i < a.count; i++) + ((int *)target)[i] = (int)u64target[i]; + + free(u64target); + + return (true); +} + +#define _OUT(_field) offsetof(struct pfr_table, _field) +static const struct snl_attr_parser ap_table[] = { + { .type = PF_T_ANCHOR, .off = _OUT(pfrt_anchor), .arg = (void *)MAXPATHLEN, .cb = snl_attr_copy_string }, + { .type = PF_T_NAME, .off = _OUT(pfrt_name), .arg = (void *)PF_TABLE_NAME_SIZE, .cb =snl_attr_copy_string }, + { .type = PF_T_TABLE_FLAGS, .off = _OUT(pfrt_flags), .cb = snl_attr_get_uint32 }, +}; +#undef _OUT +SNL_DECLARE_ATTR_PARSER(table_parser, ap_table); +#define _OUT(_field) offsetof(struct pfr_tstats, _field) +static struct snl_attr_parser ap_tstats[] = { + { .type = PF_TS_TABLE, .off = _OUT(pfrts_t), .arg = &table_parser, .cb = snl_attr_get_nested }, + { .type = PF_TS_PACKETS, .off = _OUT(pfrts_packets), .arg = (void *)(PFR_DIR_MAX * PFR_OP_TABLE_MAX), .cb = snl_attr_get_uint64_array}, + { .type = PF_TS_BYTES, .off = _OUT(pfrts_bytes), .arg = (void *)(PFR_DIR_MAX * PFR_OP_TABLE_MAX), .cb = snl_attr_get_uint64_array }, + { .type = PF_TS_MATCH, .off = _OUT(pfrts_match), .cb = snl_attr_get_uint64 }, + {. type = PF_TS_NOMATCH, .off = _OUT(pfrts_nomatch), .cb = snl_attr_get_uint64 }, + { .type = PF_TS_TZERO, .off = _OUT(pfrts_tzero), .cb = snl_attr_get_uint64 }, + { .type = PF_TS_REFCNT, .off = _OUT(pfrts_cnt), . arg = (void *)PFR_REFCNT_MAX, .cb = snl_attr_get_uint64_into_int_array }, +}; +#undef _OUT +SNL_DECLARE_PARSER(tstats_parser, struct genlmsghdr, snl_f_p_empty, ap_tstats); + +int +pfctl_get_tstats(struct pfctl_handle *h, const struct pfr_table *filter, + pfctl_get_tstats_fn fn, void *arg) +{ + struct snl_writer nw; + struct snl_errmsg_data e = {}; + struct nlmsghdr *hdr; + uint32_t seq_id; + int family_id; + int ret; + + family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME); + if (family_id == 0) + return (ENOTSUP); + + snl_init_writer(&h->ss, &nw); + hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GET_TSTATS); + + snl_add_msg_attr_string(&nw, PF_T_ANCHOR, filter->pfrt_anchor); + snl_add_msg_attr_string(&nw, PF_T_NAME, filter->pfrt_name); + snl_add_msg_attr_u32(&nw, PF_T_TABLE_FLAGS, filter->pfrt_flags); + + if ((hdr = snl_finalize_msg(&nw)) == NULL) + return (ENXIO); + + seq_id = hdr->nlmsg_seq; + + if (!snl_send_message(&h->ss, hdr)) + return (ENXIO); + + while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) { + struct pfr_tstats tstats = {}; + + if (!snl_parse_nlmsg(&h->ss, hdr, &tstats_parser, &tstats)) + continue; + + ret = fn(&tstats, arg); + if (ret != 0) + break; + } + + return (e.error); +} + +static struct snl_attr_parser ap_tstats_clr[] = { + { .type = PF_TS_NZERO, .off = 0, .cb = snl_attr_get_uint64 }, +}; +SNL_DECLARE_PARSER(tstats_clr_parser, struct genlmsghdr, snl_f_p_empty, ap_tstats_clr); + +int +pfctl_clear_tstats(struct pfctl_handle *h, const struct pfr_table *filter, + int *nzero, int flags) +{ + struct snl_writer nw; + struct snl_errmsg_data e = {}; + struct nlmsghdr *hdr; + uint64_t zero; + uint32_t seq_id; + int family_id; + + family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME); + if (family_id == 0) + return (ENOTSUP); + + snl_init_writer(&h->ss, &nw); + hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_CLR_TSTATS); + + snl_add_msg_attr_string(&nw, PF_T_ANCHOR, filter->pfrt_anchor); + snl_add_msg_attr_string(&nw, PF_T_NAME, filter->pfrt_name); + snl_add_msg_attr_u32(&nw, PF_T_TABLE_FLAGS, filter->pfrt_flags); + snl_add_msg_attr_u32(&nw, PF_T_FLAGS, flags); + + if ((hdr = snl_finalize_msg(&nw)) == NULL) + return (ENXIO); + + seq_id = hdr->nlmsg_seq; + + if (!snl_send_message(&h->ss, hdr)) + return (ENXIO); + + while ((hdr = snl_read_reply_multi(&h->ss, seq_id, &e)) != NULL) { + if (!snl_parse_nlmsg(&h->ss, hdr, &tstats_clr_parser, &zero)) + continue; + if (nzero) + *nzero = (uint32_t)zero; + } + + return (e.error); +} diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 1108b0ffc693..d8a7d1b6ebc4 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -551,4 +551,10 @@ int pfctl_add_table(struct pfctl_handle *h, struct pfr_table *table, int pfctl_del_table(struct pfctl_handle *h, struct pfr_table *table, int *ndel, int flags); +typedef int (*pfctl_get_tstats_fn)(const struct pfr_tstats *t, void *arg); +int pfctl_get_tstats(struct pfctl_handle *h, const struct pfr_table *filter, + pfctl_get_tstats_fn fn, void *arg); +int pfctl_clear_tstats(struct pfctl_handle *h, const struct pfr_table *filter, + int *nzero, int flags); + #endif diff --git a/lib/libprocstat/core.c b/lib/libprocstat/core.c index c02ab9511af7..b27b35de3bab 100644 --- a/lib/libprocstat/core.c +++ b/lib/libprocstat/core.c @@ -57,22 +57,62 @@ struct procstat_core GElf_Phdr pc_phdr; }; -static struct psc_type_info { +static const struct psc_type_info { unsigned int n_type; int structsize; } psc_type_info[PSC_TYPE_MAX] = { - { .n_type = NT_PROCSTAT_PROC, .structsize = sizeof(struct kinfo_proc) }, - { .n_type = NT_PROCSTAT_FILES, .structsize = sizeof(struct kinfo_file) }, - { .n_type = NT_PROCSTAT_VMMAP, .structsize = sizeof(struct kinfo_vmentry) }, - { .n_type = NT_PROCSTAT_GROUPS, .structsize = sizeof(gid_t) }, - { .n_type = NT_PROCSTAT_UMASK, .structsize = sizeof(u_short) }, - { .n_type = NT_PROCSTAT_RLIMIT, .structsize = sizeof(struct rlimit) * RLIM_NLIMITS }, - { .n_type = NT_PROCSTAT_OSREL, .structsize = sizeof(int) }, - { .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) }, - { .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) }, - { .n_type = NT_PROCSTAT_PSSTRINGS, .structsize = sizeof(vm_offset_t) }, - { .n_type = NT_PROCSTAT_AUXV, .structsize = sizeof(Elf_Auxinfo) }, - { .n_type = NT_PTLWPINFO, .structsize = sizeof(struct ptrace_lwpinfo) }, + [PSC_TYPE_PROC] = { + .n_type = NT_PROCSTAT_PROC, + .structsize = sizeof(struct kinfo_proc) + }, + [PSC_TYPE_FILES] = { + .n_type = NT_PROCSTAT_FILES, + .structsize = sizeof(struct kinfo_file) + }, + [PSC_TYPE_VMMAP] = { + .n_type = NT_PROCSTAT_VMMAP, + .structsize = sizeof(struct kinfo_vmentry) + }, + [PSC_TYPE_GROUPS] = { + .n_type = NT_PROCSTAT_GROUPS, + .structsize = sizeof(gid_t) + }, + [PSC_TYPE_UMASK] = { + .n_type = NT_PROCSTAT_UMASK, + .structsize = sizeof(u_short) + }, + [PSC_TYPE_RLIMIT] = { + .n_type = NT_PROCSTAT_RLIMIT, + .structsize = sizeof(struct rlimit) * RLIM_NLIMITS + }, + [PSC_TYPE_OSREL] = { + .n_type = NT_PROCSTAT_OSREL, + .structsize = sizeof(int) + }, + [PSC_TYPE_PSSTRINGS] = { + .n_type = NT_PROCSTAT_PSSTRINGS, + .structsize = sizeof(vm_offset_t) + }, + [PSC_TYPE_ARGV] = { + .n_type = NT_PROCSTAT_PSSTRINGS, + .structsize = sizeof(vm_offset_t) + }, + [PSC_TYPE_ENVV] = { + .n_type = NT_PROCSTAT_PSSTRINGS, + .structsize = sizeof(vm_offset_t) + }, + [PSC_TYPE_AUXV] = { + .n_type = NT_PROCSTAT_AUXV, + .structsize = sizeof(Elf_Auxinfo) + }, + [PSC_TYPE_PTLWPINFO] = { + .n_type = NT_PTLWPINFO, + .structsize = sizeof(struct ptrace_lwpinfo) + }, + [PSC_TYPE_KQUEUES] = { + .n_type = NT_PROCSTAT_KQUEUES, + .structsize = sizeof(struct kinfo_knote) + }, }; static bool core_offset(struct procstat_core *core, off_t offset); diff --git a/lib/libprocstat/core.h b/lib/libprocstat/core.h index d6cb60dc9e25..f4276fbdf09e 100644 --- a/lib/libprocstat/core.h +++ b/lib/libprocstat/core.h @@ -31,7 +31,7 @@ #define _CORE_H enum psc_type { - PSC_TYPE_PROC, + PSC_TYPE_PROC = 0, PSC_TYPE_FILES, PSC_TYPE_VMMAP, PSC_TYPE_GROUPS, @@ -43,6 +43,7 @@ enum psc_type { PSC_TYPE_ENVV, PSC_TYPE_AUXV, PSC_TYPE_PTLWPINFO, + PSC_TYPE_KQUEUES, PSC_TYPE_MAX }; diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 3c70c939ff7e..29f464ef6414 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -2862,6 +2862,9 @@ struct kinfo_knote * procstat_get_kqueue_info(struct procstat *procstat, struct kinfo_proc *kp, int kqfd, unsigned int *count, char *errbuf) { + struct kinfo_knote *kn, *k, *res, *rn; + size_t len, kqn; + switch (procstat->type) { case PROCSTAT_KVM: warnx("kvm method is not supported"); @@ -2870,8 +2873,34 @@ procstat_get_kqueue_info(struct procstat *procstat, return (procstat_get_kqueue_info_sysctl(kp->ki_pid, kqfd, count, errbuf)); case PROCSTAT_CORE: - warnx("core method is not supported"); - return (NULL); + k = procstat_core_get(procstat->core, PSC_TYPE_KQUEUES, + NULL, &len); + if (k == NULL) { + snprintf(errbuf, _POSIX2_LINE_MAX, + "getting NT_PROCSTAT_KQUEUES note failed"); + *count = 0; + return (NULL); + } + for (kqn = 0, kn = k; kn < k + len / sizeof(*kn); kn++) { + if (kn->knt_kq_fd == kqfd) + kqn++; + } + res = calloc(kqn, sizeof(*res)); + if (res == NULL) { + free(k); + snprintf(errbuf, _POSIX2_LINE_MAX, + "no memory"); + return (NULL); + } + for (kn = k, rn = res; kn < k + len / sizeof(*kn); kn++) { + if (kn->knt_kq_fd != kqfd) + continue; + *rn = *kn; + rn++; + } + *count = kqn; + free(k); + return (res); default: warnx("unknown access method: %d", procstat->type); return (NULL); diff --git a/lib/libsys/aio_cancel.2 b/lib/libsys/aio_cancel.2 index 42d074054716..928a8b325e5f 100644 --- a/lib/libsys/aio_cancel.2 +++ b/lib/libsys/aio_cancel.2 @@ -80,6 +80,13 @@ The .Fa fildes argument is an invalid file descriptor. +.It Bq Er ENOSYS +The +.Fn aio_cancel +system call is not supported. +This can occur if +.Xr aio 4 +support is not present. .El .Sh SEE ALSO .Xr aio_error 2 , diff --git a/lib/libsys/aio_error.2 b/lib/libsys/aio_error.2 index 69eb7cd90ee2..2579d2f33052 100644 --- a/lib/libsys/aio_error.2 +++ b/lib/libsys/aio_error.2 @@ -72,6 +72,13 @@ The .Fa iocb argument does not reference an outstanding asynchronous I/O request. +.It Bq Er ENOSYS +The +.Fn aio_error +system call is not supported. +This can occur if +.Xr aio 4 +support is not present. .El .Sh SEE ALSO .Xr aio_cancel 2 , diff --git a/lib/libsys/aio_fsync.2 b/lib/libsys/aio_fsync.2 index 46fc5d95bcfd..0b863773eaf2 100644 --- a/lib/libsys/aio_fsync.2 +++ b/lib/libsys/aio_fsync.2 @@ -136,6 +136,13 @@ argument is not a valid descriptor. .It Bq Er EINVAL This implementation does not support synchronized I/O for this file. +.It Bq Er ENOSYS +The +.Fn aio_fsync +system call is not supported. +This can occur if +.Xr aio 4 +support is not present. .El .Pp If the request is successfully enqueued, but subsequently cancelled diff --git a/lib/libsys/aio_mlock.2 b/lib/libsys/aio_mlock.2 index 02d54304c631..f89ad10936aa 100644 --- a/lib/libsys/aio_mlock.2 +++ b/lib/libsys/aio_mlock.2 @@ -98,6 +98,13 @@ The request was not queued because of system resource limitations. The asynchronous notification method in .Fa iocb->aio_sigevent.sigev_notify is invalid or not supported. +.It Bq Er ENOSYS +The +.Fn aio_mlock +system call is not supported. +This can occur if +.Xr aio 4 +support is not present. .El .Pp If the request is successfully enqueued, but subsequently cancelled diff --git a/lib/libsys/aio_read.2 b/lib/libsys/aio_read.2 index 3a9601754c06..811d0b234168 100644 --- a/lib/libsys/aio_read.2 +++ b/lib/libsys/aio_read.2 @@ -173,6 +173,13 @@ points outside the process's allocated address space. The asynchronous notification method in .Fa iocb->aio_sigevent.sigev_notify is invalid or not supported. +.It Bq Er ENOSYS +The +.Fn aio_read +system call is not supported. +This can occur if +.Xr aio 4 +support is not present. .It Bq Er EOPNOTSUPP Asynchronous read operations on the file descriptor .Fa iocb->aio_fildes @@ -263,7 +270,9 @@ The .Fn aio_read2 and .Fn aio_readv -system calls are FreeBSD extensions, +system calls are +.Fx +extensions, and should not be used in portable code. .Sh HISTORY The diff --git a/lib/libsys/aio_return.2 b/lib/libsys/aio_return.2 index 499b85ef20d8..49e1abf201ec 100644 --- a/lib/libsys/aio_return.2 +++ b/lib/libsys/aio_return.2 @@ -79,6 +79,13 @@ The I/O operation was submitted with and the value of the .Fa aio_lio_opcode is invalid. +.It Bq Er ENOSYS +The +.Fn aio_return +system call is not supported. +This can occur if +.Xr aio 4 +support is not present. .El .Sh SEE ALSO .Xr aio_cancel 2 , diff --git a/lib/libsys/aio_suspend.2 b/lib/libsys/aio_suspend.2 index c46b0292c34e..ebc3c15d059f 100644 --- a/lib/libsys/aio_suspend.2 +++ b/lib/libsys/aio_suspend.2 @@ -89,6 +89,13 @@ contains more asynchronous I/O requests than the variable, or at least one of the requests is not valid. .It Bq Er EINTR the suspend was interrupted by a signal. +.It Bq Er ENOSYS +The +.Fn aio_suspend +system call is not supported. +This can occur if +.Xr aio 4 +support is not present. .El .Sh SEE ALSO .Xr aio_cancel 2 , diff --git a/lib/libsys/aio_waitcomplete.2 b/lib/libsys/aio_waitcomplete.2 index 1f20eca942ab..0a38155d7c75 100644 --- a/lib/libsys/aio_waitcomplete.2 +++ b/lib/libsys/aio_waitcomplete.2 @@ -91,8 +91,6 @@ The .Fn aio_waitcomplete system call fails if: .Bl -tag -width Er -.It Bq Er EINVAL -The specified time limit is invalid. .It Bq Er EAGAIN The process has not yet called .Fn aio_read @@ -101,6 +99,15 @@ or .It Bq Er EINTR A signal was delivered before the timeout expired and before any asynchronous I/O requests completed. +.It Bq Er EINVAL +The specified time limit is invalid. +.It Bq Er ENOSYS +The +.Fn aio_waitcomplete +system call is not supported. +This can occur if +.Xr aio 4 +support is not present. .It Bq Er EWOULDBLOCK .It Bq Er EINPROGRESS The specified time limit expired before any asynchronous I/O requests diff --git a/lib/libsys/aio_write.2 b/lib/libsys/aio_write.2 index f59406b8ab36..a7108a87e378 100644 --- a/lib/libsys/aio_write.2 +++ b/lib/libsys/aio_write.2 @@ -182,6 +182,13 @@ points outside the process's allocated address space. The asynchronous notification method in .Fa iocb->aio_sigevent.sigev_notify is invalid or not supported. +.It Bq Er ENOSYS +The +.Fn aio_write +system call is not supported. +This can occur if +.Xr aio 4 +support is not present. .It Bq Er EOPNOTSUPP Asynchronous write operations on the file descriptor .Fa iocb->aio_fildes @@ -265,7 +272,9 @@ The .Fn aio_write2 and .Fn aio_writev -system calls are FreeBSD extensions, +system calls are +.Fx +extensions, and should not be used in portable code. .Sh HISTORY The diff --git a/libexec/rc/rc.d/hostapd b/libexec/rc/rc.d/hostapd index 251df91a280b..264cb4ef476b 100755 --- a/libexec/rc/rc.d/hostapd +++ b/libexec/rc/rc.d/hostapd @@ -34,7 +34,7 @@ fi command_args="-P ${pidfile} -B ${conf_file}" required_files="${conf_file}" -required_modules="wlan_xauth wlan_wep wlan_tkip wlan_ccmp" +required_modules="wlan_xauth wlan_wep wlan_tkip wlan_ccmp wlan_gcmp" extra_commands="reload" load_rc_config ${name} diff --git a/libexec/rc/rc.d/wpa_supplicant b/libexec/rc/rc.d/wpa_supplicant index 61525a82894b..e11dddfb5fd3 100755 --- a/libexec/rc/rc.d/wpa_supplicant +++ b/libexec/rc/rc.d/wpa_supplicant @@ -31,7 +31,7 @@ conf_file=${wpa_supplicant_conf_file} pidfile="/var/run/${name}/${ifn}.pid" command_args="-B -i $ifn -c $conf_file -D $driver -P $pidfile" required_files=$conf_file -required_modules="wlan_wep wlan_tkip wlan_ccmp" +required_modules="wlan_wep wlan_tkip wlan_ccmp wlan_gcmp" # doesn't make sense to run in a svcj: nojail keyword wpa_supplicant_svcj="NO" diff --git a/sbin/devd/devd.cc b/sbin/devd/devd.cc index 8d621e42a232..d7a3fee57870 100644 --- a/sbin/devd/devd.cc +++ b/sbin/devd/devd.cc @@ -938,7 +938,7 @@ create_socket(const char *name, int socktype) return (fd); } -static unsigned int max_clients = 10; /* Default, can be overridden on cmdline. */ +static unsigned int max_clients = 50; /* Default, can be overridden on cmdline. */ static unsigned int num_clients; static list<client_t> clients; diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h index ffd37cf023a6..b4f8c97854d1 100644 --- a/sbin/pfctl/pfctl.h +++ b/sbin/pfctl/pfctl.h @@ -59,8 +59,6 @@ int pfr_get_fd(void); int pfr_add_table(struct pfr_table *, int *, int); int pfr_del_table(struct pfr_table *, int *, int); int pfr_get_tables(struct pfr_table *, struct pfr_table *, int *, int); -int pfr_get_tstats(struct pfr_table *, struct pfr_tstats *, int *, int); -int pfr_clr_tstats(struct pfr_table *, int, int *, int); int pfr_clr_astats(struct pfr_table *, struct pfr_addr *, int, int *, int); int pfr_clr_addrs(struct pfr_table *, int *, int); int pfr_add_addrs(struct pfr_table *, struct pfr_addr *, int, int *, int); diff --git a/sbin/pfctl/pfctl_radix.c b/sbin/pfctl/pfctl_radix.c index 3bb2469a9bfb..1d1918e29f44 100644 --- a/sbin/pfctl/pfctl_radix.c +++ b/sbin/pfctl/pfctl_radix.c @@ -111,31 +111,6 @@ pfr_get_tables(struct pfr_table *filter, struct pfr_table *tbl, int *size, } int -pfr_get_tstats(struct pfr_table *filter, struct pfr_tstats *tbl, int *size, - int flags) -{ - struct pfioc_table io; - - if (size == NULL || *size < 0 || (*size && tbl == NULL)) { - errno = EINVAL; - return (-1); - } - bzero(&io, sizeof io); - io.pfrio_flags = flags; - if (filter != NULL) - io.pfrio_table = *filter; - io.pfrio_buffer = tbl; - io.pfrio_esize = sizeof(*tbl); - io.pfrio_size = *size; - if (ioctl(dev, DIOCRGETTSTATS, &io)) { - pfr_report_error(filter, &io, "get tstats for"); - return (-1); - } - *size = io.pfrio_size; - return (0); -} - -int pfr_clr_addrs(struct pfr_table *tbl, int *ndel, int flags) { struct pfioc_table io; @@ -260,29 +235,6 @@ pfr_clr_astats(struct pfr_table *tbl, struct pfr_addr *addr, int size, } int -pfr_clr_tstats(struct pfr_table *tbl, int size, int *nzero, int flags) -{ - struct pfioc_table io; - - if (size < 0 || (size && !tbl)) { - errno = EINVAL; - return (-1); - } - bzero(&io, sizeof io); - io.pfrio_flags = flags; - io.pfrio_buffer = tbl; - io.pfrio_esize = sizeof(*tbl); - io.pfrio_size = size; - if (ioctl(dev, DIOCRCLRTSTATS, &io)) { - pfr_report_error(tbl, &io, "clear tstats from"); - return (-1); - } - if (nzero) - *nzero = io.pfrio_nzero; - return (0); -} - -int pfr_tst_addrs(struct pfr_table *tbl, struct pfr_addr *addr, int size, int *nmatch, int flags) { diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c index 90e87adadb0f..834f74811ea2 100644 --- a/sbin/pfctl/pfctl_table.c +++ b/sbin/pfctl/pfctl_table.c @@ -57,8 +57,8 @@ extern void usage(void); static int pfctl_table(int, char *[], char *, const char *, char *, const char *, int); -static void print_table(struct pfr_table *, int, int); -static void print_tstats(struct pfr_tstats *, int); +static void print_table(const struct pfr_table *, int, int); +static int print_tstats(const struct pfr_tstats *, int); static int load_addr(struct pfr_buffer *, int, char *[], char *, int); static void print_addrx(struct pfr_addr *, struct pfr_addr *, int); static int nonzero_astats(struct pfr_astats *); @@ -165,28 +165,31 @@ pfctl_table(int argc, char *argv[], char *tname, const char *command, PFRB_TSTATS : PFRB_TABLES; if (argc || file != NULL) usage(); - for (;;) { - pfr_buf_grow(&b, b.pfrb_size); - b.pfrb_size = b.pfrb_msize; - if (opts & PF_OPT_VERBOSE2) - RVTEST(pfr_get_tstats(&table, - b.pfrb_caddr, &b.pfrb_size, flags)); - else - RVTEST(pfr_get_tables(&table, - b.pfrb_caddr, &b.pfrb_size, flags)); - if (b.pfrb_size <= b.pfrb_msize) - break; - } if ((opts & PF_OPT_SHOWALL) && b.pfrb_size > 0) pfctl_print_title("TABLES:"); - PFRB_FOREACH(p, &b) - if (opts & PF_OPT_VERBOSE2) - print_tstats(p, opts & PF_OPT_DEBUG); - else + if (opts & PF_OPT_VERBOSE2) { + uintptr_t arg = opts & PF_OPT_DEBUG; + pfctl_get_tstats(pfh, &table, + (pfctl_get_tstats_fn)print_tstats, (void *)arg); + } else { + for (;;) { + pfr_buf_grow(&b, b.pfrb_size); + b.pfrb_size = b.pfrb_msize; + RVTEST(pfr_get_tables(&table, + b.pfrb_caddr, &b.pfrb_size, flags)); + if (b.pfrb_size <= b.pfrb_msize) + break; + } + + if ((opts & PF_OPT_SHOWALL) && b.pfrb_size > 0) + pfctl_print_title("TABLES:"); + + PFRB_FOREACH(p, &b) print_table(p, opts & PF_OPT_VERBOSE, opts & PF_OPT_DEBUG); + } } else if (!strcmp(command, "kill")) { if (argc || file != NULL) usage(); @@ -393,7 +396,7 @@ pfctl_table(int argc, char *argv[], char *tname, const char *command, opts & PF_OPT_USEDNS); } else if (!strcmp(command, "zero")) { flags |= PFR_FLAG_ADDRSTOO; - RVTEST(pfr_clr_tstats(&table, 1, &nzero, flags)); + RVTEST(pfctl_clear_tstats(pfh, &table, &nzero, flags)); xprintf(opts, "%d table/stats cleared", nzero); } else warnx("pfctl_table: unknown command '%s'", command); @@ -408,7 +411,7 @@ _cleanup: } void -print_table(struct pfr_table *ta, int verbose, int debug) +print_table(const struct pfr_table *ta, int verbose, int debug) { if (!debug && !(ta->pfrt_flags & PFR_TFLAG_ACTIVE)) return; @@ -429,14 +432,14 @@ print_table(struct pfr_table *ta, int verbose, int debug) puts(ta->pfrt_name); } -void -print_tstats(struct pfr_tstats *ts, int debug) +int +print_tstats(const struct pfr_tstats *ts, int debug) { time_t time = ts->pfrts_tzero; int dir, op; if (!debug && !(ts->pfrts_flags & PFR_TFLAG_ACTIVE)) - return; + return (0); print_table(&ts->pfrts_t, 1, debug); printf("\tAddresses: %d\n", ts->pfrts_cnt); printf("\tCleared: %s", ctime(&time)); @@ -452,6 +455,8 @@ print_tstats(struct pfr_tstats *ts, int debug) stats_text[dir][op], (unsigned long long)ts->pfrts_packets[dir][op], (unsigned long long)ts->pfrts_bytes[dir][op]); + + return (0); } int diff --git a/secure/ssh.mk b/secure/ssh.mk index 8411fb11fb16..f522e1a927fc 100644 --- a/secure/ssh.mk +++ b/secure/ssh.mk @@ -24,3 +24,5 @@ CFLAGS+= -DLIBWRAP=1 # Built-in security key support CFLAGS+= -include sk_config.h .endif + +CFLAGS+= -DOPENSSL_API_COMPAT=0x10100000L diff --git a/share/man/man4/cd9660.4 b/share/man/man4/cd9660.4 index 0e4fd33637cb..a684df37bab9 100644 --- a/share/man/man4/cd9660.4 +++ b/share/man/man4/cd9660.4 @@ -1,4 +1,6 @@ .\" +.\" SPDX-License-Identifier: BSD-3-Clause +.\" .\" Copyright (c) 2017 Enji Cooper .\" .\" Redistribution and use in source and binary forms, with or without @@ -23,7 +25,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd April 25, 2023 +.Dd January 18, 2025 .Dt CD9660 4 .Os .Sh NAME @@ -57,6 +59,7 @@ volume located on .Pp .Dl "mount -t cd9660 /dev/cd0 /mnt" .Sh SEE ALSO +.Xr etdump 1 , .Xr nmount 2 , .Xr unmount 2 , .Xr cd 4 , diff --git a/share/man/man4/man4.aarch64/Makefile b/share/man/man4/man4.aarch64/Makefile index aca11eeb583f..0e85aab8b770 100644 --- a/share/man/man4/man4.aarch64/Makefile +++ b/share/man/man4/man4.aarch64/Makefile @@ -6,6 +6,7 @@ MAN= \ felix.4 \ rk_gpio.4 \ rk_grf.4 \ + rk_grf_gpio.4 \ rk_i2c.4 \ rk_pinctrl.4 \ diff --git a/share/man/man4/man4.aarch64/rk_grf_gpio.4 b/share/man/man4/man4.aarch64/rk_grf_gpio.4 new file mode 100644 index 000000000000..6a5ebbe19e3b --- /dev/null +++ b/share/man/man4/man4.aarch64/rk_grf_gpio.4 @@ -0,0 +1,42 @@ +.\" +.\" Copyright (c) 2025 Stephen Hurd <shurd@freebsd.org> +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" +.Dd March 18, 2025 +.Dt RK_GRF_GPIO 4 +.Os +.Sh NAME +.Nm rk_grf_gpio +.Nd RockChip GPIO_MUTE pin driver +.Sh SYNOPSIS +.Cd "options SOC_ROCKCHIP_rk3328" +.Sh DESCRIPTION +The +.Nm +driver provides a single-pin, output-only +.Xr gpio 3 +unit whose single pin is named GPIO_MUTE. +This controls the output of the GPIO_MUTE pin on the SoC. +.Pp +This gpio is usually used to control another device on the board, +so is not usually available for user software. +.Sh HARDWARE +The +.Nm +driver supports the following GRF GPIO controller: +.Pp +.Bl -bullet -compact +.It +rockchip,rk3328-grf-gpio +.El +.Sh HISTORY +The +.Nm +driver first appeared in +.Fx 15.0 . +.Sh AUTHORS +The +.Nm +driver and manual were written by +.An Stephen Hurd Aq Mt shurd@freebsd.org . diff --git a/share/man/man5/intro.5 b/share/man/man5/intro.5 index 78e147975e81..3e67b319da14 100644 --- a/share/man/man5/intro.5 +++ b/share/man/man5/intro.5 @@ -1,3 +1,6 @@ +.\" +.\" SPDX-License-Identifier: BSD-3-Clause +.\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -25,25 +28,41 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd February 16, 1997 +.Dd November 17, 2024 .Dt INTRO 5 .Os .Sh NAME .Nm intro -.Nd "introduction to file formats" +.Nd introduction to file formats .Sh DESCRIPTION -This section contains information about file formats. +This section contains information about the file formats +which comprise most data structures in the +.Bx +environment, including: +.Pp +.Bl -bullet -compact +.It +.Xr ascii 7 +configuration and resource files +.It +system binary file and stream structures +.It +composition of database files +.El .Sh FILES -.Bl -tag -width /etc/shells -compact -.It Pa /etc -location of most system configuration files +.Bl -tag -width "/usr/local/etc/" -compact +.It Pa /etc/ +base system software configuration files +.It Pa /usr/local/etc/ +locally installed software configuration files .El .Sh SEE ALSO .Xr apropos 1 , .Xr intro 1 , +.Xr hier 7 , .Xr intro 8 .Sh HISTORY The -.Nm -section manual page appeared in +.Nm Ns Pq 5 +manual page first appeared in .Fx 2.2 . diff --git a/share/man/man5/style.mdoc.5 b/share/man/man5/style.mdoc.5 index dd4d8a1f5fdf..d96c9ff08bbb 100644 --- a/share/man/man5/style.mdoc.5 +++ b/share/man/man5/style.mdoc.5 @@ -1,4 +1,4 @@ -.\"- +.\" .\" SPDX-License-Identifier: BSD-2-Clause .\" .\" Copyright (c) 2018-2022 Mateusz Piotrowski <0mp@FreeBSD.org> @@ -24,7 +24,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd December 12, 2024 +.Dd December 21, 2024 .Dt STYLE.MDOC 5 .Os .Sh NAME @@ -74,6 +74,33 @@ Historically, was the preferred way before the deprecation of .Sy \&Li . .El +.Ss HARDWARE Section +Driver manuals in section four should have a +.Sx HARDWARE +section describing hardware known to work with the driver. +This section is drawn verbatim into the Release Hardware Notes, +therefore there are several things to note: +.Bl -dash -width "" +.It +The introductory sentence should be in the form: +.Bd -literal -offset indent +The +\&.Nm +driver supports the following $device_class: +.Ed +.Pp +Followed by the list of supported hardware. +.Pp +This defines what driver the subsection is referring to, +and allows the reader to search through the Hardware Notes +not only for the device models they have, +but also for the device type they are looking to acquire. +.It +The supported hardware should be listed as a bullet list, +or if complexity requires, a column list. +These two list types create very neat subsections +with clean starting and stopping points. +.El .Ss EXAMPLES Section .Bl -dash -width "" .It diff --git a/share/man/man7/hier.7 b/share/man/man7/hier.7 index 949b521ab3d9..c5fb3cf0a7fb 100644 --- a/share/man/man7/hier.7 +++ b/share/man/man7/hier.7 @@ -156,6 +156,8 @@ file descriptor files; see .Xr fd 4 .It Pa fd0 first floppy drive +.It Pa gpt/ +filesystems by GPT label .It Pa mmcsd0 first SD storage device .It Pa mmcsd0s1 @@ -168,7 +170,7 @@ infinite loop that accepts anything and contains nothing .It Pa nvd0 first NVMe storage device using NVMe namespaces .It Pa pts/ -pseduo-terminals; see +pseudo-terminals; see .Xr pts 4 .It Pa random source of weak randomness; see diff --git a/share/man/man7/ports.7 b/share/man/man7/ports.7 index 1e924b291608..b681a326f407 100644 --- a/share/man/man7/ports.7 +++ b/share/man/man7/ports.7 @@ -1,4 +1,6 @@ .\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" .\" Copyright (c) 1997 David E. O'Brien .\" .\" All rights reserved. @@ -23,7 +25,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 24, 2023 +.Dd March 21, 2025 .Dt PORTS 7 .Os .Sh NAME @@ -163,7 +165,7 @@ target. Configure .Va OPTIONS for this port using -.Xr dialog4ports 1 . +.Xr portconfig 1 Pq Pa ports/ports-mgmt/portconfig . .It Cm fetch Fetch all of the files needed to build this port from the sites listed in @@ -245,7 +247,7 @@ configured. Configure .Va OPTIONS for this port and all its dependencies using -.Xr dialog4ports 1 . +.Xr portconfig 1 Pq Pa ports/ports-mgmt/portconfig . .It Cm fetch-list Show the list of files to fetch in order to build the port (but not its dependencies). diff --git a/stand/efi/Makefile.inc b/stand/efi/Makefile.inc index b5bd341d1b78..f91ac9102ca8 100644 --- a/stand/efi/Makefile.inc +++ b/stand/efi/Makefile.inc @@ -26,6 +26,7 @@ EFI_TARGET= efi-app-x86_64 .else EFI_TARGET= binary .endif +EFI_OBJCOPY?= elfcopy # Arbitrarily set the PE/COFF header timestamps to 1 Jan 2024 00:00:00 # for build reproducibility. diff --git a/stand/efi/boot1/Makefile b/stand/efi/boot1/Makefile index 8641ecf457ab..e2966e813504 100644 --- a/stand/efi/boot1/Makefile +++ b/stand/efi/boot1/Makefile @@ -96,7 +96,7 @@ ${BOOT1}.efi: ${PROG} exit 1; \ fi SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ - ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ + ${EFI_OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ -j .dynamic -j .dynsym -j .rel.dyn \ -j .rela.dyn -j .reloc -j .eh_frame \ --output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET} diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile index e9d29e5a219e..2dae035f04a8 100644 --- a/stand/efi/loader/Makefile +++ b/stand/efi/loader/Makefile @@ -128,7 +128,7 @@ ${LOADER}.efi: ${PROG} exit 1; \ fi SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} \ - ${OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ + ${EFI_OBJCOPY} -j .peheader -j .text -j .sdata -j .data \ -j .dynamic -j .dynsym -j .rel.dyn \ -j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \ -j set_X${LOADER_INTERP}_compile_set \ diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile index 857944dcd010..bb9111c3dcce 100644 --- a/stand/i386/loader/Makefile +++ b/stand/i386/loader/Makefile @@ -140,6 +140,10 @@ FILESMODE_${LOADER}= ${BINMODE} -b # files. LDFLAGS+= ${BTXCRT} +# Force the linker max page size to 4k so that we fit in the limited space even +# if someone has set a larger default linker max page size via /etc/src.conf. +LDFLAGS+= -Wl,-z,max-page-size=0x1000 + DPADD= ${LDR_INTERP32} ${LIBI386} ${LIBSA32} LDADD= ${LDR_INTERP32} ${LIBI386} ${LIBSA32} diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index 923574adf943..6921c1d73a58 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -283,6 +283,7 @@ options IEEE80211_DEBUG # enable debug msgs options IEEE80211_SUPPORT_MESH # enable 802.11s draft support device wlan_wep # 802.11 WEP support device wlan_ccmp # 802.11 CCMP support +device wlan_gcmp # 802.11 GCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm device ath # Atheros CardBus/PCI NICs diff --git a/sys/arm/arm/cpufunc_asm_arm11x6.S b/sys/arm/arm/cpufunc_asm_arm11x6.S deleted file mode 100644 index ded80290b3aa..000000000000 --- a/sys/arm/arm/cpufunc_asm_arm11x6.S +++ /dev/null @@ -1,86 +0,0 @@ -/* $NetBSD: cpufunc_asm_arm11x6.S,v 1.1 2012/07/21 12:19:15 skrll Exp $ */ - -/* - * Copyright (c) 2007 Microsoft - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Microsoft - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 CONTRIBUTERS 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. - */ - -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Eben Upton - * - * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <machine/asm.h> - .cpu arm1176jz-s - -/* - * Preload the cache before issuing the WFI by conditionally disabling the - * mcr intstructions the first time around the loop. Ensure the function is - * cacheline aligned. - */ - .arch armv6 - .p2align 5 - -ENTRY_NP(arm11x6_sleep) - mov r0, #0 - mov r1, #2 -1: - subs r1, #1 - nop - mcreq p15, 0, r0, c7, c10, 4 /* data sync barrier */ - mcreq p15, 0, r0, c7, c0, 4 /* wait for interrupt */ - nop - nop - nop - bne 1b - RET -END(arm11x6_sleep) diff --git a/sys/arm/conf/TEGRA124 b/sys/arm/conf/TEGRA124 index 058a85955a04..ad5532427eda 100644 --- a/sys/arm/conf/TEGRA124 +++ b/sys/arm/conf/TEGRA124 @@ -108,6 +108,7 @@ device ums # USB mouse #device wlan # 802.11 support #device wlan_wep # 802.11 WEP support #device wlan_ccmp # 802.11 CCMP support +#device wlan_gcmp # 802.11 GCMP support #device wlan_tkip # 802.11 TKIP support #device wlan_amrr # AMRR transmit rate control algorithm diff --git a/sys/arm/rockchip/files.rk32xx b/sys/arm/rockchip/files.rk32xx index 7331b12a06ed..2faee11b0b6a 100644 --- a/sys/arm/rockchip/files.rk32xx +++ b/sys/arm/rockchip/files.rk32xx @@ -6,6 +6,7 @@ dev/iicbus/controller/rockchip/rk_i2c.c standard arm64/rockchip/rk_iodomain.c standard arm64/rockchip/rk_gpio.c standard arm64/rockchip/rk_grf.c standard +arm64/rockchip/rk_grf_gpio.c standard arm64/rockchip/rk_pinctrl.c standard arm64/rockchip/rk_pmu.c standard dev/pwm/controller/rockchip/rk_pwm.c standard diff --git a/sys/arm64/rockchip/rk_grf_gpio.c b/sys/arm64/rockchip/rk_grf_gpio.c new file mode 100644 index 000000000000..6818bd85bb95 --- /dev/null +++ b/sys/arm64/rockchip/rk_grf_gpio.c @@ -0,0 +1,236 @@ +/* + * Copyright (c) 2025 Stephen Hurd <shurd@FreeBSD.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <sys/param.h> +#include <sys/bus.h> +#include <sys/gpio.h> +#include <sys/kernel.h> +#include <sys/module.h> + +#include <dev/ofw/openfirm.h> +#include <dev/ofw/ofw_bus.h> +#include <dev/ofw/ofw_bus_subr.h> + +#include <dev/gpio/gpiobusvar.h> +#include <dev/syscon/syscon.h> + +#include "syscon_if.h" + +#define GRF_SOC_CON10 0x0428 +#define SOC_CON10_GPIOMUT (1 << 1) +#define SOC_CON10_GPIOMUT_MASK ((1 << 1) << 16) +#define SOC_CON10_GPIOMUT_EN (1 << 0) +#define SOC_CON10_GPIOMUT_EN_MASK ((1 << 0) << 16) + +struct rk_grf_gpio_softc { + device_t sc_dev; + device_t sc_busdev; + struct syscon *sc_grf; + bool active_high; +}; + +static struct ofw_compat_data compat_data[] = { + {"rockchip,rk3328-grf-gpio", 1}, + {NULL, 0} +}; + +static device_t +rk_grf_gpio_get_bus(device_t dev) +{ + struct rk_grf_gpio_softc *sc; + + sc = device_get_softc(dev); + + return (sc->sc_busdev); +} + +static int +rk_grf_gpio_pin_max(device_t dev, int *maxpin) +{ + *maxpin = 1; + return (0); +} + +static int +rk_grf_gpio_pin_getname(device_t dev, uint32_t pin, char *name) +{ + if (pin) + return (EINVAL); + + snprintf(name, GPIOMAXNAME, "GPIO_MUTE"); + + return (0); +} + +static int +rk_grf_gpio_pin_getflags(device_t dev, uint32_t pin, uint32_t *flags) +{ + if (pin) + return (EINVAL); + *flags = GPIO_PIN_OUTPUT; + return (0); +} + +static int +rk_grf_gpio_pin_setflags(device_t dev, uint32_t pin, uint32_t flags) +{ + if (pin) + return (EINVAL); + if (flags != GPIO_PIN_OUTPUT) + return (EINVAL); + + return (0); +} + +static int +rk_grf_gpio_pin_getcaps(device_t dev, uint32_t pin, uint32_t *caps) +{ + if (pin) + return (EINVAL); + + *caps = GPIO_PIN_OUTPUT; + return (0); +} + +static int +rk_grf_gpio_pin_get(device_t dev, uint32_t pin, unsigned int *val) +{ + struct rk_grf_gpio_softc *sc; + uint32_t reg; + + sc = device_get_softc(dev); + + if (pin) + return (EINVAL); + + reg = SYSCON_READ_4(sc->sc_grf, GRF_SOC_CON10); + if (reg & SOC_CON10_GPIOMUT) + *val = 1; + else + *val = 0; + + return (0); +} + +static int +rk_grf_gpio_pin_set(device_t dev, uint32_t pin, unsigned int value) +{ + struct rk_grf_gpio_softc *sc; + uint32_t val; + + sc = device_get_softc(dev); + + if (pin) + return (EINVAL); + + val = SOC_CON10_GPIOMUT_MASK; + if (value) + val |= SOC_CON10_GPIOMUT; + SYSCON_WRITE_4(sc->sc_grf, GRF_SOC_CON10, val); + + return (0); +} + +static int +rk_grf_gpio_map_gpios(device_t bus, phandle_t dev, phandle_t gparent, int gcells, + pcell_t *gpios, uint32_t *pin, uint32_t *flags) +{ + if (gpios[0]) + return (EINVAL); + + /* The gpios are mapped as <pin flags> */ + *pin = 0; + /* TODO: The only valid flags are active low or active high */ + *flags = GPIO_PIN_OUTPUT; + return (0); +} + +static int +rk_grf_gpio_probe(device_t dev) +{ + + if (!ofw_bus_status_okay(dev)) + return (ENXIO); + if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0) + return (ENXIO); + + device_set_desc(dev, "RockChip General Register File GPIO (GPIO_MUTE)"); + return (BUS_PROBE_DEFAULT); +} + +static int +rk_grf_gpio_attach(device_t dev) +{ + struct rk_grf_gpio_softc *sc; + phandle_t parent_node, node; + device_t pdev; + + sc = device_get_softc(dev); + sc->sc_dev = dev; + + node = ofw_bus_get_node(sc->sc_dev); + if (!OF_hasprop(node, "gpio-controller")) + return (ENXIO); + pdev = device_get_parent(dev); + parent_node = ofw_bus_get_node(pdev); + if (syscon_get_by_ofw_node(dev, parent_node, &sc->sc_grf) != 0) { + device_printf(dev, "cannot get parent syscon handle\n"); + return (ENXIO); + } + + sc->sc_busdev = gpiobus_attach_bus(dev); + if (sc->sc_busdev == NULL) { + return (ENXIO); + } + + return (0); +} + +static int +rk_grf_gpio_detach(device_t dev) +{ + struct rk_grf_gpio_softc *sc; + + sc = device_get_softc(dev); + + if (sc->sc_busdev) + gpiobus_detach_bus(dev); + + return(0); +} + +static device_method_t rk_grf_gpio_methods[] = { + DEVMETHOD(device_probe, rk_grf_gpio_probe), + DEVMETHOD(device_attach, rk_grf_gpio_attach), + DEVMETHOD(device_detach, rk_grf_gpio_detach), + + /* GPIO protocol */ + DEVMETHOD(gpio_get_bus, rk_grf_gpio_get_bus), + DEVMETHOD(gpio_pin_max, rk_grf_gpio_pin_max), + DEVMETHOD(gpio_pin_getname, rk_grf_gpio_pin_getname), + DEVMETHOD(gpio_pin_getflags, rk_grf_gpio_pin_getflags), + DEVMETHOD(gpio_pin_setflags, rk_grf_gpio_pin_setflags), + DEVMETHOD(gpio_pin_getcaps, rk_grf_gpio_pin_getcaps), + DEVMETHOD(gpio_pin_get, rk_grf_gpio_pin_get), + DEVMETHOD(gpio_pin_set, rk_grf_gpio_pin_set), + DEVMETHOD(gpio_map_gpios, rk_grf_gpio_map_gpios), + + DEVMETHOD_END +}; + +static driver_t rk_grf_gpio_driver = { + "gpio", + rk_grf_gpio_methods, + sizeof(struct rk_grf_gpio_softc), +}; + +/* + * GPIO driver is always a child of rk_grf driver and should be probed + * and attached within rk_grf function. Due to this, bus pass order + * must be same as bus pass order of rk_grf driver. + */ +EARLY_DRIVER_MODULE(rk_grf_gpio, simplebus, rk_grf_gpio_driver, 0, 0, + BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE); diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h index 3dbf1b5a876d..3b45d291c70a 100644 --- a/sys/compat/freebsd32/freebsd32.h +++ b/sys/compat/freebsd32/freebsd32.h @@ -446,6 +446,27 @@ struct kinfo_vm_layout32 { uint32_t kvm_spare[12]; }; +#if defined(_WANT_KEVENT32) || defined(_KERNEL) +struct kinfo_knote32 { + int knt_kq_fd; + struct kevent32 knt_event; + int knt_status; + int knt_extdata; + uint32_t knt_spare0[8]; + union { + struct { + int knt_vnode_type; + uint32_t knt_vnode_fsid[2]; + uint32_t knt_vnode_fileid[2]; + char knt_vnode_fullpath[PATH_MAX]; + } knt_vnode; + struct { + uint32_t knt_pipe_ino[2]; + } knt_pipe; + }; +}; +#endif + struct kld_file_stat_1_32 { int version; /* set to sizeof(struct kld_file_stat_1) */ char name[MAXPATHLEN]; diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index e5b2b0feeafd..e10f5782c10f 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -679,6 +679,86 @@ freebsd32_pselect(struct thread *td, struct freebsd32_pselect_args *uap) return (error); } +static void +freebsd32_kevent_to_kevent32(const struct kevent *kevp, struct kevent32 *ks32) +{ + uint64_t e; + int j; + + CP(*kevp, *ks32, ident); + CP(*kevp, *ks32, filter); + CP(*kevp, *ks32, flags); + CP(*kevp, *ks32, fflags); +#if BYTE_ORDER == LITTLE_ENDIAN + ks32->data1 = kevp->data; + ks32->data2 = kevp->data >> 32; +#else + ks32->data1 = kevp->data >> 32; + ks32->data2 = kevp->data; +#endif + PTROUT_CP(*kevp, *ks32, udata); + for (j = 0; j < nitems(kevp->ext); j++) { + e = kevp->ext[j]; +#if BYTE_ORDER == LITTLE_ENDIAN + ks32->ext64[2 * j] = e; + ks32->ext64[2 * j + 1] = e >> 32; +#else + ks32->ext64[2 * j] = e >> 32; + ks32->ext64[2 * j + 1] = e; +#endif + } +} + +void +freebsd32_kinfo_knote_to_32(const struct kinfo_knote *kin, + struct kinfo_knote32 *kin32) +{ + memset(kin32, 0, sizeof(*kin32)); + CP(*kin, *kin32, knt_kq_fd); + freebsd32_kevent_to_kevent32(&kin->knt_event, &kin32->knt_event); + CP(*kin, *kin32, knt_status); + CP(*kin, *kin32, knt_extdata); + switch (kin->knt_extdata) { + case KNOTE_EXTDATA_NONE: + break; + case KNOTE_EXTDATA_VNODE: + CP(*kin, *kin32, knt_vnode.knt_vnode_type); +#if BYTE_ORDER == LITTLE_ENDIAN + kin32->knt_vnode.knt_vnode_fsid[0] = kin->knt_vnode. + knt_vnode_fsid; + kin32->knt_vnode.knt_vnode_fsid[1] = kin->knt_vnode. + knt_vnode_fsid >> 32; + kin32->knt_vnode.knt_vnode_fileid[0] = kin->knt_vnode. + knt_vnode_fileid; + kin32->knt_vnode.knt_vnode_fileid[1] = kin->knt_vnode. + knt_vnode_fileid >> 32; +#else + kin32->knt_vnode.knt_vnode_fsid[1] = kin->knt_vnode. + knt_vnode_fsid; + kin32->knt_vnode.knt_vnode_fsid[0] = kin->knt_vnode. + knt_vnode_fsid >> 32; + kin32->knt_vnode.knt_vnode_fileid[1] = kin->knt_vnode. + knt_vnode_fileid; + kin32->knt_vnode.knt_vnode_fileid[0] = kin->knt_vnode. + knt_vnode_fileid >> 32; +#endif + memcpy(kin32->knt_vnode.knt_vnode_fullpath, + kin->knt_vnode.knt_vnode_fullpath, PATH_MAX); + break; + case KNOTE_EXTDATA_PIPE: +#if BYTE_ORDER == LITTLE_ENDIAN + kin32->knt_pipe.knt_pipe_ino[0] = kin->knt_pipe.knt_pipe_ino; + kin32->knt_pipe.knt_pipe_ino[1] = kin->knt_pipe. + knt_pipe_ino >> 32; +#else + kin32->knt_pipe.knt_pipe_ino[1] = kin->knt_pipe.knt_pipe_ino; + kin32->knt_pipe.knt_pipe_ino[0] = kin->knt_pipe. + knt_pipe_ino >> 32; +#endif + break; + } +} + /* * Copy 'count' items into the destination list pointed to by uap->eventlist. */ @@ -687,36 +767,13 @@ freebsd32_kevent_copyout(void *arg, struct kevent *kevp, int count) { struct freebsd32_kevent_args *uap; struct kevent32 ks32[KQ_NEVENTS]; - uint64_t e; - int i, j, error; + int i, error; KASSERT(count <= KQ_NEVENTS, ("count (%d) > KQ_NEVENTS", count)); uap = (struct freebsd32_kevent_args *)arg; - for (i = 0; i < count; i++) { - CP(kevp[i], ks32[i], ident); - CP(kevp[i], ks32[i], filter); - CP(kevp[i], ks32[i], flags); - CP(kevp[i], ks32[i], fflags); -#if BYTE_ORDER == LITTLE_ENDIAN - ks32[i].data1 = kevp[i].data; - ks32[i].data2 = kevp[i].data >> 32; -#else - ks32[i].data1 = kevp[i].data >> 32; - ks32[i].data2 = kevp[i].data; -#endif - PTROUT_CP(kevp[i], ks32[i], udata); - for (j = 0; j < nitems(kevp->ext); j++) { - e = kevp[i].ext[j]; -#if BYTE_ORDER == LITTLE_ENDIAN - ks32[i].ext64[2 * j] = e; - ks32[i].ext64[2 * j + 1] = e >> 32; -#else - ks32[i].ext64[2 * j] = e >> 32; - ks32[i].ext64[2 * j + 1] = e; -#endif - } - } + for (i = 0; i < count; i++) + freebsd32_kevent_to_kevent32(&kevp[i], &ks32[i]); error = copyout(ks32, uap->eventlist, count * sizeof *ks32); if (error == 0) uap->eventlist += count; diff --git a/sys/compat/freebsd32/freebsd32_util.h b/sys/compat/freebsd32/freebsd32_util.h index dca61da714f0..4ac314f4391e 100644 --- a/sys/compat/freebsd32/freebsd32_util.h +++ b/sys/compat/freebsd32/freebsd32_util.h @@ -122,6 +122,11 @@ struct image_args; int freebsd32_exec_copyin_args(struct image_args *args, const char *fname, enum uio_seg segflg, uint32_t *argv, uint32_t *envv); +struct kinfo_knote; +struct kinfo_knote32; +void freebsd32_kinfo_knote_to_32(const struct kinfo_knote *kin, + struct kinfo_knote32 *kin32); + extern int compat_freebsd_32bit; #endif /* !_COMPAT_FREEBSD32_FREEBSD32_UTIL_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/cpufeature.h b/sys/compat/linuxkpi/common/include/linux/cpufeature.h new file mode 100644 index 000000000000..746d1a7164a8 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/cpufeature.h @@ -0,0 +1,43 @@ +/*- + * Copyright (c) 2025 The FreeBSD Foundation + * Copyright (c) 2025 Jean-Sébastien Pédron + * + * This software was developed by Jean-Sébastien Pédron under sponsorship + * from the FreeBSD Foundation. + * + * 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. + */ + +#ifndef _LINUXKPI_LINUX_CPUFEATURE_H_ +#define _LINUXKPI_LINUX_CPUFEATURE_H_ + +/* + * Linux includes the following header. We don't have it on FreeBSD yet, so + * let's comment this include for now. It is still referenced here because + * sometimes, consumers of headers rely voluntarily or not on the namespace + * pollution. + */ +/* #include <linux/init.h> */ +#include <linux/mod_devicetable.h> +#include <asm/cpufeature.h> + +#endif /* _LINUXKPI_LINUX_CPUFEATURE_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/gfp.h b/sys/compat/linuxkpi/common/include/linux/gfp.h index bd8fa1a18372..35dbe3e2a436 100644 --- a/sys/compat/linuxkpi/common/include/linux/gfp.h +++ b/sys/compat/linuxkpi/common/include/linux/gfp.h @@ -43,7 +43,6 @@ #define __GFP_NOWARN 0 #define __GFP_HIGHMEM 0 #define __GFP_ZERO M_ZERO -#define __GFP_NORETRY 0 #define __GFP_NOMEMALLOC 0 #define __GFP_RECLAIM 0 #define __GFP_RECLAIMABLE 0 @@ -57,7 +56,8 @@ #define __GFP_KSWAPD_RECLAIM 0 #define __GFP_WAIT M_WAITOK #define __GFP_DMA32 (1U << 24) /* LinuxKPI only */ -#define __GFP_BITS_SHIFT 25 +#define __GFP_NORETRY (1U << 25) /* LinuxKPI only */ +#define __GFP_BITS_SHIFT 26 #define __GFP_BITS_MASK ((1 << __GFP_BITS_SHIFT) - 1) #define __GFP_NOFAIL M_WAITOK diff --git a/sys/compat/linuxkpi/common/include/linux/ieee80211.h b/sys/compat/linuxkpi/common/include/linux/ieee80211.h index 964fd970ecf0..efac2a26e27e 100644 --- a/sys/compat/linuxkpi/common/include/linux/ieee80211.h +++ b/sys/compat/linuxkpi/common/include/linux/ieee80211.h @@ -147,6 +147,7 @@ enum ieee80211_key_len { WLAN_KEY_LEN_WEP104 = 13, WLAN_KEY_LEN_TKIP = 32, WLAN_KEY_LEN_CCMP = 16, + WLAN_KEY_LEN_CCMP_256 = 32, WLAN_KEY_LEN_GCMP = 16, WLAN_KEY_LEN_AES_CMAC = 16, WLAN_KEY_LEN_GCMP_256 = 32, @@ -507,6 +508,12 @@ struct ieee80211_mgmt { uint16_t capab_info; uint8_t variable[0]; } beacon; + /* 9.3.3.5 Association Request frame format */ + struct { + uint16_t capab_info; + uint16_t listen_interval; + uint8_t variable[0]; + } assoc_req; /* 9.3.3.10 Probe Request frame format */ struct { uint8_t variable[0]; diff --git a/sys/compat/linuxkpi/common/include/linux/list.h b/sys/compat/linuxkpi/common/include/linux/list.h index eecb517d780e..a6c74a324dac 100644 --- a/sys/compat/linuxkpi/common/include/linux/list.h +++ b/sys/compat/linuxkpi/common/include/linux/list.h @@ -234,6 +234,11 @@ list_del_init(struct list_head *entry) for (; &p->field != (h); \ p = list_prev_entry(p, field)) +#define list_for_each_rcu(p, head) \ + for (p = rcu_dereference((head)->next); \ + p != (head); \ + p = rcu_dereference((p)->next)) + static inline void list_add(struct list_head *new, struct list_head *head) { diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 31475d6dc7c3..afd6c827b3b4 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -116,6 +116,10 @@ MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice", \ #define PCI_COMMAND PCIR_COMMAND #define PCI_COMMAND_INTX_DISABLE PCIM_CMD_INTxDIS #define PCI_COMMAND_MEMORY PCIM_CMD_MEMEN +#define PCI_PRIMARY_BUS PCIR_PRIBUS_1 +#define PCI_SECONDARY_BUS PCIR_SECBUS_1 +#define PCI_SUBORDINATE_BUS PCIR_SUBBUS_1 +#define PCI_SEC_LATENCY_TIMER PCIR_SECLAT_1 #define PCI_EXP_DEVCTL PCIER_DEVICE_CTL /* Device Control */ #define PCI_EXP_LNKCTL PCIER_LINK_CTL /* Link Control */ #define PCI_EXP_LNKCTL_ASPM_L0S PCIEM_LINK_CTL_ASPMC_L0S @@ -226,6 +230,8 @@ typedef int pci_power_t; extern const char *pci_power_names[6]; +#define PCI_ERR_UNCOR_STATUS PCIR_AER_UC_STATUS +#define PCI_ERR_COR_STATUS PCIR_AER_COR_STATUS #define PCI_ERR_ROOT_COMMAND PCIR_AER_ROOTERR_CMD #define PCI_ERR_ROOT_ERR_SRC PCIR_AER_COR_SOURCE_ID diff --git a/sys/compat/linuxkpi/common/include/linux/string.h b/sys/compat/linuxkpi/common/include/linux/string.h index 32470312b78b..f7b64560d254 100644 --- a/sys/compat/linuxkpi/common/include/linux/string.h +++ b/sys/compat/linuxkpi/common/include/linux/string.h @@ -161,6 +161,24 @@ skip_spaces(const char *str) return (__DECONST(char *, str)); } +/* + * This function trims whitespaces at the end of a string and returns a pointer + * to the first non-whitespace character. + */ +static inline char * +strim(char *str) +{ + char *end; + + end = str + strlen(str); + while (end >= str && (*end == '\0' || isspace(*end))) { + *end = '\0'; + end--; + } + + return (skip_spaces(str)); +} + static inline void * memchr_inv(const void *start, int c, size_t length) { diff --git a/sys/compat/linuxkpi/common/include/linux/units.h b/sys/compat/linuxkpi/common/include/linux/units.h new file mode 100644 index 000000000000..304b5c27d87f --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/units.h @@ -0,0 +1,40 @@ +/*- + * Copyright (c) 2025 The FreeBSD Foundation + * Copyright (c) 2025 Jean-Sébastien Pédron + * + * This software was developed by Jean-Sébastien Pédron under sponsorship + * from the FreeBSD Foundation. + * + * 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. + */ + +#ifndef _LINUXKPI_LINUX_UNITS_H_ +#define _LINUXKPI_LINUX_UNITS_H_ + +#define NANOHZ_PER_HZ 1000000000UL +#define MICROHZ_PER_HZ 1000000UL +#define MILLIHZ_PER_HZ 1000UL +#define HZ_PER_KHZ 1000UL +#define KHZ_PER_MHZ 1000UL +#define HZ_PER_MHZ 1000000UL + +#endif /* _LINUXKPI_LINUX_UNITS_H_ */ diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h b/sys/compat/linuxkpi/common/include/net/cfg80211.h index 3454b58f1db7..2cdb96ffccdf 100644 --- a/sys/compat/linuxkpi/common/include/net/cfg80211.h +++ b/sys/compat/linuxkpi/common/include/net/cfg80211.h @@ -1033,9 +1033,12 @@ struct cfg80211_wowlan_nd_info { enum wiphy_wowlan_support_flags { WIPHY_WOWLAN_DISCONNECT, - WIPHY_WOWLAN_GTK_REKEY_FAILURE, WIPHY_WOWLAN_MAGIC_PKT, WIPHY_WOWLAN_SUPPORTS_GTK_REKEY, + WIPHY_WOWLAN_GTK_REKEY_FAILURE, + WIPHY_WOWLAN_EAP_IDENTITY_REQ, + WIPHY_WOWLAN_4WAY_HANDSHAKE, + WIPHY_WOWLAN_RFKILL_RELEASE, WIPHY_WOWLAN_NET_DETECT, }; @@ -1049,6 +1052,7 @@ struct cfg80211_wowlan_wakeup { /* XXX TODO */ uint16_t pattern_idx; bool disconnect; + bool unprot_deauth_disassoc; bool eap_identity_req; bool four_way_handshake; bool gtk_rekey_failure; @@ -1066,11 +1070,22 @@ struct cfg80211_wowlan_wakeup { struct cfg80211_wowlan { /* XXX TODO */ - int disconnect, gtk_rekey_failure, magic_pkt; - int eap_identity_req, four_way_handshake, rfkill_release, tcp, any; + bool any; + bool disconnect; + bool magic_pkt; + bool gtk_rekey_failure; + bool eap_identity_req; + bool four_way_handshake; + bool rfkill_release; + + /* Magic packet patterns. */ int n_patterns; - struct cfg80211_sched_scan_request *nd_config; struct cfg80211_pkt_pattern *patterns; + + /* netdetect? if not assoc? */ + struct cfg80211_sched_scan_request *nd_config; + + void *tcp; /* XXX ? */ }; struct cfg80211_gtk_rekey_data { @@ -1244,7 +1259,8 @@ struct wiphy { unsigned long ext_features[BITS_TO_LONGS(NUM_NL80211_EXT_FEATURES)]; struct dentry *debugfsdir; - struct cfg80211_wowlan_support *wowlan; + const struct wiphy_wowlan_support *wowlan; + struct cfg80211_wowlan *wowlan_config; /* Lower layer (driver/mac80211) specific data. */ /* Must stay last. */ uint8_t priv[0] __aligned(CACHE_LINE_SIZE); diff --git a/sys/compat/linuxkpi/common/include/net/mac80211.h b/sys/compat/linuxkpi/common/include/net/mac80211.h index 4dc1aaccb886..9830d8f16d05 100644 --- a/sys/compat/linuxkpi/common/include/net/mac80211.h +++ b/sys/compat/linuxkpi/common/include/net/mac80211.h @@ -42,6 +42,7 @@ #include <linux/workqueue.h> #include <linux/dcache.h> #include <net/cfg80211.h> +#include <net/if_inet6.h> #define ARPHRD_IEEE80211_RADIOTAP __LINE__ /* XXX TODO brcmfmac */ @@ -1089,9 +1090,7 @@ struct ieee80211_ops { int (*set_tim)(struct ieee80211_hw *, struct ieee80211_sta *, bool); int (*set_key)(struct ieee80211_hw *, enum set_key_cmd, struct ieee80211_vif *, struct ieee80211_sta *, struct ieee80211_key_conf *); - void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int); void (*update_tkip_key)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_key_conf *, struct ieee80211_sta *, u32, u16 *); - void (*set_rekey_data)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_gtk_rekey_data *); int (*start_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *); void (*abort_pmsr)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_pmsr_request *); @@ -1135,9 +1134,18 @@ struct ieee80211_ops { void (*link_sta_add_debugfs)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_link_sta *, struct dentry *); void (*link_add_debugfs)(struct ieee80211_hw *, struct ieee80211_vif *, struct ieee80211_bss_conf *, struct dentry *); /* #endif */ +/* #ifdef CONFIG_PM_SLEEP */ /* Do not change depending on compile-time option. */ + int (*suspend)(struct ieee80211_hw *, struct cfg80211_wowlan *); + int (*resume)(struct ieee80211_hw *); + void (*set_wakeup)(struct ieee80211_hw *, bool); + void (*set_rekey_data)(struct ieee80211_hw *, struct ieee80211_vif *, struct cfg80211_gtk_rekey_data *); + void (*set_default_unicast_key)(struct ieee80211_hw *, struct ieee80211_vif *, int); +/* #if IS_ENABLED(CONFIG_IPV6) */ + void (*ipv6_addr_change)(struct ieee80211_hw *, struct ieee80211_vif *, struct inet6_dev *); +/* #endif */ +/* #endif CONFIG_PM_SLEEP */ }; - /* -------------------------------------------------------------------------- */ /* linux_80211.c */ @@ -2425,7 +2433,7 @@ ieee80211_get_tkip_p1k_iv(struct ieee80211_key_conf *key, static __inline struct ieee80211_key_conf * ieee80211_gtk_rekey_add(struct ieee80211_vif *vif, - struct ieee80211_key_conf *key) + struct ieee80211_key_conf *key, int link_id) { TODO(); return (NULL); diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c index bece8c954bfd..b5a0d34a6ad7 100644 --- a/sys/compat/linuxkpi/common/src/linux_page.c +++ b/sys/compat/linuxkpi/common/src/linux_page.c @@ -117,7 +117,8 @@ linux_alloc_pages(gfp_t flags, unsigned int order) page = vm_page_alloc_noobj_contig(req, npages, 0, pmax, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT); if (page == NULL) { - if (flags & M_WAITOK) { + if ((flags & (M_WAITOK | __GFP_NORETRY)) == + M_WAITOK) { int err = vm_page_reclaim_contig(req, npages, 0, pmax, PAGE_SIZE, 0); if (err == ENOMEM) diff --git a/sys/conf/NOTES b/sys/conf/NOTES index aedb89e49b67..fc32acd681b3 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -889,10 +889,11 @@ options IEEE80211_SUPPORT_MESH #enable 802.11s D3.0 support options IEEE80211_SUPPORT_TDMA #enable TDMA support # The `wlan_wep', `wlan_tkip', and `wlan_ccmp' devices provide -# support for WEP, TKIP, and AES-CCMP crypto protocols optionally +# support for WEP, TKIP, AES-CCMP and AES-GCMP crypto protocols optionally # used with 802.11 devices that depend on the `wlan' module. device wlan_wep device wlan_ccmp +device wlan_gcmp device wlan_tkip # The `wlan_xauth' device provides support for external (i.e. user-mode) diff --git a/sys/conf/files.arm b/sys/conf/files.arm index 0188dda87c96..91b01845519e 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -10,7 +10,6 @@ arm/arm/busdma_machdep.c standard arm/arm/copystr.S standard arm/arm/cpufunc.c standard arm/arm/cpufunc_asm.S standard -arm/arm/cpufunc_asm_arm11x6.S optional cpu_arm1176 arm/arm/cpufunc_asm_armv7.S optional cpu_cortexa | cpu_krait | cpu_mv_pj4b arm/arm/cpufunc_asm_pj4b.S optional cpu_mv_pj4b arm/arm/cpuinfo.c standard diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 index de3134ad9124..480f1ac78905 100644 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -735,6 +735,7 @@ dev/iicbus/pmic/rockchip/rk805.c optional fdt rk805 soc_rockchip_rk3328 dev/iicbus/pmic/rockchip/rk808.c optional fdt rk808 soc_rockchip_rk3399 dev/iicbus/pmic/rockchip/rk817.c optional fdt rk817 soc_rockchip_rk3568 arm64/rockchip/rk_grf.c optional fdt soc_rockchip +arm64/rockchip/rk_grf_gpio.c optional fdt soc_rockchip arm64/rockchip/rk_pinctrl.c optional fdt rk_pinctrl soc_rockchip arm64/rockchip/rk_gpio.c optional fdt rk_gpio soc_rockchip arm64/rockchip/rk_iodomain.c optional fdt rk_iodomain diff --git a/sys/conf/options.arm b/sys/conf/options.arm index 6d15daebe851..49a317bb02b4 100644 --- a/sys/conf/options.arm +++ b/sys/conf/options.arm @@ -1,6 +1,5 @@ ARM_FORCE_DBG_MONITOR_DISABLE opt_ddb.h CPSW_ETHERSWITCH opt_cpsw.h -CPU_ARM1176 opt_global.h CPU_CORTEXA opt_global.h CPU_KRAIT opt_global.h CPU_MV_PJ4B opt_global.h diff --git a/sys/dev/cxgbe/firmware/t4fw_interface.h b/sys/dev/cxgbe/firmware/t4fw_interface.h index 686bb55d658b..2794bae9474b 100644 --- a/sys/dev/cxgbe/firmware/t4fw_interface.h +++ b/sys/dev/cxgbe/firmware/t4fw_interface.h @@ -7820,6 +7820,8 @@ enum fw_port_module_type { FW_PORT_MOD_TYPE_TWINAX_PASSIVE = 0x4, FW_PORT_MOD_TYPE_TWINAX_ACTIVE = 0x5, FW_PORT_MOD_TYPE_LRM = 0x6, + FW_PORT_MOD_TYPE_LR_SIMPLEX = 0x7, + FW_PORT_MOD_TYPE_DR = 0x8, FW_PORT_MOD_TYPE_ERROR = M_FW_PORT_CMD_MODTYPE - 3, FW_PORT_MOD_TYPE_UNKNOWN = M_FW_PORT_CMD_MODTYPE - 2, FW_PORT_MOD_TYPE_NOTSUPPORTED = M_FW_PORT_CMD_MODTYPE - 1, diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 20df6a97aa87..9e91250cb61c 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -3537,6 +3537,7 @@ port_mword(struct port_info *pi, uint32_t speed) /* Pluggable transceiver */ switch (pi->mod_type) { case FW_PORT_MOD_TYPE_LR: + case FW_PORT_MOD_TYPE_LR_SIMPLEX: switch (speed) { case FW_PORT_CAP32_SPEED_1G: return (IFM_1000_LX); @@ -3593,6 +3594,10 @@ port_mword(struct port_info *pi, uint32_t speed) if (speed == FW_PORT_CAP32_SPEED_10G) return (IFM_10G_LRM); break; + case FW_PORT_MOD_TYPE_DR: + if (speed == FW_PORT_CAP32_SPEED_100G) + return (IFM_100G_DR); + break; case FW_PORT_MOD_TYPE_NA: MPASS(0); /* Not pluggable? */ /* fall throough */ @@ -12210,7 +12215,8 @@ t4_os_portmod_changed(struct port_info *pi) struct vi_info *vi; if_t ifp; static const char *mod_str[] = { - NULL, "LR", "SR", "ER", "TWINAX", "active TWINAX", "LRM" + NULL, "LR", "SR", "ER", "TWINAX", "active TWINAX", "LRM", + "LR_SIMPLEX", "DR" }; KASSERT((pi->flags & FIXED_IFMEDIA) == 0, diff --git a/sys/dev/mmc/host/dwmmc_rockchip.c b/sys/dev/mmc/host/dwmmc_rockchip.c index c4b07ac3290e..656e9a9cf09d 100644 --- a/sys/dev/mmc/host/dwmmc_rockchip.c +++ b/sys/dev/mmc/host/dwmmc_rockchip.c @@ -78,6 +78,7 @@ rockchip_dwmmc_attach(device_t dev) { struct dwmmc_softc *sc; int type; + int rc; sc = device_get_softc(dev); sc->hwtype = HWTYPE_ROCKCHIP; @@ -90,8 +91,17 @@ rockchip_dwmmc_attach(device_t dev) } sc->update_ios = &dwmmc_rockchip_update_ios; + rc = dwmmc_attach(dev); - return (dwmmc_attach(dev)); + /* + * Note: It's not that the controller doesn't support HS200, + * it's that FreeBSD doesn't support tuning. + * If someone implemented tuning, this could work. + */ + device_printf(dev, "Disabling HS200+ (tuning code not written)\n"); + sc->host.caps &= ~(MMC_CAP_MMC_HS200 | MMC_CAP_MMC_HS400); + + return (rc); } static int diff --git a/sys/dev/rtwn/if_rtwn.c b/sys/dev/rtwn/if_rtwn.c index 2003fa7d20be..7df1b78db37b 100644 --- a/sys/dev/rtwn/if_rtwn.c +++ b/sys/dev/rtwn/if_rtwn.c @@ -298,6 +298,11 @@ rtwn_attach(struct rtwn_softc *sc) sc->sc_node_free = ic->ic_node_free; ic->ic_node_free = rtwn_node_free; + /* Note: this has to happen AFTER ieee80211_ifattach() */ + ieee80211_set_software_ciphers(ic, IEEE80211_CRYPTO_WEP | + IEEE80211_CRYPTO_TKIP | IEEE80211_CRYPTO_AES_CCM | + IEEE80211_CRYPTO_AES_GCM_128); + rtwn_postattach(sc); rtwn_radiotap_attach(sc); diff --git a/sys/dev/sound/pci/hda/hdaa.c b/sys/dev/sound/pci/hda/hdaa.c index ac62c04b5374..1e486b01b168 100644 --- a/sys/dev/sound/pci/hda/hdaa.c +++ b/sys/dev/sound/pci/hda/hdaa.c @@ -2912,7 +2912,7 @@ hdaa_dump_gpo(struct hdaa_devinfo *devinfo) data = hda_command(dev, HDA_CMD_GET_GPO_DATA(0, devinfo->nid)); for (i = 0; i < HDA_PARAM_GPIO_COUNT_NUM_GPO(devinfo->gpio_cap); i++) { - device_printf(dev, " GPO%d: state=%d", i, + device_printf(dev, " GPO%d: state=%d\n", i, (data >> i) & 1); } } diff --git a/sys/dev/sound/pci/hda/hdaa_patches.c b/sys/dev/sound/pci/hda/hdaa_patches.c index 8ad1c845c254..e5473ad48cc1 100644 --- a/sys/dev/sound/pci/hda/hdaa_patches.c +++ b/sys/dev/sound/pci/hda/hdaa_patches.c @@ -113,6 +113,12 @@ static const struct { { APPLE_MACBOOKAIR31, HDA_CODEC_CS4206, HDA_MATCH_ALL, 0, 0, HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) }, + { HDA_MATCH_ALL, HDA_CODEC_CS4208, APPLE_MACBOOKAIR61, + 0, 0, + HDAA_GPIO_SET(0) }, + { HDA_MATCH_ALL, HDA_CODEC_CS4208, APPLE_MACBOOKAIR62, + 0, 0, + HDAA_GPIO_SET(0) }, { APPLE_MACBOOKPRO55, HDA_CODEC_CS4206, HDA_MATCH_ALL, 0, 0, HDAA_GPIO_SET(1) | HDAA_GPIO_SET(3) }, @@ -341,6 +347,20 @@ hdac_pin_patch(struct hdaa_widget *w) break; } } else if (id == HDA_CODEC_ALC295 && + subid == FRAMEWORK_LAPTOP_0005_SUBVENDOR) { + switch (nid) { + case 20: + /* + * This pin is a duplicate of pin 23 (both as=1 seq=0), + * which ends up in the driver disabling the + * association altogether. Since sound quality from pin + * 23 seems to be better, configure this one as a back + * speaker. + */ + patch_str = "as=1 seq=2"; + break; + } + } else if (id == HDA_CODEC_ALC295 && subid == FRAMEWORK_LAPTOP_0006_SUBVENDOR) { switch (nid) { case 33: diff --git a/sys/dev/sound/pci/hda/hdac.c b/sys/dev/sound/pci/hda/hdac.c index 4f9f70d98cb6..a4242d2d1609 100644 --- a/sys/dev/sound/pci/hda/hdac.c +++ b/sys/dev/sound/pci/hda/hdac.c @@ -117,6 +117,7 @@ static const struct { { HDA_INTEL_ALLKPS, "Intel Alder Lake-PS", 0, 0 }, { HDA_INTEL_RPTLK1, "Intel Raptor Lake-P", 0, 0 }, { HDA_INTEL_RPTLK2, "Intel Raptor Lake-P", 0, 0 }, + { HDA_INTEL_RPTLK3, "Intel Raptor Lake-S", 0, 0 }, { HDA_INTEL_MTL, "Intel Meteor Lake-P", 0, 0 }, { HDA_INTEL_ARLS, "Intel Arrow Lake-S", 0, 0 }, { HDA_INTEL_ARL, "Intel Arrow Lake", 0, 0 }, diff --git a/sys/dev/sound/pci/hda/hdac.h b/sys/dev/sound/pci/hda/hdac.h index 72da5a4a44ac..2a79cb47353c 100644 --- a/sys/dev/sound/pci/hda/hdac.h +++ b/sys/dev/sound/pci/hda/hdac.h @@ -77,6 +77,7 @@ #define HDA_INTEL_ALLKPS HDA_MODEL_CONSTRUCT(INTEL, 0x51c9) #define HDA_INTEL_RPTLK1 HDA_MODEL_CONSTRUCT(INTEL, 0x51ca) #define HDA_INTEL_RPTLK2 HDA_MODEL_CONSTRUCT(INTEL, 0x51cb) +#define HDA_INTEL_RPTLK3 HDA_MODEL_CONSTRUCT(INTEL, 0x7a50) #define HDA_INTEL_SCH HDA_MODEL_CONSTRUCT(INTEL, 0x811b) #define HDA_INTEL_LPT1 HDA_MODEL_CONSTRUCT(INTEL, 0x8c20) #define HDA_INTEL_LPT2 HDA_MODEL_CONSTRUCT(INTEL, 0x8c21) @@ -425,6 +426,8 @@ */ #define APPLE_INTEL_MAC 0x76808384 #define APPLE_MACBOOKAIR31 0x0d9410de +#define APPLE_MACBOOKAIR61 0x106b7100 +#define APPLE_MACBOOKAIR62 0x106b7200 #define APPLE_MACBOOKPRO55 0xcb7910de #define APPLE_MACBOOKPRO71 0xcb8910de @@ -529,6 +532,7 @@ #define FRAMEWORK_LAPTOP_0001_SUBVENDOR HDA_MODEL_CONSTRUCT(FRAMEWORK, 0x0001) #define FRAMEWORK_LAPTOP_0002_SUBVENDOR HDA_MODEL_CONSTRUCT(FRAMEWORK, 0x0002) #define FRAMEWORK_LAPTOP_0003_SUBVENDOR HDA_MODEL_CONSTRUCT(FRAMEWORK, 0x0003) +#define FRAMEWORK_LAPTOP_0005_SUBVENDOR HDA_MODEL_CONSTRUCT(FRAMEWORK, 0x0005) #define FRAMEWORK_LAPTOP_0006_SUBVENDOR HDA_MODEL_CONSTRUCT(FRAMEWORK, 0x0006) /* All codecs you can eat... */ @@ -539,6 +543,7 @@ #define CIRRUSLOGIC_VENDORID 0x1013 #define HDA_CODEC_CS4206 HDA_CODEC_CONSTRUCT(CIRRUSLOGIC, 0x4206) #define HDA_CODEC_CS4207 HDA_CODEC_CONSTRUCT(CIRRUSLOGIC, 0x4207) +#define HDA_CODEC_CS4208 HDA_CODEC_CONSTRUCT(CIRRUSLOGIC, 0x4208) #define HDA_CODEC_CS4210 HDA_CODEC_CONSTRUCT(CIRRUSLOGIC, 0x4210) #define HDA_CODEC_CSXXXX HDA_CODEC_CONSTRUCT(CIRRUSLOGIC, 0xffff) diff --git a/sys/dev/sound/pci/hda/hdacc.c b/sys/dev/sound/pci/hda/hdacc.c index b4321a5bf998..4198982c9c2a 100644 --- a/sys/dev/sound/pci/hda/hdacc.c +++ b/sys/dev/sound/pci/hda/hdacc.c @@ -74,6 +74,7 @@ static const struct { } hdacc_codecs[] = { { HDA_CODEC_CS4206, 0, "Cirrus Logic CS4206" }, { HDA_CODEC_CS4207, 0, "Cirrus Logic CS4207" }, + { HDA_CODEC_CS4208, 0, "Cirrus Logic CS4208" }, { HDA_CODEC_CS4210, 0, "Cirrus Logic CS4210" }, { HDA_CODEC_ALC215, 0, "Realtek ALC215" }, { HDA_CODEC_ALC221, 0, "Realtek ALC221" }, diff --git a/sys/dev/usb/wlan/if_uath.c b/sys/dev/usb/wlan/if_uath.c index 28c176df1f14..b49c75032d77 100644 --- a/sys/dev/usb/wlan/if_uath.c +++ b/sys/dev/usb/wlan/if_uath.c @@ -441,6 +441,12 @@ uath_attach(device_t dev) ieee80211_init_channels(ic, NULL, bands); ieee80211_ifattach(ic); + + /* Note: this has to happen AFTER ieee80211_ifattach() */ + ieee80211_set_software_ciphers(ic, + IEEE80211_CRYPTO_WEP | IEEE80211_CRYPTO_TKIP | + IEEE80211_CRYPTO_AES_CCM | IEEE80211_CRYPTO_AES_GCM_128); + ic->ic_raw_xmit = uath_raw_xmit; ic->ic_scan_start = uath_scan_start; ic->ic_scan_end = uath_scan_end; diff --git a/sys/dev/xilinx/axi_quad_spi.c b/sys/dev/xilinx/axi_quad_spi.c index eba320731659..86b00473fc96 100644 --- a/sys/dev/xilinx/axi_quad_spi.c +++ b/sys/dev/xilinx/axi_quad_spi.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2016 Ruslan Bukin <br@bsdpad.com> + * Copyright (c) 2016-2025 Ruslan Bukin <br@bsdpad.com> * All rights reserved. * * Portions of this software were developed by SRI International and the @@ -100,6 +100,12 @@ struct spi_softc { void *ih; }; +static struct ofw_compat_data compat_data[] = { + { "xlnx,xps-spi-3.2", 1 }, + { "xlnx,xps-spi-2.00.a", 1 }, + { NULL, 0 } +}; + static struct resource_spec spi_spec[] = { { SYS_RES_MEMORY, 0, RF_ACTIVE }, { -1, 0 } @@ -112,7 +118,7 @@ spi_probe(device_t dev) if (!ofw_bus_status_okay(dev)) return (ENXIO); - if (!ofw_bus_is_compatible(dev, "xlnx,xps-spi-3.2")) + if (!ofw_bus_search_compatible(dev, compat_data)->ocd_data) return (ENXIO); device_set_desc(dev, "Xilinx Quad SPI"); @@ -148,7 +154,7 @@ spi_attach(device_t dev) reg = (CR_MASTER | CR_MSS | CR_SPE); WRITE4(sc, SPI_CR, reg); - device_add_child(dev, "spibus", 0); + device_add_child(dev, "spibus", DEVICE_UNIT_ANY); bus_attach_children(dev); return (0); } @@ -212,20 +218,33 @@ spi_transfer(device_t dev, device_t child, struct spi_command *cmd) return (0); } +static phandle_t +axispi_get_node(device_t bus, device_t dev) +{ + + return (ofw_bus_get_node(bus)); +} + static device_method_t spi_methods[] = { /* Device interface */ DEVMETHOD(device_probe, spi_probe), DEVMETHOD(device_attach, spi_attach), + /* ofw_bus_if */ + DEVMETHOD(ofw_bus_get_node, axispi_get_node), + /* SPI interface */ DEVMETHOD(spibus_transfer, spi_transfer), DEVMETHOD_END }; -static driver_t spi_driver = { - "spi", +static driver_t axispi_driver = { + "axispi", spi_methods, sizeof(struct spi_softc), }; -DRIVER_MODULE(spi, simplebus, spi_driver, 0, 0); +DRIVER_MODULE(axispi, simplebus, axispi_driver, 0, 0); +DRIVER_MODULE(ofw_spibus, axispi, ofw_spibus_driver, 0, 0); +MODULE_DEPEND(axispi, ofw_spibus, 1, 1, 1); +SIMPLEBUS_PNP_INFO(compat_data); diff --git a/sys/dev/xilinx/if_xae.c b/sys/dev/xilinx/if_xae.c index 080b13606525..97e7aa16dda4 100644 --- a/sys/dev/xilinx/if_xae.c +++ b/sys/dev/xilinx/if_xae.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2019 Ruslan Bukin <br@bsdpad.com> + * Copyright (c) 2019-2025 Ruslan Bukin <br@bsdpad.com> * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory (Department of Computer Science and @@ -43,6 +43,9 @@ #include <sys/socket.h> #include <sys/sockio.h> +#include <vm/vm.h> +#include <vm/vm_page.h> + #include <net/bpf.h> #include <net/if.h> #include <net/ethernet.h> @@ -94,6 +97,7 @@ #define NUM_RX_MBUF 16 #define BUFRING_SIZE 8192 #define MDIO_CLK_DIV_DEFAULT 29 +#define BUF_NPAGES 512 #define PHY1_RD(sc, _r) \ xae_miibus_read_reg(sc->dev, 1, _r) @@ -834,6 +838,8 @@ setup_xdma(struct xae_softc *sc) { device_t dev; vmem_t *vmem; + vm_paddr_t phys; + vm_page_t m; int error; dev = sc->dev; @@ -886,11 +892,19 @@ setup_xdma(struct xae_softc *sc) /* Setup bounce buffer */ vmem = xdma_get_memory(dev); - if (vmem) { - xchan_set_memory(sc->xchan_tx, vmem); - xchan_set_memory(sc->xchan_rx, vmem); + if (!vmem) { + m = vm_page_alloc_noobj_contig(VM_ALLOC_WIRED | VM_ALLOC_ZERO, + BUF_NPAGES, 0, BUS_SPACE_MAXADDR_32BIT, PAGE_SIZE, 0, + VM_MEMATTR_DEFAULT); + phys = VM_PAGE_TO_PHYS(m); + vmem = vmem_create("xdma vmem", 0, 0, PAGE_SIZE, PAGE_SIZE, + M_BESTFIT | M_WAITOK); + vmem_add(vmem, phys, BUF_NPAGES * PAGE_SIZE, 0); } + xchan_set_memory(sc->xchan_tx, vmem); + xchan_set_memory(sc->xchan_rx, vmem); + xdma_prep_sg(sc->xchan_tx, TX_QUEUE_SIZE, /* xchan requests queue size */ MCLBYTES, /* maxsegsize */ diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index db879efe803a..c6dcd4fc7646 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -86,6 +86,9 @@ sysctl_devname(SYSCTL_HANDLER_ARGS) struct cdev_priv *cdp; struct cdev *dev; + if (req->newptr == NULL) + return (EINVAL); + #ifdef COMPAT_FREEBSD11 if (req->newlen == sizeof(ud_compat)) { error = SYSCTL_IN(req, &ud_compat, sizeof(ud_compat)); diff --git a/sys/geom/geom.h b/sys/geom/geom.h index 0eb6775701fd..dcd6f793f9f7 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -417,7 +417,7 @@ g_free(void *ptr) static moduledata_t name##_mod = { \ #name, g_modevent, &class \ }; \ - DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND); + DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); int g_is_geom_thread(struct thread *td); diff --git a/sys/geom/raid/g_raid.c b/sys/geom/raid/g_raid.c index 6938491d696c..a483622d14a5 100644 --- a/sys/geom/raid/g_raid.c +++ b/sys/geom/raid/g_raid.c @@ -2571,5 +2571,5 @@ static moduledata_t g_raid_mod = { g_modevent, &g_raid_class }; -DECLARE_MODULE(g_raid, g_raid_mod, SI_SUB_DRIVERS, SI_ORDER_THIRD); +DECLARE_MODULE(g_raid, g_raid_mod, SI_SUB_DRIVERS, SI_ORDER_FOURTH); MODULE_VERSION(geom_raid, 0); diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index e7851f7eb92c..e7d460af21d4 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -248,6 +248,7 @@ options IEEE80211_DEBUG # enable debug msgs options IEEE80211_SUPPORT_MESH # enable 802.11s draft support device wlan_wep # 802.11 WEP support device wlan_ccmp # 802.11 CCMP support +device wlan_gcmp # 802.11 GCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm device ath # Atheros CardBus/PCI NICs diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c index 57ba48d399c3..302e493e44d1 100644 --- a/sys/i386/i386/pmap.c +++ b/sys/i386/i386/pmap.c @@ -615,15 +615,6 @@ __CONCAT(PMTYPE, bootstrap)(vm_paddr_t firstaddr) res = atop(firstaddr - (vm_paddr_t)KERNLOAD); /* - * Add a physical memory segment (vm_phys_seg) corresponding to the - * preallocated kernel page table pages so that vm_page structures - * representing these pages will be created. The vm_page structures - * are required for promotion of the corresponding kernel virtual - * addresses to superpage mappings. - */ - vm_phys_early_add_seg(KPTphys, KPTphys + ptoa(nkpt)); - - /* * Initialize the first available kernel virtual address. * However, using "firstaddr" may waste a few pages of the * kernel virtual address space, because pmap_cold() may not diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index fc074ad74e6b..1a2c0e2ef93d 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1574,6 +1574,7 @@ static void __elfN(note_threadmd)(void *, struct sbuf *, size_t *); static void __elfN(note_procstat_auxv)(void *, struct sbuf *, size_t *); static void __elfN(note_procstat_proc)(void *, struct sbuf *, size_t *); static void __elfN(note_procstat_psstrings)(void *, struct sbuf *, size_t *); +static void __elfN(note_procstat_kqueues)(void *, struct sbuf *, size_t *); static void note_procstat_files(void *, struct sbuf *, size_t *); static void note_procstat_groups(void *, struct sbuf *, size_t *); static void note_procstat_osrel(void *, struct sbuf *, size_t *); @@ -1899,6 +1900,8 @@ __elfN(prepare_notes)(struct thread *td, struct note_info_list *list, __elfN(note_procstat_psstrings), p); size += __elfN(register_note)(td, list, NT_PROCSTAT_AUXV, __elfN(note_procstat_auxv), p); + size += __elfN(register_note)(td, list, NT_PROCSTAT_KQUEUES, + __elfN(note_procstat_kqueues), p); *sizep = size; } @@ -2719,6 +2722,54 @@ __elfN(note_procstat_auxv)(void *arg, struct sbuf *sb, size_t *sizep) } } +static void +__elfN(note_procstat_kqueues)(void *arg, struct sbuf *sb, size_t *sizep) +{ + struct proc *p; + size_t size, sect_sz, i; + ssize_t start_len, sect_len; + int structsize; + bool compat32; + +#if defined(COMPAT_FREEBSD32) && __ELF_WORD_SIZE == 32 + compat32 = true; + structsize = sizeof(struct kinfo_knote32); +#else + compat32 = false; + structsize = sizeof(struct kinfo_knote); +#endif + p = arg; + if (sb == NULL) { + size = 0; + sb = sbuf_new(NULL, NULL, 128, SBUF_FIXEDLEN); + sbuf_set_drain(sb, sbuf_count_drain, &size); + sbuf_bcat(sb, &structsize, sizeof(structsize)); + kern_proc_kqueues_out(p, sb, -1, compat32); + sbuf_finish(sb); + sbuf_delete(sb); + *sizep = size; + } else { + sbuf_start_section(sb, &start_len); + + sbuf_bcat(sb, &structsize, sizeof(structsize)); + kern_proc_kqueues_out(p, sb, *sizep - sizeof(structsize), + compat32); + + sect_len = sbuf_end_section(sb, start_len, 0, 0); + if (sect_len < 0) + return; + sect_sz = sect_len; + + KASSERT(sect_sz <= *sizep, + ("kern_proc_kqueue_out did not respect maxlen; " + "requested %zu, got %zu", *sizep - sizeof(structsize), + sect_sz - sizeof(structsize))); + + for (i = 0; i < *sizep - sect_sz && sb->s_error == 0; i++) + sbuf_putc(sb, 0); + } +} + #define MAX_NOTES_LOOP 4096 bool __elfN(parse_notes)(const struct image_params *imgp, const Elf_Note *checknote, diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index f87ad1f45143..9d81c30df328 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -34,14 +34,11 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> #include "opt_capsicum.h" #include "opt_ddb.h" #include "opt_ktrace.h" -#include <sys/param.h> #include <sys/systm.h> - #include <sys/capsicum.h> #include <sys/conf.h> #include <sys/fcntl.h> @@ -2996,6 +2993,47 @@ fget_remote(struct thread *td, struct proc *p, int fd, struct file **fpp) return (error); } +int +fget_remote_foreach(struct thread *td, struct proc *p, + int (*fn)(struct proc *, int, struct file *, void *), void *arg) +{ + struct filedesc *fdp; + struct fdescenttbl *fdt; + struct file *fp; + int error, error1, fd, highfd; + + error = 0; + PROC_LOCK(p); + fdp = fdhold(p); + PROC_UNLOCK(p); + if (fdp == NULL) + return (ENOENT); + + FILEDESC_SLOCK(fdp); + if (refcount_load(&fdp->fd_refcnt) != 0) { + fdt = atomic_load_ptr(&fdp->fd_files); + highfd = fdt->fdt_nfiles - 1; + FILEDESC_SUNLOCK(fdp); + } else { + error = ENOENT; + FILEDESC_SUNLOCK(fdp); + goto out; + } + + for (fd = 0; fd <= highfd; fd++) { + error1 = fget_remote(td, p, fd, &fp); + if (error1 != 0) + continue; + error = fn(p, fd, fp, arg); + fdrop(fp, td); + if (error != 0) + break; + } +out: + fddrop(fdp); + return (error); +} + #ifdef CAPABILITIES int fgetvp_lookup_smr(struct nameidata *ndp, struct vnode **vpp, bool *fsearch) diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 14aa3abd1901..eb77a5064113 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -58,6 +58,7 @@ #include <sys/poll.h> #include <sys/protosw.h> #include <sys/resourcevar.h> +#include <sys/sbuf.h> #include <sys/sigio.h> #include <sys/signalvar.h> #include <sys/socket.h> @@ -74,6 +75,10 @@ #include <sys/ktrace.h> #endif #include <machine/atomic.h> +#ifdef COMPAT_FREEBSD32 +#include <compat/freebsd32/freebsd32.h> +#include <compat/freebsd32/freebsd32_util.h> +#endif #include <vm/uma.h> @@ -2871,94 +2876,189 @@ knote_status_export(int kn_status) } static int -sysctl_kern_proc_kqueue_report_one(struct proc *p, struct sysctl_req *req, - struct kqueue *kq, struct knote *kn) +kern_proc_kqueue_report_one(struct sbuf *s, struct proc *p, + int kq_fd, struct kqueue *kq, struct knote *kn, bool compat32 __unused) { struct kinfo_knote kin; +#ifdef COMPAT_FREEBSD32 + struct kinfo_knote32 kin32; +#endif int error; if (kn->kn_status == KN_MARKER) return (0); memset(&kin, 0, sizeof(kin)); + kin.knt_kq_fd = kq_fd; memcpy(&kin.knt_event, &kn->kn_kevent, sizeof(struct kevent)); kin.knt_status = knote_status_export(kn->kn_status); kn_enter_flux(kn); KQ_UNLOCK_FLUX(kq); if (kn->kn_fop->f_userdump != NULL) (void)kn->kn_fop->f_userdump(p, kn, &kin); - error = SYSCTL_OUT(req, &kin, sizeof(kin)); - maybe_yield(); +#ifdef COMPAT_FREEBSD32 + if (compat32) { + freebsd32_kinfo_knote_to_32(&kin, &kin32); + error = sbuf_bcat(s, &kin32, sizeof(kin32)); + } else +#endif + error = sbuf_bcat(s, &kin, sizeof(kin)); KQ_LOCK(kq); kn_leave_flux(kn); return (error); } static int +kern_proc_kqueue_report(struct sbuf *s, struct proc *p, int kq_fd, + struct kqueue *kq, bool compat32) +{ + struct knote *kn; + int error, i; + + error = 0; + KQ_LOCK(kq); + for (i = 0; i < kq->kq_knlistsize; i++) { + SLIST_FOREACH(kn, &kq->kq_knlist[i], kn_link) { + error = kern_proc_kqueue_report_one(s, p, kq_fd, + kq, kn, compat32); + if (error != 0) + goto out; + } + } + if (kq->kq_knhashmask == 0) + goto out; + for (i = 0; i <= kq->kq_knhashmask; i++) { + SLIST_FOREACH(kn, &kq->kq_knhash[i], kn_link) { + error = kern_proc_kqueue_report_one(s, p, kq_fd, + kq, kn, compat32); + if (error != 0) + goto out; + } + } +out: + KQ_UNLOCK_FLUX(kq); + return (error); +} + +struct kern_proc_kqueues_out1_cb_args { + struct sbuf *s; + bool compat32; +}; + +static int +kern_proc_kqueues_out1_cb(struct proc *p, int fd, struct file *fp, void *arg) +{ + struct kqueue *kq; + struct kern_proc_kqueues_out1_cb_args *a; + + if (fp->f_type != DTYPE_KQUEUE) + return (0); + a = arg; + kq = fp->f_data; + return (kern_proc_kqueue_report(a->s, p, fd, kq, a->compat32)); +} + +static int +kern_proc_kqueues_out1(struct thread *td, struct proc *p, struct sbuf *s, + bool compat32) +{ + struct kern_proc_kqueues_out1_cb_args a; + + a.s = s; + a.compat32 = compat32; + return (fget_remote_foreach(td, p, kern_proc_kqueues_out1_cb, &a)); +} + +int +kern_proc_kqueues_out(struct proc *p, struct sbuf *sb, size_t maxlen, + bool compat32) +{ + struct sbuf *s, sm; + size_t sb_len; + int error; + + if (maxlen == -1 || maxlen == 0) + sb_len = 128; + else + sb_len = maxlen; + s = sbuf_new(&sm, NULL, sb_len, maxlen == -1 ? SBUF_AUTOEXTEND : + SBUF_FIXEDLEN); + error = kern_proc_kqueues_out1(curthread, p, s, compat32); + sbuf_finish(s); + if (error == 0) { + sbuf_bcat(sb, sbuf_data(s), MIN(sbuf_len(s), maxlen == -1 ? + SIZE_T_MAX : maxlen)); + } + sbuf_delete(s); + return (error); +} + +static int +sysctl_kern_proc_kqueue_one(struct thread *td, struct sbuf *s, struct proc *p, + int kq_fd, bool compat32) +{ + struct file *fp; + struct kqueue *kq; + int error; + + error = fget_remote(td, p, kq_fd, &fp); + if (error == 0) { + if (fp->f_type != DTYPE_KQUEUE) { + error = EINVAL; + } else { + kq = fp->f_data; + error = kern_proc_kqueue_report(s, p, kq_fd, kq, + compat32); + } + fdrop(fp, td); + } + return (error); +} + +static int sysctl_kern_proc_kqueue(SYSCTL_HANDLER_ARGS) { struct thread *td; struct proc *p; - struct file *fp; - struct kqueue *kq; - struct knote *kn; - int error, i, *name; + struct sbuf *s, sm; + int error, error1, *name; + bool compat32; name = (int *)arg1; - if ((u_int)arg2 != 2) + if ((u_int)arg2 > 2 || (u_int)arg2 == 0) return (EINVAL); error = pget((pid_t)name[0], PGET_HOLD | PGET_CANDEBUG, &p); if (error != 0) return (error); -#ifdef COMPAT_FREEBSD32 - if (SV_CURPROC_FLAG(SV_ILP32)) { - /* XXXKIB */ - error = EOPNOTSUPP; - goto out1; - } -#endif td = curthread; - error = fget_remote(td, p, name[1] /* kqfd */, &fp); - if (error != 0) - goto out1; - if (fp->f_type != DTYPE_KQUEUE) { - error = EINVAL; - goto out2; - } +#ifdef FREEBSD_COMPAT32 + compat32 = SV_CURPROC_FLAG(SV_ILP32); +#else + compat32 = false; +#endif - kq = fp->f_data; - if (req->oldptr == NULL) { - error = SYSCTL_OUT(req, NULL, sizeof(struct kinfo_knote) * - kq->kq_knlistsize * 11 / 10); - goto out2; + s = sbuf_new_for_sysctl(&sm, NULL, 0, req); + if (s == NULL) { + error = ENOMEM; + goto out; } + sbuf_clear_flags(s, SBUF_INCLUDENUL); - KQ_LOCK(kq); - for (i = 0; i < kq->kq_knlistsize; i++) { - SLIST_FOREACH(kn, &kq->kq_knlist[i], kn_link) { - error = sysctl_kern_proc_kqueue_report_one(p, req, - kq, kn); - if (error != 0) - goto out3; - } - } - if (kq->kq_knhashmask == 0) - goto out3; - for (i = 0; i <= kq->kq_knhashmask; i++) { - SLIST_FOREACH(kn, &kq->kq_knhash[i], kn_link) { - error = sysctl_kern_proc_kqueue_report_one(p, req, - kq, kn); - if (error != 0) - goto out3; - } + if ((u_int)arg2 == 1) { + error = kern_proc_kqueues_out1(td, p, s, compat32); + } else { + error = sysctl_kern_proc_kqueue_one(td, s, p, + name[1] /* kq_fd */, compat32); } -out3: - KQ_UNLOCK_FLUX(kq); -out2: - fdrop(fp, td); -out1: + + error1 = sbuf_finish(s); + if (error == 0) + error = error1; + sbuf_delete(s); + +out: PRELE(p); return (error); } diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index b1347b15e651..0b76e633b04a 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -477,11 +477,18 @@ contigmalloc_size(uma_slab_t slab) } void * -contigmalloc(unsigned long size, struct malloc_type *type, int flags, +contigmalloc(unsigned long osize, struct malloc_type *type, int flags, vm_paddr_t low, vm_paddr_t high, unsigned long alignment, vm_paddr_t boundary) { void *ret; + unsigned long size; + +#ifdef DEBUG_REDZONE + size = redzone_size_ntor(osize); +#else + size = osize; +#endif ret = (void *)kmem_alloc_contig(size, flags, low, high, alignment, boundary, VM_MEMATTR_DEFAULT); @@ -489,16 +496,26 @@ contigmalloc(unsigned long size, struct malloc_type *type, int flags, /* Use low bits unused for slab pointers. */ vsetzoneslab((uintptr_t)ret, NULL, CONTIG_MALLOC_SLAB(size)); malloc_type_allocated(type, round_page(size)); +#ifdef DEBUG_REDZONE + ret = redzone_setup(ret, osize); +#endif } return (ret); } void * -contigmalloc_domainset(unsigned long size, struct malloc_type *type, +contigmalloc_domainset(unsigned long osize, struct malloc_type *type, struct domainset *ds, int flags, vm_paddr_t low, vm_paddr_t high, unsigned long alignment, vm_paddr_t boundary) { void *ret; + unsigned long size; + +#ifdef DEBUG_REDZONE + size = redzone_size_ntor(osize); +#else + size = osize; +#endif ret = (void *)kmem_alloc_contig_domainset(ds, size, flags, low, high, alignment, boundary, VM_MEMATTR_DEFAULT); @@ -506,6 +523,9 @@ contigmalloc_domainset(unsigned long size, struct malloc_type *type, /* Use low bits unused for slab pointers. */ vsetzoneslab((uintptr_t)ret, NULL, CONTIG_MALLOC_SLAB(size)); malloc_type_allocated(type, round_page(size)); +#ifdef DEBUG_REDZONE + ret = redzone_setup(ret, osize); +#endif } return (ret); } diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index e8d410b00c15..ec00878cd9a5 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -75,7 +75,7 @@ static void sbcompress_ktls_rx(struct sockbuf *sb, struct mbuf *m, struct mbuf *n); #endif static struct mbuf *sbcut_internal(struct sockbuf *sb, int len); -static void sbflush_internal(struct sockbuf *sb); +static void sbunreserve_locked(struct socket *so, sb_which which); /* * Our own version of m_clrprotoflags(), that can preserve M_NOTREADY. @@ -619,7 +619,7 @@ soreserve(struct socket *so, u_long sndcc, u_long rcvcc) SOCK_SENDBUF_UNLOCK(so); return (0); bad2: - sbrelease_locked(so, SO_SND); + sbunreserve_locked(so, SO_SND); bad: SOCK_RECVBUF_UNLOCK(so); SOCK_SENDBUF_UNLOCK(so); @@ -684,6 +684,18 @@ sbreserve_locked(struct socket *so, sb_which which, u_long cc, return (sbreserve_locked_limit(so, which, cc, sb_max, td)); } +static void +sbunreserve_locked(struct socket *so, sb_which which) +{ + struct sockbuf *sb = sobuf(so, which); + + SOCK_BUF_LOCK_ASSERT(so, which); + + (void)chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, 0, + RLIM_INFINITY); + sb->sb_mbmax = 0; +} + int sbsetopt(struct socket *so, struct sockopt *sopt) { @@ -779,24 +791,15 @@ sbsetopt(struct socket *so, struct sockopt *sopt) /* * Free mbufs held by a socket, and reserved mbuf space. */ -static void -sbrelease_internal(struct socket *so, sb_which which) -{ - struct sockbuf *sb = sobuf(so, which); - - sbflush_internal(sb); - (void)chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, 0, - RLIM_INFINITY); - sb->sb_mbmax = 0; -} - void sbrelease_locked(struct socket *so, sb_which which) { + struct sockbuf *sb = sobuf(so, which); SOCK_BUF_LOCK_ASSERT(so, which); - sbrelease_internal(so, which); + sbflush_locked(sb); + sbunreserve_locked(so, which); } void @@ -818,7 +821,7 @@ sbdestroy(struct socket *so, sb_which which) ktls_free(sb->sb_tls_info); sb->sb_tls_info = NULL; #endif - sbrelease_internal(so, which); + sbrelease_locked(so, which); } /* @@ -1530,10 +1533,12 @@ sbcompress_ktls_rx(struct sockbuf *sb, struct mbuf *m, struct mbuf *n) /* * Free all mbufs in a sockbuf. Check that all resources are reclaimed. */ -static void -sbflush_internal(struct sockbuf *sb) +void +sbflush_locked(struct sockbuf *sb) { + SOCKBUF_LOCK_ASSERT(sb); + while (sb->sb_mbcnt || sb->sb_tlsdcc) { /* * Don't call sbcut(sb, 0) if the leading mbuf is non-empty: @@ -1549,14 +1554,6 @@ sbflush_internal(struct sockbuf *sb) } void -sbflush_locked(struct sockbuf *sb) -{ - - SOCKBUF_LOCK_ASSERT(sb); - sbflush_internal(sb); -} - -void sbflush(struct sockbuf *sb) { diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 03bfea721dd2..63d30f04c8e0 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -592,11 +592,6 @@ so_splice_xfer_data(struct socket *so_src, struct socket *so_dst, off_t max, /* * Transfer data from the source to the sink. - * - * If "direct" is true, the transfer is done in the context of whichever thread - * is operating on one of the socket buffers. We do not know which locks are - * held, so we can only trylock the socket buffers; if this fails, we fall back - * to the worker thread, which invokes this routine with "direct" set to false. */ static void so_splice_xfer(struct so_splice *sp) @@ -1638,7 +1633,7 @@ so_splice_alloc(off_t max) sp->wq_index = atomic_fetchadd_32(&splice_index, 1) % (mp_maxid + 1); } while (CPU_ABSENT(sp->wq_index)); - sp->state = SPLICE_IDLE; + sp->state = SPLICE_INIT; TIMEOUT_TASK_INIT(taskqueue_thread, &sp->timeout, 0, so_splice_timeout, sp); return (sp); @@ -1867,14 +1862,22 @@ sofree(struct socket *so) if (pr->pr_detach != NULL) pr->pr_detach(so); - /* - * From this point on, we assume that no other references to this - * socket exist anywhere else in the stack. Therefore, no locks need - * to be acquired or held. - */ if (!(pr->pr_flags & PR_SOCKBUF) && !SOLISTENING(so)) { + /* + * From this point on, we assume that no other references to + * this socket exist anywhere else in the stack. Therefore, + * no locks need to be acquired or held. + */ +#ifdef INVARIANTS + SOCK_SENDBUF_LOCK(so); + SOCK_RECVBUF_LOCK(so); +#endif sbdestroy(so, SO_SND); sbdestroy(so, SO_RCV); +#ifdef INVARIANTS + SOCK_SENDBUF_UNLOCK(so); + SOCK_RECVBUF_UNLOCK(so); +#endif } seldrain(&so->so_rdsel); seldrain(&so->so_wrsel); diff --git a/sys/kern/vfs_acl.c b/sys/kern/vfs_acl.c index fde05478d41c..3106218abce6 100644 --- a/sys/kern/vfs_acl.c +++ b/sys/kern/vfs_acl.c @@ -551,6 +551,7 @@ kern___acl_aclcheck_path(struct thread *td, const char *path, acl_type_t type, error = namei(&nd); if (error == 0) { error = vacl_aclcheck(td, nd.ni_vp, type, aclp); + vrele(nd.ni_vp); NDFREE_PNBUF(&nd); } return (error); diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 95ed98d3217d..96e8bb765972 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -6519,6 +6519,8 @@ sysctl_vfs_ctl(SYSCTL_HANDLER_ARGS) int error; struct mount *mp; + if (req->newptr == NULL) + return (EINVAL); error = SYSCTL_IN(req, &vc, sizeof(vc)); if (error) return (error); diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 9a49353f1538..3774f73a7a8f 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1127,29 +1127,6 @@ in_pcbconnect(struct inpcb *inp, struct sockaddr_in *sin, struct ucred *cred) if (in_nullhost(inp->inp_laddr)) { error = in_pcbladdr(inp, &faddr, &laddr, cred); - /* - * If the destination address is multicast and an outgoing - * interface has been set as a multicast option, prefer the - * address of that interface as our source address. - */ - if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr)) && - inp->inp_moptions != NULL && - inp->inp_moptions->imo_multicast_ifp != NULL) { - struct ifnet *ifp = - inp->inp_moptions->imo_multicast_ifp; - struct in_ifaddr *ia; - - CK_STAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) { - if (ia->ia_ifp == ifp && - prison_check_ip4(cred, - &ia->ia_addr.sin_addr) == 0) - break; - } - if (ia == NULL) - return (EADDRNOTAVAIL); - laddr = ia->ia_addr.sin_addr; - error = 0; - } if (error) return (error); } else @@ -1231,6 +1208,27 @@ in_pcbladdr(const struct inpcb *inp, struct in_addr *faddr, if (!prison_saddrsel_ip4(cred, laddr)) return (0); + /* + * If the destination address is multicast and an outgoing + * interface has been set as a multicast option, prefer the + * address of that interface as our source address. + */ + if (IN_MULTICAST(ntohl(faddr->s_addr)) && inp->inp_moptions != NULL && + inp->inp_moptions->imo_multicast_ifp != NULL) { + struct ifnet *ifp = inp->inp_moptions->imo_multicast_ifp; + struct in_ifaddr *ia; + + CK_STAILQ_FOREACH(ia, &V_in_ifaddrhead, ia_link) { + if (ia->ia_ifp == ifp && + prison_check_ip4(cred, &ia->ia_addr.sin_addr) == 0) + break; + } + if (ia == NULL) + return (EADDRNOTAVAIL); + *laddr = ia->ia_addr.sin_addr; + return (0); + } + error = 0; nh = NULL; diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c index 7fb7ab3418cf..94d57225c20b 100644 --- a/sys/netinet/sctp_usrreq.c +++ b/sys/netinet/sctp_usrreq.c @@ -361,8 +361,9 @@ sctp_getcred(SYSCTL_HANDLER_ARGS) /* FIX, for non-bsd is this right? */ vrf_id = SCTP_DEFAULT_VRFID; + if (req->newptr == NULL) + return (EINVAL); error = priv_check(req->td, PRIV_NETINET_GETCRED); - if (error) return (error); diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index cf480ccf9772..2fc1e0deea16 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -465,6 +465,7 @@ cc_cong_signal(struct tcpcb *tp, struct tcphdr *th, uint32_t type) ENTER_CONGRECOVERY(tp->t_flags); tp->snd_nxt = tp->snd_max; tp->t_flags &= ~TF_PREVVALID; + tp->t_rxtshift = 0; tp->t_badrxtwin = 0; break; } @@ -1635,11 +1636,6 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, to.to_tsecr -= tp->ts_offset; if (TSTMP_GT(to.to_tsecr, tcp_ts_getticks())) { to.to_tsecr = 0; - } else if (tp->t_rxtshift == 1 && - tp->t_flags & TF_PREVVALID && - tp->t_badrxtwin != 0 && - TSTMP_LT(to.to_tsecr, tp->t_badrxtwin)) { - cc_cong_signal(tp, th, CC_RTO_ERR); } } /* @@ -1792,15 +1788,17 @@ tcp_do_segment(struct tcpcb *tp, struct mbuf *m, struct tcphdr *th, TCPSTAT_INC(tcps_predack); /* - * "bad retransmit" recovery without timestamps. + * "bad retransmit" recovery. */ - if ((to.to_flags & TOF_TS) == 0 && - tp->t_rxtshift == 1 && + if (tp->t_rxtshift == 1 && tp->t_flags & TF_PREVVALID && tp->t_badrxtwin != 0 && - TSTMP_LT(ticks, tp->t_badrxtwin)) { + (((to.to_flags & TOF_TS) != 0 && + to.to_tsecr != 0 && + TSTMP_LT(to.to_tsecr, tp->t_badrxtwin)) || + ((to.to_flags & TOF_TS) == 0 && + TSTMP_LT(ticks, tp->t_badrxtwin)))) cc_cong_signal(tp, th, CC_RTO_ERR); - } /* * Recalculate the transmit timer / rtt. diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 03efc759092d..f6317815521d 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -2698,6 +2698,8 @@ tcp_getcred(SYSCTL_HANDLER_ARGS) struct inpcb *inp; int error; + if (req->newptr == NULL) + return (EINVAL); error = priv_check(req->td, PRIV_NETINET_GETCRED); if (error) return (error); @@ -2740,6 +2742,8 @@ tcp6_getcred(SYSCTL_HANDLER_ARGS) int mapped = 0; #endif + if (req->newptr == NULL) + return (EINVAL); error = priv_check(req->td, PRIV_NETINET_GETCRED); if (error) return (error); diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index b3d980956b66..dafbaf6dc672 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -844,6 +844,8 @@ udp_getcred(SYSCTL_HANDLER_ARGS) struct inpcb *inp; int error; + if (req->newptr == NULL) + return (EINVAL); error = priv_check(req->td, PRIV_NETINET_GETCRED); if (error) return (error); diff --git a/sys/netinet6/sctp6_usrreq.c b/sys/netinet6/sctp6_usrreq.c index c0e758e9e12b..8964ccf54c54 100644 --- a/sys/netinet6/sctp6_usrreq.c +++ b/sys/netinet6/sctp6_usrreq.c @@ -375,6 +375,8 @@ sctp6_getcred(SYSCTL_HANDLER_ARGS) vrf_id = SCTP_DEFAULT_VRFID; + if (req->newptr == NULL) + return (EINVAL); error = priv_check(req->td, PRIV_NETINET_GETCRED); if (error) return (error); diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 40216ad4c420..c44510e3b65f 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -617,6 +617,8 @@ udp6_getcred(SYSCTL_HANDLER_ARGS) struct inpcb *inp; int error; + if (req->newptr == NULL) + return (EINVAL); error = priv_check(req->td, PRIV_NETINET_GETCRED); if (error) return (error); diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 3bf7e0e2077c..002fff9b81be 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -2266,7 +2266,7 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, *icmp_dir = PF_IN; *virtual_type = type; *virtual_id = 0; - HTONS(*virtual_type); + *virtual_type = htons(*virtual_type); return (1); /* These types match to another state */ /* @@ -2333,7 +2333,7 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, *icmp_dir = PF_IN; *virtual_type = type; *virtual_id = 0; - HTONS(*virtual_type); + *virtual_type = htons(*virtual_type); return (1); /* These types match to another state */ /* * All remaining ICMP6 types get their own states, @@ -2350,7 +2350,7 @@ pf_icmp_mapping(struct pf_pdesc *pd, u_int8_t type, default: unhandled_af(pd->af); } - HTONS(*virtual_type); + *virtual_type = htons(*virtual_type); return (0); /* These types match to their own state */ } @@ -4101,7 +4101,7 @@ pf_build_tcp(const struct pf_krule *r, sa_family_t af, opt = (char *)(th + 1); opt[0] = TCPOPT_MAXSEG; opt[1] = 4; - HTONS(mss); + mss = htons(mss); memcpy((opt + 2), &mss, 2); } @@ -4527,10 +4527,7 @@ pf_match(u_int8_t op, u_int32_t a1, u_int32_t a2, u_int32_t p) int pf_match_port(u_int8_t op, u_int16_t a1, u_int16_t a2, u_int16_t p) { - NTOHS(a1); - NTOHS(a2); - NTOHS(p); - return (pf_match(op, a1, a2, p)); + return (pf_match(op, ntohs(a1), ntohs(a2), ntohs(p))); } static int @@ -5034,7 +5031,7 @@ pf_get_mss(struct pf_pdesc *pd) break; case TCPOPT_MAXSEG: memcpy(&mss, (opt + 2), 2); - NTOHS(mss); + mss = ntohs(mss); /* FALLTHROUGH */ default: optlen = opt[1]; @@ -6103,7 +6100,6 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a, memcpy(&s->match_rules, match_rules, sizeof(s->match_rules)); memcpy(&s->act, &pd->act, sizeof(struct pf_rule_actions)); - STATE_INC_COUNTERS(s); if (r->allow_opts) s->state_flags |= PFSTATE_ALLOWOPTS; if (r->rule_flag & PFRULE_STATESLOPPY) @@ -6227,6 +6223,8 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a, } else *sm = s; + STATE_INC_COUNTERS(s); + /* * Lock order is important: first state, then source node. */ @@ -6302,7 +6300,6 @@ drop: if (s != NULL) { pf_src_tree_remove_state(s); s->timeout = PFTM_UNLINKED; - STATE_DEC_COUNTERS(s); pf_free_state(s); } @@ -8001,7 +7998,8 @@ pf_test_state_icmp(struct pf_kstate **state, struct pf_pdesc *pd, nk = (*state)->key[pd->didx]; #if defined(INET) && defined(INET6) - int afto, sidx, didx; + int afto, sidx, didx; + u_int16_t dummy_cksum = 0; afto = pd->af != nk->af; @@ -8026,10 +8024,10 @@ pf_test_state_icmp(struct pf_kstate **state, struct pf_pdesc *pd, nk->af)) return (PF_DROP); pf_change_ap(pd->m, pd2.src, &th.th_sport, - pd->ip_sum, &th.th_sum, &nk->addr[pd2.sidx], + pd->ip_sum, &dummy_cksum, &nk->addr[pd2.sidx], nk->port[sidx], 1, pd->af, nk->af); pf_change_ap(pd->m, pd2.dst, &th.th_dport, - pd->ip_sum, &th.th_sum, &nk->addr[pd2.didx], + pd->ip_sum, &dummy_cksum, &nk->addr[pd2.didx], nk->port[didx], 1, pd->af, nk->af); m_copyback(pd2.m, pd2.off, 8, (c_caddr_t)&th); PF_ACPY(&pd->nsaddr, &nk->addr[pd2.sidx], diff --git a/sys/netpfil/pf/pf_lb.c b/sys/netpfil/pf/pf_lb.c index ea9fbc46af63..f0cad4bb43c2 100644 --- a/sys/netpfil/pf/pf_lb.c +++ b/sys/netpfil/pf/pf_lb.c @@ -1065,19 +1065,19 @@ pf_get_transaddr_af(struct pf_krule *r, struct pf_pdesc *pd) } if (pd->proto == IPPROTO_ICMPV6 && pd->naf == AF_INET) { - NTOHS(pd->ndport); + pd->ndport = ntohs(pd->ndport); if (pd->ndport == ICMP6_ECHO_REQUEST) pd->ndport = ICMP_ECHO; else if (pd->ndport == ICMP6_ECHO_REPLY) pd->ndport = ICMP_ECHOREPLY; - HTONS(pd->ndport); + pd->ndport = htons(pd->ndport); } else if (pd->proto == IPPROTO_ICMP && pd->naf == AF_INET6) { - NTOHS(pd->ndport); + pd->nsport = ntohs(pd->nsport); if (pd->ndport == ICMP_ECHO) pd->ndport = ICMP6_ECHO_REQUEST; else if (pd->ndport == ICMP_ECHOREPLY) pd->ndport = ICMP6_ECHO_REPLY; - HTONS(pd->ndport); + pd->nsport = htons(pd->nsport); } /* get the destination address and port */ diff --git a/sys/netpfil/pf/pf_nl.c b/sys/netpfil/pf/pf_nl.c index 73c39e1f7471..3a5ae2f233b4 100644 --- a/sys/netpfil/pf/pf_nl.c +++ b/sys/netpfil/pf/pf_nl.c @@ -1937,6 +1937,142 @@ pf_handle_del_table(struct nlmsghdr *hdr, struct nl_pstate *npt) return (0); } +static bool +nlattr_add_pfr_table(struct nl_writer *nw, int attrtype, + struct pfr_table *t) +{ + int off = nlattr_add_nested(nw, attrtype); + + nlattr_add_string(nw, PF_T_ANCHOR, t->pfrt_anchor); + nlattr_add_string(nw, PF_T_NAME, t->pfrt_name); + nlattr_add_u32(nw, PF_T_TABLE_FLAGS, t->pfrt_flags); + + nlattr_set_len(nw, off); + + return (true); +} + +static int +pf_handle_get_tstats(struct nlmsghdr *hdr, struct nl_pstate *npt) +{ + struct pfioc_table attrs = { 0 }; + struct nl_writer *nw = npt->nw; + struct genlmsghdr *ghdr_new; + struct pfr_tstats *pfrtstats; + int error; + int n; + + PF_RULES_RLOCK_TRACKER; + + error = nl_parse_nlmsg(hdr, &table_parser, npt, &attrs); + if (error != 0) + return (error); + + PF_TABLE_STATS_LOCK(); + PF_RULES_RLOCK(); + + n = pfr_table_count(&attrs.pfrio_table, attrs.pfrio_flags); + pfrtstats = mallocarray(n, + sizeof(struct pfr_tstats), M_TEMP, M_NOWAIT | M_ZERO); + + error = pfr_get_tstats(&attrs.pfrio_table, pfrtstats, + &n, attrs.pfrio_flags | PFR_FLAG_USERIOCTL); + + PF_RULES_RUNLOCK(); + PF_TABLE_STATS_UNLOCK(); + + if (error == 0) { + hdr->nlmsg_flags |= NLM_F_MULTI; + + for (int i = 0; i < n; i++) { + uint64_t refcnt[PFR_REFCNT_MAX]; + + if (!nlmsg_reply(nw, hdr, sizeof(struct genlmsghdr))) { + error = ENOMEM; + break; + } + + ghdr_new = nlmsg_reserve_object(nw, struct genlmsghdr); + ghdr_new->cmd = PFNL_CMD_GET_TSTATS; + ghdr_new->version = 0; + ghdr_new->reserved = 0; + + nlattr_add_pfr_table(nw, PF_TS_TABLE, + &pfrtstats[i].pfrts_t); + nlattr_add_u64_array(nw, PF_TS_PACKETS, + PFR_DIR_MAX * PFR_OP_TABLE_MAX, + (uint64_t *)pfrtstats[i].pfrts_packets); + nlattr_add_u64_array(nw, PF_TS_BYTES, + PFR_DIR_MAX * PFR_OP_TABLE_MAX, + (uint64_t *)pfrtstats[i].pfrts_bytes); + nlattr_add_u64(nw, PF_TS_MATCH, + pfrtstats[i].pfrts_match); + nlattr_add_u64(nw, PF_TS_NOMATCH, + pfrtstats[i].pfrts_nomatch); + nlattr_add_u64(nw, PF_TS_TZERO, + pfrtstats[i].pfrts_tzero); + nlattr_add_u64(nw, PF_TS_CNT, pfrtstats[i].pfrts_cnt); + + for (int j = 0; j < PFR_REFCNT_MAX; j++) + refcnt[j] = pfrtstats[i].pfrts_refcnt[j]; + + nlattr_add_u64_array(nw, PF_TS_REFCNT, PFR_REFCNT_MAX, + refcnt); + + if (! nlmsg_end(nw)) { + error = ENOMEM; + break; + } + } + } + free(pfrtstats, M_TEMP); + + if (!nlmsg_end_dump(npt->nw, error, hdr)) { + NL_LOG(LOG_DEBUG, "Unable to finalize the dump"); + return (ENOMEM); + } + + return (error); +} + +static int +pf_handle_clear_tstats(struct nlmsghdr *hdr, struct nl_pstate *npt) +{ + struct pfioc_table attrs = { 0 }; + struct nl_writer *nw = npt->nw; + struct genlmsghdr *ghdr_new; + int error; + int nzero; + + PF_RULES_RLOCK_TRACKER; + + error = nl_parse_nlmsg(hdr, &table_parser, npt, &attrs); + if (error != 0) + return (error); + + PF_TABLE_STATS_LOCK(); + PF_RULES_RLOCK(); + error = pfr_clr_tstats(&attrs.pfrio_table, 1, + &nzero, attrs.pfrio_flags | PFR_FLAG_USERIOCTL); + PF_RULES_RUNLOCK(); + PF_TABLE_STATS_UNLOCK(); + + if (!nlmsg_reply(nw, hdr, sizeof(struct genlmsghdr))) + return (ENOMEM); + + ghdr_new = nlmsg_reserve_object(nw, struct genlmsghdr); + ghdr_new->cmd = PFNL_CMD_CLR_TSTATS; + ghdr_new->version = 0; + ghdr_new->reserved = 0; + + nlattr_add_u64(nw, PF_TS_NZERO, nzero); + + if (! nlmsg_end(nw)) + error = ENOMEM; + + return (error); +} + static const struct nlhdr_parser *all_parsers[] = { &state_parser, &addrule_parser, @@ -2152,6 +2288,20 @@ static const struct genl_cmd pf_cmds[] = { .cmd_flags = GENL_CMD_CAP_DO | GENL_CMD_CAP_HASPOL, .cmd_priv = PRIV_NETINET_PF, }, + { + .cmd_num = PFNL_CMD_GET_TSTATS, + .cmd_name = "GET_TSTATS", + .cmd_cb = pf_handle_get_tstats, + .cmd_flags = GENL_CMD_CAP_DUMP | GENL_CMD_CAP_HASPOL, + .cmd_priv = PRIV_NETINET_PF, + }, + { + .cmd_num = PFNL_CMD_CLR_TSTATS, + .cmd_name = "CLR_TSTATS", + .cmd_cb = pf_handle_clear_tstats, + .cmd_flags = GENL_CMD_CAP_DO | GENL_CMD_CAP_HASPOL, + .cmd_priv = PRIV_NETINET_PF, + }, }; void diff --git a/sys/netpfil/pf/pf_nl.h b/sys/netpfil/pf/pf_nl.h index dd68f452d7f1..55cc9c991b18 100644 --- a/sys/netpfil/pf/pf_nl.h +++ b/sys/netpfil/pf/pf_nl.h @@ -64,6 +64,8 @@ enum { PFNL_CMD_CLEAR_TABLES = 26, PFNL_CMD_ADD_TABLE = 27, PFNL_CMD_DEL_TABLE = 28, + PFNL_CMD_GET_TSTATS = 29, + PFNL_CMD_CLR_TSTATS = 30, __PFNL_CMD_MAX, }; #define PFNL_CMD_MAX (__PFNL_CMD_MAX -1) @@ -442,6 +444,19 @@ enum pf_tables_t { PF_T_NBR_ADDED = 6, /* u32 */ }; +enum pf_tstats_t { + PF_TS_UNSPEC, + PF_TS_TABLE = 1, /* nested, pfr_table */ + PF_TS_PACKETS = 2, /* u64 array */ + PF_TS_BYTES = 3, /* u64 array */ + PF_TS_MATCH = 4, /* u64 */ + PF_TS_NOMATCH = 5, /* u64 */ + PF_TS_TZERO = 6, /* u64 */ + PF_TS_CNT = 7, /* u64 */ + PF_TS_REFCNT = 8, /* u64 array */ + PF_TS_NZERO = 9, /* u64 */ +}; + #ifdef _KERNEL void pf_nl_register(void); diff --git a/sys/netpfil/pf/pf_osfp.c b/sys/netpfil/pf/pf_osfp.c index de60619bdc18..3e00cc7c80a2 100644 --- a/sys/netpfil/pf/pf_osfp.c +++ b/sys/netpfil/pf/pf_osfp.c @@ -157,13 +157,13 @@ pf_osfp_fingerprint_hdr(const struct ip *ip, const struct ip6_hdr *ip6, const st sizeof(fp.fp_mss)); fp.fp_tcpopts = (fp.fp_tcpopts << PF_OSFP_TCPOPT_BITS) | PF_OSFP_TCPOPT_MSS; - NTOHS(fp.fp_mss); + fp.fp_mss = ntohs(fp.fp_mss); break; case TCPOPT_WINDOW: if (optlen >= TCPOLEN_WINDOW) memcpy(&fp.fp_wscale, &optp[2], sizeof(fp.fp_wscale)); - NTOHS(fp.fp_wscale); + fp.fp_wscale = ntohs(fp.fp_wscale); fp.fp_tcpopts = (fp.fp_tcpopts << PF_OSFP_TCPOPT_BITS) | PF_OSFP_TCPOPT_WSCALE; diff --git a/sys/powerpc/aim/aim_machdep.c b/sys/powerpc/aim/aim_machdep.c index b439905441d3..814c679ff47e 100644 --- a/sys/powerpc/aim/aim_machdep.c +++ b/sys/powerpc/aim/aim_machdep.c @@ -417,6 +417,7 @@ aim_cpu_init(vm_offset_t toc) bcopy(&hypertrapcode, (void *)(EXC_HEA + trap_offset), trapsize); bcopy(&hypertrapcode, (void *)(EXC_HMI + trap_offset), trapsize); bcopy(&hypertrapcode, (void *)(EXC_HVI + trap_offset), trapsize); + bcopy(&hypertrapcode, (void *)(EXC_HFAC + trap_offset), trapsize); bcopy(&hypertrapcode, (void *)(EXC_SOFT_PATCH + trap_offset), trapsize); #endif diff --git a/sys/powerpc/conf/GENERIC64 b/sys/powerpc/conf/GENERIC64 index 9a363a5471a1..85711c8fc3ff 100644 --- a/sys/powerpc/conf/GENERIC64 +++ b/sys/powerpc/conf/GENERIC64 @@ -235,6 +235,7 @@ options IEEE80211_SUPPORT_MESH # enable 802.11s draft support options IEEE80211_DEBUG # enable debug msgs device wlan_wep # 802.11 WEP support device wlan_ccmp # 802.11 CCMP support +device wlan_gcmp # 802.11 GCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm device ath # Atheros CardBus/PCI NICs diff --git a/sys/powerpc/conf/GENERIC64LE b/sys/powerpc/conf/GENERIC64LE index 6aeb188d7501..a56feb6574a4 100644 --- a/sys/powerpc/conf/GENERIC64LE +++ b/sys/powerpc/conf/GENERIC64LE @@ -231,6 +231,7 @@ options IEEE80211_SUPPORT_MESH # enable 802.11s draft support options IEEE80211_DEBUG # enable debug msgs device wlan_wep # 802.11 WEP support device wlan_ccmp # 802.11 CCMP support +device wlan_gcmp # 802.11 GCMP support device wlan_tkip # 802.11 TKIP support device wlan_amrr # AMRR transmit rate control algorithm device ath # Atheros CardBus/PCI NICs diff --git a/sys/powerpc/include/spr.h b/sys/powerpc/include/spr.h index 5bb3858b0fb5..605b1be194d9 100644 --- a/sys/powerpc/include/spr.h +++ b/sys/powerpc/include/spr.h @@ -162,6 +162,11 @@ #define FSCR_DSCR 0x0000000000000004 /* DSCR available in PR state */ #define SPR_UAMOR 0x09d /* User Authority Mask Override Register */ #define SPR_DPDES 0x0b0 /* .6. Directed Privileged Doorbell Exception State Register */ +#define SPR_HFSCR 0xbe /* Hypervisor Facility Status and Control Register */ +#define HFSCR_BHRB 0x0000000000000010 /* BHRB instructions */ +#define HFSCR_PM 0x0000000000000008 /* Performance monitor SPRs */ +#define HFSCR_VECVSX 0x0000000000000002 /* Vector and VSX facilities */ +#define HFSCR_FP 0x0000000000000001 /* Floating Point facility */ #define SPR_USPRG0 0x100 /* 4.8 User SPR General 0 */ #define SPR_VRSAVE 0x100 /* .6. AltiVec VRSAVE */ #define SPR_SPRG0 0x110 /* 468 SPR General 0 */ diff --git a/sys/powerpc/powernv/platform_powernv.c b/sys/powerpc/powernv/platform_powernv.c index 50af24794e69..678631322173 100644 --- a/sys/powerpc/powernv/platform_powernv.c +++ b/sys/powerpc/powernv/platform_powernv.c @@ -138,6 +138,7 @@ powernv_attach(platform_t plat) phandle_t opal; int res, len, idx; register_t msr; + register_t fscr; bool has_lp; /* Ping OPAL again just to make sure */ @@ -179,6 +180,11 @@ powernv_attach(platform_t plat) mtspr(SPR_LPCR, lpcr); isync(); + fscr = mfspr(SPR_HFSCR); + fscr |= FSCR_TAR | FSCR_EBB | HFSCR_BHRB | HFSCR_PM | + HFSCR_VECVSX | HFSCR_FP | FSCR_MSGP | FSCR_DSCR; + mtspr(SPR_HFSCR, fscr); + mtmsr(msr); powernv_cpuref_init(); diff --git a/sys/powerpc/powerpc/trap.c b/sys/powerpc/powerpc/trap.c index ab3e56875169..d919b7715664 100644 --- a/sys/powerpc/powerpc/trap.c +++ b/sys/powerpc/powerpc/trap.c @@ -138,6 +138,7 @@ static struct powerpc_exception powerpc_exceptions[] = { { EXC_VEC, "altivec unavailable" }, { EXC_VSX, "vsx unavailable" }, { EXC_FAC, "facility unavailable" }, + { EXC_HFAC, "hypervisor facility unavailable" }, { EXC_ITMISS, "instruction tlb miss" }, { EXC_DLMISS, "data load tlb miss" }, { EXC_DSMISS, "data store tlb miss" }, @@ -147,6 +148,7 @@ static struct powerpc_exception powerpc_exceptions[] = { { EXC_THRM, "thermal management" }, { EXC_RUNMODETRC, "run mode/trace" }, { EXC_SOFT_PATCH, "soft patch exception" }, + { EXC_HVI, "hypervisor virtualization" }, { EXC_LAST, NULL } }; @@ -351,6 +353,7 @@ trap(struct trapframe *frame) mtspr(SPR_FSCR, fscr & ~FSCR_IC_MASK); break; case EXC_HEA: + case EXC_HFAC: sig = SIGILL; ucode = ILL_ILLOPC; break; diff --git a/sys/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC index 8dca3bdb3369..7d7d0ca6e79c 100644 --- a/sys/riscv/conf/GENERIC +++ b/sys/riscv/conf/GENERIC @@ -161,6 +161,7 @@ device fdt_pinctrl # SPI device spibus device spigen +device xilinx_spi # Xilinx AXI SPI Controller # Debugging support. Always need this: options KDB # Enable kernel debugger support. diff --git a/sys/riscv/riscv/timer.c b/sys/riscv/riscv/timer.c index dc909082edae..652e5c8db62b 100644 --- a/sys/riscv/riscv/timer.c +++ b/sys/riscv/riscv/timer.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2015-2024 Ruslan Bukin <br@bsdpad.com> + * Copyright (c) 2015-2025 Ruslan Bukin <br@bsdpad.com> * All rights reserved. * * Portions of this software were developed by SRI International and the @@ -146,7 +146,7 @@ riscv_timer_intr(void *arg) if (has_sstc) csr_write(stimecmp, -1UL); else - csr_clear(sip, SIP_STIP); + sbi_set_timer(-1UL); if (sc->et.et_active) sc->et.et_event_cb(&sc->et, sc->et.et_arg); diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h index 766ff6ede51b..488aaaf25ab1 100644 --- a/sys/sys/elf_common.h +++ b/sys/sys/elf_common.h @@ -840,6 +840,7 @@ typedef struct { #define NT_PROCSTAT_PSSTRINGS 15 /* Procstat ps_strings data. */ #define NT_PROCSTAT_AUXV 16 /* Procstat auxv data. */ #define NT_PTLWPINFO 17 /* Thread ptrace miscellaneous info. */ +#define NT_PROCSTAT_KQUEUES 18 /* Procstat kqueues events. */ #define NT_PPC_VMX 0x100 /* PowerPC Altivec/VMX registers */ #define NT_PPC_VSX 0x102 /* PowerPC VSX registers */ #define NT_X86_SEGBASES 0x200 /* x86 FS/GS base addresses. */ diff --git a/sys/sys/event.h b/sys/sys/event.h index dee3365ba7b6..1b30e4292de8 100644 --- a/sys/sys/event.h +++ b/sys/sys/event.h @@ -101,7 +101,7 @@ struct freebsd11_kevent { }; #endif -#if defined(_WANT_KEVENT32) || (defined(_KERNEL) && defined(__LP64__)) +#if defined(_WANT_KEVENT32) || defined(_KERNEL) struct kevent32 { __uint32_t ident; /* identifier for this event */ short filter; /* filter for event */ diff --git a/sys/sys/file.h b/sys/sys/file.h index bc7dd7e06ded..d0b53196151e 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -267,6 +267,8 @@ int fget_fcntl(struct thread *td, int fd, cap_rights_t *rightsp, int needfcntl, struct file **fpp); int _fdrop(struct file *fp, struct thread *td); int fget_remote(struct thread *td, struct proc *p, int fd, struct file **fpp); +int fget_remote_foreach(struct thread *td, struct proc *p, + int (*fn)(struct proc *, int, struct file *, void *), void *arg); fo_rdwr_t invfo_rdwr; fo_truncate_t invfo_truncate; diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h index 9d06cd33d5d2..6608b9250da4 100644 --- a/sys/sys/ktrace.h +++ b/sys/sys/ktrace.h @@ -87,10 +87,9 @@ struct ktr_header { * is the public interface. */ #define KTRCHECK(td, type) ((td)->td_proc->p_traceflag & (1 << type)) -#define KTRPOINT(td, type) (__predict_false(KTRCHECK((td), (type)))) -#define KTRCHECKDRAIN(td) (!(STAILQ_EMPTY(&(td)->td_proc->p_ktr))) +#define KTRPOINT(td, type) (__predict_false(KTRCHECK((td), (type)))) #define KTRUSERRET(td) do { \ - if (__predict_false(KTRCHECKDRAIN(td))) \ + if (__predict_false(!STAILQ_EMPTY_ATOMIC(&(td)->td_proc->p_ktr))) \ ktruserret(td); \ } while (0) diff --git a/sys/sys/param.h b/sys/sys/param.h index ca6957ccdb14..b08a83ccc25b 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -73,7 +73,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1500034 +#define __FreeBSD_version 1500035 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 735ff49062de..02d0ca139fa4 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -80,6 +80,7 @@ struct so_splice { struct mtx mtx; unsigned int wq_index; enum so_splice_state { + SPLICE_INIT, /* embryonic state, don't queue work yet */ SPLICE_IDLE, /* waiting for work to arrive */ SPLICE_QUEUED, /* a wakeup has queued some work */ SPLICE_RUNNING, /* currently transferring data */ diff --git a/sys/sys/user.h b/sys/sys/user.h index cf42412af66f..0c443672a3b1 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -677,9 +677,11 @@ struct kinfo_vm_layout { #define KNOTE_EXTDATA_PIPE 2 struct kinfo_knote { + int knt_kq_fd; struct kevent knt_event; int knt_status; int knt_extdata; + uint64_t knt_spare0[4]; union { struct { int knt_vnode_type; @@ -720,6 +722,8 @@ int kern_proc_cwd_out(struct proc *p, struct sbuf *sb, ssize_t maxlen); int kern_proc_out(struct proc *p, struct sbuf *sb, int flags); int kern_proc_vmmap_out(struct proc *p, struct sbuf *sb, ssize_t maxlen, int flags); +int kern_proc_kqueues_out(struct proc *p, struct sbuf *s, size_t maxlen, + bool compat32); int vntype_to_kinfo(int vtype); void pack_kinfo(struct kinfo_file *kif); diff --git a/sys/ufs/ffs/ffs_subr.c b/sys/ufs/ffs/ffs_subr.c index c293cbbcbfb0..682dd60ebd44 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/sys/ufs/ffs/ffs_subr.c @@ -340,31 +340,36 @@ ffs_oldfscompat_read(struct fs *fs, ufs2_daddr_t sblockloc) fs->fs_old_flags |= FS_FLAGS_UPDATED; fs->fs_sblockloc = sblockloc; } - /* - * If not yet done, update UFS1 superblock with new wider fields. - */ - if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_maxbsize != fs->fs_bsize) { - fs->fs_maxbsize = fs->fs_bsize; - fs->fs_time = fs->fs_old_time; - fs->fs_size = fs->fs_old_size; - fs->fs_dsize = fs->fs_old_dsize; - fs->fs_csaddr = fs->fs_old_csaddr; - fs->fs_cstotal.cs_ndir = fs->fs_old_cstotal.cs_ndir; - fs->fs_cstotal.cs_nbfree = fs->fs_old_cstotal.cs_nbfree; - fs->fs_cstotal.cs_nifree = fs->fs_old_cstotal.cs_nifree; - fs->fs_cstotal.cs_nffree = fs->fs_old_cstotal.cs_nffree; - } - if (fs->fs_magic == FS_UFS1_MAGIC && - fs->fs_old_inodefmt < FS_44INODEFMT) { - fs->fs_maxfilesize = ((uint64_t)1 << 31) - 1; - fs->fs_qbmask = ~fs->fs_bmask; - fs->fs_qfmask = ~fs->fs_fmask; - } - if (fs->fs_magic == FS_UFS1_MAGIC) { + switch (fs->fs_magic) { + case FS_UFS2_MAGIC: + /* No changes for now */ + break; + + case FS_UFS1_MAGIC: + /* + * If not yet done, update UFS1 superblock with new wider fields + */ + if (fs->fs_maxbsize != fs->fs_bsize) { + fs->fs_maxbsize = fs->fs_bsize; + fs->fs_time = fs->fs_old_time; + fs->fs_size = fs->fs_old_size; + fs->fs_dsize = fs->fs_old_dsize; + fs->fs_csaddr = fs->fs_old_csaddr; + fs->fs_cstotal.cs_ndir = fs->fs_old_cstotal.cs_ndir; + fs->fs_cstotal.cs_nbfree = fs->fs_old_cstotal.cs_nbfree; + fs->fs_cstotal.cs_nifree = fs->fs_old_cstotal.cs_nifree; + fs->fs_cstotal.cs_nffree = fs->fs_old_cstotal.cs_nffree; + } + if (fs->fs_old_inodefmt < FS_44INODEFMT) { + fs->fs_maxfilesize = ((uint64_t)1 << 31) - 1; + fs->fs_qbmask = ~fs->fs_bmask; + fs->fs_qfmask = ~fs->fs_fmask; + } fs->fs_save_maxfilesize = fs->fs_maxfilesize; maxfilesize = (uint64_t)0x80000000 * fs->fs_bsize - 1; if (fs->fs_maxfilesize > maxfilesize) fs->fs_maxfilesize = maxfilesize; + break; } /* Compatibility for old filesystems */ if (fs->fs_avgfilesize <= 0) @@ -384,16 +389,35 @@ void ffs_oldfscompat_write(struct fs *fs) { - /* - * Copy back UFS2 updated fields that UFS1 inspects. - */ - if (fs->fs_magic == FS_UFS1_MAGIC) { + switch (fs->fs_magic) { + case FS_UFS1_MAGIC: + if (fs->fs_sblockloc != SBLOCK_UFS1 && + (fs->fs_old_flags & FS_FLAGS_UPDATED) == 0) { + printf( + "WARNING: %s: correcting fs_sblockloc from %jd to %d\n", + fs->fs_fsmnt, fs->fs_sblockloc, SBLOCK_UFS1); + fs->fs_sblockloc = SBLOCK_UFS1; + } + /* + * Copy back UFS2 updated fields that UFS1 inspects. + */ fs->fs_old_time = fs->fs_time; fs->fs_old_cstotal.cs_ndir = fs->fs_cstotal.cs_ndir; fs->fs_old_cstotal.cs_nbfree = fs->fs_cstotal.cs_nbfree; fs->fs_old_cstotal.cs_nifree = fs->fs_cstotal.cs_nifree; fs->fs_old_cstotal.cs_nffree = fs->fs_cstotal.cs_nffree; - fs->fs_maxfilesize = fs->fs_save_maxfilesize; + if (fs->fs_save_maxfilesize != 0) + fs->fs_maxfilesize = fs->fs_save_maxfilesize; + break; + case FS_UFS2_MAGIC: + if (fs->fs_sblockloc != SBLOCK_UFS2 && + (fs->fs_old_flags & FS_FLAGS_UPDATED) == 0) { + printf( + "WARNING: %s: correcting fs_sblockloc from %jd to %d\n", + fs->fs_fsmnt, fs->fs_sblockloc, SBLOCK_UFS2); + fs->fs_sblockloc = SBLOCK_UFS2; + } + break; } } @@ -407,9 +431,8 @@ static int prttimechgs = 0; #ifdef _KERNEL SYSCTL_NODE(_vfs, OID_AUTO, ffs, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "FFS filesystem"); - SYSCTL_INT(_vfs_ffs, OID_AUTO, prttimechgs, CTLFLAG_RWTUN, &prttimechgs, 0, - "print UFS1 time changes made to inodes"); + "print UFS1 time changes made to inodes"); #endif /* _KERNEL */ bool ffs_oldfscompat_inode_read(struct fs *fs, union dinodep dp, time_t now) @@ -931,6 +954,7 @@ int ffs_sbput(void *devfd, struct fs *fs, off_t loc, int (*writefunc)(void *devfd, off_t loc, void *buf, int size)) { + struct fs_summary_info *fs_si; int i, error, blks, size; uint8_t *space; @@ -953,23 +977,27 @@ ffs_sbput(void *devfd, struct fs *fs, off_t loc, } } fs->fs_fmod = 0; -#ifndef _KERNEL - { - struct fs_summary_info *fs_si; - - fs->fs_time = time(NULL); - /* Clear the pointers for the duration of writing. */ - fs_si = fs->fs_si; - fs->fs_si = NULL; - fs->fs_ckhash = ffs_calc_sbhash(fs); - error = (*writefunc)(devfd, loc, fs, fs->fs_sbsize); - fs->fs_si = fs_si; - } -#else /* _KERNEL */ + ffs_oldfscompat_write(fs); +#ifdef _KERNEL fs->fs_time = time_second; +#else /* User Code */ + fs->fs_time = time(NULL); +#endif + /* Clear the pointers for the duration of writing. */ + fs_si = fs->fs_si; + fs->fs_si = NULL; fs->fs_ckhash = ffs_calc_sbhash(fs); error = (*writefunc)(devfd, loc, fs, fs->fs_sbsize); -#endif /* _KERNEL */ + /* + * A negative error code is returned when a copy of the + * superblock has been made which is discarded when the I/O + * is done. So the fs_si field does not and indeed cannot be + * restored after the write is done. Convert the error code + * back to its usual positive value when returning it. + */ + if (error < 0) + return (-error - 1); + fs->fs_si = fs_si; return (error); } diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index 498ef61d7cf1..891e490a7031 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -2032,9 +2032,15 @@ ffs_sbupdate(struct ufsmount *ump, int waitfor, int suspended) panic("ffs_sbupdate: write read-only filesystem"); /* * We use the superblock's buf to serialize calls to ffs_sbupdate(). + * Copy superblock to this buffer and have it written out. */ sbbp = getblk(ump->um_devvp, btodb(fs->fs_sblockloc), (int)fs->fs_sbsize, 0, 0, 0); + UFS_LOCK(ump); + fs->fs_fmod = 0; + bcopy((caddr_t)fs, sbbp->b_data, (uint64_t)fs->fs_sbsize); + UFS_UNLOCK(ump); + fs = (struct fs *)sbbp->b_data; /* * Initialize info needed for write function. */ @@ -2060,7 +2066,8 @@ ffs_use_bwrite(void *devfd, off_t loc, void *buf, int size) devfdp = devfd; ump = devfdp->ump; - fs = ump->um_fs; + bp = devfdp->sbbp; + fs = (struct fs *)bp->b_data; /* * Writing the superblock summary information. */ @@ -2077,44 +2084,27 @@ ffs_use_bwrite(void *devfd, off_t loc, void *buf, int size) } /* * Writing the superblock itself. We need to do special checks for it. + * A negative error code is returned to indicate that a copy of the + * superblock has been made and that the copy is discarded when the + * I/O is done. So the the caller should not attempt to restore the + * fs_si field after the write is done. The caller will convert the + * error code back to its usual positive value when returning it. */ - bp = devfdp->sbbp; if (ffs_fsfail_cleanup(ump, devfdp->error)) devfdp->error = 0; if (devfdp->error != 0) { brelse(bp); - return (devfdp->error); - } - if (fs->fs_magic == FS_UFS1_MAGIC && fs->fs_sblockloc != SBLOCK_UFS1 && - (fs->fs_old_flags & FS_FLAGS_UPDATED) == 0) { - printf("WARNING: %s: correcting fs_sblockloc from %jd to %d\n", - fs->fs_fsmnt, fs->fs_sblockloc, SBLOCK_UFS1); - fs->fs_sblockloc = SBLOCK_UFS1; - } - if (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_sblockloc != SBLOCK_UFS2 && - (fs->fs_old_flags & FS_FLAGS_UPDATED) == 0) { - printf("WARNING: %s: correcting fs_sblockloc from %jd to %d\n", - fs->fs_fsmnt, fs->fs_sblockloc, SBLOCK_UFS2); - fs->fs_sblockloc = SBLOCK_UFS2; + return (-devfdp->error - 1); } if (MOUNTEDSOFTDEP(ump->um_mountp)) - softdep_setup_sbupdate(ump, (struct fs *)bp->b_data, bp); - UFS_LOCK(ump); - bcopy((caddr_t)fs, bp->b_data, (uint64_t)fs->fs_sbsize); - UFS_UNLOCK(ump); - fs = (struct fs *)bp->b_data; - fs->fs_fmod = 0; - ffs_oldfscompat_write(fs); - fs->fs_si = NULL; - /* Recalculate the superblock hash */ - fs->fs_ckhash = ffs_calc_sbhash(fs); + softdep_setup_sbupdate(ump, fs, bp); if (devfdp->suspended) bp->b_flags |= B_VALIDSUSPWRT; if (devfdp->waitfor != MNT_WAIT) bawrite(bp); else if ((error = bwrite(bp)) != 0) devfdp->error = error; - return (devfdp->error); + return (-devfdp->error - 1); } static int diff --git a/sys/ufs/ufs/ufs_acl.c b/sys/ufs/ufs/ufs_acl.c index 6fad085daea1..4b6cabc2ab30 100644 --- a/sys/ufs/ufs/ufs_acl.c +++ b/sys/ufs/ufs/ufs_acl.c @@ -609,11 +609,11 @@ ufs_setacl(struct vop_setacl_args *ap) } static int -ufs_aclcheck_nfs4(struct vop_aclcheck_args *ap) +ufs_aclcheck_nfs4(struct vop_aclcheck_args *ap, struct mount *mp) { int is_directory = 0; - if ((ap->a_vp->v_mount->mnt_flag & MNT_NFS4ACLS) == 0) + if ((mp->mnt_flag & MNT_NFS4ACLS) == 0) return (EINVAL); /* @@ -631,10 +631,9 @@ ufs_aclcheck_nfs4(struct vop_aclcheck_args *ap) } static int -ufs_aclcheck_posix1e(struct vop_aclcheck_args *ap) +ufs_aclcheck_posix1e(struct vop_aclcheck_args *ap, struct mount *mp) { - - if ((ap->a_vp->v_mount->mnt_flag & MNT_ACLS) == 0) + if ((mp->mnt_flag & MNT_ACLS) == 0) return (EINVAL); /* @@ -642,7 +641,7 @@ ufs_aclcheck_posix1e(struct vop_aclcheck_args *ap) * to this kind of object. * Rely on the acl_posix1e_check() routine to verify the contents. */ - switch(ap->a_type) { + switch (ap->a_type) { case ACL_TYPE_ACCESS: break; @@ -667,14 +666,18 @@ ufs_aclcheck_posix1e(struct vop_aclcheck_args *ap) int ufs_aclcheck(struct vop_aclcheck_args *ap) { + struct mount *mp; - if ((ap->a_vp->v_mount->mnt_flag & (MNT_ACLS | MNT_NFS4ACLS)) == 0) + mp = atomic_load_ptr(&ap->a_vp->v_mount); + if (mp == NULL) + return (EBADF); + if ((mp->mnt_flag & (MNT_ACLS | MNT_NFS4ACLS)) == 0) return (EOPNOTSUPP); if (ap->a_type == ACL_TYPE_NFS4) - return (ufs_aclcheck_nfs4(ap)); + return (ufs_aclcheck_nfs4(ap, mp)); - return (ufs_aclcheck_posix1e(ap)); + return (ufs_aclcheck_posix1e(ap, mp)); } #endif /* !UFS_ACL */ diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c index 1102cb61323a..3dc278851cc9 100644 --- a/sys/vm/vm_reserv.c +++ b/sys/vm/vm_reserv.c @@ -506,7 +506,8 @@ vm_reserv_from_page(vm_page_t m) } /* - * Returns an existing reservation or NULL and initialized successor pointer. + * Either returns an existing reservation or returns NULL and initializes + * successor pointer. */ static vm_reserv_t vm_reserv_from_object(vm_object_t object, vm_pindex_t pindex, @@ -515,7 +516,6 @@ vm_reserv_from_object(vm_object_t object, vm_pindex_t pindex, vm_reserv_t rv; vm_page_t msucc; - msucc = NULL; if (mpred != NULL) { KASSERT(mpred->object == object, ("vm_reserv_from_object: object doesn't contain mpred")); @@ -523,7 +523,7 @@ vm_reserv_from_object(vm_object_t object, vm_pindex_t pindex, ("vm_reserv_from_object: mpred doesn't precede pindex")); rv = vm_reserv_from_page(mpred); if (rv->object == object && vm_reserv_has_pindex(rv, pindex)) - goto found; + return (rv); msucc = TAILQ_NEXT(mpred, listq); } else msucc = TAILQ_FIRST(&object->memq); @@ -532,14 +532,10 @@ vm_reserv_from_object(vm_object_t object, vm_pindex_t pindex, ("vm_reserv_from_object: msucc doesn't succeed pindex")); rv = vm_reserv_from_page(msucc); if (rv->object == object && vm_reserv_has_pindex(rv, pindex)) - goto found; + return (rv); } - rv = NULL; - -found: *msuccp = msucc; - - return (rv); + return (NULL); } /* diff --git a/tests/sys/netinet/Makefile b/tests/sys/netinet/Makefile index bd972bc3b2a0..cc525bf24480 100644 --- a/tests/sys/netinet/Makefile +++ b/tests/sys/netinet/Makefile @@ -24,6 +24,7 @@ ATF_TESTS_SH= arp \ fibs_test \ forward \ lpm \ + multicast \ output \ redirect @@ -47,7 +48,7 @@ TEST_METADATA.forward+= required_programs="python" \ TEST_METADATA.output+= required_programs="python" TEST_METADATA.redirect+= required_programs="python" -PROGS= udp_dontroute tcp_user_cookie +PROGS= udp_dontroute tcp_user_cookie sendto-IP_MULTICAST_IF ${PACKAGE}FILES+= redirect.py diff --git a/tests/sys/netinet/multicast.sh b/tests/sys/netinet/multicast.sh new file mode 100644 index 000000000000..eb2b962dac70 --- /dev/null +++ b/tests/sys/netinet/multicast.sh @@ -0,0 +1,61 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2025 Gleb Smirnoff <glebius@FreeBSD.org> +# +# 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. + +. $(atf_get_srcdir)/../common/vnet.subr + +# See regression fixed in baad45c9c12028964acd0b58096f3aaa0fb22859 +atf_test_case "IP_MULTICAST_IF" "cleanup" +IP_MULTICAST_IF_head() +{ + atf_set descr \ + 'sendto() for IP_MULTICAST_IF socket does not do routing lookup' + atf_set require.user root + +} + +IP_MULTICAST_IF_body() +{ + local epair mjail + + vnet_init + # The test doesn't use our half of epair + epair=$(vnet_mkepair) + vnet_mkjail mjail ${epair}a + jexec mjail ifconfig ${epair}a up + jexec mjail ifconfig ${epair}a 192.0.2.1/24 + atf_check -s exit:0 -o empty \ + jexec mjail $(atf_get_srcdir)/sendto-IP_MULTICAST_IF 192.0.2.1 +} + +IP_MULTICAST_IF_cleanup() +{ + vnet_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "IP_MULTICAST_IF" +} diff --git a/tests/sys/netinet/sendto-IP_MULTICAST_IF.c b/tests/sys/netinet/sendto-IP_MULTICAST_IF.c new file mode 100644 index 000000000000..d478e4da0b3b --- /dev/null +++ b/tests/sys/netinet/sendto-IP_MULTICAST_IF.c @@ -0,0 +1,63 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2025 Gleb Smirnoff <glebius@FreeBSD.org> + * + * 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 <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include <assert.h> +#include <err.h> + +int +main(int argc, char *argv[]) +{ + struct sockaddr_in sin = { + .sin_family = AF_INET, + .sin_len = sizeof(struct sockaddr_in), + }; + struct in_addr in; + int s, rv; + + if (argc < 2) + errx(1, "Usage: %s IPv4-address", argv[0]); + + if (inet_pton(AF_INET, argv[1], &in) != 1) + err(1, "inet_pton(%s) failed", argv[1]); + + assert((s = socket(PF_INET, SOCK_DGRAM, 0)) > 0); + assert(bind(s, (struct sockaddr *)&sin, sizeof(sin)) == 0); + assert(setsockopt(s, IPPROTO_IP, IP_MULTICAST_IF, &in, sizeof(in)) + == 0); + /* RFC 6676 */ + assert(inet_pton(AF_INET, "233.252.0.1", &sin.sin_addr) == 1); + sin.sin_port = htons(6676); + rv = sendto(s, &sin, sizeof(sin), 0, + (struct sockaddr *)&sin, sizeof(sin)); + if (rv != sizeof(sin)) + err(1, "sendto failed"); + + return (0); +} diff --git a/tests/sys/netipsec/tunnel/empty.sh b/tests/sys/netipsec/tunnel/empty.sh index dc1d3708f744..56480d21f4ec 100755 --- a/tests/sys/netipsec/tunnel/empty.sh +++ b/tests/sys/netipsec/tunnel/empty.sh @@ -11,7 +11,7 @@ v4_head() v4_body() { # Can't use filename "null" for this script: PR 223564 - ist_test 4 null "" + ist_test 4 null "1234" } v4_cleanup() @@ -28,7 +28,7 @@ v6_head() v6_body() { - ist_test 6 null "" + ist_test 6 null "5678" } v6_cleanup() diff --git a/tests/sys/netpfil/pf/Makefile b/tests/sys/netpfil/pf/Makefile index 8a24fae47dcb..3b1ba2085f43 100644 --- a/tests/sys/netpfil/pf/Makefile +++ b/tests/sys/netpfil/pf/Makefile @@ -45,6 +45,7 @@ ATF_TESTS_SH+= altq \ sctp \ set_skip \ set_tos \ + snmp \ src_track \ status \ syncookie \ @@ -63,7 +64,9 @@ ATF_TESTS_PYTEST+= sctp.py TEST_METADATA+= execenv="jail" TEST_METADATA+= execenv_jail_params="vnet allow.raw_sockets" -${PACKAGE}FILES+= CVE-2019-5597.py \ +${PACKAGE}FILES+= \ + bsnmpd.conf \ + CVE-2019-5597.py \ CVE-2019-5598.py \ daytime_inetd.conf \ echo_inetd.conf \ @@ -79,6 +82,7 @@ ${PACKAGE}FILES+= CVE-2019-5597.py \ rdr-srcport.py \ utils.subr +${PACKAGE}FILESMODE_bsnmpd.conf= 0555 ${PACKAGE}FILESMODE_CVE-2019-5597.py= 0555 ${PACKAGE}FILESMODE_CVE-2019-5598.py= 0555 ${PACKAGE}FILESMODE_fragcommon.py= 0555 diff --git a/tests/sys/netpfil/pf/bsnmpd.conf b/tests/sys/netpfil/pf/bsnmpd.conf new file mode 100644 index 000000000000..27abdda6cbd3 --- /dev/null +++ b/tests/sys/netpfil/pf/bsnmpd.conf @@ -0,0 +1,47 @@ +location := "A galaxy far, far away" +contact := "skywalker@Tatooine" +system := 1 + +read := "public" +write := "geheim" +trap := "mytrap" + +NoAuthProtocol := 1.3.6.1.6.3.10.1.1.1 +HMACMD5AuthProtocol := 1.3.6.1.6.3.10.1.1.2 +HMACSHAAuthProtocol := 1.3.6.1.6.3.10.1.1.3 +NoPrivProtocol := 1.3.6.1.6.3.10.1.2.1 +DESPrivProtocol := 1.3.6.1.6.3.10.1.2.2 +AesCfb128Protocol := 1.3.6.1.6.3.10.1.2.4 + +securityModelAny := 0 +securityModelSNMPv1 := 1 +securityModelSNMPv2c := 2 +securityModelUSM := 3 + +MPmodelSNMPv1 := 0 +MPmodelSNMPv2c := 1 +MPmodelSNMPv3 := 3 + +noAuthNoPriv := 1 +authNoPriv := 2 +authPriv := 3 + +%snmpd +begemotSnmpdDebugDumpPdus = 2 +begemotSnmpdDebugSyslogPri = 7 + +begemotSnmpdCommunityString.0.1 = $(read) +begemotSnmpdCommunityDisable = 1 + +begemotSnmpdTransInetStatus.1.4.0.0.0.0.161.1 = 4 +begemotSnmpdTransInetStatus.2.16.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.161.1 = 4 + +begemotSnmpdLocalPortStatus."/var/run/snmpd.sock" = 1 +begemotSnmpdLocalPortType."/var/run/snmpd.sock" = 4 + +sysContact = $(contact) +sysLocation = $(location) +sysObjectId = 1.3.6.1.4.1.12325.1.1.2.1.$(system) + +begemotSnmpdModulePath."mibII" = "/usr/lib/snmp_mibII.so" +begemotSnmpdModulePath."pf" = "/usr/lib/snmp_pf.so" diff --git a/tests/sys/netpfil/pf/snmp.sh b/tests/sys/netpfil/pf/snmp.sh new file mode 100644 index 000000000000..37cc4b75cf92 --- /dev/null +++ b/tests/sys/netpfil/pf/snmp.sh @@ -0,0 +1,123 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (c) 2025 Kristof Provost <kp@FreeBSD.org> +# +# 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. + +. $(atf_get_srcdir)/utils.subr + +atf_test_case "basic" "cleanup" +basic_head() +{ + atf_set descr 'Basic pf_snmp test' + atf_set require.user root +} + +basic_body() +{ + pft_init + + epair=$(vnet_mkepair) + + ifconfig ${epair}b 192.0.2.2/24 up + + vnet_mkjail alcatraz ${epair}a + jexec alcatraz ifconfig ${epair}a 192.0.2.1/24 up + + # Start bsnmpd + jexec alcatraz bsnmpd -c $(atf_get_srcdir)/bsnmpd.conf + + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "pass" + + # Sanity check, and create state + atf_check -s exit:0 -o ignore \ + ping -c 1 192.0.2.1 + + # pf should be enabled + atf_check -s exit:0 -o match:'pfStatusRunning.0 = true' \ + bsnmpwalk -s public@192.0.2.1 -i pf_tree.def begemot +} + +basic_cleanup() +{ + pft_cleanup +} + +atf_test_case "table" "cleanup" +table_head() +{ + atf_set descr 'Test tables and pf_snmp' + atf_set require.user root +} + +table_body() +{ + pft_init + + epair=$(vnet_mkepair) + + ifconfig ${epair}b 192.0.2.2/24 up + + vnet_mkjail alcatraz ${epair}a + jexec alcatraz ifconfig ${epair}a 192.0.2.1/24 up + + jexec alcatraz pfctl -e + pft_set_rules alcatraz \ + "table <foo> counters { 192.0.2.0/24 }" \ + "pass in from <foo>" + + # Start bsnmpd after creating the table so we don't have to wait for + # a refresh timeout + jexec alcatraz bsnmpd -c $(atf_get_srcdir)/bsnmpd.conf + + # Sanity check, and create state + atf_check -s exit:0 -o ignore \ + ping -c 1 192.0.2.1 + + # We should have one table + atf_check -s exit:0 -o match:'pfTablesTblNumber.0 = 1' \ + bsnmpwalk -s public@192.0.2.1 -i pf_tree.def begemot + + # We have the 'foo' table + atf_check -s exit:0 -o match:'pfTablesTblDescr.* = foo' \ + bsnmpwalk -s public@192.0.2.1 -i pf_tree.def pfTables + + # Which contains address 192.0.2.0/24 + atf_check -s exit:0 -o match:'pfTablesAddrNet.* = 192.0.2.0' \ + bsnmpwalk -s public@192.0.2.1 -i pf_tree.def pfTables + atf_check -s exit:0 -o match:'pfTablesAddrPrefix.* = 24' \ + bsnmpwalk -s public@192.0.2.1 -i pf_tree.def pfTables +} + +table_cleanup() +{ + pft_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case "basic" + atf_add_test_case "table" +} diff --git a/tests/sys/netpfil/pf/table.sh b/tests/sys/netpfil/pf/table.sh index a3d00f8cdb14..78320375db7c 100644 --- a/tests/sys/netpfil/pf/table.sh +++ b/tests/sys/netpfil/pf/table.sh @@ -236,6 +236,60 @@ zero_one_cleanup() pft_cleanup } +atf_test_case "zero_all" "cleanup" +zero_all_head() +{ + atf_set descr 'Test zeroing all table entries' + atf_set require.user root +} + +zero_all_body() +{ + pft_init + + epair_send=$(vnet_mkepair) + ifconfig ${epair_send}a 192.0.2.1/24 up + ifconfig ${epair_send}a inet alias 192.0.2.3/24 + + vnet_mkjail alcatraz ${epair_send}b + jexec alcatraz ifconfig ${epair_send}b 192.0.2.2/24 up + jexec alcatraz pfctl -e + + pft_set_rules alcatraz \ + "table <foo> counters { 192.0.2.1, 192.0.2.3 }" \ + "block all" \ + "pass in from <foo> to any" \ + "pass out from any to <foo>" \ + "set skip on lo" + + atf_check -s exit:0 -o ignore ping -c 3 -S 192.0.2.1 192.0.2.2 + atf_check -s exit:0 -o ignore ping -c 3 -S 192.0.2.3 192.0.2.2 + + jexec alcatraz pfctl -t foo -T show -vv + atf_check -s exit:0 -e ignore \ + -o match:'In/Block:.*'"$TABLE_STATS_ZERO_REGEXP" \ + -o match:'In/Pass:.*'"$TABLE_STATS_NONZERO_REGEXP" \ + -o match:'Out/Block:.*'"$TABLE_STATS_ZERO_REGEXP" \ + -o match:'Out/Pass:.*'"$TABLE_STATS_NONZERO_REGEXP" \ + jexec alcatraz pfctl -t foo -T show -vv + + atf_check -s exit:0 -e ignore \ + jexec alcatraz pfctl -t foo -T zero + + jexec alcatraz pfctl -t foo -T show -vv + atf_check -s exit:0 -e ignore \ + -o match:'In/Pass:.*'"$TABLE_STATS_ZERO_REGEXP" \ + -o match:'Out/Pass:.*'"$TABLE_STATS_ZERO_REGEXP" \ + -o match:'In/Pass:.*'"$TABLE_STATS_ZERO_REGEXP" \ + -o match:'Out/Pass:.*'"$TABLE_STATS_ZERO_REGEXP" \ + jexec alcatraz pfctl -t foo -T show -vv +} + +zero_all_cleanup() +{ + pft_cleanup +} + atf_test_case "reset_nonzero" "cleanup" reset_nonzero_head() { @@ -534,6 +588,7 @@ atf_init_test_cases() atf_add_test_case "v6_counters" atf_add_test_case "match_counters" atf_add_test_case "zero_one" + atf_add_test_case "zero_all" atf_add_test_case "reset_nonzero" atf_add_test_case "pr251414" atf_add_test_case "automatic" diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 864057692566..b25f551d069b 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -8125,6 +8125,7 @@ OLD_FILES+=usr/bin/cc OLD_FILES+=usr/bin/c88 OLD_FILES+=usr/bin/c++ OLD_FILES+=usr/bin/c++filt +OLD_FILES+=usr/bin/elfcopy OLD_FILES+=usr/bin/ld OLD_FILES+=usr/bin/ld.bfd OLD_FILES+=usr/bin/nm @@ -8135,6 +8136,7 @@ OLD_FILES+=usr/bin/strip OLD_FILES+=usr/bin/yacc OLD_FILES+=usr/share/man/man1/addr2line.1.gz OLD_FILES+=usr/share/man/man1/c++filt.1.gz +OLD_FILES+=usr/share/man/man1/elfcopy.1.gz OLD_FILES+=usr/share/man/man1/nm.1.gz OLD_FILES+=usr/share/man/man1/readelf.1.gz OLD_FILES+=usr/share/man/man1/size.1.gz diff --git a/tools/tools/sysdoc/tunables.mdoc b/tools/tools/sysdoc/tunables.mdoc index 54f6920a22c0..20b59f450cf2 100644 --- a/tools/tools/sysdoc/tunables.mdoc +++ b/tools/tools/sysdoc/tunables.mdoc @@ -1272,12 +1272,12 @@ bool Controls forwarding of source-routed IP packets. --- -net.inet.ip.check_interface +net.inet.ip.rfc1122_strong_es bool This .Nm -verifies that packets arrive on the correct interfaces. +verifies that the packet's IP destination address matches an address on the arrival interface. --- net.inet.ip.fastforwarding diff --git a/usr.bin/Makefile b/usr.bin/Makefile index bca7896e5a17..b9e4d6c1153a 100644 --- a/usr.bin/Makefile +++ b/usr.bin/Makefile @@ -247,9 +247,14 @@ SUBDIR.${MK_TFTP}+= tftp SUBDIR.${MK_TOOLCHAIN}+= addr2line SUBDIR.${MK_TOOLCHAIN}+= ar SUBDIR.${MK_TOOLCHAIN}+= nm -SUBDIR.${MK_TOOLCHAIN}+= objcopy SUBDIR.${MK_TOOLCHAIN}+= readelf SUBDIR.${MK_TOOLCHAIN}+= size +.endif +# Include elftoolchain's strings in build targets even if using LLVM_BINUTILS, +# as we may later install with different options. In particular, the release +# artifact builds use default options for buildworld but install with +# MK_TOOLCHAIN=no which implies MK_LLVM_BINUTILS=no. +.if ${MK_LLVM_BINUTILS} == "no" || !make(install) SUBDIR+= strings .endif SUBDIR.${MK_TOOLCHAIN}+= c89 @@ -264,6 +269,8 @@ SUBDIR.${MK_TOOLCHAIN}+= indent SUBDIR.${MK_TOOLCHAIN}+= lex SUBDIR.${MK_TOOLCHAIN}+= lorder SUBDIR.${MK_TOOLCHAIN}+= mkstr +# ELF Tool Chain elfcopy required for EFI objects (PR280771) +SUBDIR.${MK_TOOLCHAIN}+= objcopy SUBDIR.${MK_TOOLCHAIN}+= rpcgen SUBDIR.${MK_TOOLCHAIN}+= unifdef SUBDIR.${MK_TOOLCHAIN}+= xstr diff --git a/usr.bin/beep/Makefile b/usr.bin/beep/Makefile index f252ab64f843..1f2548c24819 100644 --- a/usr.bin/beep/Makefile +++ b/usr.bin/beep/Makefile @@ -1,6 +1,5 @@ PROG= beep MAN= beep.1 - -LDFLAGS= -lm +LIBADD= m .include <bsd.prog.mk> diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile index 9a146246df0d..a8bcdfd9f859 100644 --- a/usr.bin/bmake/Makefile +++ b/usr.bin/bmake/Makefile @@ -2,20 +2,20 @@ # See contrib/bmake/bsd.after-import.mk # -SRCTOP ?= ${.CURDIR:H:H} +SRCTOP?= ${.CURDIR:H:H} # look here first for config.h -CFLAGS += -I${.CURDIR} +CFLAGS+= -I${.CURDIR} # for after-import -CLEANDIRS += FreeBSD -CLEANFILES += bootstrap +CLEANDIRS+= FreeBSD +CLEANFILES+= bootstrap -# $Id: Makefile,v 1.132 2024/09/22 19:56:26 sjg Exp $ +# $Id: Makefile,v 1.133 2025/03/08 20:12:56 sjg Exp $ -PROG ?= ${.CURDIR:T} +PROG?= ${.CURDIR:T} -SRCS = \ +SRCS= \ arch.c \ buf.c \ compat.c \ @@ -40,8 +40,8 @@ SRCS = \ .MAIN: all -MAN = ${PROG}.1 -SRCS.${MAN} = ${srcdir}/make.1 +MAN= ${PROG}.1 +SRCS.${MAN}= ${srcdir}/make.1 .-include "Makefile.inc" @@ -49,45 +49,45 @@ SRCS.${MAN} = ${srcdir}/make.1 .-include "Makefile.config" .if !empty(LIBOBJS) -SRCS += ${LIBOBJS:T:.o=.c} +SRCS+= ${LIBOBJS:T:.o=.c} .endif # just in case -prefix ?= /usr -srcdir ?= ${.PARSEDIR} -srcdir := ${srcdir} +prefix?= /usr +srcdir?= ${.PARSEDIR} +srcdir:= ${srcdir} -DEFAULT_SYS_PATH ?= ${prefix}/share/mk +DEFAULT_SYS_PATH?= ${prefix}/share/mk -CPPFLAGS += -DUSE_META -CFLAGS += ${CPPFLAGS} -CFLAGS += -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\" -CFLAGS += -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE -CFLAGS += ${COPTS.${.ALLSRC:M*.c:T:u}} -COPTS.main.c += "-DMAKE_VERSION=\"${_MAKE_VERSION}\"" +CPPFLAGS+= -DUSE_META +CFLAGS+= ${CPPFLAGS} +CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\" +CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE +CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}} +COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\"" .for x in FORCE_MAKE_OS FORCE_MACHINE FORCE_MACHINE_ARCH .ifdef $x -COPTS.main.c += "-D$x=\"${$x}\"" +COPTS.main.c+= "-D$x=\"${$x}\"" .endif .endfor # meta mode can be useful even without filemon # should be set by now -USE_FILEMON ?= no +USE_FILEMON?= no .if ${USE_FILEMON:tl} != "no" .PATH: ${srcdir}/filemon -SRCS += filemon_${USE_FILEMON}.c -COPTS.meta.c += -DUSE_FILEMON -DUSE_FILEMON_${USE_FILEMON:tu} -COPTS.job.c += ${COPTS.meta.c} +SRCS+= filemon_${USE_FILEMON}.c +COPTS.meta.c+= -DUSE_FILEMON -DUSE_FILEMON_${USE_FILEMON:tu} +COPTS.job.c+= ${COPTS.meta.c} .if ${USE_FILEMON} == "dev" -FILEMON_H ?= /usr/include/dev/filemon/filemon.h +FILEMON_H?= /usr/include/dev/filemon/filemon.h .if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h" -COPTS.filemon_dev.c += -DHAVE_FILEMON_H -I${FILEMON_H:H} +COPTS.filemon_dev.c+= -DHAVE_FILEMON_H -I${FILEMON_H:H} .endif .elif ${USE_FILEMON} == "ktrace" -COPTS.filemon_ktrace.c += -Wno-error=unused-parameter +COPTS.filemon_ktrace.c+= -Wno-error=unused-parameter .endif .endif # USE_FILEMON @@ -96,10 +96,10 @@ COPTS.filemon_ktrace.c += -Wno-error=unused-parameter .if make(obj) || make(clean) -SUBDIR.${MK_TESTS} += unit-tests +SUBDIR.${MK_TESTS}+= unit-tests .endif -MAN1 = ${MAN} +MAN1= ${MAN} .if ${MK_GEN_MAN:Uno} == "yes" @@ -107,8 +107,8 @@ MAN1 = ${MAN} .include <${srcdir}/mk/genfiles.mk> .if ${PROG} != "make" -CLEANFILES += my.history -SED_CMDS.${MAN} += \ +CLEANFILES+= my.history +SED_CMDS.${MAN}+= \ -e '/^.Dt/s/MAKE/${PROG:tu}/' \ -e '/^.Nm/s/make/${PROG}/' \ @@ -123,7 +123,7 @@ my.history: echo "It uses autoconf to facilitate portability to other platforms."; \ echo ".Pp") > $@ -SED_CMDS.${MAN} += \ +SED_CMDS.${MAN}+= \ -e '/^.Sh HISTORY/rmy.history' \ -e '/^.Sh HISTORY/,/BUGS/s,^.Nm,make,' \ @@ -131,7 +131,7 @@ SED_CMDS.${MAN} += \ .if ${.MAKE.OS:N*BSD} != "" # assume .Nx is not supported -SED_CMDS.${MAN} += -e 's/^\.Nx/NetBSD/' +SED_CMDS.${MAN}+= -e 's/^\.Nx/NetBSD/' .endif # watch out for a late change of PROG @@ -140,35 +140,35 @@ SED_CMDS.${MAN} += -e 's/^\.Nx/NetBSD/' ${MAN}: ${SRCS.${MAN}} _GENFILES_USE all man beforeinstall: ${MAN} -_mfromdir = . +_mfromdir= . .endif .endif # MK_GEN_MAN -MANTARGET ?= cat -MANDEST ?= ${MANDIR}/${MANTARGET}1 +MANTARGET?= cat +MANDEST?= ${MANDIR}/${MANTARGET}1 .if ${MANTARGET} == "cat" -_mfromdir = ${srcdir} +_mfromdir= ${srcdir} .endif .include <bsd.prog.mk> -CPPFLAGS += -DMAKE_NATIVE -DHAVE_CONFIG_H -COPTS.var.c += -Wno-cast-qual -COPTS.job.c += -Wno-format-nonliteral -COPTS.parse.c += -Wno-format-nonliteral -COPTS.var.c += -Wno-format-nonliteral +CPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H +COPTS.var.c+= -Wno-cast-qual +COPTS.job.c+= -Wno-format-nonliteral +COPTS.parse.c+= -Wno-format-nonliteral +COPTS.var.c+= -Wno-format-nonliteral # Force these -SHAREDIR = ${SHAREDIR.bmake:U${prefix}/share} -BINDIR = ${BINDIR.bmake:U${prefix}/bin} -MANDIR = ${MANDIR.bmake:U${SHAREDIR}/man} +SHAREDIR= ${SHAREDIR.bmake:U${prefix}/share} +BINDIR= ${BINDIR.bmake:U${prefix}/bin} +MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man} ${OBJS}: config.h # A simple unit-test driver to help catch regressions -TEST_MAKE ?= ${.OBJDIR}/${PROG:T} +TEST_MAKE?= ${.OBJDIR}/${PROG:T} accept test: .NOMETA cd ${.CURDIR}/unit-tests && \ MAKEFLAGS= ${TEST_MAKE} -r -m / ${.TARGET} ${TESTS:DTESTS=${TESTS:Q}} @@ -179,9 +179,9 @@ accept test: .NOMETA # which prevents MK_AUTO_OBJ doing its job # so do it here .if defined(MAKEOBJDIRPREFIX) || ${MAKEOBJDIR:U:M*/*} != "" -_utobj = ${.OBJDIR}/unit-tests +_utobj= ${.OBJDIR}/unit-tests .else -_utobj = ${.CURDIR}/unit-tests/${MAKEOBJDIR:Uobj} +_utobj= ${.CURDIR}/unit-tests/${MAKEOBJDIR:Uobj} .endif utobj: .NOMETA @test -d ${_utobj} && exit 0; \ @@ -192,11 +192,11 @@ test: utobj .endif # override some simple things -BINDIR = /usr/bin -MANDIR = /usr/share/man/man +BINDIR= /usr/bin +MANDIR= /usr/share/man/man # make sure we get this -CFLAGS += ${COPTS.${.IMPSRC:T}} +CFLAGS+= ${COPTS.${.IMPSRC:T}} after-import: ${SRCTOP}/contrib/bmake/bsd.after-import.mk cd ${.CURDIR} && ${.MAKE} -f ${SRCTOP}/contrib/bmake/bsd.after-import.mk diff --git a/usr.bin/bmake/Makefile.config b/usr.bin/bmake/Makefile.config index 9ca3691cbb2a..a5e81a13cd0a 100644 --- a/usr.bin/bmake/Makefile.config +++ b/usr.bin/bmake/Makefile.config @@ -6,7 +6,7 @@ SRCTOP?= ${.CURDIR:H:H} # things set by configure -_MAKE_VERSION?=20250125 +_MAKE_VERSION?=20250308 prefix?= /usr srcdir= ${SRCTOP}/contrib/bmake @@ -14,7 +14,7 @@ CC?= cc MAKE_OS?= DEFAULT_SYS_PATH?= .../share/mk:/usr/share/mk -EGREP = egrep +EGREP= egrep CPPFLAGS+= CFLAGS+= ${CPPFLAGS} -DHAVE_CONFIG_H LDFLAGS+= diff --git a/usr.bin/bmake/unit-tests/Makefile b/usr.bin/bmake/unit-tests/Makefile index 7011ab754b9e..cdf252d5e474 100644 --- a/usr.bin/bmake/unit-tests/Makefile +++ b/usr.bin/bmake/unit-tests/Makefile @@ -471,7 +471,7 @@ TESTS+= varparse-mod TESTS+= varparse-undef-partial # some shells have quirks -_shell := ${.SHELL:tA:T} +_shell:= ${.SHELL:tA:T} .if ${_shell} == "dash" # dash fails -x output BROKEN_TESTS+= opt-debug-x-trace diff --git a/usr.bin/etdump/etdump.1 b/usr.bin/etdump/etdump.1 index bec8d201eb4f..a86a5e24742c 100644 --- a/usr.bin/etdump/etdump.1 +++ b/usr.bin/etdump/etdump.1 @@ -1,3 +1,6 @@ +.\" +.\" SPDX-License-Identifier: BSD-2-Clause +.\" .\" Copyright (c) 2018 iXsystems, Inc .\" All rights reserved. .\" @@ -22,51 +25,54 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd April 25, 2018 -.Dt ETDUMP 8 +.Dd January 18, 2025 +.Dt ETDUMP 1 .Os .Sh NAME .Nm etdump -.Nd Dump El Torito boot catalog information from ISO images +.Nd dump ISO-9660 El Torito boot catalog information .Sh SYNOPSIS .Nm .Op Fl f Ar format .Op Fl o Ar file .Ar .Sh DESCRIPTION -This program reads El Torito boot catalog information from an ISO image and -outputs it in various formats. -It can be used to check the catalog in an image or to output catalog data in -a format that can be used by other tools such as shell scripts. +This program reads El Torito boot catalog information +from an ISO-9660 image and outputs it in various formats. +It can be used to check the catalog in an image or +to output catalog data in a format that can be used by other tools +such as shell scripts. .Pp Supported options are: .Bl -tag -width flag -.It Fl f Ar format Fl -format Ar format +.It Fl f Ar format | Fl -format Ar format Select the output format. Supported output formats are: -.Bl -tag -width shell -offset indent -.It Sy text +.Bl -tag -width indent +.It Cm text Human-readable text (default) -.It Sy shell -Each boot entry is emitted as a string suitable for passing to a sh-compatible -eval command. +.It Cm shell +Each boot entry is emitted as a string +suitable for passing to a sh-compatible eval command. The variables emitted are: -.Bl -tag -width et_platform -offset indent -.It et_platform +.Bl -tag -width "et_platform" +.It Dv et_platform The platform ID from the section header. Set to 'default' for the initial (default) entry. -.It et_system +.It Dv et_system The system ID from the boot entry. -.It et_lba +.It Dv et_lba The starting LBA (2048-byte blocks) of the boot image. -.It et_sectors +.It Dv et_sectors The number of sectors (512-byte sectors) that comprise the boot image. .El .El -.It Fl o Ar file Fl -output Ar file +.It Fl o Ar file | Fl -output Ar file Write output to .Ar file . -If '-' is specified then standard out is used. +If +.Ql - +is specified then standard out is used. .El .Sh EXAMPLES To see what entries are in a given boot catalog run @@ -87,14 +93,16 @@ Section header: efi, final Media type: no emulation .Ed .Pp -To use the output in a shell script a for loop can be used to iterate over the -entries returned using eval: +To use the output in a shell script a for loop can be used +to iterate over the entries returned using eval: .Bd -literal -offset indent for entry in `etdump --format shell bootonly.iso`; do eval $entry echo $et_platform $et_system $et_lba $et_sectors done .Ed +.Sh SEE ALSO +.Xr cd9660 4 .Sh HISTORY The .Nm diff --git a/usr.bin/gcore/elfcore.c b/usr.bin/gcore/elfcore.c index 2bffd409bb11..86613a91ca73 100644 --- a/usr.bin/gcore/elfcore.c +++ b/usr.bin/gcore/elfcore.c @@ -105,6 +105,7 @@ static void *elf_note_powerpc_vsx(void *, size_t *); static void *elf_note_procstat_auxv(void *, size_t *); static void *elf_note_procstat_files(void *, size_t *); static void *elf_note_procstat_groups(void *, size_t *); +static void *elf_note_procstat_kqueues(void *, size_t *); static void *elf_note_procstat_osrel(void *, size_t *); static void *elf_note_procstat_proc(void *, size_t *); static void *elf_note_procstat_psstrings(void *, size_t *); @@ -388,6 +389,7 @@ elf_putnotes(pid_t pid, struct sbuf *sb, size_t *sizep) elf_putnote(NT_PROCSTAT_PSSTRINGS, elf_note_procstat_psstrings, &pid, sb); elf_putnote(NT_PROCSTAT_AUXV, elf_note_procstat_auxv, &pid, sb); + elf_putnote(NT_PROCSTAT_KQUEUES, elf_note_procstat_kqueues, &pid, sb); #endif size = sbuf_end_section(sb, old_len, 1, 0); @@ -756,7 +758,7 @@ procstat_sysctl(void *arg, int what, size_t structsz, size_t *sizep) { size_t len; pid_t pid; - int name[4], structsize; + int name[5], structsize; void *buf, *p; pid = *(pid_t *)arg; @@ -842,6 +844,14 @@ elf_note_procstat_auxv(void *arg, size_t *sizep) } static void * +elf_note_procstat_kqueues(void *arg, size_t *sizep) +{ + + return (procstat_sysctl(arg, KERN_PROC_KQUEUE, + sizeof(struct kinfo_knote), sizep)); +} + +static void * elf_note_procstat_rlimit(void *arg, size_t *sizep) { pid_t pid; diff --git a/usr.bin/grep/tests/grep_freebsd_test.sh b/usr.bin/grep/tests/grep_freebsd_test.sh index 77017529843e..906b70645151 100755 --- a/usr.bin/grep/tests/grep_freebsd_test.sh +++ b/usr.bin/grep/tests/grep_freebsd_test.sh @@ -103,10 +103,25 @@ zflag_body() atf_check grep -qz "foo.*bar" in } +atf_test_case color_dupe +color_dupe_body() +{ + + # This assumes a MAX_MATCHES of exactly 32. Previously buggy procline() + # calls would terminate the line premature every MAX_MATCHES matches, + # meaning we'd see the line be output again for the next MAX_MATCHES + # number of matches. + jot -nb 'A' -s '' 33 > in + + atf_check -o save:color.out grep --color=always . in + atf_check -o match:"^ +1 color.out" wc -l color.out +} + atf_init_test_cases() { atf_add_test_case grep_r_implied atf_add_test_case rgrep atf_add_test_case gnuext atf_add_test_case zflag + atf_add_test_case color_dupe } diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c index 4e1c44b442f2..ed87e56956f6 100644 --- a/usr.bin/grep/util.c +++ b/usr.bin/grep/util.c @@ -72,7 +72,7 @@ static int litexec(const struct pat *pat, const char *string, size_t nmatch, regmatch_t pmatch[]); #endif static bool procline(struct parsec *pc); -static void printline(struct parsec *pc, int sep); +static bool printline(struct parsec *pc, int sep, size_t *last_out); static void printline_metadata(struct str *line, int sep); bool @@ -214,15 +214,29 @@ procmatch_match(struct mprintc *mc, struct parsec *pc) /* Print the matching line, but only if not quiet/binary */ if (mc->printmatch) { - printline(pc, ':'); + size_t last_out; + bool terminated; + + last_out = 0; + terminated = printline(pc, ':', &last_out); while (pc->matchidx >= MAX_MATCHES) { /* Reset matchidx and try again */ pc->matchidx = 0; if (procline(pc) == !vflag) - printline(pc, ':'); + terminated = printline(pc, ':', &last_out); else break; } + + /* + * The above loop processes the entire line as long as we keep + * hitting the maximum match count. At this point, we know + * that there's nothing left to be printed and can terminate the + * line. + */ + if (!terminated) + printline(pc, ':', &last_out); + first_match = false; mc->same_file = true; mc->last_outed = 0; @@ -748,26 +762,39 @@ printline_metadata(struct str *line, int sep) } /* - * Prints a matching line according to the command line options. + * Prints a matching line according to the command line options. We need + * *last_out to be populated on entry in case this is just a continuation of + * matches within the same line. + * + * Returns true if the line was terminated, false if it was not. */ -static void -printline(struct parsec *pc, int sep) +static bool +printline(struct parsec *pc, int sep, size_t *last_out) { - size_t a = 0; + size_t a = *last_out; size_t i, matchidx; regmatch_t match; + bool terminated; + + /* + * Nearly all paths below will terminate the line by default, but it is + * avoided in some circumstances in case we don't have the full context + * available here. + */ + terminated = true; /* If matchall, everything matches but don't actually print for -o */ if (oflag && matchall) - return; + return (terminated); matchidx = pc->matchidx; /* --color and -o */ - if ((oflag || color) && matchidx > 0) { + if ((oflag || color) && (pc->printed > 0 || matchidx > 0)) { /* Only print metadata once per line if --color */ - if (!oflag && pc->printed == 0) + if (!oflag && pc->printed == 0) { printline_metadata(&pc->ln, sep); + } for (i = 0; i < matchidx; i++) { match = pc->matches[i]; /* Don't output zero length matches */ @@ -780,9 +807,10 @@ printline(struct parsec *pc, int sep) if (oflag) { pc->ln.boff = match.rm_so; printline_metadata(&pc->ln, sep); - } else + } else { fwrite(pc->ln.dat + a, match.rm_so - a, 1, stdout); + } if (color) fprintf(stdout, "\33[%sm\33[K", color); fwrite(pc->ln.dat + match.rm_so, @@ -793,13 +821,31 @@ printline(struct parsec *pc, int sep) if (oflag) putchar('\n'); } - if (!oflag) { - if (pc->ln.len - a > 0) + + /* + * Don't terminate if we reached the match limit; we may have + * other matches on this line to process. + */ + *last_out = a; + if (!oflag && matchidx != MAX_MATCHES) { + if (pc->ln.len - a > 0) { fwrite(pc->ln.dat + a, pc->ln.len - a, 1, stdout); + *last_out = pc->ln.len; + } putchar('\n'); + } else if (!oflag) { + /* + * -o is terminated on every match output, so this + * branch is only designed to capture MAX_MATCHES in a + * line which may be a signal to us for a lack of + * context. The caller will know more and call us again + * to terminate if it needs to. + */ + terminated = false; } } else grep_printline(&pc->ln, sep); pc->printed++; + return (terminated); } diff --git a/usr.bin/objcopy/Makefile b/usr.bin/objcopy/Makefile index 101c84cc5206..2f3386d95ebe 100644 --- a/usr.bin/objcopy/Makefile +++ b/usr.bin/objcopy/Makefile @@ -7,12 +7,22 @@ ELFCOPYDIR= ${ELFTCDIR}/elfcopy .PATH: ${ELFCOPYDIR} -PROG= objcopy +PROG= elfcopy +MAN= elfcopy.1 + +.if ${MK_LLVM_BINUTILS} == "no" + +LINKS+= ${BINDIR}/${PROG} ${BINDIR}/objcopy +LINKS+= ${BINDIR}/${PROG} ${BINDIR}/strip +MAN+= objcopy.1 strip.1 + objcopy.1: elfcopy.1 sed -e 's/\.Dt ELFCOPY 1/.Dt OBJCOPY 1/' \ -e '/\.Nm elfcopy ,/d' < ${.ALLSRC} > ${.TARGET} CLEANFILES+= objcopy.1 +.endif + SRCS= archive.c ascii.c binary.c main.c pe.c sections.c segments.c symbols.c WARNS?= 5 @@ -22,9 +32,7 @@ LIBADD= archive elftc elf pe CFLAGS+=-I${ELFTCDIR}/libelftc -I${ELFTCDIR}/libpe -I${ELFTCDIR}/common CFLAGS+=-DWITH_PE=1 -MAN= ${PROG}.1 strip.1 -LINKS= ${BINDIR}/${PROG} ${BINDIR}/strip # This same hack is in lib/libelf/Makefile and usr.bin/readelf/Makefile # We need to link against the correct version of these files. One diff --git a/usr.bin/top/commands.c b/usr.bin/top/commands.c index e65f4ee6c4c4..3fa63459f2e1 100644 --- a/usr.bin/top/commands.c +++ b/usr.bin/top/commands.c @@ -51,35 +51,35 @@ static int str_addarg(char *str, int len, char *arg, bool first); const struct command all_commands[] = { - {'C', "toggle the displaying of weighted CPU percentage", false, CMD_wcputog}, + {' ', "update the display", false, CMD_update}, + {'/', "filter on command name (+ selects all commands)", false, CMD_grep}, + {'a', "toggle the display of process titles", false, CMD_showargs}, + {'C', "toggle the display of raw or weighted CPU percentage", false, CMD_wcputog}, {'d', "change number of displays to show", false, CMD_displays}, {'e', "list errors generated by last \"kill\" or \"renice\" command", false, CMD_errors}, - {'H', "toggle the displaying of threads", false, CMD_thrtog}, + {'H', "toggle the display of threads", false, CMD_thrtog}, {'h', "show this help text", true, CMD_help}, {'?', NULL, true, CMD_help}, - {'/', "filter on command name (+ selects all commands)", false, CMD_grep}, - {'i', "toggle the displaying of idle processes", false, CMD_idletog}, + {'i', "toggle the display of idle processes", false, CMD_idletog}, {'I', NULL, false, CMD_idletog}, - {'j', "toggle the displaying of jail ID", false, CMD_jidtog}, {'J', "display processes for only one jail (+ selects all jails)", false, CMD_jail}, + {'j', "toggle the display of jail ID", false, CMD_jidtog}, {'k', "kill processes; send a signal to a list of processes", false, CMD_kill}, - {'q', "quit" , true, CMD_quit}, {'m', "toggle the display between 'cpu' and 'io' modes", false, CMD_viewtog}, {'n', "change number of processes to display", false, CMD_number}, {'#', NULL, false, CMD_number}, {'o', "specify the sort order", false, CMD_order}, + {'P', "toggle the display of per-CPU statistics", false, CMD_pcputog}, {'p', "display one process (+ selects all processes)", false, CMD_pid}, - {'P', "toggle the displaying of per-CPU statistics", false, CMD_pcputog}, + {'q', "quit" , true, CMD_quit}, {'r', "renice a process", false, CMD_renice}, + {'S', "toggle the display of system processes", false, CMD_viewsys}, {'s', "change number of seconds to delay between updates", false, CMD_delay}, - {'S', "toggle the displaying of system processes", false, CMD_viewsys}, - {'a', "toggle the displaying of process titles", false, CMD_showargs}, - {'T', "toggle the displaying of thread IDs", false, CMD_toggletid}, + {'T', "toggle the display of thread IDs", false, CMD_toggletid}, {'t', "toggle the display of this process", false, CMD_selftog}, {'u', "display processes for only one user (+ selects all users)", false, CMD_user}, {'w', "toggle the display of swap use for each process", false, CMD_swaptog}, - {'z', "toggle the displaying of the system idle process", false, CMD_kidletog}, - {' ', "update the display", false, CMD_update}, + {'z', "toggle the display of the system idle process", false, CMD_kidletog}, {0, NULL, true, CMD_NONE} }; @@ -108,7 +108,7 @@ show_help(void) } else if (curcmd->c == ' '){ /* special case space rather than introducing a "display string" to * the struct */ - sprintf(keys, "SPC"); + sprintf(keys, "space"); } else { sprintf(keys, "%c", curcmd->c); } diff --git a/usr.bin/top/top.1 b/usr.bin/top/top.1 index ca74860aaa35..3443df0f8c22 100644 --- a/usr.bin/top/top.1 +++ b/usr.bin/top/top.1 @@ -1,4 +1,4 @@ -.Dd November 18, 2021 +.Dd March 25, 2025 .Dt TOP 1 .Os .Sh NAME @@ -235,7 +235,7 @@ or .Dq all . Boolean flags are toggles. A second specification of any of these options will negate the first. -.Sh "INTERACTIVE MODE" +.Sh INTERACTIVE MODE When .Nm is running in @@ -255,9 +255,8 @@ is between displays; that is, while it is waiting for seconds to elapse. If this is the case, the command will be processed and the display will be updated immediately thereafter -(reflecting any changes that the command may have specified). -This -happens even if the command was incorrect. +.Pq reflecting any changes that the command may have specified . +This happens even if the command was incorrect. If a key is pressed while .Nm is in the middle of updating the display, it will finish the update and @@ -269,65 +268,54 @@ in, the user's erase and kill keys (as set up by the command .Xr stty 1 ) are recognized, and a newline terminates the input. .Pp -These commands are currently recognized (^L refers to control-L): +The bindings are as follows: .Bl -tag -width indent -.It ^L -Redraw the screen. -.It h -Display a summary of the commands (help screen). -Version information -is included in this display. -.It q -Quit -.Nm -.It d -Change the number of displays to show (prompt for new number). -Remember that the next display counts as one, so typing 'd1' will make -.Nm -show one final display and then immediately exit. -.It / -Display only processes that contain the specified string in their -command name. -If displaying arguments is enabled, the arguments are searched -too. '+' shows all processes. -.It m -Toggle the display between 'cpu' and 'io' modes. -.It n or # -Change the number of processes to display (prompt for new number). -.It s -Change the number of seconds to delay between displays -(prompt for new number). -.It S -Toggle the display of system processes. -.It a -Toggle the display of process titles. -.It k +.It Ic space +Update the display. +.It Ic / +Filter by command name. +Prompt for +.Ar string +or +.Ql Ic + +to show all processes. +.It Ic a +Toggle display of process titles. +.It Ic C +Toggle display of raw or weighted CPU percentage. +.It Ic d +Change the number of remaining displays to show before exit. +Prompt for new number. +.It Ic e +Display a list of system errors (if any) generated by the last command. +.It Ic H +Toggle display of threads. +.It Ic h No or Ic \&? +Display a summary of the commands (help screen) and version information. +.It Ic i No or Ic I +Toggle display of idle processes. +.It Ic J +Filter processes owned by a specific jail. +Prompt for jail name or +.Ql Ic + +for all processes belonging to all jails and the host. +This will also enable the display of JID. +.It Ic j +Toggle display of +.Xr jail 8 +ID. +.It Ic k Send a signal .Pq SIGKILL by default to a list of processes. This acts similarly to the command .Xr kill 1 . -.It r -Change the priority -.Pq the Dq nice -of a list of processes. -This acts similarly to -.Xr renice 8 . -.It u -Display only processes owned by a specific set of usernames (prompt for -username). -If the username specified is simply -.Dq + -or -.Dq - , -then processes belonging to all users will be displayed. -Usernames can be added -to and removed from the set by prepending them with -.Dq + -and -.Dq - , -respectively. -.It o +.It Ic m +Toggle the display between 'cpu' and 'io' modes. +.It Ic n No or Ic # +Change the number of processes to display. +Prompt for new number. +.It Ic o Change the order in which the display is sorted. The sort key names include .Dq cpu , @@ -336,41 +324,54 @@ The sort key names include and .Dq time. The default is cpu. -.It p -Display a specific process (prompt for pid). -If the pid specified is simply -.Dq + , -then show all processes. -.It e -Display a list of system errors (if any) generated by the last -command. -.It H -Toggle the display of threads. -.It i or I -Toggle the display of idle processes. -.It j -Toggle the display of -.Xr jail 8 -ID. -.It J -Display only processes owned by a specific jail (prompt for jail). -If the jail specified is simply -.Dq + , -then processes belonging -to all jails and the host will be displayed. -This will also enable the display of JID. -.It P -Toggle the display of per-CPU statistics. -.It T -Toggle display of TID and PID -.It t -Toggle the display of the +.It Ic P +Toggle display of per-CPU statistics. +.It Ic p +Filter by exact process ID. +Prompt for +.Ar PID +or +.Ql Ic + +to show all processes. +.It Ic q +Quit +.Nm . +.It Ic r +Change the priority +.Pq the Dq nice +of a list of processes. +This acts similarly to +.Xr renice 8 . +.It Ic S +Toggle the display of system processes. +.It Ic s +Change the number of seconds to delay between displays. +Prompt for new number. +.It Ic T +Toggle display between thread ID and process ID. +.It Ic t +Toggle display of the .Nm process. -.It w -Toggle the display of swap usage. -.It z -Toggle the display of the system idle process. +.It Ic u +Filter by exact process owner username. +Prompt for +.Ar username +or +.Ql Ic - Ns +.No / Ns +.Ql Ic + +for all users. +Usernames can be added +to and removed from the set by prepending them with +.Ql + +and +.Ql - , +respectively. +.It Ic w +Toggle display of swap usage. +.It Ic z +Toggle display of the system idle process. .El .Sh "THE DISPLAY" The top few lines of the display show general information diff --git a/usr.sbin/bhyve/amd64/bhyverun_machdep.c b/usr.sbin/bhyve/amd64/bhyverun_machdep.c index d51ad3a5fc05..85af124b5536 100644 --- a/usr.sbin/bhyve/amd64/bhyverun_machdep.c +++ b/usr.sbin/bhyve/amd64/bhyverun_machdep.c @@ -63,6 +63,7 @@ bhyve_init_config(void) set_config_bool("acpi_tables_in_memory", true); set_config_value("memory.size", "256M"); set_config_bool("x86.strictmsr", true); + set_config_bool("x86.verbosemsr", false); set_config_value("lpc.fwcfg", "bhyve"); } diff --git a/usr.sbin/bhyve/amd64/vmexit.c b/usr.sbin/bhyve/amd64/vmexit.c index e0b9aec2d17a..944f5de34645 100644 --- a/usr.sbin/bhyve/amd64/vmexit.c +++ b/usr.sbin/bhyve/amd64/vmexit.c @@ -107,8 +107,11 @@ vmexit_rdmsr(struct vmctx *ctx __unused, struct vcpu *vcpu, val = 0; error = emulate_rdmsr(vcpu, vme->u.msr.code, &val); if (error != 0) { - EPRINTLN("rdmsr to register %#x on vcpu %d", - vme->u.msr.code, vcpu_id(vcpu)); + if (get_config_bool("x86.strictmsr") || + get_config_bool("x86.verbosemsr")) { + EPRINTLN("rdmsr to register %#x on vcpu %d", + vme->u.msr.code, vcpu_id(vcpu)); + } if (get_config_bool("x86.strictmsr")) { vm_inject_gp(vcpu); return (VMEXIT_CONTINUE); @@ -137,8 +140,11 @@ vmexit_wrmsr(struct vmctx *ctx __unused, struct vcpu *vcpu, error = emulate_wrmsr(vcpu, vme->u.msr.code, vme->u.msr.wval); if (error != 0) { - EPRINTLN("wrmsr to register %#x(%#lx) on vcpu %d", - vme->u.msr.code, vme->u.msr.wval, vcpu_id(vcpu)); + if (get_config_bool("x86.strictmsr") || + get_config_bool("x86.verbosemsr")) { + EPRINTLN("wrmsr to register %#x(%#lx) on vcpu %d", + vme->u.msr.code, vme->u.msr.wval, vcpu_id(vcpu)); + } if (get_config_bool("x86.strictmsr")) { vm_inject_gp(vcpu); return (VMEXIT_CONTINUE); diff --git a/usr.sbin/bhyve/bhyve_config.5 b/usr.sbin/bhyve/bhyve_config.5 index 3f9d9130787b..3dd24ca5fe69 100644 --- a/usr.sbin/bhyve/bhyve_config.5 +++ b/usr.sbin/bhyve/bhyve_config.5 @@ -240,6 +240,11 @@ By default, writes are ignored and reads return all bits set. Inject a general protection fault if a guest accesses a Model Specific Register (MSR) that is not emulated. If this is false, writes are ignored and reads return zero. +.It Va x86.verbosemsr Ta bool Ta false Ta +Enable verbose MSR print out. When this option is true, +messages related to reading from (rdmsr) and writing to (wrmsr) +MSRs on virtual CPUs will be printed out. This can be useful for +debugging purposes. .It Va x86.vmexit_on_hlt Ta bool Ta false Ta Force a VM exit when a guest CPU executes the .Dv HLT diff --git a/usr.sbin/bsnmpd/bsnmpd/Makefile b/usr.sbin/bsnmpd/bsnmpd/Makefile index 245ffc51002f..e7c7a87eec7c 100644 --- a/usr.sbin/bsnmpd/bsnmpd/Makefile +++ b/usr.sbin/bsnmpd/bsnmpd/Makefile @@ -131,7 +131,7 @@ CFLAGS+= -I${CONTRIB}/lib -I${CONTRIB}/snmpd -I. -DUSE_LIBBEGEMOT CFLAGS+= -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_ERR_H -DHAVE_STRLCPY LIBADD= begemot bsnmp -LDFLAGS= -Wl,-export-dynamic +LDFLAGS+= -Wl,-export-dynamic .if ${MK_OPENSSL} != "no" CFLAGS+= -DHAVE_LIBCRYPTO diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt b/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt index 13a4a646a669..8127eb92601f 100644 --- a/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt +++ b/usr.sbin/bsnmpd/modules/snmp_pf/BEGEMOT-PF-MIB.txt @@ -21,19 +21,17 @@ IMPORTS FROM BEGEMOT-MIB; begemotPf MODULE-IDENTITY - LAST-UPDATED "201003180000Z" - ORGANIZATION "NixSys BVBA" + LAST-UPDATED "202503190000Z" + ORGANIZATION "Alternative Enterprises (HK) Limited" CONTACT-INFO " Philip Paeps - Postal: NixSys BVBA - Louizastraat 14 - BE-2800 Mechelen - Belgium - E-Mail: philip@FreeBSD.org" DESCRIPTION "The Begemot MIB for the pf packet filter." + REVISION "202503190000Z" + DESCRIPTION + "Reverted pfInterfacesIfRefsState to Unsigned32" REVISION "201003180000Z" DESCRIPTION "Modified pfTablesAddrEntry to support IPv6 @@ -583,7 +581,7 @@ PfInterfacesIfEntry ::= SEQUENCE { pfInterfacesIfDescr OCTET STRING, pfInterfacesIfType INTEGER, pfInterfacesIfTZero TimeTicks, - pfInterfacesIfRefsState Null, + pfInterfacesIfRefsState Unsigned32, pfInterfacesIfRefsRule Unsigned32, pfInterfacesIf4BytesInPass Counter64, pfInterfacesIf4BytesInBlock Counter64, diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c index 0e40bcfb843e..f0f9e0f0e149 100644 --- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c +++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c @@ -1298,10 +1298,27 @@ pfs_refresh(void) } static int +pft_add_tstats(const struct pfr_tstats *t, void *arg) +{ + struct pft_entry *e; + int *index = arg; + + e = malloc(sizeof(struct pft_entry)); + if (e == NULL) + return (ENOMEM); + + e->index = (*index) + 1; + (*index)++; + memcpy(&e->pft, t, sizeof(struct pfr_tstats)); + TAILQ_INSERT_TAIL(&pft_table, e, link); + + return (0); +} + +static int pft_refresh(void) { - struct pfioc_table io; - struct pfr_tstats *t = NULL; + struct pfr_table filter; struct pft_entry *e; int i, numtbls = 1; @@ -1314,45 +1331,18 @@ pft_refresh(void) free(e); } - bzero(&io, sizeof(io)); - io.pfrio_esize = sizeof(struct pfr_tstats); - - for (;;) { - t = reallocf(t, numtbls * sizeof(struct pfr_tstats)); - if (t == NULL) { - syslog(LOG_ERR, "pft_refresh(): reallocf() numtbls=%d: %s", - numtbls, strerror(errno)); - goto err2; - } - io.pfrio_size = numtbls; - io.pfrio_buffer = t; + bzero(&filter, sizeof(filter)); - if (ioctl(pfctl_fd(pfh), DIOCRGETTSTATS, &io)) { - syslog(LOG_ERR, "pft_refresh(): ioctl(): %s", - strerror(errno)); - goto err2; - } - - if (numtbls >= io.pfrio_size) - break; - - numtbls = io.pfrio_size; - } - - for (i = 0; i < numtbls; i++) { - e = malloc(sizeof(struct pft_entry)); - if (e == NULL) - goto err1; - e->index = i + 1; - memcpy(&e->pft, t+i, sizeof(struct pfr_tstats)); - TAILQ_INSERT_TAIL(&pft_table, e, link); + if (pfctl_get_tstats(pfh, &filter, pft_add_tstats, &i)) { + syslog(LOG_ERR, "pft_refresh(): pfctl_get_tstats(): %s", + strerror(errno)); + goto err1; } pft_table_age = time(NULL); pft_table_count = numtbls; pf_tick = this_tick; - free(t); return (0); err1: while (!TAILQ_EMPTY(&pft_table)) { @@ -1360,8 +1350,6 @@ err1: TAILQ_REMOVE(&pft_table, e, link); free(e); } -err2: - free(t); return(-1); } diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def b/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def index dcdf676aa752..7a517a876fab 100644 --- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def +++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_tree.def @@ -107,7 +107,7 @@ (2 pfInterfacesIfDescr OCTETSTRING GET) (3 pfInterfacesIfType ENUM ( 0 group 1 instance 2 detached ) GET) (4 pfInterfacesIfTZero TIMETICKS GET) - (5 pfInterfacesIfRefsState NULL GET) + (5 pfInterfacesIfRefsState UNSIGNED32 GET) (6 pfInterfacesIfRefsRule UNSIGNED32 GET) (7 pfInterfacesIf4BytesInPass COUNTER64 GET) (8 pfInterfacesIf4BytesInBlock COUNTER64 GET) diff --git a/usr.sbin/trim/Makefile b/usr.sbin/trim/Makefile index 1263c0c6819e..6cf96b703094 100644 --- a/usr.sbin/trim/Makefile +++ b/usr.sbin/trim/Makefile @@ -1,6 +1,5 @@ PROG= trim MAN= trim.8 LIBADD= util -LDFLAGS= -lutil .include <bsd.prog.mk> |