CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 04:54:43 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Limit MA10-ST0's quirk only for on-chip devices. To generate a diff of this commit: cvs rdiff -u -r1.247 -r1.248 src/sys/dev/pci/ixgbe/ixgbe.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/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.247 src/sys/dev/pci/ixgbe/ixgbe.c:1.248 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.247 Thu Aug 27 04:49:52 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 27 04:54:43 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.247 2020/08/27 04:49:52 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.248 2020/08/27 04:54:43 msaitoh Exp $ */ /** @@ -768,19 +768,26 @@ static void ixgbe_quirks(struct adapter *adapter) { device_t dev = adapter->dev; + struct ixgbe_hw *hw = >hw; const char *vendor, *product; - /* Quirk for inverted logic of SFP+'s MOD_ABS */ - vendor = pmf_get_platform("system-vendor"); - product = pmf_get_platform("system-product"); + if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) { + /* + * Quirk for inverted logic of SFP+'s MOD_ABS on GIGABYTE + * MA10-ST0. + */ + vendor = pmf_get_platform("system-vendor"); + product = pmf_get_platform("system-product"); - if ((vendor == NULL) || (product == NULL)) - return; + if ((vendor == NULL) || (product == NULL)) + return; - if ((strcmp(vendor, "GIGABYTE") == 0) && - (strcmp(product, "MA10-ST0") == 0)) { - aprint_verbose_dev(dev, "Enable SFP+ MOD_ABS inverse quirk\n"); - adapter->quirks |= IXGBE_QUIRK_MOD_ABS_INVERT; + if ((strcmp(vendor, "GIGABYTE") == 0) && + (strcmp(product, "MA10-ST0") == 0)) { + aprint_verbose_dev(dev, + "Enable SFP+ MOD_ABS inverse quirk\n"); + adapter->quirks |= IXGBE_QUIRK_MOD_ABS_INVERT; + } } } @@ -831,9 +838,6 @@ ixgbe_attach(device_t parent, device_t d aprint_normal(": %s, Version - %s\n", ixgbe_strings[ent->index], ixgbe_driver_version); - /* Set quirk flags */ - ixgbe_quirks(adapter); - /* Core Lock Init */ IXGBE_CORE_LOCK_INIT(adapter, device_xname(dev)); @@ -860,6 +864,9 @@ ixgbe_attach(device_t parent, device_t d hw->subsystem_vendor_id = PCI_SUBSYS_VENDOR(subid); hw->subsystem_device_id = PCI_SUBSYS_ID(subid); + /* Set quirk flags */ + ixgbe_quirks(adapter); + /* * Make sure BUSMASTER is set */
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 04:54:43 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Limit MA10-ST0's quirk only for on-chip devices. To generate a diff of this commit: cvs rdiff -u -r1.247 -r1.248 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 04:49:52 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix compile error. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/sys/dev/pci/ixgbe/ixgbe.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/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.246 src/sys/dev/pci/ixgbe/ixgbe.c:1.247 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.246 Thu Aug 27 03:57:52 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 27 04:49:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.246 2020/08/27 03:57:52 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.247 2020/08/27 04:49:52 msaitoh Exp $ */ /** @@ -4500,7 +4500,7 @@ ixgbe_handle_timer(struct work *wk, void /* Check for pluggable optics */ if (ixgbe_is_sfp(hw)) { bool was_full = hw->phy.sfp_type != ixgbe_sfp_type_not_present; - bool is_full = ixgbe_sfp_cage_full(hw); + bool is_full = ixgbe_sfp_cage_full(adapter); /* do probe if cage state changed */ if (was_full ^ is_full) {
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 04:49:52 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c Log Message: Fix compile error. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/sys/dev/pci/ixgbe/ixgbe.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 03:57:52 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_common.c Log Message: Minor change. - Print "X550EM X" instead of "X550EM" for Xeon D devices. - Fix typo in comment. Same as FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.245 -r1.246 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/pci/ixgbe/ixgbe_common.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 03:57:52 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe_common.c Log Message: Minor change. - Print "X550EM X" instead of "X550EM" for Xeon D devices. - Fix typo in comment. Same as FreeBSD. To generate a diff of this commit: cvs rdiff -u -r1.245 -r1.246 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/pci/ixgbe/ixgbe_common.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/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.245 src/sys/dev/pci/ixgbe/ixgbe.c:1.246 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.245 Thu Aug 27 00:07:56 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 27 03:57:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.245 2020/08/27 00:07:56 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.246 2020/08/27 03:57:52 msaitoh Exp $ */ /** @@ -900,7 +900,7 @@ ixgbe_attach(device_t parent, device_t d str = "X550"; break; case ixgbe_mac_X550EM_x: - str = "X550EM"; + str = "X550EM X"; break; case ixgbe_mac_X550EM_a: str = "X550EM A"; Index: src/sys/dev/pci/ixgbe/ixgbe_common.c diff -u src/sys/dev/pci/ixgbe/ixgbe_common.c:1.27 src/sys/dev/pci/ixgbe/ixgbe_common.c:1.28 --- src/sys/dev/pci/ixgbe/ixgbe_common.c:1.27 Wed Feb 5 07:45:46 2020 +++ src/sys/dev/pci/ixgbe/ixgbe_common.c Thu Aug 27 03:57:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe_common.c,v 1.27 2020/02/05 07:45:46 msaitoh Exp $ */ +/* $NetBSD: ixgbe_common.c,v 1.28 2020/08/27 03:57:52 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -5234,7 +5234,7 @@ void ixgbe_get_oem_prod_version(struct i nvm_ver->oem_valid = FALSE; hw->eeprom.ops.read(hw, NVM_OEM_PROD_VER_PTR, ); - /* Return is offset to OEM Product Version block is invalid */ + /* Return if offset to OEM Product Version block is invalid */ if (offset == 0x0 || offset == NVM_INVALID_PTR) return;
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 27 03:05:34 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: wg: Make sure all paths into wg_handle_msg_data guarantee enough m_len. Earlier commit moved the m_pullup into wg_validate_msg_header, but wg_overudp_cb doesn't go through that. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 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.28 src/sys/net/if_wg.c:1.29 --- src/sys/net/if_wg.c:1.28 Thu Aug 27 02:55:04 2020 +++ src/sys/net/if_wg.c Thu Aug 27 03:05:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.28 2020/08/27 02:55:04 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.29 2020/08/27 03:05:34 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.28 2020/08/27 02:55:04 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.29 2020/08/27 03:05:34 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2955,6 +2955,11 @@ wg_overudp_cb(struct mbuf **mp, int offs case WG_MSG_TYPE_DATA: /* handle immediately */ m_adj(m, offset); + if (__predict_false(m->m_len < sizeof(struct wg_msg_data))) { + m = m_pullup(m, sizeof(struct wg_msg_data)); + if (m == NULL) +return -1; + } wg_handle_msg_data(wg, m, src); *mp = NULL; return 1;
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 27 03:05:34 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: wg: Make sure all paths into wg_handle_msg_data guarantee enough m_len. Earlier commit moved the m_pullup into wg_validate_msg_header, but wg_overudp_cb doesn't go through that. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 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: riastradh Date: Thu Aug 27 02:54:31 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: wg: KASSERT m_len before mtod. XXX We should really make mtod do this automagically, and use something else for mtod(m, void *). To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 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.26 src/sys/net/if_wg.c:1.27 --- src/sys/net/if_wg.c:1.26 Thu Aug 27 02:53:47 2020 +++ src/sys/net/if_wg.c Thu Aug 27 02:54:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.26 2020/08/27 02:53:47 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.27 2020/08/27 02:54:31 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.26 2020/08/27 02:53:47 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.27 2020/08/27 02:54:31 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1570,7 +1570,6 @@ wg_send_handshake_msg_init(struct wg_sof m = m_gethdr(M_WAIT, MT_DATA); m->m_pkthdr.len = m->m_len = sizeof(*wgmi); wgmi = mtod(m, struct wg_msg_init *); - wg_fill_msg_init(wg, wgp, wgs, wgmi); error = wg->wg_ops->send_hs_msg(wgp, m); @@ -2387,6 +2386,7 @@ wg_handle_msg_data(struct wg_softc *wg, free_encrypted_buf = true; } /* m_ensure_contig may change m regardless of its result */ + KASSERT(m->m_len >= sizeof(*wgmd)); wgmd = mtod(m, struct wg_msg_data *); decrypted_len = encrypted_len - WG_AUTHTAG_LEN; @@ -2683,6 +2683,7 @@ wg_receive_packets(struct wg_softc *wg, } KASSERT(paddr != NULL); + KASSERT(paddr->m_len >= sizeof(struct sockaddr)); src = mtod(paddr, struct sockaddr *); wg_handle_packet(wg, m, src); @@ -3683,6 +3684,7 @@ wg_send_data_msg(struct wg_peer *wgp, st error = ENOBUFS; goto end; } + KASSERT(n->m_len >= sizeof(*wgmd)); wgmd = mtod(n, struct wg_msg_data *); wg_fill_msg_data(wg, wgp, wgs, wgmd); /* [W] 5.4.6: AEAD(Tm^send, Nm^send, P, e) */ @@ -4553,11 +4555,15 @@ wg_input_user(struct ifnet *ifp, struct if (af == AF_INET) { struct sockaddr_in *sin = (struct sockaddr_in *) struct ip *ip; + + KASSERT(m->m_len >= sizeof(struct ip)); ip = mtod(m, struct ip *); sockaddr_in_init(sin, >ip_dst, 0); } else { struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *) struct ip6_hdr *ip6; + + KASSERT(m->m_len >= sizeof(struct ip6_hdr)); ip6 = mtod(m, struct ip6_hdr *); sockaddr_in6_init(sin6, >ip6_dst, 0, 0, 0); }
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:55:05 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: wg: Drop invalid message types on the floor faster. Don't even let them reach the thread -- drop them in softint. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 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.27 src/sys/net/if_wg.c:1.28 --- src/sys/net/if_wg.c:1.27 Thu Aug 27 02:54:31 2020 +++ src/sys/net/if_wg.c Thu Aug 27 02:55:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.27 2020/08/27 02:54:31 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.28 2020/08/27 02:55:04 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.27 2020/08/27 02:54:31 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.28 2020/08/27 02:55:04 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2934,6 +2934,7 @@ wg_overudp_cb(struct mbuf **mp, int offs /* Verify the mbuf chain is long enough to have a wg msg header. */ KASSERT(offset <= m_length(m)); if (__predict_false(m_length(m) - offset < sizeof(struct wg_msg))) { + /* drop on the floor */ m_freem(m); return -1; } @@ -2952,15 +2953,21 @@ wg_overudp_cb(struct mbuf **mp, int offs */ switch (wgm.wgm_type) { case WG_MSG_TYPE_DATA: + /* handle immediately */ m_adj(m, offset); wg_handle_msg_data(wg, m, src); *mp = NULL; return 1; + case WG_MSG_TYPE_INIT: + case WG_MSG_TYPE_RESP: + case WG_MSG_TYPE_COOKIE: + /* pass through to so_receive in wg_receive_packets */ + return 0; default: - break; + /* drop on the floor */ + m_freem(m); + return -1; } - - return 0; } static int
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:55:05 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: wg: Drop invalid message types on the floor faster. Don't even let them reach the thread -- drop them in softint. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 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: riastradh Date: Thu Aug 27 02:54:31 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: wg: KASSERT m_len before mtod. XXX We should really make mtod do this automagically, and use something else for mtod(m, void *). To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 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: riastradh Date: Thu Aug 27 02:53:47 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: wg: Use m_pullup to make message header contiguous before processing. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 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.25 src/sys/net/if_wg.c:1.26 --- src/sys/net/if_wg.c:1.25 Thu Aug 27 02:52:33 2020 +++ src/sys/net/if_wg.c Thu Aug 27 02:53:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.25 2020/08/27 02:52:33 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.26 2020/08/27 02:53:47 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.25 2020/08/27 02:52:33 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.26 2020/08/27 02:53:47 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2343,11 +2343,7 @@ wg_handle_msg_data(struct wg_softc *wg, bool success, free_encrypted_buf = false, ok; struct mbuf *n; - if (m->m_len < sizeof(struct wg_msg_data)) { - m = m_pullup(m, sizeof(struct wg_msg_data)); - if (m == NULL) - return; - } + KASSERT(m->m_len >= sizeof(struct wg_msg_data)); wgmd = mtod(m, struct wg_msg_data *); KASSERT(wgmd->wgmd_type == WG_MSG_TYPE_DATA); @@ -2573,42 +2569,63 @@ out: wg_put_session(wgs, ); } -static bool -wg_validate_msg_length(struct wg_softc *wg, const struct mbuf *m) +static struct mbuf * +wg_validate_msg_header(struct wg_softc *wg, struct mbuf *m) { - struct wg_msg *wgm; - size_t mlen; + struct wg_msg wgm; + size_t mbuflen; + size_t msglen; - mlen = m_length(m); - if (__predict_false(mlen < sizeof(struct wg_msg))) - return false; + /* + * Get the mbuf chain length. It is already guaranteed, by + * wg_overudp_cb, to be large enough for a struct wg_msg. + */ + mbuflen = m_length(m); + KASSERT(mbuflen >= sizeof(struct wg_msg)); - wgm = mtod(m, struct wg_msg *); - switch (wgm->wgm_type) { + /* + * Copy the message header (32-bit message type) out -- we'll + * worry about contiguity and alignment later. + */ + m_copydata(m, 0, sizeof(wgm), ); + switch (wgm.wgm_type) { case WG_MSG_TYPE_INIT: - if (__predict_true(mlen >= sizeof(struct wg_msg_init))) - return true; + msglen = sizeof(struct wg_msg_init); break; case WG_MSG_TYPE_RESP: - if (__predict_true(mlen >= sizeof(struct wg_msg_resp))) - return true; + msglen = sizeof(struct wg_msg_resp); break; case WG_MSG_TYPE_COOKIE: - if (__predict_true(mlen >= sizeof(struct wg_msg_cookie))) - return true; + msglen = sizeof(struct wg_msg_cookie); break; case WG_MSG_TYPE_DATA: - if (__predict_true(mlen >= sizeof(struct wg_msg_data))) - return true; + msglen = sizeof(struct wg_msg_data); break; default: WG_LOG_RATECHECK(>wg_ppsratecheck, LOG_DEBUG, - "Unexpected msg type: %u\n", wgm->wgm_type); - return false; + "Unexpected msg type: %u\n", wgm.wgm_type); + goto error; } - WG_DLOG("Invalid msg size: mlen=%lu type=%u\n", mlen, wgm->wgm_type); - return false; + /* 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, + wgm.wgm_type); + goto error; + } + + /* Make the message header contiguous if necessary. */ + if (__predict_false(m->m_len < msglen)) { + m = m_pullup(m, msglen); + if (m == NULL) + return NULL; + } + + return m; + +error: + m_freem(m); + return NULL; } static void @@ -2616,14 +2633,12 @@ wg_handle_packet(struct wg_softc *wg, st const struct sockaddr *src) { struct wg_msg *wgm; - bool valid; - valid = wg_validate_msg_length(wg, m); - if (!valid) { - m_freem(m); + m = wg_validate_msg_header(wg, m); + if (__predict_false(m == NULL)) return; - } + KASSERT(m->m_len >= sizeof(struct wg_msg)); wgm = mtod(m, struct wg_msg *); switch (wgm->wgm_type) { case WG_MSG_TYPE_INIT: @@ -2639,7 +2654,7 @@ wg_handle_packet(struct wg_softc *wg, st wg_handle_msg_data(wg, m, src); break; default: - /* wg_validate_msg_length should already reject this case */ + /* wg_validate_msg_header should already reject this case */ break; } }
CVS commit: src/sys/net
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:53:47 UTC 2020 Modified Files: src/sys/net: if_wg.c Log Message: wg: Use m_pullup to make message header contiguous before processing. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 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
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:52:34 UTC 2020 Modified Files: src/sys/net: if_wg.c src/tests/net/if_wg: t_misc.sh Log Message: wg: Check mbuf chain length before m_copydata. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/net/if_wg.c cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_wg/t_misc.sh 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.24 src/sys/net/if_wg.c:1.25 --- src/sys/net/if_wg.c:1.24 Wed Aug 26 16:03:41 2020 +++ src/sys/net/if_wg.c Thu Aug 27 02:52:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wg.c,v 1.24 2020/08/26 16:03:41 riastradh Exp $ */ +/* $NetBSD: if_wg.c,v 1.25 2020/08/27 02:52:33 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.24 2020/08/26 16:03:41 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wg.c,v 1.25 2020/08/27 02:52:33 riastradh Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -2915,9 +2915,25 @@ wg_overudp_cb(struct mbuf **mp, int offs WG_TRACE("enter"); + /* Verify the mbuf chain is long enough to have a wg msg header. */ + KASSERT(offset <= m_length(m)); + if (__predict_false(m_length(m) - offset < sizeof(struct wg_msg))) { + m_freem(m); + return -1; + } + + /* + * Copy the message header (32-bit message type) out -- we'll + * worry about contiguity and alignment later. + */ m_copydata(m, offset, sizeof(struct wg_msg), ); WG_DLOG("type=%d\n", wgm.wgm_type); + /* + * Handle DATA packets promptly as they arrive. Other packets + * may require expensive public-key crypto and are not as + * sensitive to latency, so defer them to the worker thread. + */ switch (wgm.wgm_type) { case WG_MSG_TYPE_DATA: m_adj(m, offset); Index: src/tests/net/if_wg/t_misc.sh diff -u src/tests/net/if_wg/t_misc.sh:1.2 src/tests/net/if_wg/t_misc.sh:1.3 --- src/tests/net/if_wg/t_misc.sh:1.2 Thu Aug 27 02:51:49 2020 +++ src/tests/net/if_wg/t_misc.sh Thu Aug 27 02:52:33 2020 @@ -1,4 +1,4 @@ -# $NetBSD: t_misc.sh,v 1.2 2020/08/27 02:51:49 riastradh Exp $ +# $NetBSD: t_misc.sh,v 1.3 2020/08/27 02:52:33 riastradh Exp $ # # Copyright (c) 2018 Ryota Ozaki # All rights reserved. @@ -588,6 +588,78 @@ wg_psk_cleanup() cleanup } +atf_test_case wg_malformed cleanup +wg_malformed_head() +{ + + atf_set "descr" "tests malformed packet headers" + atf_set "require.progs" "nc" "rump_server" "wgconfig" "wg-keygen" + atf_set "timeout" "10" +} + +wg_malformed_body() +{ + local ifconfig="atf_check -s exit:0 rump.ifconfig" + local ping="atf_check -s exit:0 -o ignore rump.ping -n -c 1 -w 1" + local ip_local=192.168.1.1 + local ip_peer=192.168.1.2 + local ip_wg_local=10.0.0.1 + local ip_wg_peer=10.0.0.2 + local port=51820 + setup_servers + + # It sets key_priv_local key_pub_local key_priv_peer key_pub_peer + generate_keys + + export RUMP_SERVER=$SOCK_LOCAL + setup_common shmif0 inet $ip_local 24 + setup_wg_common wg0 inet $ip_wg_local 24 $port "$key_priv_local" + + export RUMP_SERVER=$SOCK_PEER + setup_common shmif0 inet $ip_peer 24 + setup_wg_common wg0 inet $ip_wg_peer 24 $port "$key_priv_peer" + + export RUMP_SERVER=$SOCK_LOCAL + add_peer wg0 peer0 $key_pub_peer $ip_peer:$port $ip_wg_peer/32 + + export RUMP_SERVER=$SOCK_PEER + add_peer wg0 peer0 $key_pub_local $ip_local:$port $ip_wg_local/32 + + export RUMP_SERVER=$SOCK_LOCAL + + $ping $ip_wg_peer + + printf 'send malformed packets\n' + + $HIJACKING ping -c 1 -n $ip_peer + + printf 'x' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf 'xy' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf 'xyz' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf 'xyzw' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf '\x00\x00\x00\x00' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf '\x00\x00\x00\x00z' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf '\x01\x00\x00\x00' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf '\x01\x00\x00\x00z' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf '\x02\x00\x00\x00' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf '\x02\x00\x00\x00z' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf '\x03\x00\x00\x00' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf '\x03\x00\x00\x00z' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf '\x04\x00\x00\x00' | $HIJACKING nc -Nu -w 0 $ip_peer $port + printf '\x04\x00\x00\x00z' | $HIJACKING nc -Nu -w 0 $ip_peer $port + + printf 'done sending malformed packets\n' + + $ping $ip_wg_peer +} + +wg_malformed_cleanup() +{ + + $DEBUG && dump + cleanup +} + atf_init_test_cases() { @@ -597,4 +669,5 @@ atf_init_test_cases() atf_add_test_case wg_mobility atf_add_test_case wg_keepalive atf_add_test_case wg_psk + atf_add_test_case wg_malformed }
CVS commit: src
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:52:34 UTC 2020 Modified Files: src/sys/net: if_wg.c src/tests/net/if_wg: t_misc.sh Log Message: wg: Check mbuf chain length before m_copydata. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/sys/net/if_wg.c cvs rdiff -u -r1.2 -r1.3 src/tests/net/if_wg/t_misc.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/if_wg
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:51:50 UTC 2020 Modified Files: src/tests/net/if_wg: t_misc.sh Log Message: Use wgconfig as intended to show diagnostics, not a usage message. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/if_wg/t_misc.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/if_wg
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:51:50 UTC 2020 Modified Files: src/tests/net/if_wg: t_misc.sh Log Message: Use wgconfig as intended to show diagnostics, not a usage message. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/net/if_wg/t_misc.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/net/if_wg/t_misc.sh diff -u src/tests/net/if_wg/t_misc.sh:1.1 src/tests/net/if_wg/t_misc.sh:1.2 --- src/tests/net/if_wg/t_misc.sh:1.1 Wed Aug 26 16:03:42 2020 +++ src/tests/net/if_wg/t_misc.sh Thu Aug 27 02:51:49 2020 @@ -1,4 +1,4 @@ -# $NetBSD: t_misc.sh,v 1.1 2020/08/26 16:03:42 riastradh Exp $ +# $NetBSD: t_misc.sh,v 1.2 2020/08/27 02:51:49 riastradh Exp $ # # Copyright (c) 2018 Ryota Ozaki # All rights reserved. @@ -277,7 +277,7 @@ wg_cookie_body() -o match:"$ip_peer.$port > $ip_local.$port: UDP, length 64" \ cat $outfile - $DEBUG && $HIJACKING wgconfig wg0 show + $DEBUG && $HIJACKING wgconfig wg0 show all atf_check -s exit:0 -o match:"latest-handshake: 0" \ $HIJACKING wgconfig wg0 @@ -288,7 +288,7 @@ wg_cookie_body() # a valid cookie. $ping $ip_wg_peer - $DEBUG && $HIJACKING wgconfig wg0 show + $DEBUG && $HIJACKING wgconfig wg0 show all atf_check -s exit:0 -o not-match:"latest-handshake: 0" \ $HIJACKING wgconfig wg0
CVS commit: src/sys/rump/net/lib/libwg
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:51:15 UTC 2020 Modified Files: src/sys/rump/net/lib/libwg: wg_user.c Log Message: Fix order of cleanup actions in rumpuser_wg_create error branch. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libwg/wg_user.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/rump/net/lib/libwg/wg_user.c diff -u src/sys/rump/net/lib/libwg/wg_user.c:1.2 src/sys/rump/net/lib/libwg/wg_user.c:1.3 --- src/sys/rump/net/lib/libwg/wg_user.c:1.2 Thu Aug 27 02:50:44 2020 +++ src/sys/rump/net/lib/libwg/wg_user.c Thu Aug 27 02:51:15 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wg_user.c,v 1.2 2020/08/27 02:50:44 riastradh Exp $ */ +/* $NetBSD: wg_user.c,v 1.3 2020/08/27 02:51:15 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wg_user.c,v 1.2 2020/08/27 02:50:44 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wg_user.c,v 1.3 2020/08/27 02:51:15 riastradh Exp $"); #ifndef _KERNEL #include @@ -277,13 +277,13 @@ rumpuser_wg_create(const char *tun_name, return 0; oerr5: - close(wgu->wgu_pipe[0]); - close(wgu->wgu_pipe[1]); - oerr4: if (wgu->wgu_sock4 != -1) close(wgu->wgu_sock4); if (wgu->wgu_sock6 != -1) close(wgu->wgu_sock6); + oerr4: + close(wgu->wgu_pipe[0]); + close(wgu->wgu_pipe[1]); oerr3: close_tun(wgu); oerr2:
CVS commit: src/sys/rump/net/lib/libwg
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:51:15 UTC 2020 Modified Files: src/sys/rump/net/lib/libwg: wg_user.c Log Message: Fix order of cleanup actions in rumpuser_wg_create error branch. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/rump/net/lib/libwg/wg_user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/rump/net/lib/libwg
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:50:44 UTC 2020 Modified Files: src/sys/rump/net/lib/libwg: wg_user.c Log Message: Paranoia: use strlcpy rather than strcpy here and detect truncation. Not an issue for the one caller in tree, but let's not leave rakes to step on. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libwg/wg_user.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/rump/net/lib/libwg
Module Name:src Committed By: riastradh Date: Thu Aug 27 02:50:44 UTC 2020 Modified Files: src/sys/rump/net/lib/libwg: wg_user.c Log Message: Paranoia: use strlcpy rather than strcpy here and detect truncation. Not an issue for the one caller in tree, but let's not leave rakes to step on. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/rump/net/lib/libwg/wg_user.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/rump/net/lib/libwg/wg_user.c diff -u src/sys/rump/net/lib/libwg/wg_user.c:1.1 src/sys/rump/net/lib/libwg/wg_user.c:1.2 --- src/sys/rump/net/lib/libwg/wg_user.c:1.1 Wed Aug 26 16:03:42 2020 +++ src/sys/rump/net/lib/libwg/wg_user.c Thu Aug 27 02:50:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: wg_user.c,v 1.1 2020/08/26 16:03:42 riastradh Exp $ */ +/* $NetBSD: wg_user.c,v 1.2 2020/08/27 02:50:44 riastradh Exp $ */ /* * Copyright (C) Ryota Ozaki @@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wg_user.c,v 1.1 2020/08/26 16:03:42 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wg_user.c,v 1.2 2020/08/27 02:50:44 riastradh Exp $"); #ifndef _KERNEL #include @@ -243,13 +243,18 @@ rumpuser_wg_create(const char *tun_name, goto oerr1; } + if (strlcpy(wgu->wgu_tun_name, tun_name, sizeof(wgu->wgu_tun_name)) + >= sizeof(wgu->wgu_tun_name)) { + rv = EINVAL; + goto oerr2; + } + wgu->wgu_sc = wg; + wgu->wgu_fd = open_tun(tun_name); if (wgu->wgu_fd == -1) { rv = errno; goto oerr2; } - strcpy(wgu->wgu_tun_name, tun_name); - wgu->wgu_sc = wg; if (pipe(wgu->wgu_pipe) == -1) { rv = errno;
CVS commit: src/usr.bin/column
Module Name:src Committed By: simonb Date: Thu Aug 27 01:52:04 UTC 2020 Modified Files: src/usr.bin/column: column.c Log Message: Whitespace nit. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/column/column.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/column/column.c diff -u src/usr.bin/column/column.c:1.21 src/usr.bin/column/column.c:1.22 --- src/usr.bin/column/column.c:1.21 Mon Jul 21 14:19:21 2008 +++ src/usr.bin/column/column.c Thu Aug 27 01:52:04 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: column.c,v 1.21 2008/07/21 14:19:21 lukem Exp $ */ +/* $NetBSD: column.c,v 1.22 2020/08/27 01:52:04 simonb Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19 #if 0 static char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95"; #endif -__RCSID("$NetBSD: column.c,v 1.21 2008/07/21 14:19:21 lukem Exp $"); +__RCSID("$NetBSD: column.c,v 1.22 2020/08/27 01:52:04 simonb Exp $"); #endif /* not lint */ #include @@ -246,7 +246,7 @@ maketbl(void) } } for (cnt = 0, t = tbl; cnt < entries; ++cnt, ++t) { - for (coloff = 0; coloff < t->cols - 1; ++coloff) + for (coloff = 0; coloff < t->cols - 1; ++coloff) (void)printf("%s%*s", t->list[coloff], lens[coloff] - t->len[coloff] + 2, " "); (void)printf("%s\n", t->list[coloff]);
CVS commit: src/usr.bin/column
Module Name:src Committed By: simonb Date: Thu Aug 27 01:52:04 UTC 2020 Modified Files: src/usr.bin/column: column.c Log Message: Whitespace nit. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.bin/column/column.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 00:07:56 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h Log Message: ADD SFP+ MOD_ABS inversion quirk. On X550 EM, GPIO(SDP) and SFP+'s MOD_ABS is directly connected. It has no inverter. GIGABYTE MA10-ST0 has a inverter, so add new quirk for it. To generate a diff of this commit: cvs rdiff -u -r1.244 -r1.245 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.69 -r1.70 src/sys/dev/pci/ixgbe/ixgbe.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/dev/pci/ixgbe/ixgbe.c diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.244 src/sys/dev/pci/ixgbe/ixgbe.c:1.245 --- src/sys/dev/pci/ixgbe/ixgbe.c:1.244 Mon Aug 24 19:03:27 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.c Thu Aug 27 00:07:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.c,v 1.244 2020/08/24 19:03:27 msaitoh Exp $ */ +/* $NetBSD: ixgbe.c,v 1.245 2020/08/27 00:07:56 msaitoh Exp $ */ /** @@ -159,6 +159,7 @@ static const char*ixgbe_strings[] = * Function prototypes / static int ixgbe_probe(device_t, cfdata_t, void *); +static void ixgbe_quirks(struct adapter *); static void ixgbe_attach(device_t, device_t, void *); static int ixgbe_detach(device_t, int); #if 0 @@ -257,7 +258,7 @@ static int ixgbe_sysctl_wol_enable(SYSCT static int ixgbe_sysctl_wufc(SYSCTLFN_PROTO); /* Support for pluggable optic modules */ -static bool ixgbe_sfp_cage_full(struct ixgbe_hw *); +static bool ixgbe_sfp_cage_full(struct adapter *); /* Legacy (single vector) interrupt handler */ static int ixgbe_legacy_irq(void *); @@ -763,6 +764,26 @@ ixgbe_initialize_transmit_units(struct a return; } /* ixgbe_initialize_transmit_units */ +static void +ixgbe_quirks(struct adapter *adapter) +{ + device_t dev = adapter->dev; + const char *vendor, *product; + + /* Quirk for inverted logic of SFP+'s MOD_ABS */ + vendor = pmf_get_platform("system-vendor"); + product = pmf_get_platform("system-product"); + + if ((vendor == NULL) || (product == NULL)) + return; + + if ((strcmp(vendor, "GIGABYTE") == 0) && + (strcmp(product, "MA10-ST0") == 0)) { + aprint_verbose_dev(dev, "Enable SFP+ MOD_ABS inverse quirk\n"); + adapter->quirks |= IXGBE_QUIRK_MOD_ABS_INVERT; + } +} + / * ixgbe_attach - Device initialization routine * @@ -810,6 +831,9 @@ ixgbe_attach(device_t parent, device_t d aprint_normal(": %s, Version - %s\n", ixgbe_strings[ent->index], ixgbe_driver_version); + /* Set quirk flags */ + ixgbe_quirks(adapter); + /* Core Lock Init */ IXGBE_CORE_LOCK_INIT(adapter, device_xname(dev)); @@ -4620,8 +4644,9 @@ ixgbe_handle_recovery_mode_timer(struct * Determine if a port had optics inserted. / static bool -ixgbe_sfp_cage_full(struct ixgbe_hw *hw) +ixgbe_sfp_cage_full(struct adapter *adapter) { + struct ixgbe_hw *hw = >hw; uint32_t mask; int rv; @@ -4631,9 +4656,12 @@ ixgbe_sfp_cage_full(struct ixgbe_hw *hw) mask = IXGBE_ESDP_SDP2; rv = IXGBE_READ_REG(hw, IXGBE_ESDP) & mask; + if ((adapter->quirks & IXGBE_QUIRK_MOD_ABS_INVERT) != 0) + rv = !rv; + if (hw->mac.type == ixgbe_mac_X550EM_a) { - /* It seems X550EM_a's SDP0 is inverted than others... */ - return (rv == 0); + /* X550EM_a's SDP0 is inverted than others. */ + return !rv; } return rv; Index: src/sys/dev/pci/ixgbe/ixgbe.h diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.69 src/sys/dev/pci/ixgbe/ixgbe.h:1.70 --- src/sys/dev/pci/ixgbe/ixgbe.h:1.69 Mon Aug 17 07:59:06 2020 +++ src/sys/dev/pci/ixgbe/ixgbe.h Thu Aug 27 00:07:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ixgbe.h,v 1.69 2020/08/17 07:59:06 msaitoh Exp $ */ +/* $NetBSD: ixgbe.h,v 1.70 2020/08/27 00:07:56 msaitoh Exp $ */ /** SPDX-License-Identifier: BSD-3-Clause @@ -623,6 +623,9 @@ struct adapter { u32 feat_cap; u32 feat_en; + /* Quirks */ + u32 quirks; + /* Traffic classes */ struct ixgbe_tc tcs[IXGBE_DCB_MAX_TRAFFIC_CLASS]; @@ -770,6 +773,8 @@ bool ixgbe_rxeof(struct ix_queue *); #define IXGBE_REQUEST_TASK_LSC 0x20 #define IXGBE_REQUEST_TASK_NEED_ACKINTR 0x80 +#define IXGBE_QUIRK_MOD_ABS_INVERT __BIT(0) + /* For NetBSD */ const struct sysctlnode *ixgbe_sysctl_instance(struct adapter *); void ixgbe_jcl_reinit(struct adapter *, bus_dma_tag_t, struct rx_ring *,
CVS commit: src/sys/dev/pci/ixgbe
Module Name:src Committed By: msaitoh Date: Thu Aug 27 00:07:56 UTC 2020 Modified Files: src/sys/dev/pci/ixgbe: ixgbe.c ixgbe.h Log Message: ADD SFP+ MOD_ABS inversion quirk. On X550 EM, GPIO(SDP) and SFP+'s MOD_ABS is directly connected. It has no inverter. GIGABYTE MA10-ST0 has a inverter, so add new quirk for it. To generate a diff of this commit: cvs rdiff -u -r1.244 -r1.245 src/sys/dev/pci/ixgbe/ixgbe.c cvs rdiff -u -r1.69 -r1.70 src/sys/dev/pci/ixgbe/ixgbe.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/usr.bin/sockstat
"Christos Zoulas" wrote: > Module Name: src > Committed By: christos > Date: Wed Aug 26 22:57:56 UTC 2020 > > Modified Files: > > src/usr.bin/sockstat: Makefile sockstat.c > > Log Message: > > undo previous, now sockstat works without privs Nice, thanks Christos! Cheers, Simon.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Wed Aug 26 23:08:26 UTC 2020 Modified Files: src/usr.bin/make: suff.c Log Message: make(1): merge duplicate code for creating a new suffix To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/usr.bin/make/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Wed Aug 26 23:08:26 UTC 2020 Modified Files: src/usr.bin/make: suff.c Log Message: make(1): merge duplicate code for creating a new suffix To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/usr.bin/make/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.116 src/usr.bin/make/suff.c:1.117 --- src/usr.bin/make/suff.c:1.116 Wed Aug 26 22:55:46 2020 +++ src/usr.bin/make/suff.c Wed Aug 26 23:08:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.116 2020/08/26 22:55:46 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.117 2020/08/26 23:08:26 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: suff.c,v 1.116 2020/08/26 22:55:46 rillig Exp $"; +static char rcsid[] = "$NetBSD: suff.c,v 1.117 2020/08/26 23:08:26 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else -__RCSID("$NetBSD: suff.c,v 1.116 2020/08/26 22:55:46 rillig Exp $"); +__RCSID("$NetBSD: suff.c,v 1.117 2020/08/26 23:08:26 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -527,6 +527,24 @@ SuffInsert(Lst l, Suff *s) } } +static Suff * +SuffNew(const char *name) +{ +Suff *s = bmake_malloc(sizeof(Suff)); + +s->name = bmake_strdup(name); +s->nameLen = strlen(s->name); +s->searchPath = Lst_Init(); +s->children = Lst_Init(); +s->parents = Lst_Init(); +s->ref = Lst_Init(); +s->sNum = sNum++; +s->flags = 0; +s->refCount = 1; + +return s; +} + /*- *--- * Suff_ClearSuffixes -- @@ -554,18 +572,10 @@ Suff_ClearSuffixes(void) sNum = 0; if (suffNull) SuffFree(suffNull); -emptySuff = suffNull = bmake_malloc(sizeof(Suff)); +emptySuff = suffNull = SuffNew(""); -suffNull->name = bmake_strdup(""); -suffNull->nameLen = 0; -suffNull->searchPath = Lst_Init(); Dir_Concat(suffNull->searchPath, dirSearchPath); -suffNull->children =Lst_Init(); -suffNull->parents = Lst_Init(); -suffNull->ref = Lst_Init(); -suffNull->sNum = sNum++; suffNull->flags = SUFF_NULL; -suffNull->refCount =1; } /*- @@ -978,17 +988,7 @@ Suff_AddSuffix(char *str, GNode **gn) ln = Lst_FindS(sufflist, SuffSuffHasNameP, str); if (ln == NULL) { - s = bmake_malloc(sizeof(Suff)); - - s->name = bmake_strdup(str); - s->nameLen = strlen(s->name); - s->searchPath = Lst_Init(); - s->children = Lst_Init(); - s->parents = Lst_Init(); - s->ref = Lst_Init(); - s->sNum = sNum++; - s->flags = 0; - s->refCount = 1; +s = SuffNew(str); Lst_AppendS(sufflist, s); /*
CVS commit: src/usr.bin/fstat
Module Name:src Committed By: christos Date: Wed Aug 26 23:08:29 UTC 2020 Modified Files: src/usr.bin/fstat: fstat.c Log Message: Provide a helpful error message if we don't have privs to read kernel addresses. To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/usr.bin/fstat/fstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/fstat/fstat.c diff -u src/usr.bin/fstat/fstat.c:1.113 src/usr.bin/fstat/fstat.c:1.114 --- src/usr.bin/fstat/fstat.c:1.113 Fri Sep 6 13:08:22 2019 +++ src/usr.bin/fstat/fstat.c Wed Aug 26 19:08:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: fstat.c,v 1.113 2019/09/06 17:08:22 christos Exp $ */ +/* $NetBSD: fstat.c,v 1.114 2020/08/26 23:08:29 christos Exp $ */ /*- * Copyright (c) 1988, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95"; #else -__RCSID("$NetBSD: fstat.c,v 1.113 2019/09/06 17:08:22 christos Exp $"); +__RCSID("$NetBSD: fstat.c,v 1.114 2020/08/26 23:08:29 christos Exp $"); #endif #endif /* not lint */ @@ -181,6 +181,7 @@ static void vtrans(struct file *, struct static void ftrans(fdfile_t *, int); static void ptrans(struct file *, struct pipe *, int); static void kdriver_init(void); +static void check_privs(void); int main(int argc, char **argv) @@ -244,6 +245,8 @@ main(int argc, char **argv) usage(); } + check_privs(); + kdriver_init(); if (*(argv += optind)) { @@ -309,6 +312,23 @@ main(int argc, char **argv) return 0; } +static void +check_privs(void) +{ + int expaddr; + size_t expsize = sizeof(expaddr); + const char *expname = "kern.expose_address"; + + if (geteuid() == 0) + return; + + if (sysctlbyname(expname, , , NULL, 0) == -1) + err(EXIT_FAILURE, "Can't get sysctl `%s'", expname); + if (expaddr == 0) + errx(EXIT_FAILURE, "This program does not work without " + "sysctl `%s' being set", expname); +} + static const char *Uname, *Comm; pid_t Pid;
CVS commit: src/usr.bin/fstat
Module Name:src Committed By: christos Date: Wed Aug 26 23:08:29 UTC 2020 Modified Files: src/usr.bin/fstat: fstat.c Log Message: Provide a helpful error message if we don't have privs to read kernel addresses. To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/usr.bin/fstat/fstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Wed Aug 26 23:00:47 UTC 2020 Modified Files: src/usr.bin/make: Makefile hash.c lst.h make.h Removed Files: src/usr.bin/make: sprite.h Log Message: make(1): remove header sprite.h Make is independent of the Sprite operating system. To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/usr.bin/make/Makefile cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/hash.c cvs rdiff -u -r1.44 -r1.45 src/usr.bin/make/lst.h cvs rdiff -u -r1.126 -r1.127 src/usr.bin/make/make.h cvs rdiff -u -r1.14 -r0 src/usr.bin/make/sprite.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Wed Aug 26 23:00:47 UTC 2020 Modified Files: src/usr.bin/make: Makefile hash.c lst.h make.h Removed Files: src/usr.bin/make: sprite.h Log Message: make(1): remove header sprite.h Make is independent of the Sprite operating system. To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/usr.bin/make/Makefile cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/hash.c cvs rdiff -u -r1.44 -r1.45 src/usr.bin/make/lst.h cvs rdiff -u -r1.126 -r1.127 src/usr.bin/make/make.h cvs rdiff -u -r1.14 -r0 src/usr.bin/make/sprite.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/Makefile diff -u src/usr.bin/make/Makefile:1.93 src/usr.bin/make/Makefile:1.94 --- src/usr.bin/make/Makefile:1.93 Tue Aug 25 16:39:19 2020 +++ src/usr.bin/make/Makefile Wed Aug 26 23:00:47 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.93 2020/08/25 16:39:19 rillig Exp $ +# $NetBSD: Makefile,v 1.94 2020/08/26 23:00:47 rillig Exp $ # @(#)Makefile 5.2 (Berkeley) 12/28/90 PROG= make @@ -37,7 +37,6 @@ HDRS+= meta.h HDRS+= metachar.h HDRS+= nonints.h HDRS+= pathnames.h -HDRS+= sprite.h HDRS+= strlist.h HDRS+= trace.h Index: src/usr.bin/make/hash.c diff -u src/usr.bin/make/hash.c:1.26 src/usr.bin/make/hash.c:1.27 --- src/usr.bin/make/hash.c:1.26 Sat Aug 1 14:47:49 2020 +++ src/usr.bin/make/hash.c Wed Aug 26 23:00:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.26 2020/08/01 14:47:49 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.27 2020/08/26 23:00:47 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: hash.c,v 1.26 2020/08/01 14:47:49 rillig Exp $"; +static char rcsid[] = "$NetBSD: hash.c,v 1.27 2020/08/26 23:00:47 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)hash.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: hash.c,v 1.26 2020/08/01 14:47:49 rillig Exp $"); +__RCSID("$NetBSD: hash.c,v 1.27 2020/08/26 23:00:47 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -89,9 +89,7 @@ __RCSID("$NetBSD: hash.c,v 1.26 2020/08/ * table. Hash tables grow automatically as the amount of * information increases. */ -#include "sprite.h" #include "make.h" -#include "hash.h" /* * Forward references to local procedures that are used before they're Index: src/usr.bin/make/lst.h diff -u src/usr.bin/make/lst.h:1.44 src/usr.bin/make/lst.h:1.45 --- src/usr.bin/make/lst.h:1.44 Wed Aug 26 22:55:46 2020 +++ src/usr.bin/make/lst.h Wed Aug 26 23:00:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lst.h,v 1.44 2020/08/26 22:55:46 rillig Exp $ */ +/* $NetBSD: lst.h,v 1.45 2020/08/26 23:00:47 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -83,8 +83,6 @@ #include #include -#include "sprite.h" - /* * basic typedef. This is what the Lst_ functions handle */ Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.126 src/usr.bin/make/make.h:1.127 --- src/usr.bin/make/make.h:1.126 Mon Aug 24 20:15:51 2020 +++ src/usr.bin/make/make.h Wed Aug 26 23:00:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.126 2020/08/24 20:15:51 rillig Exp $ */ +/* $NetBSD: make.h,v 1.127 2020/08/26 23:00:47 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -128,7 +128,37 @@ #define MAKE_ATTR_PRINTFLIKE(fmtarg, firstvararg) /* delete */ #endif -#include "sprite.h" +/* + * A boolean type is defined as an integer, not an enum. This allows a + * boolean argument to be an expression that isn't strictly 0 or 1 valued. + */ + +typedef int Boolean; +#ifndef TRUE +#define TRUE 1 +#endif /* TRUE */ +#ifndef FALSE +#define FALSE 0 +#endif /* FALSE */ + +/* + * Functions that must return a status can return a ReturnStatus to + * indicate success or type of failure. + */ + +typedef int ReturnStatus; + +/* + * The following statuses overlap with the first 2 generic statuses + * defined in status.h: + * + * SUCCESS There was no error. + * FAILURE There was a general error. + */ + +#define SUCCESS 0x +#define FAILURE 0x0001 + #include "lst.h" #include "hash.h" #include "config.h"
CVS commit: src/usr.bin/sockstat
Module Name:src Committed By: christos Date: Wed Aug 26 22:57:56 UTC 2020 Modified Files: src/usr.bin/sockstat: Makefile sockstat.c Log Message: undo previous, now sockstat works without privs To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/sockstat/Makefile cvs rdiff -u -r1.22 -r1.23 src/usr.bin/sockstat/sockstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/sockstat
Module Name:src Committed By: christos Date: Wed Aug 26 22:57:56 UTC 2020 Modified Files: src/usr.bin/sockstat: Makefile sockstat.c Log Message: undo previous, now sockstat works without privs To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/sockstat/Makefile cvs rdiff -u -r1.22 -r1.23 src/usr.bin/sockstat/sockstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/sockstat/Makefile diff -u src/usr.bin/sockstat/Makefile:1.6 src/usr.bin/sockstat/Makefile:1.7 --- src/usr.bin/sockstat/Makefile:1.6 Tue Aug 25 12:39:16 2020 +++ src/usr.bin/sockstat/Makefile Wed Aug 26 18:57:55 2020 @@ -1,11 +1,8 @@ -# $NetBSD: Makefile,v 1.6 2020/08/25 16:39:16 christos Exp $ +# $NetBSD: Makefile,v 1.7 2020/08/26 22:57:55 christos Exp $ .include RUMPPRG= sockstat -BINGRP= kmem -BINMODE=2555 -USE_FORT?= yes # setgid .PATH: ${.CURDIR}/../../lib/libc/gen CPPFLAGS+= -DRUMP_ACTION Index: src/usr.bin/sockstat/sockstat.c diff -u src/usr.bin/sockstat/sockstat.c:1.22 src/usr.bin/sockstat/sockstat.c:1.23 --- src/usr.bin/sockstat/sockstat.c:1.22 Tue Aug 25 10:05:17 2020 +++ src/usr.bin/sockstat/sockstat.c Wed Aug 26 18:57:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sockstat.c,v 1.22 2020/08/25 14:05:17 christos Exp $ */ +/* $NetBSD: sockstat.c,v 1.23 2020/08/26 22:57:55 christos Exp $ */ /* * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include #ifndef lint -__RCSID("$NetBSD: sockstat.c,v 1.22 2020/08/25 14:05:17 christos Exp $"); +__RCSID("$NetBSD: sockstat.c,v 1.23 2020/08/26 22:57:55 christos Exp $"); #endif #define _KMEMUSER @@ -179,11 +179,6 @@ main(int argc, char *argv[]) if (prog_init && prog_init() == -1) err(1, "init"); - /* Not used, but we set the PK_KMEM flag like this */ - int fd = open("/dev/mem", O_RDONLY); - if (fd == -1) - err(EXIT_FAILURE, "Can't open `/dev/mem'"); - close(fd); if ((portmap != NULL) && (pf_list == 0)) { pf_list = PF_LIST_INET; #ifdef INET6
CVS commit: src/sys
Module Name:src Committed By: christos Date: Wed Aug 26 22:56:55 UTC 2020 Modified Files: src/sys/crypto/blake2: files.blake2s src/sys/kern: init_main.c kern_descrip.c kern_proc.c src/sys/sys: systm.h Log Message: Instead of returning 0 when sysctl kern.expose_address=0, return a random hashed value of the data. This allows sockstat to work without exposing kernel addresses or being setgid kmem. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/blake2/files.blake2s cvs rdiff -u -r1.527 -r1.528 src/sys/kern/init_main.c cvs rdiff -u -r1.246 -r1.247 src/sys/kern/kern_descrip.c cvs rdiff -u -r1.255 -r1.256 src/sys/kern/kern_proc.c cvs rdiff -u -r1.295 -r1.296 src/sys/sys/systm.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/crypto/blake2/files.blake2s diff -u src/sys/crypto/blake2/files.blake2s:1.1 src/sys/crypto/blake2/files.blake2s:1.2 --- src/sys/crypto/blake2/files.blake2s:1.1 Thu Aug 20 17:21:05 2020 +++ src/sys/crypto/blake2/files.blake2s Wed Aug 26 18:56:55 2020 @@ -1,5 +1,5 @@ -# $NetBSD: files.blake2s,v 1.1 2020/08/20 21:21:05 riastradh Exp $ +# $NetBSD: files.blake2s,v 1.2 2020/08/26 22:56:55 christos Exp $ define blake2s -file crypto/blake2/blake2s.c blake2s +file crypto/blake2/blake2s.c Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.527 src/sys/kern/init_main.c:1.528 --- src/sys/kern/init_main.c:1.527 Thu Jun 11 15:20:46 2020 +++ src/sys/kern/init_main.c Wed Aug 26 18:56:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.527 2020/06/11 19:20:46 ad Exp $ */ +/* $NetBSD: init_main.c,v 1.528 2020/08/26 22:56:55 christos Exp $ */ /*- * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.527 2020/06/11 19:20:46 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.528 2020/08/26 22:56:55 christos Exp $"); #include "opt_ddb.h" #include "opt_inet.h" @@ -228,6 +228,8 @@ extern void *_binary_splash_image_end; #include +#include + #include extern struct lwp lwp0; @@ -730,6 +732,24 @@ main(void) /* NOTREACHED */ } +static uint8_t address_key[32]; /* key used in address hashing */ +static ONCE_DECL(random_inithook); + +static int +random_address_init(void) +{ + cprng_strong(kern_cprng, address_key, sizeof(address_key), 0); + return 0; +} + +void +hash_value(void *d, size_t ds, const void *s, size_t ss) +{ + + RUN_ONCE(_inithook, random_address_init); + blake2s(d, ds, address_key, sizeof(address_key), s, ss); +} + /* * Configure the system's hardware. */ Index: src/sys/kern/kern_descrip.c diff -u src/sys/kern/kern_descrip.c:1.246 src/sys/kern/kern_descrip.c:1.247 --- src/sys/kern/kern_descrip.c:1.246 Sat May 23 19:42:43 2020 +++ src/sys/kern/kern_descrip.c Wed Aug 26 18:56:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_descrip.c,v 1.246 2020/05/23 23:42:43 ad Exp $ */ +/* $NetBSD: kern_descrip.c,v 1.247 2020/08/26 22:56:55 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.246 2020/05/23 23:42:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.247 2020/08/26 22:56:55 christos Exp $"); #include #include @@ -2305,11 +2305,11 @@ fill_file(struct file *fp, const struct memset(fp, 0, sizeof(*fp)); fp->f_offset = fpsrc->f_offset; - COND_SET_VALUE(fp->f_cred, fpsrc->f_cred, allowaddr); - COND_SET_VALUE(fp->f_ops, fpsrc->f_ops, allowaddr); - COND_SET_VALUE(fp->f_undata, fpsrc->f_undata, allowaddr); - COND_SET_VALUE(fp->f_list, fpsrc->f_list, allowaddr); - COND_SET_VALUE(fp->f_lock, fpsrc->f_lock, allowaddr); + COND_SET_PTR(fp->f_cred, fpsrc->f_cred, allowaddr); + COND_SET_CPTR(fp->f_ops, fpsrc->f_ops, allowaddr); + COND_SET_STRUCT(fp->f_undata, fpsrc->f_undata, allowaddr); + COND_SET_STRUCT(fp->f_list, fpsrc->f_list, allowaddr); + COND_SET_STRUCT(fp->f_lock, fpsrc->f_lock, allowaddr); fp->f_flag = fpsrc->f_flag; fp->f_marker = fpsrc->f_marker; fp->f_type = fpsrc->f_type; @@ -2317,7 +2317,7 @@ fill_file(struct file *fp, const struct fp->f_count = fpsrc->f_count; fp->f_msgcount = fpsrc->f_msgcount; fp->f_unpcount = fpsrc->f_unpcount; - COND_SET_VALUE(fp->f_unplist, fpsrc->f_unplist, allowaddr); + COND_SET_STRUCT(fp->f_unplist, fpsrc->f_unplist, allowaddr); } static void Index: src/sys/kern/kern_proc.c diff -u src/sys/kern/kern_proc.c:1.255 src/sys/kern/kern_proc.c:1.256 --- src/sys/kern/kern_proc.c:1.255 Thu Jun 11 15:20:46 2020 +++ src/sys/kern/kern_proc.c Wed Aug 26 18:56:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_proc.c,v 1.255 2020/06/11 19:20:46 ad Exp $ */ +/* $NetBSD: kern_proc.c,v 1.256 2020/08/26 22:56:55 christos Exp $ */ /*- * Copyright (c) 1999, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. @@ -62,7 +62,7 @@ */ #include
CVS commit: src/sys
Module Name:src Committed By: christos Date: Wed Aug 26 22:56:55 UTC 2020 Modified Files: src/sys/crypto/blake2: files.blake2s src/sys/kern: init_main.c kern_descrip.c kern_proc.c src/sys/sys: systm.h Log Message: Instead of returning 0 when sysctl kern.expose_address=0, return a random hashed value of the data. This allows sockstat to work without exposing kernel addresses or being setgid kmem. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/blake2/files.blake2s cvs rdiff -u -r1.527 -r1.528 src/sys/kern/init_main.c cvs rdiff -u -r1.246 -r1.247 src/sys/kern/kern_descrip.c cvs rdiff -u -r1.255 -r1.256 src/sys/kern/kern_proc.c cvs rdiff -u -r1.295 -r1.296 src/sys/sys/systm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Wed Aug 26 22:55:46 UTC 2020 Modified Files: src/usr.bin/make: arch.c dir.c lst.c lst.h main.c make.c meta.c parse.c suff.c targ.c Log Message: make(1): add stricter variants for remaining Lst functions In most cases the Lst functions are only called when the arguments are indeed valid. It's not guaranteed though, therefore each function call needs to be analyzed and converted individually. While here, remove a few statements that were only useful when the Lst functions handled circular lists. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/usr.bin/make/arch.c cvs rdiff -u -r1.110 -r1.111 src/usr.bin/make/dir.c cvs rdiff -u -r1.41 -r1.42 src/usr.bin/make/lst.c cvs rdiff -u -r1.43 -r1.44 src/usr.bin/make/lst.h cvs rdiff -u -r1.313 -r1.314 src/usr.bin/make/main.c cvs rdiff -u -r1.123 -r1.124 src/usr.bin/make/make.c cvs rdiff -u -r1.99 -r1.100 src/usr.bin/make/meta.c cvs rdiff -u -r1.262 -r1.263 src/usr.bin/make/parse.c cvs rdiff -u -r1.115 -r1.116 src/usr.bin/make/suff.c cvs rdiff -u -r1.72 -r1.73 src/usr.bin/make/targ.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Wed Aug 26 22:55:46 UTC 2020 Modified Files: src/usr.bin/make: arch.c dir.c lst.c lst.h main.c make.c meta.c parse.c suff.c targ.c Log Message: make(1): add stricter variants for remaining Lst functions In most cases the Lst functions are only called when the arguments are indeed valid. It's not guaranteed though, therefore each function call needs to be analyzed and converted individually. While here, remove a few statements that were only useful when the Lst functions handled circular lists. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/usr.bin/make/arch.c cvs rdiff -u -r1.110 -r1.111 src/usr.bin/make/dir.c cvs rdiff -u -r1.41 -r1.42 src/usr.bin/make/lst.c cvs rdiff -u -r1.43 -r1.44 src/usr.bin/make/lst.h cvs rdiff -u -r1.313 -r1.314 src/usr.bin/make/main.c cvs rdiff -u -r1.123 -r1.124 src/usr.bin/make/make.c cvs rdiff -u -r1.99 -r1.100 src/usr.bin/make/meta.c cvs rdiff -u -r1.262 -r1.263 src/usr.bin/make/parse.c cvs rdiff -u -r1.115 -r1.116 src/usr.bin/make/suff.c cvs rdiff -u -r1.72 -r1.73 src/usr.bin/make/targ.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.96 src/usr.bin/make/arch.c:1.97 --- src/usr.bin/make/arch.c:1.96 Sun Aug 23 18:59:01 2020 +++ src/usr.bin/make/arch.c Wed Aug 26 22:55:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.96 2020/08/23 18:59:01 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.97 2020/08/26 22:55:46 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.96 2020/08/23 18:59:01 rillig Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.97 2020/08/26 22:55:46 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: arch.c,v 1.96 2020/08/23 18:59:01 rillig Exp $"); +__RCSID("$NetBSD: arch.c,v 1.97 2020/08/26 22:55:46 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -391,7 +391,7 @@ Arch_ParseArchive(char **linePtr, Lst no */ free(buf); } else if (Dir_HasWildcards(memName)) { - Lst members = Lst_Init(); + Lst members = Lst_Init(); Buffer nameBuf; Buf_Init(, 0); @@ -422,7 +422,7 @@ Arch_ParseArchive(char **linePtr, Lst no Lst_AppendS(nodeLst, gn); } } - Lst_Destroy(members, NULL); + Lst_FreeS(members); Buf_Destroy(, TRUE); } else { Buffer nameBuf; @@ -1288,45 +1288,19 @@ Arch_LibOODate(GNode *gn) return oodate; } -/*- - *--- - * Arch_Init -- - * Initialize things for this module. - * - * Results: - * None. - * - * Side Effects: - * The 'archives' list is initialized. - * - *--- - */ +/* Initialize things for this module. */ void Arch_Init(void) { archives = Lst_Init(); } - - -/*- - *--- - * Arch_End -- - * Cleanup things for this module. - * - * Results: - * None. - * - * Side Effects: - * The 'archives' list is freed - * - *--- - */ +/* Clean up things for this module. */ void Arch_End(void) { #ifdef CLEANUP -Lst_Destroy(archives, ArchFree); +Lst_DestroyS(archives, ArchFree); #endif } Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.110 src/usr.bin/make/dir.c:1.111 --- src/usr.bin/make/dir.c:1.110 Sun Aug 23 16:58:02 2020 +++ src/usr.bin/make/dir.c Wed Aug 26 22:55:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.110 2020/08/23 16:58:02 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.111 2020/08/26 22:55:46 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: dir.c,v 1.110 2020/08/23 16:58:02 rillig Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.111 2020/08/26 22:55:46 rillig Exp $"; #else #include #ifndef lint #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: dir.c,v 1.110 2020/08/23 16:58:02 rillig Exp $"); +__RCSID("$NetBSD: dir.c,v 1.111 2020/08/26 22:55:46 rillig Exp $"); #endif #endif /* not lint */ #endif @@ -461,9 +461,9 @@ Dir_End(void) Dir_Destroy(dotLast); Dir_Destroy(dot); Dir_ClearPath(dirSearchPath); -Lst_Destroy(dirSearchPath, NULL); +Lst_FreeS(dirSearchPath); Dir_ClearPath(openDirectories); -Lst_Destroy(openDirectories, NULL); +Lst_FreeS(openDirectories); Hash_DeleteTable(); #endif } @@ -895,7 +895,7 @@ Dir_Expand(const char *word, Lst path, L path = Lst_Init(); (void)Dir_AddDir(path, dirpath); DirExpandInt(cp + 1,
CVS commit: src/sys/kern
Module Name:src Committed By: christos Date: Wed Aug 26 22:54:31 UTC 2020 Modified Files: src/sys/kern: uipc_socket.c uipc_socket2.c uipc_usrreq.c Log Message: add socket info for user and group for unix sockets in fstat. To generate a diff of this commit: cvs rdiff -u -r1.290 -r1.291 src/sys/kern/uipc_socket.c cvs rdiff -u -r1.137 -r1.138 src/sys/kern/uipc_socket2.c cvs rdiff -u -r1.198 -r1.199 src/sys/kern/uipc_usrreq.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/kern/uipc_socket.c diff -u src/sys/kern/uipc_socket.c:1.290 src/sys/kern/uipc_socket.c:1.291 --- src/sys/kern/uipc_socket.c:1.290 Sun Jun 7 11:19:05 2020 +++ src/sys/kern/uipc_socket.c Wed Aug 26 18:54:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket.c,v 1.290 2020/06/07 15:19:05 maxv Exp $ */ +/* $NetBSD: uipc_socket.c,v 1.291 2020/08/26 22:54:30 christos Exp $ */ /* * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.290 2020/06/07 15:19:05 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.291 2020/08/26 22:54:30 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -526,6 +526,7 @@ socreate(int dom, struct socket **aso, i #endif uid = kauth_cred_geteuid(l->l_cred); so->so_uidinfo = uid_find(uid); + so->so_egid = kauth_cred_getegid(l->l_cred); so->so_cpid = l->l_proc->p_pid; /* Index: src/sys/kern/uipc_socket2.c diff -u src/sys/kern/uipc_socket2.c:1.137 src/sys/kern/uipc_socket2.c:1.138 --- src/sys/kern/uipc_socket2.c:1.137 Sat May 23 19:42:43 2020 +++ src/sys/kern/uipc_socket2.c Wed Aug 26 18:54:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_socket2.c,v 1.137 2020/05/23 23:42:43 ad Exp $ */ +/* $NetBSD: uipc_socket2.c,v 1.138 2020/08/26 22:54:30 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.137 2020/05/23 23:42:43 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_socket2.c,v 1.138 2020/08/26 22:54:30 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -317,6 +317,7 @@ sonewconn(struct socket *head, bool sore so->so_send = head->so_send; so->so_receive = head->so_receive; so->so_uidinfo = head->so_uidinfo; + so->so_egid = head->so_egid; so->so_cpid = head->so_cpid; /* Index: src/sys/kern/uipc_usrreq.c diff -u src/sys/kern/uipc_usrreq.c:1.198 src/sys/kern/uipc_usrreq.c:1.199 --- src/sys/kern/uipc_usrreq.c:1.198 Tue Apr 21 17:42:47 2020 +++ src/sys/kern/uipc_usrreq.c Wed Aug 26 18:54:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: uipc_usrreq.c,v 1.198 2020/04/21 21:42:47 ad Exp $ */ +/* $NetBSD: uipc_usrreq.c,v 1.199 2020/08/26 22:54:30 christos Exp $ */ /*- * Copyright (c) 1998, 2000, 2004, 2008, 2009, 2020 The NetBSD Foundation, Inc. @@ -96,7 +96,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.198 2020/04/21 21:42:47 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.199 2020/08/26 22:54:30 christos Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -898,6 +898,8 @@ unp_stat(struct socket *so, struct stat unp->unp_ino = unp_ino++; ub->st_atimespec = ub->st_mtimespec = ub->st_ctimespec = unp->unp_ctime; ub->st_ino = unp->unp_ino; + ub->st_uid = so->so_uidinfo->ui_uid; + ub->st_gid = so->so_egid; return (0); }
CVS commit: src/sys/kern
Module Name:src Committed By: christos Date: Wed Aug 26 22:54:31 UTC 2020 Modified Files: src/sys/kern: uipc_socket.c uipc_socket2.c uipc_usrreq.c Log Message: add socket info for user and group for unix sockets in fstat. To generate a diff of this commit: cvs rdiff -u -r1.290 -r1.291 src/sys/kern/uipc_socket.c cvs rdiff -u -r1.137 -r1.138 src/sys/kern/uipc_socket2.c cvs rdiff -u -r1.198 -r1.199 src/sys/kern/uipc_usrreq.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/net/net
Module Name:src Committed By: christos Date: Wed Aug 26 22:52:58 UTC 2020 Modified Files: src/tests/net/net: t_unix.c Log Message: Check that fstat returns the correct socket owner To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/tests/net/net/t_unix.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/net/net/t_unix.c diff -u src/tests/net/net/t_unix.c:1.19 src/tests/net/net/t_unix.c:1.20 --- src/tests/net/net/t_unix.c:1.19 Mon Jul 6 12:24:06 2020 +++ src/tests/net/net/t_unix.c Wed Aug 26 18:52:58 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: t_unix.c,v 1.19 2020/07/06 16:24:06 christos Exp $ */ +/* $NetBSD: t_unix.c,v 1.20 2020/08/26 22:52:58 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #ifdef __RCSID -__RCSID("$Id: t_unix.c,v 1.19 2020/07/06 16:24:06 christos Exp $"); +__RCSID("$Id: t_unix.c,v 1.20 2020/08/26 22:52:58 christos Exp $"); #else #define getprogname() argv[0] #endif @@ -52,6 +52,7 @@ __RCSID("$Id: t_unix.c,v 1.19 2020/07/06 #include #include #include +#include #include #include #include @@ -146,13 +147,40 @@ peercred(int s, uid_t *euid, gid_t *egid } static int -test(bool forkit, bool closeit, size_t len) +check_cred(int fd, bool statit, pid_t checkpid, const char *s) +{ + pid_t pid; + uid_t euid; + gid_t egid; + + if (statit) { + struct stat st; + if (fstat(fd, ) == -1) + FAIL("fstat (%s)", s); + euid = st.st_uid; + egid = st.st_gid; + pid = checkpid; + } else { + if (peercred(fd, , , ) == -1) + FAIL("peercred (%s)", s); + } + printf("%s(%s) euid=%jd egid=%jd pid=%jd\n", + statit ? "fstat" : "peercred", s, + (intmax_t)euid, (intmax_t)egid, (intmax_t)pid); + CHECK_EQUAL(euid, geteuid(), s); + CHECK_EQUAL(egid, getegid(), s); + CHECK_EQUAL(pid, checkpid, s); + return 0; +fail: + return -1; +} + +static int +test(bool forkit, bool closeit, bool statit, size_t len) { size_t slen; socklen_t sl; int srvr = -1, clnt = -1, acpt = -1; - uid_t euid; - gid_t egid; pid_t srvrpid, clntpid; struct sockaddr_un *sock_addr = NULL, *sun = NULL; socklen_t sock_addrlen; @@ -204,26 +232,18 @@ test(bool forkit, bool closeit, size_t l } if (clntpid == getpid()) { - pid_t pid = srvrpid; clnt = socket(AF_UNIX, SOCK_STREAM, 0); if (clnt == -1) FAIL("socket(client)"); if (connect(clnt, (const struct sockaddr *)sun, sl) == -1) FAIL("connect"); + check_cred(clnt, statit, srvrpid, "client"); - if (peercred(clnt, , , ) == -1) - FAIL("peercred (client)"); - printf("peercred(client) euid=%jd egid=%jd pid=%jd\n", - (intmax_t)euid, (intmax_t)egid, (intmax_t)pid); - CHECK_EQUAL(euid, geteuid(), "client"); - CHECK_EQUAL(egid, getegid(), "client"); - CHECK_EQUAL(pid, srvrpid, "client"); } if (srvrpid == getpid()) { acpt = acc(srvr); - peer_addrlen = sizeof(peer_addr); memset(_addr, 0, sizeof(peer_addr)); if (getpeername(acpt, (struct sockaddr *)_addr, @@ -241,15 +261,7 @@ test(bool forkit, bool closeit, size_t l } if (srvrpid == getpid()) { - pid_t pid = clntpid; - if (peercred(acpt, , , ) == -1) - FAIL("peercred (server)"); - printf("peercred(server) euid=%jd egid=%jd pid=%jd\n", - (intmax_t)euid, (intmax_t)egid, (intmax_t)pid); - CHECK_EQUAL(euid, geteuid(), "server"); - CHECK_EQUAL(egid, getegid(), "server"); - CHECK_EQUAL(pid, clntpid, "server"); - + check_cred(acpt, statit, clntpid, "server"); if ((sock_addr = calloc(1, slen)) == NULL) FAIL("calloc"); sock_addrlen = slen; @@ -322,8 +334,8 @@ ATF_TC_HEAD(sockaddr_un_len_exceed, tc) ATF_TC_BODY(sockaddr_un_len_exceed, tc) { - ATF_REQUIRE_MSG(test(false, false, 254) == -1, - "test(false, false, 254): %s", strerror(errno)); + ATF_REQUIRE_MSG(test(false, false, false, 254) == -1, + "test(false, false, false, 254): %s", strerror(errno)); } ATF_TC(sockaddr_un_len_max); @@ -337,8 +349,8 @@ ATF_TC_HEAD(sockaddr_un_len_max, tc) ATF_TC_BODY(sockaddr_un_len_max, tc) { - ATF_REQUIRE_MSG(test(false, false, 253) == 0, - "test(false, false, 253): %s", strerror(errno)); + ATF_REQUIRE_MSG(test(false, false, false, 253) == 0, + "test(false, false, false, 253): %s", strerror(errno)); } ATF_TC(sockaddr_un_closed); @@ -351,8 +363,8 @@ ATF_TC_HEAD(sockaddr_un_closed, tc) ATF_TC_BODY(sockaddr_un_closed, tc) { - ATF_REQUIRE_MSG(test(false, true, 100) == 0, - "test(false, true, 100): %s", strerror(errno)); + ATF_REQUIRE_MSG(test(false, true, false, 100) == 0, + "test(false, true, false, 100): %s", strerror(errno)); } ATF_TC(sockaddr_un_local_peereid); @@ -365,8 +377,22 @@ ATF_TC_HEAD(sockaddr_un_local_peereid, t ATF_TC_BODY(sockaddr_un_local_peereid, tc) { - ATF_REQUIRE_MSG(test(true, true, 100) == 0, - "test(true, true, 100): %s", strerror(errno)); + ATF_REQUIRE_MSG(test(true, true, false, 100) == 0, + "test(true,
CVS commit: src/tests/net/net
Module Name:src Committed By: christos Date: Wed Aug 26 22:52:58 UTC 2020 Modified Files: src/tests/net/net: t_unix.c Log Message: Check that fstat returns the correct socket owner To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/tests/net/net/t_unix.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-9] src/sys/arch/sun3/sun3x
Module Name:src Committed By: martin Date: Wed Aug 26 18:06:54 UTC 2020 Modified Files: src/sys/arch/sun3/sun3x [netbsd-9]: pmap.c Log Message: Pull up following revision(s) (requested by tsutsui in ticket #1060): sys/arch/sun3/sun3x/pmap.c: revision 1.117 Make sure pmap_kenter_pa(9) handles uncached mappings properly. Fixes "cgfour(4) is mis-probed as bwtwo(4)" problem on 3/80 that has been broken since NetBSD 1.6. Now Xorg 1.20 based Xsun 8bpp color server is confirmed working on the cgfour(4). Should be pulled up to netbsd-9. XXX: all MD PMAP_NC flags should be replaced with MI PMAP_NOCACHE flag. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.114.20.1 src/sys/arch/sun3/sun3x/pmap.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/sun3/sun3x/pmap.c diff -u src/sys/arch/sun3/sun3x/pmap.c:1.114 src/sys/arch/sun3/sun3x/pmap.c:1.114.20.1 --- src/sys/arch/sun3/sun3x/pmap.c:1.114 Thu Dec 22 14:47:59 2016 +++ src/sys/arch/sun3/sun3x/pmap.c Wed Aug 26 18:06:54 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.114 2016/12/22 14:47:59 cherry Exp $ */ +/* $NetBSD: pmap.c,v 1.114.20.1 2020/08/26 18:06:54 martin Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -105,7 +105,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.114 2016/12/22 14:47:59 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.114.20.1 2020/08/26 18:06:54 martin Exp $"); #include "opt_ddb.h" #include "opt_pmap_debug.h" @@ -2145,6 +2145,12 @@ void pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot, u_int flags) { mmu_short_pte_t *pte; + u_int mapflags; + + /* XXX: MD PMAP_NC should be replaced by MI PMAP_NOCACHE in flags. */ + mapflags = (pa & ~MMU_PAGE_MASK); + if ((mapflags & PMAP_NC) != 0) + flags |= PMAP_NOCACHE; /* This array is traditionally named "Sysmap" */ pte = [(u_long)m68k_btop(va - KERNBASE3X)]; @@ -2153,6 +2159,8 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v pte->attr.raw = MMU_DT_INVALID | MMU_DT_PAGE | (pa & MMU_PAGE_MASK); if (!(prot & VM_PROT_WRITE)) pte->attr.raw |= MMU_SHORT_PTE_WP; + if ((flags & PMAP_NOCACHE) != 0) + pte->attr.raw |= MMU_SHORT_PTE_CI; } void
CVS commit: [netbsd-9] src/sys/arch/sun3/sun3x
Module Name:src Committed By: martin Date: Wed Aug 26 18:06:54 UTC 2020 Modified Files: src/sys/arch/sun3/sun3x [netbsd-9]: pmap.c Log Message: Pull up following revision(s) (requested by tsutsui in ticket #1060): sys/arch/sun3/sun3x/pmap.c: revision 1.117 Make sure pmap_kenter_pa(9) handles uncached mappings properly. Fixes "cgfour(4) is mis-probed as bwtwo(4)" problem on 3/80 that has been broken since NetBSD 1.6. Now Xorg 1.20 based Xsun 8bpp color server is confirmed working on the cgfour(4). Should be pulled up to netbsd-9. XXX: all MD PMAP_NC flags should be replaced with MI PMAP_NOCACHE flag. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.114.20.1 src/sys/arch/sun3/sun3x/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-9] src/sys/dev/nvmm/x86
Module Name:src Committed By: martin Date: Wed Aug 26 17:55:49 UTC 2020 Modified Files: src/sys/dev/nvmm/x86 [netbsd-9]: nvmm_x86.c nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1058): sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.70 sys/dev/nvmm/x86/nvmm_x86.h: revision 1.19 sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.69 sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.71 sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.69 sys/dev/nvmm/x86/nvmm_x86.c: revision 1.11 sys/dev/nvmm/x86/nvmm_x86.c: revision 1.12 sys/dev/nvmm/x86/nvmm_x86.c: revision 1.13 sys/dev/nvmm/x86/nvmm_x86.c: revision 1.14 Improve the CPUID emulation: - Hide SGX*, PKU, WAITPKG, and SKINIT, because they are not supported. - Hide HLE and RTM, part of TSX. Because TSX is just too buggy and we cannot guarantee that it remains enabled in the guest (if for example the host disables TSX while the guest is running). Nobody wants this crap anyway, so bye-bye. - Advertise FSREP_MOV, because no reason to hide it. Hide OSPKE. NFC since the host never uses PKU, but still. Improve the CPUID emulation on nvmm-intel: - Limit the highest extended leaf. - Limit 0x0007 to ECX=0, for future-proofness. nvmm-x86-svm: improve the CPUID emulation Limit the hypervisor range, and properly handle each basic leaf until 0xD. nvmm-x86: advertise the SERIALIZE instruction, available on future CPUs nvmm-x86: improve the CPUID emulation - x86-svm: explicitly handle 0x8007 and 0x8008. The latter contains extended features we must filter out. Apply the same in x86-vmx for symmetry. - x86-svm: explicitly handle extended leaves until 0x801F, and truncate to it. To generate a diff of this commit: cvs rdiff -u -r1.7.4.3 -r1.7.4.4 src/sys/dev/nvmm/x86/nvmm_x86.c cvs rdiff -u -r1.15.4.1 -r1.15.4.2 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.46.4.8 -r1.46.4.9 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.36.2.10 -r1.36.2.11 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: [netbsd-9] src/sys/dev/nvmm/x86
Module Name:src Committed By: martin Date: Wed Aug 26 17:55:49 UTC 2020 Modified Files: src/sys/dev/nvmm/x86 [netbsd-9]: nvmm_x86.c nvmm_x86.h nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: Pull up following revision(s) (requested by maxv in ticket #1058): sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.70 sys/dev/nvmm/x86/nvmm_x86.h: revision 1.19 sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.69 sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.71 sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.69 sys/dev/nvmm/x86/nvmm_x86.c: revision 1.11 sys/dev/nvmm/x86/nvmm_x86.c: revision 1.12 sys/dev/nvmm/x86/nvmm_x86.c: revision 1.13 sys/dev/nvmm/x86/nvmm_x86.c: revision 1.14 Improve the CPUID emulation: - Hide SGX*, PKU, WAITPKG, and SKINIT, because they are not supported. - Hide HLE and RTM, part of TSX. Because TSX is just too buggy and we cannot guarantee that it remains enabled in the guest (if for example the host disables TSX while the guest is running). Nobody wants this crap anyway, so bye-bye. - Advertise FSREP_MOV, because no reason to hide it. Hide OSPKE. NFC since the host never uses PKU, but still. Improve the CPUID emulation on nvmm-intel: - Limit the highest extended leaf. - Limit 0x0007 to ECX=0, for future-proofness. nvmm-x86-svm: improve the CPUID emulation Limit the hypervisor range, and properly handle each basic leaf until 0xD. nvmm-x86: advertise the SERIALIZE instruction, available on future CPUs nvmm-x86: improve the CPUID emulation - x86-svm: explicitly handle 0x8007 and 0x8008. The latter contains extended features we must filter out. Apply the same in x86-vmx for symmetry. - x86-svm: explicitly handle extended leaves until 0x801F, and truncate to it. To generate a diff of this commit: cvs rdiff -u -r1.7.4.3 -r1.7.4.4 src/sys/dev/nvmm/x86/nvmm_x86.c cvs rdiff -u -r1.15.4.1 -r1.15.4.2 src/sys/dev/nvmm/x86/nvmm_x86.h cvs rdiff -u -r1.46.4.8 -r1.46.4.9 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.36.2.10 -r1.36.2.11 src/sys/dev/nvmm/x86/nvmm_x86_vmx.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/dev/nvmm/x86/nvmm_x86.c diff -u src/sys/dev/nvmm/x86/nvmm_x86.c:1.7.4.3 src/sys/dev/nvmm/x86/nvmm_x86.c:1.7.4.4 --- src/sys/dev/nvmm/x86/nvmm_x86.c:1.7.4.3 Tue Aug 18 09:29:52 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86.c Wed Aug 26 17:55:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86.c,v 1.7.4.3 2020/08/18 09:29:52 martin Exp $ */ +/* $NetBSD: nvmm_x86.c,v 1.7.4.4 2020/08/26 17:55:49 martin Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.7.4.3 2020/08/18 09:29:52 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.7.4.4 2020/08/26 17:55:49 martin Exp $"); #include #include @@ -304,16 +304,16 @@ const struct nvmm_x86_cpuid_mask nvmm_cp .ebx = CPUID_SEF_FSGSBASE | /* CPUID_SEF_TSC_ADJUST excluded */ - CPUID_SEF_SGX | + /* CPUID_SEF_SGX excluded */ CPUID_SEF_BMI1 | - CPUID_SEF_HLE | + /* CPUID_SEF_HLE excluded */ /* CPUID_SEF_AVX2 excluded */ CPUID_SEF_FDPEXONLY | CPUID_SEF_SMEP | CPUID_SEF_BMI2 | CPUID_SEF_ERMS | /* CPUID_SEF_INVPCID excluded, but re-included in VMX */ - CPUID_SEF_RTM | + /* CPUID_SEF_RTM excluded */ /* CPUID_SEF_QM excluded */ CPUID_SEF_FPUCSDS | /* CPUID_SEF_MPX excluded */ @@ -337,9 +337,9 @@ const struct nvmm_x86_cpuid_mask nvmm_cp CPUID_SEF_PREFETCHWT1 | /* CPUID_SEF_AVX512_VBMI excluded */ CPUID_SEF_UMIP | - CPUID_SEF_PKU | - CPUID_SEF_OSPKE | - CPUID_SEF_WAITPKG | + /* CPUID_SEF_PKU excluded */ + /* CPUID_SEF_OSPKE excluded */ + /* CPUID_SEF_WAITPKG excluded */ /* CPUID_SEF_AVX512_VBMI2 excluded */ /* CPUID_SEF_CET_SS excluded */ CPUID_SEF_GFNI | @@ -352,18 +352,18 @@ const struct nvmm_x86_cpuid_mask nvmm_cp /* CPUID_SEF_RDPID excluded */ CPUID_SEF_CLDEMOTE | CPUID_SEF_MOVDIRI | - CPUID_SEF_MOVDIR64B | - CPUID_SEF_SGXLC, + CPUID_SEF_MOVDIR64B, + /* CPUID_SEF_SGXLC excluded */ /* CPUID_SEF_PKS excluded */ .edx = /* CPUID_SEF_AVX512_4VNNIW excluded */ /* CPUID_SEF_AVX512_4FMAPS excluded */ - /* CPUID_SEF_FSREP_MOV excluded */ + CPUID_SEF_FSREP_MOV | /* CPUID_SEF_AVX512_VP2INTERSECT excluded */ /* CPUID_SEF_SRBDS_CTRL excluded */ CPUID_SEF_MD_CLEAR | /* CPUID_SEF_TSX_FORCE_ABORT excluded */ - /* CPUID_SEF_SERIALIZE excluded */ + CPUID_SEF_SERIALIZE | /* CPUID_SEF_HYBRID excluded */ /* CPUID_SEF_TSXLDTRK excluded */ /* CPUID_SEF_CET_IBT excluded */ @@ -391,7 +391,7 @@ const struct nvmm_x86_cpuid_mask nvmm_cp /* CPUID_OSVW excluded */ CPUID_IBS |
CVS commit: src/sys/kern
Module Name:src Committed By: maxv Date: Wed Aug 26 16:36:32 UTC 2020 Modified Files: src/sys/kern: tty.c Log Message: Add a check to prevent shift by -1. Not really important in this case, but to appease KUBSAN. Reported-by: syzbot+4026e8201b6b484b8...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.288 -r1.289 src/sys/kern/tty.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/kern/tty.c diff -u src/sys/kern/tty.c:1.288 src/sys/kern/tty.c:1.289 --- src/sys/kern/tty.c:1.288 Mon Jun 22 16:29:24 2020 +++ src/sys/kern/tty.c Wed Aug 26 16:36:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tty.c,v 1.288 2020/06/22 16:29:24 maxv Exp $ */ +/* $NetBSD: tty.c,v 1.289 2020/08/26 16:36:32 maxv Exp $ */ /*- * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.288 2020/06/22 16:29:24 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.289 2020/08/26 16:36:32 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -226,6 +226,9 @@ int tty_qsize = TTY_MINQSIZE; static int tty_get_qsize(int *qsize, int newsize) { + if (newsize == 0) + return EINVAL; + newsize = 1 << ilog2(newsize); /* Make it a power of two */ if (newsize < TTY_MINQSIZE || newsize > TTY_MAXQSIZE)
CVS commit: src/sys/kern
Module Name:src Committed By: maxv Date: Wed Aug 26 16:36:32 UTC 2020 Modified Files: src/sys/kern: tty.c Log Message: Add a check to prevent shift by -1. Not really important in this case, but to appease KUBSAN. Reported-by: syzbot+4026e8201b6b484b8...@syzkaller.appspotmail.com To generate a diff of this commit: cvs rdiff -u -r1.288 -r1.289 src/sys/kern/tty.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Wed Aug 26 16:33:03 UTC 2020 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c Log Message: nvmm-x86-svm: improve the handling of MSR_EFER Intercept reads of it as well, just to mask EFER_SVME, which the guest doesn't need to see. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/dev/nvmm/x86/nvmm_x86_svm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Wed Aug 26 16:33:03 UTC 2020 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c Log Message: nvmm-x86-svm: improve the handling of MSR_EFER Intercept reads of it as well, just to mask EFER_SVME, which the guest doesn't need to see. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/dev/nvmm/x86/nvmm_x86_svm.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/dev/nvmm/x86/nvmm_x86_svm.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.73 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.74 --- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.73 Wed Aug 26 16:32:02 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c Wed Aug 26 16:33:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_svm.c,v 1.73 2020/08/26 16:32:02 maxv Exp $ */ +/* $NetBSD: nvmm_x86_svm.c,v 1.74 2020/08/26 16:33:03 maxv Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.73 2020/08/26 16:32:02 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.74 2020/08/26 16:33:03 maxv Exp $"); #include #include @@ -1170,6 +1170,12 @@ svm_inkernel_handle_msr(struct nvmm_mach size_t i; if (exit->reason == NVMM_VCPU_EXIT_RDMSR) { + if (exit->u.rdmsr.msr == MSR_EFER) { + val = vmcb->state.efer & ~EFER_SVME; + vmcb->state.rax = (val & 0x); + cpudata->gprs[NVMM_X64_GPR_RDX] = (val >> 32); + goto handled; + } if (exit->u.rdmsr.msr == MSR_NB_CFG) { val = NB_CFG_INITAPICCPUIDLO; vmcb->state.rax = (val & 0x); @@ -2195,7 +2201,6 @@ svm_vcpu_init(struct nvmm_machine *mach, /* Allow direct access to certain MSRs. */ memset(cpudata->msrbm, 0xFF, MSRBM_SIZE); - svm_vcpu_msr_allow(cpudata->msrbm, MSR_EFER, true, false); svm_vcpu_msr_allow(cpudata->msrbm, MSR_STAR, true, true); svm_vcpu_msr_allow(cpudata->msrbm, MSR_LSTAR, true, true); svm_vcpu_msr_allow(cpudata->msrbm, MSR_CSTAR, true, true);
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Wed Aug 26 16:32:03 UTC 2020 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: nvmm-x86: improve the handling of RFLAGS.RF - When injecting certain exceptions, set RF. For us to have an up-to-date view of RFLAGS, we commit the state before the event. - When advancing RIP, clear RF. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.73 -r1.74 src/sys/dev/nvmm/x86/nvmm_x86_vmx.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/dev/nvmm/x86/nvmm_x86_svm.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.72 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.73 --- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.72 Wed Aug 26 16:29:19 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c Wed Aug 26 16:32:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_svm.c,v 1.72 2020/08/26 16:29:19 maxv Exp $ */ +/* $NetBSD: nvmm_x86_svm.c,v 1.73 2020/08/26 16:32:02 maxv Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.72 2020/08/26 16:29:19 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.73 2020/08/26 16:32:02 maxv Exp $"); #include #include @@ -676,8 +676,22 @@ svm_event_waitexit_disable(struct nvmm_c svm_vmcb_cache_flush(vmcb, VMCB_CTRL_VMCB_CLEAN_I); } +static inline bool +svm_excp_has_rf(uint8_t vector) +{ + switch (vector) { + case 1: /* #DB */ + case 4: /* #OF */ + case 8: /* #DF */ + case 18: /* #MC */ + return false; + default: + return true; + } +} + static inline int -svm_event_has_error(uint8_t vector) +svm_excp_has_error(uint8_t vector) { switch (vector) { case 8: /* #DF */ @@ -717,7 +731,10 @@ svm_vcpu_inject(struct nvmm_cpu *vcpu) return EINVAL; if (vector == 3 || vector == 0) return EINVAL; - err = svm_event_has_error(vector); + if (svm_excp_has_rf(vector)) { + vmcb->state.rflags |= PSL_RF; + } + err = svm_excp_has_error(vector); break; case NVMM_VCPU_EVENT_INTR: type = SVM_EVENT_TYPE_HW_INT; @@ -790,6 +807,7 @@ svm_inkernel_advance(struct vmcb *vmcb) * debugger. */ vmcb->state.rip = vmcb->ctrl.nrip; + vmcb->state.rflags &= ~PSL_RF; vmcb->ctrl.intr &= ~VMCB_CTRL_INTR_SHADOW; } @@ -1473,11 +1491,12 @@ svm_vcpu_run(struct nvmm_machine *mach, uint64_t machgen; int hcpu; + svm_vcpu_state_commit(vcpu); + comm->state_cached = 0; + if (__predict_false(svm_vcpu_event_commit(vcpu) != 0)) { return EINVAL; } - svm_vcpu_state_commit(vcpu); - comm->state_cached = 0; kpreempt_disable(); hcpu = cpu_number(); Index: src/sys/dev/nvmm/x86/nvmm_x86_vmx.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.73 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.74 --- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.73 Wed Aug 26 16:30:50 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Wed Aug 26 16:32:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_vmx.c,v 1.73 2020/08/26 16:30:50 maxv Exp $ */ +/* $NetBSD: nvmm_x86_vmx.c,v 1.74 2020/08/26 16:32:02 maxv Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.73 2020/08/26 16:30:50 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.74 2020/08/26 16:32:02 maxv Exp $"); #include #include @@ -1038,8 +1038,22 @@ vmx_event_waitexit_disable(struct nvmm_c vmx_vmwrite(VMCS_PROCBASED_CTLS, ctls1); } +static inline bool +vmx_excp_has_rf(uint8_t vector) +{ + switch (vector) { + case 1: /* #DB */ + case 4: /* #OF */ + case 8: /* #DF */ + case 18: /* #MC */ + return false; + default: + return true; + } +} + static inline int -vmx_event_has_error(uint8_t vector) +vmx_excp_has_error(uint8_t vector) { switch (vector) { case 8: /* #DF */ @@ -1062,9 +1076,9 @@ vmx_vcpu_inject(struct nvmm_cpu *vcpu) struct nvmm_comm_page *comm = vcpu->comm; struct vmx_cpudata *cpudata = vcpu->cpudata; int type = 0, err = 0, ret = EINVAL; + uint64_t rflags, info, error; u_int evtype; uint8_t vector; - uint64_t info, error; evtype = comm->event.type; vector = comm->event.vector; @@ -1079,8 +1093,12 @@ vmx_vcpu_inject(struct nvmm_cpu *vcpu) goto out; if (vector == 3 || vector == 0) goto out; + if (vmx_excp_has_rf(vector)) { + rflags = vmx_vmread(VMCS_GUEST_RFLAGS); + vmx_vmwrite(VMCS_GUEST_RFLAGS, rflags | PSL_RF); + } type = INTR_TYPE_HW_EXC; - err = vmx_event_has_error(vector); + err = vmx_excp_has_error(vector); break; case NVMM_VCPU_EVENT_INTR: type = INTR_TYPE_EXT_INT; @@ -1151,16 +1169,21 @@ vmx_vcpu_event_commit(struct nvmm_cpu *v static inline void vmx_inkernel_advance(void) { - uint64_t rip, inslen, intstate; + uint64_t rip, inslen, intstate, rflags; /* * Maybe we should also apply single-stepping and debug exceptions. * Matters for
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Wed Aug 26 16:32:03 UTC 2020 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c nvmm_x86_vmx.c Log Message: nvmm-x86: improve the handling of RFLAGS.RF - When injecting certain exceptions, set RF. For us to have an up-to-date view of RFLAGS, we commit the state before the event. - When advancing RIP, clear RF. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/dev/nvmm/x86/nvmm_x86_svm.c cvs rdiff -u -r1.73 -r1.74 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Wed Aug 26 16:30:50 UTC 2020 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_vmx.c Log Message: nvmm-x86-vmx: improve the handling of CR4 - Filter out certain features we don't want the guest to enable. This is for general correctness, and future-proofness. - Flush the guest TLB when certain flags change. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/dev/nvmm/x86/nvmm_x86_vmx.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/dev/nvmm/x86/nvmm_x86_vmx.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.72 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.73 --- src/sys/dev/nvmm/x86/nvmm_x86_vmx.c:1.72 Sat Aug 22 11:01:10 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Wed Aug 26 16:30:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_vmx.c,v 1.72 2020/08/22 11:01:10 maxv Exp $ */ +/* $NetBSD: nvmm_x86_vmx.c,v 1.73 2020/08/26 16:30:50 maxv Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.72 2020/08/22 11:01:10 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.73 2020/08/26 16:30:50 maxv Exp $"); #include #include @@ -729,6 +729,33 @@ static uint64_t vmx_xcr0_mask __read_mos #define MSRBM_NPAGES 1 #define MSRBM_SIZE (MSRBM_NPAGES * PAGE_SIZE) +#define CR4_VALID \ + (CR4_VME | \ + CR4_PVI | \ + CR4_TSD | \ + CR4_DE | \ + CR4_PSE | \ + CR4_PAE | \ + CR4_MCE | \ + CR4_PGE | \ + CR4_PCE | \ + CR4_OSFXSR | \ + CR4_OSXMMEXCPT | \ + CR4_UMIP | \ + /* CR4_LA57 excluded */ \ + /* CR4_VMXE excluded */ \ + /* CR4_SMXE excluded */ \ + CR4_FSGSBASE | \ + CR4_PCIDE | \ + CR4_OSXSAVE | \ + CR4_SMEP | \ + CR4_SMAP \ + /* CR4_PKE excluded */ \ + /* CR4_CET excluded */ \ + /* CR4_PKS excluded */) +#define CR4_INVALID \ + (0xULL & ~CR4_VALID) + #define EFER_TLB_FLUSH \ (EFER_NXE|EFER_LMA|EFER_LME) #define CR0_TLB_FLUSH \ @@ -1589,12 +1616,18 @@ vmx_inkernel_handle_cr4(struct nvmm_mach gpr = cpudata->gprs[gpr]; } + if (gpr & CR4_INVALID) { + return -1; + } cr4 = gpr | CR4_VMXE; - if (vmx_check_cr(cr4, vmx_cr4_fixed0, vmx_cr4_fixed1) == -1) { return -1; } + if ((vmx_vmread(VMCS_GUEST_CR4) ^ cr4) & CR4_TLB_FLUSH) { + cpudata->gtlb_want_flush = true; + } + vmx_vmwrite(VMCS_GUEST_CR4, cr4); vmx_inkernel_advance(); return 0; @@ -2514,7 +2547,7 @@ vmx_vcpu_setstate(struct nvmm_cpu *vcpu) cpudata->gcr2 = state->crs[NVMM_X64_CR_CR2]; vmx_vmwrite(VMCS_GUEST_CR3, state->crs[NVMM_X64_CR_CR3]); // XXX PDPTE? vmx_vmwrite(VMCS_GUEST_CR4, - state->crs[NVMM_X64_CR_CR4] | CR4_VMXE); + (state->crs[NVMM_X64_CR_CR4] & CR4_VALID) | CR4_VMXE); cpudata->gcr8 = state->crs[NVMM_X64_CR_CR8]; if (vmx_xcr0_mask != 0) { @@ -2839,8 +2872,9 @@ vmx_vcpu_init(struct nvmm_machine *mach, vmx_vmwrite(VMCS_CR0_MASK, CR0_NW|CR0_CD|CR0_ET); vmx_vmwrite(VMCS_CR0_SHADOW, CR0_ET); - /* Force CR4_VMXE to zero. */ - vmx_vmwrite(VMCS_CR4_MASK, CR4_VMXE); + /* Force unsupported CR4 fields to zero. */ + vmx_vmwrite(VMCS_CR4_MASK, CR4_INVALID); + vmx_vmwrite(VMCS_CR4_SHADOW, 0); /* Set the Host state for resuming. */ vmx_vmwrite(VMCS_HOST_RIP, (uint64_t)_resume_rip);
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Wed Aug 26 16:30:50 UTC 2020 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_vmx.c Log Message: nvmm-x86-vmx: improve the handling of CR4 - Filter out certain features we don't want the guest to enable. This is for general correctness, and future-proofness. - Flush the guest TLB when certain flags change. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/dev/nvmm/x86/nvmm_x86_vmx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/nvmm
Module Name:src Committed By: maxv Date: Wed Aug 26 16:29:49 UTC 2020 Modified Files: src/sys/dev/nvmm: nvmm_ioctl.h Log Message: nvmm: slightly clarify To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/nvmm/nvmm_ioctl.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/dev/nvmm/nvmm_ioctl.h diff -u src/sys/dev/nvmm/nvmm_ioctl.h:1.9 src/sys/dev/nvmm/nvmm_ioctl.h:1.10 --- src/sys/dev/nvmm/nvmm_ioctl.h:1.9 Mon Oct 28 09:00:08 2019 +++ src/sys/dev/nvmm/nvmm_ioctl.h Wed Aug 26 16:29:49 2020 @@ -1,7 +1,7 @@ -/* $NetBSD: nvmm_ioctl.h,v 1.9 2019/10/28 09:00:08 maxv Exp $ */ +/* $NetBSD: nvmm_ioctl.h,v 1.10 2020/08/26 16:29:49 maxv Exp $ */ /* - * Copyright (c) 2018-2019 The NetBSD Foundation, Inc. + * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -121,7 +121,9 @@ struct nvmm_ioc_gpa_unmap { }; struct nvmm_ctl_mach_info { + /* input */ nvmm_machid_t machid; + /* output */ uint32_t nvcpus; uint64_t nram; pid_t pid; @@ -151,7 +153,6 @@ struct nvmm_ioc_ctl { #define NVMM_IOC_GPA_UNMAP _IOW ('N', 12, struct nvmm_ioc_gpa_unmap) #define NVMM_IOC_HVA_MAP _IOW ('N', 13, struct nvmm_ioc_hva_map) #define NVMM_IOC_HVA_UNMAP _IOW ('N', 14, struct nvmm_ioc_hva_unmap) - #define NVMM_IOC_CTL _IOW ('N', 20, struct nvmm_ioc_ctl) #endif /* _NVMM_IOCTL_H_ */
CVS commit: src/sys/dev/nvmm
Module Name:src Committed By: maxv Date: Wed Aug 26 16:29:49 UTC 2020 Modified Files: src/sys/dev/nvmm: nvmm_ioctl.h Log Message: nvmm: slightly clarify To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/dev/nvmm/nvmm_ioctl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Wed Aug 26 16:29:20 UTC 2020 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c Log Message: nvmm-x86-svm: don't forget to intercept INVD INVD executed in the guest can be dangerous for the host, due to CPU caches being flushed without write-back. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/dev/nvmm/x86/nvmm_x86_svm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/nvmm/x86
Module Name:src Committed By: maxv Date: Wed Aug 26 16:29:20 UTC 2020 Modified Files: src/sys/dev/nvmm/x86: nvmm_x86_svm.c Log Message: nvmm-x86-svm: don't forget to intercept INVD INVD executed in the guest can be dangerous for the host, due to CPU caches being flushed without write-back. To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/sys/dev/nvmm/x86/nvmm_x86_svm.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/dev/nvmm/x86/nvmm_x86_svm.c diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.71 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.72 --- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.71 Sat Aug 22 10:59:05 2020 +++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c Wed Aug 26 16:29:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm_x86_svm.c,v 1.71 2020/08/22 10:59:05 maxv Exp $ */ +/* $NetBSD: nvmm_x86_svm.c,v 1.72 2020/08/26 16:29:19 maxv Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.71 2020/08/22 10:59:05 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.72 2020/08/26 16:29:19 maxv Exp $"); #include #include @@ -2118,7 +2118,6 @@ svm_vcpu_init(struct nvmm_machine *mach, * - POPF [popf instruction] * - IRET [iret instruction] * - INTN [int $n instructions] - * - INVD [invd instruction] * - PAUSE [pause instruction] * - INVLPG [invplg instruction] * - TASKSW [task switches] @@ -2132,6 +2131,7 @@ svm_vcpu_init(struct nvmm_machine *mach, VMCB_CTRL_INTERCEPT_RDPMC | VMCB_CTRL_INTERCEPT_CPUID | VMCB_CTRL_INTERCEPT_RSM | + VMCB_CTRL_INTERCEPT_INVD | VMCB_CTRL_INTERCEPT_HLT | VMCB_CTRL_INTERCEPT_INVLPGA | VMCB_CTRL_INTERCEPT_IOIO_PROT |
CVS commit: src/sys/dev/nvmm
Module Name:src Committed By: maxv Date: Wed Aug 26 16:28:17 UTC 2020 Modified Files: src/sys/dev/nvmm: nvmm.c Log Message: nvmm: misc improvements - use mach->ncpus to get the number of vcpus, now that we have it - don't forget to decrement mach->ncpus when a machine gets killed - add more __predict_false() To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/dev/nvmm/nvmm.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/dev/nvmm/nvmm.c diff -u src/sys/dev/nvmm/nvmm.c:1.35 src/sys/dev/nvmm/nvmm.c:1.36 --- src/sys/dev/nvmm/nvmm.c:1.35 Tue Aug 18 17:04:37 2020 +++ src/sys/dev/nvmm/nvmm.c Wed Aug 26 16:28:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nvmm.c,v 1.35 2020/08/18 17:04:37 maxv Exp $ */ +/* $NetBSD: nvmm.c,v 1.36 2020/08/26 16:28:17 maxv Exp $ */ /* * Copyright (c) 2018-2020 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.35 2020/08/18 17:04:37 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.36 2020/08/26 16:28:17 maxv Exp $"); #include #include @@ -112,17 +112,17 @@ nvmm_machine_get(struct nvmm_owner *owne struct nvmm_machine *mach; krw_t op = writer ? RW_WRITER : RW_READER; - if (machid >= NVMM_MAX_MACHINES) { + if (__predict_false(machid >= NVMM_MAX_MACHINES)) { return EINVAL; } mach = [machid]; rw_enter(>lock, op); - if (!mach->present) { + if (__predict_false(!mach->present)) { rw_exit(>lock); return ENOENT; } - if (owner != _owner && mach->owner != owner) { + if (__predict_false(mach->owner != owner && owner != _owner)) { rw_exit(>lock); return EPERM; } @@ -179,13 +179,13 @@ nvmm_vcpu_get(struct nvmm_machine *mach, { struct nvmm_cpu *vcpu; - if (cpuid >= NVMM_MAX_VCPUS) { + if (__predict_false(cpuid >= NVMM_MAX_VCPUS)) { return EINVAL; } vcpu = >cpus[cpuid]; mutex_enter(>lock); - if (!vcpu->present) { + if (__predict_false(!vcpu->present)) { mutex_exit(>lock); return ENOENT; } @@ -227,6 +227,7 @@ nvmm_kill_machines(struct nvmm_owner *ow (*nvmm_impl->vcpu_destroy)(mach, vcpu); nvmm_vcpu_free(mach, vcpu); nvmm_vcpu_put(vcpu); + atomic_dec_uint(>ncpus); } (*nvmm_impl->machine_destroy)(mach); uvmspace_free(mach->vm); @@ -314,6 +315,7 @@ nvmm_machine_destroy(struct nvmm_owner * (*nvmm_impl->vcpu_destroy)(mach, vcpu); nvmm_vcpu_free(mach, vcpu); nvmm_vcpu_put(vcpu); + atomic_dec_uint(>ncpus); } (*nvmm_impl->machine_destroy)(mach); @@ -414,7 +416,6 @@ nvmm_vcpu_create(struct nvmm_owner *owne } nvmm_vcpu_put(vcpu); - atomic_inc_uint(>ncpus); out: @@ -440,7 +441,6 @@ nvmm_vcpu_destroy(struct nvmm_owner *own (*nvmm_impl->vcpu_destroy)(mach, vcpu); nvmm_vcpu_free(mach, vcpu); nvmm_vcpu_put(vcpu); - atomic_dec_uint(>ncpus); out: @@ -907,7 +907,6 @@ nvmm_ctl_mach_info(struct nvmm_owner *ow { struct nvmm_ctl_mach_info ctl; struct nvmm_machine *mach; - struct nvmm_cpu *vcpu; int error; size_t i; @@ -921,14 +920,7 @@ nvmm_ctl_mach_info(struct nvmm_owner *ow if (error) return error; - ctl.nvcpus = 0; - for (i = 0; i < NVMM_MAX_VCPUS; i++) { - error = nvmm_vcpu_get(mach, i, ); - if (error) - continue; - ctl.nvcpus++; - nvmm_vcpu_put(vcpu); - } + ctl.nvcpus = mach->ncpus; ctl.nram = 0; for (i = 0; i < NVMM_MAX_HMAPPINGS; i++) {
CVS commit: src/sys/dev/nvmm
Module Name:src Committed By: maxv Date: Wed Aug 26 16:28:17 UTC 2020 Modified Files: src/sys/dev/nvmm: nvmm.c Log Message: nvmm: misc improvements - use mach->ncpus to get the number of vcpus, now that we have it - don't forget to decrement mach->ncpus when a machine gets killed - add more __predict_false() To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/dev/nvmm/nvmm.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: Wed Aug 26 16:03:42 UTC 2020 Modified Files: src/distrib/sets/lists/base: shl.mi src/distrib/sets/lists/comp: mi shl.mi src/distrib/sets/lists/debug: mi shl.mi src/distrib/sets/lists/tests: mi src/doc: CHANGES src/etc/mtree: NetBSD.dist.tests src/share/man/man4: wg.4 src/sys/arch/amd64/conf: ALL src/sys/net: if_types.h if_wg.c src/sys/rump/net: Makefile.rumpnetcomp src/tests/net: Makefile src/usr.sbin/wg-keygen: wg-keygen.8 src/usr.sbin/wg-userspace: wg-userspace.8 wg-userspace.sh src/usr.sbin/wgconfig: wgconfig.8 Added Files: src/sys/rump/net/lib/libwg: Makefile WG.ioconf wg_component.c wg_user.c wg_user.h src/tests/net/if_wg: Makefile common.sh t_basic.sh t_interoperability.sh t_misc.sh t_tunnel.sh Removed Files: src/sys/rump/net/lib/libwireguard: Makefile WG.ioconf wg_component.c wg_user.c wg_user.h src/tests/net/wireguard: Makefile common.sh t_basic.sh t_interoperability.sh t_misc.sh t_tunnel.sh Log Message: Clarify wg(4)'s relation to WireGuard, pending further discussion. Still planning to replace wgconfig(8) and wg-keygen(8) by one wg(8) tool compatible with wireguard-tools; update wg(4) for the minor changes from the 2018-06-30 spec to the 2020-06-01 spec; This just clarifies the current state of affairs as it exists in the development tree for now. Mark the man page EXPERIMENTAL for extra clarity. To generate a diff of this commit: cvs rdiff -u -r1.896 -r1.897 src/distrib/sets/lists/base/shl.mi cvs rdiff -u -r1.2344 -r1.2345 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.337 -r1.338 src/distrib/sets/lists/comp/shl.mi cvs rdiff -u -r1.329 -r1.330 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.258 -r1.259 src/distrib/sets/lists/debug/shl.mi cvs rdiff -u -r1.906 -r1.907 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.2732 -r1.2733 src/doc/CHANGES cvs rdiff -u -r1.175 -r1.176 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/wg.4 cvs rdiff -u -r1.161 -r1.162 src/sys/arch/amd64/conf/ALL cvs rdiff -u -r1.30 -r1.31 src/sys/net/if_types.h cvs rdiff -u -r1.23 -r1.24 src/sys/net/if_wg.c cvs rdiff -u -r1.21 -r1.22 src/sys/rump/net/Makefile.rumpnetcomp cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libwg/Makefile \ src/sys/rump/net/lib/libwg/WG.ioconf \ src/sys/rump/net/lib/libwg/wg_component.c \ src/sys/rump/net/lib/libwg/wg_user.c src/sys/rump/net/lib/libwg/wg_user.h cvs rdiff -u -r1.1 -r0 src/sys/rump/net/lib/libwireguard/Makefile \ src/sys/rump/net/lib/libwireguard/WG.ioconf \ src/sys/rump/net/lib/libwireguard/wg_component.c \ src/sys/rump/net/lib/libwireguard/wg_user.c \ src/sys/rump/net/lib/libwireguard/wg_user.h cvs rdiff -u -r1.35 -r1.36 src/tests/net/Makefile cvs rdiff -u -r0 -r1.1 src/tests/net/if_wg/Makefile \ src/tests/net/if_wg/common.sh src/tests/net/if_wg/t_basic.sh \ src/tests/net/if_wg/t_interoperability.sh src/tests/net/if_wg/t_misc.sh \ src/tests/net/if_wg/t_tunnel.sh cvs rdiff -u -r1.1 -r0 src/tests/net/wireguard/Makefile \ src/tests/net/wireguard/common.sh src/tests/net/wireguard/t_basic.sh \ src/tests/net/wireguard/t_interoperability.sh \ src/tests/net/wireguard/t_misc.sh src/tests/net/wireguard/t_tunnel.sh cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/wg-keygen/wg-keygen.8 cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/wg-userspace/wg-userspace.8 cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wg-userspace/wg-userspace.sh cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/wgconfig/wgconfig.8 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: Wed Aug 26 16:03:42 UTC 2020 Modified Files: src/distrib/sets/lists/base: shl.mi src/distrib/sets/lists/comp: mi shl.mi src/distrib/sets/lists/debug: mi shl.mi src/distrib/sets/lists/tests: mi src/doc: CHANGES src/etc/mtree: NetBSD.dist.tests src/share/man/man4: wg.4 src/sys/arch/amd64/conf: ALL src/sys/net: if_types.h if_wg.c src/sys/rump/net: Makefile.rumpnetcomp src/tests/net: Makefile src/usr.sbin/wg-keygen: wg-keygen.8 src/usr.sbin/wg-userspace: wg-userspace.8 wg-userspace.sh src/usr.sbin/wgconfig: wgconfig.8 Added Files: src/sys/rump/net/lib/libwg: Makefile WG.ioconf wg_component.c wg_user.c wg_user.h src/tests/net/if_wg: Makefile common.sh t_basic.sh t_interoperability.sh t_misc.sh t_tunnel.sh Removed Files: src/sys/rump/net/lib/libwireguard: Makefile WG.ioconf wg_component.c wg_user.c wg_user.h src/tests/net/wireguard: Makefile common.sh t_basic.sh t_interoperability.sh t_misc.sh t_tunnel.sh Log Message: Clarify wg(4)'s relation to WireGuard, pending further discussion. Still planning to replace wgconfig(8) and wg-keygen(8) by one wg(8) tool compatible with wireguard-tools; update wg(4) for the minor changes from the 2018-06-30 spec to the 2020-06-01 spec; This just clarifies the current state of affairs as it exists in the development tree for now. Mark the man page EXPERIMENTAL for extra clarity. To generate a diff of this commit: cvs rdiff -u -r1.896 -r1.897 src/distrib/sets/lists/base/shl.mi cvs rdiff -u -r1.2344 -r1.2345 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.337 -r1.338 src/distrib/sets/lists/comp/shl.mi cvs rdiff -u -r1.329 -r1.330 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.258 -r1.259 src/distrib/sets/lists/debug/shl.mi cvs rdiff -u -r1.906 -r1.907 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.2732 -r1.2733 src/doc/CHANGES cvs rdiff -u -r1.175 -r1.176 src/etc/mtree/NetBSD.dist.tests cvs rdiff -u -r1.4 -r1.5 src/share/man/man4/wg.4 cvs rdiff -u -r1.161 -r1.162 src/sys/arch/amd64/conf/ALL cvs rdiff -u -r1.30 -r1.31 src/sys/net/if_types.h cvs rdiff -u -r1.23 -r1.24 src/sys/net/if_wg.c cvs rdiff -u -r1.21 -r1.22 src/sys/rump/net/Makefile.rumpnetcomp cvs rdiff -u -r0 -r1.1 src/sys/rump/net/lib/libwg/Makefile \ src/sys/rump/net/lib/libwg/WG.ioconf \ src/sys/rump/net/lib/libwg/wg_component.c \ src/sys/rump/net/lib/libwg/wg_user.c src/sys/rump/net/lib/libwg/wg_user.h cvs rdiff -u -r1.1 -r0 src/sys/rump/net/lib/libwireguard/Makefile \ src/sys/rump/net/lib/libwireguard/WG.ioconf \ src/sys/rump/net/lib/libwireguard/wg_component.c \ src/sys/rump/net/lib/libwireguard/wg_user.c \ src/sys/rump/net/lib/libwireguard/wg_user.h cvs rdiff -u -r1.35 -r1.36 src/tests/net/Makefile cvs rdiff -u -r0 -r1.1 src/tests/net/if_wg/Makefile \ src/tests/net/if_wg/common.sh src/tests/net/if_wg/t_basic.sh \ src/tests/net/if_wg/t_interoperability.sh src/tests/net/if_wg/t_misc.sh \ src/tests/net/if_wg/t_tunnel.sh cvs rdiff -u -r1.1 -r0 src/tests/net/wireguard/Makefile \ src/tests/net/wireguard/common.sh src/tests/net/wireguard/t_basic.sh \ src/tests/net/wireguard/t_interoperability.sh \ src/tests/net/wireguard/t_misc.sh src/tests/net/wireguard/t_tunnel.sh cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/wg-keygen/wg-keygen.8 cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/wg-userspace/wg-userspace.8 cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wg-userspace/wg-userspace.sh cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/wgconfig/wgconfig.8 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/base/shl.mi diff -u src/distrib/sets/lists/base/shl.mi:1.896 src/distrib/sets/lists/base/shl.mi:1.897 --- src/distrib/sets/lists/base/shl.mi:1.896 Thu Aug 20 21:28:00 2020 +++ src/distrib/sets/lists/base/shl.mi Wed Aug 26 16:03:40 2020 @@ -1,4 +1,4 @@ -# $NetBSD: shl.mi,v 1.896 2020/08/20 21:28:00 riastradh Exp $ +# $NetBSD: shl.mi,v 1.897 2020/08/26 16:03:40 riastradh Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -832,9 +832,12 @@ ./usr/lib/librumpnet_vlan.so base-rump-shlib rump ./usr/lib/librumpnet_vlan.so.0 base-rump-shlib rump ./usr/lib/librumpnet_vlan.so.0.0 base-rump-shlib rump -./usr/lib/librumpnet_wireguard.so base-rump-shlib rump -./usr/lib/librumpnet_wireguard.so.0 base-rump-shlib rump -./usr/lib/librumpnet_wireguard.so.0.0 base-rump-shlib rump +./usr/lib/librumpnet_wg.so base-rump-shlib rump +./usr/lib/librumpnet_wg.so.0 base-rump-shlib rump +./usr/lib/librumpnet_wg.so.0.0 base-rump-shlib rump +./usr/lib/librumpnet_wireguard.so base-obsolete obsolete +./usr/lib/librumpnet_wireguard.so.0 base-obsolete obsolete
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: riastradh Date: Wed Aug 26 15:54:11 UTC 2020 Modified Files: src/sys/arch/xen/xen: if_xennet_xenbus.c Log Message: Nix trailing whitespace and mixed space/tab indentation. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/arch/xen/xen/if_xennet_xenbus.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/xen/xen/if_xennet_xenbus.c diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.127 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.128 --- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.127 Wed Jun 24 14:33:08 2020 +++ src/sys/arch/xen/xen/if_xennet_xenbus.c Wed Aug 26 15:54:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_xennet_xenbus.c,v 1.127 2020/06/24 14:33:08 jdolecek Exp $ */ +/* $NetBSD: if_xennet_xenbus.c,v 1.128 2020/08/26 15:54:10 riastradh Exp $ */ /* * Copyright (c) 2006 Manuel Bouyer. @@ -81,7 +81,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.127 2020/06/24 14:33:08 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.128 2020/08/26 15:54:10 riastradh Exp $"); #include "opt_xen.h" #include "opt_nfs_boot.h" @@ -177,7 +177,7 @@ struct xennet_xenbus_softc { unsigned int sc_evtchn; struct intrhand *sc_ih; - + grant_ref_t sc_tx_ring_gntref; grant_ref_t sc_rx_ring_gntref; @@ -320,7 +320,7 @@ xennet_xenbus_attach(device_t parent, de SLIST_INIT(>sc_txreq_head); for (i = 0; i < NET_TX_RING_SIZE; i++) { struct xennet_txreq *txreq = >sc_txreqs[i]; - + txreq->txreq_id = i; if (bus_dmamap_create(sc->sc_xbusd->xbusd_dmat, maxsz, nsegs, PAGE_SIZE, PAGE_SIZE, BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW, @@ -387,7 +387,7 @@ xennet_xenbus_attach(device_t parent, de | IFCAP_CSUM_TCPv4_Rx | IFCAP_CSUM_TCPv4_Tx | IFCAP_CSUM_UDPv6_Rx | IFCAP_CSUM_TCPv6_Rx; -#define XN_M_CSUM_SUPPORTED \ +#define XN_M_CSUM_SUPPORTED \ (M_CSUM_TCPv4 | M_CSUM_UDPv4 | M_CSUM_TCPv6 | M_CSUM_UDPv6) if (sc->sc_features & FEATURE_IPV6CSUM) { @@ -781,7 +781,7 @@ xennet_alloc_rx_buffer(struct xennet_xen printf("%s: rx no mbuf\n", ifp->if_xname); break; } - + va = (vaddr_t)pool_cache_get_paddr( if_xennetrxbuf_cache, PR_NOWAIT, ); if (__predict_false(va == 0)) { @@ -790,11 +790,11 @@ xennet_alloc_rx_buffer(struct xennet_xen break; } - MEXTADD(m, va, PAGE_SIZE, - M_DEVBUF, xennet_rx_mbuf_free, NULL); + MEXTADD(m, va, PAGE_SIZE, + M_DEVBUF, xennet_rx_mbuf_free, NULL); m->m_len = m->m_pkthdr.len = PAGE_SIZE; - m->m_ext.ext_paddr = pa; - m->m_flags |= M_EXT_RW; /* we own the buffer */ + m->m_ext.ext_paddr = pa; + m->m_flags |= M_EXT_RW; /* we own the buffer */ /* Set M_EXT_CLUSTER so that load_mbuf uses m_ext.ext_paddr */ m->m_flags |= M_EXT_CLUSTER; @@ -1232,10 +1232,10 @@ xennet_start(struct ifnet *ifp) #ifdef XENNET_DEBUG_DUMP xennet_hex_dump(mtod(m, u_char *), m->m_pkthdr.len, "s", - req->txreq_id); + req->txreq_id); #endif - if (!xennet_submit_tx_request(sc, m, req, _prod)) { + if (!xennet_submit_tx_request(sc, m, req, _prod)) { /* Grant failed, postpone */ sc->sc_cnt_tx_drop.ev_count++; bus_dmamap_unload(sc->sc_xbusd->xbusd_dmat,
CVS commit: src/sys/arch/xen/xen
Module Name:src Committed By: riastradh Date: Wed Aug 26 15:54:11 UTC 2020 Modified Files: src/sys/arch/xen/xen: if_xennet_xenbus.c Log Message: Nix trailing whitespace and mixed space/tab indentation. To generate a diff of this commit: cvs rdiff -u -r1.127 -r1.128 src/sys/arch/xen/xen/if_xennet_xenbus.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: Wed Aug 26 15:49:56 UTC 2020 Modified Files: src/sys/external/isc/libsodium/conf: files.libsodium src/sys/rump/kern/lib/libcrypto: Makefile Log Message: Tidy up libsodium makefile and config fragments. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/external/isc/libsodium/conf/files.libsodium cvs rdiff -u -r1.19 -r1.20 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
Module Name:src Committed By: riastradh Date: Wed Aug 26 15:49:56 UTC 2020 Modified Files: src/sys/external/isc/libsodium/conf: files.libsodium src/sys/rump/kern/lib/libcrypto: Makefile Log Message: Tidy up libsodium makefile and config fragments. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/external/isc/libsodium/conf/files.libsodium cvs rdiff -u -r1.19 -r1.20 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.4 src/sys/external/isc/libsodium/conf/files.libsodium:1.5 --- src/sys/external/isc/libsodium/conf/files.libsodium:1.4 Fri Aug 21 06:37:30 2020 +++ src/sys/external/isc/libsodium/conf/files.libsodium Wed Aug 26 15:49:56 2020 @@ -1,28 +1,15 @@ -# $NetBSD: files.libsodium,v 1.4 2020/08/21 06:37:30 riastradh Exp $ +# $NetBSD: files.libsodium,v 1.5 2020/08/26 15:49:56 riastradh Exp $ define libsodium -makeoptions libsodium SODIUM_CPPFLAGS+="-I$S/external/isc/libsodium/include" -makeoptions libsodium SODIUM_CPPFLAGS+="-I$S/external/isc/libsodium/dist/src/libsodium/include/sodium" +makeoptions libsodium "CPPFLAGS.libsodium"+="-I$S/external/isc/libsodium/include" +makeoptions libsodium "CPPFLAGS.libsodium"+="-I$S/external/isc/libsodium/dist/src/libsodium/include/sodium" -#makeoptions libsodium SODIUM_CPPFLAGS+="-DHAVE_TI_MODE" +#makeoptions libsodium "CPPFLAGS.libsodium"+="-DHAVE_TI_MODE" -makeoptions libsodium SODIUM_CPPFLAGS+="-Wno-shadow" -makeoptions libsodium SODIUM_CPPFLAGS+="-Wno-unused-function" -makeoptions libsodium SODIUM_CPPFLAGS+="-Wno-unused-variable" - -makeoptions libsodium "CPPFLAGS.x25519_ref10.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.scalarmult_curve25519.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.crypto_scalarmult.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.poly1305_donna.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.onetimeauth_poly1305.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.crypto_onetimeauth.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.chacha20_ref.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.stream_chacha20.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.aead_xchacha20poly1305.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.aead_chacha20poly1305.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.core_hchacha20.c"+="${SODIUM_CPPFLAGS}" -makeoptions libsodium "CPPFLAGS.ed25519_ref10.c"+="${SODIUM_CPPFLAGS}" +makeoptions libsodium "CWARNFLAGS.libsodium"+="-Wno-shadow" +makeoptions libsodium "CWARNFLAGS.libsodium"+="-Wno-unused-function" +makeoptions libsodium "CWARNFLAGS.libsodium"+="-Wno-unused-variable" file external/isc/libsodium/src/glue.c libsodium Index: src/sys/rump/kern/lib/libcrypto/Makefile diff -u src/sys/rump/kern/lib/libcrypto/Makefile:1.19 src/sys/rump/kern/lib/libcrypto/Makefile:1.20 --- src/sys/rump/kern/lib/libcrypto/Makefile:1.19 Fri Aug 21 06:37:30 2020 +++ src/sys/rump/kern/lib/libcrypto/Makefile Wed Aug 26 15:49:56 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.19 2020/08/21 06:37:30 riastradh Exp $ +# $NetBSD: Makefile,v 1.20 2020/08/26 15:49:56 riastradh Exp $ # SODIUM_IMPORTDIR=${.CURDIR}/../../../../external/isc/libsodium @@ -60,35 +60,35 @@ SRCS+= skipjack.c # BLAKE2 SRCS+= blake2s.c -# Various cryptography functions -SODIUM_CPPFLAGS= +# libsodium SODIUM_CPPFLAGS+= -I${SODIUM_IMPORTDIR}/include SODIUM_CPPFLAGS+= -I${SODIUM_IMPORTDIR}/dist/src/libsodium/include/sodium #SODIUM_CPPFLAGS+= -DHAVE_TI_MODE -SODIUM_CPPFLAGS+= -Wno-shadow -SODIUM_CPPFLAGS+= -Wno-unused-function -SODIUM_CPPFLAGS+= -Wno-unused-variable - -CPPFLAGS.x25519_ref10.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.scalarmult_curve25519.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.crypto_scalarmult.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.poly1305_donna.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.onetimeauth_poly1305.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.crypto_onetimeauth.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.chacha20_ref.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.stream_chacha20.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.aead_xchacha20poly1305.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.aead_chacha20poly1305.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.core_hchacha20.c+= ${SODIUM_CPPFLAGS} -CPPFLAGS.ed25519_ref10.c+= ${SODIUM_CPPFLAGS} - -SRCS+= x25519_ref10.c scalarmult_curve25519.c crypto_scalarmult.c -SRCS+= poly1305_donna.c onetimeauth_poly1305.c -SRCS+= crypto_onetimeauth.c chacha20_ref.c stream_chacha20.c -SRCS+= aead_xchacha20poly1305.c aead_chacha20poly1305.c -SRCS+= core_hchacha20.c ed25519_ref10.c +SODIUM_CWARNFLAGS+= -Wno-shadow +SODIUM_CWARNFLAGS+= -Wno-unused-function +SODIUM_CWARNFLAGS+= -Wno-unused-variable + +SODIUM_SRCS+= x25519_ref10.c +SODIUM_SRCS+= scalarmult_curve25519.c +SODIUM_SRCS+= crypto_scalarmult.c
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Wed Aug 26 15:49:07 UTC 2020 Modified Files: src/usr.sbin/wgconfig: Makefile Log Message: wgconfig does not need libcrypt. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wgconfig/Makefile 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/wgconfig/Makefile diff -u src/usr.sbin/wgconfig/Makefile:1.1 src/usr.sbin/wgconfig/Makefile:1.2 --- src/usr.sbin/wgconfig/Makefile:1.1 Thu Aug 20 21:28:02 2020 +++ src/usr.sbin/wgconfig/Makefile Wed Aug 26 15:49:07 2020 @@ -1,9 +1,9 @@ -# $NetBSD: Makefile,v 1.1 2020/08/20 21:28:02 riastradh Exp $ +# $NetBSD: Makefile,v 1.2 2020/08/26 15:49:07 riastradh Exp $ PROG= wgconfig MAN= wgconfig.8 -DPADD+= ${LIBPROP} ${LIBCRYPT} ${LIBUTIL} -LDADD+= -lprop -lcrypt -lutil +DPADD+= ${LIBPROP} ${LIBUTIL} +LDADD+= -lprop -lutil .include
CVS commit: src/usr.sbin/wgconfig
Module Name:src Committed By: riastradh Date: Wed Aug 26 15:49:07 UTC 2020 Modified Files: src/usr.sbin/wgconfig: Makefile Log Message: wgconfig does not need libcrypt. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/wgconfig/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/nfsd
Module Name:src Committed By: gson Date: Wed Aug 26 13:35:12 UTC 2020 Modified Files: src/usr.sbin/nfsd: nfsd.c Log Message: Fix indentation To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/usr.sbin/nfsd/nfsd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/nfsd
Module Name:src Committed By: gson Date: Wed Aug 26 13:35:12 UTC 2020 Modified Files: src/usr.sbin/nfsd: nfsd.c Log Message: Fix indentation To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/usr.sbin/nfsd/nfsd.c 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/nfsd/nfsd.c diff -u src/usr.sbin/nfsd/nfsd.c:1.71 src/usr.sbin/nfsd/nfsd.c:1.72 --- src/usr.sbin/nfsd/nfsd.c:1.71 Wed Aug 26 13:33:42 2020 +++ src/usr.sbin/nfsd/nfsd.c Wed Aug 26 13:35:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nfsd.c,v 1.71 2020/08/26 13:33:42 gson Exp $ */ +/* $NetBSD: nfsd.c,v 1.72 2020/08/26 13:35:12 gson Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19 #if 0 static char sccsid[] = "@(#)nfsd.c 8.9 (Berkeley) 3/29/95"; #else -__RCSID("$NetBSD: nfsd.c,v 1.71 2020/08/26 13:33:42 gson Exp $"); +__RCSID("$NetBSD: nfsd.c,v 1.72 2020/08/26 13:35:12 gson Exp $"); #endif #endif /* not lint */ @@ -329,7 +329,7 @@ daemon2_fork(void) /* child */ (void)close(detach_msg_pipe[0]); (void)write(detach_msg_pipe[1], "", 1); - return detach_msg_pipe[1]; + return detach_msg_pipe[1]; default: break; }
CVS commit: src/usr.sbin/nfsd
Module Name:src Committed By: gson Date: Wed Aug 26 13:33:42 UTC 2020 Modified Files: src/usr.sbin/nfsd: nfsd.c Log Message: Remove trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/usr.sbin/nfsd/nfsd.c 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/nfsd/nfsd.c diff -u src/usr.sbin/nfsd/nfsd.c:1.70 src/usr.sbin/nfsd/nfsd.c:1.71 --- src/usr.sbin/nfsd/nfsd.c:1.70 Wed Aug 26 13:32:56 2020 +++ src/usr.sbin/nfsd/nfsd.c Wed Aug 26 13:33:42 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nfsd.c,v 1.70 2020/08/26 13:32:56 gson Exp $ */ +/* $NetBSD: nfsd.c,v 1.71 2020/08/26 13:33:42 gson Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19 #if 0 static char sccsid[] = "@(#)nfsd.c 8.9 (Berkeley) 3/29/95"; #else -__RCSID("$NetBSD: nfsd.c,v 1.70 2020/08/26 13:32:56 gson Exp $"); +__RCSID("$NetBSD: nfsd.c,v 1.71 2020/08/26 13:33:42 gson Exp $"); #endif #endif /* not lint */ @@ -284,7 +284,7 @@ out: * is called to complete the daemonization and signal the parent * process to exit. * - * These functions could potentially be moved to a library and + * These functions could potentially be moved to a library and * shared by other daemons. * * The return value from daemon2_fork() is a file descriptor to
CVS commit: src/usr.sbin/nfsd
Module Name:src Committed By: gson Date: Wed Aug 26 13:33:42 UTC 2020 Modified Files: src/usr.sbin/nfsd: nfsd.c Log Message: Remove trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/usr.sbin/nfsd/nfsd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/nfsd
Module Name:src Committed By: gson Date: Wed Aug 26 13:32:57 UTC 2020 Modified Files: src/usr.sbin/nfsd: nfsd.c Log Message: Remove superfluous empty line To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/usr.sbin/nfsd/nfsd.c 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/nfsd/nfsd.c diff -u src/usr.sbin/nfsd/nfsd.c:1.69 src/usr.sbin/nfsd/nfsd.c:1.70 --- src/usr.sbin/nfsd/nfsd.c:1.69 Wed Jun 17 00:16:22 2020 +++ src/usr.sbin/nfsd/nfsd.c Wed Aug 26 13:32:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nfsd.c,v 1.69 2020/06/17 00:16:22 kamil Exp $ */ +/* $NetBSD: nfsd.c,v 1.70 2020/08/26 13:32:56 gson Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19 #if 0 static char sccsid[] = "@(#)nfsd.c 8.9 (Berkeley) 3/29/95"; #else -__RCSID("$NetBSD: nfsd.c,v 1.69 2020/06/17 00:16:22 kamil Exp $"); +__RCSID("$NetBSD: nfsd.c,v 1.70 2020/08/26 13:32:56 gson Exp $"); #endif #endif /* not lint */ @@ -548,7 +548,6 @@ main(int argc, char *argv[]) setupsock([i], [i], i); if (set[i].fd != -1) connect_type_cnt++; - } pthread_setname_np(pthread_self(), "master", NULL);
CVS commit: src/usr.sbin/nfsd
Module Name:src Committed By: gson Date: Wed Aug 26 13:32:57 UTC 2020 Modified Files: src/usr.sbin/nfsd: nfsd.c Log Message: Remove superfluous empty line To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/usr.sbin/nfsd/nfsd.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/vax/vsa
Module Name:src Committed By: isaki Date: Wed Aug 26 12:59:28 UTC 2020 Modified Files: src/sys/arch/vax/vsa: vsaudio.c Log Message: Fix misuse of device_private(). sc_dev is device_t. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/vax/vsa/vsaudio.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/vax/vsa
Module Name:src Committed By: isaki Date: Wed Aug 26 12:59:28 UTC 2020 Modified Files: src/sys/arch/vax/vsa: vsaudio.c Log Message: Fix misuse of device_private(). sc_dev is device_t. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/vax/vsa/vsaudio.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/vax/vsa/vsaudio.c diff -u src/sys/arch/vax/vsa/vsaudio.c:1.5 src/sys/arch/vax/vsa/vsaudio.c:1.6 --- src/sys/arch/vax/vsa/vsaudio.c:1.5 Wed May 8 13:40:16 2019 +++ src/sys/arch/vax/vsa/vsaudio.c Wed Aug 26 12:59:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: vsaudio.c,v 1.5 2019/05/08 13:40:16 isaki Exp $ */ +/* $NetBSD: vsaudio.c,v 1.6 2020/08/26 12:59:28 isaki Exp $ */ /* $OpenBSD: vsaudio.c,v 1.4 2013/05/15 21:21:11 ratchov Exp $ */ /* @@ -271,7 +271,7 @@ vsaudio_attach(device_t parent, device_t return; } sc->sc_bt = va->va_memt; - sc->sc_am7930.sc_dev = device_private(self); + sc->sc_am7930.sc_dev = self; sc->sc_am7930.sc_glue = _glue; mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_HIGH); am7930_init(>sc_am7930, AUDIOAMD_POLL_MODE);
CVS commit: src/usr.bin/systat
Module Name:src Committed By: simonb Date: Wed Aug 26 10:56:01 UTC 2020 Modified Files: src/usr.bin/systat: ps.c Log Message: Use the vm.uspace sysctl instead of using the USPACE kernel define. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/usr.bin/systat/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/systat/ps.c diff -u src/usr.bin/systat/ps.c:1.38 src/usr.bin/systat/ps.c:1.39 --- src/usr.bin/systat/ps.c:1.38 Sun Feb 3 10:48:47 2019 +++ src/usr.bin/systat/ps.c Wed Aug 26 10:56:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.38 2019/02/03 10:48:47 mrg Exp $ */ +/* $NetBSD: ps.c,v 1.39 2020/08/26 10:56:01 simonb Exp $ */ /*- * Copyright (c) 1999 @@ -45,7 +45,7 @@ #include #ifndef lint -__RCSID("$NetBSD: ps.c,v 1.38 2019/02/03 10:48:47 mrg Exp $"); +__RCSID("$NetBSD: ps.c,v 1.39 2020/08/26 10:56:01 simonb Exp $"); #endif /* not lint */ #include @@ -297,14 +297,30 @@ double pmem2float(struct kinfo_proc2 *kp) { double fracmem; - int szptudot = 0; + static int szptudot = -1; + + /* + * XXX want pmap ptpages, segtab, etc. (per architecture), + * not just the uarea. + */ + if (szptudot < 0) { + int mib[2]; + size_t size; + int uspace; + + mib[0] = CTL_VM; + mib[1] = VM_USPACE; + size = sizeof(uspace); + if (sysctl(mib, 2, , , NULL, 0) == 0) { + szptudot = uspace / getpagesize(); + } else { + /* pick a vaguely useful default */ + szptudot = getpagesize(); + } + } -#ifdef USPACE - /* XXX want pmap ptpages, segtab, etc. (per architecture) */ - szptudot = USPACE/getpagesize(); -#endif /* XXX don't have info about shared */ - fracmem = ((double)kp->p_vm_rssize + szptudot)/mempages; + fracmem = ((double)kp->p_vm_rssize + szptudot) / mempages; return (fracmem >= 0) ? 100.0 * fracmem : 0; }
CVS commit: src/usr.bin/systat
Module Name:src Committed By: simonb Date: Wed Aug 26 10:56:01 UTC 2020 Modified Files: src/usr.bin/systat: ps.c Log Message: Use the vm.uspace sysctl instead of using the USPACE kernel define. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/usr.bin/systat/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/ps
Module Name:src Committed By: simonb Date: Wed Aug 26 10:54:13 UTC 2020 Modified Files: src/bin/ps: nlist.c Log Message: Don't rely on the USPACE kernel define as a fallback if the vm.uspace sysctl fails. We've got bigger problems if the sysctl fail anyway. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/bin/ps/nlist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/ps
Module Name:src Committed By: simonb Date: Wed Aug 26 10:54:13 UTC 2020 Modified Files: src/bin/ps: nlist.c Log Message: Don't rely on the USPACE kernel define as a fallback if the vm.uspace sysctl fails. We've got bigger problems if the sysctl fail anyway. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/bin/ps/nlist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/nlist.c diff -u src/bin/ps/nlist.c:1.27 src/bin/ps/nlist.c:1.28 --- src/bin/ps/nlist.c:1.27 Mon Nov 28 08:19:23 2016 +++ src/bin/ps/nlist.c Wed Aug 26 10:54:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nlist.c,v 1.27 2016/11/28 08:19:23 rin Exp $ */ +/* $NetBSD: nlist.c,v 1.28 2020/08/26 10:54:12 simonb Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)nlist.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: nlist.c,v 1.27 2016/11/28 08:19:23 rin Exp $"); +__RCSID("$NetBSD: nlist.c,v 1.28 2020/08/26 10:54:12 simonb Exp $"); #endif #endif /* not lint */ @@ -113,9 +113,7 @@ int uspace;/* kernel USPACE value */ #ifndef MAXSLP #define MAXSLP 20 #endif -#ifndef USPACE -#define USPACE (getpagesize()) -#endif +#define DEF_USPACE (getpagesize()) #define kread(x, v) \ kvm_read(kd, psnl[x].n_value, (char *), sizeof v) != sizeof(v) @@ -177,7 +175,7 @@ donlist_sysctl(void) mib[1] = KERN_FSCALE; size = sizeof(fscale); if (sysctl(mib, 2, , , NULL, 0)) { - warn("fscale"); + warn("sysctl kern.fscale"); eval = 1; fscale = FSCALE; } @@ -186,7 +184,7 @@ donlist_sysctl(void) mib[1] = HW_PHYSMEM64; size = sizeof(memsize); if (sysctl(mib, 2, , , NULL, 0)) { - warn("avail_start"); + warn("sysctl hw.avail_start"); eval = 1; mempages = MEMPAGES; } else @@ -196,7 +194,7 @@ donlist_sysctl(void) mib[1] = KERN_CCPU; size = sizeof(xccpu); if (sysctl(mib, 2, , , NULL, 0)) { - warn("ccpu"); + warn("sysctl kern.ccpu"); eval = 1; log_ccpu = LOG_CCPU; } else @@ -206,7 +204,7 @@ donlist_sysctl(void) mib[1] = VM_MAXSLP; size = sizeof(maxslp); if (sysctl(mib, 2, , , NULL, 0)) { - warn("maxslp"); + warn("sysctl vm.maxslp"); eval = 1; maxslp = MAXSLP; } @@ -215,9 +213,9 @@ donlist_sysctl(void) mib[1] = VM_USPACE; size = sizeof(uspace); if (sysctl(mib, 2, , , NULL, 0)) { - warn("uspace"); + warn("sysctl vm.uspace"); eval = 1; - uspace = USPACE; + uspace = DEF_USPACE; } }
CVS commit: src/sys/arch/mips/include
Module Name:src Committed By: simonb Date: Wed Aug 26 10:51:45 UTC 2020 Modified Files: src/sys/arch/mips/include: mips_param.h proc.h Log Message: Define a UPAGES_MAX constant to size the a md_upte array in MIPS's struct mdlwp. This is exposed to userland, so we can't use something based on PAGE_SIZE. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/arch/mips/include/mips_param.h cvs rdiff -u -r1.30 -r1.31 src/sys/arch/mips/include/proc.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/mips/include/mips_param.h diff -u src/sys/arch/mips/include/mips_param.h:1.46 src/sys/arch/mips/include/mips_param.h:1.47 --- src/sys/arch/mips/include/mips_param.h:1.46 Sun Aug 23 10:23:38 2020 +++ src/sys/arch/mips/include/mips_param.h Wed Aug 26 10:51:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mips_param.h,v 1.46 2020/08/23 10:23:38 simonb Exp $ */ +/* $NetBSD: mips_param.h,v 1.47 2020/08/26 10:51:45 simonb Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -130,6 +130,7 @@ #define USPACE MAX(__MIN_USPACE, PAGE_SIZE) #define UPAGES (USPACE / PAGE_SIZE) /* number of pages for u-area */ #define USPACE_ALIGN USPACE /* make sure it starts on a even VA */ +#define UPAGES_MAX 8 /* a (constant) max for userland use */ /* * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized Index: src/sys/arch/mips/include/proc.h diff -u src/sys/arch/mips/include/proc.h:1.30 src/sys/arch/mips/include/proc.h:1.31 --- src/sys/arch/mips/include/proc.h:1.30 Sun Aug 23 10:23:38 2020 +++ src/sys/arch/mips/include/proc.h Wed Aug 26 10:51:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.30 2020/08/23 10:23:38 simonb Exp $ */ +/* $NetBSD: proc.h,v 1.31 2020/08/26 10:51:45 simonb Exp $ */ /* * Copyright (c) 1992, 1993 @@ -52,7 +52,7 @@ struct mdlwp { vaddr_t md_ss_addr; /* single step address for ptrace */ int md_ss_instr; /* single step instruction for ptrace */ volatile int md_astpending; /* AST pending on return to userland */ - int md_upte[UPAGES]; /* ptes for mapping u page */ + int md_upte[UPAGES_MAX]; /* ptes for mapping u page */ }; struct mdproc {
CVS commit: src/sys/arch/mips/include
Module Name:src Committed By: simonb Date: Wed Aug 26 10:51:45 UTC 2020 Modified Files: src/sys/arch/mips/include: mips_param.h proc.h Log Message: Define a UPAGES_MAX constant to size the a md_upte array in MIPS's struct mdlwp. This is exposed to userland, so we can't use something based on PAGE_SIZE. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/arch/mips/include/mips_param.h cvs rdiff -u -r1.30 -r1.31 src/sys/arch/mips/include/proc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/hid
Module Name:src Committed By: jdolecek Date: Wed Aug 26 10:34:04 UTC 2020 Modified Files: src/sys/dev/hid: hidkbdmap.c Log Message: for jp keymap map also scan code 49 to right bracket to handle ARCHISS model PR kern/55608 by Shinichi Doyashiki To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/hid/hidkbdmap.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/dev/hid/hidkbdmap.c diff -u src/sys/dev/hid/hidkbdmap.c:1.10 src/sys/dev/hid/hidkbdmap.c:1.11 --- src/sys/dev/hid/hidkbdmap.c:1.10 Mon Jul 13 09:44:48 2020 +++ src/sys/dev/hid/hidkbdmap.c Wed Aug 26 10:34:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: hidkbdmap.c,v 1.10 2020/07/13 09:44:48 nia Exp $ */ +/* $NetBSD: hidkbdmap.c,v 1.11 2020/08/26 10:34:03 jdolecek Exp $ */ /* * Copyright (c) 1999,2001 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hidkbdmap.c,v 1.10 2020/07/13 09:44:48 nia Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hidkbdmap.c,v 1.11 2020/08/26 10:34:03 jdolecek Exp $"); #include #include @@ -171,7 +171,8 @@ Static const keysym_t hidkbd_keydesc_jp[ KC(46), KS_asciicircum, KS_asciitilde, KC(47), KS_at, KS_grave, KC(48), KS_bracketleft, KS_braceleft, -KC(50), KS_bracketright, KS_braceright, +KC(49), /* ARCHISS */ KS_bracketright, KS_braceright, +KC(50), /* other model */ KS_bracketright, KS_braceright, KC(51), KS_semicolon, KS_plus, KC(52), KS_colon, KS_asterisk, KC(53), KS_Zenkaku_Hankaku, /* replace grave/tilde */
CVS commit: src/sys/dev/hid
Module Name:src Committed By: jdolecek Date: Wed Aug 26 10:34:04 UTC 2020 Modified Files: src/sys/dev/hid: hidkbdmap.c Log Message: for jp keymap map also scan code 49 to right bracket to handle ARCHISS model PR kern/55608 by Shinichi Doyashiki To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/hid/hidkbdmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.