sync with OpenBSD -current

This commit is contained in:
purplerain 2024-06-03 17:41:29 +00:00
parent 0d61274b26
commit bef867f8da
Signed by: purplerain
GPG Key ID: F42C07F07E2E35B7
81 changed files with 6365 additions and 372 deletions

View File

@ -1,7 +1,7 @@
# $OpenBSD: Makefile,v 1.47 2023/12/15 06:03:00 jmatthew Exp $
# $OpenBSD: Makefile,v 1.48 2024/06/02 16:00:07 deraadt Exp $
FS= install${OSrev}.img
FSSIZE= 1359872
FSSIZE= 1425408
CDROM= install${OSrev}.iso
MOUNT_POINT= /mnt

View File

@ -222,6 +222,7 @@
./etc/rc.d/bgplgd
./etc/rc.d/bootparamd
./etc/rc.d/cron
./etc/rc.d/dhcp6leased
./etc/rc.d/dhcpd
./etc/rc.d/dhcpleased
./etc/rc.d/dhcrelay
@ -329,6 +330,7 @@
./sbin/chown
./sbin/clri
./sbin/dhclient
./sbin/dhcp6leased
./sbin/dhcpleased
./sbin/disklabel
./sbin/dmesg
@ -6560,6 +6562,7 @@
./var/cron/tabs
./var/db
./var/db/acpi
./var/db/dhcp6leased
./var/db/dhcpleased
./var/db/ldap
./var/db/ns

View File

@ -2236,6 +2236,7 @@
./usr/share/man/man5/dhclient.conf.5
./usr/share/man/man5/dhclient.leases.5
./usr/share/man/man5/dhcp-options.5
./usr/share/man/man5/dhcp6leased.conf.5
./usr/share/man/man5/dhcpd.conf.5
./usr/share/man/man5/dhcpd.leases.5
./usr/share/man/man5/dhcpleased.conf.5
@ -2436,6 +2437,7 @@
./usr/share/man/man8/daily.8
./usr/share/man/man8/dev_mkdb.8
./usr/share/man/man8/dhclient.8
./usr/share/man/man8/dhcp6leased.8
./usr/share/man/man8/dhcpd.8
./usr/share/man/man8/dhcpleasectl.8
./usr/share/man/man8/dhcpleased.8

View File

@ -4,7 +4,7 @@ COPTS+=-Oz -fno-stack-protector
COPTS+=-fno-unwind-tables -fno-asynchronous-unwind-tables
.if ${MACHINE} == "amd64"
COPTS+=-fcf-protection=none
COPTS+=-fcf-protection=none -fno-ret-clean
.endif
.if ${MACHINE} == "arm64"
COPTS+=-mbranch-protection=none

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.488 2024/02/29 22:21:21 bluhm Exp $
# $OpenBSD: Makefile,v 1.489 2024/06/03 10:06:35 florian Exp $
.include <bsd.own.mk>
@ -58,12 +58,12 @@ EXAMPLES_600=bgpd.conf doas.conf dvmrpd.conf eigrpd.conf hostapd.conf \
snmpd.conf vm.conf ypldap.conf
# -r-xr-xr-x
RCDAEMONS=amd apmd bgpd bgplgd bootparamd cron dhcpd dhcpleased dhcrelay \
dhcrelay6 dvmrpd eigrpd ftpd ftpproxy ftpproxy6 hostapd hotplugd \
httpd identd ifstated iked inetd isakmpd iscsid ldapd ldattach ldomd \
ldpd lockd lpd mopd mountd mrouted nfsd npppd nsd ntpd ospf6d ospfd \
pflogd portmap rad radiusd rarpd rbootd relayd resolvd ripd route6d \
sasyncd sensorsd slowcgi slaacd smtpd sndiod snmpd spamd \
RCDAEMONS=amd apmd bgpd bgplgd bootparamd cron dhcpd dhcpleased dhcp6leased \
dhcrelay dhcrelay6 dvmrpd eigrpd ftpd ftpproxy ftpproxy6 hostapd \
hotplugd httpd identd ifstated iked inetd isakmpd iscsid ldapd \
ldattach ldomd ldpd lockd lpd mopd mountd mrouted nfsd npppd nsd ntpd \
ospf6d ospfd pflogd portmap rad radiusd rarpd rbootd relayd resolvd \
ripd route6d sasyncd sensorsd slowcgi slaacd smtpd sndiod snmpd spamd \
spamlogd sshd statd syslogd tftpd tftpproxy unbound \
unwind vmd watchdogd wsmoused xenodm ypbind ypldap ypserv

View File

@ -1,4 +1,4 @@
# $OpenBSD: changelist,v 1.138 2023/12/13 11:34:56 job Exp $
# $OpenBSD: changelist,v 1.139 2024/06/03 10:07:27 florian Exp $
#
# List of files which the security script backs up and checks
# for modifications.
@ -25,6 +25,7 @@
/etc/daily.local
/etc/defaultdomain
/etc/dhcpd.conf
/etc/dhcp6leased.conf
/etc/dhcpleased.conf
/etc/disktab
/etc/distfile

View File

@ -80,6 +80,7 @@ _ftp_proxy:*:109:
_sndiop:*:110:
_syspatch:*:112:
_slaacd:*:115:
_dhcp6leased:*:116:
dialer:*:117:
_shutdown:*:118:
nogroup:*:32766:

View File

@ -62,4 +62,5 @@ _ftp_proxy:*:109:109::0:0:ftp proxy daemon:/nonexistent:/sbin/nologin
_sndiop:*:110:110::0:0:sndio privileged user:/var/empty:/sbin/nologin
_syspatch:*:112:112::0:0:syspatch unprivileged user:/var/empty:/sbin/nologin
_slaacd:*:115:115::0:0:SLAAC Daemon:/var/empty:/sbin/nologin
_dhcp6leased:*:116:116::0:0:DHCP6Lease Daemon:/var/empty:/sbin/nologin
nobody:*:32767:32767::0:0:Unprivileged user:/nonexistent:/sbin/nologin

View File

@ -1,4 +1,4 @@
# $OpenBSD: 4.4BSD.dist,v 1.324 2023/10/26 19:28:30 naddy Exp $
# $OpenBSD: 4.4BSD.dist,v 1.325 2024/06/02 12:32:33 florian Exp $
/set type=dir uname=root gname=wheel mode=0755
@ -567,6 +567,8 @@ var
db
acpi
..
dhcp6leased
..
dhcpleased
..
ldap mode=0700

4
etc/rc
View File

@ -1,4 +1,4 @@
# $OpenBSD: rc,v 1.575 2024/05/17 00:33:43 deraadt Exp $
# $OpenBSD: rc,v 1.576 2024/06/03 10:06:35 florian Exp $
# System startup script run by init on autoboot or after single-user.
# Output and error are redirected to console by init, and the console is the
@ -633,7 +633,7 @@ run_upgrade_script sysmerge
echo -n 'starting network daemons:'
start_daemon ldomd sshd snmpd ldpd ripd ospfd ospf6d bgpd ifstated
start_daemon relayd dhcpd dhcrelay mrouted dvmrpd radiusd eigrpd route6d
start_daemon rad hostapd lpd smtpd slowcgi bgplgd httpd ftpd
start_daemon dhcp6leased rad hostapd lpd smtpd slowcgi bgplgd httpd ftpd
start_daemon ftpproxy ftpproxy6 tftpd tftpproxy identd inetd rarpd bootparamd
start_daemon rbootd mopd vmd spamd spamlogd sndiod
echo '.'

View File

@ -1,4 +1,4 @@
# $OpenBSD: rc.conf,v 1.227 2022/09/26 00:29:55 kn Exp $
# $OpenBSD: rc.conf,v 1.228 2024/06/03 10:06:35 florian Exp $
# DO NOT EDIT THIS FILE!!
#
@ -19,6 +19,7 @@ bgplgd_flags=NO
bootparamd_flags=NO
cron_flags=
dhcpd_flags=NO
dhcp6leased_flags=NO
dhcpleased_flags=
dhcrelay_flags=NO # for normal use: "-i interface [server]"
dvmrpd_flags=NO

16
etc/rc.d/dhcp6leased Normal file
View File

@ -0,0 +1,16 @@
#!/bin/ksh
#
# $OpenBSD: dhcp6leased,v 1.1 2024/06/03 10:06:35 florian Exp $
daemon="/sbin/dhcp6leased"
. /etc/rc.d/rc.subr
rc_configtest() {
# use rc_exec here since daemon_flags may contain arguments with spaces
rc_exec "${daemon} -n ${daemon_flags}"
}
rc_reload=NO
rc_cmd $1

View File

@ -1,4 +1,4 @@
/* $OpenBSD: io.c,v 1.22 2016/01/10 13:35:09 mestre Exp $ */
/* $OpenBSD: io.c,v 1.23 2024/06/03 09:43:10 otto Exp $ */
/* $NetBSD: io.c,v 1.9 1997/07/09 06:25:47 phil Exp $ */
/*-
@ -505,14 +505,12 @@ get_line(void)
{
size_t pos;
int c, oy, ox;
WINDOW *oscr;
oscr = stdscr;
stdscr = Msgwin;
getyx(stdscr, oy, ox);
refresh();
getyx(Msgwin, oy, ox);
wrefresh(Msgwin);
/* loop reading in the string, and put it in a temporary buffer */
for (pos = 0; (c = readchar()) != '\n'; clrtoeol(), refresh()) {
for (pos = 0; (c = readchar()) != '\n'; wclrtoeol(Msgwin),
wrefresh(Msgwin)) {
if (c == -1)
continue;
if (c == ' ' && (pos == 0 || linebuf[pos - 1] == ' '))
@ -522,13 +520,13 @@ get_line(void)
int i;
pos--;
for (i = strlen(unctrl(linebuf[pos])); i; i--)
addch('\b');
waddch(Msgwin, '\b');
}
continue;
}
if (c == killchar()) {
pos = 0;
move(oy, ox);
wmove(Msgwin, oy, ox);
continue;
}
if (pos >= LINESIZE - 1 || !(isalnum(c) || c == ' ')) {
@ -538,12 +536,11 @@ get_line(void)
if (islower(c))
c = toupper(c);
linebuf[pos++] = c;
addstr(unctrl(c));
waddstr(Msgwin, unctrl(c));
Mpos++;
}
while (pos < sizeof(linebuf))
linebuf[pos++] = '\0';
stdscr = oscr;
return (linebuf);
}

View File

@ -2857,6 +2857,10 @@ def fno_fixup_gadgets : Flag<["-"], "fno-fixup-gadgets">, Group<f_Group>, Flags<
HelpText<"Disable FixupGadgets pass (x86 only)">;
def ffixup_gadgets : Flag<["-"], "ffixup-gadgets">, Group<f_Group>, Flags<[CoreOption]>,
HelpText<"Replace ROP friendly instructions with safe alternatives (x86 only)">;
def fno_ret_clean : Flag<["-"], "fno-ret-clean">, Group<f_Group>, Flags<[CoreOption]>,
HelpText<"Disable ret-clean pass">;
def fret_clean : Flag<["-"], "fret-clean">, Group<f_Group>, Flags<[CoreOption]>,
HelpText<"Clean return address from stack after call">;
def ftrivial_auto_var_init_stop_after : Joined<["-"], "ftrivial-auto-var-init-stop-after=">, Group<f_Group>,
Flags<[CC1Option, CoreOption]>, HelpText<"Stop initializing trivial automatic stack variables after the specified number of instances">,
MarshallingInfoInt<LangOpts<"TrivialAutoVarInitStopAfter">>;

View File

@ -6402,6 +6402,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString(Twine("-x86-fixup-gadgets=true")));
}
// -ret-clean
if (Arg *A = Args.getLastArg(options::OPT_fno_ret_clean,
options::OPT_fret_clean)) {
CmdArgs.push_back(Args.MakeArgString(Twine("-mllvm")));
if (A->getOption().matches(options::OPT_fno_ret_clean))
CmdArgs.push_back(Args.MakeArgString(Twine("-x86-ret-clean=false")));
else if (A->getOption().matches(options::OPT_fret_clean))
CmdArgs.push_back(Args.MakeArgString(Twine("-x86-ret-clean=true")));
}
RenderSCPOptions(TC, Args, CmdArgs);
RenderTrivialAutoVarInitOptions(D, TC, Args, CmdArgs);

View File

@ -132,6 +132,10 @@ FunctionPass *createX86DomainReassignmentPass();
/// ROP friendly instructions with alternatives.
FunctionPass *createX86FixupGadgetsPass();
/// Return a Machine Function pass that attempts to replace
/// RET instructions with a cleaning sequence
FunctionPass *createX86RetCleanPass();
/// This pass replaces EVEX encoded of AVX-512 instructiosn by VEX
/// encoding when possible in order to reduce code size.
FunctionPass *createX86EvexToVexInsts();

View File

@ -0,0 +1,115 @@
//===-- X86RetClean.cpp - Clean Retaddr off stack upon function return ----===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
/// \file
/// This file defines a function pass that clears the ret-address from
/// the top of the stack, immediately upon return to the caller, the goal
/// is remove this subtle but powerful info-leak which hints at the
/// address space location of the lower level libraries.
///
//===----------------------------------------------------------------------===//
#include "X86.h"
#include "X86InstrBuilder.h"
#include "X86InstrInfo.h"
#include "X86MachineFunctionInfo.h"
#include "X86Subtarget.h"
#include "X86TargetMachine.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
#define RETCLEAN_DESC "X86 Ret Clean"
#define RETCLEAN_NAME "x86-ret-clean"
#define DEBUG_TYPE RETCLEAN_NAME
// Toggle with cc1 option: -mllvm -x86-ret-clean=<true|false>
static cl::opt<bool> RetClean(
"x86-ret-clean", cl::Hidden,
cl::desc("clean return address off stack after call"),
cl::init(false));
namespace {
class RetCleanPass : public MachineFunctionPass {
public:
static char ID;
StringRef getPassName() const override { return RETCLEAN_DESC; }
RetCleanPass()
: MachineFunctionPass(ID) {}
/// Loop over all the instructions and replace ret with ret+clean
bool runOnMachineFunction(MachineFunction &MF) override;
MachineFunctionProperties getRequiredProperties() const override {
return MachineFunctionProperties().set(
MachineFunctionProperties::Property::NoVRegs);
}
private:
bool fixupInstruction(MachineFunction &MF, MachineBasicBlock &MBB,
MachineInstr &MI);
};
char RetCleanPass::ID = 0;
} // namespace
FunctionPass *llvm::createX86RetCleanPass() {
return new RetCleanPass();
}
bool RetCleanPass::fixupInstruction(MachineFunction &MF,
MachineBasicBlock &MBB,
MachineInstr &MI) {
const X86InstrInfo *TII = MF.getSubtarget<X86Subtarget>().getInstrInfo();
bool Is64Bit = MF.getTarget().getTargetTriple().getArch() == Triple::x86_64;
unsigned Opc = Is64Bit ? X86::MOV64mi32 : X86::MOV32mi;
unsigned Offset = Is64Bit ? -8 : -4;
Register SPReg = Is64Bit ? X86::RSP : X86::ESP;
// add "movq $0, -8(%rsp)" (or similar) in caller, to clear the
// ret-addr info-leak off the stack
addRegOffset(BuildMI(MBB, MI, MI.getDebugLoc(), TII->get(Opc)),
SPReg, false, Offset)
.addImm(0);
return true;
}
bool RetCleanPass::runOnMachineFunction(MachineFunction &MF) {
if (!RetClean)
return false;
bool modified = false;
for (auto &MBB : MF) {
std::vector<MachineInstr*> fixups;
bool foundcall = false;
for (auto &MI : MBB) {
if (MI.isCall()) {
foundcall = true; // queue the insert before the next MI
} else if (foundcall) {
fixups.push_back(&MI);
foundcall = false;
}
}
for (auto *fixup : fixups)
modified |= fixupInstruction(MF, MBB, *fixup);
}
return modified;
}

View File

