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 @@ vm_swapout_object_deactivate_pages(pmap_t pmap, vm_obj TAILQ_FOREACH(p, &object->memq, listq) { if (pmap_resident_count(pmap) <= desired) goto unlock_return; + if (should_yield()) + goto unlock_return; if (vm_page_busied(p)) continue; PCPU_INC(cnt.v_pdpages); @@ -514,8 +516,10 @@ again: PRELE(p); } sx_sunlock(&allproc_lock); - if (tryagain != 0 && attempts <= 10) + if (tryagain != 0 && attempts <= 10) { + maybe_yield(); goto again; + } } } From owner-svn-src-all@freebsd.org Mon Jan 8 13:43: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 043FAE6D627; Mon, 8 Jan 2018 13:43:14 +0000 (UTC) (envelope-from fabient@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 D38527BE84; Mon, 8 Jan 2018 13:43:13 +0000 (UTC) (envelope-from fabient@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 1D1EF69D; Mon, 8 Jan 2018 13:43:13 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08DhC2u094278; Mon, 8 Jan 2018 13:43:12 GMT (envelope-from fabient@FreeBSD.org) Received: (from fabient@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08DhCjV094277; Mon, 8 Jan 2018 13:43:12 GMT (envelope-from fabient@FreeBSD.org) Message-Id: <201801081343.w08DhCjV094277@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: fabient set sender to fabient@FreeBSD.org using -f From: Fabien Thomas Date: Mon, 8 Jan 2018 13:43:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327696 - head/sys/opencrypto X-SVN-Group: head X-SVN-Commit-Author: fabient X-SVN-Commit-Paths: head/sys/opencrypto X-SVN-Commit-Revision: 327696 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:43:14 -0000 Author: fabient Date: Mon Jan 8 13:43:12 2018 New Revision: 327696 URL: https://svnweb.freebsd.org/changeset/base/327696 Log: Fix uninitialized crp_retw_id when using asynchronous crypto drivers with defered callbacks. Submitted by: emeric.poupon@stormshield.eu Reported by: mav@ Reviewed by: fabient@ Modified: head/sys/opencrypto/crypto.c Modified: head/sys/opencrypto/crypto.c ============================================================================== --- head/sys/opencrypto/crypto.c Mon Jan 8 13:19:15 2018 (r327695) +++ head/sys/opencrypto/crypto.c Mon Jan 8 13:43:12 2018 (r327696) @@ -896,11 +896,12 @@ crypto_dispatch(struct cryptop *crp) binuptime(&crp->crp_tstamp); #endif + crp->crp_retw_id = crp->crp_sid % crypto_workers_num; + if (CRYPTOP_ASYNC(crp)) { if (crp->crp_flags & CRYPTO_F_ASYNC_KEEPORDER) { struct crypto_ret_worker *ret_worker; - crp->crp_retw_id = crp->crp_sid % crypto_workers_num; ret_worker = CRYPTO_RETW(crp->crp_retw_id); CRYPTO_RETW_LOCK(ret_worker); From owner-svn-src-all@freebsd.org Mon Jan 8 15:14: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 6353BE71D89 for ; Mon, 8 Jan 2018 15:14:14 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: from mail-yb0-x232.google.com (mail-yb0-x232.google.com [IPv6:2607:f8b0:4002:c09::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 21BDB7F876 for ; Mon, 8 Jan 2018 15:14:14 +0000 (UTC) (envelope-from ed@nuxi.nl) Received: by mail-yb0-x232.google.com with SMTP id j7so4627233ybl.3 for ; Mon, 08 Jan 2018 07:14:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuxi-nl.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1vKUdDJF2q8Lg0HRJf6EmQK7A3e4gIX0T7O9lmc8wpM=; b=totnRVf9t4/2iTDP70DxOfw+qYHmQPLICZBhFf+9HP04t8zdDPkJf8w1tBUs26KXSI FkSVYRiszeOCqwWKueHftOjHvYV+TEnb0PqXto5B3r3ZTV1ZIBVo16M07s1WadmS6d6d yoVCra1G3qF/rxSTJEWiQbKmkJ0Te6Ouv4OKLkFLlnd3INBusyR9hjwWhLeBekBaj7ux hsWWIy2k+jLcGV2PuvRe9eC44X/l+s6lXIsqqaWoCVJFgwyrEZB0F13jtEjoAwNYsXuk TQVAVGkO5PlYEtQYa5AEaIUT8vADu7zdKFfu5Dl+btFoXXWai7rnla5rBX74U58hKxgE CJ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1vKUdDJF2q8Lg0HRJf6EmQK7A3e4gIX0T7O9lmc8wpM=; b=rFK7jHweVzz0f1tSUIKPltZFuguIK9ffbU5rBi+7VW6ubXmudVEuqW/2ktvoOmESDu woG/DZaKlGYRU0VS0F+K5ppzJQVSLwk4UnDtkXSPqBKvTFCHjIgru/9go81kCfdSh5Vs vS62GTAqW20Xo7bbfuSXGasM/o0hRdMROHSmu15X/AX5Vqsud0uBS6RCRO/eyzc6wDa+ 4UvkPUHqjgNfZHx7T91YDCrXjV1LG4NjlA2p1CIsO6JrPu3TbyW8ecowKAM1kwqGe6Hf Lb9vf6dZN2ohOJKyCSYhE5/0EiCACyJSI60BNfmTZjz0G9DTqvqAYThU3VQUTCqQGB7z RfNw== X-Gm-Message-State: AKGB3mJlEIgVknu3ce5X56tDY0OWXnH3ClSW9UaWyJsKYXUN1GAGsRdj Qw83CSLXJ2QfbLW2t+trJ0hkknf5GVXf1GpejMrV9A== X-Google-Smtp-Source: ACJfBouCUzYvMazQcVThk+pW/bwJWC9QEbRbMNrdrwKX8JSv++2Q6BzRBS0bD9+QeZHZACTdBKOIBm09a+gsbH2fLqY= X-Received: by 10.37.239.5 with SMTP id g5mr1841433ybd.226.1515424453231; Mon, 08 Jan 2018 07:14:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.129.85.17 with HTTP; Mon, 8 Jan 2018 07:13:42 -0800 (PST) In-Reply-To: <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> References: <201801072238.w07McjLP099234@repo.freebsd.org> <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> From: Ed Schouten Date: Mon, 8 Jan 2018 16:13:42 +0100 Message-ID: Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 To: Andrew Turner Cc: Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" 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: Mon, 08 Jan 2018 15:14:14 -0000 Hi Andrew, 2018-01-08 8:37 GMT+01:00 Andrew Turner : > Won=E2=80=99t this lead to a NULL pointer dereference on overflow? malloc= array can return NULL even with M_WAITOK. Yes, it will, but an overflow shouldn't happen in the first place. ri_data_len is compared with UIO_MAXIOV a few lines above. Even if an overflow would happen, this would cause a kernel panic due to a NULL pointer dereference later on, which is likely easier to debug than some piece of code that overruns a buffer. In this case, mallocarray() is preferred, because it makes it more obvious that we're allocating a buffer that is accessed as an array, as opposed to single structure. --=20 Ed Schouten Nuxi, 's-Hertogenbosch, the Netherlands From owner-svn-src-all@freebsd.org Mon Jan 8 15:29:04 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 EF9A2E72825 for ; Mon, 8 Jan 2018 15:29:04 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from sonic304-35.consmr.mail.ne1.yahoo.com (sonic304-35.consmr.mail.ne1.yahoo.com [66.163.191.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C2D1180157 for ; Mon, 8 Jan 2018 15:29:04 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1515425343; bh=qCWPCvfC/NeNLjWqtNypZ1SEfRSYmXmJgxGyeOsPIyE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=K00ALrq6Qvc9AI3VNFKA/7MBdX2BsnoCYgPnVeoHdRR9uKBa0RvJgLESrCCM23NRQ5hJVl+dkfnb1LY3jeQ0Un1j/9GR19eW5DuK5Tll62ZJeWnURqUQ+uMZwOXhXlQqa52lO1wKJDJF45dEs5fvrzsTPW2+wlrJx+ZA5leoTi/m16MgP2fkhr+YGk9EF4HMv7vXqgjuJN+yzDiYW5IIOGgKMTOL3jol9iy31y8dq5aRXxPldBBn6oh615XLvE+ZsBwt8C+kUN5urPaKGqw5vEbWU+RhWs+X20eMtfzj3P4nML7BEytX/6hlRzebDt67aaK6n+K6BkB7ITsdAzbajw== X-YMail-OSG: fpEclCYVM1n7ws2ySi7L7Bhb7n4shomKURrrQznn_oOW8JEjSJUpAq_fzixQD2x w0u1lS3spC03zSwI6bHl1EDwuqVFaC0k3a9V.8Ybo0HDlcwhbX.tqSeDWPLoPXxZnRY8wL2awZgE Aq66IFfdDYubDicP6AjcOHyea3hj0On2U8JvDFCDOBcjzu6J.KgpJmDcCVGyuKnXSmJN..2szVpQ CmZtYnONDEJGtgTt9o3aGa6Zggrjop4PhTwiI7CdJ3UzieLomWfcKQhNtjJlge39Vta9Otl_oDRw jKPNCxYQme_7duPx02klzCj2P703RzWBPB8jouPjXQ57DNZuABAIsdxsFoP0O2r.x6sdk_wVOqpv m.3Z2WZ66LPdkBHz8F.uPqjRHJAzMzoiPPQ.XR0VTB4GGobk44nK17q0faUC0_7MO.YXgi3D.xGt lrOXISuUlHW1OxIBOmB2gzSG2rBj9wucvY_Gg5F0BZZilqqdc8V.IUQttuY_6QVltewMYuAXM Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Mon, 8 Jan 2018 15:29:03 +0000 Received: from smtpgate103.mail.ne1.yahoo.com (EHLO [192.168.0.6]) ([216.155.193.162]) by smtp414.mail.ne1.yahoo.com (JAMES SMTP Server ) with ESMTPA ID f4ea58c48869a7f2ae5062e2c9ea97de; Mon, 08 Jan 2018 15:08:47 +0000 (UTC) Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 To: Andrew Turner , Ed Schouten Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201801072238.w07McjLP099234@repo.freebsd.org> <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> From: Pedro Giffuni Organization: FreeBSD Project Message-ID: <191085f4-3496-e063-474f-3193a3188275@FreeBSD.org> Date: Mon, 8 Jan 2018 10:08:47 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US 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 15:29:05 -0000 Hi; On 08/01/2018 02:37, Andrew Turner wrote: >> On 7 Jan 2018, at 22:38, Ed Schouten wrote: >> >> 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); > Won’t this lead to a NULL pointer dereference on overflow? mallocarray can return NULL even with M_WAITOK. I think you are right: for the M_WAITOK case we should do the check outside the malloc. Compilers and static checkers should be giving out a warning since mallocarray() has the __result_use_check attribute (is that working!?). In the case of malloc(9) we should remove the attribute since we can by using M_WAITOK. And yes, this patch should be reverted. Pedro. From owner-svn-src-all@freebsd.org Mon Jan 8 15:37: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 25880E72FC9 for ; Mon, 8 Jan 2018 15:37:46 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from sonic304-35.consmr.mail.ne1.yahoo.com (sonic304-35.consmr.mail.ne1.yahoo.com [66.163.191.161]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC165808A5 for ; Mon, 8 Jan 2018 15:37:45 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1515425864; bh=4cazRHlfbyA+0ug4ZwsxSG7jbOfiBLQTLjefHHmXOc0=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=D5pftbG52co1bqUuUQz4atjrKX/EwnBAEKVW0F8XKcJnaCIc12v+nnwp+LfqiJvV/wKX6UryUPMU03mHqXSeWY7HLsjnjDqCHgbgH4GLvi67zNpyRj/gt5M3uSm2sy+rNjXL4bjIQk903/L9SOKge4rlMHInh5amKMK6yztnPCvw3n49VgzJVtW+vg6A3vju4FlB/uriIqK+7NNbWIB3hvbEWwF8gWD3voE7KtoC7S5KseeQw0x80jThVgLR2h6n7ccwX6bzgVMpfJd9fE/JgMTLQB44r8VcGK24AykmB70BNoDI98JtnyApoHmElLdTHNCwxa9gNYNDwRQG9tTV6g== X-YMail-OSG: BCiWKAYVM1n8XErNf.XQW7lDpwoDCLHrJHxYWxTXYROPOdYcz_nB2ZZ9yPF6rm. vp0QHs7yabK4Gp.mEJ7OR0vNbisuiymlt_hcTkbkjiaTKR5Un6K4843IkC4GVXzFSC60.LxRnwx6 FTiA45l_Fz9EYKgIcFVJdeke.4W.0HKSrTO9KfTKB.bzuXgg.hRr2fpPeUVNwyQ0dfF1Q6PJbwH0 kK4iNmx21IScKtyNb4WEAmzm1szm8AoxFcJXlJytdlNM2ueOduhOOoYzNRTupzQJIqTw6J0RjHOp wO3I_MUGfIJrGHQua.V0Zrs9eesiffmh1Ddzq5VyMLXlgTOcWJI3aAbEAmpn.3cIe6VZuTYM6uTX PfJto5ElDEiumklfZ1R2o_NSjmBnU.v1y4AAmSxzHuZ7msw6VZG24Vp.Tpiiwg47GAGpmhT9vAE9 w9Eia857PZu8ZsI5rZ0VWpceJKaJKRZbquF_MmEEuzHp1Syd4rLXGnkdk9Aa5J3Lxh7Stihb. Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ne1.yahoo.com with HTTP; Mon, 8 Jan 2018 15:37:44 +0000 Received: from smtpgate105.mail.ne1.yahoo.com (EHLO [192.168.0.6]) ([216.155.193.135]) by smtp403.mail.ne1.yahoo.com (JAMES SMTP Server ) with ESMTPA ID 9d400679ba3fce3720889955d9c8c284; Mon, 08 Jan 2018 15:37:41 +0000 (UTC) Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 To: Ed Schouten , Andrew Turner Cc: Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201801072238.w07McjLP099234@repo.freebsd.org> <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> From: Pedro Giffuni Message-ID: <0a6ad324-46f2-9270-5abd-dbc3e734cc8b@FreeBSD.org> Date: Mon, 8 Jan 2018 10:37:40 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US 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 15:37:46 -0000 On 01/08/18 10:13, Ed Schouten wrote: > Hi Andrew, > > 2018-01-08 8:37 GMT+01:00 Andrew Turner : >> Won’t this lead to a NULL pointer dereference on overflow? mallocarray can return NULL even with M_WAITOK. > Yes, it will, but an overflow shouldn't happen in the first place. > ri_data_len is compared with UIO_MAXIOV a few lines above. Even if an > overflow would happen, this would cause a kernel panic due to a NULL > pointer dereference later on, which is likely easier to debug than > some piece of code that overruns a buffer. > > In this case, mallocarray() is preferred, because it makes it more > obvious that we're allocating a buffer that is accessed as an array, > as opposed to single structure. > OK... The behavior of mallocarray() somewhat inconsistent with malloc(9), realloc(9) and reallocf(9) but this is clearly documented., so we just assume the developer knows what he/she is doing :). Pedro. From owner-svn-src-all@freebsd.org Mon Jan 8 15:41:50 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 4677DE73372; Mon, 8 Jan 2018 15:41:50 +0000 (UTC) (envelope-from markj@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 224F380D62; Mon, 8 Jan 2018 15:41:50 +0000 (UTC) (envelope-from markj@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 754A719ED; Mon, 8 Jan 2018 15:41:49 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08FfnEG052773; Mon, 8 Jan 2018 15:41:49 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08Ffn7M052772; Mon, 8 Jan 2018 15:41:49 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201801081541.w08Ffn7M052772@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 8 Jan 2018 15:41:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327698 - head/sys/geom/mirror X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/geom/mirror X-SVN-Commit-Revision: 327698 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 15:41:50 -0000 Author: markj Date: Mon Jan 8 15:41:49 2018 New Revision: 327698 URL: https://svnweb.freebsd.org/changeset/base/327698 Log: Release the queue lock before restarting the worker loop. Reported and tested by: pho MFC after: 3 days Sponsored by: Dell EMC Isilon Modified: head/sys/geom/mirror/g_mirror.c Modified: head/sys/geom/mirror/g_mirror.c ============================================================================== --- head/sys/geom/mirror/g_mirror.c Mon Jan 8 15:41:48 2018 (r327697) +++ head/sys/geom/mirror/g_mirror.c Mon Jan 8 15:41:49 2018 (r327698) @@ -1964,8 +1964,10 @@ g_mirror_worker(void *arg) continue; } } - if (g_mirror_event_first(sc) != NULL) + if (g_mirror_event_first(sc) != NULL) { + mtx_unlock(&sc->sc_queue_mtx); continue; + } sx_xunlock(&sc->sc_lock); MSLEEP(sc, &sc->sc_queue_mtx, PRIBIO | PDROP, "m:w1", timeout * hz); From owner-svn-src-all@freebsd.org Mon Jan 8 15:41:49 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 A35D7E7336F; Mon, 8 Jan 2018 15:41:49 +0000 (UTC) (envelope-from pfg@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 8053D80D60; Mon, 8 Jan 2018 15:41:49 +0000 (UTC) (envelope-from pfg@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 C85C219EC; Mon, 8 Jan 2018 15:41:48 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08FfmBF052730; Mon, 8 Jan 2018 15:41:48 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08Ffmm0052729; Mon, 8 Jan 2018 15:41:48 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801081541.w08Ffmm0052729@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 8 Jan 2018 15:41:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327697 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 327697 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 15:41:49 -0000 Author: pfg Date: Mon Jan 8 15:41:48 2018 New Revision: 327697 URL: https://svnweb.freebsd.org/changeset/base/327697 Log: malloc(9): drop the __result_use_check attribute for the kernel allocator. The __result_use_check attribute was brought to the kernel malloc in r281203 for consistency with the userland malloc. For the case of the M_WAITOK flag, the kernel malloc(), realloc(), and reallocf() cannot return NULL so in that case the __result_use_check attribute makes no sense. We don't have any way of conditionalizing such attributes so just drop it. MFC after: 3 days Modified: head/sys/sys/malloc.h Modified: head/sys/sys/malloc.h ============================================================================== --- head/sys/sys/malloc.h Mon Jan 8 13:43:12 2018 (r327696) +++ head/sys/sys/malloc.h Mon Jan 8 15:41:48 2018 (r327697) @@ -176,7 +176,7 @@ void *contigmalloc(unsigned long size, struct malloc_t __alloc_size(1) __alloc_align(6); 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); + __malloc_like __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); @@ -187,7 +187,7 @@ void malloc_type_freed(struct malloc_type *type, unsig void malloc_type_list(malloc_type_list_func_t *, void *); void malloc_uninit(void *); void *realloc(void *addr, unsigned long size, struct malloc_type *type, - int flags) __result_use_check __alloc_size(2); + int flags) __alloc_size(2); void *reallocf(void *addr, unsigned long size, struct malloc_type *type, int flags) __alloc_size(2); From owner-svn-src-all@freebsd.org Mon Jan 8 15:54: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 0A986E73DF1; Mon, 8 Jan 2018 15:54:31 +0000 (UTC) (envelope-from pfg@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 D732481906; Mon, 8 Jan 2018 15:54:30 +0000 (UTC) (envelope-from pfg@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 257B41BF9; Mon, 8 Jan 2018 15:54:30 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08FsUwN058394; Mon, 8 Jan 2018 15:54:30 GMT (envelope-from pfg@FreeBSD.org) Received: (from pfg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08FsUvX058393; Mon, 8 Jan 2018 15:54:30 GMT (envelope-from pfg@FreeBSD.org) Message-Id: <201801081554.w08FsUvX058393@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: pfg set sender to pfg@FreeBSD.org using -f From: "Pedro F. Giffuni" Date: Mon, 8 Jan 2018 15:54:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327699 - head/sys/sys X-SVN-Group: head X-SVN-Commit-Author: pfg X-SVN-Commit-Paths: head/sys/sys X-SVN-Commit-Revision: 327699 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 15:54:31 -0000 Author: pfg Date: Mon Jan 8 15:54:29 2018 New Revision: 327699 URL: https://svnweb.freebsd.org/changeset/base/327699 Log: Revert r327697: malloc(9): drop the __result_use_check attribute for the kernel allocator. My bad: __result_use_check just checks the for the general and we always want to make sure allocated memory is used, not only checked for nullness. Add it to reallocf since that was missing. Modified: head/sys/sys/malloc.h Modified: head/sys/sys/malloc.h ============================================================================== --- head/sys/sys/malloc.h Mon Jan 8 15:41:49 2018 (r327698) +++ head/sys/sys/malloc.h Mon Jan 8 15:54:29 2018 (r327699) @@ -176,7 +176,7 @@ void *contigmalloc(unsigned long size, struct malloc_t __alloc_size(1) __alloc_align(6); void free(void *addr, struct malloc_type *type); void *malloc(unsigned long size, struct malloc_type *type, int flags) - __malloc_like __alloc_size(1); + __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); @@ -187,9 +187,9 @@ void malloc_type_freed(struct malloc_type *type, unsig void malloc_type_list(malloc_type_list_func_t *, void *); void malloc_uninit(void *); void *realloc(void *addr, unsigned long size, struct malloc_type *type, - int flags) __alloc_size(2); + int flags) __result_use_check __alloc_size(2); void *reallocf(void *addr, unsigned long size, struct malloc_type *type, - int flags) __alloc_size(2); + int flags) __result_use_check __alloc_size(2); struct malloc_type *malloc_desc2type(const char *desc); #endif /* _KERNEL */ From owner-svn-src-all@freebsd.org Mon Jan 8 15:56:42 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 5DA7CE73FB7; Mon, 8 Jan 2018 15:56:42 +0000 (UTC) (envelope-from markj@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 390D881AC0; Mon, 8 Jan 2018 15:56:42 +0000 (UTC) (envelope-from markj@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 6DE821BFA; Mon, 8 Jan 2018 15:56:41 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08Fufe7058539; Mon, 8 Jan 2018 15:56:41 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08FufTl058537; Mon, 8 Jan 2018 15:56:41 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201801081556.w08FufTl058537@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 8 Jan 2018 15:56:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327700 - head/sys/geom/mirror X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/geom/mirror X-SVN-Commit-Revision: 327700 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 15:56:42 -0000 Author: markj Date: Mon Jan 8 15:56:40 2018 New Revision: 327700 URL: https://svnweb.freebsd.org/changeset/base/327700 Log: Sort and remove unneeded includes. MFC after: 1 week Sponsored by: Dell EMC Isilon Modified: head/sys/geom/mirror/g_mirror.c head/sys/geom/mirror/g_mirror_ctl.c Modified: head/sys/geom/mirror/g_mirror.c ============================================================================== --- head/sys/geom/mirror/g_mirror.c Mon Jan 8 15:54:29 2018 (r327699) +++ head/sys/geom/mirror/g_mirror.c Mon Jan 8 15:56:40 2018 (r327700) @@ -31,22 +31,22 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include #include -#include +#include #include #include +#include #include -#include +#include #include +#include +#include #include -#include -#include -#include + #include -#include -#include -#include #include FEATURE(geom_mirror, "GEOM mirroring support"); Modified: head/sys/geom/mirror/g_mirror_ctl.c ============================================================================== --- head/sys/geom/mirror/g_mirror_ctl.c Mon Jan 8 15:54:29 2018 (r327699) +++ head/sys/geom/mirror/g_mirror_ctl.c Mon Jan 8 15:56:40 2018 (r327700) @@ -31,24 +31,17 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include -#include #include #include -#include -#include -#include -#include #include -#include -#include -#include +#include +#include + #include #include -#include -#include #include - static struct g_mirror_softc * g_mirror_find_device(struct g_class *mp, const char *name) From owner-svn-src-all@freebsd.org Mon Jan 8 15:58:22 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 0D989E7410D for ; Mon, 8 Jan 2018 15:58:22 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from sonic312-35.consmr.mail.ne1.yahoo.com (sonic312-35.consmr.mail.ne1.yahoo.com [66.163.191.216]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D6CAD81C57 for ; Mon, 8 Jan 2018 15:58:21 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1515427100; bh=yAzStCyWs8ONtL+8q4Nxb5AoFkj+V+evVoU8JrYSGVg=; h=Subject:From:To:References:Date:In-Reply-To:From:Subject; b=dmRX50hmw9xdaTe75Xu4xZafRYW6WvXZ0S38tg/U1oL1unOmhzIDQrR23xEPK24AVD/AiLYRlMrUHQHYtgCzGcRTy6TlRq3cNVenim6dnZtjgzfTrx6HSLAU0hnK+W+nwp+ntADCvKSO5P4EE5bkYDoYOXTvcQgIB7FFPiJ+OhoJ3Df6O1aQPQUeMpFyEmXHNQCrzvNMxak+3nhtqjtrj+stuUQFV7Xe6hENtFwo+TB/Mtw4BDJLO+kEAYLjgcWQ8rNa4J2UjZPwc3uwdLnUoBZhDw9jidzg/YnazxhVdykrcKWG3WOfvTItuQbCA6YzktiemlUx5BVcha7Lp6DW9A== X-YMail-OSG: KYFlW.YVM1mPY6R7By2zeBKxgkMBCj6pcYUIX541P0aXisX7lPJtQSVHjPl_2pu aNh6pMmI4s7ofI2SjR2gD4aoirJZGzHP9Pgy9ktESJXrFdeuaSqPHk5pn1eiB_Ro55aMhPQdVy7k XrdKSBtz0TeZndZS58dhxA029FjULHUDgXCTjRvtE2p6.F87e4dJK58nmE5wGQMVlXiPRWsyUB.4 UL_Y9TRtuVrE10fXXKLtXPaaBCERwDbz94WmQ9X0VwtBuQlWLOpq35RTcVKcgPNojMq58aRns_34 lI8y2eBT2q8Krk_B7g_rC3A36aOInTXQMHy0h9WxnrjAX2ESCp6uJzctEbMXKKPCdss_tcDsyG4z 5CUPqk77TfsTBcCGp8zllgKNHTnH1nFle3xOMghmjCQQ3UjShfZH97NeY7tdjImS_3Kx3xXXMWTD D3NJWkpq9P9a53QO9vfiTbKHyDrB98TiV0hoif3MKvGj7RcqKJsaW9sL5nJy_1N6BFqMBLbur Received: from sonic.gate.mail.ne1.yahoo.com by sonic312.consmr.mail.ne1.yahoo.com with HTTP; Mon, 8 Jan 2018 15:58:20 +0000 Received: from smtpgate103.mail.ne1.yahoo.com (EHLO [192.168.0.6]) ([216.155.193.162]) by smtp401.mail.ne1.yahoo.com (JAMES SMTP Server ) with ESMTPA ID ae7b781f65a9251b0c615b8e61e02acf; Mon, 08 Jan 2018 15:58:16 +0000 (UTC) Subject: Re: svn commit: r327697 - head/sys/sys From: Pedro Giffuni To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201801081541.w08Ffmm0052729@repo.freebsd.org> Message-ID: Date: Mon, 8 Jan 2018 10:58:16 -0500 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <201801081541.w08Ffmm0052729@repo.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US 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 15:58:22 -0000 On 01/08/18 10:41, Pedro F. Giffuni wrote: > Author: pfg > Date: Mon Jan 8 15:41:48 2018 > New Revision: 327697 > URL: https://svnweb.freebsd.org/changeset/base/327697 > > Log: > malloc(9): drop the __result_use_check attribute for the kernel allocator. > > The __result_use_check attribute was brought to the kernel malloc in > r281203 for consistency with the userland malloc. > > For the case of the M_WAITOK flag, the kernel malloc(), realloc(), and > reallocf() cannot return NULL so in that case the __result_use_check > attribute makes no sense. Bah ... I misinterpreted the attribute (hate it when that happens) reverted in r327697, sorry for the code churn. Pedro. From owner-svn-src-all@freebsd.org Mon Jan 8 16:09:11 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 E46D8E74A3C; Mon, 8 Jan 2018 16:09:11 +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 A005F824ED; Mon, 8 Jan 2018 16:09:11 +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 w08G99DU022352; Mon, 8 Jan 2018 08:09:09 -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 w08G9941022351; Mon, 8 Jan 2018 08:09:09 -0800 (PST) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201801081609.w08G9941022351@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r327699 - head/sys/sys In-Reply-To: <201801081554.w08FsUvX058393@repo.freebsd.org> To: "Pedro F. Giffuni" Date: Mon, 8 Jan 2018 08:09:08 -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: Mon, 08 Jan 2018 16:09:12 -0000 > Author: pfg > Date: Mon Jan 8 15:54:29 2018 > New Revision: 327699 > URL: https://svnweb.freebsd.org/changeset/base/327699 > > Log: > Revert r327697: > malloc(9): drop the __result_use_check attribute for the kernel allocator. > > My bad: __result_use_check just checks the for the general and we always > want to make sure allocated memory is used, not only checked for nullness. > > Add it to reallocf since that was missing. Please try not to combine a revert with an add, it makes it messy to try and figure out things in the future when only the svn log is being used to analyze stuff as digging in mail archives becomes painful. Revert, then commit the add standalone, is the better sequence in this type of situation. > > Modified: > head/sys/sys/malloc.h > > Modified: head/sys/sys/malloc.h > ============================================================================== > --- head/sys/sys/malloc.h Mon Jan 8 15:41:49 2018 (r327698) > +++ head/sys/sys/malloc.h Mon Jan 8 15:54:29 2018 (r327699) > @@ -176,7 +176,7 @@ void *contigmalloc(unsigned long size, struct malloc_t > __alloc_size(1) __alloc_align(6); > void free(void *addr, struct malloc_type *type); > void *malloc(unsigned long size, struct malloc_type *type, int flags) > - __malloc_like __alloc_size(1); > + __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); > @@ -187,9 +187,9 @@ void malloc_type_freed(struct malloc_type *type, unsig > void malloc_type_list(malloc_type_list_func_t *, void *); > void malloc_uninit(void *); > void *realloc(void *addr, unsigned long size, struct malloc_type *type, > - int flags) __alloc_size(2); > + int flags) __result_use_check __alloc_size(2); > void *reallocf(void *addr, unsigned long size, struct malloc_type *type, > - int flags) __alloc_size(2); > + int flags) __result_use_check __alloc_size(2); > > struct malloc_type *malloc_desc2type(const char *desc); > #endif /* _KERNEL */ > > -- Rod Grimes rgrimes@freebsd.org From owner-svn-src-all@freebsd.org Mon Jan 8 16:13: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 F4167E74FEE for ; Mon, 8 Jan 2018 16:13:47 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x235.google.com (mail-io0-x235.google.com [IPv6:2607:f8b0:4001:c06::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B25F782D1E for ; Mon, 8 Jan 2018 16:13:47 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x235.google.com with SMTP id w188so14727956iod.10 for ; Mon, 08 Jan 2018 08:13:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=U2dO0pIfCdQu/wrL3eiThJHNpORugumxOOcai+t91Ao=; b=L86bI7P+kyp0LqV6YMiQ+YTEv8a4rDczkiL0jqGKT7983zkAbIXeflpwG/CLqK+TEN BzRuTNa2+KuaF8o5jjL9buJxYGB8udKyyqziVOfOB7oX2PS17RsCo3XCtRG1iS1XZfSE eGFotCJlNSoKvfsXM6t60+p9xAnDOWxA5kJrN3/2sjhBeAOA3vTc5tXbCCjvWpI1wpwL 4UaeJEhqVQ6Zdc10qtmErOKwzTDS1AKGEtRhZFLbr3Lw6+gm3jW4Lz6N5F7IGJdYFY/l oqpwEANhtwoSMoThcbcvqb6vn732rDe9AXR9MCOO5Ri1SKcCzng39pl056psCr1jtIzm Inqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=U2dO0pIfCdQu/wrL3eiThJHNpORugumxOOcai+t91Ao=; b=HCPEmccz/02U4Y4cl3Y0Vwnk13duvj/dj4LGCD33Kmfb01cV9l7P7HXB0JCvrMt4RW cummNar8EE0m56zO1+ANQvVEHlhsa3yioDh/p18sdGJIVCmnsP/NCOYfylwr6Qm1qZEx /RIZiK8yZ+HePOePPfNvVoFh34OI9XKlkR5JilzI/lv05hhbccp3kw+Qz8taVpNS26Ml 117y/Hs8R0DvG7ctGEDMESUlEBXv9qnBZsgSjrRXPemF3zL9wA3u2Was8HbQBkG8goLw EM0EdwLGo6QttaT/l1U+s9/A8Er2eVvzXiKo9Gk1Z8ZPwSsNh/prVDe0A0m60S4eW5g6 4nhw== X-Gm-Message-State: AKGB3mKq+ubk2fJ6W+mI/mntAgPE6sDH6lSWWyqD3ByF5swYiAwxb00j usiAUjNVSVw5gLKPhaglLByVfJyEiEHFcNrhX2UWnQ== X-Google-Smtp-Source: ACJfBos8I1+y5+c194BRf/4iuCmIysd4xsSPPVcrHvm4+Y6bEMTNquMhBzJbmlGemSIr7m2JAvabxw0JbWVL45FV9tI= X-Received: by 10.36.3.144 with SMTP id e138mr12011934ite.97.1515428027019; Mon, 08 Jan 2018 08:13:47 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.160.217 with HTTP; Mon, 8 Jan 2018 08:13:46 -0800 (PST) X-Originating-IP: [2603:300b:6:5100:a84a:1e5c:a3af:9943] Received: by 10.79.160.217 with HTTP; Mon, 8 Jan 2018 08:13:46 -0800 (PST) In-Reply-To: <0a6ad324-46f2-9270-5abd-dbc3e734cc8b@FreeBSD.org> References: <201801072238.w07McjLP099234@repo.freebsd.org> <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> <0a6ad324-46f2-9270-5abd-dbc3e734cc8b@FreeBSD.org> From: Warner Losh Date: Mon, 8 Jan 2018 09:13:46 -0700 X-Google-Sender-Auth: 2GrbBeM6NyxWZTmwilXOd65Ynnw Message-ID: Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 To: Pedro Giffuni Cc: Ed Schouten , Andrew Turner , Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" 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: Mon, 08 Jan 2018 16:13:48 -0000 On Jan 8, 2018 8:37 AM, "Pedro Giffuni" wrote: On 01/08/18 10:13, Ed Schouten wrote: > Hi Andrew, > > 2018-01-08 8:37 GMT+01:00 Andrew Turner : > >> Won=E2=80=99t this lead to a NULL pointer dereference on overflow? mallo= carray >> can return NULL even with M_WAITOK. >> > Yes, it will, but an overflow shouldn't happen in the first place. > ri_data_len is compared with UIO_MAXIOV a few lines above. Even if an > overflow would happen, this would cause a kernel panic due to a NULL > pointer dereference later on, which is likely easier to debug than > some piece of code that overruns a buffer. > > In this case, mallocarray() is preferred, because it makes it more > obvious that we're allocating a buffer that is accessed as an array, > as opposed to single structure. > > OK... The behavior of mallocarray() somewhat inconsistent with malloc(9), realloc(9) and reallocf(9) but this is clearly documented., so we just assume the developer knows what he/she is doing :). This is one reason it didn't go in before... the error semantics suck... we re are a poor match for existing code. Warner From owner-svn-src-all@freebsd.org Mon Jan 8 16:18: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 BB7D5E75500 for ; Mon, 8 Jan 2018 16:18:36 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1b.ore.mailhop.org (outbound1b.ore.mailhop.org [54.200.247.200]) (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 9B9C383134 for ; Mon, 8 Jan 2018 16:18:36 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 84a4b9c7-f48f-11e7-8486-0934409070aa X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound1.ore.mailhop.org (Halon) with ESMTPSA id 84a4b9c7-f48f-11e7-8486-0934409070aa; Mon, 08 Jan 2018 16:18:10 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id w08GISK5002547; Mon, 8 Jan 2018 09:18:28 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1515428308.44630.2.camel@freebsd.org> Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 From: Ian Lepore To: Warner Losh , Pedro Giffuni Cc: Ed Schouten , Andrew Turner , Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Date: Mon, 08 Jan 2018 09:18:28 -0700 In-Reply-To: References: <201801072238.w07McjLP099234@repo.freebsd.org> <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> <0a6ad324-46f2-9270-5abd-dbc3e734cc8b@FreeBSD.org> Content-Type: text/plain; charset="iso-8859-7" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 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 16:18:36 -0000 On Mon, 2018-01-08 at 09:13 -0700, Warner Losh wrote: > On Jan 8, 2018 8:37 AM, "Pedro Giffuni" wrote: > > > On 01/08/18 10:13, Ed Schouten wrote: > > > > > Hi Andrew, > > > > 2018-01-08 8:37 GMT+01:00 Andrew Turner : > > > > > > > > Won¢t this lead to a NULL pointer dereference on overflow? mallocarray > > > can return NULL even with M_WAITOK. > > > > > Yes, it will, but an overflow shouldn't happen in the first place. > > ri_data_len is compared with UIO_MAXIOV a few lines above. Even if an > > overflow would happen, this would cause a kernel panic due to a NULL > > pointer dereference later on, which is likely easier to debug than > > some piece of code that overruns a buffer. > > > > In this case, mallocarray() is preferred, because it makes it more > > obvious that we're allocating a buffer that is accessed as an array, > > as opposed to single structure. > > > > OK... > The behavior of mallocarray() somewhat inconsistent with malloc(9), > realloc(9) and reallocf(9) but this is clearly documented., so we just > assume the developer knows what he/she is doing :). > > > This is one reason it didn't go in before... the error semantics suck... we > re are a poor match for existing code. > > Warner Yeah, having a bunch of functions with malloc in the name, all taking the same M_WAITOK flag, but that flag has different implications for calling code in regards to just one of the malloc functions... that's just a recipe for creating bugs.  It makes this whole function a bad idea. -- Ian From owner-svn-src-all@freebsd.org Mon Jan 8 16:29:43 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 EA269E75FDE; Mon, 8 Jan 2018 16:29:43 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qk0-x233.google.com (mail-qk0-x233.google.com [IPv6:2607:f8b0:400d:c09::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9CE0683C06; Mon, 8 Jan 2018 16:29:43 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qk0-x233.google.com with SMTP id w184so6657538qka.2; Mon, 08 Jan 2018 08:29:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=Im9tOxLlSvn4x7toFrNKTqrwnJWBNtBzr8+nJnv26Ug=; b=NRdP5O7fMCKczxgMGYbEo94auOqhWq97hbwf9FoEsqiXCJbZh/pKPsOEGVHDRR8mag I42KSlw6Tdv9xKDC+kXYKXJ6iFtQDwUKHsvONZWLbWMu/XqWOzQ5Mn9r6XbSISqLdQNR oKf7wfJ5znbmkP5yRlBsbM9uSIhdp/rroTCankcT3FZagXzATg05oLxEOHfWY+cJC2ZL 1FYeDdsECV4jQlv9odUdQcnWq7URXbMqaS9QGcGuSTklWkBK+FsS2RZ/sj7hH8g4Ebke pG0HfhHeQslK9tOCD6/5ZJWkdgRBfkcUBoV5AumqV4BM5sECeYCN4pbA76knAtnZ/SB+ APZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=Im9tOxLlSvn4x7toFrNKTqrwnJWBNtBzr8+nJnv26Ug=; b=ODHB3hc8oqDlRhyc1/sg53xIyiKYayXTTS+NBfmnq5z/t3SOgV9zvWOypiLpabIjJr CadESgf7kqDAujtAzfgwHOo+7hzTMDfymdI8/1HzKnLxLWRF810suNBQQDYQsLFw+GjS FUUZ2m0tVC6Q59QL/6stxGjW2vnNwZErojx36TMOuTmTZm48zF3EGyb+deyj63xS53vI E0ShYapwyrj3OB2wtrGmCqeWDlwlpKQ7qAvM7Zc3TKRgZkNAcPCPkL5ZB5rXqNyndme6 KxaDvCfijkWbSEzVPAMd9SFIEdAP5zgxhGuGt6cWyuL+Y1zMorOjG9c3GHTKEunmHKFI Ur7A== X-Gm-Message-State: AKwxytdUCOe+ph+92mycNeC4sKTzOPcN7QRGCOAT6vCdqDBFCg3FXf0n q7039yPC2niPrhfwruauamN4OOSd X-Google-Smtp-Source: ACJfBos+tSxR5x9fb7SUN8NXBIVAOgwBe/3uH6iF2UmdNo15o7Sy3ukER2R+aamjNIZu9qS2upNacA== X-Received: by 10.55.143.193 with SMTP id r184mr16078526qkd.193.1515428982259; Mon, 08 Jan 2018 08:29:42 -0800 (PST) Received: from raichu (toroon0560w-lp140-02-70-49-169-112.dsl.bell.ca. [70.49.169.112]) by smtp.gmail.com with ESMTPSA id m44sm7797504qtc.9.2018.01.08.08.29.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jan 2018 08:29:41 -0800 (PST) Sender: Mark Johnston Date: Mon, 8 Jan 2018 11:29:38 -0500 From: Mark Johnston To: Ian Lepore Cc: Warner Losh , Pedro Giffuni , Ed Schouten , Andrew Turner , Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 Message-ID: <20180108162938.GD2412@raichu> References: <201801072238.w07McjLP099234@repo.freebsd.org> <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> <0a6ad324-46f2-9270-5abd-dbc3e734cc8b@FreeBSD.org> <1515428308.44630.2.camel@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1515428308.44630.2.camel@freebsd.org> User-Agent: Mutt/1.9.2 (2017-12-15) 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 16:29:44 -0000 On Mon, Jan 08, 2018 at 09:18:28AM -0700, Ian Lepore wrote: > On Mon, 2018-01-08 at 09:13 -0700, Warner Losh wrote: > > On Jan 8, 2018 8:37 AM, "Pedro Giffuni" wrote: > > On 01/08/18 10:13, Ed Schouten wrote: > > > > > > > > Hi Andrew, > > > > > > 2018-01-08 8:37 GMT+01:00 Andrew Turner : > > > > > > > > > > > Won’t this lead to a NULL pointer dereference on overflow? mallocarray > > > > can return NULL even with M_WAITOK. > > > > > > > Yes, it will, but an overflow shouldn't happen in the first place. > > > ri_data_len is compared with UIO_MAXIOV a few lines above. Even if an > > > overflow would happen, this would cause a kernel panic due to a NULL > > > pointer dereference later on, which is likely easier to debug than > > > some piece of code that overruns a buffer. > > > > > > In this case, mallocarray() is preferred, because it makes it more > > > obvious that we're allocating a buffer that is accessed as an array, > > > as opposed to single structure. > > > > > > OK... > > The behavior of mallocarray() somewhat inconsistent with malloc(9), > > realloc(9) and reallocf(9) but this is clearly documented., so we just > > assume the developer knows what he/she is doing :). > > > > > > This is one reason it didn't go in before... the error semantics suck... we > > re are a poor match for existing code. > > > > Warner > > Yeah, having a bunch of functions with malloc in the name, all taking > the same M_WAITOK flag, but that flag has different implications for > calling code in regards to just one of the malloc functions... contigmalloc(M_WAITOK) isn't guaranteed to succeed either. In that case, M_WAITOK just means "try harder to defragment physical memory in the request space before giving up." > that's just a recipe for creating bugs.  It makes this whole function a bad > idea. A NULL return value from mallocarray() indicates a bug in the caller. I don't see why it isn't preferable to crash quickly and loudly in that case. From owner-svn-src-all@freebsd.org Mon Jan 8 16:36:34 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 E3A45E765F8; Mon, 8 Jan 2018 16:36:34 +0000 (UTC) (envelope-from markj@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 BD98E38C; Mon, 8 Jan 2018 16:36:34 +0000 (UTC) (envelope-from markj@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 0CEA2227A; Mon, 8 Jan 2018 16:36:34 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08GaXkk075694; Mon, 8 Jan 2018 16:36:33 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08GaXWC075691; Mon, 8 Jan 2018 16:36:33 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201801081636.w08GaXWC075691@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 8 Jan 2018 16:36:33 +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: r327701 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 327701 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 16:36:35 -0000 Author: markj Date: Mon Jan 8 16:36:33 2018 New Revision: 327701 URL: https://svnweb.freebsd.org/changeset/base/327701 Log: MFC r322547: Add vm_page_alloc_after(). Modified: stable/11/sys/vm/vm_kern.c stable/11/sys/vm/vm_page.c stable/11/sys/vm/vm_page.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/vm_kern.c ============================================================================== --- stable/11/sys/vm/vm_kern.c Mon Jan 8 15:56:40 2018 (r327700) +++ stable/11/sys/vm/vm_kern.c Mon Jan 8 16:36:33 2018 (r327701) @@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -329,7 +330,7 @@ int kmem_back(vm_object_t object, vm_offset_t addr, vm_size_t size, int flags) { vm_offset_t offset, i; - vm_page_t m; + vm_page_t m, mpred; int pflags; KASSERT(object == kmem_object || object == kernel_object, @@ -338,10 +339,13 @@ kmem_back(vm_object_t object, vm_offset_t addr, vm_siz offset = addr - VM_MIN_KERNEL_ADDRESS; pflags = malloc2vm_flags(flags) | VM_ALLOC_NOBUSY | VM_ALLOC_WIRED; - VM_OBJECT_WLOCK(object); - for (i = 0; i < size; i += PAGE_SIZE) { + i = 0; retry: - m = vm_page_alloc(object, atop(offset + i), pflags); + VM_OBJECT_WLOCK(object); + mpred = vm_radix_lookup_le(&object->rtree, atop(offset + i)); + for (; i < size; i += PAGE_SIZE, mpred = m) { + m = vm_page_alloc_after(object, atop(offset + i), pflags, + mpred); /* * Ran out of space, free everything up and return. Don't need @@ -352,7 +356,6 @@ retry: VM_OBJECT_WUNLOCK(object); if ((flags & M_NOWAIT) == 0) { VM_WAIT; - VM_OBJECT_WLOCK(object); goto retry; } kmem_unback(object, addr, i); Modified: stable/11/sys/vm/vm_page.c ============================================================================== --- stable/11/sys/vm/vm_page.c Mon Jan 8 15:56:40 2018 (r327700) +++ stable/11/sys/vm/vm_page.c Mon Jan 8 16:36:33 2018 (r327701) @@ -1583,15 +1583,32 @@ vm_page_rename(vm_page_t m, vm_object_t new_object, vm vm_page_t vm_page_alloc(vm_object_t object, vm_pindex_t pindex, int req) { - vm_page_t m, mpred; + + return (vm_page_alloc_after(object, pindex, req, object != NULL ? + vm_radix_lookup_le(&object->rtree, pindex) : NULL)); +} + +/* + * Allocate a page in the specified object with the given page index. To + * optimize insertion of the page into the object, the caller must also specifiy + * the resident page in the object with largest index smaller than the given + * page index, or NULL if no such page exists. + */ +vm_page_t +vm_page_alloc_after(vm_object_t object, vm_pindex_t pindex, int req, + vm_page_t mpred) +{ + vm_page_t m; int flags, req_class; - mpred = NULL; /* XXX: pacify gcc */ KASSERT((object != NULL) == ((req & VM_ALLOC_NOOBJ) == 0) && (object != NULL || (req & VM_ALLOC_SBUSY) == 0) && ((req & (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)) != (VM_ALLOC_NOBUSY | VM_ALLOC_SBUSY)), - ("vm_page_alloc: inconsistent object(%p)/req(%x)", object, req)); + ("inconsistent object(%p)/req(%x)", object, req)); + KASSERT(mpred == NULL || mpred->pindex < pindex, + ("mpred %p doesn't precede pindex 0x%jx", mpred, + (uintmax_t)pindex)); if (object != NULL) VM_OBJECT_ASSERT_WLOCKED(object); @@ -1606,12 +1623,6 @@ vm_page_alloc(vm_object_t object, vm_pindex_t pindex, if (curproc == pageproc && req_class != VM_ALLOC_INTERRUPT) req_class = VM_ALLOC_SYSTEM; - if (object != NULL) { - mpred = vm_radix_lookup_le(&object->rtree, pindex); - KASSERT(mpred == NULL || mpred->pindex != pindex, - ("vm_page_alloc: pindex already allocated")); - } - /* * Allocate a page if the number of free pages exceeds the minimum * for the request class. @@ -1658,7 +1669,7 @@ vm_page_alloc(vm_object_t object, vm_pindex_t pindex, /* * At this point we had better have found a good page. */ - KASSERT(m != NULL, ("vm_page_alloc: missing page")); + KASSERT(m != NULL, ("missing page")); vm_phys_freecnt_adj(m, -1); if ((m->flags & PG_ZERO) != 0) vm_page_zero_count--; @@ -3261,7 +3272,7 @@ int vm_page_grab_pages(vm_object_t object, vm_pindex_t pindex, int allocflags, vm_page_t *ma, int count) { - vm_page_t m; + vm_page_t m, mpred; int i; bool sleep; @@ -3278,7 +3289,12 @@ vm_page_grab_pages(vm_object_t object, vm_pindex_t pin return (0); i = 0; retrylookup: - m = vm_page_lookup(object, pindex + i); + m = vm_radix_lookup_le(&object->rtree, pindex + i); + if (m == NULL || m->pindex != pindex + i) { + mpred = m; + m = NULL; + } else + mpred = TAILQ_PREV(m, pglist, listq); for (; i < count; i++) { if (m != NULL) { sleep = (allocflags & VM_ALLOC_IGN_SBUSY) != 0 ? @@ -3310,8 +3326,9 @@ retrylookup: if ((allocflags & VM_ALLOC_SBUSY) != 0) vm_page_sbusy(m); } else { - m = vm_page_alloc(object, pindex + i, (allocflags & - ~VM_ALLOC_IGN_SBUSY) | VM_ALLOC_COUNT(count - i)); + m = vm_page_alloc_after(object, pindex + i, + (allocflags & ~VM_ALLOC_IGN_SBUSY) | + VM_ALLOC_COUNT(count - i), mpred); if (m == NULL) { if ((allocflags & VM_ALLOC_NOWAIT) != 0) break; @@ -3326,7 +3343,7 @@ retrylookup: pmap_zero_page(m); m->valid = VM_PAGE_BITS_ALL; } - ma[i] = m; + ma[i] = mpred = m; m = vm_page_next(m); } return (i); Modified: stable/11/sys/vm/vm_page.h ============================================================================== --- stable/11/sys/vm/vm_page.h Mon Jan 8 15:56:40 2018 (r327700) +++ stable/11/sys/vm/vm_page.h Mon Jan 8 16:36:33 2018 (r327701) @@ -462,7 +462,8 @@ void vm_page_free_zero(vm_page_t m); void vm_page_activate (vm_page_t); void vm_page_advise(vm_page_t m, int advice); -vm_page_t vm_page_alloc (vm_object_t, vm_pindex_t, int); +vm_page_t vm_page_alloc(vm_object_t, vm_pindex_t, int); +vm_page_t vm_page_alloc_after(vm_object_t, vm_pindex_t, int, vm_page_t); vm_page_t vm_page_alloc_contig(vm_object_t object, vm_pindex_t pindex, int req, u_long npages, vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary, vm_memattr_t memattr); From owner-svn-src-all@freebsd.org Mon Jan 8 17:02: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 C9E1FE77CEF for ; Mon, 8 Jan 2018 17:02:46 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x22d.google.com (mail-io0-x22d.google.com [IPv6:2607:f8b0:4001:c06::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 89AB02A08 for ; Mon, 8 Jan 2018 17:02:46 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x22d.google.com with SMTP id n14so15068977iob.4 for ; Mon, 08 Jan 2018 09:02:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=unTpTTy5P5yekblp+kxMeO/ogtZMPUK2fYnEk0u73O0=; b=XCecOU/uNDpaoqlC80WBaaJWOwROagFQdlQwNbJ3k199hnna+jKuknyX2ddmkHiIIL rk/b1EYpSA8xhZqcLJGO92tAqz8t7bAt9FNcLY6Om9q9yCfTStjvUVQYcI0PuFq3TOrl KtP7hS1DfRIQn7qdPSz9eMFkAjdGSLrDqP5bivbibrTO4G0lRXi11fW85oEBcRRp4JCy VxpRcD1Y5tRyxLrDvpQYdwCXVDYQoDofNxEnhcDq1D+H4VcRl5XNzGftdlIIu4axoDfZ JzSDqdQlVma+Y6H/xuio60MA3jwAD6qv+JQwr8XkftleWudWnbIrDVIkBSa9nRzTA9oX QAyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=unTpTTy5P5yekblp+kxMeO/ogtZMPUK2fYnEk0u73O0=; b=N70JavB4zmLyYGvcE1s/KhXeG33PJuxam5M12VebUIvLRue6vmVXaD9Q28ldrW7AA8 0ur3KYvytzCfx9NGSIii23QBGaZAvpfn7J8UWyBSSlFlxYsowHR9l365kS6UdkwjTmQo nUmNoTxp+FQOFRUtMeZNpV5ZmbGF4olm3lZineXCVz0P/HNTjtO01g/g2lsXmZS8Ofo4 rRfa3Ned4YCNwN8uHkGqNxaBVxsXw1FFLz4M8sCDAVSWKcqrV2pMQ2kvnYFlsLyVFLOv TG1D6b2DxdkayfcOsmkEPeyKbc99+EJ0RZrSTI9jVvEdCm4NZYzpnEpC7reHWJMxF8FI suiA== X-Gm-Message-State: AKwxytfsm2Us5BtUjPeaxO4zI4VkgkdGFU9NT5HBP9rN3xnbOZJefWJF xYijlV7MAN467ae6De3UH34pvYaxY1HLFNOv7ox9iA== X-Google-Smtp-Source: ACJfBot5MLf47CGTojacU1hu8Zxwg3+gS8wBCrYqgTMujYBR8G0WRHXTK6o8VfSxKTZtihBNbnZ3Y4loIv1p23MJmz4= X-Received: by 10.36.91.210 with SMTP id g201mr8912782itb.50.1515430965869; Mon, 08 Jan 2018 09:02:45 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.160.217 with HTTP; Mon, 8 Jan 2018 09:02:45 -0800 (PST) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: <20180108162938.GD2412@raichu> References: <201801072238.w07McjLP099234@repo.freebsd.org> <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> <0a6ad324-46f2-9270-5abd-dbc3e734cc8b@FreeBSD.org> <1515428308.44630.2.camel@freebsd.org> <20180108162938.GD2412@raichu> From: Warner Losh Date: Mon, 8 Jan 2018 10:02:45 -0700 X-Google-Sender-Auth: H2NfmkKECbc5gxtf5L3fpojOZjk Message-ID: Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 To: Mark Johnston Cc: Ian Lepore , Pedro Giffuni , Ed Schouten , Andrew Turner , Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" 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: Mon, 08 Jan 2018 17:02:46 -0000 On Mon, Jan 8, 2018 at 9:29 AM, Mark Johnston wrote: > On Mon, Jan 08, 2018 at 09:18:28AM -0700, Ian Lepore wrote: > > On Mon, 2018-01-08 at 09:13 -0700, Warner Losh wrote: > > > On Jan 8, 2018 8:37 AM, "Pedro Giffuni" wrote: > > > On 01/08/18 10:13, Ed Schouten wrote: > > > > > > > > > > > Hi Andrew, > > > > > > > > 2018-01-08 8:37 GMT+01:00 Andrew Turner : > > > > > > > > > > > > > > Won=E2=80=99t this lead to a NULL pointer dereference on overflow= ? > mallocarray > > > > > can return NULL even with M_WAITOK. > > > > > > > > > Yes, it will, but an overflow shouldn't happen in the first place. > > > > ri_data_len is compared with UIO_MAXIOV a few lines above. Even if = an > > > > overflow would happen, this would cause a kernel panic due to a NUL= L > > > > pointer dereference later on, which is likely easier to debug than > > > > some piece of code that overruns a buffer. > > > > > > > > In this case, mallocarray() is preferred, because it makes it more > > > > obvious that we're allocating a buffer that is accessed as an array= , > > > > as opposed to single structure. > > > > > > > > OK... > > > The behavior of mallocarray() somewhat inconsistent with malloc(9), > > > realloc(9) and reallocf(9) but this is clearly documented., so we jus= t > > > assume the developer knows what he/she is doing :). > > > > > > > > > This is one reason it didn't go in before... the error semantics > suck... we > > > re are a poor match for existing code. > > > > > > Warner > > > > Yeah, having a bunch of functions with malloc in the name, all taking > > the same M_WAITOK flag, but that flag has different implications for > > calling code in regards to just one of the malloc functions... > > contigmalloc(M_WAITOK) isn't guaranteed to succeed either. In that case, > M_WAITOK just means "try harder to defragment physical memory in the > request space before giving up." > > > that's just a recipe for creating bugs. It makes this whole function a > bad > > idea. > > A NULL return value from mallocarray() indicates a bug in the caller. I > don't see why it isn't preferable to crash quickly and loudly in that > case. > When this came up before, people wanted a check_mallocarray(a, b) so they could centralize all the integer overflow knowledge in one place... Seems like we're creating ABIs that are more error prone than the problem we're trying to catch... Warner From owner-svn-src-all@freebsd.org Mon Jan 8 17:28: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 16929E794AC; Mon, 8 Jan 2018 17:28:53 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (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 DFB146367D; Mon, 8 Jan 2018 17:28:52 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id B39975A9F15; Mon, 8 Jan 2018 17:28:50 +0000 (UTC) Date: Mon, 8 Jan 2018 17:28:50 +0000 From: Brooks Davis To: Ed Schouten Cc: Andrew Turner , Ed Schouten , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r327684 - in head/sys/compat: cloudabi32 cloudabi64 Message-ID: <20180108172850.GI95035@spindle.one-eyed-alien.net> References: <201801072238.w07McjLP099234@repo.freebsd.org> <8D8CA434-2A87-44D9-AC27-5166802FBBC2@fubar.geek.nz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="SUk9VBj82R8Xhb8H" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) 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 17:28:53 -0000 --SUk9VBj82R8Xhb8H Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 08, 2018 at 04:13:42PM +0100, Ed Schouten wrote: > Hi Andrew, >=20 > 2018-01-08 8:37 GMT+01:00 Andrew Turner : > > Won???t this lead to a NULL pointer dereference on overflow? mallocarra= y can return NULL even with M_WAITOK. >=20 > Yes, it will, but an overflow shouldn't happen in the first place. > ri_data_len is compared with UIO_MAXIOV a few lines above. Even if an > overflow would happen, this would cause a kernel panic due to a NULL > pointer dereference later on, which is likely easier to debug than > some piece of code that overruns a buffer. Given that the overflow is due to a bug, there's an argument we should panic rather than returning NULL even in the M_NOWAIT case so we produce a useful message in exactly the right place. -- Brooks --SUk9VBj82R8Xhb8H Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJaU6pSAAoJEKzQXbSebgfAoBkH/1qw/k1rmZfSDF2NG9MK26VK iYSOYHlCQsy/H50X5a1QIeXWvWJvHPrctqS40i5l5R32lo9I9NEolAmEy2/TI2CW 9VlMG7zqQ9jPTtK0wbKg/rZtcxX4pSTRLRFnFNm0HDUzqqXCHUoJ/+7SRhYvnRkI ZXbgKm9XCKKyBAVazu1Cu1UmmwhUS30+xx6zxX1KVjFB8pgsk6ildJGEf7xp2sR8 VRmAyCKy3KW+1iqx4/BgSd1zuJIPbXU74fCSp/ueFKOkSPay6XktmgKzraeGzYh+ /hZXqIf444h/+QO1m+GYW862T8/fNom017D9xnl23F6yA5yLRaLyabLPMSdoAtY= =KNFw -----END PGP SIGNATURE----- --SUk9VBj82R8Xhb8H-- From owner-svn-src-all@freebsd.org Mon Jan 8 18:08: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 E1D8FE7BBF1; Mon, 8 Jan 2018 18:08:09 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-x232.google.com (mail-io0-x232.google.com [IPv6:2607:f8b0:4001:c06::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AB1076A48F; Mon, 8 Jan 2018 18:08:09 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-x232.google.com with SMTP id q188so15567700iod.1; Mon, 08 Jan 2018 10:08:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=vzmIsZVqzoC8kFyncDcqshvN9zlsRaDR3B2vkRk4KTU=; b=mBsMP1PPPm1YVByBbmFBN990pqVKFMSP7+RLr15gGJPw/nNgEsBbE4c5UmaNDohkWs 5FTm/vXsmFj6Id+CbUmKvw/8NUih+lh+3R55PUNnZDjCvf+aJ/ry2VTnX3XYrMRlquLJ DxTVnVRnepD6vLrXoZAZbv2re9URh6cyobUATh233QN+HySLccpTIM9gX8xX18ZBwnSC KYPxYSZ33/oAbii1EJXTu9OK6R/kVnVJF3N3E9A7eHFGDPvyATWezrPk+ATxDDcDSbUv M5l/GcCYXlLsxW/hwnpwQRv5aG+GdWWrG92uLyLRFkbK4Oew8chXHx+SfuRuzF82IePt 2ntQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=vzmIsZVqzoC8kFyncDcqshvN9zlsRaDR3B2vkRk4KTU=; b=YXni+AX6ObE5uUHlhohw0IA6nIrXuSTehGaNBn62tP+q4xYzIENLjXOCydhICRZDK6 VCwvZhoNKmTO5oYo3qroW1CTN0w3PGH28by8dyfk3ZQNID03ZO23aG4LAHwokqPVe/by 38xSbapzhfcH2iK0l1jf51XvATHHTxoSobPRU1MTr89n6m9RpThpYQiBAcYHTvuoTsGY QNo5xqNjrSRd0lZkthKIazKuG0YGFRBagS5IXccwiHX1XdDmmUhCKzGHt2fVYFt/gD1y 83FnFlrc+CQZU3pljUUUTaznv00B7KPswnq0Wd7dvt7+0bWVn64oFHKC83/xbr9M48hq 0n/w== X-Gm-Message-State: AKGB3mK7mmKrj7sjxNzF8xUMMK1tCpb7jJyhKt2ONIWO7qFQblQqxnJe YvR6e1c51Qc3KdwnKCLx/6a81ncVy9zSQjpH2em9ERVW X-Google-Smtp-Source: ACJfBouIYKdvxerTQ5qC6SjOyrfgrnqjZKy681McOKVn4XjZoMEa9DiMp89Cz8/as2mzLGQyv+whV6osL8W5bby540Q= X-Received: by 10.36.47.207 with SMTP id j198mr12381787itj.119.1515434888913; Mon, 08 Jan 2018 10:08:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.15.193 with HTTP; Mon, 8 Jan 2018 10:08:08 -0800 (PST) In-Reply-To: <201801081541.w08Ffmm0052729@repo.freebsd.org> References: <201801081541.w08Ffmm0052729@repo.freebsd.org> From: Conrad Meyer Date: Mon, 8 Jan 2018 10:08:08 -0800 Message-ID: Subject: Re: svn commit: r327697 - head/sys/sys To: "Pedro F. Giffuni" Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" 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 18:08:10 -0000 Hi, Response inline. On Mon, Jan 8, 2018 at 7:41 AM, Pedro F. Giffuni wrote: > Author: pfg > Date: Mon Jan 8 15:41:48 2018 > New Revision: 327697 > URL: https://svnweb.freebsd.org/changeset/base/327697 > > Log: > malloc(9): drop the __result_use_check attribute for the kernel allocator. > > The __result_use_check attribute was brought to the kernel malloc in > r281203 for consistency with the userland malloc. > > For the case of the M_WAITOK flag, the kernel malloc(), realloc(), and > reallocf() cannot return NULL so in that case the __result_use_check > attribute makes no sense. > > We don't have any way of conditionalizing such attributes so just drop it. Could we conditionalize the attribute using two different names and a macro that inspected the (typically) constant flags argument? Something like this: #define malloc(s, t, f) \ (__builtin_constant_p(f) && (f & M_WAITOK) != 0) ? _malloc_waitok(s, t, f) : _malloc(s, t, f) void *_malloc(...) __malloc_like __alloc_size(1); void *_malloc_waitok(...) __malloc_like __result_use_check __alloc_size(1); The two names would just be aliases, or one could invoke the other as an inline function. Best, Conrad From owner-svn-src-all@freebsd.org Mon Jan 8 18:44: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 A1C32E7DF4F; Mon, 8 Jan 2018 18:44:37 +0000 (UTC) (envelope-from jhb@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 638F36C532; Mon, 8 Jan 2018 18:44:37 +0000 (UTC) (envelope-from jhb@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 8B90A3C16; Mon, 8 Jan 2018 18:44:36 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08IiaxV033486; Mon, 8 Jan 2018 18:44:36 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08Iia97033485; Mon, 8 Jan 2018 18:44:36 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201801081844.w08Iia97033485@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 8 Jan 2018 18:44:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327703 - head/stand/mips/beri/boot2 X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/stand/mips/beri/boot2 X-SVN-Commit-Revision: 327703 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 18:44:37 -0000 Author: jhb Date: Mon Jan 8 18:44:36 2018 New Revision: 327703 URL: https://svnweb.freebsd.org/changeset/base/327703 Log: Define __dmadat after #include'ing ufsread.c. The __dmadat variable is a statically allocated I/O buffer. The type is declared in the ufsread.c source file and clang warns if a variable is defined before it's type is declared. Sponsored by: DARPA / AFRL Modified: head/stand/mips/beri/boot2/boot2.c Modified: head/stand/mips/beri/boot2/boot2.c ============================================================================== --- head/stand/mips/beri/boot2/boot2.c Mon Jan 8 18:42:40 2018 (r327702) +++ head/stand/mips/beri/boot2/boot2.c Mon Jan 8 18:44:36 2018 (r327703) @@ -118,8 +118,6 @@ static const unsigned char flags[NOPT] = { static const char *const dev_nm[] = {"dram", "cfi", "sdcard"}; static const u_int dev_nm_count = nitems(dev_nm); -static struct dmadat __dmadat; - static struct dsk { unsigned type; /* BOOTINFO_DEV_TYPE_x object type. */ uintptr_t unitptr; /* Unit number or pointer to object. */ @@ -149,9 +147,10 @@ static int dskread(void *, unsigned, unsigned); static int xputc(int); static int xgetc(int); - #define UFS_SMALL_CGBASE #include "ufsread.c" + +static struct dmadat __dmadat; static inline int xfsread(ufs_ino_t inode, void *buf, size_t nbyte) From owner-svn-src-all@freebsd.org Mon Jan 8 18:46: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 4F16CE7E08A; Mon, 8 Jan 2018 18:46:12 +0000 (UTC) (envelope-from jhb@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 E36906C715; Mon, 8 Jan 2018 18:46:11 +0000 (UTC) (envelope-from jhb@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 D9D263C17; Mon, 8 Jan 2018 18:46:10 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08IkAV7033599; Mon, 8 Jan 2018 18:46:10 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08IkApk033598; Mon, 8 Jan 2018 18:46:10 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201801081846.w08IkApk033598@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 8 Jan 2018 18:46:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327704 - head/stand/mips/beri/loader X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/stand/mips/beri/loader X-SVN-Commit-Revision: 327704 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 18:46:12 -0000 Author: jhb Date: Mon Jan 8 18:46:10 2018 New Revision: 327704 URL: https://svnweb.freebsd.org/changeset/base/327704 Log: Fix printf missing format variables warnings. Include the failing kernel file name for errors in beri_elf64_exec(). Sponsored by: DARPA / AFRL Modified: head/stand/mips/beri/loader/exec.c Modified: head/stand/mips/beri/loader/exec.c ============================================================================== --- head/stand/mips/beri/loader/exec.c Mon Jan 8 18:44:36 2018 (r327703) +++ head/stand/mips/beri/loader/exec.c Mon Jan 8 18:46:10 2018 (r327704) @@ -80,14 +80,14 @@ beri_elf64_exec(struct preloaded_file *fp) md = file_findmetadata(fp, MODINFOMD_ELFHDR); if (md == NULL) { - printf("%s: file_findmetadata failed\n"); + printf("%s: file_findmetadata failed\n", fp->f_name); return (EFTYPE); } ehdr = (Elf_Ehdr *)md->md_data; error = md_load64(fp->f_args, &mdp); if (error) { - printf("%s: md_load64 failed\n"); + printf("%s: md_load64 failed\n", fp->f_name); return (error); } From owner-svn-src-all@freebsd.org Mon Jan 8 18:47: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 F0D90E7E262; Mon, 8 Jan 2018 18:47:36 +0000 (UTC) (envelope-from jhb@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 CC1446C96E; Mon, 8 Jan 2018 18:47:36 +0000 (UTC) (envelope-from jhb@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 14DE83C1D; Mon, 8 Jan 2018 18:47:36 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08IlZnT033685; Mon, 8 Jan 2018 18:47:35 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08IlZ7F033684; Mon, 8 Jan 2018 18:47:35 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201801081847.w08IlZ7F033684@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 8 Jan 2018 18:47:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327705 - head/stand/mips/beri/common X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/stand/mips/beri/common X-SVN-Commit-Revision: 327705 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 18:47:37 -0000 Author: jhb Date: Mon Jan 8 18:47:35 2018 New Revision: 327705 URL: https://svnweb.freebsd.org/changeset/base/327705 Log: Use instead of and in boot code. In the freestanding boot compile environment, standard headers are not available. Curiously, only building with clang exposed this as compiles with external GCC still succeeded. Sponsored by: DARPA / AFRL Modified: head/stand/mips/beri/common/sdcard.c Modified: head/stand/mips/beri/common/sdcard.c ============================================================================== --- head/stand/mips/beri/common/sdcard.c Mon Jan 8 18:46:10 2018 (r327704) +++ head/stand/mips/beri/common/sdcard.c Mon Jan 8 18:47:35 2018 (r327705) @@ -33,8 +33,7 @@ #include #include -#include -#include +#include /* From owner-svn-src-all@freebsd.org Mon Jan 8 19:02:11 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 2DD6FE59230 for ; Mon, 8 Jan 2018 19:02:11 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-it0-x235.google.com (mail-it0-x235.google.com [IPv6:2607:f8b0:4001:c0b::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E65EE6D9D7 for ; Mon, 8 Jan 2018 19:02:10 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-it0-x235.google.com with SMTP id b77so5483355itd.0 for ; Mon, 08 Jan 2018 11:02:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=RIaf12sFUpJVrwa1KFQE11SGUvvMkEGGgvsWdlkrxqw=; b=SMdqxwXlBlksJychW225RJeHBQjmUqLRzmOKNqvexmKRljMi0qXBvAnzDn+KNTgiC+ 1hAMwY2vF9m4g0AHZAVNFhNBwFR9EXKsWd5RjgW3wVdKFml0txFOjKaV6ERn9JwoIU96 H5+ECPX5asYsn/ACy7ZkNKiVuHPBfkk0II09NeeicoHZ3V1d+c2ZHYBWz9cPUAqqkhP1 wCQsLmagjMRQDfr+unCZfP7hPFVrYSG4PWMy8zs5DiWR451XAvdUNf2iZGSUdJtTWQ8A XI9dS/wvFKI/Csu6/wXQgVZEnXEXN2PyFiCEr3yQtrxs+OqOIjUDK/18pEifYcywgKcW r07g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=RIaf12sFUpJVrwa1KFQE11SGUvvMkEGGgvsWdlkrxqw=; b=DUVhQmCHjllEdR3hOxZBfMGbkvdzdt7MtOu8x9PwA2geDWOmPZeIkJ9HAxnhHuMMth bT/as76vZSSjrboTGqL9JDV7XiUli/dSssHsdCC9lgEcyMGXbQ0+Zvaf+qu7A/u5eKs8 g0ytUp+yejHhDbI8+xiEqyADkf9Gr86vJYQ1wdSk1Mvouahe/1ljIo3opXAZIHrR47xr shXkXzzTDGhTWm7SS9Sq6lPB6749ilrxxN8rTRjpT6rjusCFAMIsX9y76EP4pmOt6TRV sW5dTJE03GtbDWGHXaROQE4s8iiunClNba8gGNQNRzUzhfQ6XSaK3BkIK3DttYcFMdui 8Jog== X-Gm-Message-State: AKGB3mLeVmNx+xmHy0ylxNhAgwwNq29Df/l4zOHTX9/pSLL+RTctAQoU HU7v/8n5lMDCwDzYaGb94+4LF4cSRwkT8Wk7fqLoYQ== X-Google-Smtp-Source: ACJfBovjMjZdTdjyofvO5b2rBPBK6Xo7201Z18c/4/rvXjnhp5nexQpzu4zPjADphOI2hU+VqjpEJwbSf/UHmYDJPUo= X-Received: by 10.36.1.16 with SMTP id 16mr5920178itk.115.1515438130141; Mon, 08 Jan 2018 11:02:10 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.160.217 with HTTP; Mon, 8 Jan 2018 11:02:09 -0800 (PST) X-Originating-IP: [2603:300b:6:5100:1052:acc7:f9de:2b6d] In-Reply-To: <201801081847.w08IlZ7F033684@repo.freebsd.org> References: <201801081847.w08IlZ7F033684@repo.freebsd.org> From: Warner Losh Date: Mon, 8 Jan 2018 12:02:09 -0700 X-Google-Sender-Auth: G_NiX0Xu7iCpuPdpkPnQQzuty3U Message-ID: Subject: Re: svn commit: r327705 - head/stand/mips/beri/common To: John Baldwin Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" 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: Mon, 08 Jan 2018 19:02:11 -0000 This should have been a nop... libsa specifically creates 'safe' headers for all the standard ones. Ah, libsa creates a perfectly fine stdint.h, but not a inttypes.h... Warner On Mon, Jan 8, 2018 at 11:47 AM, John Baldwin wrote: > Author: jhb > Date: Mon Jan 8 18:47:35 2018 > New Revision: 327705 > URL: https://svnweb.freebsd.org/changeset/base/327705 > > Log: > Use instead of and in boot code. > > In the freestanding boot compile environment, standard headers are not > available. Curiously, only building with clang exposed this as compiles > with external GCC still succeeded. > > Sponsored by: DARPA / AFRL > > Modified: > head/stand/mips/beri/common/sdcard.c > > Modified: head/stand/mips/beri/common/sdcard.c > ============================================================ > ================== > --- head/stand/mips/beri/common/sdcard.c Mon Jan 8 18:46:10 2018 > (r327704) > +++ head/stand/mips/beri/common/sdcard.c Mon Jan 8 18:47:35 2018 > (r327705) > @@ -33,8 +33,7 @@ > #include > #include > > -#include > -#include > +#include > > > /* > > From owner-svn-src-all@freebsd.org Mon Jan 8 20:08:15 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 E6933E5E129 for ; Mon, 8 Jan 2018 20:08:15 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from sonic302-36.consmr.mail.gq1.yahoo.com (sonic302-36.consmr.mail.gq1.yahoo.com [98.137.68.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C14527136A for ; Mon, 8 Jan 2018 20:08:15 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1515442088; bh=mUMIJf2mzkP+cCeDslERQ+/yADweFxTy/aJRum1lRbM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=Tk4mpd8WhyhH4HiOp9YpAQk51OeoVyZmIGg5iWcBaa1fC9O2pMlRkvYmtWEw1Y871hSUmJwgbqYHfEy+VKd219xkZWnskDX9xHhTWFXjfm+yCBNDqeQTg8J4yVe0G/pQ769lQSnLGhyo9tw4LPAU4vNRrP1b6luL/B4FBRcW0D7zBD18VKgVQ5zUKRBV8V9tIqrxwPc9sn/7dhZLvDdeO4DJNDAWsVzrumpPDi+1re5UvqhYPZd4IIWRmok63WPeKWw/dL85VllfE2JgC+u+oGLJVvXqdGZGgtKMiG05urpoT6eT8gttOYnpN0jFrWk7s0BX3/t60Q4/WRav3327KQ== X-YMail-OSG: pPdtcRkVM1ms67vhmjHuuRBCOnLToajNqaerhKu6JvOl4ZquSbttYP.cf_nUMwc 55r2P5AOSdO3B0K3UH02_lGZ5zm3uy5z4NkESlgWujX27XrYxYqmgFjmWHAkDZNVZ8xHz9qBbmxY yC0AS9jQXIkfxiCWVoGYd5TRqj6lw1v6djJmEwTgMB39U2hufvX0c.QQggJL0yDwKDE_mdnkd1OB NqywQnGr4MHW8OGPUX8I.xUeEf.0j7BVBCzYRRJ1xWufK8cjHUyz7POlrbIgfE6jB3LvO8RzBC0Z ElWOq4wP5QeZaSJxoU84rs_D.UyCNHy_8oNUpeEkGaZiagKUu2EFGSX5HsIo6p7jSZBeHlgvHmIM 9lRM0V5V4TYNoVAxFeXbjza_ueSoOWMvGz5FGyco9.MpvyCzwWTo4Rgny0PagdOJkWZzlXeKzIDC NEBcgyt0EAV25kTYoyVrprQNOAk3naZfoKRJXVTdWIvpta6MHDk8bBQo_ZJw46frGJxeCwIGg Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.gq1.yahoo.com with HTTP; Mon, 8 Jan 2018 20:08:08 +0000 Received: from smtp102.rhel.mail.gq1.yahoo.com (EHLO [192.168.0.6]) ([216.39.57.211]) by smtp410.mail.gq1.yahoo.com (JAMES SMTP Server ) with ESMTPA ID c1b5a2f9f5d40448375d855a6ae635ce; Mon, 08 Jan 2018 20:08:04 +0000 (UTC) Subject: Re: svn commit: r327697 - head/sys/sys To: Conrad Meyer Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201801081541.w08Ffmm0052729@repo.freebsd.org> From: Pedro Giffuni Organization: FreeBSD Project Message-ID: <1665ddb4-64ad-5d01-902e-2a77a8f5b50c@FreeBSD.org> Date: Mon, 8 Jan 2018 15:08:04 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US 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 20:08:16 -0000 Hi; On 08/01/2018 13:08, Conrad Meyer wrote: > Hi, > > Response inline. > > On Mon, Jan 8, 2018 at 7:41 AM, Pedro F. Giffuni wrote: >> Author: pfg >> Date: Mon Jan 8 15:41:48 2018 >> New Revision: 327697 >> URL: https://svnweb.freebsd.org/changeset/base/327697 >> >> Log: >> malloc(9): drop the __result_use_check attribute for the kernel allocator. >> >> The __result_use_check attribute was brought to the kernel malloc in >> r281203 for consistency with the userland malloc. >> >> For the case of the M_WAITOK flag, the kernel malloc(), realloc(), and >> reallocf() cannot return NULL so in that case the __result_use_check >> attribute makes no sense. >> >> We don't have any way of conditionalizing such attributes so just drop it. > Could we conditionalize the attribute using two different names and a > macro that inspected the (typically) constant flags argument? > Something like this: > > #define malloc(s, t, f) \ > (__builtin_constant_p(f) && (f & M_WAITOK) != 0) ? > _malloc_waitok(s, t, f) : _malloc(s, t, f) > void *_malloc(...) __malloc_like __alloc_size(1); > void *_malloc_waitok(...) __malloc_like __result_use_check __alloc_size(1); > > The two names would just be aliases, or one could invoke the other as > an inline function. That would work but I completely misunderstood the GCC attribute. Quoting the GCC documentation: ____ warn_unused_result The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug, such as realloc. ____ Retrospectively, our attribute is badly named but it was very difficult to come up with a good name. Pedro. From owner-svn-src-all@freebsd.org Mon Jan 8 20:14:18 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 38458E5E836; Mon, 8 Jan 2018 20:14:18 +0000 (UTC) (envelope-from cem@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 124A7718B0; Mon, 8 Jan 2018 20:14:18 +0000 (UTC) (envelope-from cem@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 4FC6D4B9D; Mon, 8 Jan 2018 20:14:17 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08KEHVf071636; Mon, 8 Jan 2018 20:14:17 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08KEGv8071627; Mon, 8 Jan 2018 20:14:16 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201801082014.w08KEGv8071627@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Mon, 8 Jan 2018 20:14:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327706 - in head/sys: conf contrib/zstd/lib/freebsd X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/sys: conf contrib/zstd/lib/freebsd X-SVN-Commit-Revision: 327706 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 20:14:18 -0000 Author: cem Date: Mon Jan 8 20:14:16 2018 New Revision: 327706 URL: https://svnweb.freebsd.org/changeset/base/327706 Log: Integrate zstd into the kernel Mock userspace headers and include mocked headers first in compilation command to inject kernel headers and override e.g., malloc(3) with malloc(9). Submitted by: allanjude Reviewed by: imp (earlier version), bapt (earlier version) Differential Revision: https://reviews.freebsd.org/D10407 Added: head/sys/contrib/zstd/lib/freebsd/ head/sys/contrib/zstd/lib/freebsd/stddef.h (contents, props changed) head/sys/contrib/zstd/lib/freebsd/stdint.h (contents, props changed) head/sys/contrib/zstd/lib/freebsd/stdio.h (contents, props changed) head/sys/contrib/zstd/lib/freebsd/stdlib.h (contents, props changed) head/sys/contrib/zstd/lib/freebsd/string.h (contents, props changed) head/sys/contrib/zstd/lib/freebsd/zstd_kfreebsd.h (contents, props changed) head/sys/contrib/zstd/lib/freebsd/zstd_kmalloc.c (contents, props changed) Modified: head/sys/conf/files head/sys/conf/kern.pre.mk Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Jan 8 18:47:35 2018 (r327705) +++ head/sys/conf/files Mon Jan 8 20:14:16 2018 (r327706) @@ -626,6 +626,23 @@ contrib/ngatm/netnatm/sig/sig_unimsgcpy.c optional nga compile-with "${NORMAL_C} -I$S/contrib/ngatm" contrib/ngatm/netnatm/sig/sig_verify.c optional ngatm_uni \ compile-with "${NORMAL_C} -I$S/contrib/ngatm" +# Zstd +contrib/zstd/lib/freebsd/zstd_kmalloc.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/common/zstd_common.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/common/fse_decompress.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/common/entropy_common.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/common/error_private.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/common/xxhash.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/compress/zstd_compress.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/compress/fse_compress.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/compress/huf_compress.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/compress/zstd_double_fast.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/compress/zstd_fast.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/compress/zstd_lazy.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/compress/zstd_ldm.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/compress/zstd_opt.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/decompress/zstd_decompress.c standard compile-with ${ZSTD_C} +contrib/zstd/lib/decompress/huf_decompress.c standard compile-with ${ZSTD_C} crypto/blowfish/bf_ecb.c optional ipsec | ipsec_support crypto/blowfish/bf_skey.c optional crypto | ipsec | ipsec_support crypto/camellia/camellia.c optional crypto | ipsec | ipsec_support Modified: head/sys/conf/kern.pre.mk ============================================================================== --- head/sys/conf/kern.pre.mk Mon Jan 8 18:47:35 2018 (r327705) +++ head/sys/conf/kern.pre.mk Mon Jan 8 20:14:16 2018 (r327706) @@ -132,6 +132,9 @@ NORMAL_FW= uudecode -o ${.TARGET} ${.ALLSRC} NORMAL_FWO= ${LD} -b binary --no-warn-mismatch -d -warn-common -r \ -m ${LD_EMULATION} -o ${.TARGET} ${.ALLSRC:M*.fw} +# for ZSTD in the kernel (include zstd/lib/freebsd before other CFLAGS) +ZSTD_C= ${CC} -c -DZSTD_HEAPMODE=1 -I$S/contrib/zstd/lib/freebsd ${CFLAGS} -I$S/contrib/zstd/lib -I$S/contrib/zstd/lib/common ${WERROR} -Wno-missing-prototypes ${PROF} ${.IMPSRC} + # Common for dtrace / zfs CDDL_CFLAGS= -DFREEBSD_NAMECACHE -nostdinc -I$S/cddl/compat/opensolaris -I$S/cddl/contrib/opensolaris/uts/common -I$S -I$S/cddl/contrib/opensolaris/common ${CFLAGS} -Wno-unknown-pragmas -Wno-missing-prototypes -Wno-undef -Wno-strict-prototypes -Wno-cast-qual -Wno-parentheses -Wno-redundant-decls -Wno-missing-braces -Wno-uninitialized -Wno-unused -Wno-inline -Wno-switch -Wno-pointer-arith -Wno-unknown-pragmas CDDL_CFLAGS+= -include $S/cddl/compat/opensolaris/sys/debug_compat.h Added: head/sys/contrib/zstd/lib/freebsd/stddef.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/zstd/lib/freebsd/stddef.h Mon Jan 8 20:14:16 2018 (r327706) @@ -0,0 +1,3 @@ +/* This file is in the public domain */ +/* $FreeBSD$ */ +#include "zstd_kfreebsd.h" Added: head/sys/contrib/zstd/lib/freebsd/stdint.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/zstd/lib/freebsd/stdint.h Mon Jan 8 20:14:16 2018 (r327706) @@ -0,0 +1,3 @@ +/* This file is in the public domain */ +/* $FreeBSD$ */ +#include "zstd_kfreebsd.h" Added: head/sys/contrib/zstd/lib/freebsd/stdio.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/zstd/lib/freebsd/stdio.h Mon Jan 8 20:14:16 2018 (r327706) @@ -0,0 +1,3 @@ +/* This file is in the public domain */ +/* $FreeBSD$ */ +#include "zstd_kfreebsd.h" Added: head/sys/contrib/zstd/lib/freebsd/stdlib.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/zstd/lib/freebsd/stdlib.h Mon Jan 8 20:14:16 2018 (r327706) @@ -0,0 +1,3 @@ +/* This file is in the public domain */ +/* $FreeBSD$ */ +#include "zstd_kfreebsd.h" Added: head/sys/contrib/zstd/lib/freebsd/string.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/zstd/lib/freebsd/string.h Mon Jan 8 20:14:16 2018 (r327706) @@ -0,0 +1,3 @@ +/* This file is in the public domain */ +/* $FreeBSD$ */ +#include "zstd_kfreebsd.h" Added: head/sys/contrib/zstd/lib/freebsd/zstd_kfreebsd.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/zstd/lib/freebsd/zstd_kfreebsd.h Mon Jan 8 20:14:16 2018 (r327706) @@ -0,0 +1,56 @@ +/*- + * Copyright (c) 2014-2015 Allan Jude + * 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 AUTHOR 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 AUTHOR 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$ + */ + +#ifndef ZSTD_KFREEBSD_H +#define ZSTD_KFREEBSD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _KERNEL +#include /* size_t */ +#include /* memcpy, memset */ +#ifndef BUILDING_ZFS +#include /* ptrdiff_t */ +#endif +#include + +MALLOC_DECLARE(M_ZSTD); + +#define malloc(x) (malloc)((x), M_ZSTD, M_WAITOK) +#define free(x) (free)((x), M_ZSTD) +/* in zstd's use of calloc, a is always 1 */ +#define calloc(a,b) (malloc)((a)*(b), M_ZSTD, M_WAITOK | M_ZERO) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ZSTD_KFREEBSD_H */ Added: head/sys/contrib/zstd/lib/freebsd/zstd_kmalloc.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/contrib/zstd/lib/freebsd/zstd_kmalloc.c Mon Jan 8 20:14:16 2018 (r327706) @@ -0,0 +1,33 @@ +/*- + * Copyright (c) 2016-2017 Allan Jude + * 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 AUTHOR 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 AUTHOR 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$ + */ + +#include +#include +#include + +MALLOC_DEFINE(M_ZSTD, "zstd", "ZSTD Compressor"); From owner-svn-src-all@freebsd.org Mon Jan 8 20:18: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 D43B0E5EF20 for ; Mon, 8 Jan 2018 20:18:54 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from sonic302-36.consmr.mail.gq1.yahoo.com (sonic302-36.consmr.mail.gq1.yahoo.com [98.137.68.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AFBF471E6F for ; Mon, 8 Jan 2018 20:18:54 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1515442733; bh=IXOnRaga6Kz0tUV0s9PivkXdauWg6Ns6jiUL+zpiKjg=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=fe1oN27GNz4Q8jLFpMv6liZsN1fQOldICEdmoyxhhQ6TfXrnukr0b+LFiXl8VU6W6ckwHvHVS+oQ31qzEt7vtj11t1vk0NyYBTxJ5Bbm5CcoNrg582cKnReRUaGesselLnxO4VMw8j4lfXge3nkKQUyUxic4/rwiDScl/H9csBQGvkaaZANqwJrbgNQ/eB9qU7vTdmUF7T5YPWi1Vt2Z5DN5KQTs3oIkN5WkCVPAvh5eWyeY98rSHvaq/PxPAwJ9yhQ+seraAMponLVEQJNHBRh6Czpv2XpYYlJo24pN4fSM1sTVi0qpZw1B2FHenzzgy/C4l17VzuHbFnFveId8Ew== X-YMail-OSG: uD4CU.AVM1nUTsvejlLAS4b15.dXuUh8xP6euafbnd896MPdDkxo3J0XsVrMU0A ECJ2COnjqOvcP6MU_P5d9zYb6OEzoUJUV2_AegZOySxVY6jNPM18g5A0_91NSAA1L43RI3lNATpz jQP1dwCdWkTcf550gTeNKl8zkli6hhJk5hShJqu5zrLjzkxZ2hQ.4DTn_3GFrCaDoT2r0Rt0tW9l rlktlSuBLbrtxiYresnluiwXDTd.18SWO4bfNog3nUh.i5lm4Ql4g1i3pshLj36bcW7yLIdEKQOU C4eW8zQXXXUjIcYkBtr5kDC6SOm1AAOizwlTkRXO0v737HbkhDCDFD3UY7y9Q.KDOHRzLdI9._hK 7VqNQKb1CSzyRQeDuNt35cOxNELcMIZ4zCPbyESlgHPHbwaLDZUc5Sanb3G8qdxcIuWQj8QoJC1f zyo1x7.BuhNfDw5W9A64adp2elvq4Pg60hFTZGAqZs7DGblSp_9HBDSgn3jpIa1XCRhwrQ_E. Received: from sonic.gate.mail.ne1.yahoo.com by sonic302.consmr.mail.gq1.yahoo.com with HTTP; Mon, 8 Jan 2018 20:18:53 +0000 Received: from smtp110.rhel.mail.gq1.yahoo.com (EHLO [192.168.0.6]) ([216.39.57.225]) by smtp415.mail.gq1.yahoo.com (JAMES SMTP Server ) with ESMTPA ID 37dde62ddfb6676b2daab4b6d9436738; Mon, 08 Jan 2018 20:18:49 +0000 (UTC) Subject: Re: svn commit: r327699 - head/sys/sys To: rgrimes@freebsd.org Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201801081609.w08G9941022351@pdx.rh.CN85.dnsmgr.net> From: Pedro Giffuni Organization: FreeBSD Project Message-ID: Date: Mon, 8 Jan 2018 15:18:50 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <201801081609.w08G9941022351@pdx.rh.CN85.dnsmgr.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US 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 20:18:54 -0000 On 08/01/2018 11:09, Rodney W. Grimes wrote: >> Author: pfg >> Date: Mon Jan 8 15:54:29 2018 >> New Revision: 327699 >> URL: https://svnweb.freebsd.org/changeset/base/327699 >> >> Log: >> Revert r327697: >> malloc(9): drop the __result_use_check attribute for the kernel allocator. >> >> My bad: __result_use_check just checks the for the general and we always >> want to make sure allocated memory is used, not only checked for nullness. >> >> Add it to reallocf since that was missing. > Please try not to combine a revert with an add, it makes it messy > to try and figure out things in the future when only the svn log > is being used to analyze stuff as digging in mail archives becomes > painful. > > Revert, then commit the add standalone, is the better sequence in > this type of situation. Not that any of this is defined in our committers guide but IMHO "svn revert" is just a tool, pretty much as "svn move" and "svn copy". The idea is to make a committers' life easier: making two commits for such a simple change is not "easier". In this case the change is rather consistent: I added __result_use_check to the three functions that needed it. The commit log is not only clear on why the revert happened but also explains the additional one line change. When I MFC it, I will merge both changes for repository consistency but the log will basically mention that I am adding __result_use_check to reallocf(). Pedro. >> Modified: >> head/sys/sys/malloc.h >> >> Modified: head/sys/sys/malloc.h >> ============================================================================== >> --- head/sys/sys/malloc.h Mon Jan 8 15:41:49 2018 (r327698) >> +++ head/sys/sys/malloc.h Mon Jan 8 15:54:29 2018 (r327699) >> @@ -176,7 +176,7 @@ void *contigmalloc(unsigned long size, struct malloc_t >> __alloc_size(1) __alloc_align(6); >> void free(void *addr, struct malloc_type *type); >> void *malloc(unsigned long size, struct malloc_type *type, int flags) >> - __malloc_like __alloc_size(1); >> + __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); >> @@ -187,9 +187,9 @@ void malloc_type_freed(struct malloc_type *type, unsig >> void malloc_type_list(malloc_type_list_func_t *, void *); >> void malloc_uninit(void *); >> void *realloc(void *addr, unsigned long size, struct malloc_type *type, >> - int flags) __alloc_size(2); >> + int flags) __result_use_check __alloc_size(2); >> void *reallocf(void *addr, unsigned long size, struct malloc_type *type, >> - int flags) __alloc_size(2); >> + int flags) __result_use_check __alloc_size(2); >> >> struct malloc_type *malloc_desc2type(const char *desc); >> #endif /* _KERNEL */ >> >> Pedro. From owner-svn-src-all@freebsd.org Mon Jan 8 20:28:00 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 D657EE5F8DA; Mon, 8 Jan 2018 20:28:00 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f170.google.com (mail-io0-f170.google.com [209.85.223.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A65F3728F1; Mon, 8 Jan 2018 20:27:59 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f170.google.com with SMTP id z130so15986617ioe.13; Mon, 08 Jan 2018 12:27:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc; bh=eicwRyrtt8nnK8urFqWz+x5fXTQF6E0niTcCr2g8N4c=; b=HIXlU8tRNQBpYHK1NTH9HlHQ6vOCelYQ4+zKcGs33iQGkCFnOgedh2yPKh64HukQmx Ly3CNt8t1pjKr7Zc48Dz7/kVbhsu+g1JvTsqsiobhSxFFK2rZS4SyezJ+VCopJG2Q67v uyp6pNYg8fEth4iy7OVoG9zky2r+bbrttfv6yDQkOB6f7manKpU9D/ZB9Dvaj7KR37LP HNF75N1LFlj0XbkTd/iuQJpFfRPVeNgtP46ZQvrUR1b1RwetsNQa3y+j5ZA+C5OKn9YI a3s2y88npZGwYoa0+AzQFqWmDc5seGIHpoxXRbTrGZ1EQtkk4JJGUMX0XxdUuhMNWPN7 sAbQ== X-Gm-Message-State: AKGB3mITyh1feL5Acfv9YFk0i3Rkq2EOc27LWTnDTKCU3ICHMmB6GRum /HAsLcMDmPa/bJmRO7t57yvlrRp5 X-Google-Smtp-Source: ACJfBosEL/M5T9/a+cQreHvPIOjVorAhaviVOm1sYK3JKgvJqYfDUL/VYiq/qt3pXqSe5UpidBfIAg== X-Received: by 10.107.180.201 with SMTP id d192mr12086813iof.270.1515443279018; Mon, 08 Jan 2018 12:27:59 -0800 (PST) Received: from mail-it0-f45.google.com (mail-it0-f45.google.com. [209.85.214.45]) by smtp.gmail.com with ESMTPSA id v19sm7566758ite.4.2018.01.08.12.27.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jan 2018 12:27:58 -0800 (PST) Received: by mail-it0-f45.google.com with SMTP id p124so1904745ite.1; Mon, 08 Jan 2018 12:27:58 -0800 (PST) X-Received: by 10.36.7.65 with SMTP id f62mr13307198itf.75.1515443278518; Mon, 08 Jan 2018 12:27:58 -0800 (PST) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.2.15.193 with HTTP; Mon, 8 Jan 2018 12:27:58 -0800 (PST) In-Reply-To: References: <201801081609.w08G9941022351@pdx.rh.CN85.dnsmgr.net> From: Conrad Meyer Date: Mon, 8 Jan 2018 12:27:58 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r327699 - head/sys/sys To: Pedro Giffuni Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" 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 20:28:00 -0000 I'm (again, atypically) with rgrimes here. Revert has a specific meaning and shouldn't be used like this. Making a commit with the subject "Revert rXXX" that does more than just "svn revert rXXX" makes life harder for developers looking at code history after you. Making two separate commits for two different changes (revert, then add the annotation) is not burdensome. Best, Conrad On Mon, Jan 8, 2018 at 12:18 PM, Pedro Giffuni wrote: > > On 08/01/2018 11:09, Rodney W. Grimes wrote: >>> >>> Author: pfg >>> Date: Mon Jan 8 15:54:29 2018 >>> New Revision: 327699 >>> URL: https://svnweb.freebsd.org/changeset/base/327699 >>> >>> Log: >>> Revert r327697: >>> malloc(9): drop the __result_use_check attribute for the kernel >>> allocator. >>> My bad: __result_use_check just checks the for the general and we >>> always >>> want to make sure allocated memory is used, not only checked for >>> nullness. >>> Add it to reallocf since that was missing. >> >> Please try not to combine a revert with an add, it makes it messy >> to try and figure out things in the future when only the svn log >> is being used to analyze stuff as digging in mail archives becomes >> painful. >> >> Revert, then commit the add standalone, is the better sequence in >> this type of situation. > > > Not that any of this is defined in our committers guide but IMHO "svn > revert" is just a tool, pretty much as "svn move" and "svn copy". The idea > is to make a committers' life easier: making two commits for such a simple > change is not "easier". > > In this case the change is rather consistent: I added __result_use_check to > the three functions that needed it. > The commit log is not only clear on why the revert happened but also > explains the additional one line change. > > When I MFC it, I will merge both changes for repository consistency but the > log will basically mention that I am adding __result_use_check to > reallocf(). > > > Pedro. > >>> Modified: >>> head/sys/sys/malloc.h >>> >>> Modified: head/sys/sys/malloc.h >>> >>> ============================================================================== >>> --- head/sys/sys/malloc.h Mon Jan 8 15:41:49 2018 (r327698) >>> +++ head/sys/sys/malloc.h Mon Jan 8 15:54:29 2018 (r327699) >>> @@ -176,7 +176,7 @@ void *contigmalloc(unsigned long size, struct >>> malloc_t >>> __alloc_size(1) __alloc_align(6); >>> void free(void *addr, struct malloc_type *type); >>> void *malloc(unsigned long size, struct malloc_type *type, int flags) >>> - __malloc_like __alloc_size(1); >>> + __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); >>> @@ -187,9 +187,9 @@ void malloc_type_freed(struct malloc_type >>> *type, unsig >>> void malloc_type_list(malloc_type_list_func_t *, void *); >>> void malloc_uninit(void *); >>> void *realloc(void *addr, unsigned long size, struct malloc_type >>> *type, >>> - int flags) __alloc_size(2); >>> + int flags) __result_use_check __alloc_size(2); >>> void *reallocf(void *addr, unsigned long size, struct malloc_type >>> *type, >>> - int flags) __alloc_size(2); >>> + int flags) __result_use_check __alloc_size(2); >>> struct malloc_type *malloc_desc2type(const char *desc); >>> #endif /* _KERNEL */ >>> >>> > > Pedro. > From owner-svn-src-all@freebsd.org Mon Jan 8 20:54: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 DA4E7E6194E for ; Mon, 8 Jan 2018 20:54:55 +0000 (UTC) (envelope-from pfg@FreeBSD.org) Received: from sonic303-37.consmr.mail.gq1.yahoo.com (sonic303-37.consmr.mail.gq1.yahoo.com [98.137.64.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B33527428B for ; Mon, 8 Jan 2018 20:54:55 +0000 (UTC) (envelope-from pfg@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1515444889; bh=iEC/mt6zffQ+/zwfu+XtNCn6QggpYN7DB0vLjNpx4Ws=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From:Subject; b=V07PXJcfkm47eaik4k7gF2/SJIhHsM3H8TFJTxN2cltxnVgYRgddgxTUGULdVZkUCGVIUEZmefodoWZBuM0kF772ANCEmioQwuRtVrdrLZptUbG9gzDE0aaSM2FDe8GfpdUV//m3+saNpdk9jLdxvdrZYIHFEBtrMbAAa5sV3HHFVcz8vvWenum7IAt4RZxTHhivrU0a/h6yppyVX/fGxE5/jwYOwOjtcl9etmRuKGNCPbCN3kGb/cw/gz7z39Nk3rtKatVsr2hT/DR+UD/z+F9pywuZzlfs+VhfhdnESRlMQxznEY2euQYRrIVQB+ZRAlzA8mhzIxtcYxRGHVSnxg== X-YMail-OSG: 6.QGtxEVM1kQ1RUq5HhxbejaQEeRXzn8VKD6Sgy5vqN3tzwG8LY3iqyKk.ehc4x orCik4LmWzlB92KKOwD8ti8.0Ilpc7O88Fm.PJE58zC2JTh4FLRiGFDUpfq3kuV8MKasO3N7Yrc5 ZEMFzcaojYaYQN1Fb3GLYRch0Gg2GfzLXEZQion5NMvgzZ5hCH_3G62wf7z1s2kML6yQ0eMB3Hii BXemOhFxAxwUFzTWYdh1xCeAiv1XofxQA2kb57WYz0Cil.40n.rlxIurmZG4oqhIKzxsI1kLFJkj y6ikDan8z9VyOTyFE7o70HhqLbh64gW12yOPf449LbKySjvnjewvyAjDXfS4Ff7RnyhOb3qcpJnJ NSwJIz_p2GDVjQm8xiG8Fz8q2AXVAeS56Ywc3v9e73IdlHlADus0DHNseEP_JyVfmxWWA6wT._Bk TPes_0L.Hjq6YAJpi.Gx8rMmgKp2bmMLTF62SDNuZGrL.RIO.JWNMcwU075zG_d30ZOWRW3J. Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.gq1.yahoo.com with HTTP; Mon, 8 Jan 2018 20:54:49 +0000 Received: from smtp110.rhel.mail.gq1.yahoo.com (EHLO [192.168.0.6]) ([216.39.57.225]) by smtp403.mail.gq1.yahoo.com (JAMES SMTP Server ) with ESMTPA ID 281cf99df4003b4738c94627c89ec3de; Mon, 08 Jan 2018 20:54:44 +0000 (UTC) Subject: Re: svn commit: r327699 - head/sys/sys To: cem@freebsd.org Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201801081609.w08G9941022351@pdx.rh.CN85.dnsmgr.net> From: Pedro Giffuni Organization: FreeBSD Project Message-ID: <89964e3f-a982-f0e5-a7ff-9c13a5ebe61c@FreeBSD.org> Date: Mon, 8 Jan 2018 15:54:45 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US 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 20:54:56 -0000 Hello; On 08/01/2018 15:27, Conrad Meyer wrote: > I'm (again, atypically) with rgrimes here. Revert has a specific > meaning and shouldn't be used like this. Making a commit with the > subject "Revert rXXX" that does more than just "svn revert rXXX" makes > life harder for developers looking at code history after you. Making > two separate commits for two different changes (revert, then add the > annotation) is not burdensome. > > Best, > Conrad Yeah, I understand where that comes from and I will take it into account for future commits, but I think it should be *documented* and not assume that everybody  thinks that is the way version control is supposed to be used. Pedro. > On Mon, Jan 8, 2018 at 12:18 PM, Pedro Giffuni wrote: >> On 08/01/2018 11:09, Rodney W. Grimes wrote: >>>> Author: pfg >>>> Date: Mon Jan 8 15:54:29 2018 >>>> New Revision: 327699 >>>> URL: https://svnweb.freebsd.org/changeset/base/327699 >>>> >>>> Log: >>>> Revert r327697: >>>> malloc(9): drop the __result_use_check attribute for the kernel >>>> allocator. >>>> My bad: __result_use_check just checks the for the general and we >>>> always >>>> want to make sure allocated memory is used, not only checked for >>>> nullness. >>>> Add it to reallocf since that was missing. >>> Please try not to combine a revert with an add, it makes it messy >>> to try and figure out things in the future when only the svn log >>> is being used to analyze stuff as digging in mail archives becomes >>> painful. >>> >>> Revert, then commit the add standalone, is the better sequence in >>> this type of situation. >> >> Not that any of this is defined in our committers guide but IMHO "svn >> revert" is just a tool, pretty much as "svn move" and "svn copy". The idea >> is to make a committers' life easier: making two commits for such a simple >> change is not "easier". >> >> In this case the change is rather consistent: I added __result_use_check to >> the three functions that needed it. >> The commit log is not only clear on why the revert happened but also >> explains the additional one line change. >> >> When I MFC it, I will merge both changes for repository consistency but the >> log will basically mention that I am adding __result_use_check to >> reallocf(). >> >> >> Pedro. >> >>>> Modified: >>>> head/sys/sys/malloc.h >>>> >>>> Modified: head/sys/sys/malloc.h >>>> >>>> ============================================================================== >>>> --- head/sys/sys/malloc.h Mon Jan 8 15:41:49 2018 (r327698) >>>> +++ head/sys/sys/malloc.h Mon Jan 8 15:54:29 2018 (r327699) >>>> @@ -176,7 +176,7 @@ void *contigmalloc(unsigned long size, struct >>>> malloc_t >>>> __alloc_size(1) __alloc_align(6); >>>> void free(void *addr, struct malloc_type *type); >>>> void *malloc(unsigned long size, struct malloc_type *type, int flags) >>>> - __malloc_like __alloc_size(1); >>>> + __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); >>>> @@ -187,9 +187,9 @@ void malloc_type_freed(struct malloc_type >>>> *type, unsig >>>> void malloc_type_list(malloc_type_list_func_t *, void *); >>>> void malloc_uninit(void *); >>>> void *realloc(void *addr, unsigned long size, struct malloc_type >>>> *type, >>>> - int flags) __alloc_size(2); >>>> + int flags) __result_use_check __alloc_size(2); >>>> void *reallocf(void *addr, unsigned long size, struct malloc_type >>>> *type, >>>> - int flags) __alloc_size(2); >>>> + int flags) __result_use_check __alloc_size(2); >>>> struct malloc_type *malloc_desc2type(const char *desc); >>>> #endif /* _KERNEL */ >>>> >>>> >> Pedro. >> From owner-svn-src-all@freebsd.org Mon Jan 8 21:09:49 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 ED4F4E626E9; Mon, 8 Jan 2018 21:09:49 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-it0-f41.google.com (mail-it0-f41.google.com [209.85.214.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BC10174D9B; Mon, 8 Jan 2018 21:09:49 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-it0-f41.google.com with SMTP id b77so5905020itd.0; Mon, 08 Jan 2018 13:09:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=UtIY/7oD1qfTcaZMU3aWih/Uu4InNUC3exw7PTOwpnQ=; b=qAvwdIZEtEhL9iiTFMrFtmvWQbbwI3mtle0x0qA65Ba1QePRJbmNB08aVV1C206Oxc BNlsrI3EW3jg5roOfgr6aQLbaaTQ71P35zVGYs+4FME+1zWM7pGOBn+2wWh78n46tkMt 50gQMTke1fDtDzPXbCrNod88EpWh43Z/ZoR+0xYu5VyDuCmLJ2BWsOKyZ8s52Bi50YgS 8sXLgRmN+JrMBebd3oMJIMR3r2Mf1Lc9sf067m8EePYJs3Bc/tmza+avtDoo+nZrZ14P sLH/cbhiZla+RatSvigWR6n93/+xRav+jbVPYUozBD+ElRCFqgXRvE/Qp1ht2XIdGHCi Rs8Q== X-Gm-Message-State: AKwxytdsIFRj0liZ3vbr0IYxDp5WjQcuneogYZeHNzJm0UlwWe0cL1cm WzSxUDks1QB3oD3OUj5SX1U89A0h X-Google-Smtp-Source: ACJfBouR3Tu89hnY0HZEL8oFEpdzsp/9/VjihhrDtlh7MXGqS1Tj1FlyS7tYT6++GmT5w5S/i4dtBQ== X-Received: by 10.36.79.132 with SMTP id c126mr5922694itb.45.1515445782952; Mon, 08 Jan 2018 13:09:42 -0800 (PST) Received: from mail-io0-f176.google.com (mail-io0-f176.google.com. [209.85.223.176]) by smtp.gmail.com with ESMTPSA id p68sm7192688itc.26.2018.01.08.13.09.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Jan 2018 13:09:42 -0800 (PST) Received: by mail-io0-f176.google.com with SMTP id e20so16116976iof.12; Mon, 08 Jan 2018 13:09:42 -0800 (PST) X-Received: by 10.107.53.223 with SMTP id k92mr13296236ioo.38.1515445782501; Mon, 08 Jan 2018 13:09:42 -0800 (PST) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.2.15.193 with HTTP; Mon, 8 Jan 2018 13:09:42 -0800 (PST) In-Reply-To: <89964e3f-a982-f0e5-a7ff-9c13a5ebe61c@FreeBSD.org> References: <201801081609.w08G9941022351@pdx.rh.CN85.dnsmgr.net> <89964e3f-a982-f0e5-a7ff-9c13a5ebe61c@FreeBSD.org> From: Conrad Meyer Date: Mon, 8 Jan 2018 13:09:42 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r327699 - head/sys/sys To: Pedro Giffuni Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" 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: Mon, 08 Jan 2018 21:09:50 -0000 On Mon, Jan 8, 2018 at 12:54 PM, Pedro Giffuni wrote: > Yeah, I understand where that comes from and I will take it into account = for > future commits, but I think it should be *documented* and not assume that > everybody thinks that is the way version control is supposed to be used. If you want to document it somewhere, I don't think anyone will stop you. In general, we do have a bunch of unwritten guidelines that are either inferred from reading SVN log / source or explicitly requested via review (pre- or post-commit). I don't think it would hurt to document. I don't know if this specific topic is really a FreeBSD guideline or not, but it's a good practice when using any version control system. (You could do the same thing with 'git revert' =E2=80=94 make additions on = top of the revert commit =E2=80=94 and it would be equally a bad practice with that tool.) The only downsides I see are: 0. No one is interested in spending time writing this down and dealing with the inevitable bikeshedding, 1. Consensus may shift over time, and 2. People don't want to spend a ton of time reading rules Best, Conrad From owner-svn-src-all@freebsd.org Mon Jan 8 21:27:43 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 A76D7E63A6A; Mon, 8 Jan 2018 21:27:43 +0000 (UTC) (envelope-from markj@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 5CF2975EDA; Mon, 8 Jan 2018 21:27:43 +0000 (UTC) (envelope-from markj@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 99C4B5771; Mon, 8 Jan 2018 21:27:42 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w08LRg0G001649; Mon, 8 Jan 2018 21:27:42 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w08LRfqm001641; Mon, 8 Jan 2018 21:27:41 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201801082127.w08LRfqm001641@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 8 Jan 2018 21:27:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327707 - in head: share/man/man5 sys/conf sys/ddb sys/kern sys/sys X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head: share/man/man5 sys/conf sys/ddb sys/kern sys/sys X-SVN-Commit-Revision: 327707 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 21:27:43 -0000 Author: markj Date: Mon Jan 8 21:27:41 2018 New Revision: 327707 URL: https://svnweb.freebsd.org/changeset/base/327707 Log: Generalize the gzio API. We currently use a set of subroutines in kern_gzio.c to perform compression of user and kernel core dumps. In the interest of adding support for other compression algorithms (zstd) in this role without complicating the API consumers, add a simple compressor API which can be used to select an algorithm. Also change the (non-default) GZIO kernel option to not enable compressed user cores by default. It's not clear that such a default would be desirable with support for multiple algorithms implemented, and it's inconsistent in that it isn't applied to kernel dumps. Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D13632 Added: head/sys/kern/subr_compressor.c - copied, changed from r327706, head/sys/kern/kern_gzio.c head/sys/sys/compressor.h - copied, changed from r327706, head/sys/sys/gzio.h Deleted: head/sys/kern/kern_gzio.c head/sys/sys/gzio.h Modified: head/share/man/man5/core.5 head/sys/conf/files head/sys/ddb/db_textdump.c head/sys/kern/imgact_elf.c head/sys/kern/kern_shutdown.c head/sys/kern/kern_sig.c head/sys/sys/conf.h head/sys/sys/imgact.h Modified: head/share/man/man5/core.5 ============================================================================== --- head/share/man/man5/core.5 Mon Jan 8 20:14:16 2018 (r327706) +++ head/share/man/man5/core.5 Mon Jan 8 21:27:41 2018 (r327707) @@ -28,7 +28,7 @@ .\" @(#)core.5 8.3 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd October 5, 2015 +.Dd January 8, 2018 .Dt CORE 5 .Os .Sh NAME @@ -67,8 +67,8 @@ generating it). .Pp The following format specifiers may be used in the .Va kern.corefile -sysctl to insert additional information into the resulting core file -name: +sysctl to insert additional information into the resulting core +filename: .Bl -tag -width "1234567890" -compact -offset "12345" .It Em \&%H Machine hostname. @@ -108,17 +108,17 @@ is included in the kernel configuration file: GZIO .El .Pp -When the GZIO option is included, the following sysctls control whether core -files will be compressed: -.Bl -tag -width "kern.compress_user_cores_gzlevel" -compact -offset "12345" -.It Em kern.compress_user_cores_gzlevel -Gzip compression level. -Defaults to 6. +The following sysctl control core file compression: +.Bl -tag -width "kern.compress_user_cores_level" -compact -offset "12345" .It Em kern.compress_user_cores -Actually compress user cores. -Compressed core files will have a suffix of +Enable compression of user cores. +A value of 1 configures gzip compression. +gzip-compressed core files will have a suffix of .Ql .gz -appended to them. +appended to their filenames. +.It Em kern.compress_user_cores_level +Compression level. +Defaults to 6. .El .Sh NOTES Corefiles are written with open file descriptor information as an ELF note. @@ -153,6 +153,7 @@ command can be used: .Dl sysctl kern.corefile=/var/coredumps/\&%U/\&%N.core .Sh SEE ALSO .Xr gdb 1 , +.Xr gzip 1 , .Xr kgdb 1 , .Xr setrlimit 2 , .Xr sigaction 2 , Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Mon Jan 8 20:14:16 2018 (r327706) +++ head/sys/conf/files Mon Jan 8 21:27:41 2018 (r327707) @@ -3767,7 +3767,6 @@ kern/kern_exit.c standard kern/kern_fail.c standard kern/kern_ffclock.c standard kern/kern_fork.c standard -kern/kern_gzio.c optional gzio kern/kern_hhook.c standard kern/kern_idle.c standard kern/kern_intr.c standard @@ -3843,6 +3842,7 @@ kern/subr_bus_dma.c standard kern/subr_bufring.c standard kern/subr_capability.c standard kern/subr_clock.c standard +kern/subr_compressor.c standard kern/subr_counter.c standard kern/subr_devstat.c standard kern/subr_disk.c standard Modified: head/sys/ddb/db_textdump.c ============================================================================== --- head/sys/ddb/db_textdump.c Mon Jan 8 20:14:16 2018 (r327706) +++ head/sys/ddb/db_textdump.c Mon Jan 8 21:27:41 2018 (r327707) @@ -454,8 +454,8 @@ textdump_dumpsys(struct dumperinfo *di) /* * Disable EKCD because we don't provide encrypted textdumps. */ - kdc = di->kdc; - di->kdc = NULL; + kdc = di->kdcrypto; + di->kdcrypto = NULL; /* * Position the start of the dump so that we'll write the kernel dump @@ -512,7 +512,7 @@ textdump_dumpsys(struct dumperinfo *di) /* * Restore EKCD status. */ - di->kdc = kdc; + di->kdcrypto = kdc; } /*- Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Mon Jan 8 20:14:16 2018 (r327706) +++ head/sys/kern/imgact_elf.c Mon Jan 8 21:27:41 2018 (r327707) @@ -36,13 +36,12 @@ __FBSDID("$FreeBSD$"); #include "opt_capsicum.h" #include "opt_compat.h" -#include "opt_gzio.h" #include #include +#include #include #include -#include #include #include #include @@ -1185,9 +1184,12 @@ struct coredump_params { struct ucred *file_cred; struct thread *td; struct vnode *vp; - struct gzio_stream *gzs; + struct compressor *comp; }; +extern int compress_user_cores; +extern int compress_user_cores_level; + static void cb_put_phdr(vm_map_entry_t, void *); static void cb_size_segment(vm_map_entry_t, void *); static int core_write(struct coredump_params *, const void *, size_t, off_t, @@ -1219,9 +1221,6 @@ static void note_procstat_rlimit(void *, struct sbuf * static void note_procstat_umask(void *, struct sbuf *, size_t *); static void note_procstat_vmmap(void *, struct sbuf *, size_t *); -#ifdef GZIO -extern int compress_user_cores_gzlevel; - /* * Write out a core segment to the compression stream. */ @@ -1241,7 +1240,7 @@ compress_chunk(struct coredump_params *p, char *base, error = copyin(base, buf, chunk_len); if (error != 0) bzero(buf, chunk_len); - error = gzio_write(p->gzs, buf, chunk_len); + error = compressor_write(p->comp, buf, chunk_len); if (error != 0) break; base += chunk_len; @@ -1251,13 +1250,12 @@ compress_chunk(struct coredump_params *p, char *base, } static int -core_gz_write(void *base, size_t len, off_t offset, void *arg) +core_compressed_write(void *base, size_t len, off_t offset, void *arg) { return (core_write((struct coredump_params *)arg, base, len, offset, UIO_SYSSPACE)); } -#endif /* GZIO */ static int core_write(struct coredump_params *p, const void *base, size_t len, @@ -1275,10 +1273,9 @@ core_output(void *base, size_t len, off_t offset, stru { int error; -#ifdef GZIO - if (p->gzs != NULL) + if (p->comp != NULL) return (compress_chunk(p, base, tmpbuf, len)); -#endif + /* * EFAULT is a non-fatal error that we can get, for example, * if the segment is backed by a file but extends beyond its @@ -1323,11 +1320,9 @@ sbuf_drain_core_output(void *arg, const char *data, in locked = PROC_LOCKED(p->td->td_proc); if (locked) PROC_UNLOCK(p->td->td_proc); -#ifdef GZIO - if (p->gzs != NULL) - error = gzio_write(p->gzs, __DECONST(char *, data), len); + if (p->comp != NULL) + error = compressor_write(p->comp, __DECONST(char *, data), len); else -#endif error = core_write(p, __DECONST(void *, data), len, p->offset, UIO_SYSSPACE); if (locked) @@ -1362,11 +1357,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, struct note_info *ninfo; void *hdr, *tmpbuf; size_t hdrsize, notesz, coresize; -#ifdef GZIO - boolean_t compress; - compress = (flags & IMGACT_CORE_COMPRESS) != 0; -#endif hdr = NULL; tmpbuf = NULL; TAILQ_INIT(¬elst); @@ -1391,7 +1382,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, params.file_cred = NOCRED; params.td = td; params.vp = vp; - params.gzs = NULL; + params.comp = NULL; #ifdef RACCT if (racct_enable) { @@ -1409,18 +1400,17 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, goto done; } -#ifdef GZIO /* Create a compression stream if necessary. */ - if (compress) { - params.gzs = gzio_init(core_gz_write, GZIO_DEFLATE, - CORE_BUF_SIZE, compress_user_cores_gzlevel, ¶ms); - if (params.gzs == NULL) { + if (compress_user_cores != 0) { + params.comp = compressor_init(core_compressed_write, + compress_user_cores, CORE_BUF_SIZE, + compress_user_cores_level, ¶ms); + if (params.comp == NULL) { error = EFAULT; goto done; } tmpbuf = malloc(CORE_BUF_SIZE, M_TEMP, M_WAITOK | M_ZERO); } -#endif /* * Allocate memory for building the header, fill it up, @@ -1446,10 +1436,8 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, offset += php->p_filesz; php++; } -#ifdef GZIO - if (error == 0 && compress) - error = gzio_flush(params.gzs); -#endif + if (error == 0 && params.comp != NULL) + error = compressor_flush(params.comp); } if (error) { log(LOG_WARNING, @@ -1458,13 +1446,9 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, } done: -#ifdef GZIO - if (compress) { - free(tmpbuf, M_TEMP); - if (params.gzs != NULL) - gzio_fini(params.gzs); - } -#endif + free(tmpbuf, M_TEMP); + if (params.comp != NULL) + compressor_fini(params.comp); while ((ninfo = TAILQ_FIRST(¬elst)) != NULL) { TAILQ_REMOVE(¬elst, ninfo, link); free(ninfo, M_TEMP); Modified: head/sys/kern/kern_shutdown.c ============================================================================== --- head/sys/kern/kern_shutdown.c Mon Jan 8 20:14:16 2018 (r327706) +++ head/sys/kern/kern_shutdown.c Mon Jan 8 21:27:41 2018 (r327707) @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); #include "opt_ddb.h" #include "opt_ekcd.h" -#include "opt_gzio.h" #include "opt_kdb.h" #include "opt_panic.h" #include "opt_sched.h" @@ -52,10 +51,10 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include -#include #include #include #include @@ -174,23 +173,21 @@ struct kerneldumpcrypto { }; #endif -#ifdef GZIO -struct kerneldumpgz { - struct gzio_stream *kdgz_stream; - uint8_t *kdgz_buf; - size_t kdgz_resid; +struct kerneldumpcomp { + struct compressor *kdc_stream; + uint8_t *kdc_buf; + size_t kdc_resid; }; -static struct kerneldumpgz *kerneldumpgz_create(struct dumperinfo *di, +static struct kerneldumpcomp *kerneldumpcomp_create(struct dumperinfo *di, uint8_t compression); -static void kerneldumpgz_destroy(struct dumperinfo *di); -static int kerneldumpgz_write_cb(void *cb, size_t len, off_t off, void *arg); +static void kerneldumpcomp_destroy(struct dumperinfo *di); +static int kerneldumpcomp_write_cb(void *base, size_t len, off_t off, void *arg); static int kerneldump_gzlevel = 6; SYSCTL_INT(_kern, OID_AUTO, kerneldump_gzlevel, CTLFLAG_RWTUN, &kerneldump_gzlevel, 0, - "Kernel crash dump gzip compression level"); -#endif /* GZIO */ + "Kernel crash dump compression level"); /* * Variable panicstr contains argument to first call to panic; used as flag @@ -986,39 +983,37 @@ kerneldumpcrypto_dumpkeysize(const struct kerneldumpcr } #endif /* EKCD */ -#ifdef GZIO -static struct kerneldumpgz * -kerneldumpgz_create(struct dumperinfo *di, uint8_t compression) +static struct kerneldumpcomp * +kerneldumpcomp_create(struct dumperinfo *di, uint8_t compression) { - struct kerneldumpgz *kdgz; + struct kerneldumpcomp *kdcomp; if (compression != KERNELDUMP_COMP_GZIP) return (NULL); - kdgz = malloc(sizeof(*kdgz), M_DUMPER, M_WAITOK | M_ZERO); - kdgz->kdgz_stream = gzio_init(kerneldumpgz_write_cb, GZIO_DEFLATE, - di->maxiosize, kerneldump_gzlevel, di); - if (kdgz->kdgz_stream == NULL) { - free(kdgz, M_DUMPER); + kdcomp = malloc(sizeof(*kdcomp), M_DUMPER, M_WAITOK | M_ZERO); + kdcomp->kdc_stream = compressor_init(kerneldumpcomp_write_cb, + COMPRESS_GZIP, di->maxiosize, kerneldump_gzlevel, di); + if (kdcomp->kdc_stream == NULL) { + free(kdcomp, M_DUMPER); return (NULL); } - kdgz->kdgz_buf = malloc(di->maxiosize, M_DUMPER, M_WAITOK | M_NODUMP); - return (kdgz); + kdcomp->kdc_buf = malloc(di->maxiosize, M_DUMPER, M_WAITOK | M_NODUMP); + return (kdcomp); } static void -kerneldumpgz_destroy(struct dumperinfo *di) +kerneldumpcomp_destroy(struct dumperinfo *di) { - struct kerneldumpgz *kdgz; + struct kerneldumpcomp *kdcomp; - kdgz = di->kdgz; - if (kdgz == NULL) + kdcomp = di->kdcomp; + if (kdcomp == NULL) return; - gzio_fini(kdgz->kdgz_stream); - explicit_bzero(kdgz->kdgz_buf, di->maxiosize); - free(kdgz->kdgz_buf, M_DUMPER); - free(kdgz, M_DUMPER); + compressor_fini(kdcomp->kdc_stream); + explicit_bzero(kdcomp->kdc_buf, di->maxiosize); + free(kdcomp->kdc_buf, M_DUMPER); + free(kdcomp, M_DUMPER); } -#endif /* GZIO */ /* Registration of dumpers */ int @@ -1041,14 +1036,14 @@ set_dumper(struct dumperinfo *di, const char *devname, return (EBUSY); dumper = *di; dumper.blockbuf = NULL; - dumper.kdc = NULL; - dumper.kdgz = NULL; + dumper.kdcrypto = NULL; + dumper.kdcomp = NULL; if (encryption != KERNELDUMP_ENC_NONE) { #ifdef EKCD - dumper.kdc = kerneldumpcrypto_create(di->blocksize, encryption, - key, encryptedkeysize, encryptedkey); - if (dumper.kdc == NULL) { + dumper.kdcrypto = kerneldumpcrypto_create(di->blocksize, + encryption, key, encryptedkeysize, encryptedkey); + if (dumper.kdcrypto == NULL) { error = EINVAL; goto cleanup; } @@ -1065,7 +1060,6 @@ set_dumper(struct dumperinfo *di, const char *devname, } if (compression != KERNELDUMP_COMP_NONE) { -#ifdef GZIO /* * We currently can't support simultaneous encryption and * compression. @@ -1074,31 +1068,25 @@ set_dumper(struct dumperinfo *di, const char *devname, error = EOPNOTSUPP; goto cleanup; } - dumper.kdgz = kerneldumpgz_create(&dumper, compression); - if (dumper.kdgz == NULL) { + dumper.kdcomp = kerneldumpcomp_create(&dumper, compression); + if (dumper.kdcomp == NULL) { error = EINVAL; goto cleanup; } -#else - error = EOPNOTSUPP; - goto cleanup; -#endif } dumper.blockbuf = malloc(di->blocksize, M_DUMPER, M_WAITOK | M_ZERO); return (0); cleanup: #ifdef EKCD - if (dumper.kdc != NULL) { - explicit_bzero(dumper.kdc, sizeof(*dumper.kdc) + - dumper.kdc->kdc_dumpkeysize); - free(dumper.kdc, M_EKCD); + if (dumper.kdcrypto != NULL) { + explicit_bzero(dumper.kdcrypto, sizeof(*dumper.kdcrypto) + + dumper.kdcrypto->kdc_dumpkeysize); + free(dumper.kdcrypto, M_EKCD); } #endif -#ifdef GZIO - kerneldumpgz_destroy(&dumper); -#endif + kerneldumpcomp_destroy(&dumper); if (dumper.blockbuf != NULL) { explicit_bzero(dumper.blockbuf, dumper.blocksize); @@ -1168,7 +1156,7 @@ dump_encrypted_write(struct dumperinfo *di, void *virt int error; size_t nbytes; - kdc = di->kdc; + kdc = di->kdcrypto; while (length > 0) { nbytes = MIN(length, sizeof(buf)); @@ -1194,7 +1182,7 @@ dump_write_key(struct dumperinfo *di, off_t offset) { struct kerneldumpcrypto *kdc; - kdc = di->kdc; + kdc = di->kdcrypto; if (kdc == NULL) return (0); return (dump_write(di, kdc->kdc_dumpkey, 0, offset, @@ -1202,9 +1190,8 @@ dump_write_key(struct dumperinfo *di, off_t offset) } #endif /* EKCD */ -#ifdef GZIO static int -kerneldumpgz_write_cb(void *base, size_t length, off_t offset, void *arg) +kerneldumpcomp_write_cb(void *base, size_t length, off_t offset, void *arg) { struct dumperinfo *di; size_t resid, rlength; @@ -1227,12 +1214,11 @@ kerneldumpgz_write_cb(void *base, size_t length, off_t } resid = length - rlength; memmove(di->blockbuf, (uint8_t *)base + rlength, resid); - di->kdgz->kdgz_resid = resid; + di->kdcomp->kdc_resid = resid; return (EAGAIN); } return (_dump_append(di, base, 0, length)); } -#endif /* GZIO */ /* * Write a kerneldumpheader at the specified offset. The header structure is 512 @@ -1290,10 +1276,10 @@ dump_start(struct dumperinfo *di, struct kerneldumphea uint32_t keysize; #ifdef EKCD - int error = kerneldumpcrypto_init(di->kdc); + int error = kerneldumpcrypto_init(di->kdcrypto); if (error != 0) return (error); - keysize = kerneldumpcrypto_dumpkeysize(di->kdc); + keysize = kerneldumpcrypto_dumpkeysize(di->kdcrypto); #else keysize = 0; #endif @@ -1301,8 +1287,7 @@ dump_start(struct dumperinfo *di, struct kerneldumphea dumpextent = dtoh64(kdh->dumpextent); if (di->mediasize < SIZEOF_METADATA + dumpextent + 2 * di->blocksize + keysize) { -#ifdef GZIO - if (di->kdgz != NULL) { + if (di->kdcomp != NULL) { /* * We don't yet know how much space the compressed dump * will occupy, so try to use the whole swap partition @@ -1315,7 +1300,6 @@ dump_start(struct dumperinfo *di, struct kerneldumphea 2 * di->blocksize - keysize; kdh->dumpextent = htod64(dumpextent); } else -#endif return (E2BIG); } @@ -1333,7 +1317,7 @@ _dump_append(struct dumperinfo *di, void *virtual, vm_ int error; #ifdef EKCD - if (di->kdc != NULL) + if (di->kdcrypto != NULL) error = dump_encrypted_write(di, virtual, physical, di->dumpoff, length); else @@ -1353,18 +1337,16 @@ int dump_append(struct dumperinfo *di, void *virtual, vm_offset_t physical, size_t length) { -#ifdef GZIO void *buf; - if (di->kdgz != NULL) { - /* Bounce through a buffer to avoid gzip CRC errors. */ + if (di->kdcomp != NULL) { + /* Bounce through a buffer to avoid CRC errors. */ if (length > di->maxiosize) return (EINVAL); - buf = di->kdgz->kdgz_buf; + buf = di->kdcomp->kdc_buf; memmove(buf, virtual, length); - return (gzio_write(di->kdgz->kdgz_stream, buf, length)); + return (compressor_write(di->kdcomp->kdc_stream, buf, length)); } -#endif return (_dump_append(di, virtual, physical, length)); } @@ -1399,20 +1381,19 @@ dump_finish(struct dumperinfo *di, struct kerneldumphe extent = dtoh64(kdh->dumpextent); #ifdef EKCD - keysize = kerneldumpcrypto_dumpkeysize(di->kdc); + keysize = kerneldumpcrypto_dumpkeysize(di->kdcrypto); #else keysize = 0; #endif -#ifdef GZIO - if (di->kdgz != NULL) { - error = gzio_flush(di->kdgz->kdgz_stream); + if (di->kdcomp != NULL) { + error = compressor_flush(di->kdcomp->kdc_stream); if (error == EAGAIN) { /* We have residual data in di->blockbuf. */ error = dump_write(di, di->blockbuf, 0, di->dumpoff, di->blocksize); - di->dumpoff += di->kdgz->kdgz_resid; - di->kdgz->kdgz_resid = 0; + di->dumpoff += di->kdcomp->kdc_resid; + di->kdcomp->kdc_resid = 0; } if (error != 0) return (error); @@ -1426,9 +1407,8 @@ dump_finish(struct dumperinfo *di, struct kerneldumphe kdh->parity = 0; kdh->parity = kerneldump_parity(kdh); - gzio_reset(di->kdgz->kdgz_stream); + compressor_reset(di->kdcomp->kdc_stream); } -#endif /* * Write kerneldump headers at the beginning and end of the dump extent. @@ -1471,7 +1451,7 @@ dump_init_header(const struct dumperinfo *di, struct k kdh->dumpextent = kdh->dumplength; kdh->dumptime = htod64(time_second); #ifdef EKCD - kdh->dumpkeysize = htod32(kerneldumpcrypto_dumpkeysize(di->kdc)); + kdh->dumpkeysize = htod32(kerneldumpcrypto_dumpkeysize(di->kdcrypto)); #else kdh->dumpkeysize = 0; #endif @@ -1482,10 +1462,8 @@ dump_init_header(const struct dumperinfo *di, struct k kdh->versionstring[dstsize - 2] = '\n'; if (panicstr != NULL) strlcpy(kdh->panicstring, panicstr, sizeof(kdh->panicstring)); -#ifdef GZIO - if (di->kdgz != NULL) + if (di->kdcomp != NULL) kdh->compression = KERNELDUMP_COMP_GZIP; -#endif kdh->parity = kerneldump_parity(kdh); } Modified: head/sys/kern/kern_sig.c ============================================================================== --- head/sys/kern/kern_sig.c Mon Jan 8 20:14:16 2018 (r327706) +++ head/sys/kern/kern_sig.c Mon Jan 8 21:27:41 2018 (r327707) @@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$"); #include "opt_compat.h" -#include "opt_gzio.h" #include "opt_ktrace.h" #include @@ -51,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -3255,18 +3255,31 @@ SYSCTL_PROC(_debug, OID_AUTO, ncores, CTLTYPE_INT|CTLF #define GZ_SUFFIX ".gz" -#ifdef GZIO -static int compress_user_cores = 1; -SYSCTL_INT(_kern, OID_AUTO, compress_user_cores, CTLFLAG_RWTUN, - &compress_user_cores, 0, "Compression of user corefiles"); +int compress_user_cores = 0; -int compress_user_cores_gzlevel = 6; -SYSCTL_INT(_kern, OID_AUTO, compress_user_cores_gzlevel, CTLFLAG_RWTUN, - &compress_user_cores_gzlevel, 0, "Corefile gzip compression level"); -#else -static int compress_user_cores = 0; -#endif +static int +sysctl_compress_user_cores(SYSCTL_HANDLER_ARGS) +{ + int error, val; + val = compress_user_cores; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if (val != 0 && !compressor_avail(val)) + return (EINVAL); + compress_user_cores = val; + return (error); +} +SYSCTL_PROC(_kern, OID_AUTO, compress_user_cores, CTLTYPE_INT | CTLFLAG_RWTUN, + 0, sizeof(int), sysctl_compress_user_cores, "I", + "Enable compression of user corefiles (" __XSTRING(COMPRESS_GZIP) " = gzip)"); + +int compress_user_cores_level = 6; +SYSCTL_INT(_kern, OID_AUTO, compress_user_cores_level, CTLFLAG_RWTUN, + &compress_user_cores_level, 0, + "Corefile compression level"); + /* * Protect the access to corefilename[] by allproc_lock. */ @@ -3363,7 +3376,7 @@ corefile_open(const char *comm, uid_t uid, pid_t pid, } sx_sunlock(&corefilename_lock); free(hostname, M_TEMP); - if (compress) + if (compress == COMPRESS_GZIP) sbuf_printf(&sb, GZ_SUFFIX); if (sbuf_error(&sb) != 0) { log(LOG_ERR, "pid %ld (%s), uid (%lu): corename is too " @@ -3529,8 +3542,7 @@ coredump(struct thread *td) PROC_UNLOCK(p); if (p->p_sysent->sv_coredump != NULL) { - error = p->p_sysent->sv_coredump(td, vp, limit, - compress_user_cores ? IMGACT_CORE_COMPRESS : 0); + error = p->p_sysent->sv_coredump(td, vp, limit, 0); } else { error = ENOSYS; } Copied and modified: head/sys/kern/subr_compressor.c (from r327706, head/sys/kern/kern_gzio.c) ============================================================================== --- head/sys/kern/kern_gzio.c Mon Jan 8 20:14:16 2018 (r327706, copy source) +++ head/sys/kern/subr_compressor.c Mon Jan 8 21:27:41 2018 (r327707) @@ -1,6 +1,8 @@ /*- - * Copyright (c) 2014 Mark Johnston + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * + * Copyright (c) 2014, 2017 Mark Johnston + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: @@ -24,56 +26,88 @@ * SUCH DAMAGE. */ +/* + * Subroutines used for writing compressed user process and kernel core dumps. + */ + #include __FBSDID("$FreeBSD$"); +#include "opt_gzio.h" + #include -#include +#include #include +#include #include -#include -#define KERN_GZ_HDRLEN 10 /* gzip header length */ -#define KERN_GZ_TRAILERLEN 8 /* gzip trailer length */ -#define KERN_GZ_MAGIC1 0x1f /* first magic byte */ -#define KERN_GZ_MAGIC2 0x8b /* second magic byte */ +MALLOC_DEFINE(M_COMPRESS, "compressor", "kernel compression subroutines"); -MALLOC_DEFINE(M_GZIO, "gzio", "zlib state"); +struct compressor_methods { + int format; + void *(* const init)(size_t, int); + void (* const reset)(void *); + int (* const write)(void *, void *, size_t, compressor_cb_t, void *); + void (* const fini)(void *); +}; -struct gzio_stream { - uint8_t * gz_buffer; /* output buffer */ - size_t gz_bufsz; /* total buffer size */ +struct compressor { + const struct compressor_methods *methods; + compressor_cb_t cb; + void *priv; + void *arg; +}; + +SET_DECLARE(compressors, struct compressor_methods); + +#ifdef GZIO + +#include + +struct gz_stream { + uint8_t *gz_buffer; /* output buffer */ + size_t gz_bufsz; /* output buffer size */ off_t gz_off; /* offset into the output stream */ - enum gzio_mode gz_mode; /* stream mode */ uint32_t gz_crc; /* stream CRC32 */ - gzio_cb gz_cb; /* output callback */ - void * gz_arg; /* private callback arg */ z_stream gz_stream; /* zlib state */ }; -static void * gz_alloc(void *, u_int, u_int); -static void gz_free(void *, void *); -static int gz_write(struct gzio_stream *, void *, u_int, int); +static void *gz_init(size_t maxiosize, int level); +static void gz_reset(void *stream); +static int gz_write(void *stream, void *data, size_t len, compressor_cb_t, + void *); +static void gz_fini(void *stream); -struct gzio_stream * -gzio_init(gzio_cb cb, enum gzio_mode mode, size_t bufsz, int level, void *arg) +static void * +gz_alloc(void *arg __unused, u_int n, u_int sz) { - struct gzio_stream *s; - int error; - if (bufsz < KERN_GZ_HDRLEN) - return (NULL); - if (mode != GZIO_DEFLATE) - return (NULL); + /* + * Memory for zlib state is allocated using M_NODUMP since it may be + * used to compress a kernel dump, and we don't want zlib to attempt to + * compress its own state. + */ + return (malloc(n * sz, M_COMPRESS, M_WAITOK | M_ZERO | M_NODUMP)); +} - s = gz_alloc(NULL, 1, sizeof(*s)); - s->gz_bufsz = bufsz; - s->gz_buffer = gz_alloc(NULL, 1, s->gz_bufsz); - s->gz_mode = mode; - s->gz_cb = cb; - s->gz_arg = arg; +static void +gz_free(void *arg __unused, void *ptr) +{ + free(ptr, M_COMPRESS); +} + +static void * +gz_init(size_t maxiosize, int level) +{ + struct gz_stream *s; + int error; + + s = gz_alloc(NULL, 1, roundup2(sizeof(*s), PAGE_SIZE)); + s->gz_buffer = gz_alloc(NULL, 1, maxiosize); + s->gz_bufsz = maxiosize; + s->gz_stream.zalloc = gz_alloc; s->gz_stream.zfree = gz_free; s->gz_stream.opaque = NULL; @@ -85,98 +119,57 @@ gzio_init(gzio_cb cb, enum gzio_mode mode, size_t bufs if (error != 0) goto fail; - gzio_reset(s); + gz_reset(s); return (s); fail: - gz_free(NULL, s->gz_buffer); gz_free(NULL, s); return (NULL); } -void -gzio_reset(struct gzio_stream *s) +static void +gz_reset(void *stream) { + struct gz_stream *s; uint8_t *hdr; + const size_t hdrlen = 10; - (void)deflateReset(&s->gz_stream); - + s = stream; s->gz_off = 0; s->gz_crc = ~0U; + (void)deflateReset(&s->gz_stream); s->gz_stream.avail_out = s->gz_bufsz; s->gz_stream.next_out = s->gz_buffer; /* Write the gzip header to the output buffer. */ hdr = s->gz_buffer; - memset(hdr, 0, KERN_GZ_HDRLEN); - hdr[0] = KERN_GZ_MAGIC1; - hdr[1] = KERN_GZ_MAGIC2; + memset(hdr, 0, hdrlen); + hdr[0] = 0x1f; + hdr[1] = 0x8b; hdr[2] = Z_DEFLATED; hdr[9] = OS_CODE; - s->gz_stream.next_out += KERN_GZ_HDRLEN; - s->gz_stream.avail_out -= KERN_GZ_HDRLEN; + s->gz_stream.next_out += hdrlen; + s->gz_stream.avail_out -= hdrlen; } -int -gzio_write(struct gzio_stream *s, void *data, u_int len) -{ - - return (gz_write(s, data, len, Z_NO_FLUSH)); -} - -int -gzio_flush(struct gzio_stream *s) -{ - - return (gz_write(s, NULL, 0, Z_FINISH)); -} - -void -gzio_fini(struct gzio_stream *s) -{ - - (void)deflateEnd(&s->gz_stream); - gz_free(NULL, s->gz_buffer); - gz_free(NULL, s); -} - -static void * -gz_alloc(void *arg __unused, u_int n, u_int sz) -{ - - /* - * Memory for zlib state is allocated using M_NODUMP since it may be - * used to compress a kernel dump, and we don't want zlib to attempt to - * compress its own state. - */ - return (malloc(n * sz, M_GZIO, M_WAITOK | M_ZERO | M_NODUMP)); -} - -static void -gz_free(void *arg __unused, void *ptr) -{ - - free(ptr, M_GZIO); -} - static int -gz_write(struct gzio_stream *s, void *buf, u_int len, int zflag) +gz_write(void *stream, void *data, size_t len, compressor_cb_t cb, + void *arg) { - uint8_t trailer[KERN_GZ_TRAILERLEN]; + struct gz_stream *s; + uint8_t trailer[8]; size_t room; - int error, zerror; + int error, zerror, zflag; - KASSERT(zflag == Z_FINISH || zflag == Z_NO_FLUSH, - ("unexpected flag %d", zflag)); - KASSERT(s->gz_mode == GZIO_DEFLATE, - ("invalid stream mode %d", s->gz_mode)); + s = stream; + zflag = data == NULL ? Z_FINISH : Z_NO_FLUSH; if (len > 0) { s->gz_stream.avail_in = len; - s->gz_stream.next_in = buf; - s->gz_crc = crc32_raw(buf, len, s->gz_crc); + s->gz_stream.next_in = data; + s->gz_crc = crc32_raw(data, len, s->gz_crc); } else s->gz_crc ^= ~0U; @@ -202,14 +195,13 @@ gz_write(struct gzio_stream *s, void *buf, u_int len, ((uint32_t *)trailer)[0] = s->gz_crc; ((uint32_t *)trailer)[1] = s->gz_stream.total_in; - room = MIN(KERN_GZ_TRAILERLEN, + room = MIN(sizeof(trailer), s->gz_bufsz - len); memcpy(s->gz_buffer + len, trailer, room); len += room; } - error = s->gz_cb(s->gz_buffer, len, s->gz_off, - s->gz_arg); + error = cb(s->gz_buffer, len, s->gz_off, arg); if (error != 0) break; @@ -221,13 +213,103 @@ gz_write(struct gzio_stream *s, void *buf, u_int len, * If we couldn't pack the trailer into the output * buffer, write it out now. */ - if (zerror == Z_STREAM_END && room < KERN_GZ_TRAILERLEN) - error = s->gz_cb(trailer + room, - KERN_GZ_TRAILERLEN - room, s->gz_off, - s->gz_arg); + if (zerror == Z_STREAM_END && room < sizeof(trailer)) + error = cb(trailer + room, + sizeof(trailer) - room, s->gz_off, arg); } } while (zerror != Z_STREAM_END && (zflag == Z_FINISH || s->gz_stream.avail_in > 0)); return (error); +} + +static void +gz_fini(void *stream) +{ + struct gz_stream *s; + + s = stream; + (void)deflateEnd(&s->gz_stream); + gz_free(NULL, s->gz_buffer); + gz_free(NULL, s); +} + +struct compressor_methods gzip_methods = { + .format = COMPRESS_GZIP, + .init = gz_init, + .reset = gz_reset, + .write = gz_write, + .fini = gz_fini, +}; +DATA_SET(compressors, gzip_methods); + +#endif /* GZIO */ + +bool +compressor_avail(int format) +{ + struct compressor_methods **iter; + + SET_FOREACH(iter, compressors) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-all@freebsd.org Tue Jan 9 00:00: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 744B0E6CBDE; Tue, 9 Jan 2018 00:00:56 +0000 (UTC) (envelope-from scottl@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 4FEC07BF6B; Tue, 9 Jan 2018 00:00:56 +0000 (UTC) (envelope-from scottl@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 916087000; Tue, 9 Jan 2018 00:00:55 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0900twW068920; Tue, 9 Jan 2018 00:00:55 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0900t4Y068919; Tue, 9 Jan 2018 00:00:55 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201801090000.w0900t4Y068919@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Tue, 9 Jan 2018 00:00:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327709 - head/sys/cam X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: head/sys/cam X-SVN-Commit-Revision: 327709 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: Tue, 09 Jan 2018 00:00:56 -0000 Author: scottl Date: Tue Jan 9 00:00:55 2018 New Revision: 327709 URL: https://svnweb.freebsd.org/changeset/base/327709 Log: Protect against a possible NULL deference from an accessor function. Obtained from: Netflix Modified: head/sys/cam/cam_periph.h Modified: head/sys/cam/cam_periph.h ============================================================================== --- head/sys/cam/cam_periph.h Mon Jan 8 22:59:36 2018 (r327708) +++ head/sys/cam/cam_periph.h Tue Jan 9 00:00:55 2018 (r327709) @@ -202,7 +202,10 @@ int cam_periph_error(union ccb *ccb, cam_flags camfla static __inline struct mtx * cam_periph_mtx(struct cam_periph *periph) { - return (xpt_path_mtx(periph->path)); + if (periph != NULL) + return (xpt_path_mtx(periph->path)); + else + return (NULL); } #define cam_periph_owned(periph) \ From owner-svn-src-all@freebsd.org Tue Jan 9 00:11:00 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 780C0E6DA76; Tue, 9 Jan 2018 00:11:00 +0000 (UTC) (envelope-from scottl@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 5326D7C82E; Tue, 9 Jan 2018 00:11:00 +0000 (UTC) (envelope-from scottl@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 A739271AF; Tue, 9 Jan 2018 00:10:59 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w090Axab071499; Tue, 9 Jan 2018 00:10:59 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w090AxKX071496; Tue, 9 Jan 2018 00:10:59 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201801090010.w090AxKX071496@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Tue, 9 Jan 2018 00:10:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327710 - in head/sys/cam: . ata scsi X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in head/sys/cam: . ata scsi X-SVN-Commit-Revision: 327710 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: Tue, 09 Jan 2018 00:11:00 -0000 Author: scottl Date: Tue Jan 9 00:10:59 2018 New Revision: 327710 URL: https://svnweb.freebsd.org/changeset/base/327710 Log: Don't hold the periph lock when calling into cam_periph_runccb() from the ada and da dump routines. This avoids difficult locking problems from needing to be handled. While it might seem like this would leave the periphs unprotected during dump, they were aleady at risk of unexpected removal due to the dump functions not keeping refcount state across the many calls that come in during a dump. This is an exercise for future work. Obtained from: Netflix Modified: head/sys/cam/ata/ata_da.c head/sys/cam/cam_periph.c head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/ata/ata_da.c ============================================================================== --- head/sys/cam/ata/ata_da.c Tue Jan 9 00:00:55 2018 (r327709) +++ head/sys/cam/ata/ata_da.c Tue Jan 9 00:10:59 2018 (r327710) @@ -1062,15 +1062,12 @@ adadump(void *arg, void *virtual, vm_offset_t physical dp = arg; periph = dp->d_drv1; softc = (struct ada_softc *)periph->softc; - cam_periph_lock(periph); secsize = softc->params.secsize; lba = offset / secsize; count = length / secsize; - if ((periph->flags & CAM_PERIPH_INVALID) != 0) { - cam_periph_unlock(periph); + if ((periph->flags & CAM_PERIPH_INVALID) != 0) return (ENXIO); - } memset(&ataio, 0, sizeof(ataio)); if (length > 0) { @@ -1098,7 +1095,6 @@ adadump(void *arg, void *virtual, vm_offset_t physical if (error != 0) printf("Aborting dump due to I/O error.\n"); - cam_periph_unlock(periph); return (error); } @@ -1129,7 +1125,6 @@ adadump(void *arg, void *virtual, vm_offset_t physical if (error != 0) xpt_print(periph->path, "Synchronize cache failed\n"); } - cam_periph_unlock(periph); return (error); } Modified: head/sys/cam/cam_periph.c ============================================================================== --- head/sys/cam/cam_periph.c Tue Jan 9 00:00:55 2018 (r327709) +++ head/sys/cam/cam_periph.c Tue Jan 9 00:10:59 2018 (r327710) @@ -1160,8 +1160,6 @@ cam_periph_runccb(union ccb *ccb, struct bintime ltime; int error; bool must_poll; - struct mtx *periph_mtx; - struct cam_periph *periph; uint32_t timeout = 1; starttime = NULL; @@ -1188,20 +1186,20 @@ cam_periph_runccb(union ccb *ccb, * stopped for dumping, except when we call doadump from ddb. While the * scheduler is running in this case, we still need to poll the I/O to * avoid sleeping waiting for the ccb to complete. + * + * XXX To avoid locking problems, dumping/polling callers must call + * without a periph lock held. */ must_poll = dumping; ccb->ccb_h.cbfcnp = cam_periph_done; - periph = xpt_path_periph(ccb->ccb_h.path); - periph_mtx = cam_periph_mtx(periph); /* * If we're polling, then we need to ensure that we have ample resources - * in the periph. We also need to drop the periph lock while we're polling. + * in the periph. * cam_periph_error can reschedule the ccb by calling xpt_action and returning * ERESTART, so we have to effect the polling in the do loop below. */ if (must_poll) { - mtx_unlock(periph_mtx); timeout = xpt_poll_setup(ccb); } @@ -1226,9 +1224,6 @@ cam_periph_runccb(union ccb *ccb, error = 0; } while (error == ERESTART); } - - if (must_poll) - mtx_lock(periph_mtx); if ((ccb->ccb_h.status & CAM_DEV_QFRZN) != 0) { cam_release_devq(ccb->ccb_h.path, Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Tue Jan 9 00:00:55 2018 (r327709) +++ head/sys/cam/scsi/scsi_da.c Tue Jan 9 00:10:59 2018 (r327710) @@ -1647,13 +1647,10 @@ dadump(void *arg, void *virtual, vm_offset_t physical, dp = arg; periph = dp->d_drv1; softc = (struct da_softc *)periph->softc; - cam_periph_lock(periph); secsize = softc->params.secsize; - if ((softc->flags & DA_FLAG_PACK_INVALID) != 0) { - cam_periph_unlock(periph); + if ((softc->flags & DA_FLAG_PACK_INVALID) != 0) return (ENXIO); - } memset(&csio, 0, sizeof(csio)); if (length > 0) { @@ -1676,7 +1673,6 @@ dadump(void *arg, void *virtual, vm_offset_t physical, 0, SF_NO_RECOVERY | SF_NO_RETRY, NULL); if (error != 0) printf("Aborting dump due to I/O error.\n"); - cam_periph_unlock(periph); return (error); } @@ -1700,7 +1696,6 @@ dadump(void *arg, void *virtual, vm_offset_t physical, if (error != 0) xpt_print(periph->path, "Synchronize cache failed\n"); } - cam_periph_unlock(periph); return (error); } From owner-svn-src-all@freebsd.org Tue Jan 9 00:17: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 D3B2BE6DEE0; Tue, 9 Jan 2018 00:17:16 +0000 (UTC) (envelope-from scottl@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 AF9777CBA2; Tue, 9 Jan 2018 00:17:16 +0000 (UTC) (envelope-from scottl@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 EA858730F; Tue, 9 Jan 2018 00:17:15 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w090HFCO074104; Tue, 9 Jan 2018 00:17:15 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w090HFkx074103; Tue, 9 Jan 2018 00:17:15 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201801090017.w090HFkx074103@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Tue, 9 Jan 2018 00:17:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r327711 - head/sys/cam/nvme X-SVN-Group: head X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: head/sys/cam/nvme X-SVN-Commit-Revision: 327711 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: