diff --git a/distrib/Makefile b/distrib/Makefile index 47231313f..f2ce61843 100644 --- a/distrib/Makefile +++ b/distrib/Makefile @@ -3,9 +3,7 @@ SUBDIR= special notes .if make(obj) -SUBDIR+=alpha amd64 armv7 arm64 hppa i386 \ - landisk loongson luna88k macppc \ - octeon powerpc64 riscv64 sparc64 +SUBDIR+=amd64 armv7 arm64 .elif exists(${MACHINE}) SUBDIR+=${MACHINE} .endif diff --git a/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp b/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp index 524c0098b..ddc77ec45 100644 --- a/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp +++ b/gnu/llvm/clang/lib/Driver/ToolChains/Clang.cpp @@ -1819,8 +1819,11 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args, if (IndirectBranches) CmdArgs.push_back("-mbranch-target-enforce"); } else { - if (Triple.isOSOpenBSD()) + if (Triple.isOSOpenBSD()) { + CmdArgs.push_back("-msign-return-address=non-leaf"); + CmdArgs.push_back("-msign-return-address-key=a_key"); CmdArgs.push_back("-mbranch-target-enforce"); + } } // Handle -msve_vector_bits= diff --git a/gnu/llvm/lld/ELF/Arch/AArch64.cpp b/gnu/llvm/lld/ELF/Arch/AArch64.cpp index c1ab0e97e..7021aa000 100644 --- a/gnu/llvm/lld/ELF/Arch/AArch64.cpp +++ b/gnu/llvm/lld/ELF/Arch/AArch64.cpp @@ -621,7 +621,11 @@ private: } // namespace AArch64BtiPac::AArch64BtiPac() { +#ifdef __OpenBSD__ + btiHeader = true; +#else btiHeader = (config->andFeatures & GNU_PROPERTY_AARCH64_FEATURE_1_BTI); +#endif // A BTI (Branch Target Indicator) Plt Entry is only required if the // address of the PLT entry can be taken by the program, which permits an // indirect jump to the PLT entry. This can happen when the address @@ -717,6 +721,10 @@ void AArch64BtiPac::writePlt(uint8_t *buf, const Symbol &sym, } static TargetInfo *getTargetInfo() { +#ifdef __OpenBSD__ + static AArch64BtiPac t; + return &t; +#else if (config->andFeatures & (GNU_PROPERTY_AARCH64_FEATURE_1_BTI | GNU_PROPERTY_AARCH64_FEATURE_1_PAC)) { static AArch64BtiPac t; @@ -724,6 +732,7 @@ static TargetInfo *getTargetInfo() { } static AArch64 t; return &t; +#endif } TargetInfo *elf::getAArch64TargetInfo() { return getTargetInfo(); } diff --git a/gnu/usr.bin/binutils-2.17/opcodes/i386-dis.c b/gnu/usr.bin/binutils-2.17/opcodes/i386-dis.c index ee34ed399..8b4bb72e3 100644 --- a/gnu/usr.bin/binutils-2.17/opcodes/i386-dis.c +++ b/gnu/usr.bin/binutils-2.17/opcodes/i386-dis.c @@ -99,6 +99,7 @@ static void SIMD_Fixup (int, int); static void PNI_Fixup (int, int); static void XCR_Fixup (int, int); static void SVME_Fixup (int, int); +static void SSP_Fixup (int, int); static void INVLPG_Fixup (int, int); static void BadOp (void); static void SEG_Fixup (int, int); @@ -106,6 +107,7 @@ static void VMX_Fixup (int, int); static void REP_Fixup (int, int); static void OP_0f38 (int, int); static void OP_0f3a (int, int); +static void OP_0f1e (int, int); static void OP_data (int, int); struct dis_private { @@ -324,6 +326,7 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr) #define OP0FAE OP_0fae, v_mode #define OP0F38 OP_0f38, 0 #define OP0F3A OP_0f3a, 0 +#define OP0F1E OP_0f1e, v_mode #define OPDATA OP_data, 0 /* Used handle "rep" prefix for string instructions. */ @@ -471,6 +474,7 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr) #define PREGRP30 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 30, NULL, 0 #define PREGRP31 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 31, NULL, 0 #define PREGRP32 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 32, NULL, 0 +#define PREGRP33 NULL, NULL, USE_PREFIX_USER_TABLE, NULL, 33, NULL, 0 #define X86_64_0 NULL, NULL, X86_64_SPECIAL, NULL, 0, NULL, 0 @@ -494,6 +498,7 @@ struct dis386 { 'B' => print 'b' if suffix_always is true 'C' => print 's' or 'l' ('w' or 'd' in Intel mode) depending on operand . size prefix + 'D' => print '64' in place of rex64 prefix 'E' => print 'e' if 32-bit form of jcxz 'F' => print 'w' or 'l' depending on address size prefix (loop insns) 'H' => print ",pt" or ",pn" branch hint @@ -852,7 +857,7 @@ static const struct dis386 dis386_twobyte[] = { { "(bad)", XX, XX, XX }, { "(bad)", XX, XX, XX }, { "(bad)", XX, XX, XX }, - { "(bad)", XX, XX, XX }, + { PREGRP33 }, { "(bad)", XX, XX, XX }, /* 20 */ { "movZ", Rm, Cm, XX }, @@ -1135,7 +1140,7 @@ static const unsigned char twobyte_has_modrm[256] = { /* 0 1 2 3 4 5 6 7 8 9 a b c d e f */ /* ------------------------------- */ /* 00 */ 1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1, /* 0f */ - /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0, /* 1f */ + /* 10 */ 1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,0, /* 1f */ /* 20 */ 1,1,1,1,1,0,1,0,1,1,1,1,1,1,1,1, /* 2f */ /* 30 */ 0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0, /* 3f */ /* 40 */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 4f */ @@ -1416,7 +1421,7 @@ static const struct dis386 grps[][8] = { { "lgdt{Q|Q||}", XCR_Fixup, 0, XX, XX }, { "lidt{Q|Q||}", SVME_Fixup, 0, XX, XX }, { "smswQ", Ev, XX, XX }, - { "(bad)", XX, XX, XX }, + { "", SSP_Fixup, 0, XX, XX }, { "lmsw", Ew, XX, XX }, { "invlpg", INVLPG_Fixup, w_mode, XX, XX }, }, @@ -1436,9 +1441,9 @@ static const struct dis386 grps[][8] = { { "(bad)", XX, XX, XX }, { "cmpxchg8b", Eq, XX, XX }, { "(bad)", XX, XX, XX }, - { "(bad)", XX, XX, XX }, - { "(bad)", XX, XX, XX }, - { "(bad)", XX, XX, XX }, + { "xrstorsD",Ev, XX, XX }, + { "xsavecD",Ev, XX, XX }, + { "xsavesD",Ev, XX, XX }, { "", VM, XX, XX }, /* See OP_VMX. */ { "", VM2, XX, XX }, }, @@ -1477,13 +1482,13 @@ static const struct dis386 grps[][8] = { }, /* GRP13 */ { - { "fxsave", OP0FAE, XX, XX }, - { "fxrstor", OP0FAE, XX, XX }, + { "fxsaveD", OP0FAE, XX, XX }, + { "fxrstorD", OP0FAE, XX, XX }, { "ldmxcsr", OP0FAE, XX, XX }, { "stmxcsr", OP0FAE, XX, XX }, - { "xsave", Ev, XX, XX }, - { "xrstor", OP0FAE, XX, XX }, - { "xsaveopt", OP0FAE, XX, XX }, + { "xsaveD", OP0FAE, XX, XX }, + { "xrstorD", OP0FAE, XX, XX }, + { "xsaveoptD",OP0FAE, XX, XX }, { "clflush", OP0FAE, XX, XX }, }, /* GRP14 */ @@ -1529,7 +1534,7 @@ static const struct dis386 grps[][8] = { { "(bad)", OP_0f07, 0, XX, XX }, { "(bad)", OP_0f07, 0, XX, XX }, { "(bad)", OP_0f07, 0, XX, XX }, - } + }, }; static const struct dis386 prefix_user_table[][4] = { @@ -1764,6 +1769,13 @@ static const struct dis386 prefix_user_table[][4] = { { "(bad)", XM, EX, XX }, { "lddqu", XM, M, XX }, }, + /* PREGRP33 */ + { + { "(bad)", XM, EX, XX }, + { "", OP0F1E, XX, XX }, + { "(bad)", XM, EX, XX }, + { "(bad)", XM, EX, XX }, + }, }; static const struct dis386 x86_64_table[][2] = { @@ -3397,6 +3409,14 @@ putop (const char *template, int sizeflag) used_prefixes |= (prefixes & PREFIX_DATA); } break; + case 'D': + USED_REX (REX_MODE64); + if (rex & REX_MODE64) + { + *obufp++ = '6'; + *obufp++ = '4'; + } + break; case 'E': /* For jcxz/jecxz */ if (address_mode == mode_64bit) { @@ -4828,9 +4848,110 @@ OP_0f07 (int bytemode, int sizeflag) OP_E (bytemode, sizeflag); } +static void +OP_0f1e (int bytemode, int sizeflag) +{ + used_prefixes |= PREFIX_REPZ; + switch (*codep++) + { + case 0xfa: + strcpy (obuf, "endbr64"); + break; + case 0xfb: + strcpy (obuf, "endbr32"); + break; + default: + USED_REX (REX_MODE64); + if (rex & REX_MODE64) + strcpy (obuf, "rdsspq"); + else + strcpy (obuf, "rdsspd"); + OP_E (bytemode, sizeflag); + return; + } +} + static void OP_0fae (int bytemode, int sizeflag) { + if (prefixes & PREFIX_REPZ) + { + used_prefixes |= PREFIX_REPZ; + if (mod != 3) + { + if (reg == 6) + { + strcpy (obuf, "clrssbsy"); + OP_E (bytemode, sizeflag); + } + else + BadOp (); + return; + } + switch (reg) + { + case 0: + strcpy (obuf, "rdfsbase"); + break; + case 1: + strcpy (obuf, "rdgsbase"); + break; + case 2: + strcpy (obuf, "wrfsbase"); + break; + case 3: + strcpy (obuf, "wrgsbase"); + break; + case 4: + strcpy (obuf, "ptwrite"); + break; + case 5: + USED_REX (REX_MODE64); + if (rex & REX_MODE64) + strcpy (obuf, "incsspq"); + else + strcpy (obuf, "incsspd"); + break; + case 6: + strcpy (obuf, "umonitor"); /* XXX wrong size for r16/r32/r64 arg */ + break; + case 7: + BadOp (); + return; + } + OP_E (bytemode, sizeflag); + return; + } + + if (prefixes & PREFIX_REPNZ) + { + if (mod == 3 && reg == 6) + { + used_prefixes |= PREFIX_REPNZ; + strcpy (obuf, "umwait"); + OP_E (bytemode, sizeflag); + } + else + BadOp (); + return; + } + + if (prefixes & PREFIX_DATA) + { + if (mod != 3 && reg >= 6) + strcpy (obuf, reg == 6 ? "clwb" : "clflushopt"); + else if (mod == 3 && reg == 6) + strcpy (obuf, "tpause"); /* XXX wrong size for r16/r32/r64 arg */ + else + { + BadOp (); + return; + } + used_prefixes |= PREFIX_DATA; + OP_E (bytemode, sizeflag); + return; + } + if (mod == 3) { if (reg == 7) @@ -4839,21 +4960,9 @@ OP_0fae (int bytemode, int sizeflag) strcpy (obuf + strlen (obuf) - sizeof ("xsaveopt") + 1, "mfence"); else if (reg == 5) strcpy (obuf + strlen (obuf) - sizeof ("xrstor") + 1, "lfence"); - - if (reg < 4 && prefixes == PREFIX_REPZ) - { - if (reg == 0) - strcpy (obuf, "rdfsbase"); - else if (reg == 1) - strcpy (obuf, "rdgsbase"); - else if (reg == 2) - strcpy (obuf, "wrfsbase"); - else - strcpy (obuf, "wrgsbase"); - } - else if (reg < 5 || rm != 0) + else if (reg < 5) { - BadOp (); /* bad sfence, mfence, or lfence */ + BadOp (); return; } } @@ -5031,6 +5140,7 @@ SIMD_Fixup (int extrachar, int sizeflag ATTRIBUTE_UNUSED) static void PNI_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag) { + /* missing: encls==np0f01cf */ if (mod == 3 && reg == 1 && rm <= 1) { /* Override "sidt". */ @@ -5105,7 +5215,8 @@ PNI_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag) static void XCR_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag) { - if (mod == 3 && reg == 2 && rm <= 1) + if (mod == 3 && reg == 2 && (rm <= 1 || rm >= 4) && + (prefixes & (PREFIX_REPZ|PREFIX_REPNZ|PREFIX_DATA)) == 0) { /* Override "lgdt". */ size_t olen = strlen (obuf); @@ -5125,13 +5236,26 @@ XCR_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag) || strncmp (p - 3, "32", 2) == 0)) p -= 7; - if (rm) - { - strcpy (p, "xsetbv"); - } - else + switch (rm) { + case 0: strcpy (p, "xgetbv"); + break; + case 1: + strcpy (p, "xsetbv"); + break; + case 4: + strcpy (p, "vmfunc"); + break; + case 5: + strcpy (p, "xend"); + break; + case 6: + strcpy (p, "xtest"); + break; + case 7: + strcpy (p, "enclu"); + break; } codep++; @@ -5210,6 +5334,78 @@ SVME_Fixup (int bytemode, int sizeflag) } } +static void +SSP_Fixup (int bytemode, int sizeflag) +{ + used_prefixes |= (prefixes & (PREFIX_REPZ | PREFIX_REPNZ)); + if (mod != 3) + { + if (prefixes & PREFIX_REPZ) + { + strcpy (obuf, "rstorssp"); + OP_M (bytemode, sizeflag); + } + else + BadOp (); + return; + } + + if (prefixes & PREFIX_REPZ) + switch (*codep++) + { + case 0xe8: + strcpy (obuf, "setssbsy"); + break; + case 0xea: + strcpy (obuf, "saveprevssp"); + break; + case 0xec: + strcpy (obuf, "uiret"); + break; + case 0xed: + strcpy (obuf, "testui"); + break; + case 0xee: + strcpy (obuf, "clui"); + break; + case 0xef: + strcpy (obuf, "stui"); + break; + default: + break; + } + else if (prefixes & PREFIX_REPNZ) + switch (*codep) + { + case 0xe8: + strcpy (obuf, "xsusldtrk"); + break; + case 0xe9: + strcpy (obuf, "xresldtrk"); + break; + default: + BadOp (); + return; + } + else + switch (*codep) + { + case 0xe8: + strcpy (obuf, "serialize"); + break; + case 0xee: + strcpy (obuf, "rdpkru"); + break; + case 0xef: + strcpy (obuf, "wrpkru"); + break; + default: + BadOp (); + return; + } + codep++; +} + static void INVLPG_Fixup (int bytemode, int sizeflag) { @@ -5292,6 +5488,7 @@ SEG_Fixup (int extrachar, int sizeflag) static void VMX_Fixup (int extrachar ATTRIBUTE_UNUSED, int sizeflag) { + /* missing: enclv==np0f01c0 pconfig==np0f01c5 */ if (mod == 3 && reg == 0 && rm >=1 && rm <= 4) { /* Override "sgdt". */ @@ -5328,8 +5525,17 @@ OP_VMX (int bytemode, int sizeflag) { if (mod == 3) { - strcpy (obuf, "rdrand"); - OP_E (v_mode, sizeflag); + used_prefixes |= (prefixes & PREFIX_REPZ); + if (prefixes & PREFIX_REPZ) + { + strcpy (obuf, "senduipi"); + OP_G (m_mode, sizeflag); + } + else + { + strcpy (obuf, "rdrand"); + OP_E (v_mode, sizeflag); + } } else { @@ -5349,7 +5555,11 @@ OP_VMX2 (int bytemode ATTRIBUTE_UNUSED, int sizeflag) { if (mod == 3) { - strcpy (obuf, "rdseed"); + used_prefixes |= (prefixes & PREFIX_REPZ); + if (prefixes & PREFIX_REPZ) + strcpy (obuf, "rdpid"); + else + strcpy (obuf, "rdseed"); OP_E (v_mode, sizeflag); } else diff --git a/lib/libc/sys/sysctl.2 b/lib/libc/sys/sysctl.2 index 431f3ca92..4f78c121a 100644 --- a/lib/libc/sys/sysctl.2 +++ b/lib/libc/sys/sysctl.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: sysctl.2,v 1.51 2022/11/07 15:32:24 jmc Exp $ +.\" $OpenBSD: sysctl.2,v 1.52 2023/05/16 21:13:19 jmc Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: November 7 2022 $ +.Dd $Mdocdate: May 16 2023 $ .Dt SYSCTL 2 .Os .Sh NAME @@ -1336,6 +1336,7 @@ The currently defined protocols and names are: .It tcp Ta syncachelimit Ta integer Ta yes .It tcp Ta synhashsize Ta integer Ta yes .It tcp Ta synuselimit Ta integer Ta yes +.It tcp Ta tso Ta integer Ta yes .It udp Ta baddynamic Ta array Ta yes .It udp Ta checksum Ta integer Ta yes .It udp Ta recvspace Ta integer Ta yes @@ -1742,6 +1743,9 @@ SYN cache becomes empty and both SYN caches are swapped. .It Li tcp.synuselimit Pq Va net.inet.tcp.synuselimit The minimum number of times the hash function for the TCP SYN cache is used before it is reseeded. +.It Li tcp.tso Pq Va net.inet.tcp.tso +If set to 0, disable TCP segmentation offload (TSO). +If set to 1, TSO is enabled (the default). .It Li udp.baddynamic Pq Va net.inet.udp.baddynamic Analogous to .Li tcp.baddynamic diff --git a/lib/libcrypto/sha/sha512.c b/lib/libcrypto/sha/sha512.c index 2840fa944..c0752bd2c 100644 --- a/lib/libcrypto/sha/sha512.c +++ b/lib/libcrypto/sha/sha512.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sha512.c,v 1.35 2023/05/12 10:10:55 jsing Exp $ */ +/* $OpenBSD: sha512.c,v 1.36 2023/05/16 07:04:57 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. * @@ -153,27 +153,29 @@ static const SHA_LONG64 K512[80] = { #define Ch(x, y, z) (((x) & (y)) ^ ((~(x)) & (z))) #define Maj(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) -#define ROUND_00_15(i, a, b, c, d, e, f, g, h) do { \ - T1 += h + Sigma1(e) + Ch(e, f, g) + K512[i]; \ - h = Sigma0(a) + Maj(a, b, c); \ - d += T1; h += T1; } while (0) +#define ROUND_00_15(i, a, b, c, d, e, f, g, h, Wt) do { \ + T1 = h + Sigma1(e) + Ch(e, f, g) + K512[i] + Wt; \ + T2 = Sigma0(a) + Maj(a, b, c); \ + d += T1; \ + h = T1 + T2; \ + } while (0) -#define ROUND_16_80(i, j, a, b, c, d, e, f, g, h, X) do { \ - s0 = X[(j+1)&0x0f]; s0 = sigma0(s0); \ - s1 = X[(j+14)&0x0f]; s1 = sigma1(s1); \ - T1 = X[(j)&0x0f] += s0 + s1 + X[(j+9)&0x0f]; \ - ROUND_00_15(i+j, a, b, c, d, e, f, g, h); } while (0) +#define ROUND_16_80(i, j, a, b, c, d, e, f, g, h, X) do { \ + s0 = sigma0(X[(j + 1) & 0x0f]); \ + s1 = sigma1(X[(j + 14) & 0x0f]); \ + X[(j) & 0x0f] += s0 + s1 + X[(j + 9) & 0x0f]; \ + ROUND_00_15(i + j, a, b, c, d, e, f, g, h, X[(j) & 0x0f]); \ + } while (0) static void -sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) +sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num) { - const SHA_LONG64 *W = in; - SHA_LONG64 a, b, c, d, e, f, g, h, s0, s1, T1; + const SHA_LONG64 *in = _in; + SHA_LONG64 a, b, c, d, e, f, g, h, s0, s1, T1, T2; SHA_LONG64 X[16]; int i; while (num--) { - a = ctx->h[0]; b = ctx->h[1]; c = ctx->h[2]; @@ -183,38 +185,38 @@ sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) g = ctx->h[6]; h = ctx->h[7]; - T1 = X[0] = PULL64(W[0]); - ROUND_00_15(0, a, b, c, d, e, f, g, h); - T1 = X[1] = PULL64(W[1]); - ROUND_00_15(1, h, a, b, c, d, e, f, g); - T1 = X[2] = PULL64(W[2]); - ROUND_00_15(2, g, h, a, b, c, d, e, f); - T1 = X[3] = PULL64(W[3]); - ROUND_00_15(3, f, g, h, a, b, c, d, e); - T1 = X[4] = PULL64(W[4]); - ROUND_00_15(4, e, f, g, h, a, b, c, d); - T1 = X[5] = PULL64(W[5]); - ROUND_00_15(5, d, e, f, g, h, a, b, c); - T1 = X[6] = PULL64(W[6]); - ROUND_00_15(6, c, d, e, f, g, h, a, b); - T1 = X[7] = PULL64(W[7]); - ROUND_00_15(7, b, c, d, e, f, g, h, a); - T1 = X[8] = PULL64(W[8]); - ROUND_00_15(8, a, b, c, d, e, f, g, h); - T1 = X[9] = PULL64(W[9]); - ROUND_00_15(9, h, a, b, c, d, e, f, g); - T1 = X[10] = PULL64(W[10]); - ROUND_00_15(10, g, h, a, b, c, d, e, f); - T1 = X[11] = PULL64(W[11]); - ROUND_00_15(11, f, g, h, a, b, c, d, e); - T1 = X[12] = PULL64(W[12]); - ROUND_00_15(12, e, f, g, h, a, b, c, d); - T1 = X[13] = PULL64(W[13]); - ROUND_00_15(13, d, e, f, g, h, a, b, c); - T1 = X[14] = PULL64(W[14]); - ROUND_00_15(14, c, d, e, f, g, h, a, b); - T1 = X[15] = PULL64(W[15]); - ROUND_00_15(15, b, c, d, e, f, g, h, a); + X[0] = PULL64(in[0]); + ROUND_00_15(0, a, b, c, d, e, f, g, h, X[0]); + X[1] = PULL64(in[1]); + ROUND_00_15(1, h, a, b, c, d, e, f, g, X[1]); + X[2] = PULL64(in[2]); + ROUND_00_15(2, g, h, a, b, c, d, e, f, X[2]); + X[3] = PULL64(in[3]); + ROUND_00_15(3, f, g, h, a, b, c, d, e, X[3]); + X[4] = PULL64(in[4]); + ROUND_00_15(4, e, f, g, h, a, b, c, d, X[4]); + X[5] = PULL64(in[5]); + ROUND_00_15(5, d, e, f, g, h, a, b, c, X[5]); + X[6] = PULL64(in[6]); + ROUND_00_15(6, c, d, e, f, g, h, a, b, X[6]); + X[7] = PULL64(in[7]); + ROUND_00_15(7, b, c, d, e, f, g, h, a, X[7]); + X[8] = PULL64(in[8]); + ROUND_00_15(8, a, b, c, d, e, f, g, h, X[8]); + X[9] = PULL64(in[9]); + ROUND_00_15(9, h, a, b, c, d, e, f, g, X[9]); + X[10] = PULL64(in[10]); + ROUND_00_15(10, g, h, a, b, c, d, e, f, X[10]); + X[11] = PULL64(in[11]); + ROUND_00_15(11, f, g, h, a, b, c, d, e, X[11]); + X[12] = PULL64(in[12]); + ROUND_00_15(12, e, f, g, h, a, b, c, d, X[12]); + X[13] = PULL64(in[13]); + ROUND_00_15(13, d, e, f, g, h, a, b, c, X[13]); + X[14] = PULL64(in[14]); + ROUND_00_15(14, c, d, e, f, g, h, a, b, X[14]); + X[15] = PULL64(in[15]); + ROUND_00_15(15, b, c, d, e, f, g, h, a, X[15]); for (i = 16; i < 80; i += 16) { ROUND_16_80(i, 0, a, b, c, d, e, f, g, h, X); @@ -244,7 +246,7 @@ sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) ctx->h[6] += g; ctx->h[7] += h; - W += SHA_LBLOCK; + in += SHA_LBLOCK; } } diff --git a/lib/libssl/s3_lib.c b/lib/libssl/s3_lib.c index 9e76cf93d..4229b2e9e 100644 --- a/lib/libssl/s3_lib.c +++ b/lib/libssl/s3_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_lib.c,v 1.242 2022/11/26 16:08:55 tb Exp $ */ +/* $OpenBSD: s3_lib.c,v 1.243 2023/05/16 14:10:43 jcs Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1580,6 +1580,7 @@ ssl3_free(SSL *s) sk_X509_NAME_pop_free(s->s3->hs.tls12.ca_names, X509_NAME_free); sk_X509_pop_free(s->verified_chain, X509_free); + s->verified_chain = NULL; tls1_transcript_free(s); tls1_transcript_hash_free(s); diff --git a/libexec/mail.local/mail.local.c b/libexec/mail.local/mail.local.c index 8a27d03c8..815fe5832 100644 --- a/libexec/mail.local/mail.local.c +++ b/libexec/mail.local/mail.local.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mail.local.c,v 1.40 2023/05/10 08:03:49 op Exp $ */ +/* $OpenBSD: mail.local.c,v 1.41 2023/05/15 12:02:40 op Exp $ */ /*- * Copyright (c) 1996-1998 Theo de Raadt @@ -244,7 +244,7 @@ retry: curoff = lseek(mbfd, 0, SEEK_END); (void)snprintf(biffmsg, sizeof biffmsg, "%s@%lld\n", name, - (long long int)curoff); + (long long)curoff); if (lseek(fd, 0, SEEK_SET) == (off_t)-1) { mwarn("temporary file: %s", strerror(errno)); goto bad; diff --git a/regress/lib/libcrypto/ecdh/ecdhtest.c b/regress/lib/libcrypto/ecdh/ecdhtest.c index e6046a540..415414bdc 100644 --- a/regress/lib/libcrypto/ecdh/ecdhtest.c +++ b/regress/lib/libcrypto/ecdh/ecdhtest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecdhtest.c,v 1.14 2023/04/26 09:31:12 tb Exp $ */ +/* $OpenBSD: ecdhtest.c,v 1.15 2023/05/16 18:41:18 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -146,7 +146,8 @@ test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) (void)BIO_flush(out); alen = KDF1_SHA1_len; - abuf = malloc(alen); + if ((abuf = malloc(alen)) == NULL) + goto err; aout = ECDH_compute_key(abuf, alen, EC_KEY_get0_public_key(b), a, KDF1_SHA1); @@ -154,7 +155,8 @@ test_ecdh_curve(int nid, const char *text, BN_CTX *ctx, BIO *out) (void)BIO_flush(out); blen = KDF1_SHA1_len; - bbuf = malloc(blen); + if ((bbuf = malloc(blen)) == NULL) + goto err; bout = ECDH_compute_key(bbuf, blen, EC_KEY_get0_public_key(a), b, KDF1_SHA1); @@ -344,7 +346,8 @@ ecdh_kat(BIO *out, const char *cname, int nid, Ztmplen = ECDH_size(key1); if (Ztmplen != Zlen) goto err; - Ztmp = malloc(Ztmplen); + if ((Ztmp = malloc(Ztmplen)) == NULL) + goto err; if (!ECDH_compute_key(Ztmp, Ztmplen, EC_KEY_get0_public_key(key2), key1, 0)) goto err; diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index a236971f2..c635ede8b 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.394 2023/04/26 02:38:08 asou Exp $ +.\" $OpenBSD: ifconfig.8,v 1.395 2023/05/16 14:32:54 jan Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: April 26 2023 $ +.Dd $Mdocdate: May 16 2023 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -282,8 +282,18 @@ tag. As CSUM_TCPv4, but supports IPv6 datagrams. .It Sy CSUM_UDPv6 As above, for UDP. -.It Sy TSO -The device supports TCP segment offloading (TSO). +.It Sy LRO +The device supports TCP large receive offload (LRO). +.It Sy TSOv4 +The device supports IPv4 TCP segmentation offload (TSO). +TSO is used by default. +Use the +.Xr sysctl 8 +variable +.Va net.inet.tcp.tso +to disable this feature. +.It Sy TSOv6 +As above, for IPv6. .It Sy WOL The device supports Wake on LAN (WoL). .It Sy hardmtu @@ -491,25 +501,25 @@ Query and display information and diagnostics from GBIC and SFP modules installed in an interface. It is only supported by drivers implementing the necessary functionality on hardware which supports it. -.It Cm tso -Enable TCP segmentation offloading (TSO) if it's supported by the hardware; see +.It Cm tcprecvoffload +Enable TCP large receive offload (LRO) if it's supported by the hardware; see .Cm hwfeatures . -TSO enabled NICs modify received TCP/IP packets. +LRO enabled network interfaces modify received TCP/IP packets. This will also affect traffic of upper layer interfaces, such as .Xr vlan 4 , .Xr aggr 4 , and .Xr carp 4 . -It is not possible to use TSO with interfaces attached to a +It is not possible to use LRO with interfaces attached to a .Xr bridge 4 , .Xr veb 4 , or .Xr tpmr 4 . Changing this option will re-initialize the network interface. -.It Cm -tso -Disable TSO. -TSO is disabled by default. +.It Cm -tcprecvoffload +Disable LRO. +LRO is disabled by default. .It Cm up Mark an interface .Dq up . diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 0785b90f9..5dc9ea641 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.463 2023/05/12 18:24:13 jan Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.464 2023/05/16 14:32:54 jan Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -126,7 +126,7 @@ #define HWFEATURESBITS \ "\024\1CSUM_IPv4\2CSUM_TCPv4\3CSUM_UDPv4" \ "\5VLAN_MTU\6VLAN_HWTAGGING\10CSUM_TCPv6" \ - "\11CSUM_UDPv6\17TSO\20WOL" + "\11CSUM_UDPv6\15TSOv4\16TSOv6\17LRO\20WOL" struct ifencap { unsigned int ife_flags; @@ -469,8 +469,8 @@ const struct cmd { { "-soii", IFXF_INET6_NOSOII, 0, setifxflags }, { "monitor", IFXF_MONITOR, 0, setifxflags }, { "-monitor", -IFXF_MONITOR, 0, setifxflags }, - { "tso", IFXF_TSO, 0, setifxflags }, - { "-tso", -IFXF_TSO, 0, setifxflags }, + { "tcprecvoffload", IFXF_LRO, 0, setifxflags }, + { "-tcprecvoffload", -IFXF_LRO, 0, setifxflags }, #ifndef SMALL { "hwfeatures", NEXTARG0, 0, printifhwfeatures }, { "metric", NEXTARG, 0, setifmetric }, @@ -674,7 +674,7 @@ const struct cmd { "\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX" \ "\15LINK0\16LINK1\17LINK2\20MULTICAST" \ "\23AUTOCONF6TEMP\24MPLS\25WOL\26AUTOCONF6\27INET6_NOSOII" \ - "\30AUTOCONF4" "\31MONITOR" "\32TSO" + "\30AUTOCONF4" "\31MONITOR" "\32LRO" int getinfo(struct ifreq *, int); void getsock(int); diff --git a/sys/arch/arm64/arm64/trap.c b/sys/arch/arm64/arm64/trap.c index 78d1857f3..d7f0d84a9 100644 --- a/sys/arch/arm64/arm64/trap.c +++ b/sys/arch/arm64/arm64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.44 2023/04/26 12:30:24 kettenis Exp $ */ +/* $OpenBSD: trap.c,v 1.45 2023/05/15 15:02:06 kettenis Exp $ */ /*- * Copyright (c) 2014 Andrew Turner * All rights reserved. @@ -94,7 +94,7 @@ udata_abort(struct trapframe *frame, uint64_t esr, uint64_t far, int exe) switch (esr & ISS_DATA_DFSC_MASK) { case ISS_DATA_DFSC_ALIGN: sv.sival_ptr = (void *)far; - trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv); + trapsignal(p, SIGBUS, esr, BUS_ADRALN, sv); return; default: break; @@ -132,7 +132,7 @@ udata_abort(struct trapframe *frame, uint64_t esr, uint64_t far, int exe) code = SEGV_MAPERR; } sv.sival_ptr = (void *)far; - trapsignal(p, sig, 0, code, sv); + trapsignal(p, sig, esr, code, sv); } static void @@ -275,7 +275,7 @@ do_el0_sync(struct trapframe *frame) case EXCP_UNKNOWN: curcpu()->ci_flush_bp(); sv.sival_ptr = (void *)frame->tf_elr; - trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); + trapsignal(p, SIGILL, esr, ILL_ILLOPC, sv); break; case EXCP_FP_SIMD: case EXCP_TRAP_FP: @@ -284,7 +284,7 @@ do_el0_sync(struct trapframe *frame) case EXCP_BRANCH_TGT: curcpu()->ci_flush_bp(); sv.sival_ptr = (void *)frame->tf_elr; - trapsignal(p, SIGILL, 0, ILL_ILLOPC, sv); + trapsignal(p, SIGILL, esr, ILL_ILLOPC, sv); break; case EXCP_SVC: svc_handler(frame); @@ -295,23 +295,23 @@ do_el0_sync(struct trapframe *frame) case EXCP_PC_ALIGN: curcpu()->ci_flush_bp(); sv.sival_ptr = (void *)frame->tf_elr; - trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv); + trapsignal(p, SIGBUS, esr, BUS_ADRALN, sv); break; case EXCP_SP_ALIGN: curcpu()->ci_flush_bp(); sv.sival_ptr = (void *)frame->tf_sp; - trapsignal(p, SIGBUS, 0, BUS_ADRALN, sv); + trapsignal(p, SIGBUS, esr, BUS_ADRALN, sv); break; case EXCP_DATA_ABORT_L: udata_abort(frame, esr, far, 0); break; case EXCP_BRK: sv.sival_ptr = (void *)frame->tf_elr; - trapsignal(p, SIGTRAP, 0, TRAP_BRKPT, sv); + trapsignal(p, SIGTRAP, esr, TRAP_BRKPT, sv); break; case EXCP_SOFTSTP_EL0: sv.sival_ptr = (void *)frame->tf_elr; - trapsignal(p, SIGTRAP, 0, TRAP_TRACE, sv); + trapsignal(p, SIGTRAP, esr, TRAP_TRACE, sv); break; default: // panic("Unknown userland exception %x esr_el1 %lx", exception, diff --git a/sys/dev/pci/if_ix.c b/sys/dev/pci/if_ix.c index 870c3349f..8bf3ef494 100644 --- a/sys/dev/pci/if_ix.c +++ b/sys/dev/pci/if_ix.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ix.c,v 1.193 2023/04/28 10:18:57 bluhm Exp $ */ +/* $OpenBSD: if_ix.c,v 1.194 2023/05/16 14:32:54 jan Exp $ */ /****************************************************************************** @@ -1925,7 +1925,7 @@ ixgbe_setup_interface(struct ix_softc *sc) ifp->if_capabilities |= IFCAP_CSUM_IPv4; if (sc->hw.mac.type != ixgbe_mac_82598EB) - ifp->if_capabilities |= IFCAP_TSO; + ifp->if_capabilities |= IFCAP_LRO; /* * Specify the media types supported by this sc and register @@ -2873,13 +2873,13 @@ ixgbe_initialize_receive_units(struct ix_softc *sc) hlreg |= IXGBE_HLREG0_JUMBOEN; IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg); - if (ISSET(ifp->if_xflags, IFXF_TSO)) { + if (ISSET(ifp->if_xflags, IFXF_LRO)) { rdrxctl = IXGBE_READ_REG(hw, IXGBE_RDRXCTL); /* This field has to be set to zero. */ rdrxctl &= ~IXGBE_RDRXCTL_RSCFRSTSIZE; - /* Enable TSO Receive Offloading */ + /* RSC Coalescing on ACK Change */ rdrxctl |= IXGBE_RDRXCTL_RSCACKC; rdrxctl |= IXGBE_RDRXCTL_FCOE_WRFIX; @@ -2902,10 +2902,10 @@ ixgbe_initialize_receive_units(struct ix_softc *sc) srrctl = bufsz | IXGBE_SRRCTL_DESCTYPE_ADV_ONEBUF; IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(i), srrctl); - if (ISSET(ifp->if_xflags, IFXF_TSO)) { + if (ISSET(ifp->if_xflags, IFXF_LRO)) { rdrxctl = IXGBE_READ_REG(&sc->hw, IXGBE_RSCCTL(i)); - /* Enable TSO Receive Side Coalescing */ + /* Enable Receive Side Coalescing */ rdrxctl |= IXGBE_RSCCTL_RSCEN; rdrxctl |= IXGBE_RSCCTL_MAXDESC_16; @@ -3263,7 +3263,7 @@ ixgbe_setup_vlan_hw_support(struct ix_softc *sc) * We have to disable VLAN striping when using TCP offloading, due to a * firmware bug. */ - if (ISSET(ifp->if_xflags, IFXF_TSO)) { + if (ISSET(ifp->if_xflags, IFXF_LRO)) { sc->vlan_stripping = 0; return; } diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c index 3b5c0bbbc..aa38e09d0 100644 --- a/sys/kern/uipc_domain.c +++ b/sys/kern/uipc_domain.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_domain.c,v 1.61 2023/05/04 09:40:36 mvs Exp $ */ +/* $OpenBSD: uipc_domain.c,v 1.62 2023/05/16 19:36:00 mvs Exp $ */ /* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */ /* @@ -244,10 +244,12 @@ net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, protocol = name[1]; for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_protocol == protocol && pr->pr_sysctl) { - KERNEL_LOCK(); + if ((pr->pr_flags & PR_MPSYSCTL) == 0) + KERNEL_LOCK(); error = (*pr->pr_sysctl)(name + 2, namelen - 2, oldp, oldlenp, newp, newlen); - KERNEL_UNLOCK(); + if ((pr->pr_flags & PR_MPSYSCTL) == 0) + KERNEL_UNLOCK(); return (error); } return (ENOPROTOOPT); diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index 6f0ea19b0..440a1ec5e 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.285 2023/05/05 01:19:51 bluhm Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.286 2023/05/16 20:09:27 mvs Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -1801,7 +1801,7 @@ sysctl_mq(int *name, u_int namelen, void *oldp, size_t *oldlenp, case IFQCTL_MAXLEN: maxlen = mq->mq_maxlen; error = sysctl_int(oldp, oldlenp, newp, newlen, &maxlen); - if (!error && maxlen != mq->mq_maxlen) + if (error == 0) mq_set_maxlen(mq, maxlen); return (error); case IFQCTL_DROPS: diff --git a/sys/net/if.c b/sys/net/if.c index 855e5dfc9..ae1069b40 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.696 2023/05/14 01:46:53 dlg Exp $ */ +/* $OpenBSD: if.c,v 1.697 2023/05/16 14:32:54 jan Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -2109,10 +2109,9 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) error = ENOTSUP; } #endif - - if (ISSET(ifr->ifr_flags, IFXF_TSO) != - ISSET(ifp->if_xflags, IFXF_TSO)) - error = ifsettso(ifp, ISSET(ifr->ifr_flags, IFXF_TSO)); + if (ISSET(ifr->ifr_flags, IFXF_LRO) != + ISSET(ifp->if_xflags, IFXF_LRO)) + error = ifsetlro(ifp, ISSET(ifr->ifr_flags, IFXF_LRO)); if (error == 0) ifp->if_xflags = (ifp->if_xflags & IFXF_CANTCHANGE) | @@ -3153,37 +3152,33 @@ ifpromisc(struct ifnet *ifp, int pswitch) return (error); } -/* Set/clear TSO flag and restart interface if needed. */ +/* Set/clear LRO flag and restart interface if needed. */ int -ifsettso(struct ifnet *ifp, int on) +ifsetlro(struct ifnet *ifp, int on) { struct ifreq ifrq; int error = 0; int s = splnet(); + if (!ISSET(ifp->if_capabilities, IFCAP_LRO)) { + error = ENOTSUP; + goto out; + } + NET_ASSERT_LOCKED(); /* for ioctl */ KERNEL_ASSERT_LOCKED(); /* for if_flags */ - if (on && !ISSET(ifp->if_xflags, IFXF_TSO)) { - if (!ISSET(ifp->if_capabilities, IFCAP_TSO)) { - error = ENOTSUP; - goto out; - } + if (on && !ISSET(ifp->if_xflags, IFXF_LRO)) { if (ether_brport_isset(ifp)) { error = EBUSY; goto out; } - SET(ifp->if_xflags, IFXF_TSO); - } else if (!on && ISSET(ifp->if_xflags, IFXF_TSO)) - CLR(ifp->if_xflags, IFXF_TSO); + SET(ifp->if_xflags, IFXF_LRO); + } else if (!on && ISSET(ifp->if_xflags, IFXF_LRO)) + CLR(ifp->if_xflags, IFXF_LRO); else goto out; -#if NVLAN > 0 - /* Change TSO flag also on attached vlan(4) interfaces. */ - vlan_flags_from_parent(ifp, IFXF_TSO); -#endif - /* restart interface */ if (ISSET(ifp->if_flags, IFF_UP)) { /* go down for a moment... */ diff --git a/sys/net/if.h b/sys/net/if.h index 757ff96f1..189ce873c 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.211 2023/03/07 20:09:48 jan Exp $ */ +/* $OpenBSD: if.h,v 1.213 2023/05/16 14:32:54 jan Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -231,7 +231,7 @@ struct if_status_description { #define IFXF_INET6_NOSOII 0x40 /* [N] don't do RFC 7217 */ #define IFXF_AUTOCONF4 0x80 /* [N] v4 autoconf (aka dhcp) enabled */ #define IFXF_MONITOR 0x100 /* [N] only used for bpf */ -#define IFXF_TSO 0x200 /* [N] TCP segment offloading */ +#define IFXF_LRO 0x200 /* [N] TCP large recv offload */ #define IFXF_CANTCHANGE \ (IFXF_MPSAFE|IFXF_CLONED) @@ -251,7 +251,9 @@ struct if_status_description { #define IFCAP_VLAN_HWTAGGING 0x00000020 /* hardware VLAN tag support */ #define IFCAP_CSUM_TCPv6 0x00000080 /* can do IPv6/TCP checksums */ #define IFCAP_CSUM_UDPv6 0x00000100 /* can do IPv6/UDP checksums */ -#define IFCAP_TSO 0x00004000 /* TCP segment offloading */ +#define IFCAP_TSOv4 0x00001000 /* IPv4/TCP segment offload */ +#define IFCAP_TSOv6 0x00002000 /* IPv6/TCP segment offload */ +#define IFCAP_LRO 0x00004000 /* TCP large recv offload */ #define IFCAP_WOL 0x00008000 /* can do wake on lan */ #define IFCAP_CSUM_MASK (IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 | \ @@ -544,7 +546,7 @@ void if_getdata(struct ifnet *, struct if_data *); void ifinit(void); int ifioctl(struct socket *, u_long, caddr_t, struct proc *); int ifpromisc(struct ifnet *, int); -int ifsettso(struct ifnet *, int); +int ifsetlro(struct ifnet *, int); struct ifg_group *if_creategroup(const char *); int if_addgroup(struct ifnet *, const char *); int if_delgroup(struct ifnet *, const char *); diff --git a/sys/net/if_aggr.c b/sys/net/if_aggr.c index a7a5ac9d7..5240643d9 100644 --- a/sys/net/if_aggr.c +++ b/sys/net/if_aggr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_aggr.c,v 1.39 2022/02/05 03:56:16 dlg Exp $ */ +/* $OpenBSD: if_aggr.c,v 1.40 2023/05/16 14:32:54 jan Exp $ */ /* * Copyright (c) 2019 The University of Queensland @@ -2618,6 +2618,9 @@ aggr_update_capabilities(struct aggr_softc *sc) uint32_t capabilities = ~0; int set = 0; + /* Do not inherit LRO capabilities. */ + CLR(capabilities, IFCAP_LRO); + rw_enter_read(&sc->sc_lock); TAILQ_FOREACH(p, &sc->sc_ports, p_entry) { struct ifnet *ifp0 = p->p_ifp0; diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index a5ad2281a..486b041bc 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.367 2023/05/13 13:35:17 bluhm Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.368 2023/05/16 14:32:54 jan Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -338,7 +338,7 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) */ NET_LOCK(); - ifsettso(ifs, 0); + ifsetlro(ifs, 0); NET_UNLOCK(); bif->bridge_sc = sc; @@ -401,7 +401,7 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } NET_LOCK(); - ifsettso(ifs, 0); + ifsetlro(ifs, 0); NET_UNLOCK(); bif->bridge_sc = sc; diff --git a/sys/net/if_tpmr.c b/sys/net/if_tpmr.c index 9f2b2dec1..47bb4e5ca 100644 --- a/sys/net/if_tpmr.c +++ b/sys/net/if_tpmr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tpmr.c,v 1.32 2023/02/27 09:35:32 jan Exp $ */ +/* $OpenBSD: if_tpmr.c,v 1.33 2023/05/16 14:32:54 jan Exp $ */ /* * Copyright (c) 2019 The University of Queensland @@ -521,7 +521,7 @@ tpmr_add_port(struct tpmr_softc *sc, const struct ifbreq *req) goto put; } - ifsettso(ifp0, 0); + ifsetlro(ifp0, 0); p->p_ifp0 = ifp0; p->p_tpmr = sc; diff --git a/sys/net/if_veb.c b/sys/net/if_veb.c index c5f865b71..df405678f 100644 --- a/sys/net/if_veb.c +++ b/sys/net/if_veb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_veb.c,v 1.30 2023/02/27 09:35:32 jan Exp $ */ +/* $OpenBSD: if_veb.c,v 1.31 2023/05/16 14:32:54 jan Exp $ */ /* * Copyright (c) 2021 David Gwynne @@ -1465,7 +1465,7 @@ veb_add_port(struct veb_softc *sc, const struct ifbreq *req, unsigned int span) goto put; } - ifsettso(ifp0, 0); + ifsetlro(ifp0, 0); p->p_ifp0 = ifp0; p->p_veb = sc; diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 86bb5a757..d660232de 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.214 2023/04/26 00:14:21 jan Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.215 2023/05/16 14:32:54 jan Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -536,7 +536,8 @@ vlan_up(struct vlan_softc *sc) * Chips that can do hardware-assisted VLAN encapsulation, can * calculate the correct checksum for VLAN tagged packets. */ - ifp->if_capabilities = ifp0->if_capabilities & IFCAP_CSUM_MASK; + ifp->if_capabilities = ifp0->if_capabilities & + (IFCAP_CSUM_MASK | IFCAP_TSOv4 | IFCAP_TSOv6); } /* commit the sc */ @@ -560,9 +561,6 @@ vlan_up(struct vlan_softc *sc) /* configure the parent to handle packets for this vlan */ vlan_multi_apply(sc, ifp0, SIOCADDMULTI); - /* Inherit flags from parent interface. */ - vlan_flags_from_parent(ifp0, IFXF_TSO); - /* we're running now */ SET(ifp->if_flags, IFF_RUNNING); vlan_link_state(sc, ifp0->if_link_state, ifp0->if_baudrate); @@ -965,28 +963,6 @@ vlan_del_parent(struct vlan_softc *sc) return (0); } -void -vlan_flags_from_parent(struct ifnet *ifp0, int flags) -{ - struct vlan_softc *sc; - int i; - - for (i = 0; i < TAG_HASH_SIZE; i++) { - SMR_SLIST_FOREACH_LOCKED(sc, &vlan_tagh[i], sc_list) { - /* vlan and tso only works with hw tagging */ - if (!ISSET(ifp0->if_capabilities, IFCAP_VLAN_HWTAGGING)) - CLR(flags, IFXF_TSO); - - if (sc->sc_ifidx0 == ifp0->if_index) { - if (ISSET(ifp0->if_xflags, flags)) - SET(sc->sc_if.if_xflags, flags); - else - CLR(sc->sc_if.if_xflags, flags); - } - } - } -} - int vlan_set_compat(struct ifnet *ifp, struct ifreq *ifr) { diff --git a/sys/net/pf.c b/sys/net/pf.c index 7c395644c..81939d45c 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.1179 2023/05/13 13:35:17 bluhm Exp $ */ +/* $OpenBSD: pf.c,v 1.1180 2023/05/15 16:34:56 bluhm Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -6555,15 +6555,9 @@ pf_route(struct pf_pdesc *pd, struct pf_state *st) goto done; } - if (ISSET(m0->m_pkthdr.csum_flags, M_TCP_TSO) && - m0->m_pkthdr.ph_mss <= ifp->if_mtu) { - if (tcp_chopper(m0, &ml, ifp, m0->m_pkthdr.ph_mss) || - if_output_ml(ifp, &ml, sintosa(dst), rt)) - goto done; - tcpstat_inc(tcps_outswtso); + if (tcp_if_output_tso(ifp, &m0, sintosa(dst), rt, + IFCAP_TSOv4, ifp->if_mtu) || m0 == NULL) goto done; - } - CLR(m0->m_pkthdr.csum_flags, M_TCP_TSO); /* * Too large for interface; fragment if possible. @@ -6598,7 +6592,6 @@ void pf_route6(struct pf_pdesc *pd, struct pf_state *st) { struct mbuf *m0; - struct mbuf_list ml; struct sockaddr_in6 *dst, sin6; struct rtentry *rt = NULL; struct ip6_hdr *ip6; @@ -6696,15 +6689,9 @@ pf_route6(struct pf_pdesc *pd, struct pf_state *st) goto done; } - if (ISSET(m0->m_pkthdr.csum_flags, M_TCP_TSO) && - m0->m_pkthdr.ph_mss <= ifp->if_mtu) { - if (tcp_chopper(m0, &ml, ifp, m0->m_pkthdr.ph_mss) || - if_output_ml(ifp, &ml, sin6tosa(dst), rt)) - goto done; - tcpstat_inc(tcps_outswtso); + if (tcp_if_output_tso(ifp, &m0, sin6tosa(dst), rt, + IFCAP_TSOv6, ifp->if_mtu) || m0 == NULL) goto done; - } - CLR(m0->m_pkthdr.csum_flags, M_TCP_TSO); ip6stat_inc(ip6s_cantfrag); if (st->rt != PF_DUPTO) diff --git a/sys/netinet/in_proto.c b/sys/netinet/in_proto.c index c4087a7a9..2a49df55c 100644 --- a/sys/netinet/in_proto.c +++ b/sys/netinet/in_proto.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_proto.c,v 1.99 2022/08/15 09:11:38 mvs Exp $ */ +/* $OpenBSD: in_proto.c,v 1.100 2023/05/16 19:36:00 mvs Exp $ */ /* $NetBSD: in_proto.c,v 1.14 1996/02/18 18:58:32 christos Exp $ */ /* @@ -177,6 +177,7 @@ u_char ip_protox[IPPROTO_MAX]; const struct protosw inetsw[] = { { .pr_domain = &inetdomain, + .pr_flags = PR_MPSYSCTL, .pr_init = ip_init, .pr_slowtimo = ip_slowtimo, .pr_sysctl = ip_sysctl diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 519de95e4..064c44249 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_carp.c,v 1.356 2023/03/08 04:43:09 guenther Exp $ */ +/* $OpenBSD: ip_carp.c,v 1.357 2023/05/16 14:32:54 jan Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff. All rights reserved. @@ -1693,7 +1693,7 @@ carp_set_ifp(struct carp_softc *sc, struct ifnet *ifp0) sc->sc_carpdevidx = ifp0->if_index; sc->sc_if.if_capabilities = ifp0->if_capabilities & - IFCAP_CSUM_MASK; + (IFCAP_CSUM_MASK | IFCAP_TSOv4 | IFCAP_TSOv6); SRPL_FOREACH_LOCKED(vr, cif, sc_list) { struct carp_vhost_entry *vrhead, *schead; diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 42c1c72d7..cfa703cca 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.383 2023/04/05 21:51:47 bluhm Exp $ */ +/* $OpenBSD: ip_input.c,v 1.384 2023/05/16 19:36:00 mvs Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1704,8 +1704,11 @@ ip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (ip_sysctl_ipstat(oldp, oldlenp, newp)); #ifdef MROUTING case IPCTL_MRTSTATS: - return (sysctl_rdstruct(oldp, oldlenp, newp, - &mrtstat, sizeof(mrtstat))); + KERNEL_LOCK(); + error = sysctl_rdstruct(oldp, oldlenp, newp, + &mrtstat, sizeof(mrtstat)); + KERNEL_UNLOCK(); + return (error); case IPCTL_MRTMFC: if (newp) return (EPERM); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 394da08ad..a44ee063d 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.386 2023/05/13 13:35:17 bluhm Exp $ */ +/* $OpenBSD: ip_output.c,v 1.387 2023/05/15 16:34:56 bluhm Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -460,15 +460,10 @@ sendit: goto done; } - if (ISSET(m->m_pkthdr.csum_flags, M_TCP_TSO) && - m->m_pkthdr.ph_mss <= mtu) { - if ((error = tcp_chopper(m, &ml, ifp, m->m_pkthdr.ph_mss)) || - (error = if_output_ml(ifp, &ml, sintosa(dst), ro->ro_rt))) - goto done; - tcpstat_inc(tcps_outswtso); + error = tcp_if_output_tso(ifp, &m, sintosa(dst), ro->ro_rt, + IFCAP_TSOv4, mtu); + if (error || m == NULL) goto done; - } - CLR(m->m_pkthdr.csum_flags, M_TCP_TSO); /* * Too large for interface; fragment if possible. @@ -1887,10 +1882,15 @@ in_proto_cksum_out(struct mbuf *m, struct ifnet *ifp) u_int16_t csum = 0, offset; offset = ip->ip_hl << 2; - if (m->m_pkthdr.csum_flags & (M_TCP_CSUM_OUT|M_UDP_CSUM_OUT)) + if (ISSET(m->m_pkthdr.csum_flags, M_TCP_TSO)) { + csum = in_cksum_phdr(ip->ip_src.s_addr, + ip->ip_dst.s_addr, htonl(ip->ip_p)); + } else if (ISSET(m->m_pkthdr.csum_flags, + M_TCP_CSUM_OUT|M_UDP_CSUM_OUT)) { csum = in_cksum_phdr(ip->ip_src.s_addr, ip->ip_dst.s_addr, htonl(ntohs(ip->ip_len) - offset + ip->ip_p)); + } if (ip->ip_p == IPPROTO_TCP) offset += offsetof(struct tcphdr, th_sum); else if (ip->ip_p == IPPROTO_UDP) diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 752b485ba..c7111b143 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_output.c,v 1.137 2023/05/13 13:35:18 bluhm Exp $ */ +/* $OpenBSD: tcp_output.c,v 1.138 2023/05/15 16:34:56 bluhm Exp $ */ /* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */ /* @@ -80,6 +80,7 @@ #include #include +#include #include #if NPF > 0 #include @@ -753,7 +754,7 @@ send: /* Enable TSO and specify the size of the resulting segments. */ if (tso) { - m->m_pkthdr.csum_flags |= M_TCP_TSO; + SET(m->m_pkthdr.csum_flags, M_TCP_TSO); m->m_pkthdr.ph_mss = tp->t_maxseg; } @@ -1349,3 +1350,45 @@ tcp_chopper(struct mbuf *m0, struct mbuf_list *ml, struct ifnet *ifp, ml_purge(ml); return error; } + +int +tcp_if_output_tso(struct ifnet *ifp, struct mbuf **mp, struct sockaddr *dst, + struct rtentry *rt, uint32_t ifcap, u_int mtu) +{ + struct mbuf_list ml; + int error; + + /* caller must fail later or fragment */ + if (!ISSET((*mp)->m_pkthdr.csum_flags, M_TCP_TSO)) + return 0; + if ((*mp)->m_pkthdr.ph_mss > mtu) { + CLR((*mp)->m_pkthdr.csum_flags, M_TCP_TSO); + return 0; + } + + /* network interface hardware will do TSO */ + if (in_ifcap_cksum(*mp, ifp, ifcap)) { + if (ISSET(ifcap, IFCAP_TSOv4)) { + in_hdr_cksum_out(*mp, ifp); + in_proto_cksum_out(*mp, ifp); + } +#ifdef INET6 + if (ISSET(ifcap, IFCAP_TSOv6)) + in6_proto_cksum_out(*mp, ifp); +#endif + error = ifp->if_output(ifp, *mp, dst, rt); + if (!error) + tcpstat_inc(tcps_outhwtso); + goto done; + } + + /* as fallback do TSO in software */ + if ((error = tcp_chopper(*mp, &ml, ifp, (*mp)->m_pkthdr.ph_mss)) || + (error = if_output_ml(ifp, &ml, dst, rt))) + goto done; + tcpstat_inc(tcps_outswtso); + + done: + *mp = NULL; + return error; +} diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index d8cfc12c5..fc64e1187 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_var.h,v 1.164 2023/05/10 12:07:16 bluhm Exp $ */ +/* $OpenBSD: tcp_var.h,v 1.165 2023/05/15 16:34:56 bluhm Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* @@ -719,6 +719,8 @@ struct tcpcb * void tcp_notify(struct inpcb *, int); int tcp_output(struct tcpcb *); int tcp_chopper(struct mbuf *, struct mbuf_list *, struct ifnet *, u_int); +int tcp_if_output_tso(struct ifnet *, struct mbuf **, struct sockaddr *, + struct rtentry *, uint32_t, u_int); void tcp_pulloutofband(struct socket *, u_int, struct mbuf *, int); int tcp_reass(struct tcpcb *, struct tcphdr *, struct mbuf *, int *); void tcp_rscale(struct tcpcb *, u_long); diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index b14ffbe41..add8fb22c 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.275 2023/05/10 12:07:17 bluhm Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.276 2023/05/15 16:34:57 bluhm Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -706,15 +706,10 @@ reroute: goto done; } - if (ISSET(m->m_pkthdr.csum_flags, M_TCP_TSO) && - m->m_pkthdr.ph_mss <= mtu) { - if ((error = tcp_chopper(m, &ml, ifp, m->m_pkthdr.ph_mss)) || - (error = if_output_ml(ifp, &ml, sin6tosa(dst), ro->ro_rt))) - goto done; - tcpstat_inc(tcps_outswtso); + error = tcp_if_output_tso(ifp, &m, sin6tosa(dst), ro->ro_rt, + IFCAP_TSOv6, mtu); + if (error || m == NULL) goto done; - } - CLR(m->m_pkthdr.csum_flags, M_TCP_TSO); /* * try to fragment the packet. case 1-b @@ -2715,8 +2710,13 @@ in6_proto_cksum_out(struct mbuf *m, struct ifnet *ifp) u_int16_t csum; offset = ip6_lasthdr(m, 0, IPPROTO_IPV6, &nxt); - csum = in6_cksum_phdr(&ip6->ip6_src, &ip6->ip6_dst, - htonl(m->m_pkthdr.len - offset), htonl(nxt)); + if (ISSET(m->m_pkthdr.csum_flags, M_TCP_TSO)) { + csum = in6_cksum_phdr(&ip6->ip6_src, &ip6->ip6_dst, + htonl(0), htonl(nxt)); + } else { + csum = in6_cksum_phdr(&ip6->ip6_src, &ip6->ip6_dst, + htonl(m->m_pkthdr.len - offset), htonl(nxt)); + } if (nxt == IPPROTO_TCP) offset += offsetof(struct tcphdr, th_sum); else if (nxt == IPPROTO_UDP) diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 476b4bac1..549e2d046 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -1,4 +1,4 @@ -/* $OpenBSD: protosw.h,v 1.59 2022/11/26 17:52:35 mvs Exp $ */ +/* $OpenBSD: protosw.h,v 1.61 2023/05/16 19:44:55 mvs Exp $ */ /* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */ /*- @@ -115,22 +115,24 @@ struct protosw { int (*pr_sysctl)(int *, u_int, void *, size_t *, void *, size_t); }; -#define PR_SLOWHZ 2 /* 2 slow timeouts per second */ -#define PR_FASTHZ 5 /* 5 fast timeouts per second */ +#define PR_SLOWHZ 2 /* 2 slow timeouts per second */ +#define PR_FASTHZ 5 /* 5 fast timeouts per second */ /* * Values for pr_flags. * PR_ADDR requires PR_ATOMIC; * PR_ADDR and PR_CONNREQUIRED are mutually exclusive. */ -#define PR_ATOMIC 0x01 /* exchange atomic messages only */ -#define PR_ADDR 0x02 /* addresses given with messages */ -#define PR_CONNREQUIRED 0x04 /* connection required by protocol */ -#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */ -#define PR_RIGHTS 0x10 /* passes capabilities */ -#define PR_ABRTACPTDIS 0x20 /* abort on accept(2) to disconnected +#define PR_ATOMIC 0x0001 /* exchange atomic messages only */ +#define PR_ADDR 0x0002 /* addresses given with messages */ +#define PR_CONNREQUIRED 0x0004 /* connection required by protocol */ +#define PR_WANTRCVD 0x0008 /* want PRU_RCVD calls */ +#define PR_RIGHTS 0x0010 /* passes capabilities */ +#define PR_ABRTACPTDIS 0x0020 /* abort on accept(2) to disconnected socket */ -#define PR_SPLICE 0x40 /* socket splicing is possible */ +#define PR_SPLICE 0x0040 /* socket splicing is possible */ +#define PR_MPSYSCTL 0x0080 /* (*pr_sysctl)() doesn't require + kernel lock */ /* * The arguments to usrreq are: diff --git a/usr.bin/calendar/calendars/calendar.canada b/usr.bin/calendar/calendars/calendar.canada index 33acf018a..602eabf7a 100644 --- a/usr.bin/calendar/calendars/calendar.canada +++ b/usr.bin/calendar/calendars/calendar.canada @@ -1,7 +1,7 @@ /* * Canada holiday * - * $OpenBSD: calendar.canada,v 1.2 2013/03/16 07:52:29 jmc Exp $ + * $OpenBSD: calendar.canada,v 1.3 2023/05/15 16:22:07 jmc Exp $ */ #ifndef _calendar_canada_ @@ -19,7 +19,7 @@ Easter-2 Good Friday (Statutory holiday) Easter+1 Easter Monday 05/SunSecond Mother's Day (2nd Sunday of May) /* Holds up to and including 2015 */ -05/MonThird* Victoria Day (Monday on or immediately before May 24) +05/Mon-2 Victoria Day (Monday on or immediately before May 24) 06/SunThird Father's Day (3rd Sunday of June) 06/21* Summer Solstice 06/24 St-Jean Baptiste diff --git a/usr.bin/calendar/calendars/calendar.uk b/usr.bin/calendar/calendars/calendar.uk index d8aff2805..55d0cc68a 100644 --- a/usr.bin/calendar/calendars/calendar.uk +++ b/usr.bin/calendar/calendars/calendar.uk @@ -1,7 +1,7 @@ /* * United Kingdom (UK) calendar * - * $OpenBSD: calendar.uk,v 1.2 2018/11/21 14:50:28 jmc Exp $ + * $OpenBSD: calendar.uk,v 1.3 2023/05/15 16:22:07 jmc Exp $ */ #ifndef _calendar_uk_ @@ -21,7 +21,6 @@ Easter-21 Mothering Sunday (Sunday 3 weeks before Easter Sunday) Easter-2 Good Friday (bank holiday) Easter+1 Easter Monday (bank holiday - except Scotland) 05/MonFirst Early May bank holiday -05/MonThird* Victoria Day in Scotland (Monday on or immediately before 24th May) 05/MonLast Spring Bank Holiday 06/SunThird Father's Day (3rd Sunday of June) 06/21* Summer Solstice diff --git a/usr.bin/calendar/calendars/calendar.usholiday b/usr.bin/calendar/calendars/calendar.usholiday index a43781989..138205b43 100644 --- a/usr.bin/calendar/calendars/calendar.usholiday +++ b/usr.bin/calendar/calendars/calendar.usholiday @@ -1,7 +1,7 @@ /* * USA holiday * - * $OpenBSD: calendar.usholiday,v 1.9 2015/01/19 18:07:47 tedu Exp $ + * $OpenBSD: calendar.usholiday,v 1.10 2023/05/15 10:36:08 bentley Exp $ */ #ifndef _calendar_usholiday_ @@ -22,6 +22,7 @@ 05/SatThird Armed Forces Day (3rd Saturday of May) 05/MonLast Memorial Day (Last Monday of May) 06/SunThird Father's Day (3rd Sunday of June) +06/19 Juneteenth 06/21* Summer Solstice 07/04 Independence Day 09/MonFirst Labor Day (1st Monday of September) diff --git a/usr.sbin/acme-client/acme-client.1 b/usr.sbin/acme-client/acme-client.1 index 403e161dd..5af7f5f3d 100644 --- a/usr.sbin/acme-client/acme-client.1 +++ b/usr.sbin/acme-client/acme-client.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: acme-client.1,v 1.41 2022/01/21 18:46:21 deraadt Exp $ +.\" $OpenBSD: acme-client.1,v 1.42 2023/05/16 09:02:50 espie Exp $ .\" .\" Copyright (c) 2016 Kristaps Dzonsons .\" @@ -14,7 +14,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: January 21 2022 $ +.Dd $Mdocdate: May 16 2023 $ .Dt ACME-CLIENT 1 .Os .Sh NAME @@ -151,3 +151,12 @@ The .Nm utility was written by .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv . +.Sh CAVEATS +The usual ACME service providers are notoriously picky about +authenticating rules, and yield fairly long time-outs after just a +few invalid attempts. +It is strongly suggested to first validate a configuration with a +staging server before moving an official certificate validation +workflow to +.Xr crontab 5 +status. diff --git a/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm b/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm index f66aca55f..b0db9da92 100644 --- a/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm +++ b/usr.sbin/pkg_add/OpenBSD/ArcCheck.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: ArcCheck.pm,v 1.37 2022/06/06 06:57:35 espie Exp $ +# $OpenBSD: ArcCheck.pm,v 1.40 2023/05/16 16:55:32 espie Exp $ # # Copyright (c) 2005-2006 Marc Espie # @@ -21,14 +21,16 @@ # between tar balls OpenBSD::Ustar::Object and # packing list OpenBSD::PackingElement -# specifically, during create time, we call prepare_long: -# - prevent a lot of weird objects from entering the archives -# - make sure all relevant users/modes are recorded in the PLIST item +# specifically, during create time: +# $o = $archive->prepare_long($item); +# if (!$o->verify_modes($self)) +# error... +# if (!$o->is_allowed) +# error... -# during extraction: we call validate_meta: -# - make sure complex objects have all their relevant properties recorded -# - disallow extraction of non-files/links. -# - guard against files much longer than they should be. +# during extraction: +# $o->validate_meta($item) or +# error... use strict; use warnings; @@ -41,7 +43,7 @@ use POSIX; sub is_allowed() { 0 } # match archive header link name against actual link name -sub check_linkname +sub _check_linkname { my ($self, $linkname) = @_; my $c = $self->{linkname}; @@ -51,6 +53,12 @@ sub check_linkname return $c eq $linkname; } +sub _errsay +{ + my ($self, @args) = @_; + $self->{archive}{state}->errsay(@args); +} + sub validate_meta { my ($o, $item) = @_; @@ -58,59 +66,59 @@ sub validate_meta $o->{cwd} = $item->cwd; if (defined $item->{symlink} || $o->isSymLink) { if (!defined $item->{symlink}) { - $o->errsay("bogus symlink #1 -> #2", + $o->_errsay("bogus symlink #1 -> #2", $item->name, $o->{linkname}); - $o->errsay("\t(no \@symlink annotation in packing-list)"); + $o->_errsay("\t(no \@symlink annotation in packing-list)"); return 0; } if (!$o->isSymLink) { - $o->errsay("bogus symlink #1 -> #2", + $o->_errsay("bogus symlink #1 -> #2", $item->name, $item->{symlink}); - $o->errsay("\t(not a symlink in the tarball)"); + $o->_errsay("\t(not a symlink in the tarball)"); return 0; } - if (!$o->check_linkname($item->{symlink})) { - $o->errsay("archive symlink does not match #1 != #2", + if (!$o->_check_linkname($item->{symlink})) { + $o->_errsay("archive symlink does not match #1 != #2", $o->{linkname}, $item->{symlink}); return 0; } } elsif (defined $item->{link} || $o->isHardLink) { if (!defined $item->{link}) { - $o->errsay("bogus hardlink #1 -> #2", + $o->_errsay("bogus hardlink #1 -> #2", $item->name, $o->{linkname}); - $o->errsay("\t(no \@link annotation in packing-list)"); + $o->_errsay("\t(no \@link annotation in packing-list)"); return 0; } if (!$o->isHardLink) { - $o->errsay("bogus hardlink #1 -> #2", + $o->_errsay("bogus hardlink #1 -> #2", $item->name, $item->{link}); - $o->errsay("\t(not a link in the tarball)"); + $o->_errsay("\t(not a link in the tarball)"); return 0; } - if (!$o->check_linkname($item->{link})) { - $o->errsay("archive hardlink does not match #1 != #2", + if (!$o->_check_linkname($item->{link})) { + $o->_errsay("archive hardlink does not match #1 != #2", $o->{linkname}, $item->{link}); return 0; } } elsif ($o->isFile) { if (!defined $item->{size}) { - $o->errsay("Error: file #1 does not have recorded size", + $o->_errsay("Error: file #1 does not have recorded size", $item->fullname); return 0; } elsif ($item->{size} != $o->{size}) { - $o->errsay("Error: size does not match for #1", + $o->_errsay("Error: size does not match for #1", $item->fullname); return 0; } } else { - $o->errsay("archive content for #1 should be file", + $o->_errsay("archive content for #1 should be file", $item->name); return 0; } return $o->verify_modes($item); } -sub strip_modes +sub _strip_modes { my ($o, $item) = @_; @@ -139,7 +147,7 @@ sub strip_modes return $result; } -sub printable_mode +sub _printable_mode { my $o = shift; return sprintf("%4o", @@ -153,23 +161,23 @@ sub verify_modes if (!defined $item->{owner}) { if ($o->{uname} ne 'root') { - $o->errsay("Error: no \@owner for #1 (#2)", + $o->_errsay("Error: no \@owner for #1 (#2)", $item->fullname, $o->{uname}); $result = 0; } } if (!defined $item->{group}) { if ($o->{gname} ne 'bin' && $o->{gname} ne 'wheel') { - $o->errsay("Error: no \@group for #1 (#2)", + $o->_errsay("Error: no \@group for #1 (#2)", $item->fullname, $o->{gname}); $result = 0; } } # XXX /1 $o->{mode} &= ~(S_ISUID|S_ISGID); - if ($o->{mode} != $o->strip_modes($o)) { - $o->errsay("Error: weird mode for #1: #2", $item->fullname, - $o->printable_mode); + if ($o->{mode} != $o->_strip_modes($o)) { + $o->_errsay("Error: weird mode for #1: #2", $item->fullname, + $o->_printable_mode); $result = 0; } return $result; @@ -238,7 +246,7 @@ sub prepare_long $item->name, $entry->{gid}); } # XXX /2 - $entry->{mode} = $entry->strip_modes($item) & ~(S_ISUID|S_ISGID); + $entry->{mode} = $entry->_strip_modes($item) & ~(S_ISUID|S_ISGID); if (defined $item->{ts}) { delete $entry->{mtime}; } diff --git a/usr.sbin/pkg_add/OpenBSD/IdCache.pm b/usr.sbin/pkg_add/OpenBSD/IdCache.pm index 78bd4c52d..35324d954 100644 --- a/usr.sbin/pkg_add/OpenBSD/IdCache.pm +++ b/usr.sbin/pkg_add/OpenBSD/IdCache.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: IdCache.pm,v 1.10 2010/12/24 09:04:14 espie Exp $ +# $OpenBSD: IdCache.pm,v 1.11 2023/05/16 14:31:54 espie Exp $ # # Copyright (c) 2002-2005 Marc Espie # @@ -32,7 +32,7 @@ sub lookup if (defined $self->{$name}) { $r = $self->{$name}; } else { - $r = $self->convert($name); + $r = $self->_convert($name); if (!defined $r) { $r = $default; } @@ -59,7 +59,7 @@ sub lookup package OpenBSD::UidCache; our @ISA=qw(OpenBSD::IdCache); -sub convert +sub _convert { my @entry = getpwnam($_[1]); return @entry == 0 ? undef : $entry[2]; @@ -68,7 +68,7 @@ sub convert package OpenBSD::GidCache; our @ISA=qw(OpenBSD::IdCache); -sub convert +sub _convert { my @entry = getgrnam($_[1]); return @entry == 0 ? undef : $entry[2]; @@ -77,7 +77,7 @@ sub convert package OpenBSD::UnameCache; our @ISA=qw(OpenBSD::SimpleIdCache); -sub convert +sub _convert { return getpwuid($_[1]); } @@ -85,7 +85,7 @@ sub convert package OpenBSD::GnameCache; our @ISA=qw(OpenBSD::SimpleIdCache); -sub convert +sub _convert { return getgrgid($_[1]); } diff --git a/usr.sbin/pkg_add/OpenBSD/IdCache.pod b/usr.sbin/pkg_add/OpenBSD/IdCache.pod index e024130f2..dba9910ae 100644 --- a/usr.sbin/pkg_add/OpenBSD/IdCache.pod +++ b/usr.sbin/pkg_add/OpenBSD/IdCache.pod @@ -1,4 +1,4 @@ -$OpenBSD: IdCache.pod,v 1.1 2020/12/20 15:30:58 daniel Exp $ +$OpenBSD: IdCache.pod,v 1.2 2023/05/16 11:20:00 espie Exp $ =head1 NAME @@ -8,16 +8,16 @@ OpenBSD::IdCache - cache for user and group look-ups use OpenBSD::IdCache; - my $ucache = new OpenBSD::UidCache; + my $ucache = OpenBSD::UidCache->new; my $uid = $ucache->lookup("espie"); - my $gcache = new OpenBSD::GidCache; + my $gcache = OpenBSD::GidCache->new; my $gid = $gcache->lookup("wheel", 0); - my $unamecache = new OpenBSD::UnameCache; + my $unamecache = OpenBSD::UnameCache->new; my $name = $unamecache->lookup($uid); - my $gnamecache = new OpenBSD::GnameCache; + my $gnamecache = OpenBSD::GnameCache->new; my $grname = $gnamecache->lookup($gid); =head1 DESCRIPTION diff --git a/usr.sbin/pkg_add/OpenBSD/Mtree.pod b/usr.sbin/pkg_add/OpenBSD/Mtree.pod index 55a13aca6..a500da889 100644 --- a/usr.sbin/pkg_add/OpenBSD/Mtree.pod +++ b/usr.sbin/pkg_add/OpenBSD/Mtree.pod @@ -1,4 +1,4 @@ -$OpenBSD: Mtree.pod,v 1.1 2020/12/20 15:30:58 daniel Exp $ +$OpenBSD: Mtree.pod,v 1.2 2023/05/16 14:04:16 espie Exp $ =head1 NAME @@ -10,19 +10,21 @@ OpenBSD::Mtree - simple C spec parser my %hier; - OpenBSD::Mtree::parse(\%hier, "/", "/etc/mtree/4.4BSD.dist"); + OpenBSD::Mtree::parse(\%hier, "/", "/etc/mtree/4.4BSD.dist", $extra); =head1 DESCRIPTION C is a parser for C specifications that can reconstruct directory hierarchies. -The basic function C +The basic function C will populate the hash C<$hash> with defined entries for each directory seen while reading from C<$fh>, assuming the specification is to be interpreted relative to C<$basedir> (some canonicalization of directory names will occur). -C is a convenience +If C<$extra> is non null, each entry will itself be an empty hash. + +C is a convenience function which also handles opening the filehandle from C<$filename> and closing it after reading the specification. diff --git a/usr.sbin/pkg_add/OpenBSD/OldLibs.pm b/usr.sbin/pkg_add/OpenBSD/OldLibs.pm index 003fa24cf..94c4057b4 100644 --- a/usr.sbin/pkg_add/OpenBSD/OldLibs.pm +++ b/usr.sbin/pkg_add/OpenBSD/OldLibs.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: OldLibs.pm,v 1.13 2022/04/27 15:04:11 espie Exp $ +# $OpenBSD: OldLibs.pm,v 1.14 2023/05/16 14:31:26 espie Exp $ # # Copyright (c) 2004-2010 Marc Espie # @@ -154,7 +154,7 @@ sub split_some_libs my $c1 = {}; my $c2 = {}; $plist->separate_element($libs, $c1, $c2); - my $p1 = OpenBSD::PackingList::OldLibs->new; + my $p1 = OpenBSD::PackingList->new; $p1->set_infodir($plist->infodir); $plist->special_deep_copy($p1, $c1, {}); my $p2 = $plist->make_shallow_copy($c2); diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index 0cb20abb1..5e05d0130 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingElement.pm,v 1.284 2022/11/04 13:22:15 espie Exp $ +# $OpenBSD: PackingElement.pm,v 1.285 2023/05/16 14:28:39 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -27,6 +27,11 @@ require 5.008_000; # This is the basic class, which is mostly abstract, except for # create and register_with_factory. # It does provide base methods for stuff under it, though. + +# XXX PackingElement uses (very seldom) multiple inheritance: +# the subclasses ::DirBase and ::Unique are used as mix-ins +# and thus contain very limited functionality ! + package OpenBSD::PackingElement; our %keyword; @@ -84,6 +89,8 @@ sub register_manpage { } +# plist keeps a "state" while reading a plist +# $self->destate($plstate) sub destate { } @@ -96,6 +103,14 @@ sub add_object return $self; } +# $class->add($plist, @args): +# create an object with the correct arguments +# returns the actual object created, IF ANY (XXX see subclasses +# for instances of annotations like @symlink that DON'T create +# an actual object) +# +# most add methods have ONE single argument, except for +# subclasses generated from comments ! sub add { my ($class, $plist, @args) = @_; @@ -118,6 +133,7 @@ sub write } } +# specialized version to avoid copying digital signatures over sub write_no_sig { my ($self, $fh) = @_; @@ -208,6 +224,9 @@ sub cwd return ${$_[0]->{cwd}}; } +# most objects should be fs relative, but there are +# exceptions, such as sample files that will get installed +# under /etc, or rc files ! sub absolute_okay() { 0 } sub compute_fullname { @@ -320,6 +339,7 @@ our @ISA=qw(OpenBSD::PackingElement::Object); package OpenBSD::PackingElement::Meta; our @ISA=qw(OpenBSD::PackingElement); +# XXX mix-in class, see comment at top of file package OpenBSD::PackingElement::Unique; our @ISA=qw(OpenBSD::PackingElement::Meta); @@ -514,6 +534,12 @@ sub destate sub dirclass() { "OpenBSD::PackingElement::Sampledir" } +# TODO @ghost data is not yet used +# it's meant for files that used to be "registered" but are +# somewhat autogenerated or something, and should vanish in a transparent way. +# +# the keyword was introduced very early but is (still) not used + package OpenBSD::PackingElement::Ghost; our @ISA = qw(OpenBSD::PackingElement::FileObject); @@ -596,7 +622,8 @@ __PACKAGE__->register_with_factory; sub register_manpage { my ($self, $state, $key) = @_; - # XXX don't bother register stuff from partial packages + # optimization: don't bother registering stuff from partial packages + # (makewhatis will complain that the names don't match anyway) return if defined $self->{tempname}; my $fname = $self->fullname; if ($fname =~ m,^(.*/man(?:/\w+)?)/((?:man|cat)[1-9n]\w*/.*),) { @@ -724,7 +751,11 @@ our @ISA=qw(OpenBSD::PackingElement::FileBase); sub keyword() { "ltlib" } __PACKAGE__->register_with_factory; -# Comment is very special +# Comment is very special: +# - some annotations are comments for historic reasons +# - CVSTags need to be recognized for register-plist (obsolescent) +# - tools like update-plist will recognize @comment'ed entries +# and thus destate needs to run on normal comments package OpenBSD::PackingElement::Comment; our @ISA=qw(OpenBSD::PackingElement::Meta); @@ -900,7 +931,7 @@ our @ISA=qw(OpenBSD::PackingElement::UniqueOption); sub category() { 'manual-installation' } -# XXX don't incorporate this in signatures. +# don't incorporate this in signatures for obvious reasons sub write_no_sig() { } @@ -2156,7 +2187,8 @@ for my $k (qw(src display mtree ignore_inst dirrm pkgcfl pkgdep newdepend __PACKAGE__->register_old_keyword($k); } -# Real pkgpath objects, with matching properties +# pkgpath objects are parsed in extrainfo and pkgpath objects +# so that erroneous pkgpaths will be flagged early package OpenBSD::PkgPath; sub new { diff --git a/usr.sbin/pkg_add/OpenBSD/PackingList.pm b/usr.sbin/pkg_add/OpenBSD/PackingList.pm index 4b4b49ea9..33b768701 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingList.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingList.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackingList.pm,v 1.149 2022/06/06 07:21:17 espie Exp $ +# $OpenBSD: PackingList.pm,v 1.150 2023/05/16 14:31:26 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -177,10 +177,7 @@ sub read if (ref $a) { $plist = $a; } else { - $plist = new $a; - } - if (defined $subclass->{$code}) { - bless $plist, "OpenBSD::PackingList::".$subclass->{$code}; + $plist = $a->new; } &$code($u, sub { @@ -562,37 +559,4 @@ sub signature return OpenBSD::Signature->from_plist($self); } -$subclass = { - \&defaultCode => 'Full', - \&SharedItemsOnly => 'SharedItems', - \&DirrmOnly => 'SharedItems', - \&LibraryOnly => 'Libraries', - \&FilesOnly => 'Files', - \&PrelinkStuffOnly => 'Prelink', - \&DependOnly => 'Depend', - \&ExtraInfoOnly => 'ExtraInfo', - \&UpdateInfoOnly => 'UpdateInfo', - \&ConflictOnly => 'Conflict' }; - -package OpenBSD::PackingList::OldLibs; -our @ISA = qw(OpenBSD::PackingList); -package OpenBSD::PackingList::Full; -our @ISA = qw(OpenBSD::PackingList::OldLibs); -package OpenBSD::PackingList::SharedItems; -our @ISA = qw(OpenBSD::PackingList); -package OpenBSD::PackingList::Libraries; -our @ISA = qw(OpenBSD::PackingList); -package OpenBSD::PackingList::Files; -our @ISA = qw(OpenBSD::PackingList); -package OpenBSD::PackingList::Prelink; -our @ISA = qw(OpenBSD::PackingList); -package OpenBSD::PackingList::Depend; -our @ISA = qw(OpenBSD::PackingList); -package OpenBSD::PackingList::ExtraInfo; -our @ISA = qw(OpenBSD::PackingList); -package OpenBSD::PackingList::UpdateInfo; -our @ISA = qw(OpenBSD::PackingList); -package OpenBSD::PackingList::Conflict; -our @ISA = qw(OpenBSD::PackingList); - 1; diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm index 7502e9819..3149f3d6d 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgCreate.pm,v 1.185 2023/01/25 13:25:07 espie Exp $ +# $OpenBSD: PkgCreate.pm,v 1.186 2023/05/16 14:30:55 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie # @@ -434,7 +434,7 @@ sub set_destdir { my ($self, $state) = @_; if ($self->name =~ m/^\//) { - $state->{archive}->destdir($state->{base}); + $state->{archive}->set_destdir($state->{base}); } else { $self->SUPER::set_destdir($state); } @@ -585,7 +585,7 @@ sub set_destdir { my ($self, $state) = @_; - $state->{archive}->destdir($state->{base}."/".$self->cwd); + $state->{archive}->set_destdir($state->{base}."/".$self->cwd); } sub archive diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm index 9e8c948e7..39a14f9a6 100644 --- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm +++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Ustar.pm,v 1.91 2022/05/28 23:20:28 espie Exp $ +# $OpenBSD: Ustar.pm,v 1.94 2023/05/16 16:55:32 espie Exp $ # # Copyright (c) 2002-2014 Marc Espie # @@ -49,10 +49,10 @@ use File::Basename (); use OpenBSD::IdCache; use OpenBSD::Paths; -our $uidcache = new OpenBSD::UidCache; -our $gidcache = new OpenBSD::GidCache; -our $unamecache = new OpenBSD::UnameCache; -our $gnamecache = new OpenBSD::GnameCache; +our $uidcache = OpenBSD::UidCache->new; +our $gidcache = OpenBSD::GidCache->new; +our $unamecache = OpenBSD::UnameCache->new; +our $gnamecache = OpenBSD::GnameCache->new; # This is a multiple of st_blksize everywhere.... my $buffsize = 2 * 1024 * 1024; @@ -71,19 +71,24 @@ sub new destdir => $destdir} , $class; } +# $self->set_description($description): +# application-level description of the archive for error messages sub set_description { my ($self, $d) = @_; $self->{description} = $d; } +# $self->set_callback(sub($size_done) {}): +# for large file extraction, provide intermediate callbacks with the +# size already done for progress meters and the likes sub set_callback { my ($self, $code) = @_; $self->{callback} = $code; } -sub fatal +sub _fatal { my ($self, $msg, @args) = @_; $self->{state}->fatal("Ustar [#1][#2]: #3", @@ -91,7 +96,7 @@ sub fatal $self->{state}->f($msg, @args)); } -sub new_object +sub _new_object { my ($self, $h, $class) = @_; $h->{archive} = $self; @@ -112,10 +117,10 @@ sub skip } my $actual = read($self->{fh}, $temp, $toread); if (!defined $actual) { - $self->fatal("Error while skipping archive: #1", $!); + $self->_fatal("Error while skipping archive: #1", $!); } if ($actual == 0) { - $self->fatal("Premature end of archive in header"); + $self->_fatal("Premature end of archive in header"); } $self->{swallow} -= $actual; } @@ -139,7 +144,8 @@ my $unsupported = { LONGNAME => 'Long file', }; -sub read_records +# helpers for the XHDR type +sub _read_records { my ($self, $size) = @_; my $toread = $self->{swallow}; @@ -150,10 +156,10 @@ sub read_records $maxread = $toread if $maxread > $toread; my $actual = read($self->{fh}, $buffer, $maxread); if (!defined $actual) { - $self->fatal("Error reading from archive: #1", $!); + $self->_fatal("Error reading from archive: #1", $!); } if ($actual == 0) { - $self->fatal("Premature end of archive"); + $self->_fatal("Premature end of archive"); } $self->{swallow} -= $actual; $toread -= $actual; @@ -162,7 +168,7 @@ sub read_records return substr($result, 0, $size); } -sub parse_records +sub _parse_records { my ($self, $result, $h) = @_; open(my $fh, '<', \$h); @@ -187,7 +193,7 @@ sub next my $header; my $n = read($self->{fh}, $header, 512); return if (defined $n) and $n == 0; - $self->fatal("Error while reading header") + $self->_fatal("Error while reading header") unless defined $n and $n == 512; if ($header eq "\0"x512) { return $self->next; @@ -197,14 +203,14 @@ sub next $linkname, $magic, $version, $uname, $gname, $major, $minor, $prefix, $pad) = unpack(USTAR_HEADER, $header); if ($magic ne "ustar\0" || $version ne '00') { - $self->fatal("Not an ustar archive header"); + $self->_fatal("Not an ustar archive header"); } # verify checksum my $value = $header; substr($value, 148, 8) = " "x8; my $ck2 = unpack("%C*", $value); if ($ck2 != oct($chksum)) { - $self->fatal("Bad archive checksum"); + $self->_fatal("Bad archive checksum"); } $name =~ s/\0*$//o; $mode = oct($mode) & 0xfff; @@ -248,19 +254,19 @@ sub next $self->{swallow} += 512 - $size % 512; } if ($type eq XHDR) { - my $h = $self->read_records($size); + my $h = $self->_read_records($size); $result = $self->next; - $self->parse_records($result, $h); + $self->_parse_records($result, $h); return $result; } if (defined $types->{$type}) { - $self->new_object($result, $types->{$type}); + $self->_new_object($result, $types->{$type}); } else { - $self->fatal("Unsupported type #1 (#2)", $type, + $self->_fatal("Unsupported type #1 (#2)", $type, $unsupported->{$type} // "unknown"); } if (!$result->isFile && $result->{size} != 0) { - $self->fatal("Bad archive: non null size for #1 (#2)", + $self->_fatal("Bad archive: non null size for #1 (#2)", $types->{$type}, $result->{name}); } @@ -268,7 +274,8 @@ sub next return $result; } -sub split_name +# helper for prepare: ustar has strong limitations wrt directory/filename +sub _split_name { my $name = shift; my $prefix = ''; @@ -285,7 +292,8 @@ sub split_name return ($prefix, $name); } -sub extended_record +# helper for prepare +sub _extended_record { my ($k, $v) = @_; my $string = " $k=$v\n"; @@ -299,7 +307,7 @@ sub extended_record } } -sub pack_header +sub _pack_header { my ($archive, $type, $size, $entry, $prefix, $name, $linkname, $uname, $gname, $major, $minor) = @_; @@ -330,10 +338,10 @@ sub pack_header my $whatever = "usualSuspect000"; -sub mkheader +sub _mkheader { my ($archive, $entry, $type) = @_; - my ($prefix, $name) = split_name($entry->name); + my ($prefix, $name) = _split_name($entry->name); my ($extendedname, $extendedlink); my $linkname = $entry->{linkname}; my $size = $entry->{size}; @@ -378,22 +386,22 @@ sub mkheader $extendedlink = 1; } if (length $uname > MAXUSERNAME) { - $archive->fatal("Username too long #1", $uname); + $archive->_fatal("Username too long #1", $uname); } if (length $gname > MAXGROUPNAME) { - $archive->fatal("Groupname too long #1", $gname); + $archive->_fatal("Groupname too long #1", $gname); } - my $header = $archive->pack_header($type, $size, $entry, + my $header = $archive->_pack_header($type, $size, $entry, $prefix, $name, $linkname, $uname, $gname, $major, $minor); my $x; if ($extendedname) { - $x .= extended_record("path", $entry->name); + $x .= _extended_record("path", $entry->name); } if ($extendedlink) { - $x .= extended_record("linkpath",$entry->{linkname}); + $x .= _extended_record("linkpath",$entry->{linkname}); } if ($x) { - my $extended = $archive->pack_header(XHDR, length($x), $entry, + my $extended = $archive->_pack_header(XHDR, length($x), $entry, '', $whatever, '', $uname, $gname, $major, $minor); $whatever++; if ((length $x) % 512) { @@ -445,25 +453,25 @@ sub prepare } elsif (-d _) { $class = "OpenBSD::Ustar::Dir"; } - $self->new_object($entry, $class); + $self->_new_object($entry, $class); if (!$entry->isFile) { $entry->{size} = 0; } return $entry; } -sub pad +sub _pad { my $self = shift; my $fh = $self->{fh}; - print $fh "\0"x1024 or $self->fatal("Error writing to archive: #1", $!); + print $fh "\0"x1024 or $self->_fatal("Error writing to archive: #1", $!); } sub close { my $self = shift; if (defined $self->{padout}) { - $self->pad; + $self->_pad; } close($self->{fh}); } @@ -478,6 +486,12 @@ sub destdir } } +sub set_destdir +{ + my ($self, $d) = @_; + $self->{destdir} = $d; +} + sub fh { return $_[0]->{fh}; @@ -495,24 +509,13 @@ sub recheck_owner ->lookup($entry->{gname}); } -sub fatal +sub _fatal { my ($self, @args) = @_; - $self->{archive}->fatal(@args); + $self->{archive}->_fatal(@args); } -sub system -{ - my ($self, @args) = @_; - $self->{archive}{state}->system(@args); -} - -sub errsay -{ - my ($self, @args) = @_; - $self->{archive}{state}->errsay(@args); -} -sub left_todo +sub _left_todo { my ($self, $toread) = @_; return if $toread == 0; @@ -538,7 +541,7 @@ sub set_name $self->{name} = $v; } -sub set_modes_on_object +sub _set_modes_on_object { my ($self, $o) = @_; chown $self->{uid}, $self->{gid}, $o; @@ -548,28 +551,28 @@ sub set_modes_on_object } } -sub set_modes +sub _set_modes { my $self = shift; - $self->set_modes_on_object($self->fullname); + $self->_set_modes_on_object($self->fullname); } -sub ensure_dir +sub _ensure_dir { my ($self, $dir) = @_; return if -d $dir; - $self->ensure_dir(File::Basename::dirname($dir)); + $self->_ensure_dir(File::Basename::dirname($dir)); if (mkdir($dir)) { return; } - $self->fatal("Error making directory #1: #2", $dir, $!); + $self->_fatal("Error making directory #1: #2", $dir, $!); } -sub make_basedir +sub _make_basedir { my $self = shift; my $dir = $self->{destdir}.File::Basename::dirname($self->name); - $self->ensure_dir($dir); + $self->_ensure_dir($dir); } sub write @@ -579,8 +582,8 @@ sub write my $out = $arc->{fh}; $arc->{padout} = 1; - my $header = $arc->mkheader($self, $self->type); - print $out $header or $self->fatal("Error writing to archive: #1", $!); + my $header = $arc->_mkheader($self, $self->type); + print $out $header or $self->_fatal("Error writing to archive: #1", $!); $self->write_contents($arc); my $k = $self->{key}; if (!defined $arc->{key}{$k}) { @@ -619,8 +622,8 @@ sub copy my $out = $wrarc->{fh}; $self->resolve_links($wrarc); $wrarc->{padout} = 1; - my $header = $wrarc->mkheader($self, $self->type); - print $out $header or $self->fatal("Error writing to archive: #1", $!); + my $header = $wrarc->_mkheader($self, $self->type); + print $out $header or $self->_fatal("Error writing to archive: #1", $!); $self->copy_contents($wrarc); } @@ -639,8 +642,8 @@ our @ISA=qw(OpenBSD::Ustar::Object); sub create { my $self = shift; - $self->ensure_dir($self->fullname); - $self->set_modes; + $self->_ensure_dir($self->fullname); + $self->_set_modes; } sub isDir() { 1 } @@ -653,13 +656,13 @@ our @ISA=qw(OpenBSD::Ustar::Object); sub create { my $self = shift; - $self->make_basedir; + $self->_make_basedir; my $linkname = $self->{linkname}; if (defined $self->{cwd}) { $linkname=$self->{cwd}.'/'.$linkname; } link $self->{destdir}.$linkname, $self->fullname or - $self->fatal("Can't link #1#2 to #1#3: #4", + $self->_fatal("Can't link #1#2 to #1#3: #4", $self->{destdir}, $linkname, $self->name, $!); } @@ -672,7 +675,7 @@ sub resolve_links $self->{linkname} = $arc->{key}{$k}; } else { print join("\n", keys(%{$arc->{key}})), "\n"; - $self->fatal("Can't copy link over: original for #1 NOT available", $k); + $self->_fatal("Can't copy link over: original for #1 NOT available", $k); } } @@ -687,9 +690,9 @@ our @ISA=qw(OpenBSD::Ustar::Object); sub create { my $self = shift; - $self->make_basedir; + $self->_make_basedir; symlink $self->{linkname}, $self->fullname or - $self->fatal("Can't symlink #1 to #2: #3", + $self->_fatal("Can't symlink #1 to #2: #3", $self->{linkname}, $self->fullname, $!); require POSIX; POSIX::lchown($self->{uid}, $self->{gid}, $self->fullname); @@ -706,11 +709,11 @@ our @ISA=qw(OpenBSD::Ustar::Object); sub create { my $self = shift; - $self->make_basedir; + $self->_make_basedir; require POSIX; POSIX::mkfifo($self->fullname, $self->{mode}) or - $self->fatal("Can't create fifo #1: #2", $self->fullname, $!); - $self->set_modes; + $self->_fatal("Can't create fifo #1: #2", $self->fullname, $!); + $self->_set_modes; } sub isFifo() { 1 } @@ -722,11 +725,11 @@ our @ISA=qw(OpenBSD::Ustar::Object); sub create { my $self = shift; - $self->make_basedir; - $self->system(OpenBSD::Paths->mknod, + $self->_make_basedir; + $self->{archive}{state}->system(OpenBSD::Paths->mknod, '-m', $self->{mode}, '--', $self->fullname, $self->devicetype, $self->{major}, $self->{minor}); - $self->set_modes; + $self->_set_modes; } sub isDevice() { 1 } @@ -743,6 +746,8 @@ our @ISA=qw(OpenBSD::Ustar::Device); sub type() { OpenBSD::Ustar::BLOCKDEVICE } sub devicetype() { 'c' } +# This is very specific to classic Unix: files with series of 0s should +# have "gaps" created by using lseek while writing. package OpenBSD::CompactWriter; use constant { @@ -817,9 +822,9 @@ our @ISA=qw(OpenBSD::Ustar::Object); sub create { my $self = shift; - $self->make_basedir; + $self->_make_basedir; open(my $fh, '>', $self->fullname) or - $self->fatal("Can't write to #1: #2", $self->fullname, $!); + $self->_fatal("Can't write to #1: #2", $self->fullname, $!); $self->extract_to_fh($fh); } @@ -832,7 +837,7 @@ sub extract_to_fh if ($self->{partial}) { $toread -= length($self->{partial}); unless ($out->write($self->{partial})) { - $self->fatal("Error writing to #1: #2", + $self->_fatal("Error writing to #1: #2", $self->fullname, $!); } } @@ -841,22 +846,22 @@ sub extract_to_fh $maxread = $toread if $maxread > $toread; my $actual = read($self->{archive}{fh}, $buffer, $maxread); if (!defined $actual) { - $self->fatal("Error reading from archive: #1", $!); + $self->_fatal("Error reading from archive: #1", $!); } if ($actual == 0) { - $self->fatal("Premature end of archive"); + $self->_fatal("Premature end of archive"); } $self->{archive}{swallow} -= $actual; unless ($out->write($buffer)) { - $self->fatal("Error writing to #1: #2", + $self->_fatal("Error writing to #1: #2", $self->fullname, $!); } $toread -= $actual; - $self->left_todo($toread); + $self->_left_todo($toread); } - $self->set_modes_on_object($fh); - $out->close or $self->fatal("Error closing #1: #2", + $self->_set_modes_on_object($fh); + $out->close or $self->_fatal("Error closing #1: #2", $self->fullname, $!); } @@ -876,10 +881,10 @@ sub contents my $sz = $toread; my $actual = read($self->{archive}{fh}, $buffer, $sz, $offset); if (!defined $actual) { - $self->fatal("Error reading from archive: #1", $!); + $self->_fatal("Error reading from archive: #1", $!); } if ($actual != $sz) { - $self->fatal("Error: short read from archive"); + $self->_fatal("Error: short read from archive"); } $self->{archive}{swallow} -= $actual; $toread -= $actual; @@ -896,7 +901,7 @@ sub write_contents my $filename = $self->{realname}; my $size = $self->{size}; my $out = $arc->{fh}; - open my $fh, "<", $filename or $self->fatal("Can't read file #1: #2", + open my $fh, "<", $filename or $self->_fatal("Can't read file #1: #2", $filename, $!); my $buffer; @@ -906,21 +911,21 @@ sub write_contents $maxread = $toread if $maxread > $toread; my $actual = read($fh, $buffer, $maxread); if (!defined $actual) { - $self->fatal("Error reading from file: #1", $!); + $self->_fatal("Error reading from file: #1", $!); } if ($actual == 0) { - $self->fatal("Premature end of file"); + $self->_fatal("Premature end of file"); } unless (print $out $buffer) { - $self->fatal("Error writing to archive: #1", $!); + $self->_fatal("Error writing to archive: #1", $!); } $toread -= $actual; - $self->left_todo($toread); + $self->_left_todo($toread); } if ($size % 512) { print $out "\0" x (512 - $size % 512) or - $self->fatal("Error writing to archive: #1", $!); + $self->_fatal("Error writing to archive: #1", $!); } } @@ -936,21 +941,21 @@ sub copy_contents $maxread = $toread if $maxread > $toread; my $actual = read($self->{archive}{fh}, $buffer, $maxread); if (!defined $actual) { - $self->fatal("Error reading from archive: #1", $!); + $self->_fatal("Error reading from archive: #1", $!); } if ($actual == 0) { - $self->fatal("Premature end of archive"); + $self->_fatal("Premature end of archive"); } $self->{archive}{swallow} -= $actual; unless (print $out $buffer) { - $self->fatal("Error writing to archive #1", $!); + $self->_fatal("Error writing to archive #1", $!); } $toread -= $actual; } if ($size % 512) { print $out "\0" x (512 - $size % 512) or - $self->fatal("Error writing to archive: #1", $!); + $self->_fatal("Error writing to archive: #1", $!); } $self->alias($arc, $self->name); } diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pod b/usr.sbin/pkg_add/OpenBSD/Ustar.pod index cc1a7ebcb..d681778a2 100644 --- a/usr.sbin/pkg_add/OpenBSD/Ustar.pod +++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pod @@ -1,4 +1,4 @@ -$OpenBSD: Ustar.pod,v 1.1 2020/12/20 15:30:58 daniel Exp $ +$OpenBSD: Ustar.pod,v 1.3 2023/05/16 10:52:58 espie Exp $ =head1 NAME @@ -56,7 +56,7 @@ to be usable on pipe outputs. For archive writing, the filehandle should support C. Error messages and fatal errors will be handled through the C<$state> object, -which should conform to C (uses C and C). +which should conform to C (uses C and C). Note that read and write support are mutually exclusive, though there is no need to specify the mode used at creation time; it is implicitly @@ -99,13 +99,21 @@ In case of errors, the archive will call C<$state-Efatal> with a suitable error message that contains the last index name processed. The user may set an optional archive description with C. -The C method can take an optional C<$callback> argument, which will -be called regularly while extracting large objects, as C<&$callback($donesize)>, -with C<$donesize> the number of bytes already extracted. +The archive object can take a description through C<$arc-Eset_description> +which will be used in error messages related to archive extraction or creation. + +The archive object can be embued with a C<$callback> through +C<$arch-Eset_callback>, which will be called regularly while +extracting large objects, as C<&$callback($donesize)>, +with C<$donesize> the number of bytes already extracted, for use in +progressmeter-style user interactions. Small files can also be directly extracted to a scalar using C<$v = $o-Econtents>. +Actual file objects can also be directly extracted to a temporary file using +C<$oEextract_to_fh($fh)>. + Actual writing is performed through C<$o-Ewrite> and is not mandatory either. diff --git a/usr.sbin/pkg_add/OpenBSD/md5.pm b/usr.sbin/pkg_add/OpenBSD/md5.pm index 74800b4fa..be0f605f4 100644 --- a/usr.sbin/pkg_add/OpenBSD/md5.pm +++ b/usr.sbin/pkg_add/OpenBSD/md5.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: md5.pm,v 1.18 2019/07/05 06:21:14 espie Exp $ +# $OpenBSD: md5.pm,v 1.19 2023/05/16 14:29:20 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie # @@ -18,6 +18,9 @@ use strict; use warnings; +# XXX even though there is ONE current implementation of OpenBSD::digest +# (SHA256) we keep the framework open in case we ever need to switch, +# as we did in the past with md5 -> sha256 package OpenBSD::digest; sub new diff --git a/usr.sbin/pkg_add/OpenBSD/md5.pod b/usr.sbin/pkg_add/OpenBSD/md5.pod index c5f26f060..2aae5015a 100644 --- a/usr.sbin/pkg_add/OpenBSD/md5.pod +++ b/usr.sbin/pkg_add/OpenBSD/md5.pod @@ -1,4 +1,4 @@ -$OpenBSD: md5.pod,v 1.1 2020/12/20 15:30:58 daniel Exp $ +$OpenBSD: md5.pod,v 1.2 2023/05/16 11:53:01 espie Exp $ =head1 NAME @@ -51,7 +51,7 @@ create a new digest object from a string representation. create a new digest object C<$o2> of the same type as C<$o>. -=item $o-Eequal($o2) +=item $o-Eequals($o2) compare two digest objects. Returns true only if they match. diff --git a/usr.sbin/rpki-client/repo.c b/usr.sbin/rpki-client/repo.c index 81b06b8d4..dd7b4815e 100644 --- a/usr.sbin/rpki-client/repo.c +++ b/usr.sbin/rpki-client/repo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: repo.c,v 1.44 2023/04/26 16:32:41 claudio Exp $ */ +/* $OpenBSD: repo.c,v 1.45 2023/05/16 17:01:31 claudio Exp $ */ /* * Copyright (c) 2021 Claudio Jeker * Copyright (c) 2019 Kristaps Dzonsons @@ -806,6 +806,7 @@ rrdp_handle_file(unsigned int id, enum publish_type pt, char *uri, ssize_t s; char *fn = NULL; int fd = -1, try = 0; + int flags; rr = rrdp_find(id); if (rr == NULL) @@ -850,8 +851,17 @@ rrdp_handle_file(unsigned int id, enum publish_type pt, char *uri, if (repo_mkpath(AT_FDCWD, fn) == -1) goto fail; - fd = open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0644); + flags = O_WRONLY|O_CREAT|O_TRUNC; + if (pt == PUB_ADD) + flags |= O_EXCL; + fd = open(fn, flags, 0644); if (fd == -1) { + if (errno == EEXIST) { + warnx("%s: duplicate publish element for %s", + rr->notifyuri, fn); + free(fn); + return 0; + } warn("open %s", fn); goto fail; } diff --git a/usr.sbin/smtpd/bounce.c b/usr.sbin/smtpd/bounce.c index 84fd035f0..61e7b037b 100644 --- a/usr.sbin/smtpd/bounce.c +++ b/usr.sbin/smtpd/bounce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bounce.c,v 1.88 2023/05/04 12:43:44 chrisz Exp $ */ +/* $OpenBSD: bounce.c,v 1.89 2023/05/15 12:03:04 op Exp $ */ /* * Copyright (c) 2009 Gilles Chehade @@ -305,7 +305,7 @@ bounce_send(struct bounce_session *s, const char *fmt, ...) } static const char * -bounce_duration(long long int d) +bounce_duration(long long d) { static char buf[32]; diff --git a/usr.sbin/smtpd/lka_filter.c b/usr.sbin/smtpd/lka_filter.c index 0ae45f0ca..0c63657be 100644 --- a/usr.sbin/smtpd/lka_filter.c +++ b/usr.sbin/smtpd/lka_filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lka_filter.c,v 1.69 2023/05/10 07:20:20 op Exp $ */ +/* $OpenBSD: lka_filter.c,v 1.70 2023/05/15 12:03:04 op Exp $ */ /* * Copyright (c) 2018 Gilles Chehade @@ -933,13 +933,13 @@ filter_protocol_query(struct filter *filter, uint64_t token, uint64_t reqid, con n = io_printf(lka_proc_get_io(filter->proc), "filter|%s|%lld.%06ld|smtp-in|%s|%016"PRIx64"|%016"PRIx64"|%s|%s\n", PROTOCOL_VERSION, - (long long int)tv.tv_sec, tv.tv_usec, + (long long)tv.tv_sec, tv.tv_usec, phase, reqid, token, fs->rdns, param); else n = io_printf(lka_proc_get_io(filter->proc), "filter|%s|%lld.%06ld|smtp-in|%s|%016"PRIx64"|%016"PRIx64"|%s\n", PROTOCOL_VERSION, - (long long int)tv.tv_sec, tv.tv_usec, + (long long)tv.tv_sec, tv.tv_usec, phase, reqid, token, param); if (n == -1) fatalx("failed to write to processor"); @@ -957,7 +957,7 @@ filter_data_query(struct filter *filter, uint64_t token, uint64_t reqid, const c "filter|%s|%lld.%06ld|smtp-in|data-line|" "%016"PRIx64"|%016"PRIx64"|%s\n", PROTOCOL_VERSION, - (long long int)tv.tv_sec, tv.tv_usec, + (long long)tv.tv_sec, tv.tv_usec, reqid, token, line); if (n == -1) fatalx("failed to write to processor"); @@ -1374,7 +1374,7 @@ report_smtp_broadcast(uint64_t reqid, const char *direction, struct timeval *tv, va_start(ap, format); if (io_printf(lka_proc_get_io(rp->name), "report|%s|%lld.%06ld|%s|%s|%016"PRIx64"%s", - PROTOCOL_VERSION, (long long int)tv->tv_sec, tv->tv_usec, + PROTOCOL_VERSION, (long long)tv->tv_sec, tv->tv_usec, direction, event, reqid, format[0] != '\n' ? "|" : "") == -1 || io_vprintf(lka_proc_get_io(rp->name), format, ap) == -1) diff --git a/usr.sbin/smtpd/mail.maildir.c b/usr.sbin/smtpd/mail.maildir.c index 355831e89..fb221da2e 100644 --- a/usr.sbin/smtpd/mail.maildir.c +++ b/usr.sbin/smtpd/mail.maildir.c @@ -171,7 +171,7 @@ maildir_engine(const char *dirname, int junk) (void)strlcpy(hostname, "localhost", sizeof hostname); (void)snprintf(filename, sizeof filename, "%lld.%08x.%s", - (long long int) time(NULL), + (long long)time(NULL), arc4random(), hostname); diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index dbcf2c015..05506da1d 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta.c,v 1.243 2022/02/18 16:57:36 millert Exp $ */ +/* $OpenBSD: mta.c,v 1.244 2023/05/16 17:48:52 op Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -489,38 +489,41 @@ mta_setup_dispatcher(struct dispatcher *dispatcher) if (remote->tls_ciphers) ciphers = remote->tls_ciphers; if (ciphers && tls_config_set_ciphers(config, ciphers) == -1) - fatal("%s", tls_config_error(config)); + fatalx("%s", tls_config_error(config)); if (remote->tls_protocols) { if (tls_config_parse_protocols(&protos, remote->tls_protocols) == -1) - fatal("failed to parse protocols \"%s\"", + fatalx("failed to parse protocols \"%s\"", remote->tls_protocols); if (tls_config_set_protocols(config, protos) == -1) - fatal("%s", tls_config_error(config)); + fatalx("%s", tls_config_error(config)); } if (remote->pki) { pki = dict_get(env->sc_pki_dict, remote->pki); if (pki == NULL) - fatal("client pki \"%s\" not found ", remote->pki); + fatalx("client pki \"%s\" not found", remote->pki); tls_config_set_dheparams(config, dheparams[pki->pki_dhe]); tls_config_use_fake_private_key(config); if (tls_config_set_keypair_mem(config, pki->pki_cert, pki->pki_cert_len, NULL, 0) == -1) - fatal("tls_config_set_keypair_mem"); + fatalx("tls_config_set_keypair_mem: %s", + tls_config_error(config)); } if (remote->ca) { ca = dict_get(env->sc_ca_dict, remote->ca); if (tls_config_set_ca_mem(config, ca->ca_cert, ca->ca_cert_len) == -1) - fatal("tls_config_set_ca_mem"); + fatalx("tls_config_set_ca_mem: %s", + tls_config_error(config)); } else if (tls_config_set_ca_file(config, tls_default_ca_cert_file()) == -1) - fatal("tls_config_set_ca_file"); + fatalx("tls_config_set_ca_file: %s", + tls_config_error(config)); if (remote->tls_verify) { tls_config_verify(config); diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c index 0d40a63ef..92f1ec770 100644 --- a/usr.sbin/smtpd/mta_session.c +++ b/usr.sbin/smtpd/mta_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mta_session.c,v 1.147 2022/09/26 08:48:52 martijn Exp $ */ +/* $OpenBSD: mta_session.c,v 1.148 2023/05/15 12:03:04 op Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -1157,7 +1157,7 @@ mta_response(struct mta_session *s, char *line) s->rcptcount = 0; if (s->relay->limits->sessdelay_transaction) { log_debug("debug: mta: waiting for %llds before next transaction", - (long long int)s->relay->limits->sessdelay_transaction); + (long long)s->relay->limits->sessdelay_transaction); s->hangon = s->relay->limits->sessdelay_transaction -1; s->flags |= MTA_HANGON; runq_schedule(hangon, @@ -1177,7 +1177,7 @@ mta_response(struct mta_session *s, char *line) } if (s->relay->limits->sessdelay_transaction) { log_debug("debug: mta: waiting for %llds after reset", - (long long int)s->relay->limits->sessdelay_transaction); + (long long)s->relay->limits->sessdelay_transaction); s->hangon = s->relay->limits->sessdelay_transaction -1; s->flags |= MTA_HANGON; runq_schedule(hangon, diff --git a/usr.sbin/smtpd/smtp.c b/usr.sbin/smtpd/smtp.c index a9b7d48c8..c76c497a1 100644 --- a/usr.sbin/smtpd/smtp.c +++ b/usr.sbin/smtpd/smtp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp.c,v 1.173 2022/02/18 16:57:36 millert Exp $ */ +/* $OpenBSD: smtp.c,v 1.174 2023/05/16 17:48:52 op Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -166,14 +166,14 @@ smtp_setup_listener_tls(struct listener *l) if (l->tls_ciphers) ciphers = l->tls_ciphers; if (ciphers && tls_config_set_ciphers(config, ciphers) == -1) - fatal("%s", tls_config_error(config)); + fatalx("%s", tls_config_error(config)); if (l->tls_protocols) { if (tls_config_parse_protocols(&protos, l->tls_protocols) == -1) - fatal("failed to parse protocols \"%s\"", + fatalx("failed to parse protocols \"%s\"", l->tls_protocols); if (tls_config_set_protocols(config, protos) == -1) - fatal("%s", tls_config_error(config)); + fatalx("%s", tls_config_error(config)); } pki = l->pki[0]; @@ -181,7 +181,8 @@ smtp_setup_listener_tls(struct listener *l) fatal("no pki defined"); if (tls_config_set_dheparams(config, dheparams[pki->pki_dhe]) == -1) - fatal("tls_config_set_dheparams"); + fatalx("tls_config_set_dheparams: %s", + tls_config_error(config)); tls_config_use_fake_private_key(config); for (i = 0; i < l->pkicount; i++) { @@ -189,11 +190,13 @@ smtp_setup_listener_tls(struct listener *l) if (i == 0) { if (tls_config_set_keypair_mem(config, pki->pki_cert, pki->pki_cert_len, NULL, 0) == -1) - fatal("tls_config_set_keypair_mem"); + fatalx("tls_config_set_keypair_mem: %s", + tls_config_error(config)); } else { if (tls_config_add_keypair_mem(config, pki->pki_cert, pki->pki_cert_len, NULL, 0) == -1) - fatal("tls_config_add_keypair_mem"); + fatalx("tls_config_add_keypair_mem: %s", + tls_config_error(config)); } } free(l->pki); @@ -203,7 +206,8 @@ smtp_setup_listener_tls(struct listener *l) ca = dict_get(env->sc_ca_dict, l->ca_name); if (tls_config_set_ca_mem(config, ca->ca_cert, ca->ca_cert_len) == -1) - fatal("tls_config_set_ca_mem"); + fatalx("tls_config_set_ca_mem: %s", + tls_config_error(config)); } else if (tls_config_set_ca_file(config, tls_default_ca_cert_file()) == -1) @@ -216,7 +220,7 @@ smtp_setup_listener_tls(struct listener *l) if (l->tls == NULL) fatal("tls_server"); if (tls_configure(l->tls, config) == -1) { - fatal("tls_configure: %s", tls_error(l->tls)); + fatalx("tls_configure: %s", tls_error(l->tls)); } tls_config_free(config); } diff --git a/usr.sbin/smtpd/smtpc.c b/usr.sbin/smtpd/smtpc.c index 46ecf7ed3..915206a69 100644 --- a/usr.sbin/smtpd/smtpc.c +++ b/usr.sbin/smtpd/smtpc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpc.c,v 1.19 2021/07/14 13:33:57 kn Exp $ */ +/* $OpenBSD: smtpc.c,v 1.20 2023/05/16 17:48:52 op Exp $ */ /* * Copyright (c) 2018 Eric Faurot @@ -237,7 +237,7 @@ main(int argc, char **argv) if (cafile == NULL) cafile = tls_default_ca_cert_file(); if (tls_config_set_ca_file(tls_config, cafile) == -1) - fatal("tls_set_ca_file"); + fatalx("tls_set_ca_file: %s", tls_config_error(tls_config)); if (!params.tls_verify) { tls_config_insecure_noverifycert(tls_config); tls_config_insecure_noverifyname(tls_config); @@ -455,7 +455,7 @@ smtp_require_tls(void *tag, struct smtp_client *proto) fatal("tls_client"); if (tls_configure(tls, tls_config) == -1) - fatal("tls_configure"); + fatalx("tls_configure: %s", tls_error(tls)); smtp_set_tls(proto, tls); } diff --git a/usr.sbin/smtpd/smtpctl.c b/usr.sbin/smtpd/smtpctl.c index cc98b93a4..846630256 100644 --- a/usr.sbin/smtpd/smtpctl.c +++ b/usr.sbin/smtpd/smtpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpctl.c,v 1.170 2022/02/25 17:31:40 rob Exp $ */ +/* $OpenBSD: smtpctl.c,v 1.171 2023/05/15 12:03:04 op Exp $ */ /* * Copyright (c) 2013 Eric Faurot @@ -136,7 +136,7 @@ offline_file(void) FILE *fp; if (!bsnprintf(path, sizeof(path), "%s%s/%lld.XXXXXXXXXX", PATH_SPOOL, - PATH_OFFLINE, (long long int) time(NULL))) + PATH_OFFLINE, (long long)time(NULL))) err(EX_UNAVAILABLE, "snprintf"); if ((fd = mkstemp(path)) == -1 || (fp = fdopen(fd, "w+")) == NULL) { diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c index 0986df6ba..fcf86ae67 100644 --- a/usr.sbin/user/user.c +++ b/usr.sbin/user/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.128 2019/10/17 21:54:29 millert Exp $ */ +/* $OpenBSD: user.c,v 1.130 2023/05/16 21:28:46 millert Exp $ */ /* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */ /* @@ -171,7 +171,7 @@ enum { #define MKDIR "/bin/mkdir" #define MV "/bin/mv" #define NOLOGIN "/sbin/nologin" -#define PAX "/bin/pax" +#define CP "/bin/cp" #define RM "/bin/rm" #define UNSET_INACTIVE "Null (unset)" @@ -200,20 +200,18 @@ static size_t expand_len(const char *, const char *); static struct group *find_group_info(const char *); static struct passwd *find_user_info(const char *); static void checkeuid(void); -static void memsave(char **, const char *, size_t); +static void strsave(char **, const char *); static void read_defaults(user_t *); static int verbose; -/* if *cpp is non-null, free it, then assign `n' chars of `s' to it */ +/* free *cpp, then store a copy of `s' in it */ static void -memsave(char **cpp, const char *s, size_t n) +strsave(char **cpp, const char *s) { free(*cpp); - if ((*cpp = calloc (n + 1, sizeof(char))) == NULL) + if ((*cpp = strdup(s)) == NULL) err(1, NULL); - memcpy(*cpp, s, n); - (*cpp)[n] = '\0'; } /* a replacement for system(3) */ @@ -313,8 +311,8 @@ copydotfiles(char *skeldir, char *dir) if (n == 0) { warnx("No \"dot\" initialisation files found"); } else { - (void) asystem("cd %s && %s -rw -pe %s . %s", - skeldir, PAX, (verbose) ? "-v" : "", dir); + (void) asystem("%s -a %s %s/. %s", + CP, (verbose) ? "-v" : "", skeldir, dir); } return n; } @@ -788,12 +786,12 @@ read_defaults(user_t *up) unsigned char *cp; unsigned char *s; - memsave(&up->u_primgrp, DEF_GROUP, strlen(DEF_GROUP)); - memsave(&up->u_basedir, DEF_BASEDIR, strlen(DEF_BASEDIR)); - memsave(&up->u_skeldir, DEF_SKELDIR, strlen(DEF_SKELDIR)); - memsave(&up->u_shell, DEF_SHELL, strlen(DEF_SHELL)); - memsave(&up->u_comment, DEF_COMMENT, strlen(DEF_COMMENT)); - memsave(&up->u_class, DEF_CLASS, strlen(DEF_CLASS)); + strsave(&up->u_primgrp, DEF_GROUP); + strsave(&up->u_basedir, DEF_BASEDIR); + strsave(&up->u_skeldir, DEF_SKELDIR); + strsave(&up->u_shell, DEF_SHELL); + strsave(&up->u_comment, DEF_COMMENT); + strsave(&up->u_class, DEF_CLASS); up->u_rsize = 16; up->u_defrc = 0; if ((up->u_rv = calloc(up->u_rsize, sizeof(range_t))) == NULL) @@ -811,27 +809,27 @@ read_defaults(user_t *up) if (strncmp(s, "group", 5) == 0) { for (cp = s + 5 ; isspace((unsigned char)*cp); cp++) { } - memsave(&up->u_primgrp, cp, strlen(cp)); + strsave(&up->u_primgrp, cp); } else if (strncmp(s, "base_dir", 8) == 0) { for (cp = s + 8 ; isspace((unsigned char)*cp); cp++) { } - memsave(&up->u_basedir, cp, strlen(cp)); + strsave(&up->u_basedir, cp); } else if (strncmp(s, "skel_dir", 8) == 0) { for (cp = s + 8 ; isspace((unsigned char)*cp); cp++) { } - memsave(&up->u_skeldir, cp, strlen(cp)); + strsave(&up->u_skeldir, cp); } else if (strncmp(s, "shell", 5) == 0) { for (cp = s + 5 ; isspace((unsigned char)*cp); cp++) { } - memsave(&up->u_shell, cp, strlen(cp)); + strsave(&up->u_shell, cp); } else if (strncmp(s, "password", 8) == 0) { for (cp = s + 8 ; isspace((unsigned char)*cp); cp++) { } - memsave(&up->u_password, cp, strlen(cp)); + strsave(&up->u_password, cp); } else if (strncmp(s, "class", 5) == 0) { for (cp = s + 5 ; isspace((unsigned char)*cp); cp++) { } - memsave(&up->u_class, cp, strlen(cp)); + strsave(&up->u_class, cp); } else if (strncmp(s, "inactive", 8) == 0) { for (cp = s + 8 ; isspace((unsigned char)*cp); cp++) { } @@ -839,7 +837,7 @@ read_defaults(user_t *up) free(up->u_inactive); up->u_inactive = NULL; } else { - memsave(&up->u_inactive, cp, strlen(cp)); + strsave(&up->u_inactive, cp); } } else if (strncmp(s, "range", 5) == 0) { for (cp = s + 5 ; isspace((unsigned char)*cp); cp++) { @@ -858,7 +856,7 @@ read_defaults(user_t *up) free(up->u_expire); up->u_expire = NULL; } else { - memsave(&up->u_expire, cp, strlen(cp)); + strsave(&up->u_expire, cp); } } free(s); @@ -1411,8 +1409,7 @@ moduser(char *login_name, char *newlogin, user_t *up) if ((*pwp->pw_passwd != '\0') && (up->u_flags & F_PASSWORD) == 0) { up->u_flags |= F_PASSWORD; - memsave(&up->u_password, pwp->pw_passwd, - strlen(pwp->pw_passwd)); + strsave(&up->u_password, pwp->pw_passwd); explicit_bzero(pwp->pw_passwd, strlen(pwp->pw_passwd)); } } @@ -1807,34 +1804,34 @@ useradd(int argc, char **argv) break; case 'b': defaultfield = 1; - memsave(&u.u_basedir, optarg, strlen(optarg)); + strsave(&u.u_basedir, optarg); break; case 'c': - memsave(&u.u_comment, optarg, strlen(optarg)); + strsave(&u.u_comment, optarg); break; case 'd': - memsave(&u.u_home, optarg, strlen(optarg)); + strsave(&u.u_home, optarg); u.u_flags |= F_HOMEDIR; break; case 'e': defaultfield = 1; - memsave(&u.u_expire, optarg, strlen(optarg)); + strsave(&u.u_expire, optarg); break; case 'f': defaultfield = 1; - memsave(&u.u_inactive, optarg, strlen(optarg)); + strsave(&u.u_inactive, optarg); break; case 'g': defaultfield = 1; - memsave(&u.u_primgrp, optarg, strlen(optarg)); + strsave(&u.u_primgrp, optarg); break; case 'k': defaultfield = 1; - memsave(&u.u_skeldir, optarg, strlen(optarg)); + strsave(&u.u_skeldir, optarg); break; case 'L': defaultfield = 1; - memsave(&u.u_class, optarg, strlen(optarg)); + strsave(&u.u_class, optarg); break; case 'm': u.u_flags |= F_MKDIR; @@ -1843,7 +1840,7 @@ useradd(int argc, char **argv) u.u_flags |= F_DUPUID; break; case 'p': - memsave(&u.u_password, optarg, strlen(optarg)); + strsave(&u.u_password, optarg); explicit_bzero(optarg, strlen(optarg)); break; case 'r': @@ -1853,7 +1850,7 @@ useradd(int argc, char **argv) break; case 's': defaultfield = 1; - memsave(&u.u_shell, optarg, strlen(optarg)); + strsave(&u.u_shell, optarg); break; case 'u': u.u_uid = strtonum(optarg, -1, UID_MAX, &errstr); @@ -1947,23 +1944,23 @@ usermod(int argc, char **argv) u.u_flags |= F_ACCTLOCK; break; case 'c': - memsave(&u.u_comment, optarg, strlen(optarg)); + strsave(&u.u_comment, optarg); u.u_flags |= F_COMMENT; break; case 'd': - memsave(&u.u_home, optarg, strlen(optarg)); + strsave(&u.u_home, optarg); u.u_flags |= F_HOMEDIR; break; case 'e': - memsave(&u.u_expire, optarg, strlen(optarg)); + strsave(&u.u_expire, optarg); u.u_flags |= F_EXPIRE; break; case 'f': - memsave(&u.u_inactive, optarg, strlen(optarg)); + strsave(&u.u_inactive, optarg); u.u_flags |= F_INACTIVE; break; case 'g': - memsave(&u.u_primgrp, optarg, strlen(optarg)); + strsave(&u.u_primgrp, optarg); u.u_flags |= F_GROUP; break; case 'l': @@ -1975,7 +1972,7 @@ usermod(int argc, char **argv) u.u_flags |= F_USERNAME; break; case 'L': - memsave(&u.u_class, optarg, strlen(optarg)); + strsave(&u.u_class, optarg); u.u_flags |= F_CLASS; break; case 'm': @@ -1985,12 +1982,12 @@ usermod(int argc, char **argv) u.u_flags |= F_DUPUID; break; case 'p': - memsave(&u.u_password, optarg, strlen(optarg)); + strsave(&u.u_password, optarg); explicit_bzero(optarg, strlen(optarg)); u.u_flags |= F_PASSWORD; break; case 's': - memsave(&u.u_shell, optarg, strlen(optarg)); + strsave(&u.u_shell, optarg); u.u_flags |= F_SHELL; break; case 'u': @@ -2091,8 +2088,8 @@ userdel(int argc, char **argv) (void)removehomedir(pwp->pw_name, pwp->pw_uid, pwp->pw_dir); if (u.u_preserve) { u.u_flags |= F_SHELL; - memsave(&u.u_shell, NOLOGIN, strlen(NOLOGIN)); - memsave(&u.u_password, "*", strlen("*")); + strsave(&u.u_shell, NOLOGIN); + strsave(&u.u_password, "*"); u.u_flags |= F_PASSWORD; openlog("userdel", LOG_PID, LOG_USER); return moduser(*argv, *argv, &u) ? EXIT_SUCCESS : EXIT_FAILURE; @@ -2225,7 +2222,7 @@ groupmod(int argc, char **argv) dupgid = 1; break; case 'n': - memsave(&newname, optarg, strlen(optarg)); + strsave(&newname, optarg); break; case 'v': verbose = 1;