@ -596,6 +596,8 @@ void X86PassConfig::addPreEmitPass2() {
addPass(createX86IndirectThunksPass());
addPass(createX86ReturnThunksPass());
addPass(createX86RetCleanPass());
// Insert extra int3 instructions after trailing call instructions to avoid
// issues in the unwinder.
if (TT.isOSWindows() && TT.getArch() == Triple::x86_64)

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.18 2023/11/11 18:35:38 robert Exp $
# $OpenBSD: Makefile,v 1.19 2024/06/02 15:40:42 deraadt Exp $
LIB= LLVMX86CodeGen
NOPROFILE=
@ -25,6 +25,7 @@ SRCS+= X86AsmPrinter.cpp \
X86FastISel.cpp \
X86FixupBWInsts.cpp \
X86FixupGadgets.cpp \
X86RetClean.cpp \
X86FixupLEAs.cpp \
X86AvoidStoreForwardingBlocks.cpp \
X86DynAllocaExpander.cpp \

View File

@ -1,6 +1,6 @@
# $OpenBSD: Makefile,v 1.10 2020/04/01 15:26:53 claudio Exp $
# $OpenBSD: Makefile,v 1.11 2024/06/03 08:02:22 anton Exp $
PROG= generic
SRCS= main.c manager.c test_stdio.c test_tty.c
SRCS= main.c manager.c test_stdio.c test_tty.c pty.c
NOMAN= yes
LDADD+= -lutil

View File

@ -1,4 +1,4 @@
/* $OpenBSD: manager.c,v 1.8 2024/04/26 04:44:43 jsg Exp $ */
/* $OpenBSD: manager.c,v 1.9 2024/06/03 08:02:22 anton Exp $ */
/*
* Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org>
*
@ -32,6 +32,7 @@
#include <unistd.h>
#include "manager.h"
#include "pty.h"
extern char *__progname;
@ -89,20 +90,18 @@ clear_coredump(int *ret, const char *test_name)
static int
grab_syscall(pid_t pid)
grab_syscall(pid_t pid, char *output)
{
int ret = -1;
char *pattern;
regex_t regex;
regmatch_t matches[2];
FILE *fd;
char line[1024];
int error;
const char *errstr;
/* build searched string */
error = asprintf(&pattern,
"^%s\\[%d\\]: pledge \"[a-z]+\", syscall ([0-9]+)\n?$",
"%s\\[%d\\]: pledge \"[a-z]+\", syscall ([0-9]+)",
__progname, pid);
if (error <= 0) {
warn("asprintf pattern");
@ -119,56 +118,28 @@ grab_syscall(pid_t pid)
goto out;
}
/* call dmesg */
if ((fd = popen("/sbin/dmesg", "r")) == NULL) {
warn("popen /sbin/dmesg");
goto out;
}
/* search the string */
while (1) {
/* read a line */
fgets(line, sizeof(line), fd);
/* error checking */
if (ferror(fd)) {
ret = -1;
goto out;
}
/* quit */
if (feof(fd))
break;
/* check if found */
error = regexec(&regex, line, 2, matches, 0);
if (error == REG_NOMATCH)
continue;
if (error) {
warnx("regexec pattern=%s line=%s error=%d",
pattern, line, error);
ret = -1;
goto out;
}
/* convert it */
line[matches[1].rm_eo] = '\0';
ret = strtonum(&line[matches[1].rm_so], 0, 255, &errstr);
if (errstr) {
warnx("strtonum: number=%s error=%s",
&line[matches[1].rm_so], errstr);
ret = -1;
goto out;
}
error = regexec(&regex, output, 2, matches, 0);
if (error == REG_NOMATCH) {
ret = 0;
goto out;
}
if (error) {
warnx("regexec pattern=%s output=%s error=%d",
pattern, output, error);
ret = -1;
goto out;
}
/* cleanup */
if (pclose(fd) == -1)
/* convert it */
output[matches[1].rm_eo] = '\0';
ret = strtonum(&output[matches[1].rm_so], 0, 255, &errstr);
if (errstr) {
warnx("strtonum: number=%s error=%s",
&output[matches[1].rm_so], errstr);
ret = -1;
goto out;
/* not found */
if (ret == -1)
ret = 0;
}
out:
free(pattern);
@ -198,6 +169,7 @@ void
_start_test(int *ret, const char *test_name, const char *request,
void (*test_func)(void))
{
struct pty pty = {0};
int fildes[2];
pid_t pid;
int status;
@ -228,6 +200,11 @@ _start_test(int *ret, const char *test_name, const char *request,
return;
}
if (pty_open(&pty)) {
*ret = EXIT_FAILURE;
return;
}
/* fork and launch the test */
switch (pid = fork()) {
case -1:
@ -245,9 +222,19 @@ _start_test(int *ret, const char *test_name, const char *request,
if (errno != EINTR)
err(errno, "dup2");
if (pty_detach(&pty)) {
*ret = EXIT_FAILURE;
return;
}
/* create a new session (for kill) */
setsid();
if (pty_attach(&pty)) {
*ret = EXIT_FAILURE;
return;
}
/* set pledge policy */
if (request && pledge(request, NULL) != 0)
err(errno, "pledge");
@ -263,6 +250,11 @@ _start_test(int *ret, const char *test_name, const char *request,
/* NOTREACHED */
}
if (pty_drain(&pty)) {
*ret = EXIT_FAILURE;
return;
}
/* copy pipe to output */
(void)close(fildes[1]);
if (drainfd(fildes[0], STDOUT_FILENO) != 0) {
@ -331,7 +323,7 @@ _start_test(int *ret, const char *test_name, const char *request,
/* grab pledged syscall from dmesg */
if (signal == SIGKILL || signal == SIGABRT) {
int syscall = grab_syscall(pid);
int syscall = grab_syscall(pid, pty_buffer(&pty));
switch (syscall) {
case -1: /* error */
warn("test(%s): grab_syscall pid=%d", test_name,
@ -352,5 +344,7 @@ _start_test(int *ret, const char *test_name, const char *request,
if (WIFSTOPPED(status))
printf(" stop=%d", WSTOPSIG(status));
pty_close(&pty);
printf("\n");
}

View File

@ -0,0 +1,103 @@
/* $OpenBSD: pty.c,v 1.1 2024/06/03 08:02:22 anton Exp $ */
#include <sys/ioctl.h>
#include <err.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include "pty.h"
int
pty_open(struct pty *pty)
{
int master, slave;
master = posix_openpt(O_RDWR);
if (master == -1) {
warn("posix_openpt");
return 1;
}
if (grantpt(master) == -1) {
warn("grantpt");
return 1;
}
if (unlockpt(master) == -1) {
warn("unlockpt");
return 1;
}
slave = open(ptsname(master), O_RDWR);
if (slave == -1) {
warn("%s", ptsname(master));
return 1;
}
pty->master = master;
pty->slave = slave;
return 0;
}
void
pty_close(struct pty *pty)
{
close(pty->slave);
close(pty->master);
}
/*
* Disconnect the controlling tty, if present.
*/
int
pty_detach(struct pty *pty)
{
int fd;
fd = open("/dev/tty", O_RDWR | O_NOCTTY);
if (fd >= 0) {
(void)ioctl(fd, TIOCNOTTY, NULL);
close(fd);
}
return 0;
}
/*
* Connect the slave as the controlling tty.
*/
int
pty_attach(struct pty *pty)
{
if (ioctl(pty->slave, TIOCSCTTY, NULL) == -1) {
warn("TIOCSCTTY");
return 1;
}
return 0;
}
int
pty_drain(struct pty *pty)
{
for (;;) {
char *buf = &pty->buf.storage[pty->buf.len];
size_t bufsize = sizeof(pty->buf.storage) - pty->buf.len;
ssize_t n;
n = read(pty->master, buf, bufsize);
if (n == -1) {
warn("read");
return 1;
}
if (n == 0)
break;
/* Ensure space for NUL-terminator. */
if ((size_t)n >= bufsize) {
warnx("pty buffer too small");
return 1;
}
pty->buf.len += n;
}
return 0;
}

View File

@ -0,0 +1,22 @@
/* $OpenBSD: pty.h,v 1.1 2024/06/03 08:02:22 anton Exp $ */
struct pty {
struct {
char storage[1024];
size_t len;
} buf;
int master;
int slave;
};
int pty_open(struct pty *);
void pty_close(struct pty *);
int pty_detach(struct pty *);
int pty_attach(struct pty *);
int pty_drain(struct pty *pty);
static inline char *
pty_buffer(struct pty *pty)
{
return pty->buf.storage;
}

View File

@ -1,6 +1,6 @@
# $OpenBSD: Makefile,v 1.110 2021/02/26 17:17:03 florian Exp $
# $OpenBSD: Makefile,v 1.111 2024/06/03 10:05:18 florian Exp $
SUBDIR= atactl badsect bioctl clri dhclient dhcpleased \
SUBDIR= atactl badsect bioctl clri dhclient dhcp6leased dhcpleased \
disklabel dmesg dump dumpfs fdisk fsck fsck_ext2fs fsck_ffs \
fsck_msdos fsdb fsirand growfs ifconfig iked init ipsecctl \
isakmpd kbd ldattach mknod mount \

23
sbin/dhcp6leased/Makefile Normal file
View File

@ -0,0 +1,23 @@
# $OpenBSD: Makefile,v 1.1 2024/06/02 12:28:05 florian Exp $
PROG= dhcp6leased
SRCS= control.c dhcp6leased.c engine.c frontend.c log.c
SRCS+= parse.y printconf.c
MAN= dhcp6leased.8 dhcp6leased.conf.5
#DEBUG= -g -DDEBUG=3 -O0
CFLAGS+= -Wall -I${.CURDIR}
CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes
CFLAGS+= -Wmissing-declarations
CFLAGS+= -Wshadow -Wpointer-arith -Wcast-qual
CFLAGS+= -Wsign-compare
YFLAGS=
LDADD+= -levent -lutil
DPADD+= ${LIBEVENT} ${LIBUTIL}
.include <bsd.prog.mk>
# Don't compile dhcp6leased as static binary by default
LDSTATIC=

306
sbin/dhcp6leased/control.c Normal file
View File

@ -0,0 +1,306 @@
/* $OpenBSD: control.c,v 1.2 2024/06/02 13:35:52 florian Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <net/if.h>
#include <netinet/in.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "log.h"
#include "dhcp6leased.h"
#include "control.h"
#include "frontend.h"
#define CONTROL_BACKLOG 5
struct {
struct event ev;
struct event evt;
int fd;
} control_state = {.fd = -1};
struct ctl_conn {
TAILQ_ENTRY(ctl_conn) entry;
struct imsgev iev;
};
struct ctl_conn *control_connbyfd(int);
struct ctl_conn *control_connbypid(pid_t);
void control_close(int);
TAILQ_HEAD(ctl_conns, ctl_conn) ctl_conns = TAILQ_HEAD_INITIALIZER(ctl_conns);
int
control_init(char *path)
{
struct sockaddr_un sun;
int fd;
mode_t old_umask;
if ((fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK,
0)) == -1) {
log_warn("%s: socket", __func__);
return (-1);
}
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
strlcpy(sun.sun_path, path, sizeof(sun.sun_path));
if (unlink(path) == -1)
if (errno != ENOENT) {
log_warn("%s: unlink %s", __func__, path);
close(fd);
return (-1);
}
old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH);
if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) {
log_warn("%s: bind: %s", __func__, path);
close(fd);
umask(old_umask);
return (-1);
}
umask(old_umask);
if (chmod(path, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) == -1) {
log_warn("%s: chmod", __func__);
close(fd);
(void)unlink(path);
return (-1);
}
return (fd);
}
int
control_listen(int fd)
{
if (control_state.fd != -1)
fatalx("%s: received unexpected controlsock", __func__);
control_state.fd = fd;
if (listen(control_state.fd, CONTROL_BACKLOG) == -1) {
log_warn("%s: listen", __func__);
return (-1);
}
event_set(&control_state.ev, control_state.fd, EV_READ,
control_accept, NULL);
event_add(&control_state.ev, NULL);
evtimer_set(&control_state.evt, control_accept, NULL);
return (0);
}
void
control_accept(int listenfd, short event, void *bula)
{
int connfd;
socklen_t len;
struct sockaddr_un sun;
struct ctl_conn *c;
event_add(&control_state.ev, NULL);
if ((event & EV_TIMEOUT))
return;
len = sizeof(sun);
if ((connfd = accept4(listenfd, (struct sockaddr *)&sun, &len,
SOCK_CLOEXEC | SOCK_NONBLOCK)) == -1) {
/*
* Pause accept if we are out of file descriptors, or
* libevent will haunt us here too.
*/
if (errno == ENFILE || errno == EMFILE) {
struct timeval evtpause = { 1, 0 };
event_del(&control_state.ev);
evtimer_add(&control_state.evt, &evtpause);
} else if (errno != EWOULDBLOCK && errno != EINTR &&
errno != ECONNABORTED)
log_warn("%s: accept4", __func__);
return;
}
if ((c = calloc(1, sizeof(struct ctl_conn))) == NULL) {
log_warn("%s: calloc", __func__);
close(connfd);
return;
}
imsg_init(&c->iev.ibuf, connfd);
c->iev.handler = control_dispatch_imsg;
c->iev.events = EV_READ;
event_set(&c->iev.ev, c->iev.ibuf.fd, c->iev.events,
c->iev.handler, &c->iev);
event_add(&c->iev.ev, NULL);
TAILQ_INSERT_TAIL(&ctl_conns, c, entry);
}
struct ctl_conn *
control_connbyfd(int fd)
{
struct ctl_conn *c;
TAILQ_FOREACH(c, &ctl_conns, entry) {
if (c->iev.ibuf.fd == fd)
break;
}
return (c);
}
struct ctl_conn *
control_connbypid(pid_t pid)
{
struct ctl_conn *c;
TAILQ_FOREACH(c, &ctl_conns, entry) {
if (c->iev.ibuf.pid == pid)
break;
}
return (c);
}
void
control_close(int fd)
{
struct ctl_conn *c;
if ((c = control_connbyfd(fd)) == NULL) {
log_warnx("%s: fd %d: not found", __func__, fd);
return;
}
msgbuf_clear(&c->iev.ibuf.w);
TAILQ_REMOVE(&ctl_conns, c, entry);
event_del(&c->iev.ev);
close(c->iev.ibuf.fd);
/* Some file descriptors are available again. */
if (evtimer_pending(&control_state.evt, NULL)) {
evtimer_del(&control_state.evt);
event_add(&control_state.ev, NULL);
}
free(c);
}
void
control_dispatch_imsg(int fd, short event, void *bula)
{
struct ctl_conn *c;
struct imsg imsg;
ssize_t n;
int verbose;
if ((c = control_connbyfd(fd)) == NULL) {
log_warnx("%s: fd %d: not found", __func__, fd);
return;
}
if (event & EV_READ) {
if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) ||
n == 0) {
control_close(fd);
return;
}
}
if (event & EV_WRITE) {
if (msgbuf_write(&c->iev.ibuf.w) <= 0 && errno != EAGAIN) {
control_close(fd);
return;
}
}
for (;;) {
if ((n = imsg_get(&c->iev.ibuf, &imsg)) == -1) {
control_close(fd);
return;
}
if (n == 0)
break;
switch (imsg.hdr.type) {
case IMSG_CTL_RELOAD:
frontend_imsg_compose_main(imsg.hdr.type, 0, NULL, 0);
break;
case IMSG_CTL_LOG_VERBOSE:
if (IMSG_DATA_SIZE(imsg) != sizeof(verbose))
break;
c->iev.ibuf.pid = imsg.hdr.pid;
/* Forward to all other processes. */
frontend_imsg_compose_main(imsg.hdr.type, imsg.hdr.pid,
imsg.data, IMSG_DATA_SIZE(imsg));
frontend_imsg_compose_engine(imsg.hdr.type, 0,
imsg.hdr.pid, imsg.data, IMSG_DATA_SIZE(imsg));
memcpy(&verbose, imsg.data, sizeof(verbose));
log_setverbose(verbose);
break;
case IMSG_CTL_SHOW_INTERFACE_INFO:
if (IMSG_DATA_SIZE(imsg) != sizeof(uint32_t))
break;
c->iev.ibuf.pid = imsg.hdr.pid;
frontend_imsg_compose_engine(imsg.hdr.type, 0,
imsg.hdr.pid, imsg.data, IMSG_DATA_SIZE(imsg));
break;
case IMSG_CTL_SEND_REQUEST:
if (IMSG_DATA_SIZE(imsg) != sizeof(uint32_t))
break;
c->iev.ibuf.pid = imsg.hdr.pid;
frontend_imsg_compose_engine(IMSG_REQUEST_REBOOT, 0,
imsg.hdr.pid, imsg.data, IMSG_DATA_SIZE(imsg));
break;
default:
log_debug("%s: error handling imsg %d", __func__,
imsg.hdr.type);
break;
}
imsg_free(&imsg);
}
imsg_event_add(&c->iev);
}
int
control_imsg_relay(struct imsg *imsg)
{
struct ctl_conn *c;
if ((c = control_connbypid(imsg->hdr.pid)) == NULL)
return (0);
return (imsg_compose_event(&c->iev, imsg->hdr.type, 0, imsg->hdr.pid,
-1, imsg->data, IMSG_DATA_SIZE(*imsg)));
}

View File

@ -0,0 +1,23 @@
/* $OpenBSD: control.h,v 1.1 2024/06/02 12:28:05 florian Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
int control_init(char *);
int control_listen(int);
void control_accept(int, short, void *);
void control_dispatch_imsg(int, short, void *);
int control_imsg_relay(struct imsg *);

View File

@ -0,0 +1,102 @@
.\" $OpenBSD: dhcp6leased.8,v 1.1 2024/06/02 12:28:05 florian Exp $
.\"
.\" Copyright (c) 2024 Florian Obser <florian@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: June 2 2024 $
.Dt DHCP6LEASED 8
.Os
.Sh NAME
.Nm dhcp6leased
.Nd Dynamic Host Configuration Protocol (DHCPv6) client daemon for IPv6 prefix delegation
.Sh SYNOPSIS
.Nm
.Op Fl dnv
.Op Fl f Ar file
.Op Fl s Ar socket
.Sh DESCRIPTION
.Nm
is an IPv6 dynamic host configuration protocol (DHCPv6) daemon for clients.
It requests IPv6 prefix delegations from DHCPv6 servers for assignment
to downstream interfaces.
.Pp
A running
.Nm
can be controlled with the
.Xr dhcp6leasectl 8
utility.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl d
Do not daemonize.
If this option is specified,
.Nm
will run in the foreground and log to
.Em stderr .
.It Fl f Ar file
Specify an alternative configuration file.
.It Fl n
Configtest mode.
Only check the configuration file for validity.
.It Fl s Ar socket
Use an alternate location for the default control socket.
.It Fl v
Produce more verbose output.
Multiple
.Fl v
options increase the verbosity.
.El
.Sh FILES
.Bl -tag -width "/var/db/dhcp6leased/<if>" -compact
.It Pa /dev/dhcp6leased.sock
.Ux Ns -domain
socket used for communication with
.Xr dhcp6leasectl 8 .
.It Pa /etc/dhcp6leased.conf
Default
.Nm
configuration file.
.It Pa /var/db/dhcp6leased/ Ns Aq Ar if
Interface specific lease files.
.El
.Sh SEE ALSO
.Xr dhcp6leased.conf 5 ,
.Xr dhcp6leasectl 8 ,
.Xr ifconfig 8
.Sh STANDARDS
.Rs
.%A T. Mrugalski
.%A M. Siodelski
.%A B. Volz
.%A A. Yourtchenko
.%A M. Richardson
.%A S. Jiang
.%A T. Lemon
.%A T. Winters
.%D November 2018
.%R RFC 8415
.%T Dynamic Host Configuration Protocol for IPv6 (DHCPv6)
.Re
.Sh HISTORY
The
.Nm
program first appeared in
.Ox 7.6 .
.Sh AUTHORS
.An -nosplit
The
.Nm
program was written by
.An Florian Obser Aq Mt florian@openbsd.org .

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,131 @@
.\" $OpenBSD: dhcp6leased.conf.5,v 1.3 2024/06/03 11:08:31 florian Exp $
.\"
.\" Copyright (c) 2018, 2021, 2024 Florian Obser <florian@openbsd.org>
.\" Copyright (c) 2005 Esben Norby <norby@openbsd.org>
.\" Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
.\" Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
.\" Copyright (c) 2002 Daniel Hartmeier <dhartmei@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: June 3 2024 $
.Dt DHCP6LEASED.CONF 5
.Os
.Sh NAME
.Nm dhcp6leased.conf
.Nd DHCPv6 client configuration file
.Sh DESCRIPTION
The
.Xr dhcp6leased 8
daemon is a dynamic host configuration protocol client daemon for IPv6 prefix
delegation.
.Pp
The
.Nm
config file is divided into the following main sections:
.Bl -tag -width xxxx
.It Sy Macros
User-defined variables may be defined and used later, simplifying the
configuration file.
.It Sy Global Configuration
Global settings for
.Xr dhcp6leased 8 .
.It Sy Prefix delegation
.Xr dhcp6leased 8
requests prefix delegation from a DHCPv6 server and assigns prefixes
to interfaces.
This section defines on which interfaces prefix delegation should be
requested and to which interfaces prefixes should be assigned.
.El
.Sh MACROS
Macros can be defined that will later be expanded in context.
Macro names must start with a letter, digit, or underscore,
and may contain any of those characters.
Macro names may not be reserved words (for example,
.Ic interface ) .
Macros are not expanded inside quotes.
.Sh GLOBAL CONFIGURATION
These settings affect the operation of the
.Xr dhcp6leased 8
daemon as a whole.
.Bl -tag -width Ds
.It Ic request rapid commit
Send the rapid commit DHCPv6 option, requesting a two-message exchange
from the server instead of the normal four-message exchange.
.El
.Sh PREFIX DELEGATION
A list of interfaces on which to request prefix delegation:
.Bd -unfilled -offset indent
.Ic request prefix delegation on Ar name Ic for Ar { name/prefix Oo Ar name/prefix ... Oc }
.Ed
.Pp
This requests a prefix delegation on
.Ar name
upstream network interface for the list of
.Ar name/prefix
network interfaces.
If
.Ar prefix
is omitted a default of /64 is used.
.Pp
.Xr dhcp6leased 8
will calculate the prefix length needed to cover all interfaces in the list.
When a prefix is delegated by a DHCPv6 server,
.Xr dhcp6leased 8
splits the prefix into smaller prefixes and assigns them to the interfaces
in the order they are listed.
This might create unassigned gaps in the delegated prefix.
.Pp
For example if a /64 and /60 prefix are to be assigned to network interfaces,
.Xr dhcp6leased 8
requests a /59 prefix.
The prefix is then split into two /60 prefixes and the first /64 out of the
first /60 prefix is assigned to the first interface.
The second /60 prefix from the delegated /59 is assigned to the
second interface.
This leaves 15 unused /64 prefixes in the first /60.
.Pp
Care should be taken to avoid renumbering of existing interfaces
when new interfaces are added or existing interfaces are removed.
New interfaces can be added to the end of the list or in places
where unassigned gaps were present.
.Pp
The special name
.Cm reserve
can be used to reserve space in the delegated prefix for later use or
when an interface is removed.
.Pp
Running
.Xr dhcp6leased 8
in configtest mode with a verbosity of two or more will print the
configuration file with comments indicated how prefixes would be
assigned to network interfaces.
This can be used to check that existing interface are not renumbered.
.Pp
More than one prefix can be requested from a DHCPv6 server, however most ISP
DHCPv6 servers will only delegate a single prefix.
Therefore it is better to let
.Xr dhcp6leased 8
request a single larger prefix and split it up.
.Xr dhcp6leased 8
has a compile time limit on how many prefix requests per interface it can
handle.
.Sh FILES
.Bl -tag -width /etc/dhcp6leased.conf -compact
.It Pa /etc/dhcp6leased.conf
.Xr dhcp6leased 8
configuration file.
.El
.Sh SEE ALSO
.Xr dhcp6leasectl 8 ,
.Xr dhcp6leased 8

View File

@ -0,0 +1,276 @@
/* $OpenBSD: dhcp6leased.h,v 1.4 2024/06/03 11:08:31 florian Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
* Copyright (c) 2004 Esben Norby <norby@openbsd.org>
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#define _PATH_LOCKFILE "/dev/dhcp6leased.lock"
#define _PATH_CONF_FILE "/etc/dhcp6leased.conf"
#define _PATH_CTRL_SOCKET "/dev/dhcp6leased.sock"
#define DHCP6LEASED_USER "_dhcp6leased"
#define DHCP6LEASED_RTA_LABEL "dhcp6leased"
#define CLIENT_PORT 546
#define SERVER_PORT 547
#define _PATH_LEASE "/var/db/dhcp6leased/"
#define _PATH_UUID _PATH_LEASE"uuid"
#define UUID_SIZE 16
#define UUID_STR_SIZE sizeof("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n")
#define DUID_UUID_TYPE 4
#define XID_SIZE 3
#define SERVERID_SIZE 130 /* 2 octet type, max 128 octets data */
#define MAX_IA 32
#define LEASE_VERSION "version: 2"
#define LEASE_IP_PREFIX "ip: "
#define LEASE_NEXTSERVER_PREFIX "next-server: "
#define LEASE_BOOTFILE_PREFIX "filename: "
#define LEASE_HOSTNAME_PREFIX "host-name: "
#define LEASE_DOMAIN_PREFIX "domain-name: "
#define LEASE_SIZE 4096
/* MAXDNAME from arpa/namesr.h */
#define DHCP6LEASED_MAX_DNSSL 1025
#define MAX_RDNS_COUNT 8 /* max nameserver in a RTM_PROPOSAL */
/* A 1500 bytes packet can hold less than 300 classless static routes */
#define MAX_DHCP_ROUTES 256
#define OPENBSD_ENTERPRISENO 30155
/* DHCP message types. */
#define DHCPSOLICIT 1
#define DHCPADVERTISE 2
#define DHCPREQUEST 3
#define DHCPCONFIRM 4
#define DHCPRENEW 5
#define DHCPREBIND 6
#define DHCPREPLY 7
#define DHCPRELEASE 8
#define DHCPDECLINE 9
#define DHCPRECONFIGURE 10
#define DHCPINFORMATIONREQUEST 11
#define DHCPRELAYFORW 12
#define DHCPRELAYREPL 13
/* DHCP options */
#define DHO_CLIENTID 1
#define DHO_SERVERID 2
#define DHO_ORO 6
#define DHO_ELAPSED_TIME 8
#define DHO_STATUS_CODE 13
#define DHO_RAPID_COMMIT 14
#define DHO_VENDOR_CLASS 16
#define DHO_IA_PD 25
#define DHO_IA_PREFIX 26
#define DHO_SOL_MAX_RT 82
#define DHO_INF_MAX_RT 83
/* Status Code Option status codes */
#define DHCP_STATUS_SUCCESS 0
#define DHCP_STATUS_UNSPECFAIL 1
#define DHCP_STATUS_NOADDRSAVAIL 2
#define DHCP_STATUS_NOBINDING 3
#define DHCP_STATUS_NOTONLINK 4
#define DHCP_STATUS_USEMULTICAST 5
#define DHCP_STATUS_NOPREFIXAVAIL 6
/* Ignore parts of DHCP lease */
#define IGN_ROUTES 1
#define IGN_DNS 2
#define MAX_SERVERS 16 /* max servers that can be ignored per if */
#define IMSG_DATA_SIZE(imsg) ((imsg).hdr.len - IMSG_HEADER_SIZE)
#define DHCP_SNAME_LEN 64
#define DHCP_FILE_LEN 128
struct dhcp_hdr {
uint8_t msg_type; /* Message opcode/type */
uint8_t xid[XID_SIZE]; /* Transaction ID */
} __packed;
struct dhcp_option_hdr {
uint16_t code;
uint16_t len;
} __packed;
struct dhcp_duid {
uint16_t type;
uint8_t uuid[UUID_SIZE];
} __packed;
struct dhcp_iapd {
uint32_t iaid;
uint32_t t1;
uint32_t t2;
} __packed;
struct dhcp_vendor_class {
uint32_t enterprise_number;
uint16_t vendor_class_len;
} __packed;
struct dhcp_iaprefix {
uint32_t pltime;
uint32_t vltime;
uint8_t prefix_len;
struct in6_addr prefix;
} __packed;
struct imsgev {
struct imsgbuf ibuf;
void (*handler)(int, short, void *);
struct event ev;
short events;
};
struct dhcp_route {
struct in_addr dst;
struct in_addr mask;
struct in_addr gw;
};
enum imsg_type {
IMSG_NONE,
IMSG_CTL_LOG_VERBOSE,
IMSG_CTL_SHOW_INTERFACE_INFO,
IMSG_CTL_SEND_REQUEST,
IMSG_CTL_RELOAD,
IMSG_CTL_END,
IMSG_RECONF_CONF,
IMSG_RECONF_IFACE,
IMSG_RECONF_IFACE_IA,
IMSG_RECONF_IFACE_PD,
IMSG_RECONF_IFACE_IA_END,
IMSG_RECONF_IFACE_END,
IMSG_RECONF_END,
IMSG_SEND_SOLICIT,
IMSG_SEND_REQUEST,
IMSG_SEND_RENEW,
IMSG_SEND_REBIND,
IMSG_SOCKET_IPC,
IMSG_OPEN_UDPSOCK,
IMSG_UDPSOCK,
IMSG_ROUTESOCK,
IMSG_UUID,
IMSG_CONTROLFD,
IMSG_STARTUP,
IMSG_UPDATE_IF,
IMSG_REMOVE_IF,
IMSG_DHCP,
IMSG_CONFIGURE_ADDRESS,
IMSG_DECONFIGURE_ADDRESS,
IMSG_REQUEST_REBOOT,
};
struct ctl_engine_info {
uint32_t if_index;
int running;
int link_state;
char state[sizeof("IF_INIT_REBOOT")];
struct timespec request_time;
uint32_t lease_time;
uint32_t t1;
uint32_t t2;
};
struct iface_pd_conf {
SIMPLEQ_ENTRY(iface_pd_conf) entry;
char name[IF_NAMESIZE];
struct in6_addr prefix_mask;
int prefix_len;
};
struct iface_ia_conf {
SIMPLEQ_ENTRY(iface_ia_conf) entry;
SIMPLEQ_HEAD(iface_pd_conf_head, iface_pd_conf) iface_pd_list;
int id;
int prefix_len;
};
struct iface_conf {
SIMPLEQ_ENTRY(iface_conf) entry;
SIMPLEQ_HEAD(iface_ia_conf_head,
iface_ia_conf) iface_ia_list;
uint32_t ia_count;
char name[IF_NAMESIZE];
};
struct dhcp6leased_conf {
SIMPLEQ_HEAD(iface_conf_head, iface_conf) iface_list;
int rapid_commit;
};
struct imsg_ifinfo {
uint32_t if_index;
int rdomain;
int running;
int link_state;
char lease[LEASE_SIZE];
};
struct imsg_propose_rdns {
uint32_t if_index;
int rdomain;
int rdns_count;
struct in_addr rdns[MAX_RDNS_COUNT];
};
struct imsg_dhcp {
uint32_t if_index;
ssize_t len;
uint8_t packet[1500];
};
struct prefix {
struct in6_addr prefix;
int prefix_len;
uint32_t vltime;
uint32_t pltime;
};
struct imsg_req_dhcp {
uint32_t if_index;
int elapsed_time;
uint8_t xid[XID_SIZE];
int serverid_len;
uint8_t serverid[SERVERID_SIZE];
struct prefix pds[MAX_IA];
};
/* dhcp6leased.c */
void imsg_event_add(struct imsgev *);
int imsg_compose_event(struct imsgev *, uint16_t, uint32_t,
pid_t, int, void *, uint16_t);
void config_clear(struct dhcp6leased_conf *);
struct dhcp6leased_conf *config_new_empty(void);
void merge_config(struct dhcp6leased_conf *, struct
dhcp6leased_conf *);
const char *sin6_to_str(struct sockaddr_in6 *);
/* engine.c */
const char *dhcp_message_type2str(uint8_t);
/* frontend.c */
struct iface_conf *find_iface_conf(struct iface_conf_head *, char *);
int *changed_ifaces(struct dhcp6leased_conf *, struct
dhcp6leased_conf *);
/* printconf.c */
void print_config(struct dhcp6leased_conf *, int);
/* parse.y */
struct dhcp6leased_conf *parse_config(const char *);
int cmdline_symset(char *);

1505
sbin/dhcp6leased/engine.c Normal file

File diff suppressed because it is too large Load Diff

28
sbin/dhcp6leased/engine.h Normal file
View File

@ -0,0 +1,28 @@
/* $OpenBSD: engine.h,v 1.1 2024/06/02 12:28:05 florian Exp $ */
/*
* Copyright (c) 2021 Florian Obser <florian@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
struct imsg_configure_address {
uint32_t if_index;
struct sockaddr_in6 addr;
struct in6_addr mask;
uint32_t vltime;
uint32_t pltime;
};
void engine(int, int);
int engine_imsg_compose_frontend(int, pid_t, void *, uint16_t);

1092
sbin/dhcp6leased/frontend.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
/* $OpenBSD: frontend.h,v 1.1 2024/06/02 12:28:05 florian Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void frontend(int, int);
void frontend_dispatch_main(int, short, void *);
void frontend_dispatch_engine(int, short, void *);
int frontend_imsg_compose_main(int, pid_t, void *, uint16_t);
int frontend_imsg_compose_engine(int, uint32_t, pid_t, void *,
uint16_t);

199
sbin/dhcp6leased/log.c Normal file
View File

@ -0,0 +1,199 @@
/* $OpenBSD: log.c,v 1.1 2024/06/02 12:28:05 florian Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <syslog.h>
#include <errno.h>
#include <time.h>
#include "log.h"
static int debug;
static int verbose;
static const char *log_procname;
void
log_init(int n_debug, int facility)
{
extern char *__progname;
debug = n_debug;
verbose = n_debug;
log_procinit(__progname);
if (!debug)
openlog(__progname, LOG_PID | LOG_NDELAY, facility);
tzset();
}
void
log_procinit(const char *procname)
{
if (procname != NULL)
log_procname = procname;
}
void
log_setverbose(int v)
{
verbose = v;
}
int
log_getverbose(void)
{
return (verbose);
}
void
logit(int pri, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vlog(pri, fmt, ap);
va_end(ap);
}
void
vlog(int pri, const char *fmt, va_list ap)
{
char *nfmt;
int saved_errno = errno;
if (debug) {
/* best effort in out of mem situations */
if (asprintf(&nfmt, "%s\n", fmt) == -1) {
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
} else {
vfprintf(stderr, nfmt, ap);
free(nfmt);
}
fflush(stderr);
} else
vsyslog(pri, fmt, ap);
errno = saved_errno;
}
void
log_warn(const char *emsg, ...)
{
char *nfmt;
va_list ap;
int saved_errno = errno;
/* best effort to even work in out of memory situations */
if (emsg == NULL)
logit(LOG_ERR, "%s", strerror(saved_errno));
else {
va_start(ap, emsg);
if (asprintf(&nfmt, "%s: %s", emsg,
strerror(saved_errno)) == -1) {
/* we tried it... */
vlog(LOG_ERR, emsg, ap);
logit(LOG_ERR, "%s", strerror(saved_errno));
} else {
vlog(LOG_ERR, nfmt, ap);
free(nfmt);
}
va_end(ap);
}
errno = saved_errno;
}
void
log_warnx(const char *emsg, ...)
{
va_list ap;
va_start(ap, emsg);
vlog(LOG_ERR, emsg, ap);
va_end(ap);
}
void
log_info(const char *emsg, ...)
{
va_list ap;
va_start(ap, emsg);
vlog(LOG_INFO, emsg, ap);
va_end(ap);
}
void
log_debug(const char *emsg, ...)
{
va_list ap;
if (verbose) {
va_start(ap, emsg);
vlog(LOG_DEBUG, emsg, ap);
va_end(ap);
}
}
static void
vfatalc(int code, const char *emsg, va_list ap)
{
static char s[BUFSIZ];
const char *sep;
if (emsg != NULL) {
(void)vsnprintf(s, sizeof(s), emsg, ap);
sep = ": ";
} else {
s[0] = '\0';
sep = "";
}
if (code)
logit(LOG_CRIT, "fatal in %s: %s%s%s",
log_procname, s, sep, strerror(code));
else
logit(LOG_CRIT, "fatal in %s%s%s", log_procname, sep, s);
}
void
fatal(const char *emsg, ...)
{
va_list ap;
va_start(ap, emsg);
vfatalc(errno, emsg, ap);
va_end(ap);
exit(1);
}
void
fatalx(const char *emsg, ...)
{
va_list ap;
va_start(ap, emsg);
vfatalc(0, emsg, ap);
va_end(ap);
exit(1);
}

46
sbin/dhcp6leased/log.h Normal file
View File

@ -0,0 +1,46 @@
/* $OpenBSD: log.h,v 1.1 2024/06/02 12:28:05 florian Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef LOG_H
#define LOG_H
#include <stdarg.h>
#include <stdlib.h>
void log_init(int, int);
void log_procinit(const char *);
void log_setverbose(int);
int log_getverbose(void);
void log_warn(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
void log_warnx(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
void log_info(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
void log_debug(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
void logit(int, const char *, ...)
__attribute__((__format__ (printf, 2, 3)));
void vlog(int, const char *, va_list)
__attribute__((__format__ (printf, 2, 0)));
__dead void fatal(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
__dead void fatalx(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
#endif /* LOG_H */

922
sbin/dhcp6leased/parse.y Normal file
View File

@ -0,0 +1,922 @@
/* $OpenBSD: parse.y,v 1.6 2024/06/03 15:53:26 deraadt Exp $ */
/*
* Copyright (c) 2018, 2024 Florian Obser <florian@openbsd.org>
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
* Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org>
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
* Copyright (c) 2001 Markus Friedl. All rights reserved.
* Copyright (c) 2001 Daniel Hartmeier. All rights reserved.
* Copyright (c) 2001 Theo de Raadt. All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
%{
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <ctype.h>
#include <err.h>
#include <errno.h>
#include <event.h>
#include <imsg.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <vis.h>
#include "log.h"
#include "dhcp6leased.h"
#include "frontend.h"
TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files);
static struct file {
TAILQ_ENTRY(file) entry;
FILE *stream;
char *name;
size_t ungetpos;
size_t ungetsize;
u_char *ungetbuf;
int eof_reached;
int lineno;
int errors;
} *file, *topfile;
struct file *pushfile(const char *, int);
int popfile(void);
int check_file_secrecy(int, const char *);
int yyparse(void);
int yylex(void);
int yyerror(const char *, ...)
__attribute__((__format__ (printf, 1, 2)))
__attribute__((__nonnull__ (1)));
int kw_cmp(const void *, const void *);
int lookup(char *);
int igetc(void);
int lgetc(int);
void lungetc(int);
int findeol(void);
TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead);
struct sym {
TAILQ_ENTRY(sym) entry;
int used;
int persist;
char *nam;
char *val;
};
int symset(const char *, const char *, int);
char *symget(const char *);
static struct dhcp6leased_conf *conf;
static int errors;
static struct iface_conf *iface_conf;
static struct iface_ia_conf *iface_ia_conf;
struct iface_conf *conf_get_iface(char *);
struct iface_pd_conf *conf_get_pd_iface(char *, int);
void addressing_plan(struct iface_ia_conf *);
int fls64(uint64_t);
typedef struct {
union {
int64_t number;
char *string;
} v;
int lineno;
} YYSTYPE;
%}
%token ERROR DELEGATION FOR ON PREFIX REQUEST RAPID COMMIT
%token <v.string> STRING
%token <v.number> NUMBER
%type <v.string> string
%%
grammar : /* empty */
| grammar '\n'
| grammar varset '\n'
| grammar conf_main '\n'
| grammar ia_pd '\n'
| grammar error '\n' { file->errors++; }
;
string : string STRING {
if (asprintf(&$$, "%s %s", $1, $2) == -1) {
free($1);
free($2);
yyerror("string: asprintf");
YYERROR;
}
free($1);
free($2);
}
| STRING
;
varset : STRING '=' string {
char *s = $1;
if (log_getverbose() == 1)
printf("%s = \"%s\"\n", $1, $3);
while (*s++) {
if (isspace((unsigned char)*s)) {
yyerror("macro name cannot contain "
"whitespace");
free($1);
free($3);
YYERROR;
}
}
if (symset($1, $3, 0) == -1)
fatal("cannot store variable");
free($1);
free($3);
}
;
optnl : '\n' optnl /* zero or more newlines */
| /*empty*/
;
nl : '\n' optnl /* one or more newlines */
;
conf_main : REQUEST RAPID COMMIT {
conf->rapid_commit = 1;
}
;
ia_pd : REQUEST PREFIX DELEGATION ON STRING FOR {
iface_conf = conf_get_iface($5);
iface_ia_conf = calloc(1, sizeof(*iface_ia_conf));
if (iface_ia_conf == NULL)
err(1, "%s: calloc", __func__);
iface_ia_conf->id = ++iface_conf->ia_count;
if (iface_ia_conf->id > MAX_IA) {
yyerror("Too many prefix delegation requests");
YYERROR;
}
SIMPLEQ_INIT(&iface_ia_conf->iface_pd_list);
SIMPLEQ_INSERT_TAIL(&iface_conf->iface_ia_list,
iface_ia_conf, entry);
} '{' iface_block '}' {
iface_conf = NULL;
iface_ia_conf = NULL;
}
;
iface_block : optnl ifaceopts_l
| optnl
;
ifaceopts_l : ifaceopts_l ifaceoptsl nl
| ifaceoptsl optnl
;
ifaceoptsl : STRING {
struct iface_pd_conf *iface_pd_conf;
int prefixlen;
char *p;
const char *errstr;
p = strchr($1, '/');
if (p != NULL) {
*p++ = '\0';
prefixlen = strtonum(p, 0, 128, &errstr);
if (errstr != NULL) {
yyerror("error parsing interface "
"\"%s/%s\"", $1, p);
free($1);
YYERROR;
}
} else
prefixlen = 64;
if ((iface_pd_conf = conf_get_pd_iface($1, prefixlen))
== NULL) {
yyerror("duplicate interface %s", $1);
free($1);
YYERROR;
}
}
;
%%
struct keywords {
const char *k_name;
int k_val;
};
int
yyerror(const char *fmt, ...)
{
va_list ap;
char *msg;
file->errors++;
va_start(ap, fmt);
if (vasprintf(&msg, fmt, ap) == -1)
fatalx("yyerror vasprintf");
va_end(ap);
logit(LOG_CRIT, "%s:%d: %s", file->name, yylval.lineno, msg);
free(msg);
return (0);
}
int
kw_cmp(const void *k, const void *e)
{
return (strcmp(k, ((const struct keywords *)e)->k_name));
}
int
lookup(char *s)
{
/* This has to be sorted always. */
static const struct keywords keywords[] = {
{"commit", COMMIT},
{"delegation", DELEGATION},
{"for", FOR},
{"on", ON},
{"prefix", PREFIX},
{"rapid", RAPID},
{"request", REQUEST},
};
const struct keywords *p;
p = bsearch(s, keywords, sizeof(keywords)/sizeof(keywords[0]),
sizeof(keywords[0]), kw_cmp);
if (p)
return (p->k_val);
else
return (STRING);
}
#define START_EXPAND 1
#define DONE_EXPAND 2
static int expanding;
int
igetc(void)
{
int c;
while (1) {
if (file->ungetpos > 0)
c = file->ungetbuf[--file->ungetpos];
else
c = getc(file->stream);
if (c == START_EXPAND)
expanding = 1;
else if (c == DONE_EXPAND)
expanding = 0;
else
break;
}
return (c);
}
int
lgetc(int quotec)
{
int c, next;
if (quotec) {
if ((c = igetc()) == EOF) {
yyerror("reached end of file while parsing "
"quoted string");
if (file == topfile || popfile() == EOF)
return (EOF);
return (quotec);
}
return (c);
}
while ((c = igetc()) == '\\') {
next = igetc();
if (next != '\n') {
c = next;
break;
}
yylval.lineno = file->lineno;
file->lineno++;
}
if (c == EOF) {
/*
* Fake EOL when hit EOF for the first time. This gets line
* count right if last line in included file is syntactically
* invalid and has no newline.
*/
if (file->eof_reached == 0) {
file->eof_reached = 1;
return ('\n');
}
while (c == EOF) {
if (file == topfile || popfile() == EOF)
return (EOF);
c = igetc();
}
}
return (c);
}
void
lungetc(int c)
{
if (c == EOF)
return;
if (file->ungetpos >= file->ungetsize) {
void *p = reallocarray(file->ungetbuf, file->ungetsize, 2);
if (p == NULL)
err(1, "lungetc");
file->ungetbuf = p;
file->ungetsize *= 2;
}
file->ungetbuf[file->ungetpos++] = c;
}
int
findeol(void)
{
int c;
/* Skip to either EOF or the first real EOL. */
while (1) {
c = lgetc(0);
if (c == '\n') {
file->lineno++;
break;
}
if (c == EOF)
break;
}
return (ERROR);
}
int
yylex(void)
{
char buf[8096];
char *p, *val;
int quotec, next, c;
int token;
top:
p = buf;
while ((c = lgetc(0)) == ' ' || c == '\t')
; /* nothing */
yylval.lineno = file->lineno;
if (c == '#')
while ((c = lgetc(0)) != '\n' && c != EOF)
; /* nothing */
if (c == '$' && !expanding) {
while (1) {
if ((c = lgetc(0)) == EOF)
return (0);
if (p + 1 >= buf + sizeof(buf) - 1) {
yyerror("string too long");
return (findeol());
}
if (isalnum(c) || c == '_') {
*p++ = c;
continue;
}
*p = '\0';
lungetc(c);
break;
}
val = symget(buf);
if (val == NULL) {
yyerror("macro '%s' not defined", buf);
return (findeol());
}
p = val + strlen(val) - 1;
lungetc(DONE_EXPAND);
while (p >= val) {
lungetc((unsigned char)*p);
p--;
}
lungetc(START_EXPAND);
goto top;
}
switch (c) {
case '\'':
case '"':
quotec = c;
while (1) {
if ((c = lgetc(quotec)) == EOF)
return (0);
if (c == '\n') {
file->lineno++;
continue;
} else if (c == '\\') {
if ((next = lgetc(quotec)) == EOF)
return (0);
if (next == quotec || next == ' ' ||
next == '\t')
c = next;
else if (next == '\n') {
file->lineno++;
continue;
} else
lungetc(next);
} else if (c == quotec) {
*p = '\0';
break;
} else if (c == '\0') {
yyerror("syntax error");
return (findeol());
}
if (p + 1 >= buf + sizeof(buf) - 1) {
yyerror("string too long");
return (findeol());
}
*p++ = c;
}
yylval.v.string = strdup(buf);
if (yylval.v.string == NULL)
err(1, "yylex: strdup");
return (STRING);
}
#define allowed_to_end_number(x) \
(isspace(x) || x == ')' || x ==',' || x == '/' || x == '}' || x == '=')
if (c == '-' || isdigit(c)) {
do {
*p++ = c;
if ((size_t)(p-buf) >= sizeof(buf)) {
yyerror("string too long");
return (findeol());
}
} while ((c = lgetc(0)) != EOF && isdigit(c));
lungetc(c);
if (p == buf + 1 && buf[0] == '-')
goto nodigits;
if (c == EOF || allowed_to_end_number(c)) {
const char *errstr = NULL;
*p = '\0';
yylval.v.number = strtonum(buf, LLONG_MIN,
LLONG_MAX, &errstr);
if (errstr) {
yyerror("\"%s\" invalid number: %s",
buf, errstr);
return (findeol());
}
return (NUMBER);
} else {
nodigits:
while (p > buf + 1)
lungetc((unsigned char)*--p);
c = (unsigned char)*--p;
if (c == '-')
return (c);
}
}
#define allowed_in_string(x) \
(isalnum(x) || (ispunct(x) && x != '(' && x != ')' && \
x != '{' && x != '}' && \
x != '!' && x != '=' && x != '#' && \
x != ','))
if (isalnum(c) || c == ':' || c == '_') {
do {
*p++ = c;
if ((size_t)(p-buf) >= sizeof(buf)) {
yyerror("string too long");
return (findeol());
}
} while ((c = lgetc(0)) != EOF && (allowed_in_string(c)));
lungetc(c);
*p = '\0';
if ((token = lookup(buf)) == STRING)
if ((yylval.v.string = strdup(buf)) == NULL)
err(1, "yylex: strdup");
return (token);
}
if (c == '\n') {
yylval.lineno = file->lineno;
file->lineno++;
}
if (c == EOF)
return (0);
return (c);
}
int
check_file_secrecy(int fd, const char *fname)
{
struct stat st;
if (fstat(fd, &st)) {
log_warn("cannot stat %s", fname);
return (-1);
}
if (st.st_uid != 0 && st.st_uid != getuid()) {
log_warnx("%s: owner not root or current user", fname);
return (-1);
}
if (st.st_mode & (S_IWGRP | S_IXGRP | S_IRWXO)) {
log_warnx("%s: group writable or world read/writable", fname);
return (-1);
}
return (0);
}
struct file *
pushfile(const char *name, int secret)
{
struct file *nfile;
if ((nfile = calloc(1, sizeof(struct file))) == NULL) {
log_warn("calloc");
return (NULL);
}
if ((nfile->name = strdup(name)) == NULL) {
log_warn("strdup");
free(nfile);
return (NULL);
}
if ((nfile->stream = fopen(nfile->name, "r")) == NULL) {
free(nfile->name);
free(nfile);
return (NULL);
} else if (secret &&
check_file_secrecy(fileno(nfile->stream), nfile->name)) {
fclose(nfile->stream);
free(nfile->name);
free(nfile);
return (NULL);
}
nfile->lineno = TAILQ_EMPTY(&files) ? 1 : 0;
nfile->ungetsize = 16;
nfile->ungetbuf = malloc(nfile->ungetsize);
if (nfile->ungetbuf == NULL) {
log_warn("malloc");
fclose(nfile->stream);
free(nfile->name);
free(nfile);
return (NULL);
}
TAILQ_INSERT_TAIL(&files, nfile, entry);
return (nfile);
}
int
popfile(void)
{
struct file *prev;
if ((prev = TAILQ_PREV(file, files, entry)) != NULL)
prev->errors += file->errors;
TAILQ_REMOVE(&files, file, entry);
fclose(file->stream);
free(file->name);
free(file->ungetbuf);
free(file);
file = prev;
return (file ? 0 : EOF);
}
struct dhcp6leased_conf *
parse_config(const char *filename)
{
struct sym *sym, *next;
struct iface_conf *iface;
struct iface_ia_conf *ia_conf;
conf = config_new_empty();
file = pushfile(filename, 0);
if (file == NULL) {
free(conf);
return (NULL);
}
topfile = file;
yyparse();
errors = file->errors;
popfile();
/* Free macros and check which have not been used. */
TAILQ_FOREACH_SAFE(sym, &symhead, entry, next) {
if ((log_getverbose() == 2) && !sym->used)
fprintf(stderr, "warning: macro '%s' not used\n",
sym->nam);
if (!sym->persist) {
free(sym->nam);
free(sym->val);
TAILQ_REMOVE(&symhead, sym, entry);
free(sym);
}
}
if (errors) {
config_clear(conf);
return (NULL);
}
SIMPLEQ_FOREACH(iface, &conf->iface_list, entry) {
SIMPLEQ_FOREACH(ia_conf, &iface->iface_ia_list, entry) {
addressing_plan(ia_conf);
}
}
return (conf);
}
int
symset(const char *nam, const char *val, int persist)
{
struct sym *sym;
TAILQ_FOREACH(sym, &symhead, entry) {
if (strcmp(nam, sym->nam) == 0)
break;
}
if (sym != NULL) {
if (sym->persist == 1)
return (0);
else {
free(sym->nam);
free(sym->val);
TAILQ_REMOVE(&symhead, sym, entry);
free(sym);
}
}
if ((sym = calloc(1, sizeof(*sym))) == NULL)
return (-1);
sym->nam = strdup(nam);
if (sym->nam == NULL) {
free(sym);
return (-1);
}
sym->val = strdup(val);
if (sym->val == NULL) {
free(sym->nam);
free(sym);
return (-1);
}
sym->used = 0;
sym->persist = persist;
TAILQ_INSERT_TAIL(&symhead, sym, entry);
return (0);
}
int
cmdline_symset(char *s)
{
char *sym, *val;
int ret;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
sym = strndup(s, val - s);
if (sym == NULL)
errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
return (ret);
}
char *
symget(const char *nam)
{
struct sym *sym;
TAILQ_FOREACH(sym, &symhead, entry) {
if (strcmp(nam, sym->nam) == 0) {
sym->used = 1;
return (sym->val);
}
}
return (NULL);
}
struct iface_conf *
conf_get_iface(char *name)
{
struct iface_conf *iface;
size_t n;
SIMPLEQ_FOREACH(iface, &conf->iface_list, entry) {
if (strcmp(name, iface->name) == 0)
return (iface);
}
iface = calloc(1, sizeof(*iface));
if (iface == NULL)
errx(1, "%s: calloc", __func__);
n = strlcpy(iface->name, name, sizeof(iface->name));
if (n >= sizeof(iface->name))
errx(1, "%s: name too long", __func__);
SIMPLEQ_INIT(&iface->iface_ia_list);
SIMPLEQ_INSERT_TAIL(&conf->iface_list, iface, entry);
return (iface);
}
struct iface_pd_conf *
conf_get_pd_iface(char *name, int prefixlen)
{
struct iface_ia_conf *iface_ia;
struct iface_pd_conf *iface_pd;
size_t n;
if (strcmp(name, "reserve") != 0) {
SIMPLEQ_FOREACH(iface_ia, &iface_conf->iface_ia_list,
entry) {
SIMPLEQ_FOREACH(iface_pd, &iface_ia->iface_pd_list,
entry) {
if (strcmp(name, iface_pd->name) == 0)
return NULL;
}
}
}
iface_pd = calloc(1, sizeof(*iface_pd));
if (iface_pd == NULL)
err(1, "%s: calloc", __func__);
n = strlcpy(iface_pd->name, name, sizeof(iface_pd->name));
if (n >= sizeof(iface_pd->name))
errx(1, "%s: name too long", __func__);
iface_pd->prefix_len = prefixlen;
SIMPLEQ_INSERT_TAIL(&iface_ia_conf->iface_pd_list, iface_pd, entry);
return (iface_pd);
}
static inline uint64_t
get_shift(int plen)
{
if (plen > 64)
plen -= 64;
return 1ULL << (64 - plen);
}
void
addressing_plan(struct iface_ia_conf *ia_conf)
{
struct iface_pd_conf *pd_conf;
uint64_t *p, lo_counter, hi_counter, lo_shift, hi_shift;
int prev_plen = -1;
lo_counter = hi_counter = 0;
SIMPLEQ_FOREACH(pd_conf, &ia_conf->iface_pd_list, entry) {
/* not the first prefix */
if (ia_conf->prefix_len != 0) {
lo_shift = hi_shift = 0;
if (prev_plen > pd_conf->prefix_len) {
if (pd_conf->prefix_len > 64)
lo_shift =
get_shift(pd_conf->prefix_len);
else
hi_shift =
get_shift(pd_conf->prefix_len);
} else {
if (prev_plen > 64)
lo_shift = get_shift(prev_plen);
else
hi_shift = get_shift(prev_plen);
}
if (lo_shift != 0) {
if (lo_counter > UINT64_MAX - lo_shift) {
/* overflow */
hi_counter++;
lo_counter = 0;
} else {
lo_counter += lo_shift;
/* remove all lower bits */
lo_counter &= ~(lo_shift - 1);
}
} else {
hi_counter += hi_shift;
/* remove all lower bits */
hi_counter &= ~(hi_shift - 1);
lo_counter = 0;
}
} else
ia_conf->prefix_len = pd_conf->prefix_len;
p = (uint64_t *)&pd_conf->prefix_mask.s6_addr;
*p |= htobe64(hi_counter);
p = (uint64_t *)&pd_conf->prefix_mask.s6_addr[8];
*p |= htobe64(lo_counter);
prev_plen = pd_conf->prefix_len;
}
if (hi_counter != 0)
ia_conf->prefix_len = 64 - fls64(hi_counter);
else if (lo_counter != 0)
ia_conf->prefix_len = 128 - fls64(lo_counter);
}
/* from NetBSD's sys/sys/bitops.h */
/*-
* Copyright (c) 2007, 2010 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Christos Zoulas and Joerg Sonnenberger.
*
* 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.
*/
int
fls64(uint64_t _n)
{
int _v;
if (!_n)
return 0;
_v = 64;
if ((_n & 0xFFFFFFFF00000000ULL) == 0) {
_n <<= 32;
_v -= 32;
}
if ((_n & 0xFFFF000000000000ULL) == 0) {
_n <<= 16;
_v -= 16;
}
if ((_n & 0xFF00000000000000ULL) == 0) {
_n <<= 8;
_v -= 8;
}
if ((_n & 0xF000000000000000ULL) == 0) {
_n <<= 4;
_v -= 4;
}
if ((_n & 0xC000000000000000ULL) == 0) {
_n <<= 2;
_v -= 2;
}
if ((_n & 0x8000000000000000ULL) == 0) {
//_n <<= 1;
_v -= 1;
}
return _v;
}

View File

@ -0,0 +1,108 @@
/* $OpenBSD: printconf.c,v 1.3 2024/06/03 11:08:31 florian Exp $ */
/*
* Copyright (c) 2024 Florian Obser <florian@openbsd.org>
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/uio.h>
#include <net/if.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <event.h>
#include <imsg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dhcp6leased.h"
#include "log.h"
void print_iface_conf(struct iface_conf *, int);
void print_iface_ia_conf(struct iface_ia_conf *, int);
void print_iface_pd_conf(char *, struct iface_pd_conf *, int);
void
print_iface_pd_conf(char *indent, struct iface_pd_conf *pd_conf, int verbose)
{
if (verbose > 1) {
struct in6_addr ia6;
int i;
char ntopbuf[INET6_ADDRSTRLEN];
memset(&ia6, 0, sizeof(ia6));
inet_pton(AF_INET6, "2001:db8::", &ia6);
for (i = 0; i < 16; i++)
ia6.s6_addr[i] |= pd_conf->prefix_mask.s6_addr[i];
inet_ntop(AF_INET6, &ia6, ntopbuf, INET6_ADDRSTRLEN);
printf("%s%s/%d\t# %s/%d\n", indent, pd_conf->name,
pd_conf->prefix_len, ntopbuf, pd_conf->prefix_len);
} else
printf("%s%s/%d\n", indent, pd_conf->name, pd_conf->prefix_len);
}
void
print_iface_ia_conf(struct iface_ia_conf *ia_conf, int verbose)
{
struct iface_pd_conf *pd_conf;
SIMPLEQ_FOREACH(pd_conf, &ia_conf->iface_pd_list, entry)
print_iface_pd_conf("\t", pd_conf,
ia_conf->prefix_len >= 32 ? verbose : 1);
}
void
print_iface_conf(struct iface_conf *iface, int verbose)
{
struct iface_ia_conf *ia_conf;
int first = 1;
SIMPLEQ_FOREACH(ia_conf, &iface->iface_ia_list, entry) {
if (!first)
printf("\n");
first = 0;
if (verbose > 1) {
printf("request prefix delegation on %s for {"
"\t# prefix length = %d\n", iface->name,
ia_conf->prefix_len);
} else {
printf("request prefix delegation on %s for {\n",
iface->name);
}
print_iface_ia_conf(ia_conf, verbose);
printf("}\n");
}
}
void
print_config(struct dhcp6leased_conf *conf, int verbose)
{
struct iface_conf *iface;
if (conf->rapid_commit)
printf("request rapid commit\n\n");
SIMPLEQ_FOREACH(iface, &conf->iface_list, entry)
print_iface_conf(iface, verbose);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: engine.c,v 1.43 2024/02/13 12:53:05 florian Exp $ */
/* $OpenBSD: engine.c,v 1.44 2024/06/02 12:39:26 florian Exp $ */
/*
* Copyright (c) 2017, 2021 Florian Obser <florian@openbsd.org>
@ -1544,7 +1544,7 @@ iface_timeout(int fd, short events, void *arg)
timespecsub(&now, &iface->request_time, &res);
log_debug("%s: res.tv_sec: %lld, rebinding_time: %u", __func__,
res.tv_sec, iface->rebinding_time);
if (res.tv_sec > iface->rebinding_time)
if (res.tv_sec >= iface->rebinding_time)
state_transition(iface, IF_REBINDING);
else
state_transition(iface, IF_RENEWING);

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: clang-local.1,v 1.23 2022/02/18 00:39:18 jca Exp $
.\" $OpenBSD: clang-local.1,v 1.24 2024/06/02 15:40:43 deraadt Exp $
.\"
.\" Copyright (c) 2016 Pascal Stumpf <pascal@stumpf.co>
.\"
@ -15,7 +15,7 @@
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\"
.Dd $Mdocdate: February 18 2022 $
.Dd $Mdocdate: June 2 2024 $
.Dt CLANG-LOCAL 1
.Os
.Sh NAME
@ -119,6 +119,13 @@ This can be disabled with the
option.
.It
.Nm clang
includes a security pass that can clear the return address on the
stack upon return from calling a function, on i386 and amd64.
This can be enabled with the
.Fl fret-clean
option.
.It
.Nm clang
includes the retguard security feature on amd64, arm64, mips64, powerpc
and powerpc64.
This feature can be disabled with the

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: qwx.4,v 1.5 2024/05/29 09:04:12 stsp Exp $
.\" $OpenBSD: qwx.4,v 1.6 2024/06/03 14:59:22 jsg Exp $
.\"
.\" Copyright (c) 2022 Martin Pieuchot <mpi@openbsd.org>
.\" Copyright (c) 2024 Stefan Sperling <stsp@openbsd.org>
@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: May 29 2024 $
.Dd $Mdocdate: June 3 2024 $
.Dt QWX 4
.Os
.Sh NAME
@ -96,5 +96,5 @@ capabilities offered by the hardware.
.Sh BUGS
Broadcast and Multicast frames are only received on networks which
do not use encryption or which use WPA2 with group cipher CCMP.
This prevents ARP and IPv6 from working correcly on other types of
This prevents ARP and IPv6 from working correctly on other types of
networks.

View File

@ -1,4 +1,4 @@
/* $OpenBSD: acpi.c,v 1.429 2024/05/29 12:21:33 kettenis Exp $ */
/* $OpenBSD: acpi.c,v 1.430 2024/06/02 11:08:41 kettenis Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@ -611,6 +611,10 @@ acpi_getpci(struct aml_node *node, void *arg)
aml_nodename(node));
/* Collect device power state information. */
if (aml_evalinteger(sc, node, "_S0W", 0, NULL, &val) == 0)
pci->_s0w = val;
else
pci->_s0w = -1;
if (aml_evalinteger(sc, node, "_S3D", 0, NULL, &val) == 0)
pci->_s3d = val;
else
@ -721,6 +725,10 @@ acpi_pci_min_powerstate(pci_chipset_tag_t pc, pcitag_t tag)
TAILQ_FOREACH(pdev, &acpi_pcidevs, next) {
if (pdev->bus == bus && pdev->dev == dev && pdev->fun == fun) {
switch (acpi_softc->sc_state) {
case ACPI_STATE_S0:
defaultstate = PCI_PMCSR_STATE_D3;
state = pdev->_s0w;
break;
case ACPI_STATE_S3:
defaultstate = PCI_PMCSR_STATE_D3;
state = MAX(pdev->_s3d, pdev->_s3w);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: amltypes.h,v 1.49 2022/09/12 17:42:31 kettenis Exp $ */
/* $OpenBSD: amltypes.h,v 1.50 2024/06/02 11:08:41 kettenis Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
*
@ -358,6 +358,7 @@ struct acpi_pci {
int dev;
int fun;
int _s0w;
int _s3d;
int _s3w;
int _s4d;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: nvme.c,v 1.115 2024/05/28 00:24:44 jsg Exp $ */
/* $OpenBSD: nvme.c,v 1.116 2024/06/03 12:01:57 mglocker Exp $ */
/*
* Copyright (c) 2014 David Gwynne <dlg@openbsd.org>
@ -1742,8 +1742,6 @@ nvme_hibernate_io(dev_t dev, daddr_t blkno, vaddr_t addr, size_t size,
my->cq_head = 0;
my->cqe_phase = NVME_CQE_PHASE;
pmap_extract(pmap_kernel(), (vaddr_t)page, &page_phys);
memset(&qsqe, 0, sizeof(qsqe));
qsqe.opcode = NVM_ADMIN_ADD_IOCQ;
htolem64(&qsqe.prp1,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: drm_linux.c,v 1.112 2024/03/30 13:33:20 mpi Exp $ */
/* $OpenBSD: drm_linux.c,v 1.113 2024/06/03 12:48:25 claudio Exp $ */
/*
* Copyright (c) 2013 Jonathan Gray <jsg@openbsd.org>
* Copyright (c) 2015, 2016 Mark Kettenis <kettenis@openbsd.org>
@ -114,14 +114,13 @@ void
__set_current_state(int state)
{
struct proc *p = curproc;
int s;
KASSERT(state == TASK_RUNNING);
SCHED_LOCK(s);
SCHED_LOCK();
unsleep(p);
p->p_stat = SONPROC;
atomic_clearbits_int(&p->p_flag, P_WSLEEP);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
void
@ -159,11 +158,11 @@ schedule_timeout_uninterruptible(long timeout)
int
wake_up_process(struct proc *p)
{
int s, rv;
int rv;
SCHED_LOCK(s);
SCHED_LOCK();
rv = wakeup_proc(p, 0);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
return rv;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_exit.c,v 1.221 2024/05/20 10:32:20 claudio Exp $ */
/* $OpenBSD: kern_exit.c,v 1.222 2024/06/03 12:48:25 claudio Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
@ -119,7 +119,6 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
struct process *pr, *qr, *nqr;
struct rusage *rup;
struct timespec ts;
int s;
atomic_setbits_int(&p->p_flag, P_WEXIT);
@ -329,9 +328,9 @@ exit1(struct proc *p, int xexit, int xsig, int flags)
timespecclear(&ts);
else
timespecsub(&ts, &curcpu()->ci_schedstate.spc_runtime, &ts);
SCHED_LOCK(s);
SCHED_LOCK();
tuagg_locked(pr, p, &ts);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
/*
* clear %cpu usage during swap

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_fork.c,v 1.259 2024/05/29 18:55:45 claudio Exp $ */
/* $OpenBSD: kern_fork.c,v 1.260 2024/06/03 12:48:25 claudio Exp $ */
/* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */
/*
@ -329,14 +329,13 @@ static inline void
fork_thread_start(struct proc *p, struct proc *parent, int flags)
{
struct cpu_info *ci;
int s;
SCHED_LOCK(s);
SCHED_LOCK();
ci = sched_choosecpu_fork(parent, flags);
TRACEPOINT(sched, fork, p->p_tid + THREAD_PID_OFFSET,
p->p_p->ps_pid, CPU_INFO_UNIT(ci));
setrunqueue(ci, p, p->p_usrpri);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
int

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_pledge.c,v 1.314 2024/05/18 05:20:22 guenther Exp $ */
/* $OpenBSD: kern_pledge.c,v 1.316 2024/06/03 03:41:47 deraadt Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@ -574,7 +574,7 @@ pledge_fail(struct proc *p, int error, uint64_t code)
return (ENOSYS);
KERNEL_LOCK();
log(LOG_ERR, "%s[%d]: pledge \"%s\", syscall %d\n",
uprintf("%s[%d]: pledge \"%s\", syscall %d\n",
p->p_p->ps_comm, p->p_p->ps_pid, codes, p->p_pledge_syscall);
p->p_p->ps_acflag |= APLEDGE;
@ -1002,10 +1002,10 @@ pledge_sysctl(struct proc *p, int miblen, int *mib, void *new)
snprintf(buf, sizeof(buf), "%s(%d): pledge sysctl %d:",
p->p_p->ps_comm, p->p_p->ps_pid, miblen);
for (i = 0; i < miblen; i++) {
char *p = buf + strlen(buf);
snprintf(p, sizeof(buf) - (p - buf), " %d", mib[i]);
char *s = buf + strlen(buf);
snprintf(s, sizeof(buf) - (s - buf), " %d", mib[i]);
}
log(LOG_ERR, "%s\n", buf);
uprintf("%s\n", buf);
return pledge_fail(p, EINVAL, 0);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_resource.c,v 1.83 2024/05/22 09:20:22 claudio Exp $ */
/* $OpenBSD: kern_resource.c,v 1.84 2024/06/03 12:48:25 claudio Exp $ */
/* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */
/*-
@ -198,7 +198,6 @@ donice(struct proc *curp, struct process *chgpr, int n)
{
struct ucred *ucred = curp->p_ucred;
struct proc *p;
int s;
if (ucred->cr_uid != 0 && ucred->cr_ruid != 0 &&
ucred->cr_uid != chgpr->ps_ucred->cr_uid &&
@ -213,11 +212,11 @@ donice(struct proc *curp, struct process *chgpr, int n)
return (EACCES);
chgpr->ps_nice = n;
mtx_enter(&chgpr->ps_mtx);
SCHED_LOCK(s);
SCHED_LOCK();
TAILQ_FOREACH(p, &chgpr->ps_threads, p_thr_link) {
setpriority(p, p->p_estcpu, n);
}
SCHED_UNLOCK(s);
SCHED_UNLOCK();
mtx_leave(&chgpr->ps_mtx);
return (0);
}
@ -396,11 +395,9 @@ tuagg_locked(struct process *pr, struct proc *p, const struct timespec *ts)
void
tuagg(struct process *pr, struct proc *p)
{
int s;
SCHED_LOCK(s);
SCHED_LOCK();
tuagg_locked(pr, p, NULL);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
/*
@ -537,13 +534,12 @@ rucheck(void *arg)
struct rlimit rlim;
struct process *pr = arg;
time_t runtime;
int s;
KERNEL_ASSERT_LOCKED();
SCHED_LOCK(s);
SCHED_LOCK();
runtime = pr->ps_tu.tu_runtime.tv_sec;
SCHED_UNLOCK(s);
SCHED_UNLOCK();
mtx_enter(&pr->ps_mtx);
rlim = pr->ps_limit->pl_rlimit[RLIMIT_CPU];

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_sched.c,v 1.95 2024/02/28 13:43:44 mpi Exp $ */
/* $OpenBSD: kern_sched.c,v 1.96 2024/06/03 12:48:25 claudio Exp $ */
/*
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
*
@ -137,7 +137,6 @@ sched_idle(void *v)
struct schedstate_percpu *spc;
struct proc *p = curproc;
struct cpu_info *ci = v;
int s;
KERNEL_UNLOCK();
@ -147,14 +146,14 @@ sched_idle(void *v)
* First time we enter here, we're not supposed to idle,
* just go away for a while.
*/
SCHED_LOCK(s);
SCHED_LOCK();
cpuset_add(&sched_idle_cpus, ci);
p->p_stat = SSLEEP;
p->p_cpu = ci;
atomic_setbits_int(&p->p_flag, P_CPUPEG);
mi_switch();
cpuset_del(&sched_idle_cpus, ci);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
KASSERT(ci == curcpu());
KASSERT(curproc == spc->spc_idleproc);
@ -163,10 +162,10 @@ sched_idle(void *v)
while (!cpu_is_idle(curcpu())) {
struct proc *dead;
SCHED_LOCK(s);
SCHED_LOCK();
p->p_stat = SSLEEP;
mi_switch();
SCHED_UNLOCK(s);
SCHED_UNLOCK();
while ((dead = LIST_FIRST(&spc->spc_deadproc))) {
LIST_REMOVE(dead, p_hash);
@ -185,10 +184,10 @@ sched_idle(void *v)
if (spc->spc_schedflags & SPCF_SHOULDHALT &&
(spc->spc_schedflags & SPCF_HALTED) == 0) {
cpuset_del(&sched_idle_cpus, ci);
SCHED_LOCK(s);
SCHED_LOCK();
atomic_setbits_int(&spc->spc_schedflags,
spc->spc_whichqs ? 0 : SPCF_HALTED);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
wakeup(spc);
}
#endif
@ -226,7 +225,6 @@ sched_toidle(void)
{
struct schedstate_percpu *spc = &curcpu()->ci_schedstate;
struct proc *idle;
int s;
#ifdef MULTIPROCESSOR
/* This process no longer needs to hold the kernel lock. */
@ -245,8 +243,7 @@ sched_toidle(void)
atomic_clearbits_int(&spc->spc_schedflags, SPCF_SWITCHCLEAR);
SCHED_LOCK(s);
SCHED_LOCK();
idle = spc->spc_idleproc;
idle->p_stat = SRUN;
@ -627,14 +624,13 @@ void
sched_peg_curproc(struct cpu_info *ci)
{
struct proc *p = curproc;
int s;
SCHED_LOCK(s);
SCHED_LOCK();
atomic_setbits_int(&p->p_flag, P_CPUPEG);
setrunqueue(ci, p, p->p_usrpri);
p->p_ru.ru_nvcsw++;
mi_switch();
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
#ifdef MULTIPROCESSOR

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_sig.c,v 1.329 2024/05/22 09:22:55 claudio Exp $ */
/* $OpenBSD: kern_sig.c,v 1.330 2024/06/03 12:48:25 claudio Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@ -843,14 +843,12 @@ trapsignal(struct proc *p, int signum, u_long trapno, int code,
*/
if (((pr->ps_flags & (PS_TRACED | PS_PPWAIT)) == PS_TRACED) &&
signum != SIGKILL && (p->p_sigmask & mask) != 0) {
int s;
single_thread_set(p, SINGLE_SUSPEND | SINGLE_NOWAIT);
pr->ps_xsig = signum;
SCHED_LOCK(s);
SCHED_LOCK();
proc_stop(p, 1);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
signum = pr->ps_xsig;
single_thread_clear(p, 0);
@ -920,7 +918,7 @@ psignal(struct proc *p, int signum)
void
ptsignal(struct proc *p, int signum, enum signal_type type)
{
int s, prop;
int prop;
sig_t action, altaction = SIG_DFL;
sigset_t mask, sigmask;
int *siglist;
@ -1063,7 +1061,7 @@ ptsignal(struct proc *p, int signum, enum signal_type type)
if (q != p)
ptsignal(q, signum, SPROPAGATED);
SCHED_LOCK(s);
SCHED_LOCK();
switch (p->p_stat) {
@ -1252,7 +1250,7 @@ out:
atomic_clearbits_int(&p->p_flag, P_CONTINUED);
}
SCHED_UNLOCK(s);
SCHED_UNLOCK();
if (wakeparent)
wakeup(pr->ps_pptr);
}
@ -1299,7 +1297,6 @@ cursig(struct proc *p, struct sigctx *sctx)
struct process *pr = p->p_p;
int signum, mask, prop;
sigset_t ps_siglist;
int s;
KASSERT(p == curproc);
@ -1340,9 +1337,9 @@ cursig(struct proc *p, struct sigctx *sctx)
single_thread_set(p, SINGLE_SUSPEND | SINGLE_NOWAIT);
pr->ps_xsig = signum;
SCHED_LOCK(s);
SCHED_LOCK();
proc_stop(p, 1);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
/*
* re-take the signal before releasing
@ -1415,9 +1412,9 @@ cursig(struct proc *p, struct sigctx *sctx)
prop & SA_TTYSTOP))
break; /* == ignore */
pr->ps_xsig = signum;
SCHED_LOCK(s);
SCHED_LOCK();
proc_stop(p, 1);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
break;
} else if (prop & SA_IGNORE) {
/*
@ -2064,7 +2061,6 @@ int
single_thread_check_locked(struct proc *p, int deep)
{
struct process *pr = p->p_p;
int s;
MUTEX_ASSERT_LOCKED(&pr->ps_mtx);
@ -2093,10 +2089,10 @@ single_thread_check_locked(struct proc *p, int deep)
/* not exiting and don't need to unwind, so suspend */
mtx_leave(&pr->ps_mtx);
SCHED_LOCK(s);
SCHED_LOCK();
p->p_stat = SSTOP;
mi_switch();
SCHED_UNLOCK(s);
SCHED_UNLOCK();
mtx_enter(&pr->ps_mtx);
} while (pr->ps_single != NULL);
@ -2129,7 +2125,7 @@ single_thread_set(struct proc *p, int flags)
{
struct process *pr = p->p_p;
struct proc *q;
int error, s, mode = flags & SINGLE_MASK;
int error, mode = flags & SINGLE_MASK;
KASSERT(curproc == p);
@ -2161,7 +2157,7 @@ single_thread_set(struct proc *p, int flags)
TAILQ_FOREACH(q, &pr->ps_threads, p_thr_link) {
if (q == p)
continue;
SCHED_LOCK(s);
SCHED_LOCK();
atomic_setbits_int(&q->p_flag, P_SUSPSINGLE);
switch (q->p_stat) {
case SIDL:
@ -2194,7 +2190,7 @@ single_thread_set(struct proc *p, int flags)
case SRUN:
break;
}
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
/* count ourselfs out */
@ -2235,7 +2231,6 @@ single_thread_clear(struct proc *p, int flag)
{
struct process *pr = p->p_p;
struct proc *q;
int s;
KASSERT(pr->ps_single == p);
KASSERT(curproc == p);
@ -2254,7 +2249,7 @@ single_thread_clear(struct proc *p, int flag)
* then clearing that either makes it runnable or puts
* it back into some sleep queue
*/
SCHED_LOCK(s);
SCHED_LOCK();
if (q->p_stat == SSTOP && (q->p_flag & flag) == 0) {
if (q->p_wchan == NULL)
setrunnable(q);
@ -2263,7 +2258,7 @@ single_thread_clear(struct proc *p, int flag)
q->p_stat = SSLEEP;
}
}
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
mtx_leave(&pr->ps_mtx);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: kern_synch.c,v 1.204 2024/05/22 09:24:11 claudio Exp $ */
/* $OpenBSD: kern_synch.c,v 1.205 2024/06/03 12:48:25 claudio Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*
@ -332,7 +332,6 @@ void
sleep_setup(const volatile void *ident, int prio, const char *wmesg)
{
struct proc *p = curproc;
int s;
#ifdef DIAGNOSTIC
if (p->p_flag & P_CANTSLEEP)
@ -346,7 +345,7 @@ sleep_setup(const volatile void *ident, int prio, const char *wmesg)
if (p->p_flag & P_WEXIT)
CLR(prio, PCATCH);
SCHED_LOCK(s);
SCHED_LOCK();
TRACEPOINT(sched, sleep, NULL);
@ -360,14 +359,14 @@ sleep_setup(const volatile void *ident, int prio, const char *wmesg)
atomic_setbits_int(&p->p_flag, P_SINTR);
p->p_stat = SSLEEP;
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
int
sleep_finish(int timo, int do_sleep)
{
struct proc *p = curproc;
int s, catch, error = 0, error1 = 0;
int catch, error = 0, error1 = 0;
catch = p->p_flag & P_SINTR;
@ -392,7 +391,7 @@ sleep_finish(int timo, int do_sleep)
}
}
SCHED_LOCK(s);
SCHED_LOCK();
/*
* If the wakeup happens while going to sleep, p->p_wchan
* will be NULL. In that case unwind immediately but still
@ -419,7 +418,7 @@ sleep_finish(int timo, int do_sleep)
#endif
p->p_cpu->ci_schedstate.spc_curpriority = p->p_usrpri;
SCHED_UNLOCK(s);
SCHED_UNLOCK();
/*
* Even though this belongs to the signal handling part of sleep,
@ -503,11 +502,10 @@ void
endtsleep(void *arg)
{
struct proc *p = arg;
int s;
SCHED_LOCK(s);
SCHED_LOCK();
wakeup_proc(p, P_TIMEOUT);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
/*
@ -536,11 +534,10 @@ wakeup_n(const volatile void *ident, int n)
struct slpque *qp, wakeq;
struct proc *p;
struct proc *pnext;
int s;
TAILQ_INIT(&wakeq);
SCHED_LOCK(s);
SCHED_LOCK();
qp = &slpque[LOOKUP(ident)];
for (p = TAILQ_FIRST(qp); p != NULL && n != 0; p = pnext) {
pnext = TAILQ_NEXT(p, p_runq);
@ -564,7 +561,7 @@ wakeup_n(const volatile void *ident, int n)
if (p->p_stat == SSLEEP)
setrunnable(p);
}
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
/*
@ -581,7 +578,6 @@ sys_sched_yield(struct proc *p, void *v, register_t *retval)
{
struct proc *q;
uint8_t newprio;
int s;
/*
* If one of the threads of a multi-threaded process called
@ -594,11 +590,11 @@ sys_sched_yield(struct proc *p, void *v, register_t *retval)
newprio = max(newprio, q->p_runpri);
mtx_leave(&p->p_p->ps_mtx);
SCHED_LOCK(s);
SCHED_LOCK();
setrunqueue(p->p_cpu, p, newprio);
p->p_ru.ru_nvcsw++;
mi_switch();
SCHED_UNLOCK(s);
SCHED_UNLOCK();
return (0);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sched_bsd.c,v 1.92 2024/05/29 18:55:45 claudio Exp $ */
/* $OpenBSD: sched_bsd.c,v 1.93 2024/06/03 12:48:25 claudio Exp $ */
/* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */
/*-
@ -230,7 +230,6 @@ schedcpu(void *unused)
static struct timeout to = TIMEOUT_INITIALIZER(schedcpu, NULL);
fixpt_t loadfac = loadfactor(averunnable.ldavg[0]);
struct proc *p;
int s;
unsigned int newcpu;
LIST_FOREACH(p, &allproc, p_list) {
@ -253,7 +252,7 @@ schedcpu(void *unused)
*/
if (p->p_slptime > 1)
continue;
SCHED_LOCK(s);
SCHED_LOCK();
/*
* p_pctcpu is only for diagnostic tools such as ps.
*/
@ -275,7 +274,7 @@ schedcpu(void *unused)
remrunqueue(p);
setrunqueue(p->p_cpu, p, p->p_usrpri);
}
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
wakeup(&lbolt);
timeout_add_sec(&to, 1);
@ -313,13 +312,12 @@ void
yield(void)
{
struct proc *p = curproc;
int s;
SCHED_LOCK(s);
SCHED_LOCK();
setrunqueue(p->p_cpu, p, p->p_usrpri);
p->p_ru.ru_nvcsw++;
mi_switch();
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
/*
@ -332,13 +330,12 @@ void
preempt(void)
{
struct proc *p = curproc;
int s;
SCHED_LOCK(s);
SCHED_LOCK();
setrunqueue(p->p_cpu, p, p->p_usrpri);
p->p_ru.ru_nivcsw++;
mi_switch();
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
void
@ -349,7 +346,7 @@ mi_switch(void)
struct proc *nextproc;
struct process *pr = p->p_p;
struct timespec ts;
int oldipl, s;
int oldipl;
#ifdef MULTIPROCESSOR
int hold_count;
#endif
@ -427,7 +424,7 @@ mi_switch(void)
/* Restore proc's IPL. */
MUTEX_OLDIPL(&sched_lock) = oldipl;
SCHED_UNLOCK(s);
SCHED_UNLOCK();
SCHED_ASSERT_UNLOCKED();
@ -463,7 +460,7 @@ mi_switch(void)
if (hold_count)
__mp_acquire_count(&kernel_lock, hold_count);
#endif
SCHED_LOCK(s);
SCHED_LOCK();
}
/*
@ -551,15 +548,14 @@ schedclock(struct proc *p)
struct cpu_info *ci = curcpu();
struct schedstate_percpu *spc = &ci->ci_schedstate;
uint32_t newcpu;
int s;
if (p == spc->spc_idleproc || spc->spc_spinning)
return;
SCHED_LOCK(s);
SCHED_LOCK();
newcpu = ESTCPULIM(p->p_estcpu + 1);
setpriority(p, newcpu, p->p_p->ps_nice);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
}
void (*cpu_setperf)(int);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: subr_witness.c,v 1.52 2024/05/03 13:47:31 visa Exp $ */
/* $OpenBSD: subr_witness.c,v 1.53 2024/06/03 14:34:19 claudio Exp $ */
/*-
* Copyright (c) 2008 Isilon Systems, Inc.
@ -438,11 +438,6 @@ static struct lock_class lock_class_kernel_lock = {
.lc_flags = LC_SLEEPLOCK | LC_RECURSABLE | LC_SLEEPABLE
};
static struct lock_class lock_class_sched_lock = {
.lc_name = "sched_lock",
.lc_flags = LC_SPINLOCK | LC_RECURSABLE
};
static struct lock_class lock_class_mutex = {
.lc_name = "mutex",
.lc_flags = LC_SPINLOCK
@ -461,7 +456,6 @@ static struct lock_class lock_class_rrwlock = {
static struct lock_class *lock_classes[] = {
&lock_class_kernel_lock,
&lock_class_sched_lock,
&lock_class_mutex,
&lock_class_rwlock,
&lock_class_rrwlock,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sys_process.c,v 1.97 2024/04/02 08:27:22 deraadt Exp $ */
/* $OpenBSD: sys_process.c,v 1.98 2024/06/03 12:48:25 claudio Exp $ */
/* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */
/*-
@ -283,7 +283,6 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data)
struct proc *t; /* target thread */
struct process *tr; /* target process */
int error = 0;
int s;
switch (req) {
case PT_TRACE_ME:
@ -492,10 +491,10 @@ ptrace_ctrl(struct proc *p, int req, pid_t pid, caddr_t addr, int data)
/* Finally, deliver the requested signal (or none). */
if (t->p_stat == SSTOP) {
tr->ps_xsig = data;
SCHED_LOCK(s);
SCHED_LOCK();
unsleep(t);
setrunnable(t);
SCHED_UNLOCK(s);
SCHED_UNLOCK();
} else {
if (data != 0)
psignal(t, data);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: _lock.h,v 1.4 2019/04/23 13:35:12 visa Exp $ */
/* $OpenBSD: _lock.h,v 1.5 2024/06/03 12:46:59 claudio Exp $ */
/*-
* Copyright (c) 1997 Berkeley Software Design, Inc. All rights reserved.
@ -50,7 +50,6 @@
enum lock_class_index {
LO_CLASS_KERNEL_LOCK,
LO_CLASS_SCHED_LOCK,
LO_CLASS_MUTEX,
LO_CLASS_RWLOCK,
LO_CLASS_RRWLOCK

View File

@ -1,4 +1,4 @@
/* $OpenBSD: sched.h,v 1.71 2024/05/29 18:55:45 claudio Exp $ */
/* $OpenBSD: sched.h,v 1.72 2024/06/03 12:48:25 claudio Exp $ */
/* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */
/*-
@ -201,28 +201,12 @@ void remrunqueue(struct proc *);
extern struct mutex sched_lock;
#define SCHED_ASSERT_LOCKED() \
do { \
MUTEX_ASSERT_LOCKED(&sched_lock); \
} while (0)
#define SCHED_ASSERT_UNLOCKED() \
do { \
MUTEX_ASSERT_UNLOCKED(&sched_lock); \
} while (0)
#define SCHED_ASSERT_LOCKED() MUTEX_ASSERT_LOCKED(&sched_lock)
#define SCHED_ASSERT_UNLOCKED() MUTEX_ASSERT_UNLOCKED(&sched_lock)
#define SCHED_LOCK_INIT() mtx_init(&sched_lock, IPL_SCHED)
#define SCHED_LOCK(s) \
do { \
(s) = 0; /* XXX cleanup useless argument */ \
mtx_enter(&sched_lock); \
} while (/* CONSTCOND */ 0)
#define SCHED_UNLOCK(s) \
do { \
(void)s; /* XXX cleanup useless argument */ \
mtx_leave(&sched_lock); \
} while (/* CONSTCOND */ 0)
#define SCHED_LOCK() mtx_enter(&sched_lock)
#define SCHED_UNLOCK() mtx_leave(&sched_lock)
#endif /* _KERNEL */
#endif /* _SYS_SCHED_H_ */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: syscall_mi.h,v 1.33 2024/04/01 12:00:15 deraadt Exp $ */
/* $OpenBSD: syscall_mi.h,v 1.34 2024/06/02 15:31:57 deraadt Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@ -105,9 +105,8 @@ die:
ktrpinsyscall(p, error, code, addr);
#endif
KERNEL_LOCK();
/* XXX remove or simplify this log() call after SecBSD 1.5 release */
log(LOG_ERR,
"%s[%d]: pinsyscalls addr %lx code %ld, pinoff 0x%x "
/* XXX remove or simplify this uprintf() call after OpenBSD 7.5 release */
uprintf("%s[%d]: pinsyscalls addr %lx code %ld, pinoff 0x%x "
"(pin%s %d %lx-%lx %lx) (libcpin%s %d %lx-%lx %lx) error %d\n",
p->p_p->ps_comm, p->p_p->ps_pid, addr, code,
(pin && code < pin->pn_npins) ? pin->pn_pins[code] : -1,

View File

@ -1,4 +1,4 @@
/* $OpenBSD: uvm_map.c,v 1.328 2024/04/02 08:39:17 deraadt Exp $ */
/* $OpenBSD: uvm_map.c,v 1.329 2024/06/02 15:31:57 deraadt Exp $ */
/* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */
/*
@ -1659,7 +1659,7 @@ uvm_map_inentry(struct proc *p, struct p_inentry *ie, vaddr_t addr,
ok = uvm_map_inentry_fix(p, ie, addr, fn, serial);
if (!ok) {
KERNEL_LOCK();
printf(fmt, p->p_p->ps_comm, p->p_p->ps_pid, p->p_tid,
uprintf(fmt, p->p_p->ps_comm, p->p_p->ps_pid, p->p_tid,
addr, ie->ie_start, ie->ie_end-1);
p->p_p->ps_acflag |= AMAP;
sv.sival_ptr = (void *)PROC_PC(p);
@ -1685,11 +1685,8 @@ uvm_map_is_stack_remappable(struct vm_map *map, vaddr_t addr, vaddr_t sz,
vm_map_assert_anylock(map);
if (!uvm_map_lookup_entry(map, addr, &first)) {
printf("map stack 0x%lx-0x%lx of map %p failed: no mapping\n",
addr, end, map);
if (!uvm_map_lookup_entry(map, addr, &first))
return FALSE;
}
/*
* Check that the address range exists and is contiguous.
@ -1707,16 +1704,10 @@ uvm_map_is_stack_remappable(struct vm_map *map, vaddr_t addr, vaddr_t sz,
}
#endif
if (prev != NULL && prev->end != iter->start) {
printf("map stack 0x%lx-0x%lx of map %p failed: "
"hole in range\n", addr, end, map);
if (prev != NULL && prev->end != iter->start)
return FALSE;
}
if (iter->start == iter->end || UVM_ET_ISHOLE(iter)) {
printf("map stack 0x%lx-0x%lx of map %p failed: "
"hole in range\n", addr, end, map);
if (iter->start == iter->end || UVM_ET_ISHOLE(iter))
return FALSE;
}
if (sigaltstack_check) {
if (iter->protection != (PROT_READ | PROT_WRITE))
return FALSE;
@ -1740,7 +1731,6 @@ uvm_map_remap_as_stack(struct proc *p, vaddr_t addr, vaddr_t sz)
{
vm_map_t map = &p->p_vmspace->vm_map;
vaddr_t start, end;
int error;
int flags = UVM_MAPFLAG(PROT_READ | PROT_WRITE,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_INHERIT_COPY, MADV_NORMAL,
@ -1767,11 +1757,7 @@ uvm_map_remap_as_stack(struct proc *p, vaddr_t addr, vaddr_t sz)
* placed upon the region, which prevents an attacker from pivoting
* into pre-placed MAP_STACK space.
*/
error = uvm_mapanon(map, &start, end - start, 0, flags);
if (error != 0)
printf("map stack for pid %d failed\n", p->p_p->ps_pid);
return error;
return uvm_mapanon(map, &start, end - start, 0, flags);
}
/*

View File

@ -25,6 +25,10 @@ THIS SOFTWARE.
This file lists all bug fixes, changes, etc., made since the
second edition of the AWK book was published in September 2023.
May 27, 2024
Spelling fixes and removal of unneeded prototypes and extern.
Thanks to Jonathan Gray.
May 4, 2024
Fixed a use-after-free bug with ARGV for "delete ARGV".
Also ENVtab is no longer global. Thanks to Benjamin Sturz

View File

@ -224,7 +224,7 @@ January 9, 2020:
mere warnings. Thanks to Martijn Dekker <martijn@inlv.org>.
January 5, 2020:
Fix a bug in the concatentation of two string constants into
Fix a bug in the concatenation of two string constants into
one done in the grammar. Fixes GitHub issue #61. Thanks
to GitHub user awkfan77 for pointing out the direction for
the fix. New test T.concat added to the test suite.
@ -866,7 +866,7 @@ Jan 13, 1999:
added a few (int) casts to silence useless compiler warnings.
e.g., errorflag= in run.c jump().
added proctab.c to the bundle outout; one less thing
added proctab.c to the bundle output; one less thing
to have to compile out of the box.
added calls to _popen and _pclose to the win95 stub for

View File

@ -1,5 +1,6 @@
# $OpenBSD: Makefile,v 1.18 2020/07/30 17:45:44 millert Exp $
# $OpenBSD: Makefile,v 1.19 2024/06/03 00:55:05 millert Exp $
WARNINGS=Yes
PROG= awk
SRCS= awkgram.tab.c lex.c b.c main.c parse.c proctab.c tran.c lib.c run.c
LDADD= -lm

View File

@ -27,7 +27,7 @@ this affects `length`, `substr`, `index`, `match`, `split`,
points are not necessarily characters.
UTF-8 sequences may appear in literal strings and regular expressions.
Aribtrary characters may be included with `\u` followed by 1 to 8 hexadecimal digits.
Arbitrary characters may be included with `\u` followed by 1 to 8 hexadecimal digits.
### Regular expressions ###

View File

@ -1,4 +1,4 @@
/* $OpenBSD: awk.h,v 1.31 2023/11/25 16:31:33 millert Exp $ */
/* $OpenBSD: awk.h,v 1.32 2024/06/03 00:58:04 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -179,7 +179,6 @@ typedef struct Node {
#define NIL ((Node *) 0)
extern Node *winner;
extern Node *nullstat;
extern Node *nullnode;
/* ctypes */

View File

@ -1,4 +1,4 @@
/* $OpenBSD: b.c,v 1.52 2024/05/04 22:59:21 millert Exp $ */
/* $OpenBSD: b.c,v 1.53 2024/06/03 00:55:05 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -81,9 +81,6 @@ int patlen;
fa *fatab[NFA];
int nfatab = 0; /* entries in fatab */
extern int u8_nextlen(const char *s);
/* utf-8 mechanism:
For most of Awk, utf-8 strings just "work", since they look like
@ -117,7 +114,6 @@ static int entry_cmp(const void *l, const void *r);
static int get_gototab(fa*, int, int);
static int set_gototab(fa*, int, int, int);
static void clear_gototab(fa*, int);
extern int u8_rune(int *, const char *);
static int *
intalloc(size_t n, const char *f)
@ -347,7 +343,8 @@ void freetr(Node *p) /* free parse tree */
/* in the parsing of regular expressions, metacharacters like . have */
/* to be seen literally; \056 is not a metacharacter. */
int hexstr(const uschar **pp, int max) /* find and eval hex string at pp, return new p */
static int
hexstr(const uschar **pp, int max) /* find and eval hex string at pp, return new p */
{ /* only pick up one 8-bit byte (2 chars) */
const uschar *p;
int n = 0;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: lex.c,v 1.32 2023/11/25 16:31:33 millert Exp $ */
/* $OpenBSD: lex.c,v 1.34 2024/06/03 00:58:04 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -227,7 +227,7 @@ int yylex(void)
;
unput(c);
/*
* Next line is a hack, itcompensates for
* Next line is a hack, it compensates for
* unput's treatment of \n.
*/
lineno++;
@ -379,8 +379,6 @@ int yylex(void)
}
}
extern int runetochar(char *str, int c);
int string(void)
{
int c, n;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: lib.c,v 1.57 2024/05/05 02:55:34 jsg Exp $ */
/* $OpenBSD: lib.c,v 1.58 2024/06/03 00:55:05 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -35,8 +35,6 @@ THIS SOFTWARE.
#include <math.h>
#include "awk.h"
extern int u8_nextlen(const char *s);
char EMPTY[] = { '\0' };
FILE *infile = NULL;
bool innew; /* true = infile has not been read by readrec */
@ -757,7 +755,7 @@ void WARNING(const char *fmt, ...)
error();
}
void error()
void error(void)
{
extern Node *curnode;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: main.c,v 1.70 2024/05/04 22:59:21 millert Exp $ */
/* $OpenBSD: main.c,v 1.71 2024/06/03 00:58:04 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -23,7 +23,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
****************************************************************/
const char *version = "version 20240504";
const char *version = "version 20240527";
#define DEBUG
#include <stdio.h>

View File

@ -1,4 +1,4 @@
/* $OpenBSD: proto.h,v 1.23 2023/11/22 01:01:21 millert Exp $ */
/* $OpenBSD: proto.h,v 1.25 2024/06/03 00:58:04 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -35,9 +35,6 @@ extern void startreg(void);
extern int input(void);
extern void unput(int);
extern void unputstr(const char *);
extern int yylook(void);
extern int yyback(int *, int);
extern int yyinput(void);
extern fa *makedfa(const char *, bool);
extern fa *mkdfa(const char *, bool);
@ -170,7 +167,6 @@ extern Cell *boolop(Node **, int);
extern Cell *relop(Node **, int);
extern void tfree(Cell *);
extern Cell *gettemp(void);
extern Cell *field(Node **, int);
extern Cell *indirect(Node **, int);
extern Cell *substr(Node **, int);
extern Cell *sindex(Node **, int);
@ -205,4 +201,8 @@ extern Cell *gensub(Node **, int);
extern FILE *popen(const char *, const char *);
extern int pclose(FILE *);
extern int u8_nextlen(const char *s);
extern int u8_rune(int *, const char *);
extern int runetochar(char *str, int c);
extern const char *flags2str(int flags);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: run.c,v 1.86 2024/05/04 22:59:21 millert Exp $ */
/* $OpenBSD: run.c,v 1.87 2024/06/03 00:55:05 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -600,7 +600,7 @@ Cell *intest(Node **a, int n) /* a[0] is index (list), a[1] is symtab */
/* is s the beginning of a valid utf-8 string? */
/* return length 1..4 if yes, 0 if no */
int u8_isutf(const char *s)
static int u8_isutf(const char *s)
{
int n, ret;
unsigned char c;
@ -671,7 +671,7 @@ int u8_nextlen(const char *s)
}
/* return number of utf characters or single non-utf bytes */
int u8_strlen(const char *s)
static int u8_strlen(const char *s)
{
int i, len, n, totlen;
unsigned char c;
@ -693,7 +693,7 @@ int u8_strlen(const char *s)
}
/* convert utf-8 char number in a string to its byte offset */
int u8_char2byte(const char *s, int charnum)
static int u8_char2byte(const char *s, int charnum)
{
int n;
int bytenum = 0;
@ -708,7 +708,7 @@ int u8_char2byte(const char *s, int charnum)
}
/* convert byte offset in s to utf-8 char number that starts there */
int u8_byte2char(const char *s, int bytenum)
static int u8_byte2char(const char *s, int bytenum)
{
int i, len, b;
int charnum = 0; /* BUG: what origin? */
@ -1062,7 +1062,7 @@ Cell *sindex(Node **a, int nnn) /* index(a[0], a[1]) */
return(z);
}
int has_utf8(char *s) /* return 1 if s contains any utf-8 (2 bytes or more) character */
static int has_utf8(char *s) /* return 1 if s contains any utf-8 (2 bytes or more) character */
{
int n;
@ -1248,13 +1248,13 @@ int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like co
if (prec > u8_strlen(t))
prec = u8_strlen(t);
pad = wid>prec ? wid - prec : 0; // has to be >= 0
int i, k, n;
int i, precb;
if (ljust) { // print prec chars from t, then pad blanks
n = u8_char2byte(t, prec);
for (k = 0; k < n; k++) {
//putchar(t[k]);
*p++ = t[k];
precb = u8_char2byte(t, prec);
for (i = 0; i < precb; i++) {
//putchar(t[i]);
*p++ = t[i];
}
for (i = 0; i < pad; i++) {
//printf(" ");
@ -1265,10 +1265,10 @@ int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like co
//printf(" ");
*p++ = ' ';
}
n = u8_char2byte(t, prec);
for (k = 0; k < n; k++) {
//putchar(t[k]);
*p++ = t[k];
precb = u8_char2byte(t, prec);
for (i = 0; i < precb; i++) {
//putchar(t[i]);
*p++ = t[i];
}
}
*p = 0;
@ -1986,7 +1986,6 @@ static char *nawk_convert(const char *s, int (*fun_c)(int),
size_t n = 0;
wchar_t wc;
const size_t sz = awk_mb_cur_max;
int unused;
if (sz == 1) {
buf = tostring(s);
@ -1999,15 +1998,9 @@ static char *nawk_convert(const char *s, int (*fun_c)(int),
/* upper/lower character may be shorter/longer */
buf = tostringN(s, strlen(s) * sz + 1);
(void) mbtowc(NULL, NULL, 0); /* reset internal state */
/*
* Reset internal state here too.
* Assign result to avoid a compiler warning. (Casting to void
* doesn't work.)
* Increment said variable to avoid a different warning.
*/
unused = wctomb(NULL, L'\0');
unused++;
/* reset internal state */
if (mbtowc(NULL, NULL, 0) == -1 || wctomb(NULL, L'\0') == -1)
FATAL("unable to reset character conversion state");
ps = s;
pbuf = buf;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: tran.c,v 1.39 2024/05/04 22:59:21 millert Exp $ */
/* $OpenBSD: tran.c,v 1.40 2024/06/03 00:55:05 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@ -644,7 +644,7 @@ const char *flags2str(int flags)
if ((flags & flagtab[i].value) != 0) {
len = snprintf(cp, sizeof(buf) - (cp - buf),
"%s%s", cp > buf ? "|" : "", flagtab[i].name);
if (len < 0 || len >= sizeof(buf) - (cp - buf))
if (len < 0 || (size_t)len >= sizeof(buf) - (cp - buf))
FATAL("out of space in flags2str");
cp += len;
}

View File

@ -1,4 +1,4 @@
.\" $OpenBSD: uname.1,v 1.19 2023/10/09 19:28:42 schwarze Exp $
.\" $OpenBSD: uname.1,v 1.20 2024/06/03 15:55:52 florian Exp $
.\"
.\" Copyright (c) 1990 The Regents of the University of California.
.\" All rights reserved.
@ -29,7 +29,7 @@
.\"
.\" from: @(#)du.1 6.13 (Berkeley) 6/20/91
.\"
.Dd $Mdocdate: October 9 2023 $
.Dd $Mdocdate: June 3 2024 $
.Dt UNAME 1
.Os
.Sh NAME
@ -73,34 +73,8 @@ On
.Ox ,
the format is
.Sm off
.Ar digit . digit Bq \- Ar flavor .
.Ar digit . digit .
.Sm on
.Pp
The meaning of the
.Pf \- Ar flavor
suffix is as follows:
.Bl -tag -width "no suffix"
.It \-beta
A development version preceding the
.Ar digit . Ns Ar digit
release.
.It no suffix
A public release,
or a development version very closely preceding that release.
.It \-stable
A branch based on the
.Ar digit . Ns Ar digit
release that only contains patches to fix very important bugs.
.It \-current
A development version coming after the
.Ar digit . Ns Ar digit
release.
Some time before the subsequent release, the second
.Ar digit
is incremented and the
.Pf \- Ar flavor
switched to \-beta.
.El
.It Fl s
Print the operating system name.
On

View File

@ -1,4 +1,4 @@
/* $OpenBSD: crunchgen.c,v 1.27 2023/09/14 16:39:00 jca Exp $ */
/* $OpenBSD: crunchgen.c,v 1.30 2024/06/02 18:47:17 deraadt Exp $ */
/*
* Copyright (c) 1994 University of Maryland
@ -897,6 +897,7 @@ top_makefile_rules(FILE * outmk)
fprintf(outmk, "CFLAGS+=-fno-unwind-tables\n");
fprintf(outmk, ".if ${MACHINE} == \"amd64\"\n");
fprintf(outmk, "CFLAGS+=-fcf-protection=none\n");
fprintf(outmk, "CFLAGS+=-fno-ret-clean\n");
fprintf(outmk, ".endif\n");
fprintf(outmk, ".if ${MACHINE} == \"arm64\"\n");
fprintf(outmk, "CFLAGS+=-mbranch-protection=none\n");

View File

@ -3,6 +3,7 @@ body {
background-color: white;
color: black;
font-family: sans-serif;
font-variant-emoji: text;
}
table {
border-collapse: collapse;
@ -18,7 +19,6 @@ tr.sort th.sorted { font-weight: bold; }
tr.sort th::after { content: "\a0\2195"; }
tr.dir td:nth-child(2n+1) {
font-weight: bold;
font-style: italic;
}
td, th { padding: 2pt 2em; }
td:first-child, th:first-child { padding-left: 5pt; }

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cert.c,v 1.132 2024/05/31 02:45:15 tb Exp $ */
/* $OpenBSD: cert.c,v 1.133 2024/06/03 12:58:39 tb Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2021 Job Snijders <job@openbsd.org>
@ -495,7 +495,8 @@ sbgp_ipaddrblk(const char *fn, struct cert *cert, X509_EXTENSION *ext)
}
/*
* Parse "Subject Information Access" extension, RFC 6487 4.8.8.
* Parse "Subject Information Access" extension for a CA cert,
* RFC 6487, section 4.8.8.1 and RFC 8182, section 3.2.
* Returns zero on failure, non-zero on success.
*/
static int
@ -505,8 +506,11 @@ sbgp_sia(const char *fn, struct cert *cert, X509_EXTENSION *ext)
ACCESS_DESCRIPTION *ad;
ASN1_OBJECT *oid;
const char *mftfilename;
char *carepo = NULL, *rpkimft = NULL;
int i, rc = 0;
assert(cert->repo == NULL && cert->mft == NULL && cert->notify == NULL);
if (X509_EXTENSION_get_critical(ext)) {
warnx("%s: RFC 6487 section 4.8.8: SIA: "
"extension not non-critical", fn);
@ -525,13 +529,35 @@ sbgp_sia(const char *fn, struct cert *cert, X509_EXTENSION *ext)
oid = ad->method;
if (OBJ_cmp(oid, carepo_oid) == 0) {
if (!x509_location(fn, "SIA: caRepository",
RSYNC_PROTO, ad->location, &cert->repo))
if (!x509_location(fn, "SIA: caRepository", NULL,
ad->location, &carepo))
goto out;
if (cert->repo == NULL && strncasecmp(carepo,
RSYNC_PROTO, RSYNC_PROTO_LEN) == 0) {
cert->repo = carepo;
carepo = NULL;
continue;
}
if (verbose)
warnx("%s: RFC 6487 section 4.8.8: SIA: "
"ignoring location %s", fn, carepo);
free(carepo);
carepo = NULL;
} else if (OBJ_cmp(oid, manifest_oid) == 0) {
if (!x509_location(fn, "SIA: rpkiManifest",
RSYNC_PROTO, ad->location, &cert->mft))
if (!x509_location(fn, "SIA: rpkiManifest", NULL,
ad->location, &rpkimft))
goto out;
if (cert->mft == NULL && strncasecmp(rpkimft,
RSYNC_PROTO, RSYNC_PROTO_LEN) == 0) {
cert->mft = rpkimft;
rpkimft = NULL;
continue;
}
if (verbose)
warnx("%s: RFC 6487 section 4.8.8: SIA: "
"ignoring location %s", fn, rpkimft);
free(rpkimft);
rpkimft = NULL;
} else if (OBJ_cmp(oid, notify_oid) == 0) {
if (!x509_location(fn, "SIA: rpkiNotify",
HTTPS_PROTO, ad->location, &cert->notify))
@ -844,6 +870,10 @@ cert_parse_pre(const char *fn, const unsigned char *der, size_t len)
case NID_sinfo_access:
if (sia++ > 0)
goto dup;
/*
* This will fail for BGPsec certs, but they must omit
* this extension anyway (RFC 8209, section 3.1.3.3).
*/
if (!sbgp_sia(fn, cert, ext))
goto out;
break;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: x509.c,v 1.90 2024/05/31 11:27:34 tb Exp $ */
/* $OpenBSD: x509.c,v 1.91 2024/06/03 12:58:39 tb Exp $ */
/*
* Copyright (c) 2022 Theo Buehler <tb@openbsd.org>
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
@ -467,8 +467,8 @@ out:
}
/*
* Parse the Subject Information Access (SIA) extension
* See RFC 6487, section 4.8.8 for details.
* Parse the Subject Information Access (SIA) extension for an EE cert.
* See RFC 6487, section 4.8.8.2 for details.
* Returns NULL on failure, on success returns the SIA signedObject URI
* (which has to be freed after use).
*/

View File

@ -1,4 +1,4 @@
/* $OpenBSD: smtp.h,v 1.4 2021/03/05 12:37:32 eric Exp $ */
/* $OpenBSD: smtp.h,v 1.5 2024/06/02 23:26:39 jsg Exp $ */
/*
* Copyright (c) 2018 Eric Faurot <eric@openbsd.org>
@ -87,7 +87,6 @@ void smtp_quit(struct smtp_client *);
void smtp_sendmail(struct smtp_client *, struct smtp_mail *);
/* callbacks */
void smtp_verify_server_cert(void *, struct smtp_client *, void *);
void smtp_require_tls(void *, struct smtp_client *);
void smtp_ready(void *, struct smtp_client *);
void smtp_failed(void *, struct smtp_client *, int, const char *);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: smtpd.h,v 1.685 2024/05/28 07:10:30 op Exp $ */
/* $OpenBSD: smtpd.h,v 1.686 2024/06/02 23:26:39 jsg Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
@ -1261,11 +1261,6 @@ struct rule {
/* aliases.c */
int aliases_get(struct expand *, const char *);
int aliases_virtual_get(struct expand *, const struct mailaddr *);
int alias_parse(struct expandnode *, const char *);
/* auth.c */
struct auth_backend *auth_backend_lookup(enum auth_type);
/* bounce.c */
@ -1402,7 +1397,6 @@ void lka_filter_end(uint64_t);
void lka_filter_protocol(uint64_t, enum filter_phase, const char *);
void lka_filter_data_begin(uint64_t);
void lka_filter_data_end(uint64_t);
int lka_filter_response(uint64_t, const char *, const char *);
/* lka_session.c */
@ -1609,12 +1603,6 @@ int smtp_session(struct listener *, int, const struct sockaddr_storage *,
void smtp_session_imsg(struct mproc *, struct imsg *);
/* smtpf_session.c */
int smtpf_session(struct listener *, int, const struct sockaddr_storage *,
const char *);
void smtpf_session_imsg(struct mproc *, struct imsg *);
/* smtpd.c */
void imsg_dispatch(struct mproc *, struct imsg *);
const char *proc_name(enum smtp_proc_type);
@ -1670,7 +1658,6 @@ void table_close_all(struct smtpd *);
/* to.c */
int email_to_mailaddr(struct mailaddr *, char *);
int text_to_netaddr(struct netaddr *, const char *);
int text_to_mailaddr(struct mailaddr *, const char *);
int text_to_relayhost(struct relayhost *, const char *);
@ -1714,7 +1701,6 @@ int lowercase(char *, const char *, size_t);
void xlowercase(char *, const char *, size_t);
int uppercase(char *, const char *, size_t);
uint64_t generate_uid(void);
int availdesc(void);
int ckdir(const char *, mode_t, uid_t, gid_t, int);
int rmtree(char *, int);
int mvpurge(char *, char *);
@ -1730,8 +1716,6 @@ char *strip(char *);
int io_xprint(struct io *, const char *);
int io_xprintf(struct io *, const char *, ...)
__attribute__((__format__ (printf, 2, 3)));
void log_envelope(const struct envelope *, const char *, const char *,
const char *);
int session_socket_error(int);
int getmailname(char *, size_t);
int base64_encode(unsigned char const *, size_t, char *, size_t);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.158 2024/05/13 06:48:26 jsg Exp $ */
/* $OpenBSD: util.c,v 1.159 2024/06/02 23:26:39 jsg Exp $ */
/*
* Copyright (c) 2000,2001 Markus Friedl. All rights reserved.
@ -38,8 +38,6 @@
#include "smtpd.h"
#include "log.h"
const char *log_in6addr(const struct in6_addr *);
const char *log_sockaddr(struct sockaddr *);
static int parse_mailname_file(char *, size_t);
int tracing = 0;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: parse.y,v 1.90 2024/02/20 12:32:48 martijn Exp $ */
/* $OpenBSD: parse.y,v 1.91 2024/06/03 06:14:32 anton Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
@ -142,6 +142,8 @@ static uint8_t engineid[SNMPD_MAXENGINEIDLEN];
static int32_t enginepen;
static size_t engineidlen;
static unsigned char sha256[SHA256_DIGEST_LENGTH];
int resolve_oid(struct ber_oid *, struct oid_sym *);
int resolve_oids(void);
int host(const char *, const char *, int, int,
@ -708,7 +710,7 @@ enginefmt : IP4 STRING {
}
engineid[engineidlen++] = SNMP_ENGINEID_FMT_HH;
memcpy(engineid + engineidlen,
SHA256($2, strlen($2), NULL),
SHA256($2, strlen($2), sha256),
sizeof(engineid) - engineidlen);
engineidlen = sizeof(engineid);
engineid[0] |= SNMP_ENGINEID_NEW;
@ -761,7 +763,7 @@ enginefmt_local : enginefmt
engineid[engineidlen++] = SNMP_ENGINEID_FMT_HH;
memcpy(engineid + engineidlen,
SHA256(hostname, strlen(hostname), NULL),
SHA256(hostname, strlen(hostname), sha256),
sizeof(engineid) - engineidlen);
engineidlen = sizeof(engineid);
engineid[0] |= SNMP_ENGINEID_NEW;
@ -1861,7 +1863,7 @@ parse_config(const char *filename, u_int flags)
conf->sc_engineid[conf->sc_engineid_len++] |=
SNMP_ENGINEID_FMT_HH;
memcpy(conf->sc_engineid + conf->sc_engineid_len,
SHA256(hostname, strlen(hostname), NULL),
SHA256(hostname, strlen(hostname), sha256),
sizeof(conf->sc_engineid) - conf->sc_engineid_len);
conf->sc_engineid_len = sizeof(conf->sc_engineid);
conf->sc_engineid[0] |= SNMP_ENGINEID_NEW;