From owner-svn-src-all@freebsd.org Sun Jan 7 00:04:16 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C41E9DFBA37; Sun, 7 Jan 2018 00:04:16 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 887A569109; Sun, 7 Jan 2018 00:04:16 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A06F519706; Sun, 7 Jan 2018 00:04:15 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0704FCO031321; Sun, 7 Jan 2018 00:04:15 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0704D8K031297; Sun, 7 Jan 2018 00:04:13 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801070004.w0704D8K031297@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 7 Jan 2018 00:04:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327658 - in stable/11/sys: arm/allwinner arm/altera/socfpga arm/arm arm/broadcom/bcm2835 arm/conf arm/freescale/imx arm/freescale/vybrid arm/include arm/mv/armada38x arm/mv/armadaxp ar... X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11/sys: arm/allwinner arm/altera/socfpga arm/arm arm/broadcom/bcm2835 arm/conf arm/freescale/imx arm/freescale/vybrid arm/include arm/mv/armada38x arm/mv/armadaxp arm/nvidia/tegra124 arm/roc... X-SVN-Commit-Revision: 327658 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 00:04:16 -0000 Author: ian Date: Sun Jan 7 00:04:13 2018 New Revision: 327658 URL: https://svnweb.freebsd.org/changeset/base/327658 Log: MFC r327367: Make kernel option KERNVIRTADDR optional, remove it from std. files that can use the default value. It used to be required that the low-order bits of KERNVIRTADDR matched the low-order bits of the physical load address for all arm platforms. That hasn't been a requirement for armv6 platforms since FreeBSD 10. There is no longer any relationship between load addr and KERNVIRTADDR except that both must be aligned to a 2 MiB boundary. This change makes the default KERNVIRTADDR value 0xc0000000, and removes the options from all the platforms that can use the default value. The default is now defined in vmparam.h, and that file is now included in a few new places that reference KERNVIRTADDR, since it may not come in via the forced-include of opt_global.h on the compile command line. Modified: stable/11/sys/arm/allwinner/std.allwinner stable/11/sys/arm/allwinner/std.allwinner_up stable/11/sys/arm/altera/socfpga/std.socfpga stable/11/sys/arm/arm/dump_machdep.c stable/11/sys/arm/arm/elf_trampoline.c stable/11/sys/arm/arm/genassym.c stable/11/sys/arm/arm/machdep_boot.c stable/11/sys/arm/broadcom/bcm2835/std.rpi stable/11/sys/arm/conf/NOTES stable/11/sys/arm/freescale/imx/std.imx51 stable/11/sys/arm/freescale/imx/std.imx53 stable/11/sys/arm/freescale/imx/std.imx6 stable/11/sys/arm/freescale/vybrid/std.vybrid stable/11/sys/arm/include/vmparam.h stable/11/sys/arm/mv/armada38x/std.armada38x stable/11/sys/arm/mv/armadaxp/std.armadaxp stable/11/sys/arm/nvidia/tegra124/std.tegra124 stable/11/sys/arm/rockchip/std.rk30xx stable/11/sys/arm/samsung/exynos/std.exynos5250 stable/11/sys/arm/samsung/exynos/std.exynos5420 stable/11/sys/arm/ti/am335x/std.am335x stable/11/sys/arm/ti/omap4/std.omap4 stable/11/sys/arm/xilinx/std.zynq7 stable/11/sys/conf/Makefile.arm Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/allwinner/std.allwinner ============================================================================== --- stable/11/sys/arm/allwinner/std.allwinner Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/allwinner/std.allwinner Sun Jan 7 00:04:13 2018 (r327658) @@ -5,9 +5,6 @@ cpu CPU_CORTEXA machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" -makeoptions KERNVIRTADDR=0xc0200000 -options KERNVIRTADDR=0xc0200000 - options IPI_IRQ_START=0 options IPI_IRQ_END=15 Modified: stable/11/sys/arm/allwinner/std.allwinner_up ============================================================================== --- stable/11/sys/arm/allwinner/std.allwinner_up Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/allwinner/std.allwinner_up Sun Jan 7 00:04:13 2018 (r327658) @@ -5,9 +5,6 @@ cpu CPU_CORTEXA machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" -makeoptions KERNVIRTADDR=0xc0200000 -options KERNVIRTADDR=0xc0200000 - files "../allwinner/files.allwinner_up" files "../allwinner/files.allwinner" files "../allwinner/a10/files.a10" Modified: stable/11/sys/arm/altera/socfpga/std.socfpga ============================================================================== --- stable/11/sys/arm/altera/socfpga/std.socfpga Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/altera/socfpga/std.socfpga Sun Jan 7 00:04:13 2018 (r327658) @@ -4,9 +4,6 @@ cpu CPU_CORTEXA machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" -makeoptions KERNVIRTADDR=0xc0f00000 -options KERNVIRTADDR=0xc0f00000 - options IPI_IRQ_START=0 options IPI_IRQ_END=15 Modified: stable/11/sys/arm/arm/dump_machdep.c ============================================================================== --- stable/11/sys/arm/arm/dump_machdep.c Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/arm/dump_machdep.c Sun Jan 7 00:04:13 2018 (r327658) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include /* For KERNVIRTADDR */ int do_minidump = 1; SYSCTL_INT(_debug, OID_AUTO, minidump, CTLFLAG_RWTUN, &do_minidump, 0, Modified: stable/11/sys/arm/arm/elf_trampoline.c ============================================================================== --- stable/11/sys/arm/arm/elf_trampoline.c Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/arm/elf_trampoline.c Sun Jan 7 00:04:13 2018 (r327658) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include /* For KERNVIRTADDR */ extern char kernel_start[]; extern char kernel_end[]; Modified: stable/11/sys/arm/arm/genassym.c ============================================================================== --- stable/11/sys/arm/arm/genassym.c Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/arm/genassym.c Sun Jan 7 00:04:13 2018 (r327658) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include /* For KERNVIRTADDR */ #include #include @@ -57,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include ASSYM(KERNBASE, KERNBASE); +ASSYM(KERNVIRTADDR, KERNVIRTADDR); #if __ARM_ARCH >= 6 ASSYM(CPU_ASID_KERNEL,CPU_ASID_KERNEL); #endif Modified: stable/11/sys/arm/arm/machdep_boot.c ============================================================================== --- stable/11/sys/arm/arm/machdep_boot.c Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/arm/machdep_boot.c Sun Jan 7 00:04:13 2018 (r327658) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include /* For KERNVIRTADDR */ #ifdef FDT #include Modified: stable/11/sys/arm/broadcom/bcm2835/std.rpi ============================================================================== --- stable/11/sys/arm/broadcom/bcm2835/std.rpi Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/broadcom/bcm2835/std.rpi Sun Jan 7 00:04:13 2018 (r327658) @@ -1,5 +1,3 @@ # $FreeBSD$ -options KERNVIRTADDR=0xc0100000 -makeoptions KERNVIRTADDR=0xc0100000 options LINUX_BOOT_ABI Modified: stable/11/sys/arm/conf/NOTES ============================================================================== --- stable/11/sys/arm/conf/NOTES Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/conf/NOTES Sun Jan 7 00:04:13 2018 (r327658) @@ -24,11 +24,9 @@ files "../xscale/ixp425/files.ixp425" files "../xscale/pxa/files.pxa" options PHYSADDR=0x00000000 -options KERNVIRTADDR=0xc0000000 makeoptions LDFLAGS="-zmuldefs" makeoptions KERNPHYSADDR=0x00000000 -makeoptions KERNVIRTADDR=0xc0000000 options FDT Modified: stable/11/sys/arm/freescale/imx/std.imx51 ============================================================================== --- stable/11/sys/arm/freescale/imx/std.imx51 Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/freescale/imx/std.imx51 Sun Jan 7 00:04:13 2018 (r327658) @@ -3,9 +3,6 @@ machine arm armv6 cpu CPU_CORTEXA makeoptions CONF_CFLAGS="-march=armv7a" -options KERNVIRTADDR=0xc0100000 -makeoptions KERNVIRTADDR=0xc0100000 - device fdt_pinctrl files "../freescale/imx/files.imx5" Modified: stable/11/sys/arm/freescale/imx/std.imx53 ============================================================================== --- stable/11/sys/arm/freescale/imx/std.imx53 Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/freescale/imx/std.imx53 Sun Jan 7 00:04:13 2018 (r327658) @@ -3,9 +3,6 @@ machine arm armv6 cpu CPU_CORTEXA makeoptions CONF_CFLAGS="-march=armv7a" -options KERNVIRTADDR=0xc0100000 -makeoptions KERNVIRTADDR=0xc0100000 - device fdt_pinctrl files "../freescale/imx/files.imx5" Modified: stable/11/sys/arm/freescale/imx/std.imx6 ============================================================================== --- stable/11/sys/arm/freescale/imx/std.imx6 Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/freescale/imx/std.imx6 Sun Jan 7 00:04:13 2018 (r327658) @@ -3,9 +3,6 @@ machine arm armv6 cpu CPU_CORTEXA makeoptions CONF_CFLAGS="-march=armv7a" -options KERNVIRTADDR = 0xc2000000 -makeoptions KERNVIRTADDR = 0xc2000000 - options IPI_IRQ_START=0 options IPI_IRQ_END=15 Modified: stable/11/sys/arm/freescale/vybrid/std.vybrid ============================================================================== --- stable/11/sys/arm/freescale/vybrid/std.vybrid Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/freescale/vybrid/std.vybrid Sun Jan 7 00:04:13 2018 (r327658) @@ -4,7 +4,4 @@ cpu CPU_CORTEXA machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" -makeoptions KERNVIRTADDR=0xc0100000 -options KERNVIRTADDR=0xc0100000 - files "../freescale/vybrid/files.vybrid" Modified: stable/11/sys/arm/include/vmparam.h ============================================================================== --- stable/11/sys/arm/include/vmparam.h Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/include/vmparam.h Sun Jan 7 00:04:13 2018 (r327658) @@ -73,6 +73,19 @@ #endif /* + * The virtual address the kernel is linked to run at. For armv4/5 platforms + * the low-order 30 bits of this must match the low-order bits of the physical + * address the kernel is loaded at, so the value is most often provided as a + * kernel config option in the std.platform file. For armv6/7 the kernel can + * be loaded at any 2MB boundary, and KERNVIRTADDR can also be set to any 2MB + * boundary. It is typically overridden in the std.platform file only when + * KERNBASE is also set to a lower address to provide more KVA. + */ +#ifndef KERNVIRTADDR +#define KERNVIRTADDR 0xc0000000 +#endif + +/* * max number of non-contig chunks of physical RAM you can have */ Modified: stable/11/sys/arm/mv/armada38x/std.armada38x ============================================================================== --- stable/11/sys/arm/mv/armada38x/std.armada38x Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/mv/armada38x/std.armada38x Sun Jan 7 00:04:13 2018 (r327658) @@ -5,8 +5,6 @@ cpu CPU_CORTEXA machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" -makeoptions KERNVIRTADDR=0xc0000000 -options KERNVIRTADDR=0xc0000000 options IPI_IRQ_START=0 options IPI_IRQ_END=15 Modified: stable/11/sys/arm/mv/armadaxp/std.armadaxp ============================================================================== --- stable/11/sys/arm/mv/armadaxp/std.armadaxp Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/mv/armadaxp/std.armadaxp Sun Jan 7 00:04:13 2018 (r327658) @@ -1,4 +1,2 @@ # $FreeBSD$ -makeoptions KERNVIRTADDR=0xc0200000 -options KERNVIRTADDR=0xc0200000 Modified: stable/11/sys/arm/nvidia/tegra124/std.tegra124 ============================================================================== --- stable/11/sys/arm/nvidia/tegra124/std.tegra124 Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/nvidia/tegra124/std.tegra124 Sun Jan 7 00:04:13 2018 (r327658) @@ -3,9 +3,6 @@ cpu CPU_CORTEXA machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" -options KERNVIRTADDR = 0xc0200000 -makeoptions KERNVIRTADDR = 0xc0200000 - options INTRNG options IPI_IRQ_START=0 Modified: stable/11/sys/arm/rockchip/std.rk30xx ============================================================================== --- stable/11/sys/arm/rockchip/std.rk30xx Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/rockchip/std.rk30xx Sun Jan 7 00:04:13 2018 (r327658) @@ -5,9 +5,6 @@ cpu CPU_CORTEXA machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" -makeoptions KERNVIRTADDR=0xc0400000 -options KERNVIRTADDR=0xc0400000 - options IPI_IRQ_START=0 options IPI_IRQ_END=15 Modified: stable/11/sys/arm/samsung/exynos/std.exynos5250 ============================================================================== --- stable/11/sys/arm/samsung/exynos/std.exynos5250 Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/samsung/exynos/std.exynos5250 Sun Jan 7 00:04:13 2018 (r327658) @@ -4,9 +4,6 @@ cpu CPU_CORTEXA machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" -makeoptions KERNVIRTADDR=0xc0f00000 -options KERNVIRTADDR=0xc0f00000 - options IPI_IRQ_START=0 options IPI_IRQ_END=15 Modified: stable/11/sys/arm/samsung/exynos/std.exynos5420 ============================================================================== --- stable/11/sys/arm/samsung/exynos/std.exynos5420 Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/samsung/exynos/std.exynos5420 Sun Jan 7 00:04:13 2018 (r327658) @@ -4,9 +4,6 @@ cpu CPU_CORTEXA machine arm armv6 makeoptions CONF_CFLAGS="-march=armv7a" -makeoptions KERNVIRTADDR=0xc0f00000 -options KERNVIRTADDR=0xc0f00000 - options IPI_IRQ_START=0 options IPI_IRQ_END=15 Modified: stable/11/sys/arm/ti/am335x/std.am335x ============================================================================== --- stable/11/sys/arm/ti/am335x/std.am335x Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/ti/am335x/std.am335x Sun Jan 7 00:04:13 2018 (r327658) @@ -3,7 +3,4 @@ files "../ti/am335x/files.am335x" include "../ti/std.ti" -options KERNVIRTADDR=0xc0200000 # Used in ldscript.arm -makeoptions KERNVIRTADDR=0xc0200000 - options SOC_TI_AM335X Modified: stable/11/sys/arm/ti/omap4/std.omap4 ============================================================================== --- stable/11/sys/arm/ti/omap4/std.omap4 Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/ti/omap4/std.omap4 Sun Jan 7 00:04:13 2018 (r327658) @@ -3,7 +3,4 @@ files "../ti/omap4/files.omap4" include "../ti/std.ti" -options KERNVIRTADDR=0xc0200000 # Used in ldscript.arm -makeoptions KERNVIRTADDR=0xc0200000 - options SOC_OMAP4 Modified: stable/11/sys/arm/xilinx/std.zynq7 ============================================================================== --- stable/11/sys/arm/xilinx/std.zynq7 Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/arm/xilinx/std.zynq7 Sun Jan 7 00:04:13 2018 (r327658) @@ -9,8 +9,5 @@ makeoptions CONF_CFLAGS="-march=armv7a" files "../xilinx/files.zynq7" -options KERNVIRTADDR=0xc0100000 # Used in ldscript.arm -makeoptions KERNVIRTADDR=0xc0100000 - options IPI_IRQ_START=0 options IPI_IRQ_END=15 Modified: stable/11/sys/conf/Makefile.arm ============================================================================== --- stable/11/sys/conf/Makefile.arm Sat Jan 6 23:44:14 2018 (r327657) +++ stable/11/sys/conf/Makefile.arm Sun Jan 7 00:04:13 2018 (r327658) @@ -53,6 +53,11 @@ CFLAGS += -mllvm -arm-enable-ehabi .endif .endif +# "makeoptions KERNVIRTADDR=" is now optional, supply the default value. +.if empty(KERNVIRTADDR) +KERNVIRTADDR= 0xc0000000 +.endif + # hack because genassym.c includes sys/bus.h which includes these. genassym.o: bus_if.h device_if.h From owner-svn-src-all@freebsd.org Sun Jan 7 00:31:46 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 351F4DFD3F7; Sun, 7 Jan 2018 00:31:46 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 117C269E85; Sun, 7 Jan 2018 00:31:46 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6B1F719B89; Sun, 7 Jan 2018 00:31:45 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w070VjtV042683; Sun, 7 Jan 2018 00:31:45 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w070VjPR042682; Sun, 7 Jan 2018 00:31:45 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201801070031.w070VjPR042682@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 7 Jan 2018 00:31:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327659 - stable/11/share/skel X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/share/skel X-SVN-Commit-Revision: 327659 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 00:31:46 -0000 Author: eadler Date: Sun Jan 7 00:31:45 2018 New Revision: 327659 URL: https://svnweb.freebsd.org/changeset/base/327659 Log: MFC r327420: skel: Quote PAGER in dot.shrc PR: 181853 Submitted by: pl@catslair.org Modified: stable/11/share/skel/dot.shrc Directory Properties: stable/11/ (props changed) Modified: stable/11/share/skel/dot.shrc ============================================================================== --- stable/11/share/skel/dot.shrc Sun Jan 7 00:04:13 2018 (r327658) +++ stable/11/share/skel/dot.shrc Sun Jan 7 00:31:45 2018 (r327659) @@ -21,7 +21,7 @@ # some useful aliases alias h='fc -l' alias j=jobs -alias m=$PAGER +alias m="$PAGER" alias ll='ls -laFo' alias l='ls -l' alias g='egrep -i' From owner-svn-src-all@freebsd.org Sun Jan 7 00:35:54 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4F038DFD622; Sun, 7 Jan 2018 00:35:54 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 29FF56A1E5; Sun, 7 Jan 2018 00:35:54 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5F9BA19BCD; Sun, 7 Jan 2018 00:35:53 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w070ZrQp043659; Sun, 7 Jan 2018 00:35:53 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w070ZrKD043658; Sun, 7 Jan 2018 00:35:53 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201801070035.w070ZrKD043658@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 7 Jan 2018 00:35:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327660 - stable/11/usr.bin/man X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/usr.bin/man X-SVN-Commit-Revision: 327660 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 00:35:54 -0000 Author: eadler Date: Sun Jan 7 00:35:52 2018 New Revision: 327660 URL: https://svnweb.freebsd.org/changeset/base/327660 Log: MFC r327396: man(1): document exit code man(1) uses standard exit codes, document that. PR: 223517 Reported by: wosch Modified: stable/11/usr.bin/man/man.1 Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/man/man.1 ============================================================================== --- stable/11/usr.bin/man/man.1 Sun Jan 7 00:31:45 2018 (r327659) +++ stable/11/usr.bin/man/man.1 Sun Jan 7 00:35:52 2018 (r327660) @@ -355,6 +355,8 @@ System configuration file. .It Pa /usr/local/etc/man.d/*.conf Local configuration files. .El +.Sh EXIT STATUS +.Ex -std .Sh SEE ALSO .Xr apropos 1 , .Xr intro 1 , From owner-svn-src-all@freebsd.org Sun Jan 7 00:38:35 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A9A9FDFD861; Sun, 7 Jan 2018 00:38:35 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 83EBD6A374; Sun, 7 Jan 2018 00:38:35 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CCBD019BD0; Sun, 7 Jan 2018 00:38:34 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w070cYc5043798; Sun, 7 Jan 2018 00:38:34 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w070cY8a043797; Sun, 7 Jan 2018 00:38:34 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201801070038.w070cY8a043797@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 7 Jan 2018 00:38:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327661 - stable/11/lib/libc/gen X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/lib/libc/gen X-SVN-Commit-Revision: 327661 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 00:38:35 -0000 Author: eadler Date: Sun Jan 7 00:38:34 2018 New Revision: 327661 URL: https://svnweb.freebsd.org/changeset/base/327661 Log: MFC r327398: isgreater(3): correct description of isunordered macro PR: 211376 Submitted by: Duane Modified: stable/11/lib/libc/gen/isgreater.3 Directory Properties: stable/11/ (props changed) Modified: stable/11/lib/libc/gen/isgreater.3 ============================================================================== --- stable/11/lib/libc/gen/isgreater.3 Sun Jan 7 00:35:52 2018 (r327660) +++ stable/11/lib/libc/gen/isgreater.3 Sun Jan 7 00:38:34 2018 (r327661) @@ -75,9 +75,9 @@ macro takes arguments .Fa x and .Fa y -and returns non-zero if and only if neither +and returns non-zero if and only if any of .Fa x -nor +or .Fa y are NaNs. For any pair of floating-point values, one From owner-svn-src-all@freebsd.org Sun Jan 7 00:44:24 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9C9C5DFDCAC; Sun, 7 Jan 2018 00:44:24 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BC126A807; Sun, 7 Jan 2018 00:44:24 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 74BE019D62; Sun, 7 Jan 2018 00:44:23 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w070iNRt047873; Sun, 7 Jan 2018 00:44:23 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w070iMGX047862; Sun, 7 Jan 2018 00:44:22 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201801070044.w070iMGX047862@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 7 Jan 2018 00:44:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327662 - in head: . tests/sys/geom/class/eli X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in head: . tests/sys/geom/class/eli X-SVN-Commit-Revision: 327662 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 00:44:24 -0000 Author: asomers Date: Sun Jan 7 00:44:22 2018 New Revision: 327662 URL: https://svnweb.freebsd.org/changeset/base/327662 Log: geli: convert most tests from TAP to ATF I'm leaving readonly_test and nokey_test alone for now. In a future commit they should be broken up into several smaller test cases and distributed between multiple files. Reviewed by: ngie MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D13717 Added: head/tests/sys/geom/class/eli/attach_test.sh (contents, props changed) head/tests/sys/geom/class/eli/configure_test.sh (contents, props changed) head/tests/sys/geom/class/eli/detach_test.sh (contents, props changed) head/tests/sys/geom/class/eli/integrity_test.sh (contents, props changed) Deleted: head/tests/sys/geom/class/eli/attach_d_test.sh head/tests/sys/geom/class/eli/configure_b_B_test.sh head/tests/sys/geom/class/eli/detach_l_test.sh head/tests/sys/geom/class/eli/init_B_test.sh head/tests/sys/geom/class/eli/init_J_test.sh head/tests/sys/geom/class/eli/init_a_test.sh head/tests/sys/geom/class/eli/init_alias_test.sh head/tests/sys/geom/class/eli/init_i_P_test.sh head/tests/sys/geom/class/eli/integrity_copy_test.sh head/tests/sys/geom/class/eli/integrity_data_test.sh head/tests/sys/geom/class/eli/integrity_hmac_test.sh head/tests/sys/geom/class/eli/onetime_a_test.sh head/tests/sys/geom/class/eli/onetime_d_test.sh Modified: head/ObsoleteFiles.inc head/tests/sys/geom/class/eli/Makefile head/tests/sys/geom/class/eli/conf.sh head/tests/sys/geom/class/eli/delkey_test.sh head/tests/sys/geom/class/eli/init_test.sh head/tests/sys/geom/class/eli/kill_test.sh head/tests/sys/geom/class/eli/onetime_test.sh head/tests/sys/geom/class/eli/resize_test.sh head/tests/sys/geom/class/eli/setkey_test.sh Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Sun Jan 7 00:38:34 2018 (r327661) +++ head/ObsoleteFiles.inc Sun Jan 7 00:44:22 2018 (r327662) @@ -38,6 +38,20 @@ # xargs -n1 | sort | uniq -d; # done +# 20180106: Convert most geli(8) tests to ATF +OLD_FILES+=tests/sys/geom/class/eli/attach_d_test.sh +OLD_FILES+=tests/sys/geom/class/eli/configure_b_B_test.sh +OLD_FILES+=tests/sys/geom/class/eli/detach_l_test.sh +OLD_FILES+=tests/sys/geom/class/eli/init_B_test.sh +OLD_FILES+=tests/sys/geom/class/eli/init_J_test.sh +OLD_FILES+=tests/sys/geom/class/eli/init_a_test.sh +OLD_FILES+=tests/sys/geom/class/eli/init_alias_test.sh +OLD_FILES+=tests/sys/geom/class/eli/init_i_P_test.sh +OLD_FILES+=tests/sys/geom/class/eli/integrity_copy_test.sh +OLD_FILES+=tests/sys/geom/class/eli/integrity_data_test.sh +OLD_FILES+=tests/sys/geom/class/eli/integrity_hmac_test.sh +OLD_FILES+=tests/sys/geom/class/eli/onetime_a_test.sh +OLD_FILES+=tests/sys/geom/class/eli/onetime_d_test.sh # 20171230: Remove /etc/skel from mtree OLD_DIRS+=/etc/skel # 20171208: Remove basename_r(3) Modified: head/tests/sys/geom/class/eli/Makefile ============================================================================== --- head/tests/sys/geom/class/eli/Makefile Sun Jan 7 00:38:34 2018 (r327661) +++ head/tests/sys/geom/class/eli/Makefile Sun Jan 7 00:44:22 2018 (r327662) @@ -7,36 +7,20 @@ PACKAGE= tests TESTSDIR= ${TESTSBASE}/sys/geom/class/${.CURDIR:T} ATF_TESTS_C= pbkdf2_test +ATF_TESTS_SH+= attach_test +ATF_TESTS_SH+= configure_test +ATF_TESTS_SH+= delkey_test +ATF_TESTS_SH+= detach_test +ATF_TESTS_SH+= init_test +ATF_TESTS_SH+= integrity_test +ATF_TESTS_SH+= kill_test +ATF_TESTS_SH+= onetime_test +ATF_TESTS_SH+= resize_test +ATF_TESTS_SH+= setkey_test -TAP_TESTS_SH+= attach_d_test -TAP_TESTS_SH+= configure_b_B_test -TAP_TESTS_SH+= delkey_test -TAP_TESTS_SH+= detach_l_test -TAP_TESTS_SH+= init_B_test -TAP_TESTS_SH+= init_J_test -TAP_TESTS_SH+= init_a_test -TAP_TESTS_SH+= init_alias_test -TAP_TESTS_SH+= init_i_P_test -TAP_TESTS_SH+= init_test -TAP_TESTS_SH+= integrity_copy_test -TAP_TESTS_SH+= integrity_data_test -TAP_TESTS_SH+= integrity_hmac_test -TAP_TESTS_SH+= kill_test TAP_TESTS_SH+= nokey_test -TAP_TESTS_SH+= onetime_a_test -TAP_TESTS_SH+= onetime_d_test -TAP_TESTS_SH+= onetime_test TAP_TESTS_SH+= readonly_test -TAP_TESTS_SH+= resize_test -TAP_TESTS_SH+= setkey_test -TEST_METADATA.init_a_test+= timeout="3600" -TEST_METADATA.init_test+= timeout="600" -TEST_METADATA.integrity_copy_test+= timeout="3600" -TEST_METADATA.integrity_data_test+= timeout="1800" -TEST_METADATA.integrity_hmac_test+= timeout="1800" -TEST_METADATA.onetime_a_test+= timeout="1800" -TEST_METADATA.onetime_test+= timeout="1800" ${PACKAGE}FILES+= conf.sh Added: head/tests/sys/geom/class/eli/attach_test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/geom/class/eli/attach_test.sh Sun Jan 7 00:44:22 2018 (r327662) @@ -0,0 +1,45 @@ +# $FreeBSD$ + +atf_test_case attach_d cleanup +attach_d_head() +{ + atf_set "descr" "geli attach -d will cause the provider to detach on last close" + atf_set "require.user" "root" +} +attach_d_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + + atf_check geli init -B none -P -K keyfile ${md} + atf_check geli attach -d -p -k keyfile ${md} + + # Be sure it doesn't detach on read. + atf_check dd if=/dev/${md}.eli of=/dev/null status=none + sleep 1 + if [ ! -c /dev/${md}.eli ]; then + atf_fail "Detached on last close of a reader" + fi + + # It should detach on last close of a writer + true > /dev/${md}.eli + sleep 1 + if [ -c /dev/${md}.eli ]; then + atf_fail "Did not detach on last close of a writer" + fi + +} +attach_d_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case attach_d +} Modified: head/tests/sys/geom/class/eli/conf.sh ============================================================================== --- head/tests/sys/geom/class/eli/conf.sh Sun Jan 7 00:38:34 2018 (r327661) +++ head/tests/sys/geom/class/eli/conf.sh Sun Jan 7 00:44:22 2018 (r327662) @@ -2,8 +2,19 @@ # $FreeBSD$ class="eli" -base=`basename $0` +base=$(atf_get ident) +[ -z "$base" ] && base=`basename $0` # for TAP compatibility +TEST_MDS_FILE=md.devs +attach_md() +{ + local test_md + + test_md=$(mdconfig -a "$@") || atf_fail "failed to allocate md(4)" + echo $test_md >> $TEST_MDS_FILE || exit + echo $test_md +} + # Execute `func` for each combination of cipher, sectorsize, and hmac algo # `func` usage should be: # func @@ -23,7 +34,11 @@ for_each_geli_config() { for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 \ hmac/sha384 hmac/sha512; do for secsize in 512 1024 2048 4096 8192; do - bytes=`expr $secsize \* $sectors + 512`b + # Double the requested sector size to allow + # for the HMACs' storage space. + osecsize=$(( $secsize * 2 )) + # geli needs 512B for the label. + bytes=`expr $osecsize \* $sectors + 512`b md=$(attach_md -t malloc -s $bytes) ${func} $cipher $aalgo $secsize geli detach ${md} 2>/dev/null @@ -50,6 +65,7 @@ for_each_geli_config_nointegrity() { ealgo=${cipher%%:*} keylen=${cipher##*:} for secsize in 512 1024 2048 4096 8192; do + # geli needs 512B for the label. bytes=`expr $secsize \* $sectors + 512`b md=$(attach_md -t malloc -s $bytes) ${func} $cipher $secsize @@ -69,8 +85,9 @@ geli_test_cleanup() mdconfig -d -u $md 2>/dev/null done < $TEST_MDS_FILE fi - rm -f "$TEST_MDS_FILE" + true } +# TODO: remove the trap statement once all TAP tests are converted trap geli_test_cleanup ABRT EXIT INT TERM . `dirname $0`/../geom_subr.sh Added: head/tests/sys/geom/class/eli/configure_test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/geom/class/eli/configure_test.sh Sun Jan 7 00:44:22 2018 (r327662) @@ -0,0 +1,59 @@ +# $FreeBSD$ + +atf_test_case configure_b_B cleanup +configure_b_B_head() +{ + atf_set "descr" "geli configure -b will set the BOOT flag" + atf_set "require.user" "root" +} +configure_b_B_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + + atf_check geli init -B none -P -K /dev/null ${md} + + atf_check -s exit:0 -o match:'flags: 0x0$' geli dump ${md} + + atf_check geli init -B none -b -P -K /dev/null ${md} + + atf_check -s exit:0 -o match:'flags: 0x2$' geli dump ${md} + + atf_check geli configure -B ${md} + + atf_check -s exit:0 -o match:'flags: 0x0$' geli dump ${md} + + atf_check geli configure -b ${md} + + atf_check -s exit:0 -o match:'flags: 0x2$' geli dump ${md} + + atf_check geli attach -p -k /dev/null ${md} + + atf_check -s exit:0 -o match:'^Flags: .*BOOT' geli list ${md}.eli + + atf_check geli configure -B ${md} + + atf_check -o not-match:'^Flags: .*BOOT' geli list ${md}.eli + + atf_check -s exit:0 -o match:'flags: 0x0$' geli dump ${md} + + atf_check geli configure -b ${md} + + atf_check -s exit:0 -o match:'^Flags: .*BOOT' geli list ${md}.eli + + atf_check -s exit:0 -o match:'flags: 0x2$' geli dump ${md} + + atf_check geli detach ${md} +} +configure_b_B_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case configure_b_B +} Modified: head/tests/sys/geom/class/eli/delkey_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/delkey_test.sh Sun Jan 7 00:38:34 2018 (r327661) +++ head/tests/sys/geom/class/eli/delkey_test.sh Sun Jan 7 00:44:22 2018 (r327662) @@ -1,140 +1,86 @@ #!/bin/sh # $FreeBSD$ -. $(dirname $0)/conf.sh +atf_test_case delkey cleanup +delkey_head() +{ + atf_set "descr" "geli delkey can destroy the master key" + atf_set "require.user" "root" +} +delkey_body() +{ + . $(atf_get_srcdir)/conf.sh -base=`basename $0` -sectors=100 -keyfile1=`mktemp $base.XXXXXX` || exit 1 -keyfile2=`mktemp $base.XXXXXX` || exit 1 -keyfile3=`mktemp $base.XXXXXX` || exit 1 -keyfile4=`mktemp $base.XXXXXX` || exit 1 -md=$(attach_md -t malloc -s `expr $sectors + 1`) + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) -echo "1..14" + atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none + atf_check dd if=/dev/random of=keyfile2 bs=512 count=16 status=none + atf_check dd if=/dev/random of=keyfile3 bs=512 count=16 status=none + atf_check dd if=/dev/random of=keyfile4 bs=512 count=16 status=none -dd if=/dev/random of=${keyfile1} bs=512 count=16 >/dev/null 2>&1 -dd if=/dev/random of=${keyfile2} bs=512 count=16 >/dev/null 2>&1 -dd if=/dev/random of=${keyfile3} bs=512 count=16 >/dev/null 2>&1 -dd if=/dev/random of=${keyfile4} bs=512 count=16 >/dev/null 2>&1 + atf_check geli init -B none -P -K keyfile1 ${md} + atf_check geli attach -p -k keyfile1 ${md} + atf_check -s exit:0 -o ignore geli setkey -n 1 -P -K keyfile2 ${md} -geli init -B none -P -K $keyfile1 ${md} -geli attach -p -k $keyfile1 ${md} -geli setkey -n 1 -P -K $keyfile2 ${md} + # Remove key 0 for attached provider. + atf_check geli delkey -n 0 ${md} + atf_check geli detach ${md} -# Remove key 0 for attached provider. -geli delkey -n 0 ${md} -if [ $? -eq 0 ]; then - echo "ok 1" -else - echo "not ok 1" -fi -geli detach ${md} + # We cannot use keyfile1 anymore. + atf_check -s not-exit:0 -e match:"Wrong key" \ + geli attach -p -k keyfile1 ${md} -# We cannot use keyfile1 anymore. -geli attach -p -k $keyfile1 ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 2" -else - echo "not ok 2" -fi + # Attach with key 1. + atf_check geli attach -p -k keyfile2 ${md} -# Attach with key 1. -geli attach -p -k $keyfile2 ${md} -if [ $? -eq 0 ]; then - echo "ok 3" -else - echo "not ok 3" -fi + # We cannot remove last key without -f option (for attached provider). + atf_check -s not-exit:0 -e match:"This is the last Master Key" \ + geli delkey -n 1 ${md} -# We cannot remove last key without -f option (for attached provider). -geli delkey -n 1 ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 4" -else - echo "not ok 4" -fi + # Remove last key for attached provider. + atf_check geli delkey -f -n 1 ${md} -# Remove last key for attached provider. -geli delkey -f -n 1 ${md} -if [ $? -eq 0 ]; then - echo "ok 5" -else - echo "not ok 5" -fi + # If there are no valid keys, but provider is attached, we can save situation. + atf_check -s exit:0 -o ignore geli setkey -n 0 -P -K keyfile3 ${md} + atf_check geli detach ${md} -# If there are no valid keys, but provider is attached, we can save situation. -geli setkey -n 0 -P -K $keyfile3 ${md} -if [ $? -eq 0 ]; then - echo "ok 6" -else - echo "not ok 6" -fi -geli detach ${md} + # We cannot use keyfile2 anymore. + atf_check -s not-exit:0 -e match:"Wrong key" \ + geli attach -p -k keyfile2 ${md} -# We cannot use keyfile2 anymore. -geli attach -p -k $keyfile2 ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 7" -else - echo "not ok 7" -fi + # Attach with key 0. + atf_check geli attach -p -k keyfile3 ${md} -# Attach with key 0. -geli attach -p -k $keyfile3 ${md} -if [ $? -eq 0 ]; then - echo "ok 8" -else - echo "not ok 8" -fi + # Setup key 1. + atf_check -s exit:0 -o ignore geli setkey -n 1 -P -K keyfile4 ${md} + atf_check geli detach ${md} -# Setup key 1. -geli setkey -n 1 -P -K $keyfile4 ${md} -if [ $? -eq 0 ]; then - echo "ok 9" -else - echo "not ok 9" -fi -geli detach ${md} + # Remove key 1 for detached provider. + atf_check geli delkey -n 1 ${md} -# Remove key 1 for detached provider. -geli delkey -n 1 ${md} -if [ $? -eq 0 ]; then - echo "ok 10" -else - echo "not ok 10" -fi + # We cannot use keyfile4 anymore. + atf_check -s not-exit:0 -e match:"Wrong key" \ + geli attach -p -k keyfile4 ${md} -# We cannot use keyfile4 anymore. -geli attach -p -k $keyfile4 ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 11" -else - echo "not ok 11" -fi + # We cannot remove last key without -f option (for detached provider). + atf_check -s not-exit:0 -e match:"This is the last Master Key" \ + geli delkey -n 0 ${md} -# We cannot remove last key without -f option (for detached provider). -geli delkey -n 0 ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 12" -else - echo "not ok 12" -fi + # Remove last key for detached provider. + atf_check geli delkey -f -n 0 ${md} -# Remove last key for detached provider. -geli delkey -f -n 0 ${md} -if [ $? -eq 0 ]; then - echo "ok 13" -else - echo "not ok 13" -fi + # We cannot use keyfile3 anymore. + atf_check -s not-exit:0 -e match:"No valid keys" \ + geli attach -p -k keyfile3 ${md} +} +delkey_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} -# We cannot use keyfile3 anymore. -geli attach -p -k $keyfile3 ${md} 2>/dev/null -if [ $? -ne 0 ]; then - echo "ok 14" -else - echo "not ok 14" -fi - -rm -f $keyfile1 $keyfile2 $keyfile3 $keyfile4 +atf_init_test_cases() +{ + atf_add_test_case delkey +} Added: head/tests/sys/geom/class/eli/detach_test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/geom/class/eli/detach_test.sh Sun Jan 7 00:44:22 2018 (r327662) @@ -0,0 +1,46 @@ +# $FreeBSD$ + +atf_test_case detach_l cleanup +detach_l_head() +{ + atf_set "descr" "geli detach -l will cause a provider to detach on last close" + atf_set "require.user" "root" +} +detach_l_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + + atf_check geli init -B none -P -K keyfile ${md} + atf_check geli attach -p -k keyfile ${md} + + # Be sure it doesn't detach before 'detach -l'. + atf_check dd if=/dev/${md}.eli of=/dev/null status=none + sleep 1 + if [ ! -c /dev/${md}.eli ]; then + atf_fail "provider detached on last close without detach -l" + fi + atf_check geli detach -l ${md} + if [ ! -c /dev/${md}.eli ]; then + atf_fail "Provider detached before last close" + fi + atf_check dd if=/dev/${md}.eli of=/dev/null status=none + sleep 1 + if [ -c /dev/${md}.eli ]; then + atf_fail "Provider did not detach on last close" + fi +} +detach_l_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case detach_l +} Modified: head/tests/sys/geom/class/eli/init_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/init_test.sh Sun Jan 7 00:38:34 2018 (r327661) +++ head/tests/sys/geom/class/eli/init_test.sh Sun Jan 7 00:44:22 2018 (r327662) @@ -1,50 +1,368 @@ #!/bin/sh # $FreeBSD$ -. $(dirname $0)/conf.sh +init_test() +{ + cipher=$1 + secsize=$2 + ealgo=${cipher%%:*} + keylen=${cipher##*:} -base=`basename $0` -sectors=32 -keyfile=`mktemp $base.XXXXXX` || exit 1 -rnd=`mktemp $base.XXXXXX` || exit 1 + atf_check -s exit:0 -e ignore \ + geli init -B none -e $ealgo -l $keylen -P -K keyfile -s $secsize ${md} + atf_check geli attach -p -k keyfile ${md} -echo "1..200" + secs=`diskinfo /dev/${md}.eli | awk '{print $4}'` -do_test() { + atf_check dd if=/dev/random of=rnd bs=${secsize} count=${secs} status=none + atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${secs} status=none + + md_rnd=`dd if=rnd bs=${secsize} count=${secs} status=none | md5` + atf_check_equal 0 $? + md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${secs} 2>/dev/null | md5` + atf_check_equal 0 $? + md_edev=`dd if=/dev/${md} bs=${secsize} count=${secs} status=none | md5` + atf_check_equal 0 $? + + if [ ${md_rnd} != ${md_ddev} ]; then + atf_fail "Miscompare for ealgo=${ealgo} keylen=${keylen} sec=${secsize}" + fi + if [ ${md_rnd} == ${md_edev} ]; then + atf_fail "Data was not encrypted for ealgo=${ealgo} keylen=${keylen} sec=${secsize}" + fi +} +atf_test_case init cleanup +init_head() +{ + atf_set "descr" "Basic I/O with geli" + atf_set "require.user" "root" + atf_set "timeout" 600 +} +init_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=32 + + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + atf_check dd if=/dev/random of=rnd bs=8192 count=${sectors} status=none + for_each_geli_config_nointegrity init_test +} +init_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +atf_test_case init_B cleanup +init_B_head() +{ + atf_set "descr" "init -B can select an alternate backup metadata file" + atf_set "require.user" "root" +} +init_B_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + + md=$(attach_md -t malloc -s $sectors) + + # -B none + rm -f /var/backups/${md}.eli + atf_check -s exit:0 -o ignore geli init -B none -P -K keyfile ${md} + if [ -f /var/backups/${md}.eli ]; then + atf_fail "geli created a backup file even with -B none" + fi + + # no -B + rm -f /var/backups/${md}.eli + atf_check -s exit:0 -o ignore geli init -P -K keyfile ${md} + if [ ! -f /var/backups/${md}.eli ]; then + atf_fail "geli did not create a backup file" + fi + atf_check geli clear ${md} + atf_check -s not-exit:0 -e ignore geli attach -p -k keyfile ${md} + atf_check -s exit:0 -o ignore geli restore /var/backups/${md}.eli ${md} + atf_check -s exit:0 -o ignore geli attach -p -k keyfile ${md} + atf_check geli detach ${md} + rm -f /var/backups/${md}.eli + + # -B file + rm -f backupfile + atf_check -s exit:0 -o ignore \ + geli init -B backupfile -P -K keyfile ${md} + if [ ! -f backupfile ]; then + atf_fail "geli init -B did not create a backup file" + fi + atf_check geli clear ${md} + atf_check -s not-exit:0 -e ignore geli attach -p -k keyfile ${md} + atf_check geli restore backupfile ${md} + atf_check geli attach -p -k keyfile ${md} +} +init_B_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +atf_test_case init_J cleanup +init_J_head() +{ + atf_set "descr" "init -J accepts a passfile" + atf_set "require.user" "root" +} +init_J_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + + atf_check dd if=/dev/random of=keyfile0 bs=512 count=16 status=none + atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none + dd if=/dev/random bs=512 count=16 status=none | sha1 > passfile0 + atf_check_equal 0 $? + dd if=/dev/random bs=512 count=16 status=none | sha1 > passfile1 + atf_check_equal 0 $? + + for iter in -1 0 64; do + atf_check -s not-exit:0 -e ignore \ + geli init -i ${iter} -B none -J passfile0 -P ${md} + atf_check -s not-exit:0 -e ignore \ + geli init -i ${iter} -B none -J passfile0 -P -K keyfile0 ${md} + atf_check geli init -i ${iter} -B none -J passfile0 -K keyfile0 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile0 -p ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -j passfile0 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -j keyfile0 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k passfile0 -p ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -j keyfile0 -k passfile0 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -j keyfile0 -k keyfile0 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -j passfile0 -k passfile0 ${md} + atf_check -s exit:0 -e ignore \ + geli attach -j passfile0 -k keyfile0 ${md} + atf_check -s exit:0 -e ignore geli detach ${md} + atf_check -s exit:0 -e ignore -x \ + "cat keyfile0 | geli attach -j passfile0 -k - ${md}" + atf_check -s exit:0 -e ignore geli detach ${md} + atf_check -s exit:0 -e ignore -x \ + "cat passfile0 | geli attach -j - -k keyfile0 ${md}" + atf_check -s exit:0 -e ignore geli detach ${md} + + atf_check -s not-exit:0 -e ignore \ + geli init -i ${iter} -B none -J passfile0 -J passfile1 -P ${md} + atf_check -s not-exit:0 -e ignore \ + geli init -i ${iter} -B none -J passfile0 -J passfile1 -P -K keyfile0 -K keyfile1 ${md} + atf_check -s exit:0 -e ignore \ + geli init -i ${iter} -B none -J passfile0 -J passfile1 -K keyfile0 -K keyfile1 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile0 -p ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile1 -p ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -j passfile0 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -j passfile1 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile0 -k keyfile1 -p ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -j passfile0 -j passfile1 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile0 -j passfile0 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile0 -j passfile1 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile1 -j passfile0 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile1 -j passfile1 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile0 -j passfile0 -j passfile1 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile1 -j passfile0 -j passfile1 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile0 -k keyfile1 -j passfile0 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile0 -k keyfile1 -j passfile1 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile1 -k keyfile0 -j passfile0 -j passfile1 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile0 -k keyfile1 -j passfile1 -j passfile0 ${md} + atf_check -s not-exit:0 -e ignore \ + geli attach -k keyfile1 -k keyfile0 -j passfile1 -j passfile0 ${md} + atf_check -s exit:0 -e ignore \ + geli attach -j passfile0 -j passfile1 -k keyfile0 -k keyfile1 ${md} + atf_check -s exit:0 -e ignore geli detach ${md} + atf_check -s exit:0 -e ignore -x \ + "cat passfile0 | geli attach -j - -j passfile1 -k keyfile0 -k keyfile1 ${md}" + atf_check -s exit:0 -e ignore geli detach ${md} + atf_check -s exit:0 -e ignore -x \ + "cat passfile1 | geli attach -j passfile0 -j - -k keyfile0 -k keyfile1 ${md}" + atf_check -s exit:0 -e ignore geli detach ${md} + atf_check -s exit:0 -e ignore -x \ + "cat keyfile0 | geli attach -j passfile0 -j passfile1 -k - -k keyfile1 ${md}" + atf_check -s exit:0 -e ignore geli detach ${md} + atf_check -s exit:0 -e ignore -x \ + "cat keyfile1 | geli attach -j passfile0 -j passfile1 -k keyfile0 -k - ${md}" + atf_check -s exit:0 -e ignore geli detach ${md} + atf_check -s exit:0 -e ignore -x \ + "cat keyfile0 keyfile1 | geli attach -j passfile0 -j passfile1 -k - ${md}" + atf_check -s exit:0 -e ignore geli detach ${md} + atf_check -s exit:0 -e ignore -x \ + "cat passfile0 passfile1 | awk '{printf \"%s\", \$0}' | geli attach -j - -k keyfile0 -k keyfile1 ${md}" + atf_check -s exit:0 -e ignore geli detach ${md} + done +} +init_J_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +init_a_test() +{ cipher=$1 - secsize=$2 + aalgo=$2 + secsize=$3 ealgo=${cipher%%:*} keylen=${cipher##*:} - geli init -B none -e $ealgo -l $keylen -P -K $keyfile -s $secsize ${md} 2>/dev/null - geli attach -p -k $keyfile ${md} + atf_check -s exit:0 -e ignore geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile -s $secsize ${md} + atf_check geli attach -p -k keyfile ${md} secs=`diskinfo /dev/${md}.eli | awk '{print $4}'` - dd if=/dev/random of=${rnd} bs=${secsize} count=${secs} >/dev/null 2>&1 - dd if=${rnd} of=/dev/${md}.eli bs=${secsize} count=${secs} 2>/dev/null + atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${secs} status=none - md_rnd=`dd if=${rnd} bs=${secsize} count=${secs} 2>/dev/null | md5` - md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${secs} 2>/dev/null | md5` - md_edev=`dd if=/dev/${md} bs=${secsize} count=${secs} 2>/dev/null | md5` + md_rnd=`dd if=rnd bs=${secsize} count=${secs} status=none | md5` + atf_check_equal 0 $? + md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${secs} status=none | md5` + atf_check_equal 0 $? - if [ ${md_rnd} = ${md_ddev} ]; then - echo "ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}" - else - echo "not ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}" + if [ ${md_rnd} != ${md_ddev} ]; then + atf_fail "Miscompare for aalgo=${aalgo} ealgo=${ealgo} keylen=${keylen} sec=${secsize}" fi - i=$((i+1)) - if [ ${md_rnd} != ${md_edev} ]; then - echo "ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}" - else - echo "not ok $i - ealgo=${ealgo} keylen=${keylen} sec=${secsize}" +} +atf_test_case init_a cleanup +init_a_head() +{ + atf_set "descr" "I/O with geli and HMACs" + atf_set "require.user" "root" + atf_set "timeout" 3600 +} +init_a_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + atf_check dd if=/dev/random of=rnd bs=8192 count=${sectors} status=none + for_each_geli_config init_a_test + true +} +init_a_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +init_alias_test() { + ealgo=$1 + keylen=$2 + expected_ealgo=$3 + expected_keylen=$4 + + atf_check geli init -B none -e $ealgo -l $keylen -P -K keyfile ${md} + atf_check geli attach -p -k keyfile ${md} + real_ealgo=`geli list ${md}.eli | awk '/EncryptionAlgorithm/ {print $2}'` + real_keylen=`geli list ${md}.eli | awk '/KeyLength/ {print $2}'` + + if [ "${real_ealgo}" != "${expected_ealgo}" ]; then + atf_fail "expected ${expected_ealgo} but got ${real_ealgo}" fi - i=$((i+1)) + + if [ "${real_keylen}" != "${expected_keylen}" ]; then + atf_fail "expected ${expected_keylen} but got ${real_keylen}" + fi + atf_check geli detach ${md} } +atf_test_case init_alias cleanup +init_alias_head() +{ + atf_set "descr" "geli init accepts cipher aliases" + atf_set "require.user" "root" +} +init_alias_body() +{ + . $(atf_get_srcdir)/conf.sh -i=1 -dd if=/dev/random of=${keyfile} bs=512 count=16 >/dev/null 2>&1 -for_each_geli_config_nointegrity do_test + md=$(attach_md -t malloc -s 1024k) + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none -rm -f $rnd -rm -f $keyfile + for spec in aes:0:AES-XTS:128 aes:128:AES-XTS:128 aes:256:AES-XTS:256 \ + 3des:0:3DES-CBC:192 3des:192:3DES-CBC:192 \ + blowfish:0:Blowfish-CBC:128 blowfish:128:Blowfish-CBC:128 \ + blowfish:160:Blowfish-CBC:160 blowfish:192:Blowfish-CBC:192 \ + blowfish:224:Blowfish-CBC:224 blowfish:256:Blowfish-CBC:256 \ + blowfish:288:Blowfish-CBC:288 blowfish:352:Blowfish-CBC:352 \ + blowfish:384:Blowfish-CBC:384 blowfish:416:Blowfish-CBC:416 \ + blowfish:448:Blowfish-CBC:448 \ + camellia:0:CAMELLIA-CBC:128 camellia:128:CAMELLIA-CBC:128 \ + camellia:256:CAMELLIA-CBC:256 ; do + + ealgo=`echo $spec | cut -d : -f 1` + keylen=`echo $spec | cut -d : -f 2` + expected_ealgo=`echo $spec | cut -d : -f 3` + expected_keylen=`echo $spec | cut -d : -f 4` + + init_alias_test $ealgo $keylen $expected_ealgo $expected_keylen + done +} +init_alias_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +atf_test_case init_i_P cleanup +init_i_P_head() +{ + atf_set "descr" "geli: Options -i and -P are mutually exclusive" + atf_set "require.user" "root" +} +init_i_P_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + + atf_check -s exit:1 -e "match:Options -i and -P are mutually exclusive"\ + geli init -B none -i 64 -P -K keyfile $md +} +init_i_P_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +atf_init_test_cases() +{ + atf_add_test_case init + atf_add_test_case init_B + atf_add_test_case init_J + atf_add_test_case init_a + atf_add_test_case init_alias + atf_add_test_case init_i_P +} Added: head/tests/sys/geom/class/eli/integrity_test.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/geom/class/eli/integrity_test.sh Sun Jan 7 00:44:22 2018 (r327662) @@ -0,0 +1,160 @@ +# $FreeBSD$ + +copy_test() { + cipher=$1 + aalgo=$2 + secsize=$3 + ealgo=${cipher%%:*} + keylen=${cipher##*:} + + atf_check -s exit:0 -e ignore \ + geli init -B none -a $aalgo -e $ealgo -l $keylen -P \ + -K keyfile -s $secsize ${md} + atf_check geli attach -p -k keyfile ${md} + + atf_check dd if=/dev/random of=/dev/${md}.eli bs=${secsize} count=1 status=none + + atf_check geli detach ${md} + # Copy first small sector to the second small sector. + # This should be detected as corruption. + atf_check dd if=/dev/${md} of=sector bs=512 count=1 status=none + atf_check dd if=sector of=/dev/${md} bs=512 count=1 seek=1 status=none + atf_check geli attach -p -k keyfile ${md} + + atf_check -s not-exit:0 -e ignore \ + dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=1 + + # Fix the corruption + atf_check dd if=/dev/random of=/dev/${md}.eli bs=${secsize} count=2 status=none + atf_check dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=2 status=none + + # Copy first big sector to the second big sector. + # This should be detected as corruption. + ms=`diskinfo /dev/${md} | awk '{print $3 - 512}'` + ns=`diskinfo /dev/${md}.eli | awk '{print $4}'` + usecsize=`echo "($ms / $ns) - (($ms / $ns) % 512)" | bc` + atf_check geli detach ${md} + atf_check dd if=/dev/${md} bs=512 count=$(( ${usecsize} / 512 )) seek=$(( $secsize / 512 )) of=sector status=none + atf_check dd of=/dev/${md} bs=512 count=$(( ${usecsize} / 512 )) seek=$(( $secsize / 256 )) if=sector status=none + atf_check -s exit:0 -e ignore geli attach -p -k keyfile ${md} + atf_check -s not-exit:0 -e ignore \ + dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=$ns +} + +atf_test_case copy cleanup +copy_head() +{ + atf_set "descr" "geli will detect misdirected writes as corruption" + atf_set "require.user" "root" + atf_set "timeout" 3600 +} +copy_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=2 + + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + for_each_geli_config copy_test +} +copy_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + + +data_test() { + cipher=$1 + aalgo=$2 + secsize=$3 + ealgo=${cipher%%:*} + keylen=${cipher##*:} + + atf_check -s exit:0 -e ignore \ + geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \ + -s $secsize ${md} + + # Corrupt 8 bytes of data. + atf_check dd if=/dev/${md} of=sector bs=512 count=1 status=none + atf_check dd if=/dev/random of=sector bs=1 count=8 seek=64 conv=notrunc status=none + atf_check dd if=sector of=/dev/${md} bs=512 count=1 status=none + atf_check geli attach -p -k keyfile ${md} + + # Try to read from the corrupt sector + atf_check -s not-exit:0 -e ignore \ + dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=1 +} + +atf_test_case data cleanup +data_head() +{ + atf_set "descr" "With HMACs, geli will detect data corruption" + atf_set "require.user" "root" + atf_set "timeout" 1800 +} +data_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=2 + + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Sun Jan 7 01:06:06 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 445F5DFEAAA; Sun, 7 Jan 2018 01:06:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1E2D56B21D; Sun, 7 Jan 2018 01:06:06 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 690331A0A4; Sun, 7 Jan 2018 01:06:05 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w071650u056255; Sun, 7 Jan 2018 01:06:05 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07165K0056253; Sun, 7 Jan 2018 01:06:05 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801070106.w07165K0056253@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 7 Jan 2018 01:06:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327663 - in stable/11: . share/man/man7 X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11: . share/man/man7 X-SVN-Commit-Revision: 327663 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 01:06:06 -0000 Author: ian Date: Sun Jan 7 01:06:04 2018 New Revision: 327663 URL: https://svnweb.freebsd.org/changeset/base/327663 Log: MFC r327439: Allow use of .WAIT in the LOCAL_DIRS and LOCAL_LIB_DIRS lists. A comment in Makefile.inc1 has long stated that LOCAL_DIRS are built last, after the base system. Incremental improvements in parallel building over the years have led to LOCAL_DIRS being built in parallel with base system directories. This change allows the .WAIT directive to appear in LOCAL_DIRS and LOCAL_LIB_DIRS lists to give the user some control over parallel building of local additions. Differential Revision: https://reviews.freebsd.org/D13622 Modified: stable/11/Makefile.inc1 stable/11/share/man/man7/build.7 Directory Properties: stable/11/ (props changed) Modified: stable/11/Makefile.inc1 ============================================================================== --- stable/11/Makefile.inc1 Sun Jan 7 00:44:22 2018 (r327662) +++ stable/11/Makefile.inc1 Sun Jan 7 01:06:04 2018 (r327663) @@ -260,10 +260,11 @@ SUBDIR+= tests SUBDIR+=contrib/ofed .endif -# Local directories are last, since it is nice to at least get the base -# system rebuilt before you do them. +# Local directories are built in parallel with the base system directories. +# Users may insert a .WAIT directive at the beginning or elsewhere within +# the LOCAL_DIRS and LOCAL_LIB_DIRS lists as needed. .for _DIR in ${LOCAL_DIRS} -.if exists(${.CURDIR}/${_DIR}/Makefile) +.if ${_DIR} == ".WAIT" || exists(${.CURDIR}/${_DIR}/Makefile) SUBDIR+= ${_DIR} .endif .endfor @@ -274,7 +275,7 @@ SUBDIR+= ${_DIR} _REDUNDANT_LIB_DIRS+= ${LOCAL_LIB_DIRS:M${_DIR}*} .endfor .for _DIR in ${LOCAL_LIB_DIRS} -.if empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile) +.if ${_DIR} == ".WAIT" || (empty(_REDUNDANT_LIB_DIRS:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)) SUBDIR+= ${_DIR} .endif .endfor @@ -2146,7 +2147,7 @@ lib/liblzma__L: lib/libthr__L _generic_libs= ${_cddl_lib} gnu/lib ${_kerberos5_lib} lib ${_secure_lib} usr.bin/lex/lib ${_ofed_lib} .for _DIR in ${LOCAL_LIB_DIRS} -.if exists(${.CURDIR}/${_DIR}/Makefile) && empty(_generic_libs:M${_DIR}) +.if ${_DIR} == ".WAIT" || (empty(_generic_libs:M${_DIR}) && exists(${.CURDIR}/${_DIR}/Makefile)) _generic_libs+= ${_DIR} .endif .endfor Modified: stable/11/share/man/man7/build.7 ============================================================================== --- stable/11/share/man/man7/build.7 Sun Jan 7 00:44:22 2018 (r327662) +++ stable/11/share/man/man7/build.7 Sun Jan 7 01:06:04 2018 (r327663) @@ -441,6 +441,15 @@ If set, this variable supplies a list of additional di the root of the source tree to build as part of the .Cm everything target. +The directories are built in parallel with each other, +and with the base system directories. +Insert a +.Va .WAIT +directive at the beginning of the +.Va LOCAL_DIRS +list to ensure all base system directories are built first. +.Va .WAIT +may also be used as needed elsewhere within the list. .It Va LOCAL_ITOOLS If set, this variable supplies a list of additional tools that are used by the .Cm installworld @@ -452,6 +461,15 @@ If set, this variable supplies a list of additional di the root of the source tree to build as part of the .Cm libraries target. +The directories are built in parallel with each other, +and with the base system libraries. +Insert a +.Va .WAIT +directive at the beginning of the +.Va LOCAL_DIRS +list to ensure all base system libraries are built first. +.Va .WAIT +may also be used as needed elsewhere within the list. .It Va LOCAL_MTREE If set, this variable supplies a list of additional mtrees relative to the root of the source tree to use as part of the From owner-svn-src-all@freebsd.org Sun Jan 7 01:08:12 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1A9CADFED32; Sun, 7 Jan 2018 01:08:12 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D19586B3E9; Sun, 7 Jan 2018 01:08:11 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1F1CB1A0A6; Sun, 7 Jan 2018 01:08:11 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0718A80056362; Sun, 7 Jan 2018 01:08:10 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0718A6S056361; Sun, 7 Jan 2018 01:08:10 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801070108.w0718A6S056361@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 7 Jan 2018 01:08:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327664 - stable/11/share/man/man4 X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/share/man/man4 X-SVN-Commit-Revision: 327664 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 01:08:12 -0000 Author: ian Date: Sun Jan 7 01:08:10 2018 New Revision: 327664 URL: https://svnweb.freebsd.org/changeset/base/327664 Log: MFC r327226, r327356 r327226: Add a section describing how to tune ARM kernel options to use an MD_ROOT filesystem larger than about 50-55 MiB. The description of VM_KMEM_SIZE_SCALE is roughly as hand-wavy as my understanding of the option, but at least mentioning that it's a factor and giving an empirical datapoint that works will give folks some idea of what to tweak if they have problems. r327356: Correct a mistake and reword a couple sentences to clarify that "the value" refers to the scale value, not the kmem_arena size that results from scaling. Suggested by: alc@ Modified: stable/11/share/man/man4/md.4 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/md.4 ============================================================================== --- stable/11/share/man/man4/md.4 Sun Jan 7 01:06:04 2018 (r327663) +++ stable/11/share/man/man4/md.4 Sun Jan 7 01:08:10 2018 (r327664) @@ -7,7 +7,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 7, 2017 +.Dd December 26, 2017 .Dt MD 4 .Os .Sh NAME @@ -93,6 +93,47 @@ disk found in the .Xr mdconfig 8 man page. Other tools will also create these images, such as NanoBSD. +.Sh ARM KERNEL OPTIONS +On armv6 and armv7 architectures, an MD_ROOT image larger than +approximately 55 MiB may require building a custom kernel using +several tuning options related to kernel memory usage. +.Bl -tag -width indent +.It Cd options LOCORE_MAP_MB= +This configures how much memory is mapped for the kernel during +the early initialization stages. +The value must be at least as large as the kernel plus all preloaded +modules, including the root image. +There is no downside to setting this value too large, as long +as it does not exceed the amount of physical memory. +The default is 64 MiB. +.It Cd options NKPT2PG= +This configures the number of kernel L2 page table pages to +preallocate during kernel initialization. +Each L2 page can map 4 MiB of kernel space. +The value must be large enough to map the kernel plus all preloaded +modules, including the root image. +The default value is 32, which is sufficient to map 128 MiB. +.It Cd options VM_KMEM_SIZE_SCALE= +This configures the amount of kernel virtual address (KVA) space to +dedicate to the kmem_arena map. +The scale value is the ratio of physical to virtual pages. +The default value of 3 allocates a page of KVA for each 3 pages +of physical ram in the system. + +The kernel and modules, including the root image, also consume KVA. +The combination of a large root image and the default scaling +may preallocate so much KVA that there is not enough +remaining address space to allocate kernel stacks, IO buffers, +and other resources that are not part of kmem_arena. +Overallocating kmem_arena space is likely to manifest as failure to +launch userland processes with "cannot allocate kernel stack" messages. + +Setting the scale value too high may result in kernel failure to allocate +memory because kmem_arena is too small, and the failure may require +significant runtime to manifest. +Empirically, a value of 5 works well for a 200 MiB root image on +a system with 2 GiB of physical ram. +.El .Sh SEE ALSO .Xr gpart 8 , .Xr loader 8 , From owner-svn-src-all@freebsd.org Sun Jan 7 02:30:10 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43A55E5DBE8; Sun, 7 Jan 2018 02:30:10 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1F0816F053; Sun, 7 Jan 2018 02:30:10 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 75EE51B039; Sun, 7 Jan 2018 02:30:09 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w072U9EO089382; Sun, 7 Jan 2018 02:30:09 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w072U9FX089379; Sun, 7 Jan 2018 02:30:09 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201801070230.w072U9FX089379@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 7 Jan 2018 02:30:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327666 - head/tests/sys/geom/class/eli X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/tests/sys/geom/class/eli X-SVN-Commit-Revision: 327666 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 02:30:10 -0000 Author: asomers Date: Sun Jan 7 02:30:08 2018 New Revision: 327666 URL: https://svnweb.freebsd.org/changeset/base/327666 Log: geli: fix parallel execution of tests The trick is not to destroy an md(4) device during a test. That can create a "double-free" situation, because we also destroy md devices during test cleanup. MFC after: 2 weeks Modified: head/tests/sys/geom/class/eli/conf.sh head/tests/sys/geom/class/eli/init_test.sh head/tests/sys/geom/class/eli/onetime_test.sh Modified: head/tests/sys/geom/class/eli/conf.sh ============================================================================== --- head/tests/sys/geom/class/eli/conf.sh Sun Jan 7 02:19:54 2018 (r327665) +++ head/tests/sys/geom/class/eli/conf.sh Sun Jan 7 02:30:08 2018 (r327666) @@ -4,6 +4,7 @@ class="eli" base=$(atf_get ident) [ -z "$base" ] && base=`basename $0` # for TAP compatibility +MAX_SECSIZE=8192 TEST_MDS_FILE=md.devs attach_md() @@ -21,6 +22,11 @@ attach_md() for_each_geli_config() { func=$1 + # Double the sector size to allow for the HMACs' storage space. + osecsize=$(( $MAX_SECSIZE * 2 )) + # geli needs 512B for the label. + bytes=`expr $osecsize \* $sectors + 512`b + md=$(attach_md -t malloc -s $bytes) for cipher in aes-xts:128 aes-xts:256 \ aes-cbc:128 aes-cbc:192 aes-cbc:256 \ 3des-cbc:192 \ @@ -33,16 +39,9 @@ for_each_geli_config() { keylen=${cipher##*:} for aalgo in hmac/md5 hmac/sha1 hmac/ripemd160 hmac/sha256 \ hmac/sha384 hmac/sha512; do - for secsize in 512 1024 2048 4096 8192; do - # Double the requested sector size to allow - # for the HMACs' storage space. - osecsize=$(( $secsize * 2 )) - # geli needs 512B for the label. - bytes=`expr $osecsize \* $sectors + 512`b - md=$(attach_md -t malloc -s $bytes) + for secsize in 512 1024 2048 4096 $MAX_SECSIZE; do ${func} $cipher $aalgo $secsize geli detach ${md} 2>/dev/null - mdconfig -d -u ${md} 2>/dev/null done done done @@ -54,6 +53,9 @@ for_each_geli_config() { for_each_geli_config_nointegrity() { func=$1 + # geli needs 512B for the label. + bytes=`expr $MAX_SECSIZE \* $sectors + 512`b + md=$(attach_md -t malloc -s $bytes) for cipher in aes-xts:128 aes-xts:256 \ aes-cbc:128 aes-cbc:192 aes-cbc:256 \ 3des-cbc:192 \ @@ -64,13 +66,9 @@ for_each_geli_config_nointegrity() { camellia-cbc:128 camellia-cbc:192 camellia-cbc:256; do ealgo=${cipher%%:*} keylen=${cipher##*:} - for secsize in 512 1024 2048 4096 8192; do - # geli needs 512B for the label. - bytes=`expr $secsize \* $sectors + 512`b - md=$(attach_md -t malloc -s $bytes) + for secsize in 512 1024 2048 4096 $MAX_SECSIZE; do ${func} $cipher $secsize geli detach ${md} 2>/dev/null - mdconfig -d -u ${md} 2>/dev/null done done } Modified: head/tests/sys/geom/class/eli/init_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/init_test.sh Sun Jan 7 02:19:54 2018 (r327665) +++ head/tests/sys/geom/class/eli/init_test.sh Sun Jan 7 02:30:08 2018 (r327666) @@ -9,19 +9,18 @@ init_test() keylen=${cipher##*:} atf_check -s exit:0 -e ignore \ - geli init -B none -e $ealgo -l $keylen -P -K keyfile -s $secsize ${md} + geli init -B none -e $ealgo -l $keylen -P -K keyfile + -s $secsize ${md} atf_check geli attach -p -k keyfile ${md} - secs=`diskinfo /dev/${md}.eli | awk '{print $4}'` + atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} \ + status=none - atf_check dd if=/dev/random of=rnd bs=${secsize} count=${secs} status=none - atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${secs} status=none - - md_rnd=`dd if=rnd bs=${secsize} count=${secs} status=none | md5` + md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? - md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${secs} 2>/dev/null | md5` + md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? - md_edev=`dd if=/dev/${md} bs=${secsize} count=${secs} status=none | md5` + md_edev=`dd if=/dev/${md} bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? if [ ${md_rnd} != ${md_ddev} ]; then @@ -45,7 +44,8 @@ init_body() sectors=32 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none - atf_check dd if=/dev/random of=rnd bs=8192 count=${sectors} status=none + atf_check dd if=/dev/random of=rnd bs=$MAX_SECSIZE count=${sectors} \ + status=none for_each_geli_config_nointegrity init_test } init_cleanup() @@ -235,16 +235,16 @@ init_a_test() ealgo=${cipher%%:*} keylen=${cipher##*:} - atf_check -s exit:0 -e ignore geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile -s $secsize ${md} + atf_check -s exit:0 -e ignore \ + geli init -B none -a $aalgo -e $ealgo -l $keylen -P -K keyfile \ + -s $secsize ${md} atf_check geli attach -p -k keyfile ${md} - secs=`diskinfo /dev/${md}.eli | awk '{print $4}'` + atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} status=none - atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${secs} status=none - - md_rnd=`dd if=rnd bs=${secsize} count=${secs} status=none | md5` + md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? - md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${secs} status=none | md5` + md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? if [ ${md_rnd} != ${md_ddev} ]; then @@ -265,7 +265,8 @@ init_a_body() sectors=100 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none - atf_check dd if=/dev/random of=rnd bs=8192 count=${sectors} status=none + atf_check dd if=/dev/random of=rnd bs=$MAX_SECSIZE count=${sectors} \ + status=none for_each_geli_config init_a_test true } @@ -348,7 +349,7 @@ init_i_P_body() atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none - atf_check -s exit:1 -e "match:Options -i and -P are mutually exclusive"\ + atf_check -s not-exit:0 -e "match:Options -i and -P are mutually exclusive"\ geli init -B none -i 64 -P -K keyfile $md } init_i_P_cleanup() Modified: head/tests/sys/geom/class/eli/onetime_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/onetime_test.sh Sun Jan 7 02:19:54 2018 (r327665) +++ head/tests/sys/geom/class/eli/onetime_test.sh Sun Jan 7 02:30:08 2018 (r327666) @@ -10,16 +10,14 @@ onetime_test() atf_check -s exit:0 -o ignore -e ignore \ geli onetime -e $ealgo -l $keylen -s $secsize ${md} - secs=`diskinfo /dev/${md}.eli | awk '{print $4}'` + atf_check dd if=/dev/random of=rnd bs=${secsize} count=${sectors} status=none + atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} status=none - atf_check dd if=/dev/random of=rnd bs=${secsize} count=${secs} status=none - atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${secs} status=none - - md_rnd=`dd if=rnd bs=${secsize} count=${secs} status=none | md5` + md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? - md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${secs} status=none | md5` + md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? - md_edev=`dd if=/dev/${md} bs=${secsize} count=${secs} status=none | md5` + md_edev=`dd if=/dev/${md} bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? if [ ${md_rnd} != ${md_ddev} ]; then @@ -41,6 +39,7 @@ onetime_body() . $(atf_get_srcdir)/conf.sh sectors=100 + dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none for_each_geli_config_nointegrity onetime_test } onetime_cleanup() @@ -60,13 +59,11 @@ onetime_a_test() atf_check -s exit:0 -o ignore -e ignore \ geli onetime -a $aalgo -e $ealgo -l $keylen -s $secsize ${md} - secs=`diskinfo /dev/${md}.eli | awk '{print $4}'` + atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} status=none - atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${secs} status=none - - md_rnd=`dd if=rnd bs=${secsize} count=${secs} status=none | md5` + md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? - md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${secs} status=none | md5` + md_ddev=`dd if=/dev/${md}.eli bs=${secsize} count=${sectors} status=none | md5` atf_check_equal 0 $? if [ ${md_rnd} != ${md_ddev} ]; then From owner-svn-src-all@freebsd.org Sun Jan 7 02:19:55 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AA4F7E5D185; Sun, 7 Jan 2018 02:19:55 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 856826EB0D; Sun, 7 Jan 2018 02:19:55 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A918D1AE67; Sun, 7 Jan 2018 02:19:54 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w072JskF085252; Sun, 7 Jan 2018 02:19:54 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w072Jsx2085251; Sun, 7 Jan 2018 02:19:54 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201801070219.w072Jsx2085251@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 7 Jan 2018 02:19:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327665 - head/sys/dev/extres/syscon X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/dev/extres/syscon X-SVN-Commit-Revision: 327665 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 02:19:55 -0000 Author: kevans Date: Sun Jan 7 02:19:54 2018 New Revision: 327665 URL: https://svnweb.freebsd.org/changeset/base/327665 Log: Fix bogus pass for syscon_generic introduced in r327621 ian@ pointed out that BUS_PASS_DEFAULT + $anything is bogus, given that BUS_PASS_DEFAULT is defined as __INT_MAX. Instead, we take a page out of imx6_usbphy's book and use BUS_PASS_DEFAULT - 1000 to achieve the desired effect of syscon_generic attaching before if_awg and other potential consumers, but late enough that more specialized implementations should have no problem attaching instead. Reported by: ian Modified: head/sys/dev/extres/syscon/syscon_generic.c Modified: head/sys/dev/extres/syscon/syscon_generic.c ============================================================================== --- head/sys/dev/extres/syscon/syscon_generic.c Sun Jan 7 01:08:10 2018 (r327664) +++ head/sys/dev/extres/syscon/syscon_generic.c Sun Jan 7 02:19:54 2018 (r327665) @@ -206,6 +206,11 @@ static device_method_t syscon_generic_dmethods[] = { DEFINE_CLASS_0(syscon_generic, syscon_generic_driver, syscon_generic_dmethods, sizeof(struct syscon_generic_softc)); static devclass_t syscon_generic_devclass; +/* + * syscon_generic needs to attach before other devices that may require it, such + * as if_awg, but later than others to give way for more specialized syscon + * implementations. + */ EARLY_DRIVER_MODULE(syscon_generic, simplebus, syscon_generic_driver, - syscon_generic_devclass, 0, 0, BUS_PASS_DEFAULT + BUS_PASS_ORDER_FIRST); + syscon_generic_devclass, 0, 0, BUS_PASS_DEFAULT - 1000); MODULE_VERSION(syscon_generic, 1); From owner-svn-src-all@freebsd.org Sun Jan 7 03:31:56 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D85D3E6213C; Sun, 7 Jan 2018 03:31:56 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B3FC3722D7; Sun, 7 Jan 2018 03:31:56 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0B0CC1BCD4; Sun, 7 Jan 2018 03:31:56 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w073VtWL019149; Sun, 7 Jan 2018 03:31:55 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w073Vttb019148; Sun, 7 Jan 2018 03:31:55 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201801070331.w073Vttb019148@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 7 Jan 2018 03:31:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327669 - head/sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/arm/allwinner X-SVN-Commit-Revision: 327669 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 03:31:57 -0000 Author: kevans Date: Sun Jan 7 03:31:55 2018 New Revision: 327669 URL: https://svnweb.freebsd.org/changeset/base/327669 Log: aw_sid: Add method for reading keys via prctl registers Technically supported on the later SoCs, this will only really be used to add support for the H3 sid. The H3 has a silicon bug that manifests itself by returning garbled rootkeys unless first read via the prctl registers. Modified: head/sys/arm/allwinner/aw_sid.c Modified: head/sys/arm/allwinner/aw_sid.c ============================================================================== --- head/sys/arm/allwinner/aw_sid.c Sun Jan 7 02:59:27 2018 (r327668) +++ head/sys/arm/allwinner/aw_sid.c Sun Jan 7 03:31:55 2018 (r327669) @@ -39,6 +39,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include #include @@ -48,6 +50,16 @@ __FBSDID("$FreeBSD$"); #include +/* efuse registers */ +#define SID_PRCTL 0x40 +#define SID_PRCTL_OFFSET_MASK 0xff +#define SID_PRCTL_OFFSET(n) (((n) & SID_PRCTL_OFFSET_MASK) << 16) +#define SID_PRCTL_LOCK (0xac << 8) +#define SID_PRCTL_READ (0x01 << 1) +#define SID_PRCTL_WRITE (0x01 << 0) +#define SID_PRKEY 0x50 +#define SID_RDKEY 0x60 + #define SID_SRAM 0x200 #define SID_THERMAL_CALIB0 (SID_SRAM + 0x34) #define SID_THERMAL_CALIB1 (SID_SRAM + 0x38) @@ -56,6 +68,7 @@ __FBSDID("$FreeBSD$"); struct aw_sid_conf { bus_size_t rootkey_offset; + bool has_prctl; bool has_thermal; }; @@ -69,11 +82,13 @@ static const struct aw_sid_conf a20_conf = { static const struct aw_sid_conf a64_conf = { .rootkey_offset = SID_SRAM, + .has_prctl = true, .has_thermal = true, }; static const struct aw_sid_conf a83t_conf = { .rootkey_offset = SID_SRAM, + .has_prctl = true, .has_thermal = true, }; @@ -88,6 +103,7 @@ static struct ofw_compat_data compat_data[] = { struct aw_sid_softc { struct resource *res; struct aw_sid_conf *sid_conf; + struct mtx prctl_mtx; }; static struct aw_sid_softc *aw_sid_sc; @@ -105,8 +121,37 @@ enum sid_keys { #define WR4(sc, reg, val) bus_write_4((sc)->res, (reg), (val)) static int aw_sid_sysctl(SYSCTL_HANDLER_ARGS); +static int aw_sid_prctl_read(device_t dev, bus_size_t offset, uint32_t *val); + +/* + * offset here is offset into efuse space, rather than offset into sid register + * space. This form of read is only an option for newer SoC: A83t, H3, A64 + */ static int +aw_sid_prctl_read(device_t dev, bus_size_t offset, uint32_t *val) +{ + struct aw_sid_softc *sc; + uint32_t readval; + + sc = device_get_softc(dev); + if (!sc->sid_conf->has_prctl) + return (1); + + mtx_lock(&sc->prctl_mtx); + readval = SID_PRCTL_OFFSET(offset) | SID_PRCTL_LOCK | SID_PRCTL_READ; + WR4(sc, SID_PRCTL, readval); + /* Read bit will be cleared once read has concluded */ + while (RD4(sc, SID_PRCTL) & SID_PRCTL_READ) + continue; + readval = RD4(sc, SID_RDKEY); + mtx_unlock(&sc->prctl_mtx); + *val = readval; + + return (0); +} + +static int aw_sid_probe(device_t dev) { if (!ofw_bus_status_okay(dev)) @@ -131,8 +176,9 @@ aw_sid_attach(device_t dev) return (ENXIO); } - aw_sid_sc = sc; + mtx_init(&sc->prctl_mtx, device_get_nameunit(dev), NULL, MTX_DEF); sc->sid_conf = (struct aw_sid_conf *)ofw_bus_search_compatible(dev, compat_data)->ocd_data; + aw_sid_sc = sc; SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), From owner-svn-src-all@freebsd.org Sun Jan 7 02:57:37 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 76ED6E5FCA5; Sun, 7 Jan 2018 02:57:37 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 52AD070512; Sun, 7 Jan 2018 02:57:37 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 80C4B1B5B8; Sun, 7 Jan 2018 02:57:36 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w072vaDT001922; Sun, 7 Jan 2018 02:57:36 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w072vaBA001919; Sun, 7 Jan 2018 02:57:36 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801070257.w072vaBA001919@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 7 Jan 2018 02:57:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327667 - in stable/11/sys: arm/arm conf X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11/sys: arm/arm conf X-SVN-Commit-Revision: 327667 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 02:57:37 -0000 Author: ian Date: Sun Jan 7 02:57:35 2018 New Revision: 327667 URL: https://svnweb.freebsd.org/changeset/base/327667 Log: MFC r327222: Add a new ARM kernel option, LOCORE_MAP_MB, to control the size of the kernel VA mapping in the temporary page tables set up by locore-v6.S. The number used to be hard-coded to 64MB, which is still the default if the kernel option is not specified. However, 64MB is insufficient for using a large mdroot filesystem. The hard-coded number can't be safely increased because too large a number may run into memory-mapped IO space on some SoCs that must not be mapped as ordinary memory. Modified: stable/11/sys/arm/arm/genassym.c stable/11/sys/arm/arm/locore-v6.S stable/11/sys/conf/options.arm Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/arm/genassym.c ============================================================================== --- stable/11/sys/arm/arm/genassym.c Sun Jan 7 02:30:08 2018 (r327666) +++ stable/11/sys/arm/arm/genassym.c Sun Jan 7 02:57:35 2018 (r327667) @@ -161,3 +161,12 @@ ASSYM(DCACHE_LINE_SIZE, offsetof(struct cpuinfo, dcach ASSYM(DCACHE_LINE_MASK, offsetof(struct cpuinfo, dcache_line_mask)); ASSYM(ICACHE_LINE_SIZE, offsetof(struct cpuinfo, icache_line_size)); ASSYM(ICACHE_LINE_MASK, offsetof(struct cpuinfo, icache_line_mask)); + +/* + * Emit the LOCORE_MAP_MB option as a #define only if the option was set. + */ +#include "opt_locore.h" + +#ifdef LOCORE_MAP_MB +ASSYM(LOCORE_MAP_MB, LOCORE_MAP_MB); +#endif Modified: stable/11/sys/arm/arm/locore-v6.S ============================================================================== --- stable/11/sys/arm/arm/locore-v6.S Sun Jan 7 02:30:08 2018 (r327666) +++ stable/11/sys/arm/arm/locore-v6.S Sun Jan 7 02:57:35 2018 (r327667) @@ -38,6 +38,10 @@ __FBSDID("$FreeBSD$"); +/* We map 64MB of kernel unless overridden in assym.s by the kernel option. */ +#ifndef LOCORE_MAP_MB +#define LOCORE_MAP_MB 64 +#endif #if __ARM_ARCH >= 7 #if defined(__ARM_ARCH_7VE__) || defined(__clang__) @@ -172,12 +176,13 @@ ASENTRY_NP(_start) bl build_pagetables /* - * Next we do 64MiB starting at the physical load address, mapped to - * the VA the kernel is linked for. + * Next we map the kernel starting at the physical load address, mapped + * to the VA the kernel is linked for. The default size we map is 64MiB + * but it can be overridden with a kernel option. */ mov r1, r5 ldr r2, =(KERNVIRTADDR) - mov r3, #64 + ldr r3, =(LOCORE_MAP_MB) bl build_pagetables /* Create a device mapping for early_printf if specified. */ Modified: stable/11/sys/conf/options.arm ============================================================================== --- stable/11/sys/conf/options.arm Sun Jan 7 02:30:08 2018 (r327666) +++ stable/11/sys/conf/options.arm Sun Jan 7 02:57:35 2018 (r327667) @@ -34,6 +34,7 @@ KERNVIRTADDR opt_global.h LINUX_BOOT_ABI opt_global.h LOADERRAMADDR opt_global.h MULTIDELAY opt_global.h +LOCORE_MAP_MB opt_locore.h PHYSADDR opt_global.h PLATFORM opt_global.h PLATFORM_SMP opt_global.h From owner-svn-src-all@freebsd.org Sun Jan 7 02:59:29 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CF6DEE5FE52; Sun, 7 Jan 2018 02:59:29 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A81E2706B9; Sun, 7 Jan 2018 02:59:29 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 556571B5D3; Sun, 7 Jan 2018 02:59:27 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w072xR2k002028; Sun, 7 Jan 2018 02:59:27 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w072xR7V002027; Sun, 7 Jan 2018 02:59:27 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801070259.w072xR7V002027@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 7 Jan 2018 02:59:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327668 - stable/11/share/man/man4 X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: stable/11/share/man/man4 X-SVN-Commit-Revision: 327668 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 02:59:29 -0000 Author: ian Date: Sun Jan 7 02:59:27 2018 New Revision: 327668 URL: https://svnweb.freebsd.org/changeset/base/327668 Log: MFC r327220-r327221 r327220: Update the FDT example for the lm75 sensor to match current devicetree standards and what the existing driver expects. Also change 'like' to 'such as' where the text is providing an example rather than a simile. r327221: Complete the changing of the old "i2c-address" property to the modern "reg" property by updating the description text to match the updated example. This should have been part of r327220 Modified: stable/11/share/man/man4/lm75.4 Directory Properties: stable/11/ (props changed) Modified: stable/11/share/man/man4/lm75.4 ============================================================================== --- stable/11/share/man/man4/lm75.4 Sun Jan 7 02:57:35 2018 (r327667) +++ stable/11/share/man/man4/lm75.4 Sun Jan 7 02:59:27 2018 (r327668) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 11, 2014 +.Dd December 26, 2017 .Dt LM75 4 .Os .Sh NAME @@ -122,7 +122,7 @@ clones may not work reliably. .Pp On a .Xr device.hints 5 -based system, like +based system, such as .Li MIPS , these values are configurable for .Nm : @@ -140,31 +140,28 @@ i2c address on the .Pp On a .Xr FDT 4 -based system, like +based system, such as .Li ARM , the DTS part for a .Nm device usually looks like: .Bd -literal i2c { - + /* Properties describing the controller appear here. */ ... - - lm750 { + lm750@49 { compatible = "national,lm75"; - i2c-address = <0x49>; + reg = <0x49>; }; }; .Ed .Pp Where: -.Bl -tag -width ".Va i2c-address" +.Bl -tag -width ".Va compatible" .It Va compatible Should always be set to "national,lm75". -.It Va i2c-address -The -.Va i2c-address -property indicates which i2c address the +.It Va reg +Indicates which 7-bit i2c address the .Nm is wired at. .Nm From owner-svn-src-all@freebsd.org Sun Jan 7 04:59:29 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8A6F0E68822; Sun, 7 Jan 2018 04:59:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CFCF76668; Sun, 7 Jan 2018 04:59:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9568A1CA61; Sun, 7 Jan 2018 04:59:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w074xSb5052268; Sun, 7 Jan 2018 04:59:28 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w074xSaZ052266; Sun, 7 Jan 2018 04:59:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201801070459.w074xSaZ052266@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 7 Jan 2018 04:59:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327670 - in head: share/man/man4 sys/arm/allwinner X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head: share/man/man4 sys/arm/allwinner X-SVN-Commit-Revision: 327670 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 04:59:29 -0000 Author: kevans Date: Sun Jan 7 04:59:28 2018 New Revision: 327670 URL: https://svnweb.freebsd.org/changeset/base/327670 Log: aw_sid(4): Add support for Allwinner H3 The sid controller on the H3 is generally identical in location, size, and efuse offset to the a64 and the a83t. The main difference is that the H3 has a silicon bug that sometimes causes the rootkey (at least) to be garbled unless first read by the prctl registers. This device is currently not in our DTS and, as of now, is not yet present in mainline Linux DTS. Tested on: OrangePi One Modified: head/share/man/man4/aw_sid.4 head/sys/arm/allwinner/aw_sid.c Modified: head/share/man/man4/aw_sid.4 ============================================================================== --- head/share/man/man4/aw_sid.4 Sun Jan 7 03:31:55 2018 (r327669) +++ head/share/man/man4/aw_sid.4 Sun Jan 7 04:59:28 2018 (r327670) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 2, 2018 +.Dd January 6, 2018 .Dt AW_SID 4 .Os .Sh NAME @@ -52,6 +52,8 @@ allwinner,sun7i-a20-sid allwinner,sun50i-a64-sid .It allwinner,sun8i-a83t-sid +.It +allwinner,sun8i-h3-sid .El .Sh SYSCTL VARIABLES The following read-only variables are available via Modified: head/sys/arm/allwinner/aw_sid.c ============================================================================== --- head/sys/arm/allwinner/aw_sid.c Sun Jan 7 03:31:55 2018 (r327669) +++ head/sys/arm/allwinner/aw_sid.c Sun Jan 7 04:59:28 2018 (r327670) @@ -67,36 +67,51 @@ __FBSDID("$FreeBSD$"); #define ROOT_KEY_SIZE 4 struct aw_sid_conf { + bus_size_t efuse_size; bus_size_t rootkey_offset; bool has_prctl; bool has_thermal; + bool requires_prctl_read; }; static const struct aw_sid_conf a10_conf = { + .efuse_size = 0x10, .rootkey_offset = 0, }; static const struct aw_sid_conf a20_conf = { + .efuse_size = 0x10, .rootkey_offset = 0, }; static const struct aw_sid_conf a64_conf = { + .efuse_size = 0x100, .rootkey_offset = SID_SRAM, .has_prctl = true, .has_thermal = true, }; static const struct aw_sid_conf a83t_conf = { + .efuse_size = 0x100, .rootkey_offset = SID_SRAM, .has_prctl = true, .has_thermal = true, }; +static const struct aw_sid_conf h3_conf = { + .efuse_size = 0x100, + .rootkey_offset = SID_SRAM, + .has_prctl = true, + .has_thermal = true, + .requires_prctl_read = true, +}; + static struct ofw_compat_data compat_data[] = { { "allwinner,sun4i-a10-sid", (uintptr_t)&a10_conf}, { "allwinner,sun7i-a20-sid", (uintptr_t)&a20_conf}, { "allwinner,sun50i-a64-sid", (uintptr_t)&a64_conf}, { "allwinner,sun8i-a83t-sid", (uintptr_t)&a83t_conf}, + { "allwinner,sun8i-h3-sid", (uintptr_t)&h3_conf}, { NULL, 0 } }; @@ -168,6 +183,8 @@ static int aw_sid_attach(device_t dev) { struct aw_sid_softc *sc; + bus_size_t i; + uint32_t val; sc = device_get_softc(dev); @@ -179,6 +196,19 @@ aw_sid_attach(device_t dev) mtx_init(&sc->prctl_mtx, device_get_nameunit(dev), NULL, MTX_DEF); sc->sid_conf = (struct aw_sid_conf *)ofw_bus_search_compatible(dev, compat_data)->ocd_data; aw_sid_sc = sc; + + /* + * This set of reads is solely for working around a silicon bug on some + * SoC that require a prctl read in order for direct register access to + * return a non-garbled value. Hence, the values we read are simply + * ignored. + */ + if (sc->sid_conf->requires_prctl_read) + for (i = 0; i < sc->sid_conf->efuse_size; i += 4) + if (aw_sid_prctl_read(dev, i, &val) != 0) { + device_printf(dev, "failed prctl read\n"); + return (ENXIO); + } SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), From owner-svn-src-all@freebsd.org Sun Jan 7 05:38:54 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 719CAE6A6FC; Sun, 7 Jan 2018 05:38:54 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4E23977A1E; Sun, 7 Jan 2018 05:38:54 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8EE771D0F5; Sun, 7 Jan 2018 05:38:53 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w075croB068640; Sun, 7 Jan 2018 05:38:53 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w075crox068639; Sun, 7 Jan 2018 05:38:53 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201801070538.w075crox068639@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Sun, 7 Jan 2018 05:38:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327671 - head/sbin/ldconfig X-SVN-Group: head X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: head/sbin/ldconfig X-SVN-Commit-Revision: 327671 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 05:38:54 -0000 Author: eadler Date: Sun Jan 7 05:38:53 2018 New Revision: 327671 URL: https://svnweb.freebsd.org/changeset/base/327671 Log: ldconfig(8): clarify language for files The previous language did not make it clear that 'Files' are the files specified above. Clarify it. Reported by: dana Reviewed by: dana MFC After: 1 week Modified: head/sbin/ldconfig/ldconfig.8 Modified: head/sbin/ldconfig/ldconfig.8 ============================================================================== --- head/sbin/ldconfig/ldconfig.8 Sun Jan 7 04:59:28 2018 (r327670) +++ head/sbin/ldconfig/ldconfig.8 Sun Jan 7 05:38:53 2018 (r327671) @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 19, 2013 +.Dd January 6, 2018 .Dt LDCONFIG 8 .Os .Sh NAME @@ -58,7 +58,9 @@ the overhead that would otherwise result from the dire operations the dynamic linker would have to perform to load the required shared libraries. .Pp -Files named on the command line are expected to contain directories +Alternatively, +.Ar files +may be specified; these are expected to contain directories to scan for shared libraries. Each directory's pathname must start on a new line. From owner-svn-src-all@freebsd.org Sun Jan 7 07:09:01 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2BEFEE5AC5D; Sun, 7 Jan 2018 07:09:01 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 07C4A7A369; Sun, 7 Jan 2018 07:09:01 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 52AFB1DF5C; Sun, 7 Jan 2018 07:09:00 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07790gr005800; Sun, 7 Jan 2018 07:09:00 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07790UI005799; Sun, 7 Jan 2018 07:09:00 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201801070709.w07790UI005799@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sun, 7 Jan 2018 07:09:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327672 - head/bin/cat X-SVN-Group: head X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: head/bin/cat X-SVN-Commit-Revision: 327672 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 07:09:01 -0000 Author: delphij Date: Sun Jan 7 07:08:59 2018 New Revision: 327672 URL: https://svnweb.freebsd.org/changeset/base/327672 Log: stddef.h is not used by cat.c, remove the include. Modified: head/bin/cat/cat.c Modified: head/bin/cat/cat.c ============================================================================== --- head/bin/cat/cat.c Sun Jan 7 05:38:53 2018 (r327671) +++ head/bin/cat/cat.c Sun Jan 7 07:08:59 2018 (r327672) @@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include From owner-svn-src-all@freebsd.org Sun Jan 7 09:55:48 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 76CC1E63218; Sun, 7 Jan 2018 09:55:48 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.blih.net", Issuer "mail.blih.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4EB9D7F58B; Sun, 7 Jan 2018 09:55:46 +0000 (UTC) (envelope-from manu@bidouilliste.com) Received: from mail.blih.net (mail.blih.net [212.83.177.182]) by mail.blih.net (OpenSMTPD) with ESMTP id a1694042; Sun, 7 Jan 2018 10:55:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=bidouilliste.com; h= mime-version:content-type:content-transfer-encoding:date:from:to :cc:subject:in-reply-to:references:message-id; s=mail; bh=dHeQsY 7JicdZxRCIelLgf25sbjk=; b=rMkd/Sygcmhsz2xMbEp43iQXHALIKLGRsI8z3w oZDOJeQzeJFYdtFr29Lfh+n0tvou8ds7cdA0PotQsLTW9Iqnv1vXzNDxSQWmtsA3 8+dzpiH0H4j97+aos22Lnov3MRUhMTtyqIeRTkzf4UmPPkRfs6x9icE4Hlbl1FrZ UPPBM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=bidouilliste.com; h= mime-version:content-type:content-transfer-encoding:date:from:to :cc:subject:in-reply-to:references:message-id; q=dns; s=mail; b= b9sxhBxdh5Ac73OKf2bLQvRodiDhiL3qkhYVBfhLLBhseSA9G2glbiaMQuJP3VgF 0GFi8jBMrATQC5Gz+n4DUj0nOs0iUUl3uYLY91mAW8oxgSwGq4Y5jEX/5M0fGy07 iNVNSjGsVAKQI5rIxiHhMpGrTfqVdvmUlcjLbmBsOEY= Received: from webmail.megadrive.org (www1.blih.net [212.83.177.180]) by mail.blih.net (OpenSMTPD) with ESMTP id 9c75bae9; Sun, 7 Jan 2018 10:55:44 +0100 (CET) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sun, 07 Jan 2018 10:55:43 +0100 From: Emmanuel Vadot To: Kyle Evans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org, owner-src-committers@freebsd.org Subject: Re: svn commit: r327665 - head/sys/dev/extres/syscon Organization: Bidouilliste In-Reply-To: <201801070219.w072Jsx2085251@repo.freebsd.org> References: <201801070219.w072Jsx2085251@repo.freebsd.org> Message-ID: X-Sender: manu@bidouilliste.com User-Agent: Roundcube Webmail/1.1.1 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 09:55:48 -0000 On 2018-01-07 03:19, Kyle Evans wrote: > Author: kevans > Date: Sun Jan 7 02:19:54 2018 > New Revision: 327665 > URL: https://svnweb.freebsd.org/changeset/base/327665 > > Log: > Fix bogus pass for syscon_generic introduced in r327621 > > ian@ pointed out that BUS_PASS_DEFAULT + $anything is bogus, given > that > BUS_PASS_DEFAULT is defined as __INT_MAX. Instead, we take a page out > of > imx6_usbphy's book and use BUS_PASS_DEFAULT - 1000 to achieve the > desired > effect of syscon_generic attaching before if_awg and other potential > consumers, but late enough that more specialized implementations > should have > no problem attaching instead. > > Reported by: ian > > Modified: > head/sys/dev/extres/syscon/syscon_generic.c > > Modified: head/sys/dev/extres/syscon/syscon_generic.c > ============================================================================== > --- head/sys/dev/extres/syscon/syscon_generic.c Sun Jan 7 01:08:10 > 2018 (r327664) > +++ head/sys/dev/extres/syscon/syscon_generic.c Sun Jan 7 02:19:54 > 2018 (r327665) > @@ -206,6 +206,11 @@ static device_method_t syscon_generic_dmethods[] = > { > DEFINE_CLASS_0(syscon_generic, syscon_generic_driver, > syscon_generic_dmethods, > sizeof(struct syscon_generic_softc)); > static devclass_t syscon_generic_devclass; > +/* > + * syscon_generic needs to attach before other devices that may > require it, such > + * as if_awg, but later than others to give way for more specialized > syscon > + * implementations. > + */ I think that the comment should be more generic, syscon_generic will only be match for the "syscon" compatible, if a driver needs to attach at a specific pass, it should be subclassed and use the other compatible in the node. All the syscon node I've seen always have a specific compatible and a fallback to "syscon". > EARLY_DRIVER_MODULE(syscon_generic, simplebus, syscon_generic_driver, > - syscon_generic_devclass, 0, 0, BUS_PASS_DEFAULT + > BUS_PASS_ORDER_FIRST); > + syscon_generic_devclass, 0, 0, BUS_PASS_DEFAULT - 1000); > MODULE_VERSION(syscon_generic, 1); -- Emmanuel Vadot From owner-svn-src-all@freebsd.org Sun Jan 7 10:29:17 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0A875E647DA; Sun, 7 Jan 2018 10:29:17 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D8A8080608; Sun, 7 Jan 2018 10:29:16 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 219FF1FF83; Sun, 7 Jan 2018 10:29:16 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07ATGeq088777; Sun, 7 Jan 2018 10:29:16 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07ATFRV088776; Sun, 7 Jan 2018 10:29:15 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201801071029.w07ATFRV088776@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sun, 7 Jan 2018 10:29:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327673 - stable/11/usr.bin/ctlstat X-SVN-Group: stable-11 X-SVN-Commit-Author: bapt X-SVN-Commit-Paths: stable/11/usr.bin/ctlstat X-SVN-Commit-Revision: 327673 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 10:29:17 -0000 Author: bapt Date: Sun Jan 7 10:29:15 2018 New Revision: 327673 URL: https://svnweb.freebsd.org/changeset/base/327673 Log: MFC r326769: Remove hard coded number of lun definition The number of lun exposed is now exposed via sysctl by the kernel. Use that number in ctlstat instead of the hardcoded version Add a backward compatibility in case the sysctl(2) request fails. This also allows ctlstat -l 1118 to actually work when having more than 1024 luns. Reviewed by: avg, manu (both before the backward compatibility addition) Approved by: avg, manu (both before the backward compatibility addition) Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D13446 Modified: stable/11/usr.bin/ctlstat/ctlstat.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/ctlstat/ctlstat.c ============================================================================== --- stable/11/usr.bin/ctlstat/ctlstat.c Sun Jan 7 07:08:59 2018 (r327672) +++ stable/11/usr.bin/ctlstat/ctlstat.c Sun Jan 7 10:29:15 2018 (r327673) @@ -72,12 +72,7 @@ __FBSDID("$FreeBSD$"); */ #define CTL_STAT_NUM_ITEMS 256 -/* - * The default number of LUN selection bits we allocate. This is large - * because we don't currently increase it if the user specifies a LUN - * number of 1024 or larger. - */ -#define CTL_STAT_BITS 1024L +static int ctl_stat_bits; static const char *ctlstat_opts = "Cc:Ddhjl:n:p:tw:"; static const char *ctlstat_usage = "Usage: ctlstat [-CDdjht] [-l lunnum]" @@ -125,7 +120,7 @@ struct ctlstat_context { struct ctl_cpu_stats cur_cpu, prev_cpu; uint64_t cur_total_jiffies, prev_total_jiffies; uint64_t cur_idle, prev_idle; - bitstr_t bit_decl(item_mask, CTL_STAT_BITS); + bitstr_t *item_mask; int cur_items, prev_items; int cur_alloc, prev_alloc; int numdevs; @@ -429,7 +424,7 @@ ctlstat_standard(struct ctlstat_context *ctx) { (F_TIMEVAL(ctx) != 0) ? " " : ""); n = 3; } else { - for (i = n = 0; i < min(CTL_STAT_BITS, + for (i = n = 0; i < min(ctl_stat_bits, ctx->cur_items); i++) { int item; @@ -537,7 +532,7 @@ ctlstat_standard(struct ctlstat_context *ctx) { dmas_per_sec[i], mbsec[i]); } } else { - for (i = n = 0; i < min(CTL_STAT_BITS, ctx->cur_items); i++) { + for (i = n = 0; i < min(ctl_stat_bits, ctx->cur_items); i++) { long double mbsec, kb_per_transfer; long double transfers_per_sec; long double ms_per_transfer; @@ -580,6 +575,7 @@ main(int argc, char **argv) int c; int count, waittime; int fd, retval; + size_t size; struct ctlstat_context ctx; struct ctl_io_stats *tmp_stats; @@ -594,6 +590,16 @@ main(int argc, char **argv) ctx.flags |= CTLSTAT_FLAG_FIRST_RUN; ctx.flags |= CTLSTAT_FLAG_HEADER; + size = sizeof(ctl_stat_bits); + if (sysctlbyname("kern.cam.ctl.max_luns", &ctl_stat_bits, &size, NULL, + 0) == -1) { + /* Backward compatibility for where the sysctl wasn't exposed */ + ctl_stat_bits = 1024; + } + ctx.item_mask = bit_alloc(ctl_stat_bits); + if (ctx.item_mask == NULL) + err(1, "bit_alloc() failed"); + while ((c = getopt(argc, argv, ctlstat_opts)) != -1) { switch (c) { case 'C': @@ -620,7 +626,7 @@ main(int argc, char **argv) int cur_lun; cur_lun = atoi(optarg); - if (cur_lun > CTL_STAT_BITS) + if (cur_lun > ctl_stat_bits) errx(1, "Invalid LUN number %d", cur_lun); if (!F_MASK(&ctx)) @@ -639,7 +645,7 @@ main(int argc, char **argv) int cur_port; cur_port = atoi(optarg); - if (cur_port > CTL_STAT_BITS) + if (cur_port > ctl_stat_bits) errx(1, "Invalid port number %d", cur_port); if (!F_MASK(&ctx)) From owner-svn-src-all@freebsd.org Sun Jan 7 13:21:03 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4D559E6CFF4; Sun, 7 Jan 2018 13:21:03 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 288653099; Sun, 7 Jan 2018 13:21:03 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7C49421BA5; Sun, 7 Jan 2018 13:21:02 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07DL2JZ064477; Sun, 7 Jan 2018 13:21:02 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07DL2hN064072; Sun, 7 Jan 2018 13:21:02 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201801071321.w07DL2hN064072@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 7 Jan 2018 13:21:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327674 - in head: share/man/man9 sys/kern sys/sys X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: in head: share/man/man9 sys/kern sys/sys X-SVN-Commit-Revision: 327674 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 13:21:03 -0000 Author: kp Date: Sun Jan 7 13:21:01 2018 New Revision: 327674 URL: https://svnweb.freebsd.org/changeset/base/327674 Log: Introduce mallocarray() in the kernel Similar to calloc() the mallocarray() function checks for integer overflows before allocating memory. It does not zero memory, unless the M_ZERO flag is set. Reviewed by: pfg, vangyzen (previous version), imp (previous version) Obtained from: OpenBSD Differential Revision: https://reviews.freebsd.org/D13766 Modified: head/share/man/man9/malloc.9 head/sys/kern/kern_malloc.c head/sys/sys/malloc.h Modified: head/share/man/man9/malloc.9 ============================================================================== --- head/share/man/man9/malloc.9 Sun Jan 7 10:29:15 2018 (r327673) +++ head/share/man/man9/malloc.9 Sun Jan 7 13:21:01 2018 (r327674) @@ -45,6 +45,8 @@ .In sys/malloc.h .Ft void * .Fn malloc "unsigned long size" "struct malloc_type *type" "int flags" +.Ft void * +.Fn mallocarray "size_t nmemb" "size_t size" "struct malloc_type *type" "int flags" .Ft void .Fn free "void *addr" "struct malloc_type *type" .Ft void * @@ -64,6 +66,14 @@ object whose size is specified by .Fa size . .Pp The +.Fn mallocarray +function allocates uninitialized memory in kernel address space for an +array of +.Fa nmemb +entries whose size is specified by +.Fa size . +.Pp +The .Fn free function releases memory at address .Fa addr @@ -152,6 +162,15 @@ functions cannot return if .Dv M_WAITOK is specified. +The +.Fn mallocarray +function can return +.Dv NULL +if the multiplication of +.Fa nmemb +and +.Fa size +would cause an integer overflow. .It Dv M_USE_RESERVE Indicates that the system can use its reserve of memory to satisfy the request. Modified: head/sys/kern/kern_malloc.c ============================================================================== --- head/sys/kern/kern_malloc.c Sun Jan 7 10:29:15 2018 (r327673) +++ head/sys/kern/kern_malloc.c Sun Jan 7 13:21:01 2018 (r327674) @@ -4,6 +4,7 @@ * Copyright (c) 1987, 1991, 1993 * The Regents of the University of California. * Copyright (c) 2005-2009 Robert N. M. Watson + * Copyright (c) 2008 Otto Moerbeek (mallocarray) * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -532,6 +533,22 @@ malloc(unsigned long size, struct malloc_type *mtp, in va = redzone_setup(va, osize); #endif return ((void *) va); +} + +/* + * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX + * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW + */ +#define MUL_NO_OVERFLOW (1UL << (sizeof(size_t) * 8 / 2)) +void * +mallocarray(size_t nmemb, size_t size, struct malloc_type *type, int flags) +{ + + if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && + nmemb > 0 && SIZE_MAX / nmemb < size) + return (NULL); + + return (malloc(size * nmemb, type, flags)); } /* Modified: head/sys/sys/malloc.h ============================================================================== --- head/sys/sys/malloc.h Sun Jan 7 10:29:15 2018 (r327673) +++ head/sys/sys/malloc.h Sun Jan 7 13:21:01 2018 (r327674) @@ -177,6 +177,9 @@ void *contigmalloc(unsigned long size, struct malloc_t void free(void *addr, struct malloc_type *type); void *malloc(unsigned long size, struct malloc_type *type, int flags) __malloc_like __result_use_check __alloc_size(1); +void *mallocarray(size_t nmemb, size_t size, struct malloc_type *type, + int flags) __malloc_like __result_use_check + __alloc_size(1) __alloc_size(2); void malloc_init(void *); int malloc_last_fail(void); void malloc_type_allocated(struct malloc_type *type, unsigned long size); From owner-svn-src-all@freebsd.org Sun Jan 7 13:35:16 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 895C7E6DAED; Sun, 7 Jan 2018 13:35:16 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 507AC3AB2; Sun, 7 Jan 2018 13:35:16 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7A68421DC9; Sun, 7 Jan 2018 13:35:15 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07DZFDw069855; Sun, 7 Jan 2018 13:35:15 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07DZFWh069854; Sun, 7 Jan 2018 13:35:15 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201801071335.w07DZFWh069854@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 7 Jan 2018 13:35:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327675 - head/sys/netpfil/pf X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/sys/netpfil/pf X-SVN-Commit-Revision: 327675 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 13:35:16 -0000 Author: kp Date: Sun Jan 7 13:35:15 2018 New Revision: 327675 URL: https://svnweb.freebsd.org/changeset/base/327675 Log: pf: Avoid integer overflow issues by using mallocarray() iso. malloc() pfioctl() handles several ioctl that takes variable length input, these include: - DIOCRADDTABLES - DIOCRDELTABLES - DIOCRGETTABLES - DIOCRGETTSTATS - DIOCRCLRTSTATS - DIOCRSETTFLAGS All of them take a pfioc_table struct as input from userland. One of its elements (pfrio_size) is used in a buffer length calculation. The calculation contains an integer overflow which if triggered can lead to out of bound reads and writes later on. Reported by: Ilja Van Sprundel Modified: head/sys/netpfil/pf/pf_ioctl.c Modified: head/sys/netpfil/pf/pf_ioctl.c ============================================================================== --- head/sys/netpfil/pf/pf_ioctl.c Sun Jan 7 13:21:01 2018 (r327674) +++ head/sys/netpfil/pf/pf_ioctl.c Sun Jan 7 13:35:15 2018 (r327675) @@ -2531,7 +2531,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_table); - pfrts = malloc(totlen, M_TEMP, M_WAITOK); + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), + M_TEMP, M_WAITOK); + if (! pfrts) { + error = ENOMEM; + break; + } error = copyin(io->pfrio_buffer, pfrts, totlen); if (error) { free(pfrts, M_TEMP); @@ -2555,7 +2560,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_table); - pfrts = malloc(totlen, M_TEMP, M_WAITOK); + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), + M_TEMP, M_WAITOK); + if (! pfrts) { + error = ENOMEM; + break; + } error = copyin(io->pfrio_buffer, pfrts, totlen); if (error) { free(pfrts, M_TEMP); @@ -2579,7 +2589,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_table); - pfrts = malloc(totlen, M_TEMP, M_WAITOK); + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), + M_TEMP, M_WAITOK); + if (! pfrts) { + error = ENOMEM; + break; + } PF_RULES_RLOCK(); error = pfr_get_tables(&io->pfrio_table, pfrts, &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); @@ -2600,7 +2615,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_tstats); - pfrtstats = malloc(totlen, M_TEMP, M_WAITOK); + pfrtstats = mallocarray(io->pfrio_size, + sizeof(struct pfr_tstats), M_TEMP, M_WAITOK); + if (! pfrtstats) { + error = ENOMEM; + break; + } PF_RULES_WLOCK(); error = pfr_get_tstats(&io->pfrio_table, pfrtstats, &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); @@ -2621,7 +2641,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_table); - pfrts = malloc(totlen, M_TEMP, M_WAITOK); + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), + M_TEMP, M_WAITOK); + if (! pfrts) { + error = ENOMEM; + break; + } error = copyin(io->pfrio_buffer, pfrts, totlen); if (error) { free(pfrts, M_TEMP); @@ -2645,7 +2670,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_table); - pfrts = malloc(totlen, M_TEMP, M_WAITOK); + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), + M_TEMP, M_WAITOK); + if (! pfrts) { + error = ENOMEM; + break; + } error = copyin(io->pfrio_buffer, pfrts, totlen); if (error) { free(pfrts, M_TEMP); @@ -2684,7 +2714,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_addr); - pfras = malloc(totlen, M_TEMP, M_WAITOK); + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), + M_TEMP, M_WAITOK); + if (! pfras) { + error = ENOMEM; + break; + } error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -2711,7 +2746,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_addr); - pfras = malloc(totlen, M_TEMP, M_WAITOK); + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), + M_TEMP, M_WAITOK); + if (! pfras) { + error = ENOMEM; + break; + } error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -2739,7 +2779,12 @@ DIOCCHANGEADDR_error: } count = max(io->pfrio_size, io->pfrio_size2); totlen = count * sizeof(struct pfr_addr); - pfras = malloc(totlen, M_TEMP, M_WAITOK); + pfras = mallocarray(count, sizeof(struct pfr_addr), M_TEMP, + M_WAITOK); + if (! pfras) { + error = ENOMEM; + break; + } error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -2767,7 +2812,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_addr); - pfras = malloc(totlen, M_TEMP, M_WAITOK); + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), + M_TEMP, M_WAITOK); + if (! pfras) { + error = ENOMEM; + break; + } PF_RULES_RLOCK(); error = pfr_get_addrs(&io->pfrio_table, pfras, &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); @@ -2788,7 +2838,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_astats); - pfrastats = malloc(totlen, M_TEMP, M_WAITOK); + pfrastats = mallocarray(io->pfrio_size, + sizeof(struct pfr_astats), M_TEMP, M_WAITOK); + if (! pfrastats) { + error = ENOMEM; + break; + } PF_RULES_RLOCK(); error = pfr_get_astats(&io->pfrio_table, pfrastats, &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); @@ -2809,7 +2864,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_addr); - pfras = malloc(totlen, M_TEMP, M_WAITOK); + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), + M_TEMP, M_WAITOK); + if (! pfras) { + error = ENOMEM; + break; + } error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -2836,7 +2896,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_addr); - pfras = malloc(totlen, M_TEMP, M_WAITOK); + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), + M_TEMP, M_WAITOK); + if (! pfras) { + error = ENOMEM; + break; + } error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -2863,7 +2928,12 @@ DIOCCHANGEADDR_error: break; } totlen = io->pfrio_size * sizeof(struct pfr_addr); - pfras = malloc(totlen, M_TEMP, M_WAITOK); + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), + M_TEMP, M_WAITOK); + if (! pfras) { + error = ENOMEM; + break; + } error = copyin(io->pfrio_buffer, pfras, totlen); if (error) { free(pfras, M_TEMP); @@ -2905,7 +2975,12 @@ DIOCCHANGEADDR_error: break; } totlen = sizeof(struct pfioc_trans_e) * io->size; - ioes = malloc(totlen, M_TEMP, M_WAITOK); + ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), + M_TEMP, M_WAITOK); + if (! ioes) { + error = ENOMEM; + break; + } error = copyin(io->array, ioes, totlen); if (error) { free(ioes, M_TEMP); @@ -2971,7 +3046,12 @@ DIOCCHANGEADDR_error: break; } totlen = sizeof(struct pfioc_trans_e) * io->size; - ioes = malloc(totlen, M_TEMP, M_WAITOK); + ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), + M_TEMP, M_WAITOK); + if (! ioes) { + error = ENOMEM; + break; + } error = copyin(io->array, ioes, totlen); if (error) { free(ioes, M_TEMP); @@ -3037,7 +3117,12 @@ DIOCCHANGEADDR_error: break; } totlen = sizeof(struct pfioc_trans_e) * io->size; - ioes = malloc(totlen, M_TEMP, M_WAITOK); + ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), + M_TEMP, M_WAITOK); + if (! ioes) { + error = ENOMEM; + break; + } error = copyin(io->array, ioes, totlen); if (error) { free(ioes, M_TEMP); @@ -3238,7 +3323,12 @@ DIOCCHANGEADDR_error: } bufsiz = io->pfiio_size * sizeof(struct pfi_kif); - ifstore = malloc(bufsiz, M_TEMP, M_WAITOK); + ifstore = mallocarray(io->pfiio_size, sizeof(struct pfi_kif), + M_TEMP, M_WAITOK); + if (! ifstore) { + error = ENOMEM; + break; + } PF_RULES_RLOCK(); pfi_get_ifaces(io->pfiio_name, ifstore, &io->pfiio_size); PF_RULES_RUNLOCK(); From owner-svn-src-all@freebsd.org Sun Jan 7 13:39:13 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BEE9DE6DD2B; Sun, 7 Jan 2018 13:39:13 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9977D3C6B; Sun, 7 Jan 2018 13:39:13 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CB4B421DCA; Sun, 7 Jan 2018 13:39:12 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07DdCrN070033; Sun, 7 Jan 2018 13:39:12 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07DdCaX070032; Sun, 7 Jan 2018 13:39:12 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201801071339.w07DdCaX070032@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 7 Jan 2018 13:39:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327676 - head/sys/compat/linuxkpi/common/include/linux X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/sys/compat/linuxkpi/common/include/linux X-SVN-Commit-Revision: 327676 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 13:39:13 -0000 Author: kp Date: Sun Jan 7 13:39:12 2018 New Revision: 327676 URL: https://svnweb.freebsd.org/changeset/base/327676 Log: linuxkpi: Implement kcalloc() based on mallocarray() This means we now get integer overflow protection, which Linux code might expect as it is also provided by kcalloc() in Linux. Modified: head/sys/compat/linuxkpi/common/include/linux/slab.h Modified: head/sys/compat/linuxkpi/common/include/linux/slab.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 13:35:15 2018 (r327675) +++ head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 13:39:12 2018 (r327676) @@ -46,7 +46,6 @@ MALLOC_DECLARE(M_KMALLOC); #define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO) #define kzalloc_node(size, flags, node) kmalloc(size, (flags) | __GFP_ZERO) #define kfree_const(ptr) kfree(ptr) -#define kcalloc(n, size, flags) kmalloc((n) * (size), (flags) | __GFP_ZERO) #define vzalloc(size) __vmalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, 0) #define vfree(arg) kfree(arg) #define kvfree(arg) kfree(arg) @@ -98,6 +97,13 @@ static inline void * kmalloc(size_t size, gfp_t flags) { return (malloc(size, M_KMALLOC, linux_check_m_flags(flags))); +} + +static inline void * +kcalloc(size_t n, size_t size, gfp_t flags) +{ + flags |= __GFP_ZERO; + return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags))); } static inline void * From owner-svn-src-all@freebsd.org Sun Jan 7 13:41:07 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1CA2E6DFF3; Sun, 7 Jan 2018 13:41:07 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7B93C3FCE; Sun, 7 Jan 2018 13:41:07 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AD6CA21DF9; Sun, 7 Jan 2018 13:41:06 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07Df6ID070846; Sun, 7 Jan 2018 13:41:06 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07Df62R070845; Sun, 7 Jan 2018 13:41:06 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201801071341.w07Df62R070845@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Sun, 7 Jan 2018 13:41:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327677 - head/sys/contrib/vchiq/interface/compat X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/sys/contrib/vchiq/interface/compat X-SVN-Commit-Revision: 327677 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 13:41:07 -0000 Author: kp Date: Sun Jan 7 13:41:06 2018 New Revision: 327677 URL: https://svnweb.freebsd.org/changeset/base/327677 Log: vchiq: Use mallocarray() to provide kcalloc() This means we now also provide integer overflow protection, like the Linux kcalloc(). Modified: head/sys/contrib/vchiq/interface/compat/vchi_bsd.h Modified: head/sys/contrib/vchiq/interface/compat/vchi_bsd.h ============================================================================== --- head/sys/contrib/vchiq/interface/compat/vchi_bsd.h Sun Jan 7 13:39:12 2018 (r327676) +++ head/sys/contrib/vchiq/interface/compat/vchi_bsd.h Sun Jan 7 13:41:06 2018 (r327677) @@ -329,7 +329,8 @@ device_rlprintf(int pps, device_t dev, const char *fmt MALLOC_DECLARE(M_VCHI); #define kmalloc(size, flags) malloc((size), M_VCHI, M_NOWAIT | M_ZERO) -#define kcalloc(n, size, flags) malloc((n) * (size), M_VCHI, M_NOWAIT | M_ZERO) +#define kcalloc(n, size, flags) mallocarray((n), (size), M_VCHI, \ + M_NOWAIT | M_ZERO) #define kzalloc(a, b) kcalloc(1, (a), (b)) #define kfree(p) free(p, M_VCHI) From owner-svn-src-all@freebsd.org Sun Jan 7 14:44:33 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A70F0E706FF; Sun, 7 Jan 2018 14:44:33 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B7B4691D0; Sun, 7 Jan 2018 14:44:33 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w07EiNVx027025 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sun, 7 Jan 2018 16:44:26 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w07EiNVx027025 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w07EiNY4027024; Sun, 7 Jan 2018 16:44:23 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sun, 7 Jan 2018 16:44:23 +0200 From: Konstantin Belousov To: Kristof Provost Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r327675 - head/sys/netpfil/pf Message-ID: <20180107144423.GD1684@kib.kiev.ua> References: <201801071335.w07DZFWh069854@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201801071335.w07DZFWh069854@repo.freebsd.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 14:44:33 -0000 On Sun, Jan 07, 2018 at 01:35:15PM +0000, Kristof Provost wrote: > Author: kp > Date: Sun Jan 7 13:35:15 2018 > New Revision: 327675 > URL: https://svnweb.freebsd.org/changeset/base/327675 > > Log: > pf: Avoid integer overflow issues by using mallocarray() iso. malloc() > > pfioctl() handles several ioctl that takes variable length input, these > include: > - DIOCRADDTABLES > - DIOCRDELTABLES > - DIOCRGETTABLES > - DIOCRGETTSTATS > - DIOCRCLRTSTATS > - DIOCRSETTFLAGS > > All of them take a pfioc_table struct as input from userland. One of > its elements (pfrio_size) is used in a buffer length calculation. > The calculation contains an integer overflow which if triggered can lead > to out of bound reads and writes later on. So the size of the allocation is controlled directly from the userspace ? This is an easy DoS, and by itself is perhaps bigger issue than the overflow. > > Reported by: Ilja Van Sprundel > > Modified: > head/sys/netpfil/pf/pf_ioctl.c > > Modified: head/sys/netpfil/pf/pf_ioctl.c > ============================================================================== > --- head/sys/netpfil/pf/pf_ioctl.c Sun Jan 7 13:21:01 2018 (r327674) > +++ head/sys/netpfil/pf/pf_ioctl.c Sun Jan 7 13:35:15 2018 (r327675) > @@ -2531,7 +2531,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_table); > - pfrts = malloc(totlen, M_TEMP, M_WAITOK); > + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), > + M_TEMP, M_WAITOK); > + if (! pfrts) { > + error = ENOMEM; > + break; > + } > error = copyin(io->pfrio_buffer, pfrts, totlen); > if (error) { > free(pfrts, M_TEMP); > @@ -2555,7 +2560,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_table); > - pfrts = malloc(totlen, M_TEMP, M_WAITOK); > + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), > + M_TEMP, M_WAITOK); > + if (! pfrts) { > + error = ENOMEM; > + break; > + } > error = copyin(io->pfrio_buffer, pfrts, totlen); > if (error) { > free(pfrts, M_TEMP); > @@ -2579,7 +2589,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_table); > - pfrts = malloc(totlen, M_TEMP, M_WAITOK); > + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), > + M_TEMP, M_WAITOK); > + if (! pfrts) { > + error = ENOMEM; > + break; > + } > PF_RULES_RLOCK(); > error = pfr_get_tables(&io->pfrio_table, pfrts, > &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); > @@ -2600,7 +2615,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_tstats); > - pfrtstats = malloc(totlen, M_TEMP, M_WAITOK); > + pfrtstats = mallocarray(io->pfrio_size, > + sizeof(struct pfr_tstats), M_TEMP, M_WAITOK); > + if (! pfrtstats) { > + error = ENOMEM; > + break; > + } > PF_RULES_WLOCK(); > error = pfr_get_tstats(&io->pfrio_table, pfrtstats, > &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); > @@ -2621,7 +2641,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_table); > - pfrts = malloc(totlen, M_TEMP, M_WAITOK); > + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), > + M_TEMP, M_WAITOK); > + if (! pfrts) { > + error = ENOMEM; > + break; > + } > error = copyin(io->pfrio_buffer, pfrts, totlen); > if (error) { > free(pfrts, M_TEMP); > @@ -2645,7 +2670,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_table); > - pfrts = malloc(totlen, M_TEMP, M_WAITOK); > + pfrts = mallocarray(io->pfrio_size, sizeof(struct pfr_table), > + M_TEMP, M_WAITOK); > + if (! pfrts) { > + error = ENOMEM; > + break; > + } > error = copyin(io->pfrio_buffer, pfrts, totlen); > if (error) { > free(pfrts, M_TEMP); > @@ -2684,7 +2714,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_addr); > - pfras = malloc(totlen, M_TEMP, M_WAITOK); > + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), > + M_TEMP, M_WAITOK); > + if (! pfras) { > + error = ENOMEM; > + break; > + } > error = copyin(io->pfrio_buffer, pfras, totlen); > if (error) { > free(pfras, M_TEMP); > @@ -2711,7 +2746,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_addr); > - pfras = malloc(totlen, M_TEMP, M_WAITOK); > + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), > + M_TEMP, M_WAITOK); > + if (! pfras) { > + error = ENOMEM; > + break; > + } > error = copyin(io->pfrio_buffer, pfras, totlen); > if (error) { > free(pfras, M_TEMP); > @@ -2739,7 +2779,12 @@ DIOCCHANGEADDR_error: > } > count = max(io->pfrio_size, io->pfrio_size2); > totlen = count * sizeof(struct pfr_addr); > - pfras = malloc(totlen, M_TEMP, M_WAITOK); > + pfras = mallocarray(count, sizeof(struct pfr_addr), M_TEMP, > + M_WAITOK); > + if (! pfras) { > + error = ENOMEM; > + break; > + } > error = copyin(io->pfrio_buffer, pfras, totlen); > if (error) { > free(pfras, M_TEMP); > @@ -2767,7 +2812,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_addr); > - pfras = malloc(totlen, M_TEMP, M_WAITOK); > + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), > + M_TEMP, M_WAITOK); > + if (! pfras) { > + error = ENOMEM; > + break; > + } > PF_RULES_RLOCK(); > error = pfr_get_addrs(&io->pfrio_table, pfras, > &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); > @@ -2788,7 +2838,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_astats); > - pfrastats = malloc(totlen, M_TEMP, M_WAITOK); > + pfrastats = mallocarray(io->pfrio_size, > + sizeof(struct pfr_astats), M_TEMP, M_WAITOK); > + if (! pfrastats) { > + error = ENOMEM; > + break; > + } > PF_RULES_RLOCK(); > error = pfr_get_astats(&io->pfrio_table, pfrastats, > &io->pfrio_size, io->pfrio_flags | PFR_FLAG_USERIOCTL); > @@ -2809,7 +2864,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_addr); > - pfras = malloc(totlen, M_TEMP, M_WAITOK); > + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), > + M_TEMP, M_WAITOK); > + if (! pfras) { > + error = ENOMEM; > + break; > + } > error = copyin(io->pfrio_buffer, pfras, totlen); > if (error) { > free(pfras, M_TEMP); > @@ -2836,7 +2896,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_addr); > - pfras = malloc(totlen, M_TEMP, M_WAITOK); > + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), > + M_TEMP, M_WAITOK); > + if (! pfras) { > + error = ENOMEM; > + break; > + } > error = copyin(io->pfrio_buffer, pfras, totlen); > if (error) { > free(pfras, M_TEMP); > @@ -2863,7 +2928,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = io->pfrio_size * sizeof(struct pfr_addr); > - pfras = malloc(totlen, M_TEMP, M_WAITOK); > + pfras = mallocarray(io->pfrio_size, sizeof(struct pfr_addr), > + M_TEMP, M_WAITOK); > + if (! pfras) { > + error = ENOMEM; > + break; > + } > error = copyin(io->pfrio_buffer, pfras, totlen); > if (error) { > free(pfras, M_TEMP); > @@ -2905,7 +2975,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = sizeof(struct pfioc_trans_e) * io->size; > - ioes = malloc(totlen, M_TEMP, M_WAITOK); > + ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), > + M_TEMP, M_WAITOK); > + if (! ioes) { > + error = ENOMEM; > + break; > + } > error = copyin(io->array, ioes, totlen); > if (error) { > free(ioes, M_TEMP); > @@ -2971,7 +3046,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = sizeof(struct pfioc_trans_e) * io->size; > - ioes = malloc(totlen, M_TEMP, M_WAITOK); > + ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), > + M_TEMP, M_WAITOK); > + if (! ioes) { > + error = ENOMEM; > + break; > + } > error = copyin(io->array, ioes, totlen); > if (error) { > free(ioes, M_TEMP); > @@ -3037,7 +3117,12 @@ DIOCCHANGEADDR_error: > break; > } > totlen = sizeof(struct pfioc_trans_e) * io->size; > - ioes = malloc(totlen, M_TEMP, M_WAITOK); > + ioes = mallocarray(io->size, sizeof(struct pfioc_trans_e), > + M_TEMP, M_WAITOK); > + if (! ioes) { > + error = ENOMEM; > + break; > + } > error = copyin(io->array, ioes, totlen); > if (error) { > free(ioes, M_TEMP); > @@ -3238,7 +3323,12 @@ DIOCCHANGEADDR_error: > } > > bufsiz = io->pfiio_size * sizeof(struct pfi_kif); > - ifstore = malloc(bufsiz, M_TEMP, M_WAITOK); > + ifstore = mallocarray(io->pfiio_size, sizeof(struct pfi_kif), > + M_TEMP, M_WAITOK); > + if (! ifstore) { > + error = ENOMEM; > + break; > + } > PF_RULES_RLOCK(); > pfi_get_ifaces(io->pfiio_name, ifstore, &io->pfiio_size); > PF_RULES_RUNLOCK(); From owner-svn-src-all@freebsd.org Sun Jan 7 16:24:35 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 26297E748E1; Sun, 7 Jan 2018 16:24:35 +0000 (UTC) (envelope-from srs0=cu0q=ec=freebsd.org=kp@codepro.be) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.codepro.be", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E2ACE6CF27; Sun, 7 Jan 2018 16:24:34 +0000 (UTC) (envelope-from srs0=cu0q=ec=freebsd.org=kp@codepro.be) Received: from [10.0.2.164] (ptr-8ripyyhthbnp0l0tszn.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:2419:4e02:e0f1:72a1:d72b:ec03]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id EB44EAC73; Sun, 7 Jan 2018 17:24:31 +0100 (CET) From: "Kristof Provost" To: "Konstantin Belousov" Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r327675 - head/sys/netpfil/pf Date: Sun, 07 Jan 2018 17:25:02 +0100 X-Mailer: MailMate (2.0BETAr6102) Message-ID: In-Reply-To: <20180107144423.GD1684@kib.kiev.ua> References: <201801071335.w07DZFWh069854@repo.freebsd.org> <20180107144423.GD1684@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 16:24:35 -0000 On 7 Jan 2018, at 15:44, Konstantin Belousov wrote: > On Sun, Jan 07, 2018 at 01:35:15PM +0000, Kristof Provost wrote: >> Author: kp >> Date: Sun Jan 7 13:35:15 2018 >> New Revision: 327675 >> URL: https://svnweb.freebsd.org/changeset/base/327675 >> >> Log: >> pf: Avoid integer overflow issues by using mallocarray() iso. >> malloc() >> >> pfioctl() handles several ioctl that takes variable length input, >> these >> include: >> - DIOCRADDTABLES >> - DIOCRDELTABLES >> - DIOCRGETTABLES >> - DIOCRGETTSTATS >> - DIOCRCLRTSTATS >> - DIOCRSETTFLAGS >> >> All of them take a pfioc_table struct as input from userland. One >> of >> its elements (pfrio_size) is used in a buffer length calculation. >> The calculation contains an integer overflow which if triggered can >> lead >> to out of bound reads and writes later on. > So the size of the allocation is controlled directly from the > userspace ? > This is an easy DoS, and by itself is perhaps bigger issue than the > overflow. Yes, although only as root. I’m not sure what the best way of handling that would be. It’s not easy to determine limits for these sizes. Any arbitrary value might break someone’s use case. OpenBSD tend to copy in individual entries one at a time. This avoids having to allocate memory for all of them in one go, but I don’t like mixing user pointers and kernel pointers. It’s far too easy to lose track of what’s been copied in and what’s still in user space. Regards, Kristof From owner-svn-src-all@freebsd.org Sun Jan 7 17:55:14 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D7F26E783BD; Sun, 7 Jan 2018 17:55:14 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A781F702FC; Sun, 7 Jan 2018 17:55:14 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w07HtCFJ017656; Sun, 7 Jan 2018 09:55:12 -0800 (PST) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w07HtCAU017655; Sun, 7 Jan 2018 09:55:12 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201801071755.w07HtCAU017655@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r327674 - in head: share/man/man9 sys/kern sys/sys In-Reply-To: <201801071321.w07DL2hN064072@repo.freebsd.org> To: Kristof Provost Date: Sun, 7 Jan 2018 09:55:12 -0800 (PST) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 17:55:14 -0000 [ Charset UTF-8 unsupported, converting... ] > Author: kp > Date: Sun Jan 7 13:21:01 2018 > New Revision: 327674 > URL: https://svnweb.freebsd.org/changeset/base/327674 > > Log: > Introduce mallocarray() in the kernel > > Similar to calloc() the mallocarray() function checks for integer > overflows before allocating memory. > It does not zero memory, unless the M_ZERO flag is set. > > Reviewed by: pfg, vangyzen (previous version), imp (previous version) > Obtained from: OpenBSD > Differential Revision: https://reviews.freebsd.org/D13766 > > Modified: > head/share/man/man9/malloc.9 > head/sys/kern/kern_malloc.c > head/sys/sys/malloc.h > > Modified: head/share/man/man9/malloc.9 > ============================================================================== > --- head/share/man/man9/malloc.9 Sun Jan 7 10:29:15 2018 (r327673) > +++ head/share/man/man9/malloc.9 Sun Jan 7 13:21:01 2018 (r327674) > @@ -45,6 +45,8 @@ > .In sys/malloc.h > .Ft void * > .Fn malloc "unsigned long size" "struct malloc_type *type" "int flags" > +.Ft void * > +.Fn mallocarray "size_t nmemb" "size_t size" "struct malloc_type *type" "int flags" > .Ft void > .Fn free "void *addr" "struct malloc_type *type" > .Ft void * > @@ -64,6 +66,14 @@ object whose size is specified by > .Fa size . > .Pp > The > +.Fn mallocarray > +function allocates uninitialized memory in kernel address space for an > +array of > +.Fa nmemb > +entries whose size is specified by > +.Fa size . > +.Pp > +The > .Fn free > function releases memory at address > .Fa addr > @@ -152,6 +162,15 @@ functions cannot return > if > .Dv M_WAITOK > is specified. > +The > +.Fn mallocarray > +function can return > +.Dv NULL > +if the multiplication of > +.Fa nmemb > +and > +.Fa size > +would cause an integer overflow. > .It Dv M_USE_RESERVE > Indicates that the system can use its reserve of memory to satisfy the > request. > > Modified: head/sys/kern/kern_malloc.c > ============================================================================== > --- head/sys/kern/kern_malloc.c Sun Jan 7 10:29:15 2018 (r327673) > +++ head/sys/kern/kern_malloc.c Sun Jan 7 13:21:01 2018 (r327674) > @@ -4,6 +4,7 @@ > * Copyright (c) 1987, 1991, 1993 > * The Regents of the University of California. > * Copyright (c) 2005-2009 Robert N. M. Watson > + * Copyright (c) 2008 Otto Moerbeek (mallocarray) Is this code really over a decade old???? or is this a typo? > * All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > @@ -532,6 +533,22 @@ malloc(unsigned long size, struct malloc_type *mtp, in > va = redzone_setup(va, osize); > #endif > return ((void *) va); > +} > + > +/* > + * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX > + * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW > + */ > +#define MUL_NO_OVERFLOW (1UL << (sizeof(size_t) * 8 / 2)) > +void * > +mallocarray(size_t nmemb, size_t size, struct malloc_type *type, int flags) > +{ > + > + if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && > + nmemb > 0 && SIZE_MAX / nmemb < size) > + return (NULL); > + > + return (malloc(size * nmemb, type, flags)); > } > > /* > > Modified: head/sys/sys/malloc.h > ============================================================================== > --- head/sys/sys/malloc.h Sun Jan 7 10:29:15 2018 (r327673) > +++ head/sys/sys/malloc.h Sun Jan 7 13:21:01 2018 (r327674) > @@ -177,6 +177,9 @@ void *contigmalloc(unsigned long size, struct malloc_t > void free(void *addr, struct malloc_type *type); > void *malloc(unsigned long size, struct malloc_type *type, int flags) > __malloc_like __result_use_check __alloc_size(1); > +void *mallocarray(size_t nmemb, size_t size, struct malloc_type *type, > + int flags) __malloc_like __result_use_check > + __alloc_size(1) __alloc_size(2); > void malloc_init(void *); > int malloc_last_fail(void); > void malloc_type_allocated(struct malloc_type *type, unsigned long size); > > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Sun Jan 7 18:00:47 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43D88E788BC; Sun, 7 Jan 2018 18:00:47 +0000 (UTC) (envelope-from srs0=cu0q=ec=freebsd.org=kp@codepro.be) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.codepro.be", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0CCA670704; Sun, 7 Jan 2018 18:00:46 +0000 (UTC) (envelope-from srs0=cu0q=ec=freebsd.org=kp@codepro.be) Received: from [10.0.2.164] (ptr-8ripyyhthbnp0l0tszn.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:2419:4e02:e0f1:72a1:d72b:ec03]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 1D862ADE1; Sun, 7 Jan 2018 19:00:44 +0100 (CET) From: "Kristof Provost" To: rgrimes@freebsd.org Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r327674 - in head: share/man/man9 sys/kern sys/sys Date: Sun, 07 Jan 2018 19:00:43 +0100 X-Mailer: MailMate (2.0BETAr6102) Message-ID: <89EADF3F-DFCB-4EE7-8FE6-5129B77411EB@FreeBSD.org> In-Reply-To: <201801071755.w07HtCAU017655@pdx.rh.CN85.dnsmgr.net> References: <201801071755.w07HtCAU017655@pdx.rh.CN85.dnsmgr.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 18:00:47 -0000 On 7 Jan 2018, at 18:55, Rodney W. Grimes wrote: > [ Charset UTF-8 unsupported, converting... ] >> Author: kp >> Date: Sun Jan 7 13:21:01 2018 >> New Revision: 327674 >> URL: https://svnweb.freebsd.org/changeset/base/327674 >> >> Log: >> Introduce mallocarray() in the kernel >> >> Similar to calloc() the mallocarray() function checks for integer >> overflows before allocating memory. >> It does not zero memory, unless the M_ZERO flag is set. >> >> Reviewed by: pfg, vangyzen (previous version), imp (previous = >> version) >> Obtained from: OpenBSD >> Differential Revision: https://reviews.freebsd.org/D13766 >> >> Modified: head/sys/kern/kern_malloc.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/sys/kern/kern_malloc.c Sun Jan 7 10:29:15 2018 (r327673) >> +++ head/sys/kern/kern_malloc.c Sun Jan 7 13:21:01 2018 (r327674) >> @@ -4,6 +4,7 @@ >> * Copyright (c) 1987, 1991, 1993 >> * The Regents of the University of California. >> * Copyright (c) 2005-2009 Robert N. M. Watson >> + * Copyright (c) 2008 Otto Moerbeek (mallocarray) > > Is this code really over a decade old???? or is this a typo? > > That=E2=80=99s the copyright statement OpenBSD have for it, and that=E2=80= =99s where = it came from: https://github.com/openbsd/src/blob/3031d9a2ee043e48086ede83d43c1e37d034a= ff4/sys/kern/kern_malloc.c#L705 Regards, Kristof From owner-svn-src-all@freebsd.org Sun Jan 7 18:02:36 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 593CDE789B9; Sun, 7 Jan 2018 18:02:36 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 21E5870A9E; Sun, 7 Jan 2018 18:02:35 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w07I2Ycj017700; Sun, 7 Jan 2018 10:02:34 -0800 (PST) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w07I2YEB017699; Sun, 7 Jan 2018 10:02:34 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201801071802.w07I2YEB017699@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r327676 - head/sys/compat/linuxkpi/common/include/linux In-Reply-To: <201801071339.w07DdCaX070032@repo.freebsd.org> To: Kristof Provost Date: Sun, 7 Jan 2018 10:02:34 -0800 (PST) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 18:02:36 -0000 [ Charset UTF-8 unsupported, converting... ] > Author: kp > Date: Sun Jan 7 13:39:12 2018 > New Revision: 327676 > URL: https://svnweb.freebsd.org/changeset/base/327676 > > Log: > linuxkpi: Implement kcalloc() based on mallocarray() > > This means we now get integer overflow protection, which Linux code > might expect as it is also provided by kcalloc() in Linux. > > Modified: > head/sys/compat/linuxkpi/common/include/linux/slab.h > > Modified: head/sys/compat/linuxkpi/common/include/linux/slab.h > ============================================================================== > --- head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 13:35:15 2018 (r327675) > +++ head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 13:39:12 2018 (r327676) > @@ -46,7 +46,6 @@ MALLOC_DECLARE(M_KMALLOC); > #define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO) > #define kzalloc_node(size, flags, node) kmalloc(size, (flags) | __GFP_ZERO) > #define kfree_const(ptr) kfree(ptr) > -#define kcalloc(n, size, flags) kmalloc((n) * (size), (flags) | __GFP_ZERO) Would not: #define kcalloc(n, size, flags) mallocarray(mallocarray((n), (size), M_KMALLOC, linux_check_m_flags((flags | __GFP_ZERO)) work just fine, saving a call and stack use of about framesize + 32 bytes? > #define vzalloc(size) __vmalloc(size, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO, 0) > #define vfree(arg) kfree(arg) > #define kvfree(arg) kfree(arg) > @@ -98,6 +97,13 @@ static inline void * > kmalloc(size_t size, gfp_t flags) > { > return (malloc(size, M_KMALLOC, linux_check_m_flags(flags))); > +} > + > +static inline void * > +kcalloc(size_t n, size_t size, gfp_t flags) > +{ > + flags |= __GFP_ZERO; > + return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags))); > } > > static inline void * > > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Sun Jan 7 18:06:31 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D9F56E78DB8; Sun, 7 Jan 2018 18:06:31 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B61B170F7B; Sun, 7 Jan 2018 18:06:31 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DE17124921; Sun, 7 Jan 2018 18:06:30 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07I6UVe084571; Sun, 7 Jan 2018 18:06:30 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07I6U84084570; Sun, 7 Jan 2018 18:06:30 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801071806.w07I6U84084570@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 7 Jan 2018 18:06:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327678 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 327678 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 18:06:32 -0000 Author: ian Date: Sun Jan 7 18:06:30 2018 New Revision: 327678 URL: https://svnweb.freebsd.org/changeset/base/327678 Log: Use EVENTHANDLER_DIRECT_INVOKE() for device events, for better performance. Modified: head/sys/kern/subr_bus.c Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Sun Jan 7 13:41:06 2018 (r327677) +++ head/sys/kern/subr_bus.c Sun Jan 7 18:06:30 2018 (r327678) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -146,6 +147,10 @@ struct device { static MALLOC_DEFINE(M_BUS, "bus", "Bus data structures"); static MALLOC_DEFINE(M_BUS_SC, "bus-sc", "Bus data structures, softc"); +EVENTHANDLER_LIST_DEFINE(device_attach); +EVENTHANDLER_LIST_DEFINE(device_detach); +EVENTHANDLER_LIST_DEFINE(dev_lookup); + static void devctl2_init(void); #define DRIVERNAME(d) ((d)? d->name : "no driver") @@ -2938,7 +2943,7 @@ device_attach(device_t dev) else dev->state = DS_ATTACHED; dev->flags &= ~DF_DONENOMATCH; - EVENTHANDLER_INVOKE(device_attach, dev); + EVENTHANDLER_DIRECT_INVOKE(device_attach, dev); devadded(dev); return (0); } @@ -2972,12 +2977,14 @@ device_detach(device_t dev) if (dev->state != DS_ATTACHED) return (0); - EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_BEGIN); + EVENTHANDLER_DIRECT_INVOKE(device_detach, dev, EVHDEV_DETACH_BEGIN); if ((error = DEVICE_DETACH(dev)) != 0) { - EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_FAILED); + EVENTHANDLER_DIRECT_INVOKE(device_detach, dev, + EVHDEV_DETACH_FAILED); return (error); } else { - EVENTHANDLER_INVOKE(device_detach, dev, EVHDEV_DETACH_COMPLETE); + EVENTHANDLER_DIRECT_INVOKE(device_detach, dev, + EVHDEV_DETACH_COMPLETE); } devremoved(dev); if (!device_is_quiet(dev)) @@ -5330,7 +5337,7 @@ find_device(struct devreq *req, device_t *devp) /* Finally, give device enumerators a chance. */ dev = NULL; - EVENTHANDLER_INVOKE(dev_lookup, req->dr_name, &dev); + EVENTHANDLER_DIRECT_INVOKE(dev_lookup, req->dr_name, &dev); if (dev == NULL) return (ENOENT); *devp = dev; From owner-svn-src-all@freebsd.org Sun Jan 7 18:07:23 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 970A5E78E75; Sun, 7 Jan 2018 18:07:23 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 73679710D0; Sun, 7 Jan 2018 18:07:23 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BE06D24922; Sun, 7 Jan 2018 18:07:22 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07I7Ms5084642; Sun, 7 Jan 2018 18:07:22 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07I7MQm084641; Sun, 7 Jan 2018 18:07:22 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201801071807.w07I7MQm084641@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 7 Jan 2018 18:07:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327679 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: ian X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 327679 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 18:07:23 -0000 Author: ian Date: Sun Jan 7 18:07:22 2018 New Revision: 327679 URL: https://svnweb.freebsd.org/changeset/base/327679 Log: Use EVENTHANDLER_DIRECT_INVOKE for [un]mount events, for better performance. Modified: head/sys/kern/vfs_mount.c Modified: head/sys/kern/vfs_mount.c ============================================================================== --- head/sys/kern/vfs_mount.c Sun Jan 7 18:06:30 2018 (r327678) +++ head/sys/kern/vfs_mount.c Sun Jan 7 18:07:22 2018 (r327679) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -91,6 +92,9 @@ struct mntlist mountlist = TAILQ_HEAD_INITIALIZER(moun struct mtx mountlist_mtx; MTX_SYSINIT(mountlist, &mountlist_mtx, "mountlist", MTX_DEF); +EVENTHANDLER_LIST_DEFINE(vfs_mounted); +EVENTHANDLER_LIST_DEFINE(vfs_unmounted); + /* * Global opts, taken by all filesystems */ @@ -865,7 +869,7 @@ vfs_domount_first( if (VFS_ROOT(mp, LK_EXCLUSIVE, &newdp)) panic("mount: lost mount"); VOP_UNLOCK(vp, 0); - EVENTHANDLER_INVOKE(vfs_mounted, mp, newdp, td); + EVENTHANDLER_DIRECT_INVOKE(vfs_mounted, mp, newdp, td); VOP_UNLOCK(newdp, 0); mountcheckdirs(vp, newdp); vrele(newdp); @@ -1401,7 +1405,7 @@ dounmount(struct mount *mp, int flags, struct thread * mtx_lock(&mountlist_mtx); TAILQ_REMOVE(&mountlist, mp, mnt_list); mtx_unlock(&mountlist_mtx); - EVENTHANDLER_INVOKE(vfs_unmounted, mp, td); + EVENTHANDLER_DIRECT_INVOKE(vfs_unmounted, mp, td); if (coveredvp != NULL) { coveredvp->v_mountedhere = NULL; VOP_UNLOCK(coveredvp, 0); From owner-svn-src-all@freebsd.org Sun Jan 7 18:30:08 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 923CBE79E08; Sun, 7 Jan 2018 18:30:08 +0000 (UTC) (envelope-from srs0=cu0q=ec=freebsd.org=kp@codepro.be) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.codepro.be", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 59B3B722E3; Sun, 7 Jan 2018 18:30:08 +0000 (UTC) (envelope-from srs0=cu0q=ec=freebsd.org=kp@codepro.be) Received: from [10.0.2.164] (ptr-8ripyyhthbnp0l0tszn.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:2419:4e02:e0f1:72a1:d72b:ec03]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 181FBAE7A; Sun, 7 Jan 2018 19:30:06 +0100 (CET) From: "Kristof Provost" To: rgrimes@freebsd.org Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r327676 - head/sys/compat/linuxkpi/common/include/linux Date: Sun, 07 Jan 2018 19:30:04 +0100 X-Mailer: MailMate (2.0BETAr6102) Message-ID: <219974D5-0240-49D9-8DE4-C1FBCEF74776@FreeBSD.org> In-Reply-To: <201801071802.w07I2YEB017699@pdx.rh.CN85.dnsmgr.net> References: <201801071802.w07I2YEB017699@pdx.rh.CN85.dnsmgr.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 18:30:08 -0000 On 7 Jan 2018, at 19:02, Rodney W. Grimes wrote: > [ Charset UTF-8 unsupported, converting... ] >> Author: kp >> Date: Sun Jan 7 13:39:12 2018 >> New Revision: 327676 >> URL: https://svnweb.freebsd.org/changeset/base/327676 >> >> Log: >> linuxkpi: Implement kcalloc() based on mallocarray() >> >> This means we now get integer overflow protection, which Linux code >> might expect as it is also provided by kcalloc() in Linux. >> >> Modified: >> head/sys/compat/linuxkpi/common/include/linux/slab.h >> >> Modified: head/sys/compat/linuxkpi/common/include/linux/slab.h >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 = >> 13:35:15 2018 (r327675) >> +++ head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 = >> 13:39:12 2018 (r327676) >> @@ -46,7 +46,6 @@ MALLOC_DECLARE(M_KMALLOC); >> #define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO) >> #define kzalloc_node(size, flags, node) kmalloc(size, (flags) | = >> __GFP_ZERO) >> #define kfree_const(ptr) kfree(ptr) >> -#define kcalloc(n, size, flags) kmalloc((n) * (size), = >> (flags) | __GFP_ZERO) > > Would not: > #define kcalloc(n, size, flags) mallocarray(mallocarray((n), = > (size), M_KMALLOC, linux_check_m_flags((flags | __GFP_ZERO)) > work just fine, saving a call and stack use of about framesize + 32 = > bytes? > > It would also work, but it=E2=80=99d have to be split up into multiple li= nes = then. I thought it=E2=80=99d be more readable as a function. It=E2=80=99s an inline function, so it won=E2=80=99t actually use stack s= pace in = practice. Also, it used to call kmalloc(), which is also an inline function, so at = worst we=E2=80=99ve traded one function for another. Regards, Kristof From owner-svn-src-all@freebsd.org Sun Jan 7 18:37:44 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 54EFCE7A3E1; Sun, 7 Jan 2018 18:37:44 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1C04B729C7; Sun, 7 Jan 2018 18:37:43 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w07Ibf29017915; Sun, 7 Jan 2018 10:37:41 -0800 (PST) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w07Ibfxb017914; Sun, 7 Jan 2018 10:37:41 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201801071837.w07Ibfxb017914@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r327676 - head/sys/compat/linuxkpi/common/include/linux In-Reply-To: <219974D5-0240-49D9-8DE4-C1FBCEF74776@FreeBSD.org> To: Kristof Provost Date: Sun, 7 Jan 2018 10:37:41 -0800 (PST) CC: rgrimes@FreeBSD.org, src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Reply-To: rgrimes@FreeBSD.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 18:37:44 -0000 > On 7 Jan 2018, at 19:02, Rodney W. Grimes wrote: > >> Author: kp > >> Date: Sun Jan 7 13:39:12 2018 > >> New Revision: 327676 > >> URL: https://svnweb.freebsd.org/changeset/base/327676 > >> > >> Log: > >> linuxkpi: Implement kcalloc() based on mallocarray() > >> > >> This means we now get integer overflow protection, which Linux code > >> might expect as it is also provided by kcalloc() in Linux. > >> > >> Modified: > >> head/sys/compat/linuxkpi/common/include/linux/slab.h > >> > >> Modified: head/sys/compat/linuxkpi/common/include/linux/slab.h > >> ============================================================================== > >> --- head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 > >> 13:35:15 2018 (r327675) > >> +++ head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 > >> 13:39:12 2018 (r327676) > >> @@ -46,7 +46,6 @@ MALLOC_DECLARE(M_KMALLOC); > >> #define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO) > >> #define kzalloc_node(size, flags, node) kmalloc(size, (flags) | > >> __GFP_ZERO) > >> #define kfree_const(ptr) kfree(ptr) > >> -#define kcalloc(n, size, flags) kmalloc((n) * (size), > >> (flags) | __GFP_ZERO) > > > > Would not: > > #define kcalloc(n, size, flags) mallocarray(mallocarray((n), > > (size), M_KMALLOC, linux_check_m_flags((flags | __GFP_ZERO)) > > work just fine, saving a call and stack use of about framesize + 32 > > bytes? > > > > > It would also work, but it?d have to be split up into multiple lines > then. But it would retain the direct macro form, your change changes it from a #define which is evaluated at pre proc time to a function call that is evaluated at compile time. The resulting code from a -O0 well be different because of this. > I thought it?d be more readable as a function. If that is the only reason I would rather see it retain the same form as all the other allocs. > It?s an inline function, so it won?t actually use stack space in > practice. That depends on compiler and optimization levels. > Also, it used to call kmalloc(), which is also an inline function, so at > worst we?ve traded one function for another. I am not sure, well the inlining of all compilers unwrap 2 levels? -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Sun Jan 7 18:53:03 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 64D13E7AD8E; Sun, 7 Jan 2018 18:53:03 +0000 (UTC) (envelope-from srs0=cu0q=ec=freebsd.org=kp@codepro.be) Received: from venus.codepro.be (venus.codepro.be [IPv6:2a01:4f8:162:1127::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.codepro.be", Issuer "Gandi Standard SSL CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 15C4073320; Sun, 7 Jan 2018 18:53:03 +0000 (UTC) (envelope-from srs0=cu0q=ec=freebsd.org=kp@codepro.be) Received: from [10.0.2.164] (ptr-8ripyyhthbnp0l0tszn.18120a2.ip6.access.telenet.be [IPv6:2a02:1811:2419:4e02:e0f1:72a1:d72b:ec03]) (Authenticated sender: kp) by venus.codepro.be (Postfix) with ESMTPSA id 03FEEAEDF; Sun, 7 Jan 2018 19:53:00 +0100 (CET) From: "Kristof Provost" To: rgrimes@FreeBSD.org Cc: src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org Subject: Re: svn commit: r327676 - head/sys/compat/linuxkpi/common/include/linux Date: Sun, 07 Jan 2018 19:52:59 +0100 X-Mailer: MailMate (2.0BETAr6102) Message-ID: In-Reply-To: <201801071837.w07Ibfxb017914@pdx.rh.CN85.dnsmgr.net> References: <201801071837.w07Ibfxb017914@pdx.rh.CN85.dnsmgr.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.25 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 18:53:03 -0000 On 7 Jan 2018, at 19:37, Rodney W. Grimes wrote: >> On 7 Jan 2018, at 19:02, Rodney W. Grimes wrote: >>>> Author: kp >>>> Date: Sun Jan 7 13:39:12 2018 >>>> New Revision: 327676 >>>> URL: https://svnweb.freebsd.org/changeset/base/327676 >>>> >>>> Log: >>>> linuxkpi: Implement kcalloc() based on mallocarray() >>>> >>>> This means we now get integer overflow protection, which Linux = >>>> code >>>> might expect as it is also provided by kcalloc() in Linux. >>>> >>>> Modified: >>>> head/sys/compat/linuxkpi/common/include/linux/slab.h >>>> >>>> Modified: head/sys/compat/linuxkpi/common/include/linux/slab.h >>>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D >>>> --- head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 >>>> 13:35:15 2018 (r327675) >>>> +++ head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 >>>> 13:39:12 2018 (r327676) >>>> @@ -46,7 +46,6 @@ MALLOC_DECLARE(M_KMALLOC); >>>> #define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO) >>>> #define kzalloc_node(size, flags, node) kmalloc(size, (flags) | >>>> __GFP_ZERO) >>>> #define kfree_const(ptr) kfree(ptr) >>>> -#define kcalloc(n, size, flags) kmalloc((n) * (size), >>>> (flags) | __GFP_ZERO) >>> >>> Would not: >>> #define kcalloc(n, size, flags) mallocarray(mallocarray((n), >>> (size), M_KMALLOC, linux_check_m_flags((flags | __GFP_ZERO)) >>> work just fine, saving a call and stack use of about framesize + 32 >>> bytes? >>> >>> >> It would also work, but it?d have to be split up into multiple lines >> then. > > But it would retain the direct macro form, your change changes it > from a #define which is evaluated at pre proc time to a function > call that is evaluated at compile time. The resulting code from > a -O0 well be different because of this. > Indeed. It=E2=80=99s not something I=E2=80=99d worry about as anyone who = cares about = it being fast (as opposed to easier to debug for example) would build it = as -O2/-O3. >> I thought it?d be more readable as a function. > > If that is the only reason I would rather see it retain the > same form as all the other allocs. > How does this look? diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h = b/sys/compat/linuxkpi/common/include/linux/slab.h index 1f8ec82db98..5551211c281 100644 --- a/sys/compat/linuxkpi/common/include/linux/slab.h +++ b/sys/compat/linuxkpi/common/include/linux/slab.h @@ -46,6 +46,9 @@ MALLOC_DECLARE(M_KMALLOC); #define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO) #define kzalloc_node(size, flags, node) kmalloc(size, (flags) | = __GFP_ZERO) #define kfree_const(ptr) kfree(ptr) +#define kcalloc(n, size, flags) mallocarray((n), (size), \ + M_KMALLOC, \ + linux_check_m_flags((flags | __GFP_ZERO))) #define vzalloc(size) __vmalloc(size, GFP_KERNEL | __GFP_NOWARN | = __GFP_ZERO, 0) #define vfree(arg) kfree(arg) #define kvfree(arg) kfree(arg) @@ -99,13 +102,6 @@ kmalloc(size_t size, gfp_t flags) return (malloc(size, M_KMALLOC, linux_check_m_flags(flags))); } = -static inline void * -kcalloc(size_t n, size_t size, gfp_t flags) -{ - flags |=3D __GFP_ZERO; - return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags))); -} - static inline void * __vmalloc(size_t size, gfp_t flags, int other) { Regards, Kristof From owner-svn-src-all@freebsd.org Sun Jan 7 19:07:54 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1D37AE7B849; Sun, 7 Jan 2018 19:07:54 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC8B773EAC; Sun, 7 Jan 2018 19:07:53 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w07J7pRd018032; Sun, 7 Jan 2018 11:07:51 -0800 (PST) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w07J7pUF018031; Sun, 7 Jan 2018 11:07:51 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201801071907.w07J7pUF018031@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r327676 - head/sys/compat/linuxkpi/common/include/linux In-Reply-To: To: Kristof Provost Date: Sun, 7 Jan 2018 11:07:51 -0800 (PST) CC: rgrimes@freebsd.org, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 19:07:54 -0000 > On 7 Jan 2018, at 19:37, Rodney W. Grimes wrote: > >> On 7 Jan 2018, at 19:02, Rodney W. Grimes wrote: > >>>> Author: kp > >>>> Date: Sun Jan 7 13:39:12 2018 > >>>> New Revision: 327676 > >>>> URL: https://svnweb.freebsd.org/changeset/base/327676 > >>>> > >>>> Log: > >>>> linuxkpi: Implement kcalloc() based on mallocarray() > >>>> > >>>> This means we now get integer overflow protection, which Linux > >>>> code > >>>> might expect as it is also provided by kcalloc() in Linux. > >>>> > >>>> Modified: > >>>> head/sys/compat/linuxkpi/common/include/linux/slab.h > >>>> > >>>> Modified: head/sys/compat/linuxkpi/common/include/linux/slab.h > >>>> ============================================================================== > >>>> --- head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 > >>>> 13:35:15 2018 (r327675) > >>>> +++ head/sys/compat/linuxkpi/common/include/linux/slab.h Sun Jan 7 > >>>> 13:39:12 2018 (r327676) > >>>> @@ -46,7 +46,6 @@ MALLOC_DECLARE(M_KMALLOC); > >>>> #define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO) > >>>> #define kzalloc_node(size, flags, node) kmalloc(size, (flags) | > >>>> __GFP_ZERO) > >>>> #define kfree_const(ptr) kfree(ptr) > >>>> -#define kcalloc(n, size, flags) kmalloc((n) * (size), > >>>> (flags) | __GFP_ZERO) > >>> > >>> Would not: > >>> #define kcalloc(n, size, flags) mallocarray(mallocarray((n), > >>> (size), M_KMALLOC, linux_check_m_flags((flags | __GFP_ZERO)) > >>> work just fine, saving a call and stack use of about framesize + 32 > >>> bytes? > >>> > >>> > >> It would also work, but it?d have to be split up into multiple lines > >> then. > > > > But it would retain the direct macro form, your change changes it > > from a #define which is evaluated at pre proc time to a function > > call that is evaluated at compile time. The resulting code from > > a -O0 well be different because of this. > > > Indeed. It?s not something I?d worry about as anyone who cares about > it being fast (as opposed to easier to debug for example) would build it > as -O2/-O3. > > >> I thought it?d be more readable as a function. > > > > If that is the only reason I would rather see it retain the > > same form as all the other allocs. > > > How does this look? > > diff --git a/sys/compat/linuxkpi/common/include/linux/slab.h > b/sys/compat/linuxkpi/common/include/linux/slab.h > index 1f8ec82db98..5551211c281 100644 > --- a/sys/compat/linuxkpi/common/include/linux/slab.h > +++ b/sys/compat/linuxkpi/common/include/linux/slab.h > @@ -46,6 +46,9 @@ MALLOC_DECLARE(M_KMALLOC); > #define kzalloc(size, flags) kmalloc(size, (flags) | __GFP_ZERO) > #define kzalloc_node(size, flags, node) kmalloc(size, (flags) | > __GFP_ZERO) > #define kfree_const(ptr) kfree(ptr) > +#define kcalloc(n, size, flags) mallocarray((n), (size), \ > + M_KMALLOC, \ > + linux_check_m_flags((flags | __GFP_ZERO))) > #define vzalloc(size) __vmalloc(size, GFP_KERNEL | __GFP_NOWARN | > __GFP_ZERO, 0) > #define vfree(arg) kfree(arg) > #define kvfree(arg) kfree(arg) > @@ -99,13 +102,6 @@ kmalloc(size_t size, gfp_t flags) > return (malloc(size, M_KMALLOC, linux_check_m_flags(flags))); > } > > -static inline void * > -kcalloc(size_t n, size_t size, gfp_t flags) > -{ > - flags |= __GFP_ZERO; > - return (mallocarray(n, size, M_KMALLOC, linux_check_m_flags(flags))); > -} > - > static inline void * > __vmalloc(size_t size, gfp_t flags, int other) > { > > Regards, > Kristof Should probably revert and go through review, I would at least wait for comments from others. -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Sun Jan 7 20:28:19 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0E11FE5ACDB; Sun, 7 Jan 2018 20:28:19 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DCF1C77328; Sun, 7 Jan 2018 20:28:18 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1EF4F25F95; Sun, 7 Jan 2018 20:28:18 +0000 (UTC) (envelope-from jhibbits@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07KSHKr044609; Sun, 7 Jan 2018 20:28:17 GMT (envelope-from jhibbits@FreeBSD.org) Received: (from jhibbits@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07KSHpF044608; Sun, 7 Jan 2018 20:28:17 GMT (envelope-from jhibbits@FreeBSD.org) Message-Id: <201801072028.w07KSHpF044608@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhibbits set sender to jhibbits@FreeBSD.org using -f From: Justin Hibbits Date: Sun, 7 Jan 2018 20:28:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327681 - head/sys/modules/gpio/gpiobus X-SVN-Group: head X-SVN-Commit-Author: jhibbits X-SVN-Commit-Paths: head/sys/modules/gpio/gpiobus X-SVN-Commit-Revision: 327681 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 20:28:19 -0000 Author: jhibbits Date: Sun Jan 7 20:28:17 2018 New Revision: 327681 URL: https://svnweb.freebsd.org/changeset/base/327681 Log: Add missing file to gpiobus module ofw_gpiobus.c is needed when FDT is used. MFC after: 2 weeks Modified: head/sys/modules/gpio/gpiobus/Makefile Modified: head/sys/modules/gpio/gpiobus/Makefile ============================================================================== --- head/sys/modules/gpio/gpiobus/Makefile Sun Jan 7 18:33:19 2018 (r327680) +++ head/sys/modules/gpio/gpiobus/Makefile Sun Jan 7 20:28:17 2018 (r327681) @@ -36,6 +36,10 @@ SRCS= gpiobus.c gpioc.c SRCS+= gpio_if.c gpio_if.h gpiobus_if.c gpiobus_if.h ofw_bus_if.h SRCS+= device_if.h bus_if.h opt_platform.h +.if !empty(OPT_FDT) +SRCS+= ofw_gpiobus.c +.endif + CFLAGS+= -I. -I${SRCTOP}/sys/dev/gpio/ .include From owner-svn-src-all@freebsd.org Sun Jan 7 21:57:53 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77893E60DF7; Sun, 7 Jan 2018 21:57:53 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 52C0C7ACBB; Sun, 7 Jan 2018 21:57:53 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8B3C226DF4; Sun, 7 Jan 2018 21:57:52 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07LvqAt082185; Sun, 7 Jan 2018 21:57:52 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07LvqPR082184; Sun, 7 Jan 2018 21:57:52 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201801072157.w07LvqPR082184@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 7 Jan 2018 21:57:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327682 - head/tests/sys/geom/class/eli X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/tests/sys/geom/class/eli X-SVN-Commit-Revision: 327682 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 21:57:53 -0000 Author: asomers Date: Sun Jan 7 21:57:52 2018 New Revision: 327682 URL: https://svnweb.freebsd.org/changeset/base/327682 Log: Fix typo from r327666 MFC after: 13 days X-MFC-With: 327666 Modified: head/tests/sys/geom/class/eli/init_test.sh Modified: head/tests/sys/geom/class/eli/init_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/init_test.sh Sun Jan 7 20:28:17 2018 (r327681) +++ head/tests/sys/geom/class/eli/init_test.sh Sun Jan 7 21:57:52 2018 (r327682) @@ -9,7 +9,7 @@ init_test() keylen=${cipher##*:} atf_check -s exit:0 -e ignore \ - geli init -B none -e $ealgo -l $keylen -P -K keyfile + geli init -B none -e $ealgo -l $keylen -P -K keyfile \ -s $secsize ${md} atf_check geli attach -p -k keyfile ${md} From owner-svn-src-all@freebsd.org Sun Jan 7 22:21:09 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 21E12E62495; Sun, 7 Jan 2018 22:21:09 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id F029F7BDCE; Sun, 7 Jan 2018 22:21:08 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3ACEC2724A; Sun, 7 Jan 2018 22:21:08 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07ML8i2092796; Sun, 7 Jan 2018 22:21:08 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07ML7AE092788; Sun, 7 Jan 2018 22:21:07 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201801072221.w07ML7AE092788@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Sun, 7 Jan 2018 22:21:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327683 - in head: . tests/sys/geom/class/eli X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: in head: . tests/sys/geom/class/eli X-SVN-Commit-Revision: 327683 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 22:21:09 -0000 Author: asomers Date: Sun Jan 7 22:21:07 2018 New Revision: 327683 URL: https://svnweb.freebsd.org/changeset/base/327683 Log: geli: convert remaining TAP tests to ATF MFC after: 2 weeks Deleted: head/tests/sys/geom/class/eli/nokey_test.sh head/tests/sys/geom/class/eli/readonly_test.sh Modified: head/ObsoleteFiles.inc head/tests/sys/geom/class/eli/Makefile head/tests/sys/geom/class/eli/attach_test.sh head/tests/sys/geom/class/eli/conf.sh head/tests/sys/geom/class/eli/delkey_test.sh head/tests/sys/geom/class/eli/init_test.sh head/tests/sys/geom/class/eli/kill_test.sh head/tests/sys/geom/class/eli/setkey_test.sh Modified: head/ObsoleteFiles.inc ============================================================================== --- head/ObsoleteFiles.inc Sun Jan 7 21:57:52 2018 (r327682) +++ head/ObsoleteFiles.inc Sun Jan 7 22:21:07 2018 (r327683) @@ -38,6 +38,9 @@ # xargs -n1 | sort | uniq -d; # done +# 20180107: Convert remaining geli(8) tests to ATF +OLD_FILES+=tests/sys/geom/class/eli/nokey_test.sh +OLD_FILES+=tests/sys/geom/class/eli/readonly_test.sh # 20180106: Convert most geli(8) tests to ATF OLD_FILES+=tests/sys/geom/class/eli/attach_d_test.sh OLD_FILES+=tests/sys/geom/class/eli/configure_b_B_test.sh Modified: head/tests/sys/geom/class/eli/Makefile ============================================================================== --- head/tests/sys/geom/class/eli/Makefile Sun Jan 7 21:57:52 2018 (r327682) +++ head/tests/sys/geom/class/eli/Makefile Sun Jan 7 22:21:07 2018 (r327683) @@ -18,10 +18,6 @@ ATF_TESTS_SH+= onetime_test ATF_TESTS_SH+= resize_test ATF_TESTS_SH+= setkey_test -TAP_TESTS_SH+= nokey_test -TAP_TESTS_SH+= readonly_test - - ${PACKAGE}FILES+= conf.sh .for t in ${TAP_TESTS_SH} Modified: head/tests/sys/geom/class/eli/attach_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/attach_test.sh Sun Jan 7 21:57:52 2018 (r327682) +++ head/tests/sys/geom/class/eli/attach_test.sh Sun Jan 7 22:21:07 2018 (r327683) @@ -39,7 +39,62 @@ attach_d_cleanup() geli_test_cleanup } +atf_test_case attach_r cleanup +attach_r_head() +{ + atf_set "descr" "geli attach -r will create a readonly provider" + atf_set "require.user" "root" +} +attach_r_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + + atf_check geli init -B none -P -K keyfile ${md} + atf_check geli attach -r -p -k keyfile ${md} + + atf_check -o match:"^Flags: .*READ-ONLY" geli list ${md}.eli + + # Verify that writes are verbotten + atf_check -s not-exit:0 -e match:"Read-only" \ + dd if=/dev/zero of=/dev/${md}.eli count=1 +} +attach_r_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +atf_test_case nokey cleanup +nokey_head() +{ + atf_set "descr" "geli attach fails if called with no key component" + atf_set "require.user" "root" +} +nokey_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + + atf_check geli init -B none -P -K keyfile ${md} + atf_check -s not-exit:0 -e match:"No key components given" \ + geli attach -p ${md} 2>/dev/null +} +nokey_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + atf_init_test_cases() { atf_add_test_case attach_d + atf_add_test_case attach_r + atf_add_test_case nokey } Modified: head/tests/sys/geom/class/eli/conf.sh ============================================================================== --- head/tests/sys/geom/class/eli/conf.sh Sun Jan 7 21:57:52 2018 (r327682) +++ head/tests/sys/geom/class/eli/conf.sh Sun Jan 7 22:21:07 2018 (r327683) @@ -3,7 +3,6 @@ class="eli" base=$(atf_get ident) -[ -z "$base" ] && base=`basename $0` # for TAP compatibility MAX_SECSIZE=8192 TEST_MDS_FILE=md.devs @@ -85,7 +84,5 @@ geli_test_cleanup() fi true } -# TODO: remove the trap statement once all TAP tests are converted -trap geli_test_cleanup ABRT EXIT INT TERM . `dirname $0`/../geom_subr.sh Modified: head/tests/sys/geom/class/eli/delkey_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/delkey_test.sh Sun Jan 7 21:57:52 2018 (r327682) +++ head/tests/sys/geom/class/eli/delkey_test.sh Sun Jan 7 22:21:07 2018 (r327683) @@ -80,7 +80,35 @@ delkey_cleanup() geli_test_cleanup } +atf_test_case delkey_readonly cleanup +delkey_readonly_head() +{ + atf_set "descr" "geli delkey cannot work on a read-only provider" + atf_set "require.user" "root" +} +delkey_readonly_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + + atf_check geli init -B none -P -K keyfile ${md} + atf_check geli attach -r -p -k keyfile ${md} + + atf_check -s not-exit:0 -e match:"read-only" geli delkey -n 0 ${md} + # Even with -f (force) it should still fail + atf_check -s not-exit:0 -e match:"read-only" geli delkey -f -n 0 ${md} +} +delkey_readonly_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + atf_init_test_cases() { atf_add_test_case delkey + atf_add_test_case delkey_readonly } Modified: head/tests/sys/geom/class/eli/init_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/init_test.sh Sun Jan 7 21:57:52 2018 (r327682) +++ head/tests/sys/geom/class/eli/init_test.sh Sun Jan 7 22:21:07 2018 (r327683) @@ -358,6 +358,28 @@ init_i_P_cleanup() geli_test_cleanup } +atf_test_case nokey cleanup +nokey_head() +{ + atf_set "descr" "geli init fails if called with no key component" + atf_set "require.user" "root" +} +nokey_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + + atf_check -s not-exit:0 -e match:"No key components given" \ + geli init -B none -P ${md} +} +nokey_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + atf_init_test_cases() { atf_add_test_case init @@ -366,4 +388,5 @@ atf_init_test_cases() atf_add_test_case init_a atf_add_test_case init_alias atf_add_test_case init_i_P + atf_add_test_case nokey } Modified: head/tests/sys/geom/class/eli/kill_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/kill_test.sh Sun Jan 7 21:57:52 2018 (r327682) +++ head/tests/sys/geom/class/eli/kill_test.sh Sun Jan 7 22:21:07 2018 (r327683) @@ -65,7 +65,38 @@ kill_cleanup() geli_test_cleanup } +atf_test_case kill_readonly cleanup +kill_readonly_head() +{ + atf_set "descr" "geli kill will not destroy the keys of a readonly provider" + atf_set "require.user" "root" +} +kill_readonly_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + + atf_check geli init -B none -P -K keyfile ${md} + # Attach read-only + atf_check geli attach -r -p -k keyfile ${md} + + atf_check geli kill ${md} + # The provider will be detached + atf_check [ ! -c /dev/${md}.eli ] + # But its keys should not be destroyed + atf_check geli attach -p -k keyfile ${md} +} +kill_readonly_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + atf_init_test_cases() { atf_add_test_case kill + atf_add_test_case kill_readonly } Modified: head/tests/sys/geom/class/eli/setkey_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/setkey_test.sh Sun Jan 7 21:57:52 2018 (r327682) +++ head/tests/sys/geom/class/eli/setkey_test.sh Sun Jan 7 22:21:07 2018 (r327683) @@ -92,7 +92,73 @@ setkey_cleanup() geli_test_cleanup } +atf_test_case setkey_readonly cleanup +setkey_readonly_head() +{ + atf_set "descr" "geli setkey cannot change the keys of a readonly provider" + atf_set "require.user" "root" +} +setkey_readonly_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + + atf_check geli init -B none -P -K keyfile ${md} + atf_check geli attach -r -p -k keyfile ${md} + + atf_check -s not-exit:0 -e match:"read-only" \ + geli setkey -n 1 -P -K /dev/null ${md} +} +setkey_readonly_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + +atf_test_case nokey cleanup +nokey_head() +{ + atf_set "descr" "geli setkey can change the key for an existing provider" + atf_set "require.user" "root" +} +nokey_body() +{ + . $(atf_get_srcdir)/conf.sh + + sectors=100 + md=$(attach_md -t malloc -s `expr $sectors + 1`) + atf_check dd if=/dev/random of=keyfile1 bs=512 count=16 status=none + atf_check dd if=/dev/random of=keyfile2 bs=512 count=16 status=none + + atf_check geli init -B none -P -K keyfile1 ${md} + + # Try to set the key for a detached device without providing any + # components for the old key. + atf_check -s not-exit:0 -e match:"No key components given" \ + geli setkey -n 0 -p -P -K keyfile2 ${md} + + # Try to set the key for a detached device without providing any + # components for the new key + atf_check -s not-exit:0 -e match:"No key components given" \ + geli setkey -n 0 -p -k keyfile1 -P ${md} + + # Try to set a new key for an attached device with no components + atf_check geli attach -p -k keyfile1 ${md} + atf_check -s not-exit:0 -e match:"No key components given" \ + geli setkey -n 0 -P ${md} +} +nokey_cleanup() +{ + . $(atf_get_srcdir)/conf.sh + geli_test_cleanup +} + atf_init_test_cases() { atf_add_test_case setkey + atf_add_test_case setkey_readonly + atf_add_test_case nokey } From owner-svn-src-all@freebsd.org Sun Jan 7 22:38:46 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F08C7E63301; Sun, 7 Jan 2018 22:38:46 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CD2EF7C76D; Sun, 7 Jan 2018 22:38:46 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2A32727444; Sun, 7 Jan 2018 22:38:46 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w07McjVM099236; Sun, 7 Jan 2018 22:38:45 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w07McjLP099234; Sun, 7 Jan 2018 22:38:45 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201801072238.w07McjLP099234@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Sun, 7 Jan 2018 22:38:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 X-SVN-Group: head X-SVN-Commit-Author: ed X-SVN-Commit-Paths: in head/sys/compat: cloudabi32 cloudabi64 X-SVN-Commit-Revision: 327684 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jan 2018 22:38:47 -0000 Author: ed Date: Sun Jan 7 22:38:45 2018 New Revision: 327684 URL: https://svnweb.freebsd.org/changeset/base/327684 Log: Use mallocarray(9) in CloudABI kernel code where possible. Submitted by: pfg@ Modified: head/sys/compat/cloudabi32/cloudabi32_sock.c head/sys/compat/cloudabi64/cloudabi64_sock.c Modified: head/sys/compat/cloudabi32/cloudabi32_sock.c ============================================================================== --- head/sys/compat/cloudabi32/cloudabi32_sock.c Sun Jan 7 22:21:07 2018 (r327683) +++ head/sys/compat/cloudabi32/cloudabi32_sock.c Sun Jan 7 22:38:45 2018 (r327684) @@ -60,7 +60,7 @@ cloudabi32_sys_sock_recv(struct thread *td, /* Convert iovecs to native format. */ if (ri.ri_data_len > UIO_MAXIOV) return (EINVAL); - iov = malloc(ri.ri_data_len * sizeof(struct iovec), + iov = mallocarray(ri.ri_data_len, sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(ri.ri_data); for (i = 0; i < ri.ri_data_len; i++) { @@ -104,7 +104,7 @@ cloudabi32_sys_sock_send(struct thread *td, /* Convert iovecs to native format. */ if (si.si_data_len > UIO_MAXIOV) return (EINVAL); - iov = malloc(si.si_data_len * sizeof(struct iovec), + iov = mallocarray(si.si_data_len, sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(si.si_data); for (i = 0; i < si.si_data_len; i++) { Modified: head/sys/compat/cloudabi64/cloudabi64_sock.c ============================================================================== --- head/sys/compat/cloudabi64/cloudabi64_sock.c Sun Jan 7 22:21:07 2018 (r327683) +++ head/sys/compat/cloudabi64/cloudabi64_sock.c Sun Jan 7 22:38:45 2018 (r327684) @@ -60,7 +60,7 @@ cloudabi64_sys_sock_recv(struct thread *td, /* Convert iovecs to native format. */ if (ri.ri_data_len > UIO_MAXIOV) return (EINVAL); - iov = malloc(ri.ri_data_len * sizeof(struct iovec), + iov = mallocarray(ri.ri_data_len, sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(ri.ri_data); for (i = 0; i < ri.ri_data_len; i++) { @@ -104,7 +104,7 @@ cloudabi64_sys_sock_send(struct thread *td, /* Convert iovecs to native format. */ if (si.si_data_len > UIO_MAXIOV) return (EINVAL); - iov = malloc(si.si_data_len * sizeof(struct iovec), + iov = mallocarray(si.si_data_len, sizeof(struct iovec), M_SOCKET, M_WAITOK); user_iov = TO_PTR(si.si_data); for (i = 0; i < si.si_data_len; i++) { From owner-svn-src-all@freebsd.org Mon Jan 8 00:10:46 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DF5CCE68548; Mon, 8 Jan 2018 00:10:46 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A196B7F949; Mon, 8 Jan 2018 00:10:46 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BA595282BD; Mon, 8 Jan 2018 00:10:45 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w080Aj8s037228; Mon, 8 Jan 2018 00:10:45 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w080AjJj037225; Mon, 8 Jan 2018 00:10:45 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201801080010.w080AjJj037225@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Mon, 8 Jan 2018 00:10:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327685 - head/tests/sys/geom/class/eli X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/tests/sys/geom/class/eli X-SVN-Commit-Revision: 327685 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 00:10:47 -0000 Author: asomers Date: Mon Jan 8 00:10:45 2018 New Revision: 327685 URL: https://svnweb.freebsd.org/changeset/base/327685 Log: geli: optimize tests Reduce the geli tests' runtime by about a third: * In integrity_test:copy, use a file-backed md(4) device instead of a malloc'd one. That way we can corrupt the underlying storage without needing to detach and reattach the geli device. * In integrity_test:{copy, hmac, data} and onetime_test:{onetime, onetime_a}, move reads of /dev/random out of the loop. MFC after: 2 weeks Modified: head/tests/sys/geom/class/eli/conf.sh head/tests/sys/geom/class/eli/integrity_test.sh head/tests/sys/geom/class/eli/onetime_test.sh Modified: head/tests/sys/geom/class/eli/conf.sh ============================================================================== --- head/tests/sys/geom/class/eli/conf.sh Sun Jan 7 22:38:45 2018 (r327684) +++ head/tests/sys/geom/class/eli/conf.sh Mon Jan 8 00:10:45 2018 (r327685) @@ -20,12 +20,22 @@ attach_md() # func for_each_geli_config() { func=$1 + backing_filename=$2 # Double the sector size to allow for the HMACs' storage space. osecsize=$(( $MAX_SECSIZE * 2 )) # geli needs 512B for the label. bytes=`expr $osecsize \* $sectors + 512`b - md=$(attach_md -t malloc -s $bytes) + + if [ -n "$backing_filename" ]; then + # Use a file-backed md(4) device, so we can deliberatly corrupt + # it without detaching the geli device first. + truncate -s $bytes backing_file + md=$(attach_md -t vnode -f backing_file) + else + md=$(attach_md -t malloc -s $bytes) + fi + for cipher in aes-xts:128 aes-xts:256 \ aes-cbc:128 aes-cbc:192 aes-cbc:256 \ 3des-cbc:192 \ Modified: head/tests/sys/geom/class/eli/integrity_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/integrity_test.sh Sun Jan 7 22:38:45 2018 (r327684) +++ head/tests/sys/geom/class/eli/integrity_test.sh Mon Jan 8 00:10:45 2018 (r327685) @@ -12,31 +12,32 @@ copy_test() { -K keyfile -s $secsize ${md} atf_check geli attach -p -k keyfile ${md} - atf_check dd if=/dev/random of=/dev/${md}.eli bs=${secsize} count=1 status=none + atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=1 status=none - atf_check geli detach ${md} # Copy first small sector to the second small sector. # This should be detected as corruption. - atf_check dd if=/dev/${md} of=sector bs=512 count=1 status=none - atf_check dd if=sector of=/dev/${md} bs=512 count=1 seek=1 status=none - atf_check geli attach -p -k keyfile ${md} + atf_check dd if=backing_file of=sector bs=512 count=1 \ + conv=notrunc status=none + atf_check dd if=sector of=backing_file bs=512 count=1 seek=1 \ + conv=notrunc status=none atf_check -s not-exit:0 -e ignore \ dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=1 # Fix the corruption - atf_check dd if=/dev/random of=/dev/${md}.eli bs=${secsize} count=2 status=none - atf_check dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=2 status=none + atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=2 status=none + atf_check dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=2 \ + status=none # Copy first big sector to the second big sector. # This should be detected as corruption. ms=`diskinfo /dev/${md} | awk '{print $3 - 512}'` ns=`diskinfo /dev/${md}.eli | awk '{print $4}'` usecsize=`echo "($ms / $ns) - (($ms / $ns) % 512)" | bc` - atf_check geli detach ${md} - atf_check dd if=/dev/${md} bs=512 count=$(( ${usecsize} / 512 )) seek=$(( $secsize / 512 )) of=sector status=none - atf_check dd of=/dev/${md} bs=512 count=$(( ${usecsize} / 512 )) seek=$(( $secsize / 256 )) if=sector status=none - atf_check -s exit:0 -e ignore geli attach -p -k keyfile ${md} + atf_check dd if=backing_file bs=512 count=$(( ${usecsize} / 512 )) \ + seek=$(( $secsize / 512 )) of=sector conv=notrunc status=none + atf_check dd of=backing_file bs=512 count=$(( ${usecsize} / 512 )) \ + seek=$(( $secsize / 256 )) if=sector conv=notrunc status=none atf_check -s not-exit:0 -e ignore \ dd if=/dev/${md}.eli of=/dev/null bs=${secsize} count=$ns } @@ -55,7 +56,9 @@ copy_body() sectors=2 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none - for_each_geli_config copy_test + dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none + + for_each_geli_config copy_test backing_file } copy_cleanup() { @@ -77,7 +80,7 @@ data_test() { # Corrupt 8 bytes of data. atf_check dd if=/dev/${md} of=sector bs=512 count=1 status=none - atf_check dd if=/dev/random of=sector bs=1 count=8 seek=64 conv=notrunc status=none + atf_check dd if=rnd of=sector bs=1 count=8 seek=64 conv=notrunc status=none atf_check dd if=sector of=/dev/${md} bs=512 count=1 status=none atf_check geli attach -p -k keyfile ${md} @@ -100,6 +103,7 @@ data_body() sectors=2 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none for_each_geli_config data_test } data_cleanup() @@ -121,7 +125,7 @@ hmac_test() { # Corrupt 8 bytes of HMAC. atf_check dd if=/dev/${md} of=sector bs=512 count=1 status=none - atf_check dd if=/dev/random of=sector bs=1 count=16 conv=notrunc status=none + atf_check dd if=rnd of=sector bs=1 count=16 conv=notrunc status=none atf_check dd if=sector of=/dev/${md} bs=512 count=1 status=none atf_check geli attach -p -k keyfile ${md} @@ -144,6 +148,7 @@ hmac_body() sectors=2 atf_check dd if=/dev/random of=keyfile bs=512 count=16 status=none + dd if=/dev/random of=rnd bs=${MAX_SECSIZE} count=${sectors} status=none for_each_geli_config hmac_test } hmac_cleanup() Modified: head/tests/sys/geom/class/eli/onetime_test.sh ============================================================================== --- head/tests/sys/geom/class/eli/onetime_test.sh Sun Jan 7 22:38:45 2018 (r327684) +++ head/tests/sys/geom/class/eli/onetime_test.sh Mon Jan 8 00:10:45 2018 (r327685) @@ -10,7 +10,6 @@ onetime_test() atf_check -s exit:0 -o ignore -e ignore \ geli onetime -e $ealgo -l $keylen -s $secsize ${md} - atf_check dd if=/dev/random of=rnd bs=${secsize} count=${sectors} status=none atf_check dd if=rnd of=/dev/${md}.eli bs=${secsize} count=${sectors} status=none md_rnd=`dd if=rnd bs=${secsize} count=${sectors} status=none | md5` @@ -82,7 +81,8 @@ onetime_a_body() . $(atf_get_srcdir)/conf.sh sectors=8 - atf_check dd if=/dev/random of=rnd bs=1024 count=1024 status=none + atf_check dd if=/dev/random of=rnd bs=$MAX_SECSIZE count=$sectors \ + status=none for_each_geli_config onetime_a_test } onetime_a_cleanup() From owner-svn-src-all@freebsd.org Mon Jan 8 00:57:30 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 55B35E6B01B; Mon, 8 Jan 2018 00:57:30 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2F74E81656; Mon, 8 Jan 2018 00:57:30 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 59F4628AFA; Mon, 8 Jan 2018 00:57:29 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w080vTiZ058155; Mon, 8 Jan 2018 00:57:29 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w080vTdx058154; Mon, 8 Jan 2018 00:57:29 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201801080057.w080vTdx058154@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Mon, 8 Jan 2018 00:57:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327686 - stable/11/usr.bin/units X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/usr.bin/units X-SVN-Commit-Revision: 327686 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 00:57:30 -0000 Author: eadler Date: Mon Jan 8 00:57:28 2018 New Revision: 327686 URL: https://svnweb.freebsd.org/changeset/base/327686 Log: MFC r327578: units(1): add missing ':' for two short arguments PR: 209850 Modified: stable/11/usr.bin/units/units.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/units/units.c ============================================================================== --- stable/11/usr.bin/units/units.c Mon Jan 8 00:10:45 2018 (r327685) +++ stable/11/usr.bin/units/units.c Mon Jan 8 00:57:28 2018 (r327686) @@ -761,7 +761,7 @@ main(int argc, char **argv) history_file = NULL; outputformat = numfmt; quit = false; - while ((optchar = getopt_long(argc, argv, "+ehf:oqtvHUV", longopts, NULL)) != -1) { + while ((optchar = getopt_long(argc, argv, "+ehf:o:qtvH:UV", longopts, NULL)) != -1) { switch (optchar) { case 'e': outputformat = "%6e"; From owner-svn-src-all@freebsd.org Mon Jan 8 07:47:08 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 730C9E7E2EB; Mon, 8 Jan 2018 07:47:08 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from fry.fubar.geek.nz (fry.fubar.geek.nz [139.59.165.16]) by mx1.freebsd.org (Postfix) with ESMTP id CEBAB6E9AF; Mon, 8 Jan 2018 07:47:05 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from [IPv6:2a02:c7f:1e13:cf00:341b:263b:a811:3894] (unknown [IPv6:2a02:c7f:1e13:cf00:341b:263b:a811:3894]) by fry.fubar.geek.nz (Postfix) with ESMTPSA id B75784EBDB; Mon, 8 Jan 2018 07:37:45 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 From: Andrew Turner In-Reply-To: <201801072238.w07McjLP099234@repo.freebsd.org> Date: Mon, 8 Jan 2018 07:37:44 +0000 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> References: <201801072238.w07McjLP099234@repo.freebsd.org> To: Ed Schouten X-Mailer: Apple Mail (2.3445.5.20) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 07:47:08 -0000 > On 7 Jan 2018, at 22:38, Ed Schouten wrote: >=20 > Author: ed > Date: Sun Jan 7 22:38:45 2018 > New Revision: 327684 > URL: https://svnweb.freebsd.org/changeset/base/327684 >=20 > Log: > Use mallocarray(9) in CloudABI kernel code where possible. >=20 > Submitted by: pfg@ >=20 > Modified: > head/sys/compat/cloudabi32/cloudabi32_sock.c > head/sys/compat/cloudabi64/cloudabi64_sock.c >=20 > Modified: head/sys/compat/cloudabi32/cloudabi32_sock.c > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- head/sys/compat/cloudabi32/cloudabi32_sock.c Sun Jan 7 = 22:21:07 2018 (r327683) > +++ head/sys/compat/cloudabi32/cloudabi32_sock.c Sun Jan 7 = 22:38:45 2018 (r327684) > @@ -60,7 +60,7 @@ cloudabi32_sys_sock_recv(struct thread *td, > /* Convert iovecs to native format. */ > if (ri.ri_data_len > UIO_MAXIOV) > return (EINVAL); > - iov =3D malloc(ri.ri_data_len * sizeof(struct iovec), > + iov =3D mallocarray(ri.ri_data_len, sizeof(struct iovec), > M_SOCKET, M_WAITOK); Won=E2=80=99t this lead to a NULL pointer dereference on overflow? = mallocarray can return NULL even with M_WAITOK. Andrew From owner-svn-src-all@freebsd.org Mon Jan 8 09:20:09 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BE24DE5DCE1; Mon, 8 Jan 2018 09:20:09 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 956AF72080; Mon, 8 Jan 2018 09:20:09 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B77D12DB24; Mon, 8 Jan 2018 09:20:08 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w089K8dS068923; Mon, 8 Jan 2018 09:20:08 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w089K8Ur068921; Mon, 8 Jan 2018 09:20:08 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201801080920.w089K8Ur068921@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Mon, 8 Jan 2018 09:20:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327689 - head/lib/libcasper/services/cap_dns X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: head/lib/libcasper/services/cap_dns X-SVN-Commit-Revision: 327689 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 09:20:09 -0000 Author: oshogbo Date: Mon Jan 8 09:20:08 2018 New Revision: 327689 URL: https://svnweb.freebsd.org/changeset/base/327689 Log: Document the DNS Casper service. Reviewed by: brueffer@, bcr@ Differential Revision: https://reviews.freebsd.org/D13762 Added: head/lib/libcasper/services/cap_dns/cap_dns.3 (contents, props changed) Modified: head/lib/libcasper/services/cap_dns/Makefile Modified: head/lib/libcasper/services/cap_dns/Makefile ============================================================================== --- head/lib/libcasper/services/cap_dns/Makefile Mon Jan 8 08:37:31 2018 (r327688) +++ head/lib/libcasper/services/cap_dns/Makefile Mon Jan 8 09:20:08 2018 (r327689) @@ -24,4 +24,14 @@ CFLAGS+=-I${.CURDIR} HAS_TESTS= SUBDIR.${MK_TESTS}+= tests +MAN+= cap_dns.3 + +MLINKS+=cap_dns.3 libcap_dns.3 +MLINKS+=cap_dns.3 cap_gethostbyname.3 +MLINKS+=cap_dns.3 cap_gethostbyname2.3 +MLINKS+=cap_dns.3 cap_gethostbyaddr.3 +MLINKS+=cap_dns.3 cap_getnameinfo.3 +MLINKS+=cap_dns.3 cap_dns_type_limit.3 +MLINKS+=cap_dns.3 cap_dns_family_limit.3 + .include Added: head/lib/libcasper/services/cap_dns/cap_dns.3 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/libcasper/services/cap_dns/cap_dns.3 Mon Jan 8 09:20:08 2018 (r327689) @@ -0,0 +1,205 @@ +.\" Copyright (c) 2018 Mariusz Zaborski +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd January 8, 2018 +.Dt CAP_DNS 3 +.Os +.Sh NAME +.Nm cap_gethostbyname , +.Nm cap_gethostbyname2 , +.Nm cap_gethostbyaddr , +.Nm cap_getnameinfo , +.Nm cap_dns_type_limit , +.Nm cap_dns_family_limit +.Nd "library for getting network host entry in capability mode" +.Sh LIBRARY +.Lb libcap_dns +.Sh SYNOPSIS +.In sys/nv.h +.In libcasper.h +.In casper/cap_dns.h +.Ft "struct hostent *" +.Fn cap_gethostbyname "const cap_channel_t *chan" "const char *name" +.Ft "struct hostent *" +.Fn cap_gethostbyname2 "const cap_channel_t *chan" "const char *name" "int af" +.Ft "struct hostent *" +.Fn cap_gethostbyaddr "const cap_channel_t *chan" "const void *addr" "socklen_t len" "int af" +.Ft "int" +.Fn cap_getnameinfo "const cap_channel_t *chan" "const void *name" "int namelen" +.Ft "int" +.Fn cap_dns_type_limit "cap_channel_t *chan" "const char * const *types" "size_t ntypes" +.Ft "int" +.Fn cap_dns_family_limit "const cap_channel_t *chan" "const int *families" "size_t nfamilies" +.Sh DESCRIPTION +The functions +.Fn cap_gethostbyname , +.Fn cap_gethostbyname2 , +.Fn cep_gethostbyaddr +and +.Xr cap_getnameinfo +are respectively equivalent to +.Xr gethostbyname 2 , +.Xr gethostbyname2 2 , +.Xr gethostbyaddr 2 +and +.Xr getnameinfo 2 +except that the connection to the +.Nm system.dns +service needs to be provided. +.Pp +The +.Fn cap_dns_type_limit +function limits the functions allowed in the service. +The +.Fa types +variable can be set to +.Dv ADDR +or +.Dv NAME . +See the +.Sx LIMITS +section for more details. +The +.Fa ntpyes +variable contains the number of +.Fa types +provided. +.Pp +The +.Fn cap_dns_family_limit +functions allows to limit address families. +For details see +.Sx LIMITS . +The +.Fa nfamilies +variable contains the number of +.Fa families +provided. +.Sh LIMITS +The preferred way of setting limits is to use the +.Fn cap_dns_type_limit +and +.Fn cap_dns_family_limit +functions, but the limits of service can be set also using +.Xr cap_limit_set 3 . +The nvlist for that function can contain the following values and types: +.Bl -ohang -offset indent +.It type ( NV_TYPE_STRING ) +The +.Va type +can have two values: +.Dv ADDR +or +.Dv NAME . +The +.Dv ADDR +means that functions +.Fn cap_gethostbyname , +.Fn cap_gethostbyname2 +and +.Fn cap_gethostbyaddr +are allowed. +In case when +.Va type +is set to +.Dv NAME +the +.Fn cap_getnameinfo +function is allowed. +.It family ( NV_TYPE_NUMBER ) +The +.Va family +limits service to one of the address families (e.g. +.Dv AF_INET , AF_INET6 , +etc.). +.Sh EXAMPLES +The following example first opens a capability to casper and then uses this +capability to create the +.Nm system.dns +casper service and uses it to resolve an IP address. +.Bd -literal +cap_channel_t *capcas, *capdns; +const char *typelimit = "ADDR"; +int familylimit; +const char *ipstr = "127.0.0.1"; +struct in_addr ip; +struct hostent *hp; + +/* Open capability to Casper. */ +capcas = cap_init(); +if (capcas == NULL) + err(1, "Unable to contact Casper"); + +/* Enter capability mode sandbox. */ +if (cap_enter() < 0 && errno != ENOSYS) + err(1, "Unable to enter capability mode"); + +/* Use Casper capability to create capability to the system.dns service. */ +capdns = cap_service_open(capcas, "system.dns"); +if (capdns == NULL) + err(1, "Unable to open system.dns service"); + +/* Close Casper capability, we don't need it anymore. */ +cap_close(capcas); + +/* Limit system.dns to reverse DNS lookups. */ +if (cap_dns_type_limit(capdns, &typelimit, 1) < 0) + err(1, "Unable to limit access to the system.dns service"); + +/* Limit system.dns to reserve IPv4 addresses */ +familylimit = AF_INET; +if (cap_dns_family_limit(capdns, &familylimit, 1) < 0) + err(1, "Unable to limit access to the system.dns service"); + +/* Convert IP address in C-string to in_addr. */ +if (!inet_aton(ipstr, &ip)) + errx(1, "Unable to parse IP address %s.", ipstr); + +/* Find hostname for the given IP address. */ +hp = cap_gethostbyaddr(capdns, (const void *)&ip, sizeof(ip), AF_INET); +if (hp == NULL) + errx(1, "No name associated with %s.", ipstr); + +printf("Name associated with %s is %s.\\n", ipstr, hp->h_name); +.Ed +.Sh SEE ALSO +.Xr cap_enter 2 , +.Xr err 3 , +.Xr gethostbyaddr 3 , +.Xr gethostbyname 3 , +.Xr gethostbyname2 3 , +.Xr getnameinfo 3, +.Xr nv 3 , +.Xr capsicum 4 +.Sh AUTHORS +The +.Nm cap_dns +service was implemented by +.An Pawel Jakub Dawidek Aq Mt pawel@dawidek.net +under sponsorship from the FreeBSD Foundation. +.Pp +This manual page was written by +.An Mariusz Zaborski Aq Mt oshogbo@FreeBSD.org . From owner-svn-src-all@freebsd.org Mon Jan 8 10:23:32 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C9D51E62495; Mon, 8 Jan 2018 10:23:32 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A17367444A; Mon, 8 Jan 2018 10:23:32 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D385F2E65C; Mon, 8 Jan 2018 10:23:31 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08ANVGv097684; Mon, 8 Jan 2018 10:23:31 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08ANVNi097681; Mon, 8 Jan 2018 10:23:31 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201801081023.w08ANVNi097681@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Mon, 8 Jan 2018 10:23:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327690 - in head/sys/arm64: arm64 include X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: in head/sys/arm64: arm64 include X-SVN-Commit-Revision: 327690 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 10:23:32 -0000 Author: andrew Date: Mon Jan 8 10:23:31 2018 New Revision: 327690 URL: https://svnweb.freebsd.org/changeset/base/327690 Log: Move some of the common thread switching code into C. This will help with future optimisations, e.g. using Address Space IDs (asid). MFC after: 1 week Sponsored by: DARPA, AFRL Modified: head/sys/arm64/arm64/pmap.c head/sys/arm64/arm64/swtch.S head/sys/arm64/include/pmap.h Modified: head/sys/arm64/arm64/pmap.c ============================================================================== --- head/sys/arm64/arm64/pmap.c Mon Jan 8 09:20:08 2018 (r327689) +++ head/sys/arm64/arm64/pmap.c Mon Jan 8 10:23:31 2018 (r327690) @@ -4660,6 +4660,38 @@ pmap_activate(struct thread *td) critical_exit(); } +struct pcb * +pmap_switch(struct thread *old, struct thread *new) +{ + struct pcb *pcb; + + /* Store the new curthread */ + PCPU_SET(curthread, new); + + /* And the new pcb */ + pcb = new->td_pcb; + PCPU_SET(curpcb, pcb); + + /* + * TODO: We may need to flush the cache here if switching + * to a user process. + */ + + __asm __volatile( + /* Switch to the new pmap */ + "msr ttbr0_el1, %0 \n" + "isb \n" + + /* Invalidate the TLB */ + "dsb ishst \n" + "tlbi vmalle1is \n" + "dsb ish \n" + "isb \n" + : : "r"(new->td_proc->p_md.md_l0addr)); + + return (pcb); +} + void pmap_sync_icache(pmap_t pmap, vm_offset_t va, vm_size_t sz) { Modified: head/sys/arm64/arm64/swtch.S ============================================================================== --- head/sys/arm64/arm64/swtch.S Mon Jan 8 09:20:08 2018 (r327689) +++ head/sys/arm64/arm64/swtch.S Mon Jan 8 10:23:31 2018 (r327690) @@ -70,33 +70,16 @@ ENTRY(cpu_throw) #ifdef VFP /* Backup the new thread pointer around a call to C code */ - mov x19, x1 + mov x19, x0 + mov x20, x1 bl vfp_discard - mov x1, x19 + mov x1, x20 + mov x0, x19 #endif - /* Store the new curthread */ - str x1, [x18, #PC_CURTHREAD] - /* And the new pcb */ - ldr x4, [x1, #TD_PCB] - str x4, [x18, #PC_CURPCB] + bl pmap_switch + mov x4, x0 - /* - * TODO: We may need to flush the cache here. - */ - - /* Switch to the new pmap */ - ldr x28, [x1, #TD_PROC] - ldr x5, [x28, #(P_MD + MD_L0ADDR)] - msr ttbr0_el1, x5 - isb - - /* Invalidate the TLB */ - dsb ishst - tlbi vmalle1 - dsb ish - isb - /* If we are single stepping, enable it */ ldr w5, [x4, #PCB_FLAGS] set_step_flag w5, x6 @@ -161,45 +144,25 @@ ENTRY(cpu_switch) ldr w5, [x4, #PCB_FLAGS] clear_step_flag w5, x6 -#ifdef VFP mov x19, x0 mov x20, x1 mov x21, x2 + +#ifdef VFP /* Load the pcb address */ mov x1, x4 bl vfp_save_state - mov x2, x21 mov x1, x20 mov x0, x19 #endif - /* Store the new curthread */ - str x1, [x18, #PC_CURTHREAD] + bl pmap_switch + /* Move the new pcb out of the way */ + mov x4, x0 - /* - * Restore the saved context and set it as curpcb. - */ - ldr x4, [x1, #TD_PCB] - str x4, [x18, #PC_CURPCB] - - /* - * TODO: We may need to flush the cache here if switching - * to a user process. - */ - - /* Load the new proc address */ - ldr x28, [x1, #TD_PROC] - - /* Switch to the new pmap */ - ldr x5, [x28, #(P_MD + MD_L0ADDR)] - msr ttbr0_el1, x5 - isb - - /* Invalidate the TLB */ - dsb ishst - tlbi vmalle1 - dsb ish - isb + mov x2, x21 + mov x1, x20 + mov x0, x19 /* * Release the old thread. This doesn't need to be a store-release Modified: head/sys/arm64/include/pmap.h ============================================================================== --- head/sys/arm64/include/pmap.h Mon Jan 8 09:20:08 2018 (r327689) +++ head/sys/arm64/include/pmap.h Mon Jan 8 10:23:31 2018 (r327690) @@ -106,6 +106,8 @@ struct pv_chunk { typedef struct pmap *pmap_t; +struct thread; + #ifdef _KERNEL extern struct pmap kernel_pmap_store; #define kernel_pmap (&kernel_pmap_store) @@ -155,6 +157,8 @@ bool pmap_get_tables(pmap_t, vm_offset_t, pd_entry_t * pd_entry_t **, pt_entry_t **); int pmap_fault(pmap_t, uint64_t, uint64_t); + +struct pcb *pmap_switch(struct thread *, struct thread *); #define pmap_page_is_mapped(m) (!TAILQ_EMPTY(&(m)->md.pv_list)) From owner-svn-src-all@freebsd.org Mon Jan 8 11:08:46 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BE7D4E64645; Mon, 8 Jan 2018 11:08:46 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 918A175E20; Mon, 8 Jan 2018 11:08:46 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C2DA32ECFB; Mon, 8 Jan 2018 11:08:45 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08B8j0G014904; Mon, 8 Jan 2018 11:08:45 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08B8jN5014903; Mon, 8 Jan 2018 11:08:45 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201801081108.w08B8jN5014903@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Mon, 8 Jan 2018 11:08:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327691 - head/sys/arm64/arm64 X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/arm64/arm64 X-SVN-Commit-Revision: 327691 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 11:08:46 -0000 Author: andrew Date: Mon Jan 8 11:08:45 2018 New Revision: 327691 URL: https://svnweb.freebsd.org/changeset/base/327691 Log: Only install the new pagetable pointer into ttbr0_el1 when it differs from the existing value. MFC after: 1 week Sponsored by: DARPA, AFRL Modified: head/sys/arm64/arm64/pmap.c Modified: head/sys/arm64/arm64/pmap.c ============================================================================== --- head/sys/arm64/arm64/pmap.c Mon Jan 8 10:23:31 2018 (r327690) +++ head/sys/arm64/arm64/pmap.c Mon Jan 8 11:08:45 2018 (r327691) @@ -4677,17 +4677,20 @@ pmap_switch(struct thread *old, struct thread *new) * to a user process. */ - __asm __volatile( - /* Switch to the new pmap */ - "msr ttbr0_el1, %0 \n" - "isb \n" + if (old == NULL || + old->td_proc->p_md.md_l0addr != new->td_proc->p_md.md_l0addr) { + __asm __volatile( + /* Switch to the new pmap */ + "msr ttbr0_el1, %0 \n" + "isb \n" - /* Invalidate the TLB */ - "dsb ishst \n" - "tlbi vmalle1is \n" - "dsb ish \n" - "isb \n" - : : "r"(new->td_proc->p_md.md_l0addr)); + /* Invalidate the TLB */ + "dsb ishst \n" + "tlbi vmalle1is \n" + "dsb ish \n" + "isb \n" + : : "r"(new->td_proc->p_md.md_l0addr)); + } return (pcb); } From owner-svn-src-all@freebsd.org Mon Jan 8 12:56:54 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 77F7DE6AB6B; Mon, 8 Jan 2018 12:56:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 52B3D79BD0; Mon, 8 Jan 2018 12:56:54 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 903532FE5E; Mon, 8 Jan 2018 12:56:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08CurnS067551; Mon, 8 Jan 2018 12:56:53 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08Cur5c067549; Mon, 8 Jan 2018 12:56:53 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801081256.w08Cur5c067549@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 8 Jan 2018 12:56:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327694 - in stable/11/sys: amd64/amd64 i386/i386 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 i386/i386 X-SVN-Commit-Revision: 327694 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 12:56:54 -0000 Author: kib Date: Mon Jan 8 12:56:53 2018 New Revision: 327694 URL: https://svnweb.freebsd.org/changeset/base/327694 Log: MFC r327472: Avoid re-check of usermode condition. Modified: stable/11/sys/amd64/amd64/trap.c stable/11/sys/i386/i386/trap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/trap.c ============================================================================== --- stable/11/sys/amd64/amd64/trap.c Mon Jan 8 11:45:56 2018 (r327693) +++ stable/11/sys/amd64/amd64/trap.c Mon Jan 8 12:56:53 2018 (r327694) @@ -606,7 +606,6 @@ trap_pfault(struct trapframe *frame, int usermode) td = curthread; p = td->td_proc; eva = frame->tf_addr; - rv = 0; if (__predict_false((td->td_pflags & TDP_NOFAULTING) != 0)) { /* @@ -658,7 +657,7 @@ trap_pfault(struct trapframe *frame, int usermode) * Don't allow user-mode faults in kernel address space. */ if (usermode) - goto nogo; + return (SIGSEGV); map = kernel_map; } else { @@ -713,7 +712,6 @@ trap_pfault(struct trapframe *frame, int usermode) #endif return (0); } -nogo: if (!usermode) { if (td->td_intr_nesting_level == 0 && curpcb->pcb_onfault != NULL) { Modified: stable/11/sys/i386/i386/trap.c ============================================================================== --- stable/11/sys/i386/i386/trap.c Mon Jan 8 11:45:56 2018 (r327693) +++ stable/11/sys/i386/i386/trap.c Mon Jan 8 12:56:53 2018 (r327694) @@ -742,7 +742,6 @@ trap_pfault(struct trapframe *frame, int usermode, vm_ td = curthread; p = td->td_proc; - rv = 0; if (__predict_false((td->td_pflags & TDP_NOFAULTING) != 0)) { /* @@ -803,7 +802,7 @@ trap_pfault(struct trapframe *frame, int usermode, vm_ return (-2); #endif if (usermode) - goto nogo; + return (SIGSEGV); map = kernel_map; } else { @@ -860,7 +859,6 @@ trap_pfault(struct trapframe *frame, int usermode, vm_ #endif return (0); } -nogo: if (!usermode) { if (td->td_intr_nesting_level == 0 && curpcb->pcb_onfault != NULL) { From owner-svn-src-all@freebsd.org Mon Jan 8 13:19:16 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AEB98E6BFAD; Mon, 8 Jan 2018 13:19:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 89F8C7A932; Mon, 8 Jan 2018 13:19:16 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C42E31BC; Mon, 8 Jan 2018 13:19:15 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08DJFiL078100; Mon, 8 Jan 2018 13:19:15 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08DJFZT078099; Mon, 8 Jan 2018 13:19:15 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201801081319.w08DJFZT078099@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 8 Jan 2018 13:19:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327695 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 327695 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Jan 2018 13:19:16 -0000 Author: kib Date: Mon Jan 8 13:19:15 2018 New Revision: 327695 URL: https://svnweb.freebsd.org/changeset/base/327695 Log: MFC r327468: Do not let vm_daemon run unbounded. Modified: stable/11/sys/vm/vm_swapout.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_swapout.c ============================================================================== --- stable/11/sys/vm/vm_swapout.c Mon Jan 8 12:56:53 2018 (r327694) +++ stable/11/sys/vm/vm_swapout.c Mon Jan 8 13:19:15 2018 (r327695) @@ -201,6 +201,8 @