CVS commit: src/sys/arch/riscv/starfive
Module Name:src Committed By: skrll Date: Sat Jul 27 07:09:50 UTC 2024 Modified Files: src/sys/arch/riscv/starfive: files.starfive jh7100_clkc.c Added Files: src/sys/arch/riscv/starfive: jh71x0_clkc.c jh71x0_clkc.h Removed Files: src/sys/arch/riscv/starfive: jh7100_clkc.h Log Message: risc-v: split the jh7100 clock controller driver In preparation for the JH7110 clock driver split the clock definition and attachment code from the clock handling macros / methods. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/riscv/starfive/files.starfive cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/starfive/jh7100_clkc.c cvs rdiff -u -r1.2 -r0 src/sys/arch/riscv/starfive/jh7100_clkc.h cvs rdiff -u -r0 -r1.1 src/sys/arch/riscv/starfive/jh71x0_clkc.c \ src/sys/arch/riscv/starfive/jh71x0_clkc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/riscv/starfive/files.starfive diff -u src/sys/arch/riscv/starfive/files.starfive:1.3 src/sys/arch/riscv/starfive/files.starfive:1.4 --- src/sys/arch/riscv/starfive/files.starfive:1.3 Wed Feb 7 17:17:59 2024 +++ src/sys/arch/riscv/starfive/files.starfive Sat Jul 27 07:09:50 2024 @@ -1,13 +1,19 @@ -# $NetBSD: files.starfive,v 1.3 2024/02/07 17:17:59 skrll Exp $ +# $NetBSD: files.starfive,v 1.4 2024/07/27 07:09:50 skrll Exp $ # # Configuration info for StarFive SoCs # -# JH7100 Clock controller +# JH71x0 Clock controllers device jh7100clkc attach jh7100clkc at fdt with jh7100_clkc file arch/riscv/starfive/jh7100_clkc.c jh7100_clkc +device jh7110clkc +attach jh7110clkc at fdt with jh7110_clkc +file arch/riscv/starfive/jh7110_clkc.c jh7110_clkc + +file arch/riscv/starfive/jh71x0_clkc.c jh7100_clkc | jh7110_clkc + # JH71x0 USB device jh71x0usb attach jh71x0usb at fdt with jh71x0_usb Index: src/sys/arch/riscv/starfive/jh7100_clkc.c diff -u src/sys/arch/riscv/starfive/jh7100_clkc.c:1.2 src/sys/arch/riscv/starfive/jh7100_clkc.c:1.3 --- src/sys/arch/riscv/starfive/jh7100_clkc.c:1.2 Wed Jan 17 06:56:50 2024 +++ src/sys/arch/riscv/starfive/jh7100_clkc.c Sat Jul 27 07:09:50 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: jh7100_clkc.c,v 1.2 2024/01/17 06:56:50 skrll Exp $ */ +/* $NetBSD: jh7100_clkc.c,v 1.3 2024/07/27 07:09:50 skrll Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: jh7100_clkc.c,v 1.2 2024/01/17 06:56:50 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: jh7100_clkc.c,v 1.3 2024/07/27 07:09:50 skrll Exp $"); #include @@ -41,7 +41,7 @@ __KERNEL_RCSID(0, "$NetBSD: jh7100_clkc. #include -#include +#include #define JH7100_CLK_CPUNDBUS_ROOT 0 @@ -133,355 +133,6 @@ __KERNEL_RCSID(0, "$NetBSD: jh7100_clkc. #define JH7100_NCLKS 189 -struct jh7100_clkc_softc { - device_t sc_dev; - bus_space_tag_t sc_bst; - bus_space_handle_t sc_bsh; - int sc_phandle; - struct clk_domain sc_clkdom; - struct jh7100_clkc_clk *sc_clk; - size_t sc_nclks; - - u_int sc_osclk; - u_int sc_oaclk; -}; - -#define RD4(sc, reg) \ - bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg)) -#define WR4(sc, reg, val) \ - bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val)) - -static void -jh7100_clkc_update(struct jh7100_clkc_softc * const sc, -struct jh7100_clkc_clk *jcc, uint32_t set, uint32_t clr) -{ - uint32_t val = RD4(sc, jcc->jcc_reg); - val &= ~clr; - val |= set; - WR4(sc, jcc->jcc_reg, val); -} - - -/* - * FIXED_FACTOR operations - */ - -static u_int -jh7100_clkc_fixed_factor_get_parent_rate(struct clk *clk) -{ - struct clk *clk_parent = clk_get_parent(clk); - if (clk_parent == NULL) - return 0; - - return clk_get_rate(clk_parent); -} - -u_int -jh7100_clkc_fixed_factor_get_rate(struct jh7100_clkc_softc *sc, -struct jh7100_clkc_clk *jcc) -{ - KASSERT(jcc->jcc_type == JH7100CLK_FIXED_FACTOR); - - struct jh7100_clkc_fixed_factor * const jcff = >jcc_ffactor; - struct clk *clk = >jcc_clk; - - uint64_t rate = jh7100_clkc_fixed_factor_get_parent_rate(clk); - if (rate == 0) - return 0; - - rate *= jcff->jcff_mult; - rate /= jcff->jcff_div; - - return rate; -} - -static int -jh7100_clkc_fixed_factor_set_parent_rate(struct clk *clk, u_int rate) -{ - struct clk *clk_parent = clk_get_parent(clk); - if (clk_parent == NULL) - return ENXIO; - - return clk_set_rate(clk_parent, rate); -} - -int -jh7100_clkc_fixed_factor_set_rate(struct jh7100_clkc_softc *sc, -struct jh7100_clkc_clk *jcc, u_int rate) -{ - KASSERT(jcc->jcc_type == JH7100CLK_FIXED_FACTOR); - - struct jh7100_clkc_fixed_factor * const jcff = >jcc_ffactor; - struct clk *clk = >jcc_clk; - - uint64_t tmp = rate; - tmp *= jcff->jcff_div; - tmp /= jcff->jcff_mult; - - return jh7100_clkc_fixed_factor_set_parent_rate(clk, tmp); -} - -const char * -jh7100_clkc_fixed_factor_get_parent(struct jh7100_clkc_softc *sc, -struct jh7100_clkc_clk *jcc) -{ -
CVS commit: src/sys/arch/riscv/starfive
Module Name:src Committed By: skrll Date: Sat Jul 27 07:09:50 UTC 2024 Modified Files: src/sys/arch/riscv/starfive: files.starfive jh7100_clkc.c Added Files: src/sys/arch/riscv/starfive: jh71x0_clkc.c jh71x0_clkc.h Removed Files: src/sys/arch/riscv/starfive: jh7100_clkc.h Log Message: risc-v: split the jh7100 clock controller driver In preparation for the JH7110 clock driver split the clock definition and attachment code from the clock handling macros / methods. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/riscv/starfive/files.starfive cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/starfive/jh7100_clkc.c cvs rdiff -u -r1.2 -r0 src/sys/arch/riscv/starfive/jh7100_clkc.h cvs rdiff -u -r0 -r1.1 src/sys/arch/riscv/starfive/jh71x0_clkc.c \ src/sys/arch/riscv/starfive/jh71x0_clkc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/service
Module Name:src Committed By: jakllsch Date: Fri Jul 26 18:54:49 UTC 2024 Modified Files: src/usr.sbin/service: service Log Message: Fix missing whitespace in not found message. >From Daniel Cunha in PR 58471 To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/service/service Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/service/service diff -u src/usr.sbin/service/service:1.9 src/usr.sbin/service/service:1.10 --- src/usr.sbin/service/service:1.9 Tue Mar 14 06:19:35 2023 +++ src/usr.sbin/service/service Fri Jul 26 18:54:49 2024 @@ -1,5 +1,5 @@ #!/bin/sh -#$NetBSD: service,v 1.9 2023/03/14 06:19:35 kre Exp $ +#$NetBSD: service,v 1.10 2024/07/26 18:54:49 jakllsch Exp $ #service -- run or list system services # # Taken from FreeBSD: releng/10.1/usr.sbin/service/service.sh 268098 @@ -213,5 +213,5 @@ do fi done -printf >&2 '%s does not exist in%s\n' "${script}" "${rc_directories}" +printf >&2 '%s does not exist in %s\n' "${script}" "${rc_directories}" exit 1
CVS commit: src/usr.sbin/service
Module Name:src Committed By: jakllsch Date: Fri Jul 26 18:54:49 UTC 2024 Modified Files: src/usr.sbin/service: service Log Message: Fix missing whitespace in not found message. >From Daniel Cunha in PR 58471 To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/service/service Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:34:35 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: wg(4): Allow modunload before any interface creation. The workqueue and pktq are both lazily created, for annoying module initialization order reasons, so they may not have been created by the time of modunload. PR kern/58470 To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.91 src/sys/net/if_wg.c:1.92 --- src/sys/net/if_wg.c:1.91 Thu Jul 25 16:45:36 2024 +++ src/sys/net/if_wg.c Fri Jul 26 18:34:35 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.91 2024/07/25 16:45:36 christos Exp $ */ +/* $NetBSD: if_wg.c,v 1.92 2024/07/26 18:34:35 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.91 2024/07/25 16:45:36 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.92 2024/07/26 18:34:35 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -924,8 +924,10 @@ wgdetach(void) } /* No interfaces left. Nuke it. */ - workqueue_destroy(wg_wq); - pktq_destroy(wg_pktq); + if (wg_wq) + workqueue_destroy(wg_wq); + if (wg_pktq) + pktq_destroy(wg_pktq); psref_class_destroy(wg_psref_class); return 0;
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:34:35 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: wg(4): Allow modunload before any interface creation. The workqueue and pktq are both lazily created, for annoying module initialization order reasons, so they may not have been created by the time of modunload. PR kern/58470 To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:32:15 UTC 2024 Modified Files: src/sys/crypto/sodium: sodium_selftest.h src/sys/external/isc/libsodium/src: sodium_selftest.c Log Message: sys/crypto/sodium: Add self-test for XChaCha20/Poly1305 AEAD. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/sodium/sodium_selftest.h cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/src/sodium_selftest.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/crypto/sodium/sodium_selftest.h diff -u src/sys/crypto/sodium/sodium_selftest.h:1.1 src/sys/crypto/sodium/sodium_selftest.h:1.2 --- src/sys/crypto/sodium/sodium_selftest.h:1.1 Fri Jul 26 18:25:03 2024 +++ src/sys/crypto/sodium/sodium_selftest.h Fri Jul 26 18:32:15 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: sodium_selftest.h,v 1.1 2024/07/26 18:25:03 riastradh Exp $ */ +/* $NetBSD: sodium_selftest.h,v 1.2 2024/07/26 18:32:15 riastradh Exp $ */ /*- * Copyright (c) 2024 The NetBSD Foundation, Inc. @@ -30,6 +30,7 @@ #define _SYS_CRYPTO_SODIUM_SODIUM_SELFTEST_H_ int crypto_aead_chacha20poly1305_ietf_selftest(void); +int crypto_aead_xchacha20poly1305_ietf_selftest(void); int sodium_selftest(void); Index: src/sys/external/isc/libsodium/src/sodium_selftest.c diff -u src/sys/external/isc/libsodium/src/sodium_selftest.c:1.1 src/sys/external/isc/libsodium/src/sodium_selftest.c:1.2 --- src/sys/external/isc/libsodium/src/sodium_selftest.c:1.1 Fri Jul 26 18:25:03 2024 +++ src/sys/external/isc/libsodium/src/sodium_selftest.c Fri Jul 26 18:32:15 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: sodium_selftest.c,v 1.1 2024/07/26 18:25:03 riastradh Exp $ */ +/* $NetBSD: sodium_selftest.c,v 1.2 2024/07/26 18:32:15 riastradh Exp $ */ /*- * Copyright (c) 2024 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #ifdef _KERNEL #include -__KERNEL_RCSID(0, "$NetBSD: sodium_selftest.c,v 1.1 2024/07/26 18:25:03 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sodium_selftest.c,v 1.2 2024/07/26 18:32:15 riastradh Exp $"); #include @@ -40,7 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: sodium_selft #else #include -__RCSID("$NetBSD: sodium_selftest.c,v 1.1 2024/07/26 18:25:03 riastradh Exp $"); +__RCSID("$NetBSD: sodium_selftest.c,v 1.2 2024/07/26 18:32:15 riastradh Exp $"); #include #include @@ -70,6 +70,7 @@ hexdump(int (*prf)(const char *, ...) __ #endif #include +#include #include /* @@ -321,11 +322,255 @@ crypto_aead_chacha20poly1305_ietf_selfte } int +crypto_aead_xchacha20poly1305_ietf_selftest(void) +{ + /* https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-xchacha#appendix-A.3.1 */ + static const uint8_t plaintext[] = { + 0x4c,0x61,0x64,0x69, 0x65,0x73,0x20,0x61, + 0x6e,0x64,0x20,0x47, 0x65,0x6e,0x74,0x6c, + 0x65,0x6d,0x65,0x6e, 0x20,0x6f,0x66,0x20, + 0x74,0x68,0x65,0x20, 0x63,0x6c,0x61,0x73, + 0x73,0x20,0x6f,0x66, 0x20,0x27,0x39,0x39, + 0x3a,0x20,0x49,0x66, 0x20,0x49,0x20,0x63, + 0x6f,0x75,0x6c,0x64, 0x20,0x6f,0x66,0x66, + 0x65,0x72,0x20,0x79, 0x6f,0x75,0x20,0x6f, + 0x6e,0x6c,0x79,0x20, 0x6f,0x6e,0x65,0x20, + 0x74,0x69,0x70,0x20, 0x66,0x6f,0x72,0x20, + 0x74,0x68,0x65,0x20, 0x66,0x75,0x74,0x75, + 0x72,0x65,0x2c,0x20, 0x73,0x75,0x6e,0x73, + 0x63,0x72,0x65,0x65, 0x6e,0x20,0x77,0x6f, + 0x75,0x6c,0x64,0x20, 0x62,0x65,0x20,0x69, + 0x74,0x2e, + }; + static const uint8_t aad[] = { + 0x50,0x51,0x52,0x53, 0xc0,0xc1,0xc2,0xc3, + 0xc4,0xc5,0xc6,0xc7, + }; + static const uint8_t key[] = { + 0x80,0x81,0x82,0x83, 0x84,0x85,0x86,0x87, + 0x88,0x89,0x8a,0x8b, 0x8c,0x8d,0x8e,0x8f, + 0x90,0x91,0x92,0x93, 0x94,0x95,0x96,0x97, + 0x98,0x99,0x9a,0x9b, 0x9c,0x9d,0x9e,0x9f, + }; + static const uint8_t nonce[] = { + 0x40,0x41,0x42,0x43, 0x44,0x45,0x46,0x47, + 0x48,0x49,0x4a,0x4b, 0x4c,0x4d,0x4e,0x4f, + 0x50,0x51,0x52,0x53, 0x54,0x55,0x56,0x57, + 0x00,0x00,0x00,0x00, + }; + static const uint8_t ciphertext[] = { + 0xbd,0x6d,0x17,0x9d, 0x3e,0x83,0xd4,0x3b, + 0x95,0x76,0x57,0x94, 0x93,0xc0,0xe9,0x39, + 0x57,0x2a,0x17,0x00, 0x25,0x2b,0xfa,0xcc, + 0xbe,0xd2,0x90,0x2c, 0x21,0x39,0x6c,0xbb, + 0x73,0x1c,0x7f,0x1b, 0x0b,0x4a,0xa6,0x44, + 0x0b,0xf3,0xa8,0x2f, 0x4e,0xda,0x7e,0x39, + 0xae,0x64,0xc6,0x70, 0x8c,0x54,0xc2,0x16, + 0xcb,0x96,0xb7,0x2e, 0x12,0x13,0xb4,0x52, + 0x2f,0x8c,0x9b,0xa4, 0x0d,0xb5,0xd9,0x45, + 0xb1,0x1b,0x69,0xb9, 0x82,0xc1,0xbb,0x9e, + 0x3f,0x3f,0xac,0x2b, 0xc3,0x69,0x48,0x8f, + 0x76,0xb2,0x38,0x35, 0x65,0xd3,0xff,0xf9, + 0x21,0xf9,0x66,0x4c, 0x97,0x63,0x7d,0xa9, + 0x76,0x88,0x12,0xf6, 0x15,0xc6,0x8b,0x13, + 0xb5,0x2e, + + 0xc0,0x87,0x59,0x24, 0xc1,0xc7,0x98,0x79, + 0x47,0xde,0xaf,0xd8, 0x78,0x0a,0xcf,0x49, + }; + uint8_t inbuf[sizeof(ciphertext) + TESTALIGN]; + uint8_t outbuf[sizeof(ciphertext) + TESTALIGN]; + uint8_t aadbuf[sizeof(aad) + TESTALIGN]; + uint8_t noncebuf[sizeof(nonce) + TESTALIGN]; + uint8_t keybuf[sizeof(key) + TESTALIGN]; + unsigned i, j, k,
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:32:15 UTC 2024 Modified Files: src/sys/crypto/sodium: sodium_selftest.h src/sys/external/isc/libsodium/src: sodium_selftest.c Log Message: sys/crypto/sodium: Add self-test for XChaCha20/Poly1305 AEAD. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/sodium/sodium_selftest.h cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/src/sodium_selftest.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:31:45 UTC 2024 Modified Files: src/sys/external/isc/libsodium/include: stdlib.h Log Message: sys/crypto/sodium: Tighten stdlib.h glue. 1. Make sure nothing uses malloc and free. All of the routines we need should work in fixed-size, caller-allocated buffers and reasonable stack space. 2. Make panic message for abort() stub clearer. There are calls to it, but they imply internal errors inside libsodium which should not happen unless there is an unrecoverable software bug in libsodium. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/include/stdlib.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/isc/libsodium/include/stdlib.h diff -u src/sys/external/isc/libsodium/include/stdlib.h:1.1 src/sys/external/isc/libsodium/include/stdlib.h:1.2 --- src/sys/external/isc/libsodium/include/stdlib.h:1.1 Thu Aug 20 21:20:16 2020 +++ src/sys/external/isc/libsodium/include/stdlib.h Fri Jul 26 18:31:45 2024 @@ -2,7 +2,7 @@ #include #undef malloc #undef free -#define malloc(size) kern_malloc(size, 0) -#define free(addr) kern_free(addr) +#define malloc(size) __malloc_should_not_be_used +#define free(addr) __free_should_not_be_used -#define abort() panic("abort") +#define abort() panic("libsodium internal error")
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:31:45 UTC 2024 Modified Files: src/sys/external/isc/libsodium/include: stdlib.h Log Message: sys/crypto/sodium: Tighten stdlib.h glue. 1. Make sure nothing uses malloc and free. All of the routines we need should work in fixed-size, caller-allocated buffers and reasonable stack space. 2. Make panic message for abort() stub clearer. There are calls to it, but they imply internal errors inside libsodium which should not happen unless there is an unrecoverable software bug in libsodium. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/include/stdlib.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:30:43 UTC 2024 Modified Files: src/sys/external/isc/libsodium/include: stdint.h Log Message: sys/crypto/sodium: Simplify stdint.h stub. No change to the .o or .kmod files; just the .d make dependency files change. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/include/stdint.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/isc/libsodium/include/stdint.h diff -u src/sys/external/isc/libsodium/include/stdint.h:1.1 src/sys/external/isc/libsodium/include/stdint.h:1.2 --- src/sys/external/isc/libsodium/include/stdint.h:1.1 Thu Aug 20 21:20:16 2020 +++ src/sys/external/isc/libsodium/include/stdint.h Fri Jul 26 18:30:43 2024 @@ -1,2 +1 @@ -#include -#include +#include
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:30:43 UTC 2024 Modified Files: src/sys/external/isc/libsodium/include: stdint.h Log Message: sys/crypto/sodium: Simplify stdint.h stub. No change to the .o or .kmod files; just the .d make dependency files change. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/include/stdint.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:30:27 UTC 2024 Removed Files: src/sys/external/isc/libsodium/include: errno.h Log Message: sys/crypto/sodium: Nix unused errno.h. Maybe this was a vestige of an earlier draft of the libsodium import, but it doesn't appear to be needed now by any libsodium files we use. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r0 src/sys/external/isc/libsodium/include/errno.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:30:27 UTC 2024 Removed Files: src/sys/external/isc/libsodium/include: errno.h Log Message: sys/crypto/sodium: Nix unused errno.h. Maybe this was a vestige of an earlier draft of the libsodium import, but it doesn't appear to be needed now by any libsodium files we use. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r0 src/sys/external/isc/libsodium/include/errno.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:29:50 UTC 2024 Modified Files: src/sys/external/isc/libsodium/include: core.h Log Message: sys/crypto/sodium: Nix risky defines from core.h stub. These are risky not because they might cause crypto flaws, but because they might cause usage of the SIMD unit in the kernel along paths where we haven't made it safe. That said -- no change to the amd64 module .o and .kmod files, so this doesn't currently make a difference; it's just risky to have around in case we later include other parts of libsodium that it does affect, like the Salsa20 code. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/include/core.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/isc/libsodium/include/core.h diff -u src/sys/external/isc/libsodium/include/core.h:1.1 src/sys/external/isc/libsodium/include/core.h:1.2 --- src/sys/external/isc/libsodium/include/core.h:1.1 Thu Aug 20 21:20:16 2020 +++ src/sys/external/isc/libsodium/include/core.h Fri Jul 26 18:29:50 2024 @@ -2,11 +2,3 @@ #include "../dist/src/libsodium/include/sodium/export.h" #define sodium_misuse() panic("sodium_misuse") - -#ifdef __x86_64__ -/* From Makefile generated by libsodium/configure on NetBSD/amd64 */ -#define HAVE_AMD64_ASM 1 -//#define HAVE_AVX_ASM 1 -#define HAVE_CPUID 1 -//#define HAVE_TI_MODE 1 -#endif
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:29:50 UTC 2024 Modified Files: src/sys/external/isc/libsodium/include: core.h Log Message: sys/crypto/sodium: Nix risky defines from core.h stub. These are risky not because they might cause crypto flaws, but because they might cause usage of the SIMD unit in the kernel along paths where we haven't made it safe. That said -- no change to the amd64 module .o and .kmod files, so this doesn't currently make a difference; it's just risky to have around in case we later include other parts of libsodium that it does affect, like the Salsa20 code. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/include/core.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:29:03 UTC 2024 Removed Files: src/sys/external/isc/libsodium/include: assert.h Log Message: sys/crypto/sodium: Nix unused assert.h stub. Maybe this was a vestige of an earlier draft of the libsodium import, but it doesn't appear to be needed now by any libsodium files we use. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r0 src/sys/external/isc/libsodium/include/assert.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:29:03 UTC 2024 Removed Files: src/sys/external/isc/libsodium/include: assert.h Log Message: sys/crypto/sodium: Nix unused assert.h stub. Maybe this was a vestige of an earlier draft of the libsodium import, but it doesn't appear to be needed now by any libsodium files we use. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r0 src/sys/external/isc/libsodium/include/assert.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:28:27 UTC 2024 Modified Files: src/sys/external/isc/libsodium/include: string.h Log Message: sys/crypto/sodium: Simplify string.h stub. Not sure of any particular problem with the previous stub, but let's make sure to use the same prototypes for memset/memcpy/memmove as everything else in the kernel. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/include/string.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:28:27 UTC 2024 Modified Files: src/sys/external/isc/libsodium/include: string.h Log Message: sys/crypto/sodium: Simplify string.h stub. Not sure of any particular problem with the previous stub, but let's make sure to use the same prototypes for memset/memcpy/memmove as everything else in the kernel. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/include/string.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/isc/libsodium/include/string.h diff -u src/sys/external/isc/libsodium/include/string.h:1.1 src/sys/external/isc/libsodium/include/string.h:1.2 --- src/sys/external/isc/libsodium/include/string.h:1.1 Thu Aug 20 21:20:16 2020 +++ src/sys/external/isc/libsodium/include/string.h Fri Jul 26 18:28:27 2024 @@ -1,6 +1 @@ -#include -#include - -extern void *memset(void *, int, size_t); -extern void *memcpy(void * restrict, const void * restrict, size_t); -extern void *memmove(void *, const void *, size_t); +#include /* memset, memcpy, memmove */
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:27:48 UTC 2024 Modified Files: src/sys/external/isc/libsodium/include: crypto_verify_16.h Log Message: sys/crypto/sodium: Fill out crypto_verify_16 stub. Without this change, libsodium silently accepts forgeries. This one's a doozy, and it's a sobering reminder that: (a) wg(4) is still experimental (only user of libsodium in kernel; both are available only through default-off optional modules). (b) Known-answer test vectors are critical, including negative tests (test that forgeries are rejected), and must be mandatory for all new crypto code -- and should be added to old crypto code too. (c) Crypto code must also have self-tests that run in the same environment, not just the same code in a different build or test environment -- the libsodium code itself is fine, but we built it differently and need to exercise it differently from upstream's automatic tests. It's my fault for not catching this earlier. What happened is: 1. ozaki-r@ adapted libsodium to build in the kernel with various glue to build code meant for standard userland C, like errno.h and string.h. 2. Since libsodium's crypto_verify_16.c uses various SIMD intrinsics on various architectures, it couldn't be used directly in the kernel build, because -- at the time -- we hadn't wired up any header files for SIMD intrinsics or any runtime support for saving and restoring SIMD state appropriately in the kernel. 3. ozaki-r@ put a similar glue header file crypto_verify_16.h to override libsodium's, with a stub to be implemented later, and presumably forgot to remind me about it. 4. I missed the stub in crypto_verify_16.h when reviewing the libsodium import and wg(4) code because it was in the same directory as various other simple glue code that I deemed low-risk. (I did make one change to that glue code, to replace cprng_fast by cprng_strong, but I suspect I found that by searching for cprng_fast users rather than by reviewing this code.) 5. I broke my own rule about always having known-answer test vectors for crypto code because I figured libsodium was well-enough exercised that we could skimp on it for now, and my focus was more on the state machine and synchronization logic than on the crypto. 6. I had not yet written known-answer test vectors for the higher-level wg(4) protocol messages. Before we can remove the `experimental' tag from wg(4) we will need to (among other things): i. Write self-tests for the rest of (what we use from) libsodium. ii. Write extensive known-answer test vectors for all the wg(4) protocol messages (and ideally state machine transitions). iii. Write self-tests for a reasonable subset of the wg(4) KATs. iv. Review all of the libsodium glue code I neglected to review. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/sys/external/isc/libsodium/include/crypto_verify_16.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/external/isc/libsodium/include
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:27:48 UTC 2024 Modified Files: src/sys/external/isc/libsodium/include: crypto_verify_16.h Log Message: sys/crypto/sodium: Fill out crypto_verify_16 stub. Without this change, libsodium silently accepts forgeries. This one's a doozy, and it's a sobering reminder that: (a) wg(4) is still experimental (only user of libsodium in kernel; both are available only through default-off optional modules). (b) Known-answer test vectors are critical, including negative tests (test that forgeries are rejected), and must be mandatory for all new crypto code -- and should be added to old crypto code too. (c) Crypto code must also have self-tests that run in the same environment, not just the same code in a different build or test environment -- the libsodium code itself is fine, but we built it differently and need to exercise it differently from upstream's automatic tests. It's my fault for not catching this earlier. What happened is: 1. ozaki-r@ adapted libsodium to build in the kernel with various glue to build code meant for standard userland C, like errno.h and string.h. 2. Since libsodium's crypto_verify_16.c uses various SIMD intrinsics on various architectures, it couldn't be used directly in the kernel build, because -- at the time -- we hadn't wired up any header files for SIMD intrinsics or any runtime support for saving and restoring SIMD state appropriately in the kernel. 3. ozaki-r@ put a similar glue header file crypto_verify_16.h to override libsodium's, with a stub to be implemented later, and presumably forgot to remind me about it. 4. I missed the stub in crypto_verify_16.h when reviewing the libsodium import and wg(4) code because it was in the same directory as various other simple glue code that I deemed low-risk. (I did make one change to that glue code, to replace cprng_fast by cprng_strong, but I suspect I found that by searching for cprng_fast users rather than by reviewing this code.) 5. I broke my own rule about always having known-answer test vectors for crypto code because I figured libsodium was well-enough exercised that we could skimp on it for now, and my focus was more on the state machine and synchronization logic than on the crypto. 6. I had not yet written known-answer test vectors for the higher-level wg(4) protocol messages. Before we can remove the `experimental' tag from wg(4) we will need to (among other things): i. Write self-tests for the rest of (what we use from) libsodium. ii. Write extensive known-answer test vectors for all the wg(4) protocol messages (and ideally state machine transitions). iii. Write self-tests for a reasonable subset of the wg(4) KATs. iv. Review all of the libsodium glue code I neglected to review. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 \ src/sys/external/isc/libsodium/include/crypto_verify_16.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/isc/libsodium/include/crypto_verify_16.h diff -u src/sys/external/isc/libsodium/include/crypto_verify_16.h:1.1 src/sys/external/isc/libsodium/include/crypto_verify_16.h:1.2 --- src/sys/external/isc/libsodium/include/crypto_verify_16.h:1.1 Thu Aug 20 21:20:16 2020 +++ src/sys/external/isc/libsodium/include/crypto_verify_16.h Fri Jul 26 18:27:48 2024 @@ -1,9 +1,17 @@ /* This overwrites dist/src/libsodium/include/sodium/crypto_verify_16.h */ -/* dummy */ +#include + static inline int crypto_verify_16(const unsigned char *x, const unsigned char *y) { - return 0; + /* + * crypto_verify_16 must return 0 if equal, -1 if not. + * + * consttime_memequal returns 1 if equal, 0 if not. + * + * Hence we simply subtract one. + */ + return consttime_memequal(x, y, 16) - 1; }
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:25:03 UTC 2024 Modified Files: src/sys/external/isc/libsodium/conf: files.libsodium src/sys/external/isc/libsodium/src: sodium_module.c src/sys/modules/sodium: Makefile.sodmod src/sys/rump/kern/lib/libcrypto: Makefile Added Files: src/sys/crypto/sodium: sodium_selftest.h src/sys/external/isc/libsodium/src: sodium_selftest.c Log Message: sys/crypto/sodium: Add a self-test for IETF ChaCha20/Poly1305 AEAD. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/crypto/sodium/sodium_selftest.h cvs rdiff -u -r1.6 -r1.7 src/sys/external/isc/libsodium/conf/files.libsodium cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/src/sodium_module.c cvs rdiff -u -r0 -r1.1 src/sys/external/isc/libsodium/src/sodium_selftest.c cvs rdiff -u -r1.3 -r1.4 src/sys/modules/sodium/Makefile.sodmod cvs rdiff -u -r1.23 -r1.24 src/sys/rump/kern/lib/libcrypto/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/external/isc/libsodium/conf/files.libsodium diff -u src/sys/external/isc/libsodium/conf/files.libsodium:1.6 src/sys/external/isc/libsodium/conf/files.libsodium:1.7 --- src/sys/external/isc/libsodium/conf/files.libsodium:1.6 Sat Aug 21 09:09:39 2021 +++ src/sys/external/isc/libsodium/conf/files.libsodium Fri Jul 26 18:25:03 2024 @@ -1,4 +1,4 @@ -# $NetBSD: files.libsodium,v 1.6 2021/08/21 09:09:39 christos Exp $ +# $NetBSD: files.libsodium,v 1.7 2024/07/26 18:25:03 riastradh Exp $ define libsodium @@ -12,6 +12,7 @@ makeoptions libsodium "CWARNFLAGS.libsod makeoptions libsodium "CWARNFLAGS.libsodium"+="-Wno-unused-variable" file external/isc/libsodium/src/sodium_module.c libsodium +file external/isc/libsodium/src/sodium_selftest.c libsodium file external/isc/libsodium/dist/src/libsodium/crypto_scalarmult/curve25519/ref10/x25519_ref10.c libsodium file external/isc/libsodium/dist/src/libsodium/crypto_scalarmult/curve25519/scalarmult_curve25519.c libsodium Index: src/sys/external/isc/libsodium/src/sodium_module.c diff -u src/sys/external/isc/libsodium/src/sodium_module.c:1.1 src/sys/external/isc/libsodium/src/sodium_module.c:1.2 --- src/sys/external/isc/libsodium/src/sodium_module.c:1.1 Sat Aug 21 09:08:08 2021 +++ src/sys/external/isc/libsodium/src/sodium_module.c Fri Jul 26 18:25:03 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: sodium_module.c,v 1.1 2021/08/21 09:08:08 christos Exp $ */ +/* $NetBSD: sodium_module.c,v 1.2 2024/07/26 18:25:03 riastradh Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -27,12 +27,14 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sodium_module.c,v 1.1 2021/08/21 09:08:08 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sodium_module.c,v 1.2 2024/07/26 18:25:03 riastradh Exp $"); #include #include #include +#include + MODULE(MODULE_CLASS_MISC, sodium, NULL); static int @@ -41,6 +43,10 @@ sodium_modcmd(modcmd_t cmd, void *arg) switch (cmd) { case MODULE_CMD_INIT: + if (sodium_selftest()) { + printf("sodium self-test failed\n"); + return EIO; + } break; case MODULE_CMD_FINI: Index: src/sys/modules/sodium/Makefile.sodmod diff -u src/sys/modules/sodium/Makefile.sodmod:1.3 src/sys/modules/sodium/Makefile.sodmod:1.4 --- src/sys/modules/sodium/Makefile.sodmod:1.3 Sat Aug 21 09:07:08 2021 +++ src/sys/modules/sodium/Makefile.sodmod Fri Jul 26 18:25:03 2024 @@ -1,10 +1,11 @@ -# $NetBSD: Makefile.sodmod,v 1.3 2021/08/21 09:07:08 christos Exp $ +# $NetBSD: Makefile.sodmod,v 1.4 2024/07/26 18:25:03 riastradh Exp $ SODIUMDIR= ${S}/external/isc/libsodium SODIUMSRCDIR= ${SODIUMDIR}/dist/src/libsodium .PATH: ${SODIUMDIR}/src SRCS+= sodium_module.c +SRCS+= sodium_selftest.c .PATH: ${SODIUMSRCDIR}/crypto_scalarmult/curve25519/ref10 SRCS+= x25519_ref10.c Index: src/sys/rump/kern/lib/libcrypto/Makefile diff -u src/sys/rump/kern/lib/libcrypto/Makefile:1.23 src/sys/rump/kern/lib/libcrypto/Makefile:1.24 --- src/sys/rump/kern/lib/libcrypto/Makefile:1.23 Sat Aug 21 09:08:55 2021 +++ src/sys/rump/kern/lib/libcrypto/Makefile Fri Jul 26 18:25:03 2024 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.23 2021/08/21 09:08:55 christos Exp $ +# $NetBSD: Makefile,v 1.24 2024/07/26 18:25:03 riastradh Exp $ # S=${.CURDIR}/../../../.. @@ -81,6 +81,7 @@ SODIUM_SRCS+= aead_chacha20poly1305.c SODIUM_SRCS+= core_hchacha20.c SODIUM_SRCS+= ed25519_ref10.c SODIUM_SRCS+= sodium_module.c +SODIUM_SRCS+= sodium_selftest.c SRCS+= ${SODIUM_SRCS} Added files: Index: src/sys/crypto/sodium/sodium_selftest.h diff -u /dev/null src/sys/crypto/sodium/sodium_selftest.h:1.1 --- /dev/null Fri Jul 26 18:25:03 2024 +++ src/sys/crypto/sodium/sodium_selftest.h Fri Jul 26 18:25:03 2024 @@ -0,0 +1,36 @@ +/* $NetBSD: sodium_selftest.h,v 1.1 2024/07/26 18:25:03 riastradh Exp $ */ + +/*- + * Copyright (c) 2024 The NetBSD Foundation, Inc. + *
CVS commit: src/sys
Module Name:src Committed By: riastradh Date: Fri Jul 26 18:25:03 UTC 2024 Modified Files: src/sys/external/isc/libsodium/conf: files.libsodium src/sys/external/isc/libsodium/src: sodium_module.c src/sys/modules/sodium: Makefile.sodmod src/sys/rump/kern/lib/libcrypto: Makefile Added Files: src/sys/crypto/sodium: sodium_selftest.h src/sys/external/isc/libsodium/src: sodium_selftest.c Log Message: sys/crypto/sodium: Add a self-test for IETF ChaCha20/Poly1305 AEAD. PR kern/58468 To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/crypto/sodium/sodium_selftest.h cvs rdiff -u -r1.6 -r1.7 src/sys/external/isc/libsodium/conf/files.libsodium cvs rdiff -u -r1.1 -r1.2 src/sys/external/isc/libsodium/src/sodium_module.c cvs rdiff -u -r0 -r1.1 src/sys/external/isc/libsodium/src/sodium_selftest.c cvs rdiff -u -r1.3 -r1.4 src/sys/modules/sodium/Makefile.sodmod cvs rdiff -u -r1.23 -r1.24 src/sys/rump/kern/lib/libcrypto/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Thu Jul 25 16:45:36 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: consistently use printf instead of aprint_debug and print the tkeys with the packet. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.90 src/sys/net/if_wg.c:1.91 --- src/sys/net/if_wg.c:1.90 Wed Jul 24 21:47:00 2024 +++ src/sys/net/if_wg.c Thu Jul 25 12:45:36 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.90 2024/07/25 01:47:00 christos Exp $ */ +/* $NetBSD: if_wg.c,v 1.91 2024/07/25 16:45:36 christos Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.90 2024/07/25 01:47:00 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.91 2024/07/25 16:45:36 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -2715,8 +2715,10 @@ wg_handle_msg_data(struct wg_softc *wg, #ifdef WG_DEBUG_PACKET if (wg_debug & WG_DEBUG_FLAGS_PACKET) { - hexdump(aprint_debug, "wgmd", wgmd, sizeof(*wgmd)); - hexdump(aprint_debug, "decrypted_buf", decrypted_buf, + hexdump(printf, "tkey_recv", wgs->wgs_tkey_recv, + sizeof(wgs->wgs_tkey_recv)); + hexdump(printf, "wgmd", wgmd, sizeof(*wgmd)); + hexdump(printf, "decrypted_buf", decrypted_buf, decrypted_len); } #endif @@ -4096,8 +4098,7 @@ wg_send_data_msg(struct wg_peer *wgp, st wg_fill_msg_data(wg, wgp, wgs, wgmd); #ifdef WG_DEBUG_PACKET if (wg_debug & WG_DEBUG_FLAGS_PACKET) { - hexdump(aprint_debug, "wgmd", wgmd, sizeof(*wgmd)); - hexdump(aprint_debug, "padded_buf", padded_buf, + hexdump(printf, "padded_buf", padded_buf, padded_len); } #endif @@ -4108,7 +4109,10 @@ wg_send_data_msg(struct wg_peer *wgp, st NULL, 0); #ifdef WG_DEBUG_PACKET if (wg_debug & WG_DEBUG_FLAGS_PACKET) { - hexdump(aprint_debug, "outgoing packet", + hexdump(printf, "tkey_send", wgs->wgs_tkey_send, + sizeof(wgs->wgs_tkey_send)); + hexdump(printf, "wgmd", wgmd, sizeof(*wgmd)); + hexdump(printf, "outgoing packet", (char *)wgmd + sizeof(*wgmd), encrypted_len); size_t decrypted_len = encrypted_len - WG_AUTHTAG_LEN; char *decrypted_buf = kmem_intr_alloc((decrypted_len +
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Thu Jul 25 16:45:36 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: consistently use printf instead of aprint_debug and print the tkeys with the packet. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: nia Date: Thu Jul 25 13:55:48 UTC 2024 Modified Files: src/doc: CHANGES Log Message: doc: update CHANGES To generate a diff of this commit: cvs rdiff -u -r1.3073 -r1.3074 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.3073 src/doc/CHANGES:1.3074 --- src/doc/CHANGES:1.3073 Mon Jul 8 22:36:29 2024 +++ src/doc/CHANGES Thu Jul 25 13:55:47 2024 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.3073 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.3074 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -450,3 +450,10 @@ Changes from NetBSD 10.0 to NetBSD 11.0: mcx(4): Match on ConnectX-6 virtual functions, from OpenBSD. [msaitoh 20240707] OpenSSH: Import 9.8. [christos 20240708] + patch(1): Handle lines of length beyond INT16_MAX. [manu 20240712] + sh(1): Implement the HISTFILE and HISTAPPEND variables. [kre 20240713] + mips: Switch to binutils 2.42. [rin 20240713] + riscv: Switch to binutils 2.42. [skrll 20240714] + aarch64: Switch to binutils 2.42. [skrll 20240714] + hppa: Switch to binutils 2.42. [skrll 20240715] + hppa: Add hyperfb, a driver for HCRX video cards. [macallan 20240717]
CVS commit: src/doc
Module Name:src Committed By: nia Date: Thu Jul 25 13:55:48 UTC 2024 Modified Files: src/doc: CHANGES Log Message: doc: update CHANGES To generate a diff of this commit: cvs rdiff -u -r1.3073 -r1.3074 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Thu Jul 25 01:47:01 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Add more debugging from Taylor To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.89 src/sys/net/if_wg.c:1.90 --- src/sys/net/if_wg.c:1.89 Wed Jul 24 20:55:53 2024 +++ src/sys/net/if_wg.c Wed Jul 24 21:47:00 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.89 2024/07/25 00:55:53 kre Exp $ */ +/* $NetBSD: if_wg.c,v 1.90 2024/07/25 01:47:00 christos Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.89 2024/07/25 00:55:53 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.90 2024/07/25 01:47:00 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -2660,6 +2660,12 @@ wg_handle_msg_data(struct wg_softc *wg, KASSERT(m->m_len >= sizeof(*wgmd)); wgmd = mtod(m, struct wg_msg_data *); +#ifdef WG_DEBUG_PACKET + if (wg_debug & WG_DEBUG_FLAGS_PACKET) { + hexdump(printf, "incoming packet", encrypted_buf, + encrypted_len); + } +#endif /* * Get a buffer for the plaintext. Add WG_AUTHTAG_LEN to avoid * a zero-length buffer (XXX). Drop if plaintext is longer @@ -4100,6 +4106,34 @@ wg_send_data_msg(struct wg_peer *wgp, st wgs->wgs_tkey_send, le64toh(wgmd->wgmd_counter), padded_buf, padded_len, NULL, 0); +#ifdef WG_DEBUG_PACKET + if (wg_debug & WG_DEBUG_FLAGS_PACKET) { + hexdump(aprint_debug, "outgoing packet", + (char *)wgmd + sizeof(*wgmd), encrypted_len); + size_t decrypted_len = encrypted_len - WG_AUTHTAG_LEN; + char *decrypted_buf = kmem_intr_alloc((decrypted_len + + WG_AUTHTAG_LEN/*XXX*/), KM_NOSLEEP); + if (decrypted_buf != NULL) { + error = wg_algo_aead_dec( + 1 + decrypted_buf /* force misalignment */, + encrypted_len - WG_AUTHTAG_LEN /* XXX */, + wgs->wgs_tkey_send, le64toh(wgmd->wgmd_counter), + (char *)wgmd + sizeof(*wgmd), encrypted_len, + NULL, 0); + if (error) { +WG_DLOG("wg_algo_aead_dec failed: %d\n", +error); + } + if (!consttime_memequal(1 + decrypted_buf, +(char *)wgmd + sizeof(*wgmd), +decrypted_len)) { +WG_DLOG("wg_algo_aead_dec returned garbage\n"); + } + kmem_intr_free(decrypted_buf, (decrypted_len + +WG_AUTHTAG_LEN/*XXX*/)); + } + } +#endif error = wg->wg_ops->send_data_msg(wgp, n); if (error == 0) {
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Thu Jul 25 01:47:01 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Add more debugging from Taylor To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: kre Date: Thu Jul 25 00:55:53 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Make the debug (WG_DEBUG) func gethexdump() always return a valid pointer, never NULL, so it doesn't need to be tested before being printed, which was being done sometimes, but not always. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.88 src/sys/net/if_wg.c:1.89 --- src/sys/net/if_wg.c:1.88 Thu Jul 25 00:37:08 2024 +++ src/sys/net/if_wg.c Thu Jul 25 00:55:53 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.88 2024/07/25 00:37:08 kre Exp $ */ +/* $NetBSD: if_wg.c,v 1.89 2024/07/25 00:55:53 kre Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.88 2024/07/25 00:37:08 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.89 2024/07/25 00:55:53 kre Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -243,6 +243,8 @@ static bool wg_force_underload = false; #ifdef WG_DEBUG_DUMP +static char enomem[10] = "[enomem]"; + static char * gethexdump(const void *vp, size_t n) { @@ -251,10 +253,10 @@ gethexdump(const void *vp, size_t n) size_t i; if (n > (SIZE_MAX - 1) / 3) - return NULL; + return enomem; buf = kmem_alloc(3 * n + 1, KM_NOSLEEP); if (buf == NULL) - return NULL; + return enomem; for (i = 0; i < n; i++) snprintf(buf + 3 * i, 3 + 1, " %02hhx", p[i]); return buf; @@ -264,7 +266,7 @@ static void puthexdump(char *buf, const void *p, size_t n) { - if (buf == NULL) + if (buf == NULL || buf == enomem) return; kmem_free(buf, 3*n + 1); } @@ -278,7 +280,7 @@ wg_dump_buf(const char *func, const char char *hex = gethexdump(buf, size); - log(LOG_DEBUG, "%s: %s\n", func, hex ? hex : "(enomem)"); + log(LOG_DEBUG, "%s: %s\n", func, hex); puthexdump(hex, buf, size); } #endif @@ -292,7 +294,7 @@ wg_dump_hash(const uint8_t *func, const char *hex = gethexdump(hash, size); - log(LOG_DEBUG, "%s: %s: %s\n", func, name, hex ? hex : "(enomem)"); + log(LOG_DEBUG, "%s: %s: %s\n", func, name, hex); puthexdump(hex, hash, size); }
CVS commit: src/sys/net
Module Name:src Committed By: kre Date: Thu Jul 25 00:55:53 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Make the debug (WG_DEBUG) func gethexdump() always return a valid pointer, never NULL, so it doesn't need to be tested before being printed, which was being done sometimes, but not always. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: kre Date: Thu Jul 25 00:37:08 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: There's a new WG_DEBUG_XXX ( XXX==PACKET ) to deal with now. That needs WG_DEBUG defined as well, if set. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.87 src/sys/net/if_wg.c:1.88 --- src/sys/net/if_wg.c:1.87 Thu Jul 25 00:29:24 2024 +++ src/sys/net/if_wg.c Thu Jul 25 00:37:08 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.87 2024/07/25 00:29:24 kre Exp $ */ +/* $NetBSD: if_wg.c,v 1.88 2024/07/25 00:37:08 kre Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.87 2024/07/25 00:29:24 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.88 2024/07/25 00:37:08 kre Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -197,7 +197,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. #ifndef WG_DEBUG # if defined(WG_DEBUG_LOG) || defined(WG_DEBUG_TRACE) || \ - defined(WG_DEBUG_DUMP) || defined(WG_DEBUG_PARAMS) + defined(WG_DEBUG_DUMP) || defined(WG_DEBUG_PARAMS) || \ + defined(WG_DEBUG_PACKET) # define WG_DEBUG # endif #endif
CVS commit: src/sys/net
Module Name:src Committed By: kre Date: Thu Jul 25 00:37:08 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: There's a new WG_DEBUG_XXX ( XXX==PACKET ) to deal with now. That needs WG_DEBUG defined as well, if set. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: kre Date: Thu Jul 25 00:29:24 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Fix 32 bit (32 bit size_t) WG_DEBUG builds - use %zu rather than %lu to print size_t values. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.86 src/sys/net/if_wg.c:1.87 --- src/sys/net/if_wg.c:1.86 Thu Jul 25 00:24:02 2024 +++ src/sys/net/if_wg.c Thu Jul 25 00:29:24 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.86 2024/07/25 00:24:02 christos Exp $ */ +/* $NetBSD: if_wg.c,v 1.87 2024/07/25 00:29:24 kre Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.86 2024/07/25 00:24:02 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.87 2024/07/25 00:29:24 kre Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -2638,7 +2638,7 @@ wg_handle_msg_data(struct wg_softc *wg, mlen = m_length(m); encrypted_len = mlen - sizeof(*wgmd); if (encrypted_len < WG_AUTHTAG_LEN) { - WG_DLOG("Short encrypted_len: %lu\n", encrypted_len); + WG_DLOG("Short encrypted_len: %zu\n", encrypted_len); goto out; } success = m_ensure_contig(, sizeof(*wgmd) + encrypted_len); @@ -2676,7 +2676,7 @@ wg_handle_msg_data(struct wg_softc *wg, decrypted_buf = mtod(n, char *); /* Decrypt and verify the packet. */ - WG_DLOG("mlen=%lu, encrypted_len=%lu\n", mlen, encrypted_len); + WG_DLOG("mlen=%zu, encrypted_len=%zu\n", mlen, encrypted_len); error = wg_algo_aead_dec(decrypted_buf, encrypted_len - WG_AUTHTAG_LEN /* can be 0 */, wgs->wgs_tkey_recv, le64toh(wgmd->wgmd_counter), encrypted_buf, @@ -2899,7 +2899,7 @@ wg_validate_msg_header(struct wg_softc * /* Verify the mbuf chain is long enough for this type of message. */ if (__predict_false(mbuflen < msglen)) { - WG_DLOG("Invalid msg size: mbuflen=%lu type=%u\n", mbuflen, + WG_DLOG("Invalid msg size: mbuflen=%zu type=%u\n", mbuflen, le32toh(wgm.wgm_type)); goto error; } @@ -4058,7 +4058,7 @@ wg_send_data_msg(struct wg_peer *wgp, st inner_len = mlen; padded_len = roundup(mlen, 16); encrypted_len = padded_len + WG_AUTHTAG_LEN; - WG_DLOG("inner=%lu, padded=%lu, encrypted_len=%lu\n", + WG_DLOG("inner=%zu, padded=%zu, encrypted_len=%zu\n", inner_len, padded_len, encrypted_len); if (mlen != 0) { bool success; @@ -4228,7 +4228,7 @@ wg_handle_prop_peer(struct wg_softc *wg, #ifdef WG_DEBUG_DUMP if (wg_debug & WG_DEBUG_FLAGS_DUMP) { char *hex = gethexdump(pubkey, pubkey_len); - log(LOG_DEBUG, "pubkey=%p, pubkey_len=%lu\n%s\n", + log(LOG_DEBUG, "pubkey=%p, pubkey_len=%zu\n%s\n", pubkey, pubkey_len, hex); puthexdump(hex, pubkey, pubkey_len); } @@ -4382,7 +4382,7 @@ wg_alloc_prop_buf(char **_buf, struct if int error; char *buf; - WG_DLOG("buf=%p, len=%lu\n", ifd->ifd_data, ifd->ifd_len); + WG_DLOG("buf=%p, len=%zu\n", ifd->ifd_data, ifd->ifd_len); if (ifd->ifd_len >= WG_MAX_PROPLEN) return E2BIG; buf = kmem_alloc(ifd->ifd_len + 1, KM_SLEEP); @@ -4422,7 +4422,7 @@ wg_ioctl_set_private_key(struct wg_softc #ifdef WG_DEBUG_DUMP if (wg_debug & WG_DEBUG_FLAGS_DUMP) { char *hex = gethexdump(privkey, privkey_len); - log(LOG_DEBUG, "privkey=%p, privkey_len=%lu\n%s\n", + log(LOG_DEBUG, "privkey=%p, privkey_len=%zu\n%s\n", privkey, privkey_len, hex); puthexdump(hex, privkey, privkey_len); } @@ -5092,7 +5092,7 @@ rumpkern_wg_recv_user(struct wg_softc *w m->m_len = m->m_pkthdr.len = 0; m_copyback(m, 0, iov[1].iov_len, iov[1].iov_base); - WG_DLOG("iov_len=%lu\n", iov[1].iov_len); + WG_DLOG("iov_len=%zu\n", iov[1].iov_len); WG_DUMP_BUF(iov[1].iov_base, iov[1].iov_len); (void)wg_output(ifp, m, dst, NULL); @@ -5118,7 +5118,7 @@ rumpkern_wg_recv_peer(struct wg_softc *w m->m_len = m->m_pkthdr.len = 0; m_copyback(m, 0, iov[1].iov_len, iov[1].iov_base); - WG_DLOG("iov_len=%lu\n", iov[1].iov_len); + WG_DLOG("iov_len=%zu\n", iov[1].iov_len); WG_DUMP_BUF(iov[1].iov_base, iov[1].iov_len); bound = curlwp_bind();
CVS commit: src/sys/net
Module Name:src Committed By: kre Date: Thu Jul 25 00:29:24 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Fix 32 bit (32 bit size_t) WG_DEBUG builds - use %zu rather than %lu to print size_t values. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Thu Jul 25 00:24:02 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: use hexdump... To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.85 src/sys/net/if_wg.c:1.86 --- src/sys/net/if_wg.c:1.85 Wed Jul 24 20:07:33 2024 +++ src/sys/net/if_wg.c Wed Jul 24 20:24:02 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.85 2024/07/25 00:07:33 christos Exp $ */ +/* $NetBSD: if_wg.c,v 1.86 2024/07/25 00:24:02 christos Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.85 2024/07/25 00:07:33 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.86 2024/07/25 00:24:02 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -83,6 +83,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. #include #include +#include + #include #include #include @@ -2704,19 +2706,9 @@ wg_handle_msg_data(struct wg_softc *wg, #ifdef WG_DEBUG_PACKET if (wg_debug & WG_DEBUG_FLAGS_PACKET) { - char *hex = gethexdump(wgmd, sizeof(*wgmd)); - if (hex != NULL) { - log(LOG_DEBUG, "wgmd=%p, sizeof(*wgmd)=%zu\n%s\n", - wgmd, sizeof(*wgmd), hex); - puthexdump(hex, wgmd, sizeof(*wgmd)); - } - hex = gethexdump(decrypted_buf, decrypted_len); - if (hex != NULL) { - log(LOG_DEBUG, "decrypted_buf=%p, " - "decrypted_len=%zu\n%s\n", - decrypted_buf, decrypted_len, hex); - puthexdump(hex, decrypted_buf, decrypted_len); - } + hexdump(aprint_debug, "wgmd", wgmd, sizeof(*wgmd)); + hexdump(aprint_debug, "decrypted_buf", decrypted_buf, + decrypted_len); } #endif /* We're done with m now; free it and chuck the pointers. */ @@ -4095,18 +4087,9 @@ wg_send_data_msg(struct wg_peer *wgp, st wg_fill_msg_data(wg, wgp, wgs, wgmd); #ifdef WG_DEBUG_PACKET if (wg_debug & WG_DEBUG_FLAGS_PACKET) { - char *hex = gethexdump(wgmd, sizeof(*wgmd)); - if (hex != NULL) { - log(LOG_DEBUG, "wgmd=%p, sizeof(*wgmd)=%zu\n%s\n", - wgmd, sizeof(*wgmd), hex); - puthexdump(hex, wgmd, sizeof(*wgmd)); - } - hex = gethexdump(padded_buf, padded_len); - if (hex != NULL) { - log(LOG_DEBUG, "padded_buf=%p, padded_len=%zu\n%s\n", - padded_buf, padded_len, hex); - puthexdump(hex, padded_buf, padded_len); - } + hexdump(aprint_debug, "wgmd", wgmd, sizeof(*wgmd)); + hexdump(aprint_debug, "padded_buf", padded_buf, + padded_len); } #endif /* [W] 5.4.6: AEAD(Tm^send, Nm^send, P, e) */
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Thu Jul 25 00:24:02 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: use hexdump... To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Thu Jul 25 00:07:33 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: fix size limit calculation in dump and NULL checks To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.84 src/sys/net/if_wg.c:1.85 --- src/sys/net/if_wg.c:1.84 Wed Jul 24 19:46:13 2024 +++ src/sys/net/if_wg.c Wed Jul 24 20:07:33 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.84 2024/07/24 23:46:13 christos Exp $ */ +/* $NetBSD: if_wg.c,v 1.85 2024/07/25 00:07:33 christos Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.84 2024/07/24 23:46:13 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.85 2024/07/25 00:07:33 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -167,7 +167,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. #define WGLOG(level, fmt, args...) \ log(level, "%s: " fmt, __func__, ##args) -// #define WG_DEBUG +#define WG_DEBUG /* Debug options */ #ifdef WG_DEBUG @@ -247,13 +247,13 @@ gethexdump(const void *vp, size_t n) const uint8_t *p = vp; size_t i; - if (n > SIZE_MAX/3 - 1) + if (n > (SIZE_MAX - 1) / 3) return NULL; - buf = kmem_alloc(3*n + 1, KM_NOSLEEP); + buf = kmem_alloc(3 * n + 1, KM_NOSLEEP); if (buf == NULL) return NULL; for (i = 0; i < n; i++) - snprintf(buf + 3*i, 3 + 1, " %02hhx", p[i]); + snprintf(buf + 3 * i, 3 + 1, " %02hhx", p[i]); return buf; } @@ -2705,13 +2705,18 @@ wg_handle_msg_data(struct wg_softc *wg, #ifdef WG_DEBUG_PACKET if (wg_debug & WG_DEBUG_FLAGS_PACKET) { char *hex = gethexdump(wgmd, sizeof(*wgmd)); - log(LOG_DEBUG, "wgmd=%p, sizeof(*wgmd)=%zu\n%s\n", - wgmd, sizeof(*wgmd), hex); - puthexdump(hex, wgmd, sizeof(*wgmd)); + if (hex != NULL) { + log(LOG_DEBUG, "wgmd=%p, sizeof(*wgmd)=%zu\n%s\n", + wgmd, sizeof(*wgmd), hex); + puthexdump(hex, wgmd, sizeof(*wgmd)); + } hex = gethexdump(decrypted_buf, decrypted_len); - log(LOG_DEBUG, "decrypted_buf=%p, decrypted_len=%zu\n%s\n", - decrypted_buf, decrypted_len, hex); - puthexdump(hex, decrypted_buf, decrypted_len); + if (hex != NULL) { + log(LOG_DEBUG, "decrypted_buf=%p, " + "decrypted_len=%zu\n%s\n", + decrypted_buf, decrypted_len, hex); + puthexdump(hex, decrypted_buf, decrypted_len); + } } #endif /* We're done with m now; free it and chuck the pointers. */ @@ -4091,13 +4096,17 @@ wg_send_data_msg(struct wg_peer *wgp, st #ifdef WG_DEBUG_PACKET if (wg_debug & WG_DEBUG_FLAGS_PACKET) { char *hex = gethexdump(wgmd, sizeof(*wgmd)); - log(LOG_DEBUG, "wgmd=%p, sizeof(*wgmd)=%zu\n%s\n", - wgmd, sizeof(*wgmd), hex); - puthexdump(hex, wgmd, sizeof(*wgmd)); + if (hex != NULL) { + log(LOG_DEBUG, "wgmd=%p, sizeof(*wgmd)=%zu\n%s\n", + wgmd, sizeof(*wgmd), hex); + puthexdump(hex, wgmd, sizeof(*wgmd)); + } hex = gethexdump(padded_buf, padded_len); - log(LOG_DEBUG, "padded_buf=%p, padded_len=%zu\n%s\n", - padded_buf, padded_len, hex); - puthexdump(hex, padded_buf, padded_len); + if (hex != NULL) { + log(LOG_DEBUG, "padded_buf=%p, padded_len=%zu\n%s\n", + padded_buf, padded_len, hex); + puthexdump(hex, padded_buf, padded_len); + } } #endif /* [W] 5.4.6: AEAD(Tm^send, Nm^send, P, e) */
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Thu Jul 25 00:07:33 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: fix size limit calculation in dump and NULL checks To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Wed Jul 24 23:46:13 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Add packet dump debugging To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Wed Jul 24 23:46:13 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Add packet dump debugging To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.83 src/sys/net/if_wg.c:1.84 --- src/sys/net/if_wg.c:1.83 Wed Jul 24 18:32:07 2024 +++ src/sys/net/if_wg.c Wed Jul 24 19:46:13 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.83 2024/07/24 22:32:07 kre Exp $ */ +/* $NetBSD: if_wg.c,v 1.84 2024/07/24 23:46:13 christos Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.83 2024/07/24 22:32:07 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.84 2024/07/24 23:46:13 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -183,6 +183,10 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. #ifndef WG_DEBUG_DUMP #define WG_DEBUG_DUMP #endif +/* debug packets */ +#ifndef WG_DEBUG_PACKET +#define WG_DEBUG_PACKET +#endif /* Make some internal parameters configurable for testing and debugging */ #ifndef WG_DEBUG_PARAMS #define WG_DEBUG_PARAMS @@ -201,6 +205,7 @@ int wg_debug; #define WG_DEBUG_FLAGS_LOG 1 #define WG_DEBUG_FLAGS_TRACE 2 #define WG_DEBUG_FLAGS_DUMP 4 +#define WG_DEBUG_FLAGS_PACKET 8 #endif @@ -236,9 +241,10 @@ static bool wg_force_underload = false; #ifdef WG_DEBUG_DUMP static char * -gethexdump(const char *p, size_t n) +gethexdump(const void *vp, size_t n) { char *buf; + const uint8_t *p = vp; size_t i; if (n > SIZE_MAX/3 - 1) @@ -2696,6 +2702,18 @@ wg_handle_msg_data(struct wg_softc *wg, goto out; } +#ifdef WG_DEBUG_PACKET + if (wg_debug & WG_DEBUG_FLAGS_PACKET) { + char *hex = gethexdump(wgmd, sizeof(*wgmd)); + log(LOG_DEBUG, "wgmd=%p, sizeof(*wgmd)=%zu\n%s\n", + wgmd, sizeof(*wgmd), hex); + puthexdump(hex, wgmd, sizeof(*wgmd)); + hex = gethexdump(decrypted_buf, decrypted_len); + log(LOG_DEBUG, "decrypted_buf=%p, decrypted_len=%zu\n%s\n", + decrypted_buf, decrypted_len, hex); + puthexdump(hex, decrypted_buf, decrypted_len); + } +#endif /* We're done with m now; free it and chuck the pointers. */ m_freem(m); m = NULL; @@ -4070,6 +4088,18 @@ wg_send_data_msg(struct wg_peer *wgp, st KASSERT(n->m_len >= sizeof(*wgmd)); wgmd = mtod(n, struct wg_msg_data *); wg_fill_msg_data(wg, wgp, wgs, wgmd); +#ifdef WG_DEBUG_PACKET + if (wg_debug & WG_DEBUG_FLAGS_PACKET) { + char *hex = gethexdump(wgmd, sizeof(*wgmd)); + log(LOG_DEBUG, "wgmd=%p, sizeof(*wgmd)=%zu\n%s\n", + wgmd, sizeof(*wgmd), hex); + puthexdump(hex, wgmd, sizeof(*wgmd)); + hex = gethexdump(padded_buf, padded_len); + log(LOG_DEBUG, "padded_buf=%p, padded_len=%zu\n%s\n", + padded_buf, padded_len, hex); + puthexdump(hex, padded_buf, padded_len); + } +#endif /* [W] 5.4.6: AEAD(Tm^send, Nm^send, P, e) */ wg_algo_aead_enc((char *)wgmd + sizeof(*wgmd), encrypted_len, wgs->wgs_tkey_send, le64toh(wgmd->wgmd_counter), @@ -4920,7 +4950,7 @@ SYSCTL_SETUP(sysctl_net_wg_setup, "sysct sysctl_createv(clog, 0, , NULL, CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_INT, "debug", - SYSCTL_DESCR("set debug flags 1=debug 2=trace 4=dump"), + SYSCTL_DESCR("set debug flags 1=log 2=trace 4=dump 8=packet"), NULL, 0, _debug, 0, CTL_CREATE, CTL_EOL); } #endif
CVS commit: src/sys/net
Module Name:src Committed By: kre Date: Wed Jul 24 22:32:07 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: While the previous change fixed the broken build, it wasn't the best way, as defining any of the WG_DEBUG_XXX symbols then effectively defined all of them - making them as seperate entities, pointless. So, rearrange the way things are done a little to avoid doing that. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.82 src/sys/net/if_wg.c:1.83 --- src/sys/net/if_wg.c:1.82 Wed Jul 24 22:17:21 2024 +++ src/sys/net/if_wg.c Wed Jul 24 22:32:07 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.82 2024/07/24 22:17:21 kre Exp $ */ +/* $NetBSD: if_wg.c,v 1.83 2024/07/24 22:32:07 kre Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.82 2024/07/24 22:17:21 kre Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.83 2024/07/24 22:32:07 kre Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -169,13 +169,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. // #define WG_DEBUG -#ifndef WG_DEBUG -# if defined(WG_DEBUG_LOG) || defined(WG_DEBUG_TRACE) || \ - defined(WG_DEBUG_DUMP) || defined(WG_DEBUG_PARAMS) -# define WG_DEBUG -# endif -#endif - /* Debug options */ #ifdef WG_DEBUG /* Output debug logs */ @@ -194,6 +187,16 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. #ifndef WG_DEBUG_PARAMS #define WG_DEBUG_PARAMS #endif +#endif /* WG_DEBUG */ + +#ifndef WG_DEBUG +# if defined(WG_DEBUG_LOG) || defined(WG_DEBUG_TRACE) || \ + defined(WG_DEBUG_DUMP) || defined(WG_DEBUG_PARAMS) +# define WG_DEBUG +# endif +#endif + +#ifdef WG_DEBUG int wg_debug; #define WG_DEBUG_FLAGS_LOG 1 #define WG_DEBUG_FLAGS_TRACE 2
CVS commit: src/sys/net
Module Name:src Committed By: kre Date: Wed Jul 24 22:32:07 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: While the previous change fixed the broken build, it wasn't the best way, as defining any of the WG_DEBUG_XXX symbols then effectively defined all of them - making them as seperate entities, pointless. So, rearrange the way things are done a little to avoid doing that. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: kre Date: Wed Jul 24 22:17:21 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: If any of the WG_DEBUG_XXX symbols happens to be defined (say, from a stray rump Makefile...) then we now must have WG_DEBUG also defined, so if it wasn't, make it so. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.81 src/sys/net/if_wg.c:1.82 --- src/sys/net/if_wg.c:1.81 Wed Jul 24 20:54:43 2024 +++ src/sys/net/if_wg.c Wed Jul 24 22:17:21 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.81 2024/07/24 20:54:43 christos Exp $ */ +/* $NetBSD: if_wg.c,v 1.82 2024/07/24 22:17:21 kre Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.81 2024/07/24 20:54:43 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.82 2024/07/24 22:17:21 kre Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -169,6 +169,13 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. // #define WG_DEBUG +#ifndef WG_DEBUG +# if defined(WG_DEBUG_LOG) || defined(WG_DEBUG_TRACE) || \ + defined(WG_DEBUG_DUMP) || defined(WG_DEBUG_PARAMS) +# define WG_DEBUG +# endif +#endif + /* Debug options */ #ifdef WG_DEBUG /* Output debug logs */
CVS commit: src/sys/net
Module Name:src Committed By: kre Date: Wed Jul 24 22:17:21 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: If any of the WG_DEBUG_XXX symbols happens to be defined (say, from a stray rump Makefile...) then we now must have WG_DEBUG also defined, so if it wasn't, make it so. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Wed Jul 24 20:54:43 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Add more debugging in packet validation To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Wed Jul 24 20:54:43 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Add more debugging in packet validation To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.80 src/sys/net/if_wg.c:1.81 --- src/sys/net/if_wg.c:1.80 Wed Jul 24 16:29:43 2024 +++ src/sys/net/if_wg.c Wed Jul 24 16:54:43 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.80 2024/07/24 20:29:43 christos Exp $ */ +/* $NetBSD: if_wg.c,v 1.81 2024/07/24 20:54:43 christos Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.80 2024/07/24 20:29:43 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.81 2024/07/24 20:54:43 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -213,8 +213,7 @@ int wg_debug; #endif #define WG_LOG_RATECHECK(wgprc, level, fmt, args...) do { \ - if ((wg_debug & WG_DEBUG_FLAGS_LOG) && \ - ppsratecheck(&(wgprc)->wgprc_lasttime, \ + if (ppsratecheck(&(wgprc)->wgprc_lasttime, \ &(wgprc)->wgprc_curpps, 1)) {\ log(level, fmt, ##args);\ }\ @@ -2388,16 +2387,21 @@ wg_validate_inner_packet(const char *pac uint16_t packet_len; const struct ip *ip; - if (__predict_false(decrypted_len < sizeof(struct ip))) + if (__predict_false(decrypted_len < sizeof(*ip))) { + WG_DLOG("decrypted_len=%zu < %zu\n", decrypted_len, + sizeof(*ip)); return false; + } ip = (const struct ip *)packet; if (ip->ip_v == 4) *af = AF_INET; else if (ip->ip_v == 6) *af = AF_INET6; - else + else { + WG_DLOG("ip_v=%d\n", ip->ip_v); return false; + } WG_DLOG("af=%d\n", *af); @@ -2411,11 +2415,14 @@ wg_validate_inner_packet(const char *pac case AF_INET6: { const struct ip6_hdr *ip6; - if (__predict_false(decrypted_len < sizeof(struct ip6_hdr))) + if (__predict_false(decrypted_len < sizeof(*ip6))) { + WG_DLOG("decrypted_len=%zu < %zu\n", decrypted_len, + sizeof(*ip6)); return false; + } ip6 = (const struct ip6_hdr *)packet; - packet_len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen); + packet_len = sizeof(*ip6) + ntohs(ip6->ip6_plen); break; } #endif @@ -2423,9 +2430,11 @@ wg_validate_inner_packet(const char *pac return false; } - WG_DLOG("packet_len=%u\n", packet_len); - if (packet_len > decrypted_len) + if (packet_len > decrypted_len) { + WG_DLOG("packet_len %u > decrypted_len %zu\n", packet_len, + decrypted_len); return false; + } return true; }
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Wed Jul 24 20:29:43 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Add a wg_debug variable to split between debug/trace/dump messages To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/if_wg.c diff -u src/sys/net/if_wg.c:1.79 src/sys/net/if_wg.c:1.80 --- src/sys/net/if_wg.c:1.79 Fri Jul 5 00:31:53 2024 +++ src/sys/net/if_wg.c Wed Jul 24 16:29:43 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.79 2024/07/05 04:31:53 rin Exp $ */ +/* $NetBSD: if_wg.c,v 1.80 2024/07/24 20:29:43 christos Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.79 2024/07/05 04:31:53 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.80 2024/07/24 20:29:43 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_altq_enabled.h" @@ -167,6 +167,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. #define WGLOG(level, fmt, args...) \ log(level, "%s: " fmt, __func__, ##args) +// #define WG_DEBUG + /* Debug options */ #ifdef WG_DEBUG /* Output debug logs */ @@ -185,23 +187,34 @@ __KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1. #ifndef WG_DEBUG_PARAMS #define WG_DEBUG_PARAMS #endif +int wg_debug; +#define WG_DEBUG_FLAGS_LOG 1 +#define WG_DEBUG_FLAGS_TRACE 2 +#define WG_DEBUG_FLAGS_DUMP 4 #endif + #ifdef WG_DEBUG_TRACE -#define WG_TRACE(msg) \ - log(LOG_DEBUG, "%s:%d: %s\n", __func__, __LINE__, (msg)) +#define WG_TRACE(msg) do { \ + if (wg_debug & WG_DEBUG_FLAGS_TRACE)\ + log(LOG_DEBUG, "%s:%d: %s\n", __func__, __LINE__, (msg)); \ +} while (0) #else #define WG_TRACE(msg) __nothing #endif #ifdef WG_DEBUG_LOG -#define WG_DLOG(fmt, args...) log(LOG_DEBUG, "%s: " fmt, __func__, ##args) +#define WG_DLOG(fmt, args...) do { \ + if (wg_debug & WG_DEBUG_FLAGS_LOG)\ + log(LOG_DEBUG, "%s: " fmt, __func__, ##args); \ +} while (0) #else #define WG_DLOG(fmt, args...) __nothing #endif #define WG_LOG_RATECHECK(wgprc, level, fmt, args...) do { \ - if (ppsratecheck(&(wgprc)->wgprc_lasttime, \ + if ((wg_debug & WG_DEBUG_FLAGS_LOG) && \ + ppsratecheck(&(wgprc)->wgprc_lasttime, \ &(wgprc)->wgprc_curpps, 1)) {\ log(level, fmt, ##args);\ }\ @@ -242,6 +255,9 @@ puthexdump(char *buf, const void *p, siz static void wg_dump_buf(const char *func, const char *buf, const size_t size) { + if ((wg_debug & WG_DEBUG_FLAGS_DUMP) == 0) + return; + char *hex = gethexdump(buf, size); log(LOG_DEBUG, "%s: %s\n", func, hex ? hex : "(enomem)"); @@ -253,6 +269,9 @@ static void wg_dump_hash(const uint8_t *func, const uint8_t *name, const uint8_t *hash, const size_t size) { + if ((wg_debug & WG_DEBUG_FLAGS_DUMP) == 0) + return; + char *hex = gethexdump(hash, size); log(LOG_DEBUG, "%s: %s: %s\n", func, name, hex ? hex : "(enomem)"); @@ -2307,6 +2326,7 @@ wg_send_keepalive_msg(struct wg_peer *wg * "A keepalive message is simply a transport data message with * a zero-length encapsulated encrypted inner-packet." */ + WG_TRACE(""); m = m_gethdr(M_WAIT, MT_DATA); wg_send_data_msg(wgp, wgs, m); } @@ -4165,12 +4185,12 @@ wg_handle_prop_peer(struct wg_softc *wg, goto out; } #ifdef WG_DEBUG_DUMP -{ - char *hex = gethexdump(pubkey, pubkey_len); - log(LOG_DEBUG, "pubkey=%p, pubkey_len=%lu\n%s\n", - pubkey, pubkey_len, hex); - puthexdump(hex, pubkey, pubkey_len); -} +if (wg_debug & WG_DEBUG_FLAGS_DUMP) { + char *hex = gethexdump(pubkey, pubkey_len); + log(LOG_DEBUG, "pubkey=%p, pubkey_len=%lu\n%s\n", + pubkey, pubkey_len, hex); + puthexdump(hex, pubkey, pubkey_len); + } #endif struct wg_peer *wgp = wg_alloc_peer(wg); @@ -4330,9 +4350,10 @@ wg_alloc_prop_buf(char **_buf, struct if return error; buf[ifd->ifd_len] = '\0'; #ifdef WG_DEBUG_DUMP - log(LOG_DEBUG, "%.*s\n", - (int)MIN(INT_MAX, ifd->ifd_len), - (const char *)buf); + if (wg_debug & WG_DEBUG_FLAGS_DUMP) { + log(LOG_DEBUG, "%.*s\n", (int)MIN(INT_MAX, ifd->ifd_len), + (const char *)buf); + } #endif *_buf = buf; return 0; @@ -4358,12 +4379,12 @@ wg_ioctl_set_private_key(struct wg_softc , _len)) goto out; #ifdef WG_DEBUG_DUMP -{ - char *hex = gethexdump(privkey, privkey_len); - log(LOG_DEBUG, "privkey=%p, privkey_len=%lu\n%s\n", - privkey, privkey_len, hex); - puthexdump(hex, privkey, privkey_len); -} + if (wg_debug & WG_DEBUG_FLAGS_DUMP) { + char *hex = gethexdump(privkey, privkey_len); + log(LOG_DEBUG, "privkey=%p, privkey_len=%lu\n%s\n", + privkey, privkey_len, hex); + puthexdump(hex, privkey, privkey_len); + } #endif if (privkey_len != WG_STATIC_KEY_LEN) goto out; @@ -4877,6 +4898,11 @@ SYSCTL_SETUP(sysctl_net_wg_setup, "sysct CTLTYPE_BOOL, "force_underload",
CVS commit: src/sys/net
Module Name:src Committed By: christos Date: Wed Jul 24 20:29:43 UTC 2024 Modified Files: src/sys/net: if_wg.c Log Message: Add a wg_debug variable to split between debug/trace/dump messages To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/net/if_wg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man9
Module Name:src Committed By: uwe Date: Wed Jul 24 12:48:17 UTC 2024 Modified Files: src/share/man/man9: crashme.9 Log Message: crashme(9): brush up markup, reword cn_fn slightly for clarity To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/share/man/man9/crashme.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/crashme.9 diff -u src/share/man/man9/crashme.9:1.5 src/share/man/man9/crashme.9:1.6 --- src/share/man/man9/crashme.9:1.5 Sat Dec 11 23:47:53 2021 +++ src/share/man/man9/crashme.9 Wed Jul 24 12:48:17 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: crashme.9,v 1.5 2021/12/11 23:47:53 riastradh Exp $ +.\" $NetBSD: crashme.9,v 1.6 2024/07/24 12:48:17 uwe Exp $ .\" .\" Copyright (c) 2019 Matthew R. Green .\" All rights reserved. @@ -46,20 +46,21 @@ These nodes are simply named callbacks t system to crash. .Pp The crashme functionality is only available in kernels with the -.Xr options 4 -.Dv DEBUG -option set. +.Ic options DEBUG +set in the kernel +.Xr config 5 +file. .Pp Each crashme node is maintained in a .Vt crashme_node structure which has the following public members: -.Bd -literal -typedef int (*crashme_fn)(int); +.Bd -literal -offset indent +typedef int (*crashme_fn)(int /* flags */); typedef struct crashme_node { - const char *cn_name; - const char *cn_longname; - crashme_fn cn_fn; +const char *cn_name; +const char *cn_longname; +crashme_fn cn_fn; } crashme_node; .Ed .Pp @@ -72,17 +73,19 @@ and members. .Pp The +.Fa cn_fn +function is passed .Ar flags -parameter is passed from sysctl. -The return value is 0 upon success or non zero for failure. +parameter from sysctl. +It shall return 0 upon success or non zero on failure. .Sh SYSCTL SUPPORT The following .Xr sysctl 8 variables are provided by the .Nm subsystem: -.Bl -tag -width Li -.It Li debug.crashme_enable +.Bl -tag -offset indent -width Va +.It Va debug.crashme_enable Must be set to 1 for any .Nm node to be executed. @@ -90,28 +93,29 @@ node to be executed. .Pp The following .Xr sysctl 8 -nodes trigger crashes in different ways when written: -.Bl -tag -width ".Li debug.crashme.null_deref" -.It Li debug.crashme.panic +variables trigger crashes in different ways when written to: +.Bl -tag -offset indent -width Va +.It Va debug.crashme.panic Call .Xr panic 9 . -.It Li debug.crashme.null_deref +.It Va debug.crashme.null_deref Dereference a null pointer. -.It Li debug.crashme.null_jump +.It Va debug.crashme.null_jump Call a null function pointer, i.e., jump to the instruction address zero. -.It Li debug.crashme.ddb +.It Va debug.crashme.ddb Enter -.Xr ddb 9 +.Xr ddb 4 directly by calling -.Xr Debugger 9 . +.Fn Debugger . Requires -.Xr options 4 -.Dv DDB . +.Ic options DDB . .El .Sh SEE ALSO +.Xr ddb 4 , .Xr options 4 , -.Xr panic 9 +.Xr sysctl 8 , +.Xr panic 9 . .Sh HISTORY The .Nm
CVS commit: src/share/man/man9
Module Name:src Committed By: uwe Date: Wed Jul 24 12:48:17 UTC 2024 Modified Files: src/share/man/man9: crashme.9 Log Message: crashme(9): brush up markup, reword cn_fn slightly for clarity To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/share/man/man9/crashme.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/stdlib
Module Name:src Committed By: kre Date: Wed Jul 24 09:26:06 UTC 2024 Modified Files: src/tests/lib/libc/stdlib: t_strtoi.c Log Message: Add some test cases to tests/lib/libc/stdlib/t_strtoi PR lib/58461 PR lib/58453 Apologies for the previous commit message - I managed to forget to include the message filename after commit -F and so used the file being committed (the only changed file in the directory) as the log message. (Fortunately that meant that the log didn't get appended to the PR). For the PR, the command to check what actually changed is cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/stdlib/t_strtoi.c rather than what will be reported below. This commit message really belongs to the previous commit, (1.5) there are no changes at all in this one. No pullups required. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/stdlib/t_strtoi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libc/stdlib/t_strtoi.c diff -u src/tests/lib/libc/stdlib/t_strtoi.c:1.4 src/tests/lib/libc/stdlib/t_strtoi.c:1.5 --- src/tests/lib/libc/stdlib/t_strtoi.c:1.4 Wed Jul 24 08:59:11 2024 +++ src/tests/lib/libc/stdlib/t_strtoi.c Wed Jul 24 09:26:06 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_strtoi.c,v 1.4 2024/07/24 08:59:11 kre Exp $ */ +/* $NetBSD: t_strtoi.c,v 1.5 2024/07/24 09:26:06 kre Exp $ */ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__RCSID("$NetBSD: t_strtoi.c,v 1.4 2024/07/24 08:59:11 kre Exp $"); +__RCSID("$NetBSD: t_strtoi.c,v 1.5 2024/07/24 09:26:06 kre Exp $"); #include #include
CVS commit: src/tests/lib/libc/stdlib
Module Name:src Committed By: kre Date: Wed Jul 24 09:26:06 UTC 2024 Modified Files: src/tests/lib/libc/stdlib: t_strtoi.c Log Message: Add some test cases to tests/lib/libc/stdlib/t_strtoi PR lib/58461 PR lib/58453 Apologies for the previous commit message - I managed to forget to include the message filename after commit -F and so used the file being committed (the only changed file in the directory) as the log message. (Fortunately that meant that the log didn't get appended to the PR). For the PR, the command to check what actually changed is cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/stdlib/t_strtoi.c rather than what will be reported below. This commit message really belongs to the previous commit, (1.5) there are no changes at all in this one. No pullups required. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/stdlib/t_strtoi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/common/lib/libc/stdlib
Module Name:src Committed By: kre Date: Wed Jul 24 09:11:28 UTC 2024 Modified Files: src/common/lib/libc/stdlib: _strtoi.h Log Message: PR lib/58461 PR lib/58453 portability fixes Revert previous (1.4) and make the changes properly. If base is invalid, what gets left in *endptr by strtoimax() is unspecified (it is not guaranteed to be either nptr or unaltered) and so cannot (in that case) be used in any way at all. Since it is hard to determine from some implementations of strtoimax() whether this happened or not, simply duplicate the validity test for base here, so we know that error (EINVAL because base is invalid) cannot occur from strtoimax(). In that case, if we get an EINVAL from strtoimax we can simply ignore it, as all it can mean is the (optional in POSIX) case where no conversion occurred (where strtoi() sets the status to ECANCELED). Since NetBSD never did that, this all changes nothing here, but makes strtoi() portable to other environments using a different version of strtoimax(). NFCI. No pullups required, nothing has really changed, there never was a NetBSD bug to fix. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/stdlib/_strtoi.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/common/lib/libc/stdlib/_strtoi.h diff -u src/common/lib/libc/stdlib/_strtoi.h:1.4 src/common/lib/libc/stdlib/_strtoi.h:1.5 --- src/common/lib/libc/stdlib/_strtoi.h:1.4 Sun Jul 21 17:40:42 2024 +++ src/common/lib/libc/stdlib/_strtoi.h Wed Jul 24 09:11:27 2024 @@ -1,9 +1,8 @@ -/* $NetBSD: _strtoi.h,v 1.4 2024/07/21 17:40:42 christos Exp $ */ +/* $NetBSD: _strtoi.h,v 1.5 2024/07/24 09:11:27 kre Exp $ */ /*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. - * Copyright (c) 2024, Alejandro Colomar * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -70,7 +69,7 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const int serrno; #endif __TYPE im; - char *e; + char *ep; int rep; _DIAGASSERT(hi >= lo); @@ -78,11 +77,26 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const _DIAGASSERT(nptr != NULL); /* endptr may be NULL */ - e = NULL; + if (endptr == NULL) + endptr = if (rstatus == NULL) rstatus = + *rstatus = 0; /* assume there will be no errors */ + + if (base != 0 && (base < 2 || base > 36)) { +#if !defined(_KERNEL) && !defined(_STANDALONE) + *rstatus = EINVAL; + if (endptr != NULL) + /* LINTED interface specification */ + *endptr = __UNCONST(nptr); + return 0; +#else + panic("%s: invalid base %d", __func__, base); +#endif + } + #if !defined(_KERNEL) && !defined(_STANDALONE) serrno = errno; errno = 0; @@ -90,21 +104,20 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const #if defined(_KERNEL) || defined(_STANDALONE) || \ defined(HAVE_NBTOOL_CONFIG_H) || defined(BCS_ONLY) - im = __WRAPPED(nptr, , base); + im = __WRAPPED(nptr, endptr, base); #else - im = __WRAPPED_L(nptr, , base, loc); + im = __WRAPPED_L(nptr, endptr, base, loc); #endif #if !defined(_KERNEL) && !defined(_STANDALONE) - *rstatus = errno; + /* EINVAL here can only mean "nothing converted" */ + if (errno != EINVAL) + *rstatus = errno; errno = serrno; #endif - if (endptr != NULL && e != NULL) - *endptr = e; - /* No digits were found */ - if (nptr == e && (*rstatus == 0 || *rstatus == EINVAL)) + if (*rstatus == 0 && nptr == *endptr) *rstatus = ECANCELED; if (im < lo) { @@ -120,7 +133,7 @@ INT_FUNCNAME(_int_, _FUNCNAME, _l)(const } /* There are further characters after number */ - if (*rstatus == 0 && *e != '\0') + if (*rstatus == 0 && **endptr != '\0') *rstatus = ENOTSUP; return im;
CVS commit: src/common/lib/libc/stdlib
Module Name:src Committed By: kre Date: Wed Jul 24 09:11:28 UTC 2024 Modified Files: src/common/lib/libc/stdlib: _strtoi.h Log Message: PR lib/58461 PR lib/58453 portability fixes Revert previous (1.4) and make the changes properly. If base is invalid, what gets left in *endptr by strtoimax() is unspecified (it is not guaranteed to be either nptr or unaltered) and so cannot (in that case) be used in any way at all. Since it is hard to determine from some implementations of strtoimax() whether this happened or not, simply duplicate the validity test for base here, so we know that error (EINVAL because base is invalid) cannot occur from strtoimax(). In that case, if we get an EINVAL from strtoimax we can simply ignore it, as all it can mean is the (optional in POSIX) case where no conversion occurred (where strtoi() sets the status to ECANCELED). Since NetBSD never did that, this all changes nothing here, but makes strtoi() portable to other environments using a different version of strtoimax(). NFCI. No pullups required, nothing has really changed, there never was a NetBSD bug to fix. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/common/lib/libc/stdlib/_strtoi.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libc/stdlib
Module Name:src Committed By: kre Date: Wed Jul 24 08:59:12 UTC 2024 Modified Files: src/tests/lib/libc/stdlib: t_strtoi.c Log Message: /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $*/ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include #include #include #include #include #include struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", , %d, %jd, %jd, " ") failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", , %d, %jd, %jd, )" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", , %d, %jd, %jd, ), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "11101011000110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 },
CVS commit: src/tests/lib/libc/stdlib
Module Name:src Committed By: kre Date: Wed Jul 24 08:59:12 UTC 2024 Modified Files: src/tests/lib/libc/stdlib: t_strtoi.c Log Message: /* $NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $*/ /*- * Copyright (c) 2015 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer in the *documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ /* * Created by Kamil Rytarowski, based on ID: * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp */ #include __RCSID("$NetBSD: t_strtoi.c,v 1.3 2024/01/20 16:52:41 christos Exp $"); #include #include #include #include #include #include struct test { const char *str; intmax_t res; int base; const char *end; intmax_t lo; intmax_t hi; int rstatus; }; static void check(struct test *, intmax_t, char *, int); static void check(struct test *t, intmax_t rv, char *end, int rstatus) { if (rv != t->res) atf_tc_fail_nonfatal("strtoi(\"%s\", , %d, %jd, %jd, " ") failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv); if (rstatus != t->rstatus) { char *emsg; if (rstatus != 0) { emsg = strerror(rstatus); if (emsg != NULL) { emsg = strdup(emsg); if (emsg == NULL) { atf_tc_fail("Out of Memory"); return; } } } else emsg = NULL; atf_tc_fail_nonfatal("strtoi(\"%s\", , %d, %jd, %jd, )" " failed (rstatus: %d %s%s%sexpected %d%s%s%s)", t->str, t->base, t->lo, t->hi, rstatus, rstatus ? "('" : "", emsg != NULL ? emsg : "", rstatus ? "') " : "", t->rstatus, t->rstatus ? " ('" : "", t->rstatus ? strerror(t->rstatus) : "", t->rstatus ? "')" : ""); free(emsg); } if ((t->end != NULL && strcmp(t->end, end) != 0) || (t->end == NULL && *end != '\0')) atf_tc_fail_nonfatal("invalid end pointer ('%s') from " "strtoi(\"%s\", , %d, %jd, %jd, ), " "expected '%s'", end, t->str, t->base, t->lo, t->hi, t->end != NULL ? t->end : "\\0"); } static void check_errno(int e) { if (e != 0) atf_tc_fail("strtoi(3) changed errno to %d ('%s')", e, strerror(e)); } ATF_TC(strtoi_base); ATF_TC_HEAD(strtoi_base, tc) { atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases"); } ATF_TC_BODY(strtoi_base, tc) { struct test t[] = { { "123456789", 123456789, 0, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "11101011000110100010101",123456789, 2, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "22121022020212200", 123456789, 3, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "13112330310111", 123456789, 4, NULL, INTMAX_MIN, INTMAX_MAX, 0 }, { "223101104124", 123456789, 5, NULL, INTMAX_MIN, INTMAX_MAX, 0 },
CVS commit: src
Module Name:src Committed By: kre Date: Wed Jul 24 08:55:09 UTC 2024 Modified Files: src/distrib/sets/lists/comp: mi src/lib/libc/stdlib: Makefile.inc strtoi.3 Log Message: Improve the man for strtoi() (and consequently strtou()) PR lib/58461 PR lib/58453 Improve the wording so it is clearer exactly what strtoi() is intended to do in various cases. While here, add, in the most minimalist way possible, the strtoi_l(), and so also strtou_l(), functions, which seem to have been previously undocumented. Do some linguistic gymnastics so that the conversion of the page from strtoi(3) -> strtou(3) will not generate "an unitmax_t" which is incorrect, we need "a unitmax_t" - one of those was easy to fix in the Makefile sed script, the others would have been more difficult, so reword instead. To generate a diff of this commit: cvs rdiff -u -r1.2465 -r1.2466 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.99 -r1.100 src/lib/libc/stdlib/Makefile.inc cvs rdiff -u -r1.10 -r1.11 src/lib/libc/stdlib/strtoi.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2465 src/distrib/sets/lists/comp/mi:1.2466 --- src/distrib/sets/lists/comp/mi:1.2465 Wed Jul 24 02:36:24 2024 +++ src/distrib/sets/lists/comp/mi Wed Jul 24 08:55:08 2024 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2465 2024/07/24 02:36:24 rin Exp $ +# $NetBSD: mi,v 1.2466 2024/07/24 08:55:08 kre Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -10900,6 +10900,7 @@ ./usr/share/man/cat3/strtof.0 comp-c-catman .cat ./usr/share/man/cat3/strtoi.0 comp-c-catman .cat ./usr/share/man/cat3/strtoimax.0 comp-c-catman .cat +./usr/share/man/cat3/strtoi_l.0 comp-c-catman .cat ./usr/share/man/cat3/strtok.0 comp-c-catman .cat ./usr/share/man/cat3/strtok_r.0 comp-c-catman .cat ./usr/share/man/cat3/strtol.0 comp-c-catman .cat @@ -10912,6 +10913,7 @@ ./usr/share/man/cat3/strtoull.0 comp-c-catman .cat ./usr/share/man/cat3/strtoumax.0 comp-c-catman .cat ./usr/share/man/cat3/strtouq.0 comp-c-catman .cat +./usr/share/man/cat3/strtou_l.0 comp-c-catman .cat ./usr/share/man/cat3/strunvis.0 comp-c-catman .cat ./usr/share/man/cat3/strunvisx.0 comp-c-catman .cat ./usr/share/man/cat3/strvis.0 comp-c-catman .cat @@ -19384,6 +19386,7 @@ ./usr/share/man/html3/strtof.html comp-c-htmlman html ./usr/share/man/html3/strtoi.html comp-c-htmlman html ./usr/share/man/html3/strtoimax.html comp-c-htmlman html +./usr/share/man/html3/strtoi_l.html comp-c-htmlman html ./usr/share/man/html3/strtok.html comp-c-htmlman html ./usr/share/man/html3/strtok_r.html comp-c-htmlman html ./usr/share/man/html3/strtol.html comp-c-htmlman html @@ -19396,6 +19399,7 @@ ./usr/share/man/html3/strtoull.html comp-c-htmlman html ./usr/share/man/html3/strtoumax.html comp-c-htmlman html ./usr/share/man/html3/strtouq.html comp-c-htmlman html +./usr/share/man/html3/strtou_l.html comp-c-htmlman html ./usr/share/man/html3/strunvis.html comp-c-htmlman html ./usr/share/man/html3/strunvisx.html comp-c-htmlman html ./usr/share/man/html3/strvis.html comp-c-htmlman html @@ -27904,6 +27908,7 @@ ./usr/share/man/man3/strtof.3 comp-c-man .man ./usr/share/man/man3/strtoi.3 comp-c-man .man ./usr/share/man/man3/strtoimax.3 comp-c-man .man +./usr/share/man/man3/strtoi_l.3 comp-c-man .man ./usr/share/man/man3/strtok.3 comp-c-man .man ./usr/share/man/man3/strtok_r.3 comp-c-man .man ./usr/share/man/man3/strtol.3 comp-c-man .man @@ -27916,6 +27921,7 @@ ./usr/share/man/man3/strtoull.3 comp-c-man .man ./usr/share/man/man3/strtoumax.3 comp-c-man .man ./usr/share/man/man3/strtouq.3 comp-c-man .man +./usr/share/man/man3/strtou_l.3 comp-c-man .man ./usr/share/man/man3/strunvis.3 comp-c-man .man ./usr/share/man/man3/strunvisx.3 comp-c-man .man ./usr/share/man/man3/strvis.3 comp-c-man .man Index: src/lib/libc/stdlib/Makefile.inc diff -u src/lib/libc/stdlib/Makefile.inc:1.99 src/lib/libc/stdlib/Makefile.inc:1.100 --- src/lib/libc/stdlib/Makefile.inc:1.99 Fri Jun 7 20:50:13 2024 +++ src/lib/libc/stdlib/Makefile.inc Wed Jul 24 08:55:08 2024 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.99 2024/06/07 20:50:13 riastradh Exp $ +# $NetBSD: Makefile.inc,v 1.100 2024/07/24 08:55:08 kre Exp $ # from: @(#)Makefile.inc 8.3 (Berkeley) 2/4/95 # stdlib sources @@ -65,6 +65,7 @@ MAN+= a64l.3 abort.3 abs.3 alloca.3 atex strtou.3: strtoi.3 ${_MKTARGET_CREATE} ${TOOL_SED} -e s/strtoi/strtou/g -e s/STRTOI/STRTOU/g \ + -e 's/an intmax_t/a unitmax_t/g' -e 's/strtou 3/strtoi 3/g' \ -e s/intmax_t/uintmax_t/g -e s/%jd/%ju/g ${.ALLSRC} > ${.TARGET} CLEANFILES += strtou.3 @@ -98,9 +99,11 @@ MLINKS+=radixsort.3 sradixsort.3 MLINKS+=strfmon.3 strfmon_l.3
CVS commit: src
Module Name:src Committed By: kre Date: Wed Jul 24 08:55:09 UTC 2024 Modified Files: src/distrib/sets/lists/comp: mi src/lib/libc/stdlib: Makefile.inc strtoi.3 Log Message: Improve the man for strtoi() (and consequently strtou()) PR lib/58461 PR lib/58453 Improve the wording so it is clearer exactly what strtoi() is intended to do in various cases. While here, add, in the most minimalist way possible, the strtoi_l(), and so also strtou_l(), functions, which seem to have been previously undocumented. Do some linguistic gymnastics so that the conversion of the page from strtoi(3) -> strtou(3) will not generate "an unitmax_t" which is incorrect, we need "a unitmax_t" - one of those was easy to fix in the Makefile sed script, the others would have been more difficult, so reword instead. To generate a diff of this commit: cvs rdiff -u -r1.2465 -r1.2466 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.99 -r1.100 src/lib/libc/stdlib/Makefile.inc cvs rdiff -u -r1.10 -r1.11 src/lib/libc/stdlib/strtoi.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/hppa/dev
Module Name:src Committed By: macallan Date: Wed Jul 24 08:34:03 UTC 2024 Modified Files: src/sys/arch/hppa/dev: hyperfb.c Log Message: hand X a 24bit framebuffer if the hardware supports it To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/dev/hyperfb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/hppa/dev
Module Name:src Committed By: macallan Date: Wed Jul 24 08:34:03 UTC 2024 Modified Files: src/sys/arch/hppa/dev: hyperfb.c Log Message: hand X a 24bit framebuffer if the hardware supports it To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/dev/hyperfb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/hppa/dev/hyperfb.c diff -u src/sys/arch/hppa/dev/hyperfb.c:1.4 src/sys/arch/hppa/dev/hyperfb.c:1.5 --- src/sys/arch/hppa/dev/hyperfb.c:1.4 Wed Jul 17 08:30:28 2024 +++ src/sys/arch/hppa/dev/hyperfb.c Wed Jul 24 08:34:03 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: hyperfb.c,v 1.4 2024/07/17 08:30:28 macallan Exp $ */ +/* $NetBSD: hyperfb.c,v 1.5 2024/07/24 08:34:03 macallan Exp $ */ /* * Copyright (c) 2024 Michael Lorenz @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hyperfb.c,v 1.4 2024/07/17 08:30:28 macallan Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hyperfb.c,v 1.5 2024/07/24 08:34:03 macallan Exp $"); #include "opt_cputype.h" #include "opt_hyperfb.h" @@ -113,7 +113,8 @@ extern struct cfdriver hyperfb_cd; CFATTACH_DECL_NEW(hyperfb, sizeof(struct hyperfb_softc), hyperfb_match, hyperfb_attach, NULL, NULL); -void hyperfb_setup_fb(struct hyperfb_softc *); +static inline void hyperfb_setup_fb(struct hyperfb_softc *); +static inline void hyperfb_setup_fb24(struct hyperfb_softc *); static void hyperfb_init_screen(void *, struct vcons_screen *, int, long *); static int hyperfb_ioctl(void *, void *, u_long, void *, int, @@ -205,13 +206,31 @@ hyperfb_wait_fifo(struct hyperfb_softc * } while (reg < slots); } -void +static inline void hyperfb_setup_fb(struct hyperfb_softc *sc) { hyperfb_wait(sc); - hyperfb_write4(sc, NGLE_REG_10, 0x13602000); /* 8bit */ + if ((sc->sc_mode != WSDISPLAYIO_MODE_EMUL) && sc->sc_24bit) { + hyperfb_write4(sc, NGLE_REG_10, 0xBBA0A000); /* 24bit */ + hyperfb_write4(sc, NGLE_REG_13, 0x); + } else + hyperfb_write4(sc, NGLE_REG_10, 0x13602000); /* 8bit */ + hyperfb_write4(sc, NGLE_REG_14, 0x83000300); + hyperfb_wait(sc); + hyperfb_write1(sc, NGLE_REG_16b1, 1); + sc->sc_hwmode = HW_FB; +} + +static inline void +hyperfb_setup_fb24(struct hyperfb_softc *sc) +{ + + hyperfb_wait(sc); + hyperfb_write4(sc, NGLE_REG_10, 0xBBA0A000); /* 24bit */ + hyperfb_write4(sc, NGLE_REG_13, 0x); hyperfb_write4(sc, NGLE_REG_14, 0x83000300); + //IBOvals(RopSrc,0,BitmapExtent08,0,DataDynamic,MaskDynamic,0,0) hyperfb_wait(sc); hyperfb_write1(sc, NGLE_REG_16b1, 1); sc->sc_hwmode = HW_FB; @@ -367,6 +386,9 @@ hyperfb_attach(device_t parent, device_t eaio_l2(PCXL2_ACCEL_IO_ADDR2MASK(ca->ca_hpa)); #endif /* HP7300LC_CPU */ + sc->sc_mode = WSDISPLAYIO_MODE_EMUL; + sc->sc_locked = 0; + hyperfb_setup(sc); hyperfb_setup_fb(sc); @@ -382,8 +404,6 @@ hyperfb_attach(device_t parent, device_t sc->sc_screens[0] = >sc_defaultscreen_descr; sc->sc_screenlist = (struct wsscreen_list){1, sc->sc_screens}; - sc->sc_mode = WSDISPLAYIO_MODE_EMUL; - sc->sc_locked = 0; vcons_init(>vd, sc, >sc_defaultscreen_descr, _accessops); @@ -458,6 +478,8 @@ hyperfb_attach(device_t parent, device_t config_found(sc->sc_dev, , wsemuldisplaydevprint, CFARGS_NONE); + hyperfb_setup_fb(sc); + } static void @@ -513,7 +535,7 @@ hyperfb_ioctl(void *v, void *vs, u_long return ENODEV; wdf = (void *)data; wdf->height = ms->scr_ri.ri_height; - wdf->width = ms->scr_ri.ri_width; + wdf->width = sc->sc_24bit ? ms->scr_ri.ri_width << 2 : ms->scr_ri.ri_width; wdf->depth = ms->scr_ri.ri_depth; wdf->cmsize = 256; return 0; @@ -526,7 +548,7 @@ hyperfb_ioctl(void *v, void *vs, u_long return hyperfb_putcmap(sc, (struct wsdisplay_cmap *)data); case WSDISPLAYIO_LINEBYTES: - *(u_int *)data = 2048; + *(u_int *)data = sc->sc_24bit ? 8192 : 2048; return 0; case WSDISPLAYIO_SMODE: { @@ -544,6 +566,11 @@ hyperfb_ioctl(void *v, void *vs, u_long (ms->scr_defattr >> 16) & 0xff]); vcons_redraw_screen(ms); hyperfb_set_video(sc, 1); + } else { +hyperfb_setup(sc); +hyperfb_rectfill(sc, 0, 0, sc->sc_width, +sc->sc_height, 0xff); +hyperfb_setup_fb24(sc); } } } @@ -556,6 +583,19 @@ hyperfb_ioctl(void *v, void *vs, u_long ret = wsdisplayio_get_fbinfo(>scr_ri, fbi); fbi->fbi_fbsize = sc->sc_height * 2048; + if (sc->sc_24bit) { +fbi->fbi_stride = 8192; +fbi->fbi_bitsperpixel = 32; +fbi->fbi_pixeltype = WSFB_RGB; +fbi->fbi_subtype.fbi_rgbmasks.red_offset = 16; +fbi->fbi_subtype.fbi_rgbmasks.red_size = 8; +fbi->fbi_subtype.fbi_rgbmasks.green_offset = 8; +fbi->fbi_subtype.fbi_rgbmasks.green_size = 8; +fbi->fbi_subtype.fbi_rgbmasks.blue_offset = 0; +fbi->fbi_subtype.fbi_rgbmasks.blue_size = 8; +fbi->fbi_subtype.fbi_rgbmasks.alpha_size = 0; +fbi->fbi_fbsize = sc->sc_height * 8192; + }
CVS commit: src
Module Name:src Committed By: rin Date: Wed Jul 24 02:36:24 UTC 2024 Modified Files: src/distrib/sets/lists/comp: mi src/share/man/man9: Makefile Log Message: crashme(9): Install man page Suggested by ozaki-r@ To generate a diff of this commit: cvs rdiff -u -r1.2464 -r1.2465 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.471 -r1.472 src/share/man/man9/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: rin Date: Wed Jul 24 02:36:24 UTC 2024 Modified Files: src/distrib/sets/lists/comp: mi src/share/man/man9: Makefile Log Message: crashme(9): Install man page Suggested by ozaki-r@ To generate a diff of this commit: cvs rdiff -u -r1.2464 -r1.2465 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.471 -r1.472 src/share/man/man9/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2464 src/distrib/sets/lists/comp/mi:1.2465 --- src/distrib/sets/lists/comp/mi:1.2464 Fri Jul 12 21:02:22 2024 +++ src/distrib/sets/lists/comp/mi Wed Jul 24 02:36:24 2024 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2464 2024/07/12 21:02:22 christos Exp $ +# $NetBSD: mi,v 1.2465 2024/07/24 02:36:24 rin Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -11946,6 +11946,7 @@ ./usr/share/man/cat9/crypto_newsession.0 comp-sys-catman .cat ./usr/share/man/cat9/crypto_register.0 comp-sys-catman .cat ./usr/share/man/cat9/crypto_unregister.0 comp-sys-catman .cat +./usr/share/man/cat9/crashme.0 comp-sys-catman .cat ./usr/share/man/cat9/csf.0 comp-sys-catman .cat ./usr/share/man/cat9/ctob.0 comp-sys-catman .cat ./usr/share/man/cat9/ctod.0 comp-sys-catman .cat @@ -20379,6 +20380,7 @@ ./usr/share/man/html9/crypto_newsession.html comp-sys-htmlman html ./usr/share/man/html9/crypto_register.html comp-sys-htmlman html ./usr/share/man/html9/crypto_unregister.html comp-sys-htmlman html +./usr/share/man/html9/crashme.html comp-sys-htmlman html ./usr/share/man/html9/csf.html comp-sys-htmlman html ./usr/share/man/html9/ctob.html comp-sys-htmlman html ./usr/share/man/html9/ctod.html comp-sys-htmlman html @@ -28947,6 +28949,7 @@ ./usr/share/man/man9/crypto_newsession.9 comp-sys-man .man ./usr/share/man/man9/crypto_register.9 comp-sys-man .man ./usr/share/man/man9/crypto_unregister.9 comp-sys-man .man +./usr/share/man/man9/crashme.9 comp-sys-man .man ./usr/share/man/man9/csf.9 comp-sys-man .man ./usr/share/man/man9/ctob.9 comp-sys-man .man ./usr/share/man/man9/ctod.9 comp-sys-man .man Index: src/share/man/man9/Makefile diff -u src/share/man/man9/Makefile:1.471 src/share/man/man9/Makefile:1.472 --- src/share/man/man9/Makefile:1.471 Wed Jul 10 07:20:01 2024 +++ src/share/man/man9/Makefile Wed Jul 24 02:36:24 2024 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.471 2024/07/10 07:20:01 rin Exp $ +# $NetBSD: Makefile,v 1.472 2024/07/24 02:36:24 rin Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -14,7 +14,7 @@ MAN= accept_filter.9 accf_data.9 accf_ht cpu_idle.9 cpu_initclocks.9 cpu_need_resched.9 \ cpu_number.9 cpu_reboot.9 cpu_rootconf.9 \ cpu_startup.9 cpu_switchto.9 cpufreq.9 \ - csf.9 ctod.9 \ + crashme.9 csf.9 ctod.9 \ curproc.9 \ ddb.9 ddc.9 \ delay.9 devsw_attach.9 disk.9 disklabel.9 dksubr.9 dofileread.9 \
CVS commit: src/lib/libcrypt
Module Name:src Committed By: riastradh Date: Tue Jul 23 22:37:11 UTC 2024 Modified Files: src/lib/libcrypt: crypt-argon2.c crypt-sha1.c crypt.c hmac.c md5crypt.c pw_gensalt.c Log Message: libcrypt: Nix trailing whitespace. No functional change intended. Prompted by tying up loose ends around PR lib/57895. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/lib/libcrypt/crypt-argon2.c cvs rdiff -u -r1.10 -r1.11 src/lib/libcrypt/crypt-sha1.c cvs rdiff -u -r1.40 -r1.41 src/lib/libcrypt/crypt.c cvs rdiff -u -r1.4 -r1.5 src/lib/libcrypt/hmac.c cvs rdiff -u -r1.15 -r1.16 src/lib/libcrypt/md5crypt.c cvs rdiff -u -r1.13 -r1.14 src/lib/libcrypt/pw_gensalt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/lib/libcrypt
Module Name:src Committed By: riastradh Date: Tue Jul 23 22:37:11 UTC 2024 Modified Files: src/lib/libcrypt: crypt-argon2.c crypt-sha1.c crypt.c hmac.c md5crypt.c pw_gensalt.c Log Message: libcrypt: Nix trailing whitespace. No functional change intended. Prompted by tying up loose ends around PR lib/57895. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/lib/libcrypt/crypt-argon2.c cvs rdiff -u -r1.10 -r1.11 src/lib/libcrypt/crypt-sha1.c cvs rdiff -u -r1.40 -r1.41 src/lib/libcrypt/crypt.c cvs rdiff -u -r1.4 -r1.5 src/lib/libcrypt/hmac.c cvs rdiff -u -r1.15 -r1.16 src/lib/libcrypt/md5crypt.c cvs rdiff -u -r1.13 -r1.14 src/lib/libcrypt/pw_gensalt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcrypt/crypt-argon2.c diff -u src/lib/libcrypt/crypt-argon2.c:1.21 src/lib/libcrypt/crypt-argon2.c:1.22 --- src/lib/libcrypt/crypt-argon2.c:1.21 Tue Jul 23 22:32:22 2024 +++ src/lib/libcrypt/crypt-argon2.c Tue Jul 23 22:37:11 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: crypt-argon2.c,v 1.21 2024/07/23 22:32:22 riastradh Exp $ */ +/* $NetBSD: crypt-argon2.c,v 1.22 2024/07/23 22:37:11 riastradh Exp $ */ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: crypt-argon2.c,v 1.21 2024/07/23 22:32:22 riastradh Exp $"); +__RCSID("$NetBSD: crypt-argon2.c,v 1.22 2024/07/23 22:37:11 riastradh Exp $"); #include #include @@ -35,7 +35,7 @@ __RCSID("$NetBSD: crypt-argon2.c,v 1.21 #include #include -#include +#include #include #include #include @@ -53,7 +53,7 @@ estimate_argon2_params(argon2_type, uint /* defaults pulled from run.c */ #define HASHLEN 32 -#define T_COST_DEF 3 +#define T_COST_DEF 3 #define LOG_M_COST_DEF 12 /* 2^12 = 4 MiB */ #define LANES_DEF 1 #define THREADS_DEF 1 @@ -214,10 +214,10 @@ estimate_argon2_params(argon2_type atype goto error; for (; time < ARGON2_MAX_TIME; ++time) { if (argon2_hash(time, memory, threads, - tmp_pwd, sizeof(tmp_pwd), - tmp_salt, sizeof(tmp_salt), - tmp_hash, sizeof(tmp_hash), - tmp_encoded, sizeof(tmp_encoded), + tmp_pwd, sizeof(tmp_pwd), + tmp_salt, sizeof(tmp_salt), + tmp_hash, sizeof(tmp_hash), + tmp_encoded, sizeof(tmp_encoded), atype, ARGON2_VERSION_NUMBER) != ARGON2_OK) { goto reset; } @@ -250,7 +250,7 @@ reset: /* we don't force param order as input, */ /* but we do provide the expected order to argon2 api */ static int -decode_option(argon2_context *ctx, argon2_type *atype, const char *option) +decode_option(argon2_context *ctx, argon2_type *atype, const char *option) { size_t tmp = 0; char *in = 0, *inp; @@ -268,14 +268,14 @@ decode_option(argon2_context *ctx, argon sl = strlen(a); - if (sl == strlen(ARGON2_ARGON2I_STR) && + if (sl == strlen(ARGON2_ARGON2I_STR) && !(strcmp(ARGON2_ARGON2I_STR, a))) { *atype=Argon2_i; - } else if (sl == strlen(ARGON2_ARGON2D_STR) && + } else if (sl == strlen(ARGON2_ARGON2D_STR) && !(strcmp(ARGON2_ARGON2D_STR, a))) { *atype=Argon2_d; } - else if (sl == strlen(ARGON2_ARGON2ID_STR) && + else if (sl == strlen(ARGON2_ARGON2ID_STR) && !(strcmp(ARGON2_ARGON2ID_STR, a))) { *atype=Argon2_id; } else { /* default to id, we assume simple mistake */ @@ -363,7 +363,7 @@ decode_option(argon2_context *ctx, argon } else { /* don't care if passwd hash is missing */ /* if missing, most likely coming from */ - /* pwhash or similar */ + /* pwhash or similar */ } /* free our token buffer */ @@ -373,7 +373,7 @@ decode_option(argon2_context *ctx, argon return error; } -crypt_private char * +crypt_private char * __crypt_argon2(const char *pw, const char * salt) { /* we use the libargon2 api to generate */ Index: src/lib/libcrypt/crypt-sha1.c diff -u src/lib/libcrypt/crypt-sha1.c:1.10 src/lib/libcrypt/crypt-sha1.c:1.11 --- src/lib/libcrypt/crypt-sha1.c:1.10 Fri Oct 29 13:22:08 2021 +++ src/lib/libcrypt/crypt-sha1.c Tue Jul 23 22:37:11 2024 @@ -1,21 +1,21 @@ -/* $NetBSD: crypt-sha1.c,v 1.10 2021/10/29 13:22:08 nia Exp $ */ +/* $NetBSD: crypt-sha1.c,v 1.11 2024/07/23 22:37:11 riastradh Exp $ */ /* * Copyright (c) 2004, Juniper Networks, Inc. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: + * modification, are permitted provided that the following conditions + * are met: * 1. Redistributions of source code must retain the above copyright - *notice, this list of conditions and the following disclaimer. + *notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *notice, this list of conditions and the following disclaimer
CVS commit: src/lib/libcrypt
Module Name:src Committed By: riastradh Date: Tue Jul 23 22:32:22 UTC 2024 Modified Files: src/lib/libcrypt: crypt-argon2.c Log Message: libcrypt/crypt-argon2.c: Add RCS id. Noted in PR lib/57895. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/lib/libcrypt/crypt-argon2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libcrypt/crypt-argon2.c diff -u src/lib/libcrypt/crypt-argon2.c:1.20 src/lib/libcrypt/crypt-argon2.c:1.21 --- src/lib/libcrypt/crypt-argon2.c:1.20 Sat Mar 9 13:48:50 2024 +++ src/lib/libcrypt/crypt-argon2.c Tue Jul 23 22:32:22 2024 @@ -1,3 +1,5 @@ +/* $NetBSD: crypt-argon2.c,v 1.21 2024/07/23 22:32:22 riastradh Exp $ */ + /* * Copyright (c) 2009 The NetBSD Foundation, Inc. * All rights reserved. @@ -24,6 +26,9 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include +__RCSID("$NetBSD: crypt-argon2.c,v 1.21 2024/07/23 22:32:22 riastradh Exp $"); + #include #include #include
CVS commit: src/lib/libcrypt
Module Name:src Committed By: riastradh Date: Tue Jul 23 22:32:22 UTC 2024 Modified Files: src/lib/libcrypt: crypt-argon2.c Log Message: libcrypt/crypt-argon2.c: Add RCS id. Noted in PR lib/57895. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/lib/libcrypt/crypt-argon2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/ld.elf_so
Module Name:src Committed By: riastradh Date: Tue Jul 23 22:00:00 UTC 2024 Modified Files: src/libexec/ld.elf_so: tls.c Log Message: ld.elf_so: Fix off-by-one error in common __tls_get_addr. DTV_MAX_INDEX(dtv) is an _inclusive_ upper bound, i.e., the actual maximum value of the allowed indices. It is not an exclusive upper bound -- it is not the number of allowed indices. This off-by-one doesn't hurt correctness, but it may hurt performance by using the slow path when the fast path would be safe. Found by pho@ in PR lib/58154. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/libexec/ld.elf_so/tls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/tls.c diff -u src/libexec/ld.elf_so/tls.c:1.21 src/libexec/ld.elf_so/tls.c:1.22 --- src/libexec/ld.elf_so/tls.c:1.21 Mon Jul 22 23:15:57 2024 +++ src/libexec/ld.elf_so/tls.c Tue Jul 23 22:00:00 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: tls.c,v 1.21 2024/07/22 23:15:57 riastradh Exp $ */ +/* $NetBSD: tls.c,v 1.22 2024/07/23 22:00:00 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -29,7 +29,7 @@ */ #include -__RCSID("$NetBSD: tls.c,v 1.21 2024/07/22 23:15:57 riastradh Exp $"); +__RCSID("$NetBSD: tls.c,v 1.22 2024/07/23 22:00:00 riastradh Exp $"); /* * Thread-local storage @@ -523,7 +523,7 @@ __tls_get_addr(void *arg_) * application bug if code of the module is still running at * that point. */ - if (__predict_true(idx < DTV_MAX_INDEX(dtv) && dtv[idx] != NULL)) + if (__predict_true(idx <= DTV_MAX_INDEX(dtv) && dtv[idx] != NULL)) return (uint8_t *)dtv[idx] + offset; return _rtld_tls_get_addr(tcb, idx, offset);
CVS commit: src/libexec/ld.elf_so
Module Name:src Committed By: riastradh Date: Tue Jul 23 22:00:00 UTC 2024 Modified Files: src/libexec/ld.elf_so: tls.c Log Message: ld.elf_so: Fix off-by-one error in common __tls_get_addr. DTV_MAX_INDEX(dtv) is an _inclusive_ upper bound, i.e., the actual maximum value of the allowed indices. It is not an exclusive upper bound -- it is not the number of allowed indices. This off-by-one doesn't hurt correctness, but it may hurt performance by using the slow path when the fast path would be safe. Found by pho@ in PR lib/58154. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/libexec/ld.elf_so/tls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: riastradh Date: Tue Jul 23 20:46:41 UTC 2024 Modified Files: src: build.sh Log Message: build.sh: Adjust xsrc existence test as requested. PR toolchain/58399 To generate a diff of this commit: cvs rdiff -u -r1.378 -r1.379 src/build.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/build.sh diff -u src/build.sh:1.378 src/build.sh:1.379 --- src/build.sh:1.378 Fri Jul 5 00:34:11 2024 +++ src/build.sh Tue Jul 23 20:46:40 2024 @@ -1,5 +1,5 @@ #! /usr/bin/env sh -# $NetBSD: build.sh,v 1.378 2024/07/05 00:34:11 riastradh Exp $ +# $NetBSD: build.sh,v 1.379 2024/07/23 20:46:40 riastradh Exp $ # # Copyright (c) 2001-2023 The NetBSD Foundation, Inc. # All rights reserved. @@ -1547,7 +1547,7 @@ sanitycheck() while [ ${MKX11-no} = "yes" ]; do # not really a loop test -n "${X11SRCDIR}" && { - test -f "${X11SRCDIR}/Makefile" || + test -d "${X11SRCDIR}/external" || bomb "X11SRCDIR (${X11SRCDIR}) does not exist (with -x)" break } @@ -2031,7 +2031,7 @@ createmakewrapper() eval cat <
CVS commit: src
Module Name:src Committed By: riastradh Date: Tue Jul 23 20:46:41 UTC 2024 Modified Files: src: build.sh Log Message: build.sh: Adjust xsrc existence test as requested. PR toolchain/58399 To generate a diff of this commit: cvs rdiff -u -r1.378 -r1.379 src/build.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: riastradh Date: Tue Jul 23 18:11:53 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/aarch64: rtld_start.S src/tests/libexec/ld.elf_so: t_tls_extern.c Log Message: ld.elf_so aarch64/rtld_start.S: Fix dynamic TLS fast path branch. Bug found and patch prepared by pho@. PR lib/58154 To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/libexec/ld.elf_so/arch/aarch64/rtld_start.S cvs rdiff -u -r1.15 -r1.16 src/tests/libexec/ld.elf_so/t_tls_extern.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/arch/aarch64/rtld_start.S diff -u src/libexec/ld.elf_so/arch/aarch64/rtld_start.S:1.6 src/libexec/ld.elf_so/arch/aarch64/rtld_start.S:1.7 --- src/libexec/ld.elf_so/arch/aarch64/rtld_start.S:1.6 Mon Jul 22 23:18:50 2024 +++ src/libexec/ld.elf_so/arch/aarch64/rtld_start.S Tue Jul 23 18:11:53 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: rtld_start.S,v 1.6 2024/07/22 23:18:50 riastradh Exp $ */ +/* $NetBSD: rtld_start.S,v 1.7 2024/07/23 18:11:53 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ #include -RCSID("$NetBSD: rtld_start.S,v 1.6 2024/07/22 23:18:50 riastradh Exp $") +RCSID("$NetBSD: rtld_start.S,v 1.7 2024/07/23 18:11:53 riastradh Exp $") /* * void _rtld_start(void (*cleanup)(void), const Obj_Entry *obj, @@ -236,8 +236,7 @@ ENTRY(_rtld_tlsdesc_dynamic) ldr x3, [x0, #-8] /* x3 := max = DTV_MAX_INDEX(dtv) */ ldr x2, [x1, #0] /* x2 := idx = tlsdesc->td_tlsindex */ cmp x2, x3 - b.lt 1f /* Slow path if idx < max */ - /* XXX PR lib/58154 */ + b.gt 1f /* Slow path if idx > max */ ldr x3, [x0, x2, lsl #3] /* x3 := dtv[idx] */ cbz x3, 1f /* Slow path if dtv[idx] is null */ Index: src/tests/libexec/ld.elf_so/t_tls_extern.c diff -u src/tests/libexec/ld.elf_so/t_tls_extern.c:1.15 src/tests/libexec/ld.elf_so/t_tls_extern.c:1.16 --- src/tests/libexec/ld.elf_so/t_tls_extern.c:1.15 Mon Jul 22 23:18:30 2024 +++ src/tests/libexec/ld.elf_so/t_tls_extern.c Tue Jul 23 18:11:53 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_tls_extern.c,v 1.15 2024/07/22 23:18:30 riastradh Exp $ */ +/* $NetBSD: t_tls_extern.c,v 1.16 2024/07/23 18:11:53 riastradh Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,6 @@ #include #include -#include #define ATF_REQUIRE_DL(x) ATF_REQUIRE_MSG((x) != 0, "%s: %s", #x, dlerror()) @@ -424,10 +423,6 @@ ATF_TC_BODY(opencloseloop_use, tc) */ ATF_REQUIRE_DL(use = dlopen("libh_use_dynamic.so", 0)); ATF_REQUIRE_DL(fuse = dlsym(use, "fuse")); -#ifdef __aarch64__ - atf_tc_expect_signal(SIGSEGV, - "PR lib/58154: bad fast path test in aarch64 tls"); -#endif pdef = (*fdef)(); puse = (*fuse)(); ATF_CHECK_EQ_MSG(pdef, puse,
CVS commit: src
Module Name:src Committed By: riastradh Date: Tue Jul 23 18:11:53 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/aarch64: rtld_start.S src/tests/libexec/ld.elf_so: t_tls_extern.c Log Message: ld.elf_so aarch64/rtld_start.S: Fix dynamic TLS fast path branch. Bug found and patch prepared by pho@. PR lib/58154 To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/libexec/ld.elf_so/arch/aarch64/rtld_start.S cvs rdiff -u -r1.15 -r1.16 src/tests/libexec/ld.elf_so/t_tls_extern.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
re: CVS commit: src/external/mit/xorg/server/drivers/xf86-video-nv
"Taylor R Campbell" writes: > Module Name: src > Committed By: riastradh > Date: Tue Jul 23 07:52:06 UTC 2024 > > Modified Files: > src/external/mit/xorg/server/drivers/xf86-video-nv: Makefile > > Log Message: > xf86-video-nv: Don't fail on -Wpointer-sign with clang. > > Not sure why this isn't disabled by default (surely this very old > code hasn't been clean for it in a long time?), but with any luck > this should resolve clang build failures like: thanks. may as well revert the attempt(s) to avoid this warning in the code now. it was updated recently, actually, and this specific line changed in upstream and needed a merge, and then i had one attempt to fix the warning that clearly didn't work. .mrg.
CVS commit: src/sbin/mount_null
Module Name:src Committed By: uwe Date: Tue Jul 23 15:53:43 UTC 2024 Modified Files: src/sbin/mount_null: mount_null.8 Log Message: mount_null(8): tweak previous Make the wording in the example less ambiguous. While here, g/c accidental blank like in input. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sbin/mount_null/mount_null.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/mount_null/mount_null.8 diff -u src/sbin/mount_null/mount_null.8:1.23 src/sbin/mount_null/mount_null.8:1.24 --- src/sbin/mount_null/mount_null.8:1.23 Tue Jul 23 15:06:31 2024 +++ src/sbin/mount_null/mount_null.8 Tue Jul 23 15:53:43 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: mount_null.8,v 1.23 2024/07/23 15:06:31 uwe Exp $ +.\" $NetBSD: mount_null.8,v 1.24 2024/07/23 15:53:43 uwe Exp $ .\" .\" Copyright (c) 1992, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -231,10 +231,11 @@ The disadvantage is that vnode arguments Expose .Nx source tree under +.Pa /export/netbsd/src +as .Pa /usr/src -in read-only mode to prevent polluting the sources with accidental +but in read-only mode to prevent polluting the sources with accidental writes: - .Pp .Dl mount -t null -o ro /export/netbsd/src /usr/src .\"
CVS commit: src/sbin/mount_null
Module Name:src Committed By: uwe Date: Tue Jul 23 15:53:43 UTC 2024 Modified Files: src/sbin/mount_null: mount_null.8 Log Message: mount_null(8): tweak previous Make the wording in the example less ambiguous. While here, g/c accidental blank like in input. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sbin/mount_null/mount_null.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/mount_null
Module Name:src Committed By: uwe Date: Tue Jul 23 15:06:31 UTC 2024 Modified Files: src/sbin/mount_null: mount_null.8 Log Message: mount_null(8): brush up markup, add read-only /usr/src example TODO: the source code references probably need to be updated! To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sbin/mount_null/mount_null.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/mount_null
Module Name:src Committed By: uwe Date: Tue Jul 23 15:06:31 UTC 2024 Modified Files: src/sbin/mount_null: mount_null.8 Log Message: mount_null(8): brush up markup, add read-only /usr/src example TODO: the source code references probably need to be updated! To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sbin/mount_null/mount_null.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/mount_null/mount_null.8 diff -u src/sbin/mount_null/mount_null.8:1.22 src/sbin/mount_null/mount_null.8:1.23 --- src/sbin/mount_null/mount_null.8:1.22 Tue Dec 1 02:43:18 2020 +++ src/sbin/mount_null/mount_null.8 Tue Jul 23 15:06:31 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: mount_null.8,v 1.22 2020/12/01 02:43:18 pgoyette Exp $ +.\" $NetBSD: mount_null.8,v 1.23 2024/07/23 15:06:31 uwe Exp $ .\" .\" Copyright (c) 1992, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -68,9 +68,7 @@ The filesystem differs from a traditional loopback file system in two respects: it is implemented using a stackable layers technique, and its -.Do -null-nodes -.Dc +.Dq null-nodes stack above all lower-layer vnodes (not just above directory vnodes). .Pp @@ -81,7 +79,7 @@ and are converted to absolute paths before use. .Pp The options are as follows: -.Bl -tag -width indent +.Bl -tag -width Fl .It Fl o Options are specified with a .Fl o @@ -131,20 +129,20 @@ in the arguments and, if a vnode is retu stacks a null-node on top of the returned vnode. .Pp Although bypass handles most operations, -.Em vop_getattr , -.Em vop_inactive , -.Em vop_reclaim , +.Fa vop_getattr , +.Fa vop_inactive , +.Fa vop_reclaim , and -.Em vop_print +.Fa vop_print are not bypassed. -.Em vop_getattr +.Fa vop_getattr must change the fsid being returned. -.Em vop_inactive +.Fa vop_inactive and -.Em vop_reclaim +.Fa vop_reclaim are not bypassed so that they can handle freeing null-layer specific data. -.Em vop_print +.Fa vop_print is not bypassed to avoid excessive debugging information. .\" @@ -167,20 +165,23 @@ The bypass routine stacks a null-node ab vnode before returning it to the caller. .Pp For example, imagine mounting a null layer with -.Bd -literal -offset indent -mount_null /usr/include /dev/layer/null -.Ed +.Pp +.Dl mount_null /usr/include /dev/layer/null +.Pp Changing directory to .Pa /dev/layer/null will assign the root null-node (which was created when the null layer was mounted). Now consider opening .Pa sys . -A vop_lookup would be done on the root null-node. +A +.Fa vop_lookup +would be done on the root null-node. This operation would bypass through to the lower layer which would return a vnode representing the UFS .Pa sys . -null_bypass then builds a null-node aliasing the UFS +.Fn null_bypass +then builds a null-node aliasing the UFS .Pa sys and returns this to the caller. Later operations on the null-node @@ -204,7 +205,9 @@ There are two techniques to invoke opera when the operation cannot be completely bypassed. Each method is appropriate in different situations. In both cases, it is the responsibility of the aliasing layer to make -the operation arguments "correct" for the lower layer +the operation arguments +.Dq correct +for the lower layer by mapping any vnode arguments to the lower layer. .Pp The first approach is to call the aliasing layer's bypass routine. @@ -212,18 +215,30 @@ This method is most suitable when you wi currently being handled on the lower layer. It has the advantage that the bypass routine already must do argument mapping. An example of this is -.Em null_getattrs +.Fn null_getattrs in the null layer. .Pp A second approach is to directly invoke vnode operations on the lower layer with the -.Em VOP_OPERATIONNAME +.Xr vnodeops 9 interface. The advantage of this method is that it is easy to invoke arbitrary operations on the lower layer. The disadvantage is that vnode arguments must be manually mapped. .\" .\" +.Sh EXAMPLES +Expose +.Nx +source tree under +.Pa /usr/src +in read-only mode to prevent polluting the sources with accidental +writes: + +.Pp +.Dl mount -t null -o ro /export/netbsd/src /usr/src +.\" +.\" .Sh SEE ALSO .Xr mount 8 .Pp
CVS commit: src/libexec/ld.elf_so/arch/powerpc
Module Name:src Committed By: uwe Date: Tue Jul 23 10:17:32 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/powerpc: ppc_reloc.c Log Message: ld.elf_so: Cite reference for PowerPC ELF relocations PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c diff -u src/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c:1.63 src/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c:1.64 --- src/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c:1.63 Sun Jun 4 01:24:57 2023 +++ src/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c Tue Jul 23 10:17:32 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: ppc_reloc.c,v 1.63 2023/06/04 01:24:57 joerg Exp $ */ +/* $NetBSD: ppc_reloc.c,v 1.64 2024/07/23 10:17:32 uwe Exp $ */ /*- * Copyright (C) 1998 Tsubai Masanari @@ -28,9 +28,22 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +/* + * Power ELF relocations. + * + * Reference: + * + * Power Architecture(R) 32-bit + * Application Binary Interface Supplement 1.0 - Linux(R) + * http://web.archive.org/web/20120608163845/https://www.power.org/resources/downloads/Power-Arch-32-bit-ABI-supp-1.0-Linux.pdf + * + * 64-bit PowerPC ELF Application Binary Interface Supplement 1.9 + * https://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.pdf + */ + #include #ifndef lint -__RCSID("$NetBSD: ppc_reloc.c,v 1.63 2023/06/04 01:24:57 joerg Exp $"); +__RCSID("$NetBSD: ppc_reloc.c,v 1.64 2024/07/23 10:17:32 uwe Exp $"); #endif /* not lint */ #include
CVS commit: src/libexec/ld.elf_so/arch/powerpc
Module Name:src Committed By: uwe Date: Tue Jul 23 10:17:32 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/powerpc: ppc_reloc.c Log Message: ld.elf_so: Cite reference for PowerPC ELF relocations PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/libexec/ld.elf_so/arch/powerpc/ppc_reloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/ld.elf_so/arch
Module Name:src Committed By: uwe Date: Tue Jul 23 09:55:19 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/sparc: mdreloc.c src/libexec/ld.elf_so/arch/sparc64: mdreloc.c Log Message: ld.elf_so: Cite reference for SPARC ELF relocations PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/libexec/ld.elf_so/arch/sparc/mdreloc.c cvs rdiff -u -r1.70 -r1.71 src/libexec/ld.elf_so/arch/sparc64/mdreloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/ld.elf_so/arch/sh3
Module Name:src Committed By: uwe Date: Tue Jul 23 09:27:00 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/sh3: mdreloc.c Log Message: ld.elf_so: Cite reference for SuperH ELF relocations PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/libexec/ld.elf_so/arch/sh3/mdreloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/arch/sh3/mdreloc.c diff -u src/libexec/ld.elf_so/arch/sh3/mdreloc.c:1.36 src/libexec/ld.elf_so/arch/sh3/mdreloc.c:1.37 --- src/libexec/ld.elf_so/arch/sh3/mdreloc.c:1.36 Sun Jun 4 01:24:58 2023 +++ src/libexec/ld.elf_so/arch/sh3/mdreloc.c Tue Jul 23 09:27:00 2024 @@ -1,10 +1,19 @@ -/* $NetBSD: mdreloc.c,v 1.36 2023/06/04 01:24:58 joerg Exp $ */ +/* $NetBSD: mdreloc.c,v 1.37 2024/07/23 09:27:00 uwe Exp $ */ #include #ifndef lint -__RCSID("$NetBSD: mdreloc.c,v 1.36 2023/06/04 01:24:58 joerg Exp $"); +__RCSID("$NetBSD: mdreloc.c,v 1.37 2024/07/23 09:27:00 uwe Exp $"); #endif /* not lint */ +/* + * SuperH ELF relocations. + * + * Reference: + * + * [RM0197] SH-4 generic and C specific application binary interface + * https://www.st.com/resource/en/reference_manual/rm0197-sh4-generic-and-c-specific-application-binary-interface-stmicroelectronics.pdf + */ + #include #include
CVS commit: src/libexec/ld.elf_so/arch/sh3
Module Name:src Committed By: uwe Date: Tue Jul 23 09:27:00 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/sh3: mdreloc.c Log Message: ld.elf_so: Cite reference for SuperH ELF relocations PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/libexec/ld.elf_so/arch/sh3/mdreloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/mit/xorg/server/drivers/xf86-video-nv
Module Name:src Committed By: riastradh Date: Tue Jul 23 07:52:06 UTC 2024 Modified Files: src/external/mit/xorg/server/drivers/xf86-video-nv: Makefile Log Message: xf86-video-nv: Don't fail on -Wpointer-sign with clang. Not sure why this isn't disabled by default (surely this very old code hasn't been clean for it in a long time?), but with any luck this should resolve clang build failures like: /home/source/ab/HEAD-llvm/xsrc/external/mit/xf86-video-nv/dist/src/nv_driver.c:1557:40: error: passing 'char *' to parameter of type 'CARD8 *' (aka 'unsigned char *') converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign] vgaHWSetMmioFuncs(VGAHWPTR(pScrn), (char *)pNv->IOAddress, 0); ^~ /home/builds/ab/HEAD-llvm/macppc/202407182350Z-dest/usr/X11R7/include/xorg/vgaHW.h:189:62: note: passing argument to parameter 'base' here extern _X_EXPORT void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset); ^ 1 error generated. --- nv_driver.pico --- *** Failed target: nv_driver.pico *** In directory: /home/source/ab/HEAD-llvm/src/external/mit/xorg/server/drivers/xf86-video-nv To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 \ src/external/mit/xorg/server/drivers/xf86-video-nv/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/mit/xorg/server/drivers/xf86-video-nv
Module Name:src Committed By: riastradh Date: Tue Jul 23 07:52:06 UTC 2024 Modified Files: src/external/mit/xorg/server/drivers/xf86-video-nv: Makefile Log Message: xf86-video-nv: Don't fail on -Wpointer-sign with clang. Not sure why this isn't disabled by default (surely this very old code hasn't been clean for it in a long time?), but with any luck this should resolve clang build failures like: /home/source/ab/HEAD-llvm/xsrc/external/mit/xf86-video-nv/dist/src/nv_driver.c:1557:40: error: passing 'char *' to parameter of type 'CARD8 *' (aka 'unsigned char *') converts between pointers to integer types where one is of the unique plain 'char' type and the other is not [-Werror,-Wpointer-sign] vgaHWSetMmioFuncs(VGAHWPTR(pScrn), (char *)pNv->IOAddress, 0); ^~ /home/builds/ab/HEAD-llvm/macppc/202407182350Z-dest/usr/X11R7/include/xorg/vgaHW.h:189:62: note: passing argument to parameter 'base' here extern _X_EXPORT void vgaHWSetMmioFuncs(vgaHWPtr hwp, CARD8 *base, int offset); ^ 1 error generated. --- nv_driver.pico --- *** Failed target: nv_driver.pico *** In directory: /home/source/ab/HEAD-llvm/src/external/mit/xorg/server/drivers/xf86-video-nv To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 \ src/external/mit/xorg/server/drivers/xf86-video-nv/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/mit/xorg/server/drivers/xf86-video-nv/Makefile diff -u src/external/mit/xorg/server/drivers/xf86-video-nv/Makefile:1.14 src/external/mit/xorg/server/drivers/xf86-video-nv/Makefile:1.15 --- src/external/mit/xorg/server/drivers/xf86-video-nv/Makefile:1.14 Mon Dec 31 12:13:50 2018 +++ src/external/mit/xorg/server/drivers/xf86-video-nv/Makefile Tue Jul 23 07:52:06 2024 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.14 2018/12/31 12:13:50 mrg Exp $ +# $NetBSD: Makefile,v 1.15 2024/07/23 07:52:06 riastradh Exp $ DRIVER= xf86-video-nv DRIVER_NAME= nv_drv @@ -33,6 +33,7 @@ CPPFLAGS+= -DAVOID_VGAHW # XXX COPTS+= ${${ACTIVE_CC} == "gcc":? -Wno-error=cpp :} COPTS+= ${${ACTIVE_CC} == "clang":? -Wno-error=\#warnings :} +COPTS+= ${${ACTIVE_CC} == "clang":? -Wno-error=pointer-sign :} COPTS.g80_dac.c+= -Wno-error # XXX deprecated
CVS commit: src/libexec/ld.elf_so/arch/aarch64
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:18:50 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/aarch64: rtld_start.S Log Message: ld.elf_so aarch64/rtld_start.S: Sprinkle comments. No functional change intended. Prompted by PR lib/58154. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/libexec/ld.elf_so/arch/aarch64/rtld_start.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/arch/aarch64/rtld_start.S diff -u src/libexec/ld.elf_so/arch/aarch64/rtld_start.S:1.5 src/libexec/ld.elf_so/arch/aarch64/rtld_start.S:1.6 --- src/libexec/ld.elf_so/arch/aarch64/rtld_start.S:1.5 Thu Mar 24 12:12:00 2022 +++ src/libexec/ld.elf_so/arch/aarch64/rtld_start.S Mon Jul 22 23:18:50 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: rtld_start.S,v 1.5 2022/03/24 12:12:00 andvar Exp $ */ +/* $NetBSD: rtld_start.S,v 1.6 2024/07/22 23:18:50 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ #include -RCSID("$NetBSD: rtld_start.S,v 1.5 2022/03/24 12:12:00 andvar Exp $") +RCSID("$NetBSD: rtld_start.S,v 1.6 2024/07/22 23:18:50 riastradh Exp $") /* * void _rtld_start(void (*cleanup)(void), const Obj_Entry *obj, @@ -146,87 +146,122 @@ ENTRY_NP(_rtld_bind_start) END(_rtld_bind_start) /* - * struct rel_tlsdesc { - * uint64_t resolver_fnc; - * uint64_t resolver_arg; + * Entry points used by _rtld_tlsdesc_fill. They will be passed in x0 + * a pointer to: * + * struct rel_tlsdesc { + * uint64_t resolver_fnc; + * uint64_t resolver_arg; + * }; * - * uint64_t _rtld_tlsdesc_static(struct rel_tlsdesc *); + * They are called with nonstandard calling convention and must + * preserve all registers except x0. + */ + +/* + * uint64_t@x0 + * _rtld_tlsdesc_static(struct rel_tlsdesc *rel_tlsdesc@x0); + * + * Resolver function for TLS symbols resolved at load time. * - * Resolver function for TLS symbols resolved at load time + * rel_tlsdesc->resolver_arg is the offset of the static + * thread-local storage region, relative to the start of the TCB. + * + * Nonstandard calling convention: Must preserve all registers + * except x0. */ ENTRY(_rtld_tlsdesc_static) .cfi_startproc - ldr x0, [x0, #8] - ret + ldr x0, [x0, #8] /* x0 := tcboffset */ + ret/* return x0 = tcboffset */ .cfi_endproc END(_rtld_tlsdesc_static) /* - * uint64_t _rtld_tlsdesc_undef(void); + * uint64_t@x0 + * _rtld_tlsdesc_undef(struct rel_tlsdesc *rel_tlsdesc@x0); + * + * Resolver function for weak and undefined TLS symbols. * - * Resolver function for weak and undefined TLS symbols + * rel_tlsdesc->resolver_arg is the Elf_Rela rela->r_addend. + * + * Nonstandard calling convention: Must preserve all registers + * except x0. */ ENTRY(_rtld_tlsdesc_undef) .cfi_startproc - str x1, [sp, #-16]! + str x1, [sp, #-16]! /* save x1 on stack */ .cfi_adjust_cfa_offset 16 - mrs x1, tpidr_el0 - ldr x0, [x0, #8] - sub x0, x0, x1 + mrs x1, tpidr_el0 /* x1 := current thread tcb */ + ldr x0, [x0, #8] /* x0 := rela->r_addend */ + sub x0, x0, x1 /* x0 := rela->r_addend - tcb */ - ldr x1, [sp], #16 - .cfi_adjust_cfa_offset -16 + ldr x1, [sp], #16 /* restore x1 from stack */ + .cfi_adjust_cfa_offset -16 .cfi_endproc - ret + ret/* return x0 = rela->r_addend - tcb */ END(_rtld_tlsdesc_undef) /* - * uint64_t _rtld_tlsdesc_dynamic(struct rel_tlsdesc *); + * uint64_t@x0 + * _rtld_tlsdesc_dynamic(struct rel_tlsdesc *tlsdesc@x0); + * + * Resolver function for TLS symbols from dlopen(). * - * Resolver function for TLS symbols from dlopen() + * rel_tlsdesc->resolver_arg is a pointer to a struct tls_data + * object allocated during relocation. + * + * Nonstandard calling convention: Must preserve all registers + * except x0. */ ENTRY(_rtld_tlsdesc_dynamic) .cfi_startproc /* Save registers used in fast path */ - stp x1, x2, [sp, #(-2 * 16)]! - stp x3, x4, [sp, #(1 * 16)] + stp x1, x2, [sp, #(-2 * 16)]! + stp x3, x4, [sp, #(1 * 16)] .cfi_adjust_cfa_offset 2 * 16 .cfi_rel_offset x1, 0 .cfi_rel_offset x2, 8 .cfi_rel_offset x3, 16 .cfi_rel_offset x4, 24 - /* Test fastpath - inlined version of __tls_get_addr. */ + /* Try for the fast path -- inlined version of __tls_get_addr. */ - ldr x1, [x0, #8] /* tlsdesc ptr */ - mrs x4, tpidr_el0 - ldr x0, [x4] /* DTV pointer (tcb->tcb_dtv) */ + ldr x1, [x0, #8] /* x1 := tlsdesc (struct tls_data *) */ + mrs x4, tpidr_el0 /* x4 := tcb */ + ldr x0, [x4] /* x0 := dtv = tcb->tcb_dtv */ - ldr x3, [x0, #-8] /* DTV_MAX_INDEX(dtv) */ - ldr x2, [x1, #0] /* tlsdesc->td_tlsindex */ + ldr x3, [x0, #-8] /* x3 := max = DTV_MAX_INDEX(dtv) */ + ldr x2, [x1, #0] /* x2 := idx = tlsdesc->td_tlsindex */ cmp x2, x3 - b.lt 1f /* Slow path */ + b.lt 1f /* Slow path if idx < max */ + /* XXX PR lib/58154 */ + + ldr x3, [x0, x2, lsl #3] /* x3 := dtv[idx] */ + cbz x3, 1f /* Slow path if
CVS commit: src/libexec/ld.elf_so/arch/aarch64
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:18:50 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/aarch64: rtld_start.S Log Message: ld.elf_so aarch64/rtld_start.S: Sprinkle comments. No functional change intended. Prompted by PR lib/58154. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/libexec/ld.elf_so/arch/aarch64/rtld_start.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/libexec/ld.elf_so
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:18:30 UTC 2024 Modified Files: src/tests/libexec/ld.elf_so: t_tls_extern.c Log Message: tests/libexec/ld.elf_so/t_tls_extern: Test PR lib/58154. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/libexec/ld.elf_so/t_tls_extern.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/libexec/ld.elf_so/t_tls_extern.c diff -u src/tests/libexec/ld.elf_so/t_tls_extern.c:1.14 src/tests/libexec/ld.elf_so/t_tls_extern.c:1.15 --- src/tests/libexec/ld.elf_so/t_tls_extern.c:1.14 Thu Jul 11 02:10:42 2024 +++ src/tests/libexec/ld.elf_so/t_tls_extern.c Mon Jul 22 23:18:30 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: t_tls_extern.c,v 1.14 2024/07/11 02:10:42 kre Exp $ */ +/* $NetBSD: t_tls_extern.c,v 1.15 2024/07/22 23:18:30 riastradh Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,6 +30,7 @@ #include #include +#include #define ATF_REQUIRE_DL(x) ATF_REQUIRE_MSG((x) != 0, "%s: %s", #x, dlerror()) @@ -382,6 +383,67 @@ ATF_TC_BODY(onlydef_static_dynamic_lazy, pstatic, pdynamic); } +ATF_TC(opencloseloop_use); +ATF_TC_HEAD(opencloseloop_use, tc) +{ + atf_tc_set_md_var(tc, "descr", "Testing opening and closing in a loop," + " then opening and using dynamic TLS"); +} +ATF_TC_BODY(opencloseloop_use, tc) +{ + unsigned i; + void *def, *use; + int *(*fdef)(void), *(*fuse)(void); + int *pdef, *puse; + + /* + * Open and close the definition library repeatedly. This + * should trigger allocation of many DTV offsets, which are + * (currently) not recycled, so the required DTV offsets should + * become very long -- pages past what is actually allocated + * before we attempt to use it. + * + * This way, we will exercise the wrong-way-conditional fast + * path of PR lib/58154. + */ + for (i = sysconf(_SC_PAGESIZE); i --> 0;) { + ATF_REQUIRE_DL(def = dlopen("libh_def_dynamic.so", 0)); + ATF_REQUIRE_EQ_MSG(dlclose(def), 0, + "dlclose(def): %s", dlerror()); + } + + /* + * Now open the definition library and keep it open. + */ + ATF_REQUIRE_DL(def = dlopen("libh_def_dynamic.so", 0)); + ATF_REQUIRE_DL(fdef = dlsym(def, "fdef")); + + /* + * Open libraries that use the definition and verify they + * observe the same pointer. + */ + ATF_REQUIRE_DL(use = dlopen("libh_use_dynamic.so", 0)); + ATF_REQUIRE_DL(fuse = dlsym(use, "fuse")); +#ifdef __aarch64__ + atf_tc_expect_signal(SIGSEGV, + "PR lib/58154: bad fast path test in aarch64 tls"); +#endif + pdef = (*fdef)(); + puse = (*fuse)(); + ATF_CHECK_EQ_MSG(pdef, puse, + "%p in defining library != %p in using library", + pdef, puse); + + /* + * Also verify the pointer can be used. + */ + *pdef = 123; + *puse = 456; + ATF_CHECK_EQ_MSG(*pdef, *puse, + "%d in defining library != %d in using library", + *pdef, *puse); +} + ATF_TP_ADD_TCS(tp) { @@ -398,6 +460,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, onlydef_dynamic_static_lazy); ATF_TP_ADD_TC(tp, onlydef_static_dynamic_eager); ATF_TP_ADD_TC(tp, onlydef_static_dynamic_lazy); + ATF_TP_ADD_TC(tp, opencloseloop_use); ATF_TP_ADD_TC(tp, static_abusedef); ATF_TP_ADD_TC(tp, static_abusedefnoload); ATF_TP_ADD_TC(tp, static_defabuse_eager);
CVS commit: src/tests/libexec/ld.elf_so
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:18:30 UTC 2024 Modified Files: src/tests/libexec/ld.elf_so: t_tls_extern.c Log Message: tests/libexec/ld.elf_so/t_tls_extern: Test PR lib/58154. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/tests/libexec/ld.elf_so/t_tls_extern.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/ld.elf_so
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:15:57 UTC 2024 Modified Files: src/libexec/ld.elf_so: tls.c Log Message: ld.elf_so: Add comments explaining DTV allocation size. Patch by pho@ for PR lib/58154. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/libexec/ld.elf_so/tls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/tls.c diff -u src/libexec/ld.elf_so/tls.c:1.20 src/libexec/ld.elf_so/tls.c:1.21 --- src/libexec/ld.elf_so/tls.c:1.20 Mon Jul 22 23:14:25 2024 +++ src/libexec/ld.elf_so/tls.c Mon Jul 22 23:15:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: tls.c,v 1.20 2024/07/22 23:14:25 riastradh Exp $ */ +/* $NetBSD: tls.c,v 1.21 2024/07/22 23:15:57 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. @@ -29,7 +29,7 @@ */ #include -__RCSID("$NetBSD: tls.c,v 1.20 2024/07/22 23:14:25 riastradh Exp $"); +__RCSID("$NetBSD: tls.c,v 1.21 2024/07/22 23:15:57 riastradh Exp $"); /* * Thread-local storage @@ -164,6 +164,10 @@ _rtld_tls_get_addr(void *tls, size_t idx if (__predict_false(DTV_GENERATION(dtv) != _rtld_tls_dtv_generation)) { size_t to_copy = DTV_MAX_INDEX(dtv); + /* + * "2 +" because the first element is the generation and + * the second one is the maximum index. + */ new_dtv = xcalloc((2 + _rtld_tls_max_index) * sizeof(*dtv)); ++new_dtv; /* advance past DTV_MAX_INDEX */ if (to_copy > _rtld_tls_max_index) /* XXX How? */ @@ -248,6 +252,10 @@ _rtld_tls_allocate_locked(void) tcb->tcb_self = tcb; #endif dbg(("lwp %d tls tcb %p", _lwp_self(), tcb)); + /* + * "2 +" because the first element is the generation and the second + * one is the maximum index. + */ tcb->tcb_dtv = xcalloc(sizeof(*tcb->tcb_dtv) * (2 + _rtld_tls_max_index)); ++tcb->tcb_dtv; /* advance past DTV_MAX_INDEX */ SET_DTV_MAX_INDEX(tcb->tcb_dtv, _rtld_tls_max_index);
CVS commit: src/libexec/ld.elf_so
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:15:57 UTC 2024 Modified Files: src/libexec/ld.elf_so: tls.c Log Message: ld.elf_so: Add comments explaining DTV allocation size. Patch by pho@ for PR lib/58154. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/libexec/ld.elf_so/tls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/ld.elf_so
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:14:25 UTC 2024 Modified Files: src/libexec/ld.elf_so: README.TLS tls.c Log Message: ld.elf_so: Sprinkle comments and references for thread-local storage. Maybe this will help the TLS business to be less mysterious to the next traveller to pass by here. Prompted by PR lib/58154. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/libexec/ld.elf_so/README.TLS cvs rdiff -u -r1.19 -r1.20 src/libexec/ld.elf_so/tls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/README.TLS diff -u src/libexec/ld.elf_so/README.TLS:1.6 src/libexec/ld.elf_so/README.TLS:1.7 --- src/libexec/ld.elf_so/README.TLS:1.6 Sun Jun 4 01:24:56 2023 +++ src/libexec/ld.elf_so/README.TLS Mon Jul 22 23:14:25 2024 @@ -1,11 +1,111 @@ +Thread-local storage. + +Each thread has a thread control block, or TCB. The TCB is a +variable-size structure headed by `struct tls_tcb' from , +with: + +(a) static thread-local storage for the TLS data of initial objects, +i.e., those loaded at startup rather than those dynamically loaded +by dlopen + +(b) a pointer to a dynamic thread vector (DTV) for the TLS data +pointers of objects that use global-dynamic or local-dynamic models +(typically shared libraries or dlopenable modules) + +(c) the pthread_t pointer + +The per-thread lwp private pointer, also sometimes called TP (thread +pointer), managed by the _lwp_setprivate and _lwp_setprivate syscalls, +either points at the TCB directly, or, on some architectures, points at + + tp = tcb + sizeof(struct tls_tcb) + TLS_TP_OFFSET. + +This bias is chosen for architectures where signed displacements from +TP enable twice the range of static TLS offsets when biased like this. +Architectures with such a tp/tcb offset must provide + +void *__lwp_gettcb_fast(void); + +in machine/mcontext.h and must define __HAVE___LWP_GETTCB_FAST in +machine/types.h to reflect this; otherwise they must provide +__lwp_getprivate_fast to return the TCB pointer. + +Each architecture has one of two TLS variants, variant I or variant II. +Variant I places the static thread-local storage _after_ the fixed +content of the TCB, at increasing addresses (increasing addresses grow +down in diagram): + + +---+ + | dtv pointer | tcb points here (struct tls_tcb) + +---+ + | pthread_t | + +---+ + | obj0 tls | obj0->tlsoffset = 0 + | | + | | + +---+ + | obj1 tls | obj1->tlsoffset = 3 + +---+ + | obj2 tls | obj2->tlsoffset = 4 + | | + . . + . . + . . + | | + +---+ + | objN tls | objN->tlsoffset = k + +---+ + +Variant II places the static thread-local storage _before_ the fixed +content of the TCB, at decreasing addresses: + + +---+ + | objN tls | objN->tlsoffset = k + +---+ + | obj(N-1) tls | obj(N-1)->tlsoffset = k - 1 + . . + . . + . . + | | + +---+ + | obj2 tls | obj2->tlsoffset = 4 + +---+ + | obj1 tls | obj1->tlsoffset = 3 + +---+ + | obj0 tls | obj0->tlsoffset = 0 + | | + | | + +---+ + | tcb pointer | tcb points here (struct tls_tcb) + +---+ + | dtv pointer | + +---+ + | pthread_t | + +---+ + +See [ELFTLS] Sec. 3 `Run-Time Handling of TLS', Figs 1 and 2, for +bigger pictures including the DTV and dynamically allocated TLS blocks. + +Each architecture also has its own ELF ABI processor supplement with +the architecture-specific relocations and TLS details. + +References: + + [ELFTLS] Ulrich Drepper, `ELF Handling For Thread-Local + Storage', Version 0.21, 2023-08-22. + https://akkadia.org/drepper/tls.pdf + https://web.archive.org/web/20240718081934/https://akkadia.org/drepper/tls.pdf + Steps for adding TLS support for a new platform: (1) Declare TLS variant in machine/types.h by defining either __HAVE_TLS_VARIANT_I or __HAVE_TLS_VARIANT_II. -(2) _lwp_makecontext has to set the reserved register or kernel transfer -variable in uc_mcontext to the provided value of 'private'. See -src/lib/libc/arch/$PLATFORM/gen/_lwp.c. +(2) _lwp_makecontext has to set the reserved register or kernel +transfer variable in uc_mcontext according to the provided value of +`private'. Note that _lwp_makecontext takes tcb, not tp, as an +argument, so make sure to adjust it if needed for the tp/tcb offset. +See src/lib/libc/arch/$PLATFORM/gen/_lwp.c. This is not possible on the VAX as there is no free space in ucontext_t. This requires either a special version of _lwp_create or versioning @@ -60,9 +160,22 @@ def->st_value - defobj->tlsoffset
CVS commit: src/libexec/ld.elf_so
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:14:25 UTC 2024 Modified Files: src/libexec/ld.elf_so: README.TLS tls.c Log Message: ld.elf_so: Sprinkle comments and references for thread-local storage. Maybe this will help the TLS business to be less mysterious to the next traveller to pass by here. Prompted by PR lib/58154. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/libexec/ld.elf_so/README.TLS cvs rdiff -u -r1.19 -r1.20 src/libexec/ld.elf_so/tls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/ld.elf_so/arch/riscv
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:11:05 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/riscv: mdreloc.c Log Message: ld.elf_so: Cite reference for RISC-V ELF relocations. PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/libexec/ld.elf_so/arch/riscv/mdreloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/arch/riscv/mdreloc.c diff -u src/libexec/ld.elf_so/arch/riscv/mdreloc.c:1.9 src/libexec/ld.elf_so/arch/riscv/mdreloc.c:1.10 --- src/libexec/ld.elf_so/arch/riscv/mdreloc.c:1.9 Sun Jun 4 01:24:58 2023 +++ src/libexec/ld.elf_so/arch/riscv/mdreloc.c Mon Jul 22 23:11:05 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: mdreloc.c,v 1.9 2023/06/04 01:24:58 joerg Exp $ */ +/* $NetBSD: mdreloc.c,v 1.10 2024/07/22 23:11:05 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -31,9 +31,18 @@ #include #ifndef lint -__RCSID("$NetBSD: mdreloc.c,v 1.9 2023/06/04 01:24:58 joerg Exp $"); +__RCSID("$NetBSD: mdreloc.c,v 1.10 2024/07/22 23:11:05 riastradh Exp $"); #endif /* not lint */ +/* + * RISC-V ELF relocations. + * + * Reference: + * + * [RISCVELF] RISC-V ELF Specification, 2024-07-17. + * https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/9fec6080d15e7f009c9e714d1e9b8dd7177b0b67/riscv-elf.adoc + */ + #include #include #include
CVS commit: src/libexec/ld.elf_so/arch/riscv
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:11:05 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/riscv: mdreloc.c Log Message: ld.elf_so: Cite reference for RISC-V ELF relocations. PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/libexec/ld.elf_so/arch/riscv/mdreloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/ld.elf_so/arch/hppa
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:10:46 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/hppa: hppa_reloc.c Log Message: ld.elf_so: Cite reference for HP PA-RISC ELF relocations. PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c diff -u src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c:1.50 src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c:1.51 --- src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c:1.50 Sun Jun 4 01:24:57 2023 +++ src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c Mon Jul 22 23:10:46 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: hppa_reloc.c,v 1.50 2023/06/04 01:24:57 joerg Exp $ */ +/* $NetBSD: hppa_reloc.c,v 1.51 2024/07/22 23:10:46 riastradh Exp $ */ /*- * Copyright (c) 2002, 2004 The NetBSD Foundation, Inc. @@ -29,9 +29,26 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/* + * HP PA-RISC ELF relocations. + * + * References: + * + * [PAELF] Processor-Specific ELF Supplement for PA-RISC, Version + * 1.5, 1998-08-20. + * https://parisc.wiki.kernel.org/images-parisc/0/0e/Elf-pa-hp.pdf + * https://web.archive.org/web/20240712004045/https://parisc.wiki.kernel.org/images-parisc/0/0e/Elf-pa-hp.pdf + * + * [PATLS] Randolph Chung, Carlos O'Donell, and John David + * Anglin, `Implementing Thread Local Storage for HP PA-RISC + * Linux', 2013-11-11. + * http://www.parisc-linux.org/documentation/tls/hppa-tls-implementation.pdf + * https://web.archive.org/web/20240722131647/http://www.parisc-linux.org/documentation/tls/hppa-tls-implementation.pdf + */ + #include #ifndef lint -__RCSID("$NetBSD: hppa_reloc.c,v 1.50 2023/06/04 01:24:57 joerg Exp $"); +__RCSID("$NetBSD: hppa_reloc.c,v 1.51 2024/07/22 23:10:46 riastradh Exp $"); #endif /* not lint */ #include
CVS commit: src/libexec/ld.elf_so/arch/hppa
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:10:46 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/hppa: hppa_reloc.c Log Message: ld.elf_so: Cite reference for HP PA-RISC ELF relocations. PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/libexec/ld.elf_so/arch/hppa/hppa_reloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/libexec/ld.elf_so/arch
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:10:35 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/aarch64: mdreloc.c src/libexec/ld.elf_so/arch/arm: mdreloc.c Log Message: ld.elf_so: Cite reference for Arm ELF relocations. PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/libexec/ld.elf_so/arch/aarch64/mdreloc.c cvs rdiff -u -r1.46 -r1.47 src/libexec/ld.elf_so/arch/arm/mdreloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/libexec/ld.elf_so/arch/aarch64/mdreloc.c diff -u src/libexec/ld.elf_so/arch/aarch64/mdreloc.c:1.18 src/libexec/ld.elf_so/arch/aarch64/mdreloc.c:1.19 --- src/libexec/ld.elf_so/arch/aarch64/mdreloc.c:1.18 Sun Jun 4 01:24:56 2023 +++ src/libexec/ld.elf_so/arch/aarch64/mdreloc.c Mon Jul 22 23:10:35 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: mdreloc.c,v 1.18 2023/06/04 01:24:56 joerg Exp $ */ +/* $NetBSD: mdreloc.c,v 1.19 2024/07/22 23:10:35 riastradh Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -60,9 +60,24 @@ #include #ifndef lint -__RCSID("$NetBSD: mdreloc.c,v 1.18 2023/06/04 01:24:56 joerg Exp $"); +__RCSID("$NetBSD: mdreloc.c,v 1.19 2024/07/22 23:10:35 riastradh Exp $"); #endif /* not lint */ +/* + * AArch64 ELF relocations. + * + * References: + * + * [AAELF64] ELF for the Arm 64-bit Architecture (AArch64), + * 2022Q3. Arm Ltd. + * https://github.com/ARM-software/abi-aa/blob/2982a9f3b512a5bfdc9e3fea5d3b298f9165c36b/aaelf64/aaelf64.rst + * + * [TLSDESC] Glauber de Oliveira Costa and Alexandre Oliva, + * `Thread-Local Storage Access in Dynamic Libraries in the ARM + * Platform', 2006. + * https://www.fsfla.org/~lxoliva/writeups/TLS/paper-lk2006.pdf + */ + #include #include Index: src/libexec/ld.elf_so/arch/arm/mdreloc.c diff -u src/libexec/ld.elf_so/arch/arm/mdreloc.c:1.46 src/libexec/ld.elf_so/arch/arm/mdreloc.c:1.47 --- src/libexec/ld.elf_so/arch/arm/mdreloc.c:1.46 Sun Jun 4 01:24:57 2023 +++ src/libexec/ld.elf_so/arch/arm/mdreloc.c Mon Jul 22 23:10:35 2024 @@ -1,10 +1,19 @@ -/* $NetBSD: mdreloc.c,v 1.46 2023/06/04 01:24:57 joerg Exp $ */ +/* $NetBSD: mdreloc.c,v 1.47 2024/07/22 23:10:35 riastradh Exp $ */ #include #ifndef lint -__RCSID("$NetBSD: mdreloc.c,v 1.46 2023/06/04 01:24:57 joerg Exp $"); +__RCSID("$NetBSD: mdreloc.c,v 1.47 2024/07/22 23:10:35 riastradh Exp $"); #endif /* not lint */ +/* + * Arm (32-bit) ELF relocations. + * + * Reference: + * + * [AAELF32] ELF for the Arm Architecture, 2022Q3. Arm Ltd. + * https://github.com/ARM-software/abi-aa/blob/2982a9f3b512a5bfdc9e3fea5d3b298f9165c36b/aaelf32/aaelf32.rst + */ + #include #include
CVS commit: src/libexec/ld.elf_so/arch
Module Name:src Committed By: riastradh Date: Mon Jul 22 23:10:35 UTC 2024 Modified Files: src/libexec/ld.elf_so/arch/aarch64: mdreloc.c src/libexec/ld.elf_so/arch/arm: mdreloc.c Log Message: ld.elf_so: Cite reference for Arm ELF relocations. PR lib/58455: Missing references for processor-specific ELF relocation semantics To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/libexec/ld.elf_so/arch/aarch64/mdreloc.c cvs rdiff -u -r1.46 -r1.47 src/libexec/ld.elf_so/arch/arm/mdreloc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.