system(3): Unwrap execve()
There is no need to call execl(), which will allocate an array and copy
our arguments into it, when we can use a static array and call execve()
directly.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D55648
lpd: Add timeout option
Set a 120-second receive timeout on all client connections, and add a
command-line option to change that value.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55400
(cherry picked from commit 56fbfd1ecdc78fc99b3a2e381c355ce8980de39d)
lpd: Add -F flag to prevent daemonizing
This is necessary for use with supervision, e.g. runit.
I chose -F simply because that is what the folks at LPRng use.
Approved by: pfg, gad, ngie
Differential Revision: https://reviews.freebsd.org/D29566
(cherry picked from commit 3c6366067036d4573528309a0a4d3b52e2a76ae7)
lpd: Improve robustness
* Check for integer overflow when receiving file sizes.
* Check for buffer overflow when receiving file names, and fully
validate the names.
* Check for integer overflow when checking for available disk space.
* Check for I/O errors when sending status codes.
* Enforce one job per connection and one control file per job (see
code comments for additional details).
* Simplify readfile(), avoiding constructs vulnerable to integer
overflow.
* Don't delete files we didn't create.
[11 lines not shown]
system(3): Clarify return values
Our manual page currently states that system() will return 127 if it
fails to execute the shell. The actual return value is, to quote POSIX,
“as if the command language interpreter had terminated using exit(127)
or _exit(127)”.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: bnovkov, kevans
Differential Revision: https://reviews.freebsd.org/D55483
(cherry picked from commit 7305604b29d3db29c9bb5de6e7a25829fb541d1e)
lpd: Add timeout option
Set a 120-second receive timeout on all client connections, and add a
command-line option to change that value.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55400
(cherry picked from commit 56fbfd1ecdc78fc99b3a2e381c355ce8980de39d)
lpd: Improve robustness
* Check for integer overflow when receiving file sizes.
* Check for buffer overflow when receiving file names, and fully
validate the names.
* Check for integer overflow when checking for available disk space.
* Check for I/O errors when sending status codes.
* Enforce one job per connection and one control file per job (see
code comments for additional details).
* Simplify readfile(), avoiding constructs vulnerable to integer
overflow.
* Don't delete files we didn't create.
[11 lines not shown]
system(3): Clarify return values
Our manual page currently states that system() will return 127 if it
fails to execute the shell. The actual return value is, to quote POSIX,
“as if the command language interpreter had terminated using exit(127)
or _exit(127)”.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: bnovkov, kevans
Differential Revision: https://reviews.freebsd.org/D55483
(cherry picked from commit 7305604b29d3db29c9bb5de6e7a25829fb541d1e)
lpd: Add timeout option
Set a 120-second receive timeout on all client connections, and add a
command-line option to change that value.
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D55400
(cherry picked from commit 56fbfd1ecdc78fc99b3a2e381c355ce8980de39d)
lpd: Improve robustness
* Check for integer overflow when receiving file sizes.
* Check for buffer overflow when receiving file names, and fully
validate the names.
* Check for integer overflow when checking for available disk space.
* Check for I/O errors when sending status codes.
* Enforce one job per connection and one control file per job (see
code comments for additional details).
* Simplify readfile(), avoiding constructs vulnerable to integer
overflow.
* Don't delete files we didn't create.
[11 lines not shown]
system(3): Fix null case
Our manual page states that if given a null pointer, system() returns
non-zero if the shell is available and zero if it is not. This is
consistent with the C standard's description of system(), but it is not
what we actually do. What we actually do is always return non-zero, as
required by POSIX.
As the POSIX rationale explains, implementing the logic required by the
C standard does not violate POSIX, since a conforming system always has
a shell, therefore the logic will always return non-zero.
Since our libc is commonly used in non-conforming situations such as
chroots or thin jails, we should implement the full logic required by
the C standard.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: obiwac, bnovkov, kevans
[3 lines not shown]
system(3): Clarify return values
Our manual page currently states that system() will return 127 if it
fails to execute the shell. The actual return value is, to quote POSIX,
“as if the command language interpreter had terminated using exit(127)
or _exit(127)”.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: bnovkov, kevans
Differential Revision: https://reviews.freebsd.org/D55483
(cherry picked from commit 7305604b29d3db29c9bb5de6e7a25829fb541d1e)
system(3): Improve signal handling
Ignore SIGINT and SIGQUIT and block SIGCHLD, as POSIX requires.
To deal with the concurrency problem described in POSIX, we keep track
of the count of concurrent invocations. We ignore and block signals
only when the counter was zero before we incremented it, and restore
them only when the counter reaches zero after we decrement it.
Note that this does not address the issue of thread cancellation.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: bnovkov, sef, kevans
Differential Revision: https://reviews.freebsd.org/D55471
(cherry picked from commit 6e589e6e8e64793adb437c561ec084dbb6ad1ced)
vmm: Support INOUT manual decode.
The inout instruction in AMD SVM requires DecodeAssist feature to decode the
segment override prefix. However, without that feature, we are still
able to decode by fetching the instruction directly.
Approved by: markj (mentor)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D51256
(cherry picked from commit c18c521c79b6160ce43bb2ca4c2eb42ccf7e6e57)
sysutils/auto-admin: Update to 0.8.4.24
auto-update-system:
Don't use -DBATCH, user may need to accept license
auto-chromium+widevine-install:
Tag linux-widevine-cdm as install-from-source so
auto-update-system can update it automatically.
smp: Use bitwise operation to count cpu number
Previously, we iterated over all CPUs using CPU_FOREACH and checked
individual bits to count valid CPUs. Refactor this to use a bitwise AND
and popcount to count the number of enabled bits directly.
Approved by: markj (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D54474
(cherry picked from commit e387d9438ba0258b88ebe03ef139bc6fd70b5a46)