From owner-svn-src-stable@freebsd.org Sun Sep 2 10:51:33 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8B3D7FEBDDF; Sun, 2 Sep 2018 10:51:33 +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 3F9FB74208; Sun, 2 Sep 2018 10:51:33 +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 3A9DE184A4; Sun, 2 Sep 2018 10:51:33 +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 w82ApXtF012456; Sun, 2 Sep 2018 10:51:33 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w82ApVE0012450; Sun, 2 Sep 2018 10:51:31 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201809021051.w82ApVE0012450@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 2 Sep 2018 10:51:31 +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: r338427 - in stable/11/sys/amd64: amd64 include vmm/intel X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys/amd64: amd64 include vmm/intel X-SVN-Commit-Revision: 338427 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Sep 2018 10:51:33 -0000 Author: kib Date: Sun Sep 2 10:51:31 2018 New Revision: 338427 URL: https://svnweb.freebsd.org/changeset/base/338427 Log: MFC r338068, r338113: Update L1TF workaround to sustain L1D pollution from NMI. Modified: stable/11/sys/amd64/amd64/exception.S stable/11/sys/amd64/amd64/support.S stable/11/sys/amd64/amd64/trap.c stable/11/sys/amd64/include/md_var.h stable/11/sys/amd64/vmm/intel/vmx.c stable/11/sys/amd64/vmm/intel/vmx_support.S Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/exception.S ============================================================================== --- stable/11/sys/amd64/amd64/exception.S Sat Sep 1 16:16:40 2018 (r338426) +++ stable/11/sys/amd64/amd64/exception.S Sun Sep 2 10:51:31 2018 (r338427) @@ -848,7 +848,10 @@ nocallchain: movl %edx,%eax shrq $32,%rdx wrmsr - movq %r13,%cr3 + cmpb $0, nmi_flush_l1d_sw(%rip) + je 2f + call flush_l1d_sw /* bhyve L1TF assist */ +2: movq %r13,%cr3 RESTORE_REGS addq $TF_RIP,%rsp jmp doreti_iret Modified: stable/11/sys/amd64/amd64/support.S ============================================================================== --- stable/11/sys/amd64/amd64/support.S Sat Sep 1 16:16:40 2018 (r338426) +++ stable/11/sys/amd64/amd64/support.S Sun Sep 2 10:51:31 2018 (r338427) @@ -892,3 +892,36 @@ ENTRY(handle_ibrs_exit_rs) END(handle_ibrs_exit_rs) .noaltmacro + +/* + * Flush L1D cache. Load enough of the data from the kernel text + * to flush existing L1D content. + * + * N.B. The function does not follow ABI calling conventions, it corrupts %rbx. + * The vmm.ko caller expects that only %rax, %rdx, %rbx, %rcx, %r9, and %rflags + * registers are clobbered. The NMI handler caller only needs %r13 preserved. + */ +ENTRY(flush_l1d_sw) +#define L1D_FLUSH_SIZE (64 * 1024) + movq $KERNBASE, %r9 + movq $-L1D_FLUSH_SIZE, %rcx + /* + * pass 1: Preload TLB. + * Kernel text is mapped using superpages. TLB preload is + * done for the benefit of older CPUs which split 2M page + * into 4k TLB entries. + */ +1: movb L1D_FLUSH_SIZE(%r9, %rcx), %al + addq $PAGE_SIZE, %rcx + jne 1b + xorl %eax, %eax + cpuid + movq $-L1D_FLUSH_SIZE, %rcx + /* pass 2: Read each cache line. */ +2: movb L1D_FLUSH_SIZE(%r9, %rcx), %al + addq $64, %rcx + jne 2b + lfence + ret +#undef L1D_FLUSH_SIZE +END(flush_l1d_sw) Modified: stable/11/sys/amd64/amd64/trap.c ============================================================================== --- stable/11/sys/amd64/amd64/trap.c Sat Sep 1 16:16:40 2018 (r338426) +++ stable/11/sys/amd64/amd64/trap.c Sun Sep 2 10:51:31 2018 (r338427) @@ -158,6 +158,20 @@ SYSCTL_INT(_machdep, OID_AUTO, uprintf_signal, CTLFLAG "Print debugging information on trap signal to ctty"); /* + * Control L1D flush on return from NMI. + * + * Tunable can be set to the following values: + * 0 - only enable flush on return from NMI if required by vmm.ko (default) + * >1 - always flush on return from NMI. + * + * Post-boot, the sysctl indicates if flushing is currently enabled. + */ +int nmi_flush_l1d_sw; +SYSCTL_INT(_machdep, OID_AUTO, nmi_flush_l1d_sw, CTLFLAG_RWTUN, + &nmi_flush_l1d_sw, 0, + "Flush L1 Data Cache on NMI exit, software bhyve L1TF mitigation assist"); + +/* * Exception, fault, and trap interface to the FreeBSD kernel. * This common code is called from assembly language IDT gate entry * routines that prepare a suitable stack frame, and restore this Modified: stable/11/sys/amd64/include/md_var.h ============================================================================== --- stable/11/sys/amd64/include/md_var.h Sat Sep 1 16:16:40 2018 (r338426) +++ stable/11/sys/amd64/include/md_var.h Sun Sep 2 10:51:31 2018 (r338427) @@ -38,6 +38,7 @@ extern uint64_t *vm_page_dump; extern int hw_lower_amd64_sharedpage; extern int hw_ibrs_disable; extern int hw_ssb_disable; +extern int nmi_flush_l1d_sw; /* * The file "conf/ldscript.amd64" defines the symbol "kernphys". Its Modified: stable/11/sys/amd64/vmm/intel/vmx.c ============================================================================== --- stable/11/sys/amd64/vmm/intel/vmx.c Sat Sep 1 16:16:40 2018 (r338426) +++ stable/11/sys/amd64/vmm/intel/vmx.c Sun Sep 2 10:51:31 2018 (r338427) @@ -188,8 +188,11 @@ SYSCTL_UINT(_hw_vmm_vmx, OID_AUTO, vpid_alloc_failed, static int guest_l1d_flush; SYSCTL_INT(_hw_vmm_vmx, OID_AUTO, l1d_flush, CTLFLAG_RD, &guest_l1d_flush, 0, NULL); +static int guest_l1d_flush_sw; +SYSCTL_INT(_hw_vmm_vmx, OID_AUTO, l1d_flush_sw, CTLFLAG_RD, + &guest_l1d_flush_sw, 0, NULL); -uint64_t vmx_msr_flush_cmd; +static struct msr_entry msr_load_list[1] __aligned(16); /* * Use the last page below 4GB as the APIC access address. This address is @@ -500,6 +503,9 @@ vmx_cleanup(void) vpid_unr = NULL; } + if (nmi_flush_l1d_sw == 1) + nmi_flush_l1d_sw = 0; + smp_rendezvous(NULL, vmx_disable, NULL, NULL); return (0); @@ -728,11 +734,30 @@ vmx_init(int ipinum) guest_l1d_flush = (cpu_ia32_arch_caps & IA32_ARCH_CAP_RDCL_NO) == 0; TUNABLE_INT_FETCH("hw.vmm.l1d_flush", &guest_l1d_flush); - if (guest_l1d_flush && - (cpu_stdext_feature3 & CPUID_STDEXT3_L1D_FLUSH) != 0) - vmx_msr_flush_cmd = IA32_FLUSH_CMD_L1D; /* + * L1D cache flush is enabled. Use IA32_FLUSH_CMD MSR when + * available. Otherwise fall back to the software flush + * method which loads enough data from the kernel text to + * flush existing L1D content, both on VMX entry and on NMI + * return. + */ + if (guest_l1d_flush) { + if ((cpu_stdext_feature3 & CPUID_STDEXT3_L1D_FLUSH) == 0) { + guest_l1d_flush_sw = 1; + TUNABLE_INT_FETCH("hw.vmm.l1d_flush_sw", + &guest_l1d_flush_sw); + } + if (guest_l1d_flush_sw) { + if (nmi_flush_l1d_sw <= 1) + nmi_flush_l1d_sw = 1; + } else { + msr_load_list[0].index = MSR_IA32_FLUSH_CMD; + msr_load_list[0].val = IA32_FLUSH_CMD_L1D; + } + } + + /* * Stash the cr0 and cr4 bits that must be fixed to 0 or 1 */ fixed0 = rdmsr(MSR_VMX_CR0_FIXED0); @@ -920,6 +945,15 @@ vmx_vminit(struct vm *vm, pmap_t pmap) error += vmwrite(VMCS_ENTRY_CTLS, entry_ctls); error += vmwrite(VMCS_MSR_BITMAP, vtophys(vmx->msr_bitmap)); error += vmwrite(VMCS_VPID, vpid[i]); + + if (guest_l1d_flush && !guest_l1d_flush_sw) { + vmcs_write(VMCS_ENTRY_MSR_LOAD, pmap_kextract( + (vm_offset_t)&msr_load_list[0])); + vmcs_write(VMCS_ENTRY_MSR_LOAD_COUNT, + nitems(msr_load_list)); + vmcs_write(VMCS_EXIT_MSR_STORE, 0); + vmcs_write(VMCS_EXIT_MSR_STORE_COUNT, 0); + } /* exception bitmap */ if (vcpu_trace_exceptions(vm, i)) Modified: stable/11/sys/amd64/vmm/intel/vmx_support.S ============================================================================== --- stable/11/sys/amd64/vmm/intel/vmx_support.S Sat Sep 1 16:16:40 2018 (r338426) +++ stable/11/sys/amd64/vmm/intel/vmx_support.S Sun Sep 2 10:51:31 2018 (r338427) @@ -176,44 +176,10 @@ ENTRY(vmx_enter_guest) jbe invept_error /* Check invept instruction error */ guest_restore: - - /* - * Flush L1D cache if requested. Use IA32_FLUSH_CMD MSR if available, - * otherwise load enough of the data from the zero_region to flush - * existing L1D content. - */ -#define L1D_FLUSH_SIZE (64 * 1024) movl %edx, %r8d - cmpb $0, guest_l1d_flush(%rip) + cmpb $0, guest_l1d_flush_sw(%rip) je after_l1d - movq vmx_msr_flush_cmd(%rip), %rax - testq %rax, %rax - jz 1f - movq %rax, %rdx - shrq $32, %rdx - movl $MSR_IA32_FLUSH_CMD, %ecx - wrmsr - jmp after_l1d -1: movq $KERNBASE, %r9 - movq $-L1D_FLUSH_SIZE, %rcx - /* - * pass 1: Preload TLB. - * Kernel text is mapped using superpages. TLB preload is - * done for the benefit of older CPUs which split 2M page - * into 4k TLB entries. - */ -2: movb L1D_FLUSH_SIZE(%r9, %rcx), %al - addq $PAGE_SIZE, %rcx - jne 2b - xorl %eax, %eax - cpuid - movq $-L1D_FLUSH_SIZE, %rcx - /* pass 2: Read each cache line */ -3: movb L1D_FLUSH_SIZE(%r9, %rcx), %al - addq $64, %rcx - jne 3b - lfence -#undef L1D_FLUSH_SIZE + call flush_l1d_sw after_l1d: cmpl $0, %r8d je do_launch From owner-svn-src-stable@freebsd.org Mon Sep 3 06:36:29 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 56C1AFDFAF5; Mon, 3 Sep 2018 06:36:29 +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 111EC773BB; Mon, 3 Sep 2018 06:36:29 +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 07BF22452B; Mon, 3 Sep 2018 06:36:29 +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 w836aSXJ025632; Mon, 3 Sep 2018 06:36:28 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w836aSfx025630; Mon, 3 Sep 2018 06:36:28 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201809030636.w836aSfx025630@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 3 Sep 2018 06:36:28 +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: r338439 - in stable/11/usr.bin/diff: . tests X-SVN-Group: stable-11 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: in stable/11/usr.bin/diff: . tests X-SVN-Commit-Revision: 338439 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Sep 2018 06:36:29 -0000 Author: delphij Date: Mon Sep 3 06:36:28 2018 New Revision: 338439 URL: https://svnweb.freebsd.org/changeset/base/338439 Log: MFC r336754: Improve --strip-trailing-cr handling. Modified: stable/11/usr.bin/diff/diffreg.c stable/11/usr.bin/diff/tests/diff_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/diff/diffreg.c ============================================================================== --- stable/11/usr.bin/diff/diffreg.c Mon Sep 3 03:23:09 2018 (r338438) +++ stable/11/usr.bin/diff/diffreg.c Mon Sep 3 06:36:28 2018 (r338439) @@ -792,19 +792,22 @@ check(FILE *f1, FILE *f2, int flags) } ctold++; ctnew++; - if (flags & D_STRIPCR) { + if (flags & D_STRIPCR && (c == '\r' || d == '\r')) { if (c == '\r') { if ((c = getc(f1)) == '\n') { - ctnew++; - break; + ctold++; + } else { + ungetc(c, f1); } } if (d == '\r') { if ((d = getc(f2)) == '\n') { - ctold++; - break; + ctnew++; + } else { + ungetc(d, f2); } } + break; } if ((flags & D_FOLDBLANKS) && isspace(c) && isspace(d)) { Modified: stable/11/usr.bin/diff/tests/diff_test.sh ============================================================================== --- stable/11/usr.bin/diff/tests/diff_test.sh Mon Sep 3 03:23:09 2018 (r338438) +++ stable/11/usr.bin/diff/tests/diff_test.sh Mon Sep 3 06:36:28 2018 (r338439) @@ -8,6 +8,7 @@ atf_test_case ifdef atf_test_case group_format atf_test_case side_by_side atf_test_case brief_format +atf_test_case b230049 simple_body() { @@ -52,6 +53,15 @@ unified_body() diff -u9999 -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" } +b230049_body() +{ + printf 'a\nb\r\nc\n' > b230049_a.in + printf 'a\r\nb\r\nc\r\n' > b230049_b.in + atf_check -o empty -s eq:0 \ + diff -up --strip-trailing-cr -L b230049_a.in -L b230049_b.in \ + b230049_a.in b230049_b.in +} + header_body() { export TZ=UTC @@ -150,4 +160,5 @@ atf_init_test_cases() atf_add_test_case group_format atf_add_test_case side_by_side atf_add_test_case brief_format + atf_add_test_case b230049 } From owner-svn-src-stable@freebsd.org Mon Sep 3 06:55:39 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 42602FE0106; Mon, 3 Sep 2018 06:55:39 +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 F01A777B6B; Mon, 3 Sep 2018 06:55:38 +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 EAF872487C; Mon, 3 Sep 2018 06:55:38 +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 w836tcxH035685; Mon, 3 Sep 2018 06:55:38 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w836tcQH035684; Mon, 3 Sep 2018 06:55:38 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201809030655.w836tcQH035684@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 3 Sep 2018 06:55:38 +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: r338440 - stable/11/usr.sbin/tzsetup X-SVN-Group: stable-11 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/11/usr.sbin/tzsetup X-SVN-Commit-Revision: 338440 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Sep 2018 06:55:39 -0000 Author: delphij Date: Mon Sep 3 06:55:38 2018 New Revision: 338440 URL: https://svnweb.freebsd.org/changeset/base/338440 Log: MFC r337522: In read_zones(), check if the file name actually fit in the buffer and make sure it would terminate with nul with strlcpy(). Reviewed by: imp (earlier revision) Differential Revision: https://reviews.freebsd.org/D16595 Modified: stable/11/usr.sbin/tzsetup/tzsetup.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- stable/11/usr.sbin/tzsetup/tzsetup.c Mon Sep 3 06:36:28 2018 (r338439) +++ stable/11/usr.sbin/tzsetup/tzsetup.c Mon Sep 3 06:55:38 2018 (r338440) @@ -481,7 +481,7 @@ read_zones(void) char contbuf[16]; FILE *fp; struct continent *cont; - size_t len; + size_t len, contlen; char *line, *tlc, *file, *descr, *p; int lineno; @@ -504,12 +504,16 @@ read_zones(void) path_zonetab, lineno, tlc); /* coord = */ strsep(&line, "\t"); /* Unused */ file = strsep(&line, "\t"); + /* get continent portion from continent/country */ p = strchr(file, '/'); if (p == NULL) errx(1, "%s:%d: invalid zone name `%s'", path_zonetab, lineno, file); - contbuf[0] = '\0'; - strncat(contbuf, file, p - file); + contlen = p - file + 1; /* trailing nul */ + if (contlen > sizeof(contbuf)) + errx(1, "%s:%d: continent name in zone name `%s' too long", + path_zonetab, lineno, file); + strlcpy(contbuf, file, contlen); cont = find_continent(contbuf); if (!cont) errx(1, "%s:%d: invalid region `%s'", path_zonetab, From owner-svn-src-stable@freebsd.org Mon Sep 3 06:57:25 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E06CAFE01B1; Mon, 3 Sep 2018 06:57:25 +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 9C90677CCD; Mon, 3 Sep 2018 06:57:25 +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 9781B24880; Mon, 3 Sep 2018 06:57:25 +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 w836vPZS035809; Mon, 3 Sep 2018 06:57:25 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w836vPKx035808; Mon, 3 Sep 2018 06:57:25 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201809030657.w836vPKx035808@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Mon, 3 Sep 2018 06:57:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r338441 - stable/10/usr.sbin/tzsetup X-SVN-Group: stable-10 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: stable/10/usr.sbin/tzsetup X-SVN-Commit-Revision: 338441 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Sep 2018 06:57:26 -0000 Author: delphij Date: Mon Sep 3 06:57:25 2018 New Revision: 338441 URL: https://svnweb.freebsd.org/changeset/base/338441 Log: MFC r337522: In read_zones(), check if the file name actually fit in the buffer and make sure it would terminate with nul with strlcpy(). Reviewed by: imp (earlier revision) Differential Revision: https://reviews.freebsd.org/D16595 Modified: stable/10/usr.sbin/tzsetup/tzsetup.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/tzsetup/tzsetup.c ============================================================================== --- stable/10/usr.sbin/tzsetup/tzsetup.c Mon Sep 3 06:55:38 2018 (r338440) +++ stable/10/usr.sbin/tzsetup/tzsetup.c Mon Sep 3 06:57:25 2018 (r338441) @@ -481,7 +481,7 @@ read_zones(void) char contbuf[16]; FILE *fp; struct continent *cont; - size_t len; + size_t len, contlen; char *line, *tlc, *file, *descr, *p; int lineno; @@ -504,12 +504,16 @@ read_zones(void) path_zonetab, lineno, tlc); /* coord = */ strsep(&line, "\t"); /* Unused */ file = strsep(&line, "\t"); + /* get continent portion from continent/country */ p = strchr(file, '/'); if (p == NULL) errx(1, "%s:%d: invalid zone name `%s'", path_zonetab, lineno, file); - contbuf[0] = '\0'; - strncat(contbuf, file, p - file); + contlen = p - file + 1; /* trailing nul */ + if (contlen > sizeof(contbuf)) + errx(1, "%s:%d: continent name in zone name `%s' too long", + path_zonetab, lineno, file); + strlcpy(contbuf, file, contlen); cont = find_continent(contbuf); if (!cont) errx(1, "%s:%d: invalid region `%s'", path_zonetab, From owner-svn-src-stable@freebsd.org Mon Sep 3 08:57:10 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F0E89FE2FA6; Mon, 3 Sep 2018 08:57:09 +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 B2FD67BCDA; Mon, 3 Sep 2018 08:57:09 +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 A9B6B25BDF; Mon, 3 Sep 2018 08:57:09 +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 w838v9AT097477; Mon, 3 Sep 2018 08:57:09 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w838v9Ip097476; Mon, 3 Sep 2018 08:57:09 GMT (envelope-from kp@FreeBSD.org) Message-Id: <201809030857.w838v9Ip097476@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Mon, 3 Sep 2018 08:57:09 +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: r338442 - stable/11/sys/netinet6 X-SVN-Group: stable-11 X-SVN-Commit-Author: kp X-SVN-Commit-Paths: stable/11/sys/netinet6 X-SVN-Commit-Revision: 338442 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Sep 2018 08:57:10 -0000 Author: kp Date: Mon Sep 3 08:57:09 2018 New Revision: 338442 URL: https://svnweb.freebsd.org/changeset/base/338442 Log: MFC r338406: frag6: Fix fragment reassembly r337776 started hashing the fragments into buckets for faster lookup. The hashkey is larger than intended. This results in random stack data being included in the hashed data, which in turn means that fragments of the same packet might end up in different buckets, causing the reassembly to fail. Set the correct size for hashkey. PR: 231045 Modified: stable/11/sys/netinet6/frag6.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet6/frag6.c ============================================================================== --- stable/11/sys/netinet6/frag6.c Mon Sep 3 06:57:25 2018 (r338441) +++ stable/11/sys/netinet6/frag6.c Mon Sep 3 08:57:09 2018 (r338442) @@ -216,7 +216,9 @@ frag6_input(struct mbuf **mp, int *offp, int proto) int offset = *offp, nxt, i, next; int first_frag = 0; int fragoff, frgpartlen; /* must be larger than u_int16_t */ - uint32_t hash, hashkey[sizeof(struct in6_addr) * 2 + 1], *hashkeyp; + uint32_t hashkey[(sizeof(struct in6_addr) * 2 + + sizeof(ip6f->ip6f_ident)) / sizeof(uint32_t)]; + uint32_t hash, *hashkeyp; struct ifnet *dstifp; u_int8_t ecn, ecn0; #ifdef RSS From owner-svn-src-stable@freebsd.org Tue Sep 4 09:53:46 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8F010FE9690; Tue, 4 Sep 2018 09:53:46 +0000 (UTC) (envelope-from philip@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 4367590572; Tue, 4 Sep 2018 09:53:46 +0000 (UTC) (envelope-from philip@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 3E1E8157D3; Tue, 4 Sep 2018 09:53:46 +0000 (UTC) (envelope-from philip@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w849rkXW082298; Tue, 4 Sep 2018 09:53:46 GMT (envelope-from philip@FreeBSD.org) Received: (from philip@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w849rj4j082295; Tue, 4 Sep 2018 09:53:45 GMT (envelope-from philip@FreeBSD.org) Message-Id: <201809040953.w849rj4j082295@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: philip set sender to philip@FreeBSD.org using -f From: Philip Paeps Date: Tue, 4 Sep 2018 09:53: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: r338451 - stable/11/usr.bin/last X-SVN-Group: stable-11 X-SVN-Commit-Author: philip X-SVN-Commit-Paths: stable/11/usr.bin/last X-SVN-Commit-Revision: 338451 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2018 09:53:46 -0000 Author: philip Date: Tue Sep 4 09:53:45 2018 New Revision: 338451 URL: https://svnweb.freebsd.org/changeset/base/338451 Log: MFC r319508: Fix a memory leak with last free memory allocated to 'buf' Submitted by: Thomas Rix MFC r338352: Add libxo(3) support to last(1). Modified: stable/11/usr.bin/last/Makefile stable/11/usr.bin/last/last.1 stable/11/usr.bin/last/last.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/last/Makefile ============================================================================== --- stable/11/usr.bin/last/Makefile Mon Sep 3 22:27:27 2018 (r338450) +++ stable/11/usr.bin/last/Makefile Tue Sep 4 09:53:45 2018 (r338451) @@ -2,6 +2,7 @@ # $FreeBSD$ PROG= last +LIBADD= xo NO_WFORMAT= Modified: stable/11/usr.bin/last/last.1 ============================================================================== --- stable/11/usr.bin/last/last.1 Mon Sep 3 22:27:27 2018 (r338450) +++ stable/11/usr.bin/last/last.1 Tue Sep 4 09:53:45 2018 (r338451) @@ -28,7 +28,7 @@ .\" @(#)last.1 8.1 (Berkeley) 6/6/93 .\" $FreeBSD$ .\" -.Dd June 6, 2015 +.Dd August 28, 2018 .Dt LAST 1 .Os .Sh NAME @@ -36,6 +36,7 @@ .Nd indicate last logins of users and ttys .Sh SYNOPSIS .Nm +.Op Fl -libxo .Op Fl swy .Oo .Fl d @@ -72,6 +73,13 @@ will so indicate. .Pp The following options are available: .Bl -tag -width indent-two +.It Fl -libxo +Generate output via +.Xr libxo 3 +in a selection of different human and machine readable formats. +See +.Xr xo_parse_args 3 +for details on command line arguments. .It Fl d Ar date Specify the snapshot date and time. All users logged in at the snapshot date and time will @@ -201,6 +209,8 @@ login data base .Xr getutxent 3 , .Xr ac 8 , .Xr lastlogin 8 +.Xr libxo 3 , +.Xr xo_parse_args 3 .Sh HISTORY .Nm utility first appeared in @@ -211,6 +221,10 @@ The original version was written by .An Howard P. Katseff ; .An Keith Bostic rewrote it in 1986/87 to add functionality and to improve code quality. +.An Philip Paeps +added +.Xr libxo 3 +support in August 2018. .Sh BUGS If a login shell should terminate abnormally for some reason, it is likely that a logout record will not be written to the Modified: stable/11/usr.bin/last/last.c ============================================================================== --- stable/11/usr.bin/last/last.c Mon Sep 3 22:27:27 2018 (r338450) +++ stable/11/usr.bin/last/last.c Tue Sep 4 09:53:45 2018 (r338451) @@ -1,6 +1,7 @@ /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. + * Copyright (c) 2018 Philip Paeps * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -58,6 +59,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #define NO 0 /* false/no */ #define YES 1 /* true/yes */ #define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2; @@ -108,7 +111,7 @@ static void wtmp(void); static void usage(void) { - (void)fprintf(stderr, + xo_error( "usage: last [-swy] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h host]\n" " [-n maxrec] [-t tty] [user ...]\n"); exit(1); @@ -123,6 +126,11 @@ main(int argc, char *argv[]) (void) setlocale(LC_TIME, ""); d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); + argc = xo_parse_args(argc, argv); + if (argc < 0) + exit(1); + atexit(xo_finish_atexit); + maxrec = -1; snaptime = 0; while ((ch = getopt(argc, argv, "0123456789d:f:h:n:st:wy")) != -1) @@ -157,7 +165,7 @@ main(int argc, char *argv[]) maxrec = strtol(optarg, &p, 10); if (p == optarg || *p != '\0' || errno != 0 || maxrec <= 0) - errx(1, "%s: bad line count", optarg); + xo_errx(1, "%s: bad line count", optarg); break; case 's': sflag++; /* Show delta as seconds */ @@ -212,14 +220,16 @@ wtmp(void) SLIST_INIT(&idlist); (void)time(&t); + xo_open_container("last-information"); + /* Load the last entries from the file. */ if (setutxdb(UTXDB_LOG, file) != 0) - err(1, "%s", file); + xo_err(1, "%s", file); while ((ut = getutxent()) != NULL) { if (amount % 128 == 0) { buf = realloc(buf, (amount + 128) * sizeof *ut); if (buf == NULL) - err(1, "realloc"); + xo_err(1, "realloc"); } memcpy(&buf[amount++], ut, sizeof *ut); if (t > ut->ut_tv.tv_sec) @@ -228,12 +238,17 @@ wtmp(void) endutxent(); /* Display them in reverse order. */ + xo_open_list("last"); while (amount > 0) doentry(&buf[--amount]); - + xo_close_list("last"); + free(buf); tm = localtime(&t); (void) strftime(ct, sizeof(ct), "%+", tm); - printf("\n%s begins %s\n", ((file == NULL) ? "utx.log" : file), ct); + xo_emit("\n{:utxdb/%s}", (file == NULL) ? "utx.log" : file); + xo_attr("seconds", "%lu", (unsigned long) t); + xo_emit(" begins {:begins/%s}\n", ct); + xo_close_container("last-information"); } /* @@ -288,7 +303,7 @@ doentry(struct utmpx *bp) /* add new one */ tt = malloc(sizeof(struct idtab)); if (tt == NULL) - errx(1, "malloc failure"); + xo_errx(1, "malloc failure"); tt->logout = currentout; memcpy(tt->id, bp->ut_id, sizeof bp->ut_id); SLIST_INSERT_HEAD(&idlist, tt, list); @@ -324,6 +339,7 @@ printentry(struct utmpx *bp, struct idtab *tt) if (maxrec != -1 && !maxrec--) exit(0); + xo_open_instance("last"); t = bp->ut_tv.tv_sec; tm = localtime(&t); (void) strftime(ct, sizeof(ct), d_first ? @@ -331,48 +347,55 @@ printentry(struct utmpx *bp, struct idtab *tt) (yflag ? "%a %b %e %Y %R" : "%a %b %e %R"), tm); switch (bp->ut_type) { case BOOT_TIME: - printf("%-42s", "boot time"); + xo_emit("{:user/%-42s/%s}", "boot time"); break; case SHUTDOWN_TIME: - printf("%-42s", "shutdown time"); + xo_emit("{:user/%-42s/%s}", "shutdown time"); break; case OLD_TIME: - printf("%-42s", "old time"); + xo_emit("{:user/%-42s/%s}", "old time"); break; case NEW_TIME: - printf("%-42s", "new time"); + xo_emit("{:user/%-42s/%s}", "new time"); break; case USER_PROCESS: - printf("%-10s %-8s %-22.22s", + xo_emit("{:user/%-10s/%s} {:tty/%-8s/%s} {:from/%-22.22s/%s}", bp->ut_user, bp->ut_line, bp->ut_host); break; } - printf(" %s%c", ct, tt == NULL ? '\n' : ' '); + xo_attr("seconds", "%lu", (unsigned long)t); + xo_emit(" {:login-time/%s%c/%s}", ct, tt == NULL ? '\n' : ' '); if (tt == NULL) - return; + goto end; if (!tt->logout) { - puts(" still logged in"); - return; + xo_emit(" {:logout-time/still logged in}\n"); + goto end; } if (tt->logout < 0) { tt->logout = -tt->logout; - printf("- %s", crmsg); + xo_emit("- {:logout-reason/%s}", crmsg); } else { tm = localtime(&tt->logout); (void) strftime(ct, sizeof(ct), "%R", tm); - printf("- %s", ct); + xo_attr("seconds", "%lu", (unsigned long)tt->logout); + xo_emit("- {:logout-time/%s}", ct); } delta = tt->logout - bp->ut_tv.tv_sec; + xo_attr("seconds", "%ld", (long)delta); if (sflag) { - printf(" (%8ld)\n", (long)delta); + xo_emit(" ({:session-length/%8ld})\n", (long)delta); } else { tm = gmtime(&delta); (void) strftime(ct, sizeof(ct), width >= 8 ? "%T" : "%R", tm); if (delta < 86400) - printf(" (%s)\n", ct); + xo_emit(" ({:session-length/%s})\n", ct); else - printf(" (%ld+%s)\n", (long)delta / 86400, ct); + xo_emit(" ({:session-length/%ld+%s})\n", + (long)delta / 86400, ct); } + +end: + xo_close_instance("last"); } /* @@ -423,7 +446,7 @@ addarg(int type, char *arg) ARG *cur; if ((cur = malloc(sizeof(ARG))) == NULL) - errx(1, "malloc failure"); + xo_errx(1, "malloc failure"); cur->next = arglist; cur->type = type; cur->name = arg; @@ -448,7 +471,7 @@ hostconv(char *arg) if (first) { first = 0; if (gethostname(name, sizeof(name))) - err(1, "gethostname"); + xo_err(1, "gethostname"); hostdot = strchr(name, '.'); } if (hostdot && !strcasecmp(hostdot, argdot)) @@ -471,7 +494,7 @@ ttyconv(char *arg) if (strlen(arg) == 2) { /* either 6 for "ttyxx" or 8 for "console" */ if ((mval = malloc(8)) == NULL) - errx(1, "malloc failure"); + xo_errx(1, "malloc failure"); if (!strcmp(arg, "co")) (void)strcpy(mval, "console"); else { @@ -501,9 +524,9 @@ dateconv(char *arg) /* Start with the current time. */ if (time(&timet) < 0) - err(1, "time"); + xo_err(1, "time"); if ((t = localtime(&timet)) == NULL) - err(1, "localtime"); + xo_err(1, "localtime"); /* [[CC]YY]MMDDhhmm[.SS] */ if ((p = strchr(arg, '.')) == NULL) @@ -552,7 +575,7 @@ dateconv(char *arg) t->tm_isdst = -1; /* Figure out DST. */ timet = mktime(t); if (timet == -1) -terr: errx(1, +terr: xo_errx(1, "out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]"); return timet; } From owner-svn-src-stable@freebsd.org Tue Sep 4 09:58:15 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E663CFE98CE; Tue, 4 Sep 2018 09:58:14 +0000 (UTC) (envelope-from philip@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 9ACDC90A2F; Tue, 4 Sep 2018 09:58:14 +0000 (UTC) (envelope-from philip@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 8E319157D8; Tue, 4 Sep 2018 09:58:14 +0000 (UTC) (envelope-from philip@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w849wEmO082812; Tue, 4 Sep 2018 09:58:14 GMT (envelope-from philip@FreeBSD.org) Received: (from philip@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w849wDuF082810; Tue, 4 Sep 2018 09:58:13 GMT (envelope-from philip@FreeBSD.org) Message-Id: <201809040958.w849wDuF082810@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: philip set sender to philip@FreeBSD.org using -f From: Philip Paeps Date: Tue, 4 Sep 2018 09:58: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: r338452 - stable/11/usr.sbin/lastlogin X-SVN-Group: stable-11 X-SVN-Commit-Author: philip X-SVN-Commit-Paths: stable/11/usr.sbin/lastlogin X-SVN-Commit-Revision: 338452 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2018 09:58:15 -0000 Author: philip Date: Tue Sep 4 09:58:13 2018 New Revision: 338452 URL: https://svnweb.freebsd.org/changeset/base/338452 Log: MFC r338353: Add libxo(3) support to lastlogin(8). Modified: stable/11/usr.sbin/lastlogin/Makefile stable/11/usr.sbin/lastlogin/lastlogin.8 stable/11/usr.sbin/lastlogin/lastlogin.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/lastlogin/Makefile ============================================================================== --- stable/11/usr.sbin/lastlogin/Makefile Tue Sep 4 09:53:45 2018 (r338451) +++ stable/11/usr.sbin/lastlogin/Makefile Tue Sep 4 09:58:13 2018 (r338452) @@ -2,5 +2,6 @@ PROG= lastlogin MAN= lastlogin.8 +LIBADD= xo .include Modified: stable/11/usr.sbin/lastlogin/lastlogin.8 ============================================================================== --- stable/11/usr.sbin/lastlogin/lastlogin.8 Tue Sep 4 09:53:45 2018 (r338451) +++ stable/11/usr.sbin/lastlogin/lastlogin.8 Tue Sep 4 09:58:13 2018 (r338452) @@ -31,7 +31,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd June 6, 2011 +.Dd August 28, 2018 .Dt LASTLOGIN 8 .Os .Sh NAME @@ -39,6 +39,7 @@ .Nd indicate last login time of users .Sh SYNOPSIS .Nm +.Op Fl -libxo .Op Fl f Ar file .Op Fl rt .Op Ar user ... @@ -68,6 +69,13 @@ The last login database is never turned over or delete .Pp The following options are available: .Bl -tag -width indent +.It Fl -libxo +Generate output via +.Xr libxo 3 +in a selection of different human and machine readable formats. +See +.Xr xo_parse_args 3 +for details on command line arguments. .It Fl f Ar file Open last login database .Ar file @@ -86,9 +94,15 @@ last login database .Xr last 1 , .Xr getutxent 3 , .Xr ac 8 +.Xr libxo 3 , +.Xr xo_parse_args 3 .Sh AUTHORS +.An -nosplit .An John M. Vinopal wrote this program in January 1996 and contributed it to the .Nx project. +.An Philip Paeps added +.Xr libxo 3 +support in August 2018. Modified: stable/11/usr.sbin/lastlogin/lastlogin.c ============================================================================== --- stable/11/usr.sbin/lastlogin/lastlogin.c Tue Sep 4 09:53:45 2018 (r338451) +++ stable/11/usr.sbin/lastlogin/lastlogin.c Tue Sep 4 09:58:13 2018 (r338452) @@ -2,6 +2,7 @@ * SPDX-License-Identifier: BSD-4-Clause * * Copyright (c) 1996 John M. Vinopal + * Copyright (c) 2018 Philip Paeps * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -46,6 +47,8 @@ __RCSID("$NetBSD: lastlogin.c,v 1.4 1998/02/03 04:45:3 #include #include +#include + int main(int, char **); static void output(struct utmpx *); static void usage(void); @@ -79,6 +82,10 @@ main(int argc, char *argv[]) int ch, i, ulistsize; struct utmpx *u, *ulist; + argc = xo_parse_args(argc, argv); + if (argc < 0) + exit(1); + while ((ch = getopt(argc, argv, "f:rt")) != -1) { switch (ch) { case 'f': @@ -97,13 +104,16 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + xo_open_container("lastlogin-information"); + xo_open_list("lastlogin"); + if (argc > 0) { /* Process usernames given on the command line. */ for (i = 0; i < argc; i++) { if (setutxdb(UTXDB_LASTLOGIN, file) != 0) - err(1, "failed to open lastlog database"); + xo_err(1, "failed to open lastlog database"); if ((u = getutxuser(argv[i])) == NULL) { - warnx("user '%s' not found", argv[i]); + xo_warnx("user '%s' not found", argv[i]); continue; } output(u); @@ -112,7 +122,7 @@ main(int argc, char *argv[]) } else { /* Read all lastlog entries, looking for active ones. */ if (setutxdb(UTXDB_LASTLOGIN, file) != 0) - err(1, "failed to open lastlog database"); + xo_err(1, "failed to open lastlog database"); ulist = NULL; ulistsize = 0; while ((u = getutxent()) != NULL) { @@ -122,7 +132,7 @@ main(int argc, char *argv[]) ulist = realloc(ulist, (ulistsize + 16) * sizeof(struct utmpx)); if (ulist == NULL) - err(1, "malloc"); + xo_err(1, "malloc"); } ulist[ulistsize++] = *u; } @@ -133,6 +143,10 @@ main(int argc, char *argv[]) output(&ulist[i]); } + xo_close_list("lastlogin"); + xo_close_container("lastlogin-information"); + xo_finish(); + exit(0); } @@ -142,13 +156,18 @@ output(struct utmpx *u) { time_t t = u->ut_tv.tv_sec; - printf("%-10s %-8s %-22.22s %s", - u->ut_user, u->ut_line, u->ut_host, ctime(&t)); + xo_open_instance("lastlogin"); + xo_emit("{:user/%-10s/%s} {:tty/%-8s/%s} {:from/%-22.22s/%s}", + u->ut_user, u->ut_line, u->ut_host); + xo_attr("seconds", "%lu", (unsigned long)t); + xo_emit(" {:login-time/%.24s/%.24s}\n", ctime(&t)); + xo_close_instance("lastlogin"); } static void usage(void) { - fprintf(stderr, "usage: lastlogin [-f file] [-rt] [user ...]\n"); + xo_error("usage: lastlogin [-f file] [-rt] [user ...]\n"); + xo_finish(); exit(1); } From owner-svn-src-stable@freebsd.org Tue Sep 4 09:59:33 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2163CFE9990; Tue, 4 Sep 2018 09:59:33 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7C49F90B9A; Tue, 4 Sep 2018 09:59:32 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by mail-lf1-x142.google.com with SMTP id h64-v6so2429846lfi.10; Tue, 04 Sep 2018 02:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc; bh=6a1shjHvDEmKJ26KED68MPUpiwGhzJBvAcBqVysIKXE=; b=SncvS/7HByHHt10bfWkR/IDUXqn/vrblgkBmH8BQWT9RrGHIbiQv2BLEZISNgFdBon lxClMt5NR2B8fDSeBeY8E0VDdwtLEAr6g8T7IVrfjeeryV1F2VPSTuN8HnDwfHi72LQn d4+y8JZP2XZAdaFbuKexUnA8mNw/wxKIlF6aelg5LjfgcVzTwVfCK259SKYc6Vl4qLRD V1cB9/irfQ+GSbgTAtupbN+91+jf9FDQ4ToRgWFSSoFEE33HvTMKakXCGShpmqXXxIWf RnGhsgu9QmzupAlOg9XnXjC8IJDLuBuPjReXAo1Ca3ag1KtkCJnAOFEroU74q3+6sjeB hRRw== 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=6a1shjHvDEmKJ26KED68MPUpiwGhzJBvAcBqVysIKXE=; b=Mywr1+50rH3qQhfjUXuWdl1yswmxRKtQCjDWS0/YySR9e1CkLvOa/u5spkplZxV6Z8 uJMxgUEs8B9SzbqYgGnvn1VLyjDFieDlwsVLavhU7wFtczBqLugRr3iurBCd9PBeFkqf Q1qKe3tYDME61xrCO0nmBHnLeBRHnHxTXAb5hGJzQPhzNckBpryomUojJ3cpq5pCwiKP zXhMAzRHIQJ2UJ4luDAE96X0vp5gLaAf9mZ+caFNRaX1jwwn10xoNZ/0qD7N+n7oYKWU 4YJ9g7TsX9eLbMQndoj6unJ42920K7+UG7ckvOVsDaOI1Z4xwB/m0auOURxSt+1UcTIz UKTw== X-Gm-Message-State: APzg51DZMNrfwJ6AaJ63PwrEfIIuq1woImJHCVCH/5mlr5BA1uDowZOt 2G+Y2lp9KTJDpmv8g6VcPJIRVYaHnZ+9I6ae4eEr/Q== X-Google-Smtp-Source: ANB0VdbD8I5etAakMETAHkEKeRmFRgpwNi7iz7CQYKm4w6wuXbtZnB1TbAu2vgnV3/L1OuVw9hqKniKVpLaYtfbA/3w= X-Received: by 2002:a19:4b15:: with SMTP id y21-v6mr19708690lfa.118.1536055170997; Tue, 04 Sep 2018 02:59:30 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:db4b:0:0:0:0:0 with HTTP; Tue, 4 Sep 2018 02:59:30 -0700 (PDT) Reply-To: araujo@freebsd.org In-Reply-To: <201809040953.w849rj4j082295@repo.freebsd.org> References: <201809040953.w849rj4j082295@repo.freebsd.org> From: Marcelo Araujo Date: Tue, 4 Sep 2018 17:59:30 +0800 Message-ID: Subject: Re: svn commit: r338451 - stable/11/usr.bin/last To: Philip Paeps Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2018 09:59:33 -0000 2018-09-04 17:53 GMT+08:00 Philip Paeps : > Author: philip > Date: Tue Sep 4 09:53:45 2018 > New Revision: 338451 > URL: https://svnweb.freebsd.org/changeset/base/338451 > > Log: > MFC r319508: > Fix a memory leak with last > free memory allocated to 'buf' > Is that the right patch? Or the commit message missed adding support to libxo(3)? > > Submitted by: Thomas Rix > > MFC r338352: > Add libxo(3) support to last(1). > > Modified: > stable/11/usr.bin/last/Makefile > stable/11/usr.bin/last/last.1 > stable/11/usr.bin/last/last.c > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/usr.bin/last/Makefile > ============================================================ > ================== > --- stable/11/usr.bin/last/Makefile Mon Sep 3 22:27:27 2018 > (r338450) > +++ stable/11/usr.bin/last/Makefile Tue Sep 4 09:53:45 2018 > (r338451) > @@ -2,6 +2,7 @@ > # $FreeBSD$ > > PROG= last > +LIBADD= xo > > NO_WFORMAT= > > > Modified: stable/11/usr.bin/last/last.1 > ============================================================ > ================== > --- stable/11/usr.bin/last/last.1 Mon Sep 3 22:27:27 2018 > (r338450) > +++ stable/11/usr.bin/last/last.1 Tue Sep 4 09:53:45 2018 > (r338451) > @@ -28,7 +28,7 @@ > .\" @(#)last.1 8.1 (Berkeley) 6/6/93 > .\" $FreeBSD$ > .\" > -.Dd June 6, 2015 > +.Dd August 28, 2018 > .Dt LAST 1 > .Os > .Sh NAME > @@ -36,6 +36,7 @@ > .Nd indicate last logins of users and ttys > .Sh SYNOPSIS > .Nm > +.Op Fl -libxo > .Op Fl swy > .Oo > .Fl d > @@ -72,6 +73,13 @@ will so indicate. > .Pp > The following options are available: > .Bl -tag -width indent-two > +.It Fl -libxo > +Generate output via > +.Xr libxo 3 > +in a selection of different human and machine readable formats. > +See > +.Xr xo_parse_args 3 > +for details on command line arguments. > .It Fl d Ar date > Specify the snapshot date and time. > All users logged in at the snapshot date and time will > @@ -201,6 +209,8 @@ login data base > .Xr getutxent 3 , > .Xr ac 8 , > .Xr lastlogin 8 > +.Xr libxo 3 , > +.Xr xo_parse_args 3 > .Sh HISTORY > .Nm > utility first appeared in > @@ -211,6 +221,10 @@ The original version was written by > .An Howard P. Katseff ; > .An Keith Bostic > rewrote it in 1986/87 to add functionality and to improve code quality. > +.An Philip Paeps > +added > +.Xr libxo 3 > +support in August 2018. > .Sh BUGS > If a login shell should terminate abnormally for some reason, it is likely > that a logout record will not be written to the > > Modified: stable/11/usr.bin/last/last.c > ============================================================ > ================== > --- stable/11/usr.bin/last/last.c Mon Sep 3 22:27:27 2018 > (r338450) > +++ stable/11/usr.bin/last/last.c Tue Sep 4 09:53:45 2018 > (r338451) > @@ -1,6 +1,7 @@ > /* > * Copyright (c) 1987, 1993, 1994 > * The Regents of the University of California. All rights reserved. > + * Copyright (c) 2018 Philip Paeps > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > @@ -58,6 +59,8 @@ __FBSDID("$FreeBSD$"); > #include > #include > > +#include > + > #define NO 0 /* false/no */ > #define YES 1 /* true/yes */ > #define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); > (ar) += 2; > @@ -108,7 +111,7 @@ static void wtmp(void); > static void > usage(void) > { > - (void)fprintf(stderr, > + xo_error( > "usage: last [-swy] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h host]\n" > " [-n maxrec] [-t tty] [user ...]\n"); > exit(1); > @@ -123,6 +126,11 @@ main(int argc, char *argv[]) > (void) setlocale(LC_TIME, ""); > d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); > > + argc = xo_parse_args(argc, argv); > + if (argc < 0) > + exit(1); > + atexit(xo_finish_atexit); > + > maxrec = -1; > snaptime = 0; > while ((ch = getopt(argc, argv, "0123456789d:f:h:n:st:wy")) != -1) > @@ -157,7 +165,7 @@ main(int argc, char *argv[]) > maxrec = strtol(optarg, &p, 10); > if (p == optarg || *p != '\0' || errno != 0 || > maxrec <= 0) > - errx(1, "%s: bad line count", optarg); > + xo_errx(1, "%s: bad line count", optarg); > break; > case 's': > sflag++; /* Show delta as seconds */ > @@ -212,14 +220,16 @@ wtmp(void) > SLIST_INIT(&idlist); > (void)time(&t); > > + xo_open_container("last-information"); > + > /* Load the last entries from the file. */ > if (setutxdb(UTXDB_LOG, file) != 0) > - err(1, "%s", file); > + xo_err(1, "%s", file); > while ((ut = getutxent()) != NULL) { > if (amount % 128 == 0) { > buf = realloc(buf, (amount + 128) * sizeof *ut); > if (buf == NULL) > - err(1, "realloc"); > + xo_err(1, "realloc"); > } > memcpy(&buf[amount++], ut, sizeof *ut); > if (t > ut->ut_tv.tv_sec) > @@ -228,12 +238,17 @@ wtmp(void) > endutxent(); > > /* Display them in reverse order. */ > + xo_open_list("last"); > while (amount > 0) > doentry(&buf[--amount]); > - > + xo_close_list("last"); > + free(buf); > tm = localtime(&t); > (void) strftime(ct, sizeof(ct), "%+", tm); > - printf("\n%s begins %s\n", ((file == NULL) ? "utx.log" : file), > ct); > + xo_emit("\n{:utxdb/%s}", (file == NULL) ? "utx.log" : file); > + xo_attr("seconds", "%lu", (unsigned long) t); > + xo_emit(" begins {:begins/%s}\n", ct); > + xo_close_container("last-information"); > } > > /* > @@ -288,7 +303,7 @@ doentry(struct utmpx *bp) > /* add new one */ > tt = malloc(sizeof(struct idtab)); > if (tt == NULL) > - errx(1, "malloc failure"); > + xo_errx(1, "malloc failure"); > tt->logout = currentout; > memcpy(tt->id, bp->ut_id, sizeof bp->ut_id); > SLIST_INSERT_HEAD(&idlist, tt, list); > @@ -324,6 +339,7 @@ printentry(struct utmpx *bp, struct idtab *tt) > > if (maxrec != -1 && !maxrec--) > exit(0); > + xo_open_instance("last"); > t = bp->ut_tv.tv_sec; > tm = localtime(&t); > (void) strftime(ct, sizeof(ct), d_first ? > @@ -331,48 +347,55 @@ printentry(struct utmpx *bp, struct idtab *tt) > (yflag ? "%a %b %e %Y %R" : "%a %b %e %R"), tm); > switch (bp->ut_type) { > case BOOT_TIME: > - printf("%-42s", "boot time"); > + xo_emit("{:user/%-42s/%s}", "boot time"); > break; > case SHUTDOWN_TIME: > - printf("%-42s", "shutdown time"); > + xo_emit("{:user/%-42s/%s}", "shutdown time"); > break; > case OLD_TIME: > - printf("%-42s", "old time"); > + xo_emit("{:user/%-42s/%s}", "old time"); > break; > case NEW_TIME: > - printf("%-42s", "new time"); > + xo_emit("{:user/%-42s/%s}", "new time"); > break; > case USER_PROCESS: > - printf("%-10s %-8s %-22.22s", > + xo_emit("{:user/%-10s/%s} {:tty/%-8s/%s} > {:from/%-22.22s/%s}", > bp->ut_user, bp->ut_line, bp->ut_host); > break; > } > - printf(" %s%c", ct, tt == NULL ? '\n' : ' '); > + xo_attr("seconds", "%lu", (unsigned long)t); > + xo_emit(" {:login-time/%s%c/%s}", ct, tt == NULL ? '\n' : ' '); > if (tt == NULL) > - return; > + goto end; > if (!tt->logout) { > - puts(" still logged in"); > - return; > + xo_emit(" {:logout-time/still logged in}\n"); > + goto end; > } > if (tt->logout < 0) { > tt->logout = -tt->logout; > - printf("- %s", crmsg); > + xo_emit("- {:logout-reason/%s}", crmsg); > } else { > tm = localtime(&tt->logout); > (void) strftime(ct, sizeof(ct), "%R", tm); > - printf("- %s", ct); > + xo_attr("seconds", "%lu", (unsigned long)tt->logout); > + xo_emit("- {:logout-time/%s}", ct); > } > delta = tt->logout - bp->ut_tv.tv_sec; > + xo_attr("seconds", "%ld", (long)delta); > if (sflag) { > - printf(" (%8ld)\n", (long)delta); > + xo_emit(" ({:session-length/%8ld})\n", (long)delta); > } else { > tm = gmtime(&delta); > (void) strftime(ct, sizeof(ct), width >= 8 ? "%T" : "%R", > tm); > if (delta < 86400) > - printf(" (%s)\n", ct); > + xo_emit(" ({:session-length/%s})\n", ct); > else > - printf(" (%ld+%s)\n", (long)delta / 86400, ct); > + xo_emit(" ({:session-length/%ld+%s})\n", > + (long)delta / 86400, ct); > } > + > +end: > + xo_close_instance("last"); > } > > /* > @@ -423,7 +446,7 @@ addarg(int type, char *arg) > ARG *cur; > > if ((cur = malloc(sizeof(ARG))) == NULL) > - errx(1, "malloc failure"); > + xo_errx(1, "malloc failure"); > cur->next = arglist; > cur->type = type; > cur->name = arg; > @@ -448,7 +471,7 @@ hostconv(char *arg) > if (first) { > first = 0; > if (gethostname(name, sizeof(name))) > - err(1, "gethostname"); > + xo_err(1, "gethostname"); > hostdot = strchr(name, '.'); > } > if (hostdot && !strcasecmp(hostdot, argdot)) > @@ -471,7 +494,7 @@ ttyconv(char *arg) > if (strlen(arg) == 2) { > /* either 6 for "ttyxx" or 8 for "console" */ > if ((mval = malloc(8)) == NULL) > - errx(1, "malloc failure"); > + xo_errx(1, "malloc failure"); > if (!strcmp(arg, "co")) > (void)strcpy(mval, "console"); > else { > @@ -501,9 +524,9 @@ dateconv(char *arg) > > /* Start with the current time. */ > if (time(&timet) < 0) > - err(1, "time"); > + xo_err(1, "time"); > if ((t = localtime(&timet)) == NULL) > - err(1, "localtime"); > + xo_err(1, "localtime"); > > /* [[CC]YY]MMDDhhmm[.SS] */ > if ((p = strchr(arg, '.')) == NULL) > @@ -552,7 +575,7 @@ dateconv(char *arg) > t->tm_isdst = -1; /* Figure out DST. */ > timet = mktime(t); > if (timet == -1) > -terr: errx(1, > +terr: xo_errx(1, > "out of range or illegal time specification: > [[CC]YY]MMDDhhmm[.SS]"); > return timet; > } > > -- -- Marcelo Araujo (__)araujo@FreeBSD.org \\\'',)http://www.FreeBSD.org \/ \ ^ Power To Server. .\. /_) From owner-svn-src-stable@freebsd.org Tue Sep 4 10:09:38 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1F535FEA00F; Tue, 4 Sep 2018 10:09:38 +0000 (UTC) (envelope-from philip@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B273F910F5; Tue, 4 Sep 2018 10:09:37 +0000 (UTC) (envelope-from philip@freebsd.org) Received: from weatherwax.trouble.is (weatherwax.trouble.is [176.58.93.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "weatherwax.trouble.is", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: philip/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 8AD3A9E2D; Tue, 4 Sep 2018 10:09:37 +0000 (UTC) (envelope-from philip@freebsd.org) Received: from rincewind.trouble.is (rincewind.trouble.is [IPv6:2a01:4f8:a0:10e6::1:1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "rincewind.trouble.is", Issuer "Let's Encrypt Authority X3" (verified OK)) by weatherwax.trouble.is (Postfix) with ESMTPS id 424My74fVcz3C25; Tue, 4 Sep 2018 10:09:35 +0000 (UTC) Received: by rincewind.trouble.is (Postfix, from userid 1001) id 424My70nthzJcZ; Tue, 4 Sep 2018 10:09:35 +0000 (UTC) Date: Tue, 4 Sep 2018 12:09:35 +0200 From: Philip Paeps To: araujo@freebsd.org Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r338451 - stable/11/usr.bin/last Message-ID: <20180904100934.GC27236@rincewind.trouble.is> Mail-Followup-To: araujo@freebsd.org, src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <201809040953.w849rj4j082295@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-PGP-Fingerprint: 2CD1 92C2 6EE7 B7D1 F552 6619 31AE B9B5 FDBB CB0E X-Date: Today is Boomtime, the 28th day of Bureaucracy in the YOLD 3184 X-Phase-of-Moon: The Moon is Waning Crescent (36% of Full) X-Clacks-Overhead: GNU Terry Pratchett Organization: Happily Disorganized User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2018 10:09:38 -0000 On 2018-09-04 17:59:30 (+0800), Marcelo Araujo wrote: >2018-09-04 17:53 GMT+08:00 Philip Paeps : > >> Author: philip >> Date: Tue Sep 4 09:53:45 2018 >> New Revision: 338451 >> URL: https://svnweb.freebsd.org/changeset/base/338451 >> >> Log: >> MFC r319508: >> Fix a memory leak with last >> free memory allocated to 'buf' > >Is that the right patch? Or the commit message missed adding support to >libxo(3)? I merged two changes: * r319508 plugs a memory leak. This was originally committed by stevek in June 2017 but apparently never MFCed. * rr338352 adds libxo support. I mentioned both changes in the commit message. I'm not sure what's unclear. Philip -- Philip Paeps Senior Reality Engineer Ministry of Information From owner-svn-src-stable@freebsd.org Tue Sep 4 10:15:17 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 35C94FEA533; Tue, 4 Sep 2018 10:15:17 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A12149151E; Tue, 4 Sep 2018 10:15:16 +0000 (UTC) (envelope-from araujobsdport@gmail.com) Received: by mail-lf1-x142.google.com with SMTP id h64-v6so2466553lfi.10; Tue, 04 Sep 2018 03:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to; bh=3gsYFROSo1KnB/kKgOezoS4tW4fgx+vXrLW+Itclj4s=; b=Oo4wEd2OvCeuUYh50vbV9RKfUpOBjZlUmXy4aOUYx/tYwrQodhNjRgv69CLBoukFsz poGNWFxjmjUcHEa1frDcd2z+Ryd6bH3TnMnEJ9/xFFPEzaIUAy83LZw8UtsPPsVkXaJQ eTqcEa1ccbatvq/9KGA826mr8mCkCTox6mEEF7d/6Eo4dcTf2WYTcWuDWKafYK5ZwzQI fsGSTmA/hgMyFHpy7kkVTAYkOgpXtszlg8Av/MdNM6//6GVD67HFOshITjJKKY+jisHt 2KsRXcwzoa5JU0vUXjyANiXLB5KBlmMrBspH7vdS7PgPfiHv9eLo5LZXOnLtiI6DB05f GuVg== 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; bh=3gsYFROSo1KnB/kKgOezoS4tW4fgx+vXrLW+Itclj4s=; b=JxP09qLnxQmYyMLPzUicqMmUN0sU7UGlzBxPBQuxwTVHQu3Fr0DOHT7gIIfE6AeYkz V2lequCMLReDlxt4D6F1r4QFwBQaGFtbVpmS9/01ywIINysdPEo1qFBY5RhqokyHC4HX PrDDKjAOqLxLtZL4cphm2mhTs1JVMSCjbZlyqtIgrzCvvDBKzfMCr95AmKelhiEXfDTV Hm6tFA+54TqQTv/EuM1ZqnLtbotZz6OqjwwmH0vWu+g0mKzNLq3i84wMlLbdwqIrqtc4 5UyGl5LWsIosIHbeNlDvCplRK5Led7B7QtlM72NTi5BiF9TK8Eiyu/xfTHUVwJB38e5j R1fQ== X-Gm-Message-State: APzg51DfcEnWFJZ2mQyMrKFxqpMH8oII62g5y7CGS6k9o2TjTFB6Pfkb w0Afj4dMakxFqtjsJ6/DhtkcslkyfyW9zgbz3euAww== X-Google-Smtp-Source: ANB0VdapOBGDcQMeYsJU9JCfecpZa2H/RBjgxabR6+PnDlj1VjVN+V/hisUtI0K0D+aTbvQQGblJYSyAjyLKSe2VApw= X-Received: by 2002:a19:11d1:: with SMTP id 78-v6mr19761257lfr.25.1536056115158; Tue, 04 Sep 2018 03:15:15 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:db4b:0:0:0:0:0 with HTTP; Tue, 4 Sep 2018 03:15:14 -0700 (PDT) Reply-To: araujo@freebsd.org In-Reply-To: <20180904100934.GC27236@rincewind.trouble.is> References: <201809040953.w849rj4j082295@repo.freebsd.org> <20180904100934.GC27236@rincewind.trouble.is> From: Marcelo Araujo Date: Tue, 4 Sep 2018 18:15:14 +0800 Message-ID: Subject: Re: svn commit: r338451 - stable/11/usr.bin/last To: Marcelo Araujo , src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.27 X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2018 10:15:17 -0000 2018-09-04 18:09 GMT+08:00 Philip Paeps : > On 2018-09-04 17:59:30 (+0800), Marcelo Araujo wrote: > >> 2018-09-04 17:53 GMT+08:00 Philip Paeps : >> >> Author: philip >>> Date: Tue Sep 4 09:53:45 2018 >>> New Revision: 338451 >>> URL: https://svnweb.freebsd.org/changeset/base/338451 >>> >>> Log: >>> MFC r319508: >>> Fix a memory leak with last >>> free memory allocated to 'buf' >>> >> >> Is that the right patch? Or the commit message missed adding support to >> libxo(3)? >> > > I merged two changes: > > * r319508 plugs a memory leak. This was originally committed by stevek in > June 2017 but apparently never MFCed. > > * rr338352 adds libxo support. > > I mentioned both changes in the commit message. I'm not sure what's > unclear. > Ops, my bad! I just read the first MFC! Sorry for the noise! > > Philip > > -- > Philip Paeps > Senior Reality Engineer > Ministry of Information > -- -- Marcelo Araujo (__)araujo@FreeBSD.org \\\'',)http://www.FreeBSD.org \/ \ ^ Power To Server. .\. /_) From owner-svn-src-stable@freebsd.org Tue Sep 4 16:45:09 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6ABF8FF4B83; Tue, 4 Sep 2018 16:45:09 +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 15AE876A1A; Tue, 4 Sep 2018 16:45:09 +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 0AB2919A47; Tue, 4 Sep 2018 16:45:09 +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 w84Gj8CG093483; Tue, 4 Sep 2018 16:45:08 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w84Gj88I093482; Tue, 4 Sep 2018 16:45:08 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201809041645.w84Gj88I093482@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Sep 2018 16:45:08 +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: r338455 - stable/11/usr.sbin/nfsuserd X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/usr.sbin/nfsuserd X-SVN-Commit-Revision: 338455 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2018 16:45:09 -0000 Author: markj Date: Tue Sep 4 16:45:08 2018 New Revision: 338455 URL: https://svnweb.freebsd.org/changeset/base/338455 Log: MFC r338350: Add missing endpwent() and endgrent() calls to nfsuserd(8). PR: 230937 Modified: stable/11/usr.sbin/nfsuserd/nfsuserd.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/nfsuserd/nfsuserd.c ============================================================================== --- stable/11/usr.sbin/nfsuserd/nfsuserd.c Tue Sep 4 15:48:13 2018 (r338454) +++ stable/11/usr.sbin/nfsuserd/nfsuserd.c Tue Sep 4 16:45:08 2018 (r338455) @@ -334,6 +334,7 @@ main(int argc, char *argv[]) #endif i++; } + endgrent(); /* * Loop around adding all users. @@ -382,6 +383,7 @@ main(int argc, char *argv[]) #endif i++; } + endpwent(); /* * I should feel guilty for not calling this for all the above exit() From owner-svn-src-stable@freebsd.org Tue Sep 4 16:47:10 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D2B79FF4C75; Tue, 4 Sep 2018 16:47:10 +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 3066976C76; Tue, 4 Sep 2018 16:47:08 +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 A0E3919A4B; Tue, 4 Sep 2018 16:47:08 +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 w84Gl8ES093752; Tue, 4 Sep 2018 16:47:08 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w84Gl8MI093751; Tue, 4 Sep 2018 16:47:08 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201809041647.w84Gl8MI093751@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 4 Sep 2018 16:47:08 +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: r338456 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 338456 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2018 16:47:11 -0000 Author: markj Date: Tue Sep 4 16:47:08 2018 New Revision: 338456 URL: https://svnweb.freebsd.org/changeset/base/338456 Log: MFC r338416: Re-compute the ARC size before computing the MFU target. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Tue Sep 4 16:45:08 2018 (r338455) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c Tue Sep 4 16:47:08 2018 (r338456) @@ -4119,6 +4119,12 @@ arc_adjust(void) } /* + * Re-sum ARC stats after the first round of evictions. + */ + asize = aggsum_value(&arc_size); + ameta = aggsum_value(&arc_meta_used); + + /* * Adjust MFU size * * Now that we've tried to evict enough from the MRU to get its From owner-svn-src-stable@freebsd.org Tue Sep 4 16:50:13 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 57656FF4E88; Tue, 4 Sep 2018 16:50:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 03E4076EE5; Tue, 4 Sep 2018 16:50:13 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-2.local (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id 62EFA10B476; Tue, 4 Sep 2018 12:50:11 -0400 (EDT) Subject: Re: svn commit: r338451 - stable/11/usr.bin/last To: araujo@freebsd.org, src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org References: <201809040953.w849rj4j082295@repo.freebsd.org> <20180904100934.GC27236@rincewind.trouble.is> From: John Baldwin Message-ID: <3781df8e-57a0-feb8-9c6a-83a3a760e0d3@FreeBSD.org> Date: Tue, 4 Sep 2018 09:39:40 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180904100934.GC27236@rincewind.trouble.is> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Tue, 04 Sep 2018 12:50:12 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2018 16:50:13 -0000 On 9/4/18 3:09 AM, Philip Paeps wrote: > On 2018-09-04 17:59:30 (+0800), Marcelo Araujo wrote: >> 2018-09-04 17:53 GMT+08:00 Philip Paeps : >> >>> Author: philip >>> Date: Tue Sep 4 09:53:45 2018 >>> New Revision: 338451 >>> URL: https://svnweb.freebsd.org/changeset/base/338451 >>> >>> Log: >>> MFC r319508: >>> Fix a memory leak with last >>> free memory allocated to 'buf' >> >> Is that the right patch? Or the commit message missed adding support to >> libxo(3)? > > I merged two changes: > > * r319508 plugs a memory leak. This was originally committed by stevek > in June 2017 but apparently never MFCed. > > * rr338352 adds libxo support. > > I mentioned both changes in the commit message. I'm not sure what's > unclear. Most MFC commits list a summary of merged changes first (and perhaps a brief summary of the effective MFC if it is using several commits from HEAD to merge a single feature) before including logs from individual changes. This ensures that the first line of a commit is still a useful overall summary of the entire change. -- John Baldwin                                                                              From owner-svn-src-stable@freebsd.org Wed Sep 5 00:30:36 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6B371FCF116; Wed, 5 Sep 2018 00:30:36 +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 2154388817; Wed, 5 Sep 2018 00:30:36 +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 1BD071E69E; Wed, 5 Sep 2018 00:30:36 +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 w850UZ0m031646; Wed, 5 Sep 2018 00:30:35 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w850UZaF031642; Wed, 5 Sep 2018 00:30:35 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201809050030.w850UZaF031642@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 5 Sep 2018 00:30:35 +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: r338462 - in stable/11: sys/kern usr.bin/sed usr.bin/sed/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/11: sys/kern usr.bin/sed usr.bin/sed/tests X-SVN-Commit-Revision: 338462 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 00:30:36 -0000 Author: markj Date: Wed Sep 5 00:30:34 2018 New Revision: 338462 URL: https://svnweb.freebsd.org/changeset/base/338462 Log: MFC r338375: sed: Fix -i option behavior with 'q' command. PR: 230507 Modified: stable/11/sys/kern/imgact_elf.c stable/11/usr.bin/sed/extern.h stable/11/usr.bin/sed/main.c stable/11/usr.bin/sed/process.c stable/11/usr.bin/sed/tests/sed2_test.sh Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/imgact_elf.c ============================================================================== --- stable/11/sys/kern/imgact_elf.c Tue Sep 4 19:28:46 2018 (r338461) +++ stable/11/sys/kern/imgact_elf.c Wed Sep 5 00:30:34 2018 (r338462) @@ -839,7 +839,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i break; case PT_INTERP: /* Path to interpreter */ - if (phdr[i].p_filesz > MAXPATHLEN) { + if (phdr[i].p_filesz < 2 || + phdr[i].p_filesz > MAXPATHLEN) { uprintf("Invalid PT_INTERP\n"); error = ENOEXEC; goto ret; @@ -870,6 +871,11 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i } else { interp = __DECONST(char *, imgp->image_header) + phdr[i].p_offset; + if (interp[interp_name_len - 1] != '\0') { + uprintf("Invalid PT_INTERP\n"); + error = ENOEXEC; + goto ret; + } } break; case PT_GNU_STACK: Modified: stable/11/usr.bin/sed/extern.h ============================================================================== --- stable/11/usr.bin/sed/extern.h Tue Sep 4 19:28:46 2018 (r338461) +++ stable/11/usr.bin/sed/extern.h Wed Sep 5 00:30:34 2018 (r338462) @@ -44,6 +44,8 @@ extern int aflag, eflag, nflag; extern const char *fname, *outfname; extern FILE *infile, *outfile; extern int rflags; /* regex flags to use */ +extern const char *inplace; +extern int quit; void cfclose(struct s_command *, struct s_command *); void compile(void); Modified: stable/11/usr.bin/sed/main.c ============================================================================== --- stable/11/usr.bin/sed/main.c Tue Sep 4 19:28:46 2018 (r338461) +++ stable/11/usr.bin/sed/main.c Wed Sep 5 00:30:34 2018 (r338462) @@ -101,6 +101,7 @@ FILE *outfile; /* Current output file */ int aflag, eflag, nflag; int rflags = 0; +int quit = 0; static int rval; /* Exit status */ static int ispan; /* Whether inplace editing spans across files */ @@ -114,7 +115,7 @@ const char *fname; /* File name. */ const char *outfname; /* Output file name */ static char oldfname[PATH_MAX]; /* Old file name (for in-place editing) */ static char tmpfname[PATH_MAX]; /* Temporary file name (for in-place editing) */ -static const char *inplace; /* Inplace edit file extension. */ +const char *inplace; /* Inplace edit file extension. */ u_long linenum; static void add_compunit(enum e_cut, char *); @@ -334,7 +335,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) } for (;;) { - if (infile != NULL && (c = getc(infile)) != EOF) { + if (infile != NULL && (c = getc(infile)) != EOF && !quit) { (void)ungetc(c, infile); break; } Modified: stable/11/usr.bin/sed/process.c ============================================================================== --- stable/11/usr.bin/sed/process.c Tue Sep 4 19:28:46 2018 (r338461) +++ stable/11/usr.bin/sed/process.c Wed Sep 5 00:30:34 2018 (r338462) @@ -207,10 +207,14 @@ redirect: } break; case 'q': - if (!nflag && !pd) - OUT(); - flush_appends(); - exit(0); + if (inplace == NULL) { + if (!nflag && !pd) + OUT(); + flush_appends(); + exit(0); + } + quit = 1; + break; case 'r': if (appendx >= appendnum) if ((appends = realloc(appends, Modified: stable/11/usr.bin/sed/tests/sed2_test.sh ============================================================================== --- stable/11/usr.bin/sed/tests/sed2_test.sh Tue Sep 4 19:28:46 2018 (r338461) +++ stable/11/usr.bin/sed/tests/sed2_test.sh Wed Sep 5 00:30:34 2018 (r338462) @@ -38,6 +38,7 @@ inplace_hardlink_src_body() atf_check ln a b atf_check sed -i '' -e 's,foo,bar,g' b atf_check -o 'inline:bar\n' -s exit:0 cat b + atf_check -s not-exit:0 stat -q '.!'* } atf_test_case inplace_symlink_src @@ -50,10 +51,27 @@ inplace_symlink_src_body() echo foo > a atf_check ln -s a b atf_check -e not-empty -s not-exit:0 sed -i '' -e 's,foo,bar,g' b + atf_check -s not-exit:0 stat -q '.!'* } +atf_test_case inplace_command_q +inplace_command_q_head() +{ + atf_set "descr" "Verify -i works correctly with the 'q' command" +} +inplace_command_q_body() +{ + printf '1\n2\n3\n' > a + atf_check -o 'inline:1\n2\n' sed '2q' a + atf_check sed -i.bak '2q' a + atf_check -o 'inline:1\n2\n' cat a + atf_check -o 'inline:1\n2\n3\n' cat a.bak + atf_check -s not-exit:0 stat -q '.!'* +} + atf_init_test_cases() { + atf_add_test_case inplace_command_q atf_add_test_case inplace_hardlink_src atf_add_test_case inplace_symlink_src } From owner-svn-src-stable@freebsd.org Wed Sep 5 01:24:14 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5348FFD4B37; Wed, 5 Sep 2018 01:24:14 +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 E9E6D8A4F8; Wed, 5 Sep 2018 01:24:13 +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 E02F41F05A; Wed, 5 Sep 2018 01:24:13 +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 w851OD2J061900; Wed, 5 Sep 2018 01:24:13 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w851ODb8061899; Wed, 5 Sep 2018 01:24:13 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201809050124.w851ODb8061899@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 5 Sep 2018 01:24: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: r338463 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 338463 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 01:24:14 -0000 Author: markj Date: Wed Sep 5 01:24:13 2018 New Revision: 338463 URL: https://svnweb.freebsd.org/changeset/base/338463 Log: MFC r337974: Add INVARIANTS-only fences around lockless vnode refcount updates. Modified: stable/11/sys/kern/vfs_subr.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/vfs_subr.c ============================================================================== --- stable/11/sys/kern/vfs_subr.c Wed Sep 5 00:30:34 2018 (r338462) +++ stable/11/sys/kern/vfs_subr.c Wed Sep 5 01:24:13 2018 (r338463) @@ -116,6 +116,22 @@ static void vfs_knl_assert_unlocked(void *arg); static void destroy_vpollinfo(struct vpollinfo *vi); /* + * These fences are intended for cases where some synchronization is + * needed between access of v_iflags and lockless vnode refcount (v_holdcnt + * and v_usecount) updates. Access to v_iflags is generally synchronized + * by the interlock, but we have some internal assertions that check vnode + * flags * without acquiring the lock. Thus, these fences are INVARIANTS-only + * for now. + */ +#ifdef INVARIANTS +#define VNODE_REFCOUNT_FENCE_ACQ() atomic_thread_fence_acq() +#define VNODE_REFCOUNT_FENCE_REL() atomic_thread_fence_rel() +#else +#define VNODE_REFCOUNT_FENCE_ACQ() +#define VNODE_REFCOUNT_FENCE_REL() +#endif + +/* * Number of vnodes in existence. Increased whenever getnewvnode() * allocates a new vnode, decreased in vdropl() for VI_DOOMED vnode. */ @@ -1006,6 +1022,7 @@ vnlru_free_locked(int count, struct vfsops *mnt_op) */ freevnodes--; vp->v_iflag &= ~VI_FREE; + VNODE_REFCOUNT_FENCE_REL(); refcount_acquire(&vp->v_holdcnt); mtx_unlock(&vnode_free_list_mtx); @@ -2429,6 +2446,7 @@ v_incr_usecount(struct vnode *vp) if (vp->v_type != VCHR && refcount_acquire_if_not_zero(&vp->v_usecount)) { + VNODE_REFCOUNT_FENCE_ACQ(); VNASSERT((vp->v_iflag & VI_OWEINACT) == 0, vp, ("vnode with usecount and VI_OWEINACT set")); } else { @@ -2527,6 +2545,7 @@ vget(struct vnode *vp, int flags, struct thread *td) } else { oweinact = 1; vp->v_iflag &= ~VI_OWEINACT; + VNODE_REFCOUNT_FENCE_REL(); } refcount_acquire(&vp->v_usecount); v_incr_devcount(vp); @@ -2740,6 +2759,7 @@ _vhold(struct vnode *vp, bool locked) CTR2(KTR_VFS, "%s: vp %p", __func__, vp); if (!locked) { if (refcount_acquire_if_not_zero(&vp->v_holdcnt)) { + VNODE_REFCOUNT_FENCE_ACQ(); VNASSERT((vp->v_iflag & VI_FREE) == 0, vp, ("_vhold: vnode with holdcnt is free")); return; From owner-svn-src-stable@freebsd.org Wed Sep 5 01:33:31 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2DAA8FD513E; Wed, 5 Sep 2018 01:33:31 +0000 (UTC) (envelope-from cy@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 D6AAC8AACE; Wed, 5 Sep 2018 01:33:30 +0000 (UTC) (envelope-from cy@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 D19AA1F1F2; Wed, 5 Sep 2018 01:33:30 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w851XUMm067124; Wed, 5 Sep 2018 01:33:30 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w851XUZh067123; Wed, 5 Sep 2018 01:33:30 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201809050133.w851XUZh067123@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Wed, 5 Sep 2018 01:33:30 +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: r338464 - in stable: 10/crypto/heimdal/doc/doxyout/krb5/man/man3 11/crypto/heimdal/doc/doxyout/krb5/man/man3 X-SVN-Group: stable-11 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 10/crypto/heimdal/doc/doxyout/krb5/man/man3 11/crypto/heimdal/doc/doxyout/krb5/man/man3 X-SVN-Commit-Revision: 338464 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 01:33:31 -0000 Author: cy Date: Wed Sep 5 01:33:30 2018 New Revision: 338464 URL: https://svnweb.freebsd.org/changeset/base/338464 Log: Avoid printing extraneous function names when searching man page database (apropos, man -k). This commit Replaces .SS with .SH, similar to the man page provided by original heimdal (as in port). PR: 230573 Submitted by: yuripv@yuripv.net Modified: stable/11/crypto/heimdal/doc/doxyout/krb5/man/man3/krb5.3 Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/crypto/heimdal/doc/doxyout/krb5/man/man3/krb5.3 Directory Properties: stable/10/ (props changed) Modified: stable/11/crypto/heimdal/doc/doxyout/krb5/man/man3/krb5.3 ============================================================================== --- stable/11/crypto/heimdal/doc/doxyout/krb5/man/man3/krb5.3 Wed Sep 5 01:24:13 2018 (r338463) +++ stable/11/crypto/heimdal/doc/doxyout/krb5/man/man3/krb5.3 Wed Sep 5 01:33:30 2018 (r338464) @@ -2,9 +2,8 @@ .ad l .nh .SH NAME -Heimdal Kerberos 5 library \- -.SS "Functions" - +krb5 \- Heimdal Kerberos 5 library +.SH SYNOPSIS .in +1c .ti -1c .RI "KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL \fBkrb5_add_et_list\fP (krb5_context context, void(*func)(struct et_list **))" From owner-svn-src-stable@freebsd.org Wed Sep 5 01:33:31 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 82328FD514A; Wed, 5 Sep 2018 01:33:31 +0000 (UTC) (envelope-from cy@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 369438AAD0; Wed, 5 Sep 2018 01:33:31 +0000 (UTC) (envelope-from cy@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 318F21F1F3; Wed, 5 Sep 2018 01:33:31 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w851XV3L067130; Wed, 5 Sep 2018 01:33:31 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w851XVTD067129; Wed, 5 Sep 2018 01:33:31 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201809050133.w851XVTD067129@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Wed, 5 Sep 2018 01:33:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r338464 - in stable: 10/crypto/heimdal/doc/doxyout/krb5/man/man3 11/crypto/heimdal/doc/doxyout/krb5/man/man3 X-SVN-Group: stable-10 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 10/crypto/heimdal/doc/doxyout/krb5/man/man3 11/crypto/heimdal/doc/doxyout/krb5/man/man3 X-SVN-Commit-Revision: 338464 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 01:33:31 -0000 Author: cy Date: Wed Sep 5 01:33:30 2018 New Revision: 338464 URL: https://svnweb.freebsd.org/changeset/base/338464 Log: Avoid printing extraneous function names when searching man page database (apropos, man -k). This commit Replaces .SS with .SH, similar to the man page provided by original heimdal (as in port). PR: 230573 Submitted by: yuripv@yuripv.net Modified: stable/10/crypto/heimdal/doc/doxyout/krb5/man/man3/krb5.3 Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/crypto/heimdal/doc/doxyout/krb5/man/man3/krb5.3 Directory Properties: stable/11/ (props changed) Modified: stable/10/crypto/heimdal/doc/doxyout/krb5/man/man3/krb5.3 ============================================================================== --- stable/10/crypto/heimdal/doc/doxyout/krb5/man/man3/krb5.3 Wed Sep 5 01:24:13 2018 (r338463) +++ stable/10/crypto/heimdal/doc/doxyout/krb5/man/man3/krb5.3 Wed Sep 5 01:33:30 2018 (r338464) @@ -2,9 +2,8 @@ .ad l .nh .SH NAME -Heimdal Kerberos 5 library \- -.SS "Functions" - +krb5 \- Heimdal Kerberos 5 library +.SH SYNOPSIS .in +1c .ti -1c .RI "KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL \fBkrb5_add_et_list\fP (krb5_context context, void(*func)(struct et_list **))" From owner-svn-src-stable@freebsd.org Wed Sep 5 12:06:24 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8C995FEE384; Wed, 5 Sep 2018 12:06:24 +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 171D97E33A; Wed, 5 Sep 2018 12:06:23 +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 w85C66TO025934 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 5 Sep 2018 15:06:09 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w85C66TO025934 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w85C66Sd025933; Wed, 5 Sep 2018 15:06:06 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 5 Sep 2018 15:06:06 +0300 From: Konstantin Belousov To: Mark Johnston Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: Re: svn commit: r338462 - in stable/11: sys/kern usr.bin/sed usr.bin/sed/tests Message-ID: <20180905120606.GA3161@kib.kiev.ua> References: <201809050030.w850UZaF031642@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201809050030.w850UZaF031642@repo.freebsd.org> User-Agent: Mutt/1.10.1 (2018-07-13) 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-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 12:06:24 -0000 On Wed, Sep 05, 2018 at 12:30:35AM +0000, Mark Johnston wrote: > Author: markj > Date: Wed Sep 5 00:30:34 2018 > New Revision: 338462 > URL: https://svnweb.freebsd.org/changeset/base/338462 > > Log: > MFC r338375: > sed: Fix -i option behavior with 'q' command. > > PR: 230507 > > Modified: > stable/11/sys/kern/imgact_elf.c ^^^^ This part is not relevant. > stable/11/usr.bin/sed/extern.h > stable/11/usr.bin/sed/main.c > stable/11/usr.bin/sed/process.c > stable/11/usr.bin/sed/tests/sed2_test.sh > Directory Properties: > stable/11/ (props changed) > > Modified: stable/11/sys/kern/imgact_elf.c > ============================================================================== > --- stable/11/sys/kern/imgact_elf.c Tue Sep 4 19:28:46 2018 (r338461) > +++ stable/11/sys/kern/imgact_elf.c Wed Sep 5 00:30:34 2018 (r338462) > @@ -839,7 +839,8 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i > break; > case PT_INTERP: > /* Path to interpreter */ > - if (phdr[i].p_filesz > MAXPATHLEN) { > + if (phdr[i].p_filesz < 2 || > + phdr[i].p_filesz > MAXPATHLEN) { > uprintf("Invalid PT_INTERP\n"); > error = ENOEXEC; > goto ret; > @@ -870,6 +871,11 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i > } else { > interp = __DECONST(char *, imgp->image_header) + > phdr[i].p_offset; > + if (interp[interp_name_len - 1] != '\0') { > + uprintf("Invalid PT_INTERP\n"); > + error = ENOEXEC; > + goto ret; > + } > } > break; > case PT_GNU_STACK: > > Modified: stable/11/usr.bin/sed/extern.h > ============================================================================== > --- stable/11/usr.bin/sed/extern.h Tue Sep 4 19:28:46 2018 (r338461) > +++ stable/11/usr.bin/sed/extern.h Wed Sep 5 00:30:34 2018 (r338462) > @@ -44,6 +44,8 @@ extern int aflag, eflag, nflag; > extern const char *fname, *outfname; > extern FILE *infile, *outfile; > extern int rflags; /* regex flags to use */ > +extern const char *inplace; > +extern int quit; > > void cfclose(struct s_command *, struct s_command *); > void compile(void); > > Modified: stable/11/usr.bin/sed/main.c > ============================================================================== > --- stable/11/usr.bin/sed/main.c Tue Sep 4 19:28:46 2018 (r338461) > +++ stable/11/usr.bin/sed/main.c Wed Sep 5 00:30:34 2018 (r338462) > @@ -101,6 +101,7 @@ FILE *outfile; /* Current output file */ > > int aflag, eflag, nflag; > int rflags = 0; > +int quit = 0; > static int rval; /* Exit status */ > > static int ispan; /* Whether inplace editing spans across files */ > @@ -114,7 +115,7 @@ const char *fname; /* File name. */ > const char *outfname; /* Output file name */ > static char oldfname[PATH_MAX]; /* Old file name (for in-place editing) */ > static char tmpfname[PATH_MAX]; /* Temporary file name (for in-place editing) */ > -static const char *inplace; /* Inplace edit file extension. */ > +const char *inplace; /* Inplace edit file extension. */ > u_long linenum; > > static void add_compunit(enum e_cut, char *); > @@ -334,7 +335,7 @@ mf_fgets(SPACE *sp, enum e_spflag spflag) > } > > for (;;) { > - if (infile != NULL && (c = getc(infile)) != EOF) { > + if (infile != NULL && (c = getc(infile)) != EOF && !quit) { > (void)ungetc(c, infile); > break; > } > > Modified: stable/11/usr.bin/sed/process.c > ============================================================================== > --- stable/11/usr.bin/sed/process.c Tue Sep 4 19:28:46 2018 (r338461) > +++ stable/11/usr.bin/sed/process.c Wed Sep 5 00:30:34 2018 (r338462) > @@ -207,10 +207,14 @@ redirect: > } > break; > case 'q': > - if (!nflag && !pd) > - OUT(); > - flush_appends(); > - exit(0); > + if (inplace == NULL) { > + if (!nflag && !pd) > + OUT(); > + flush_appends(); > + exit(0); > + } > + quit = 1; > + break; > case 'r': > if (appendx >= appendnum) > if ((appends = realloc(appends, > > Modified: stable/11/usr.bin/sed/tests/sed2_test.sh > ============================================================================== > --- stable/11/usr.bin/sed/tests/sed2_test.sh Tue Sep 4 19:28:46 2018 (r338461) > +++ stable/11/usr.bin/sed/tests/sed2_test.sh Wed Sep 5 00:30:34 2018 (r338462) > @@ -38,6 +38,7 @@ inplace_hardlink_src_body() > atf_check ln a b > atf_check sed -i '' -e 's,foo,bar,g' b > atf_check -o 'inline:bar\n' -s exit:0 cat b > + atf_check -s not-exit:0 stat -q '.!'* > } > > atf_test_case inplace_symlink_src > @@ -50,10 +51,27 @@ inplace_symlink_src_body() > echo foo > a > atf_check ln -s a b > atf_check -e not-empty -s not-exit:0 sed -i '' -e 's,foo,bar,g' b > + atf_check -s not-exit:0 stat -q '.!'* > } > > +atf_test_case inplace_command_q > +inplace_command_q_head() > +{ > + atf_set "descr" "Verify -i works correctly with the 'q' command" > +} > +inplace_command_q_body() > +{ > + printf '1\n2\n3\n' > a > + atf_check -o 'inline:1\n2\n' sed '2q' a > + atf_check sed -i.bak '2q' a > + atf_check -o 'inline:1\n2\n' cat a > + atf_check -o 'inline:1\n2\n3\n' cat a.bak > + atf_check -s not-exit:0 stat -q '.!'* > +} > + > atf_init_test_cases() > { > + atf_add_test_case inplace_command_q > atf_add_test_case inplace_hardlink_src > atf_add_test_case inplace_symlink_src > } From owner-svn-src-stable@freebsd.org Wed Sep 5 14:49:27 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7DD36FF26F8; Wed, 5 Sep 2018 14:49:27 +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 319DA84218; Wed, 5 Sep 2018 14:49:27 +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 2C7B62737A; Wed, 5 Sep 2018 14:49:27 +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 w85EnRf7074161; Wed, 5 Sep 2018 14:49:27 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w85EnRNv074160; Wed, 5 Sep 2018 14:49:27 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201809051449.w85EnRNv074160@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 5 Sep 2018 14:49: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: r338469 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 338469 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 14:49:27 -0000 Author: markj Date: Wed Sep 5 14:49:26 2018 New Revision: 338469 URL: https://svnweb.freebsd.org/changeset/base/338469 Log: Revert an unintentional change from r338462. Reported by: kib Modified: stable/11/sys/kern/imgact_elf.c Modified: stable/11/sys/kern/imgact_elf.c ============================================================================== --- stable/11/sys/kern/imgact_elf.c Wed Sep 5 13:59:36 2018 (r338468) +++ stable/11/sys/kern/imgact_elf.c Wed Sep 5 14:49:26 2018 (r338469) @@ -839,8 +839,7 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i break; case PT_INTERP: /* Path to interpreter */ - if (phdr[i].p_filesz < 2 || - phdr[i].p_filesz > MAXPATHLEN) { + if (phdr[i].p_filesz > MAXPATHLEN) { uprintf("Invalid PT_INTERP\n"); error = ENOEXEC; goto ret; @@ -871,11 +870,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i } else { interp = __DECONST(char *, imgp->image_header) + phdr[i].p_offset; - if (interp[interp_name_len - 1] != '\0') { - uprintf("Invalid PT_INTERP\n"); - error = ENOEXEC; - goto ret; - } } break; case PT_GNU_STACK: From owner-svn-src-stable@freebsd.org Wed Sep 5 20:13:29 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F4C2FFBBEA; Wed, 5 Sep 2018 20:13:29 +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 1B4F5716A1; Wed, 5 Sep 2018 20:13:29 +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 138402A85A; Wed, 5 Sep 2018 20:13:29 +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 w85KDSLb043450; Wed, 5 Sep 2018 20:13:28 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w85KDSDr043449; Wed, 5 Sep 2018 20:13:28 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201809052013.w85KDSDr043449@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Wed, 5 Sep 2018 20:13:28 +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: r338475 - in stable/11: contrib/traceroute usr.sbin/traceroute X-SVN-Group: stable-11 X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: in stable/11: contrib/traceroute usr.sbin/traceroute X-SVN-Commit-Revision: 338475 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 20:13:29 -0000 Author: oshogbo Date: Wed Sep 5 20:13:28 2018 New Revision: 338475 URL: https://svnweb.freebsd.org/changeset/base/338475 Log: MFC r314000: Capsicumize traceroute. PR: 193973 Submitted by: Mikhail Reviewed by: pjd, bapt, emaste, AllanJude Differential Revision: https://reviews.freebsd.org/D9303 Modified: stable/11/contrib/traceroute/traceroute.c stable/11/usr.sbin/traceroute/Makefile Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/traceroute/traceroute.c ============================================================================== --- stable/11/contrib/traceroute/traceroute.c Wed Sep 5 20:02:23 2018 (r338474) +++ stable/11/contrib/traceroute/traceroute.c Wed Sep 5 20:13:28 2018 (r338475) @@ -203,6 +203,7 @@ static const char rcsid[] = */ #include +#include #include #include #ifdef HAVE_SYS_SELECT_H @@ -227,6 +228,11 @@ static const char rcsid[] = #include +#ifdef HAVE_LIBCASPER +#include +#include +#endif + #ifdef IPSEC #include #include /* XXX */ @@ -363,6 +369,10 @@ extern int optind; extern int opterr; extern char *optarg; +#ifdef HAVE_LIBCASPER +static cap_channel_t *capdns; +#endif + /* Forwards */ double deltaT(struct timeval *, struct timeval *); void freehostinfo(struct hostinfo *); @@ -511,6 +521,13 @@ main(int argc, char **argv) int requestPort = -1; int sump = 0; int sockerrno; +#ifdef HAVE_LIBCASPER + const char *types[] = { "NAME", "ADDR" }; + int families[1]; + cap_channel_t *casper; +#endif + cap_rights_t rights; + bool cansandbox; /* Insure the socket fds won't be 0, 1 or 2 */ if (open(devnull, O_RDONLY) < 0 || @@ -539,6 +556,20 @@ main(int argc, char **argv) exit(1); } +#ifdef HAVE_LIBCASPER + casper = cap_init(); + if (casper == NULL) + errx(1, "unable to create casper process"); + capdns = cap_service_open(casper, "system.dns"); + if (capdns == NULL) + errx(1, "unable to open system.dns service"); + if (cap_dns_type_limit(capdns, types, 2) < 0) + errx(1, "unable to limit access to system.dns service"); + families[0] = AF_INET; + if (cap_dns_family_limit(capdns, families, 1) < 0) + errx(1, "unable to limit access to system.dns service"); +#endif /* HAVE_LIBCASPER */ + #ifdef IPCTL_DEFTTL { int mib[4] = { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_DEFTTL }; @@ -549,10 +580,14 @@ main(int argc, char **argv) exit(1); } } -#else +#else /* !IPCTL_DEFTTL */ max_ttl = 30; #endif +#ifdef HAVE_LIBCASPER + cap_close(casper); +#endif + if (argv[0] == NULL) prog = "traceroute"; else if ((cp = strrchr(argv[0], '/')) != NULL) @@ -965,6 +1000,45 @@ main(int argc, char **argv) } } + if (connect(sndsock, (struct sockaddr *)&whereto, + sizeof(whereto)) != 0) { + Fprintf(stderr, "%s: connect: %s\n", prog, strerror(errno)); + exit(1); + } + +#ifdef HAVE_LIBCASPER + cansandbox = true; +#else + if (nflag) + cansandbox = true; + else + cansandbox = false; +#endif + + /* + * Here we enter capability mode. Further down access to global + * namespaces (e.g filesystem) is restricted (see capsicum(4)). + * We must connect(2) our socket before this point. + */ + if (cansandbox && cap_enter() < 0) { + Fprintf(stderr, "%s: cap_enter: %s\n", prog, strerror(errno)); + exit(1); + } + + cap_rights_init(&rights, CAP_SEND, CAP_SETSOCKOPT); + if (cansandbox && cap_rights_limit(sndsock, &rights) < 0) { + Fprintf(stderr, "%s: cap_rights_limit sndsock: %s\n", prog, + strerror(errno)); + exit(1); + } + + cap_rights_init(&rights, CAP_RECV, CAP_EVENT); + if (cansandbox && cap_rights_limit(s, &rights) < 0) { + Fprintf(stderr, "%s: cap_rights_limit s: %s\n", prog, + strerror(errno)); + exit(1); + } + #if defined(IPSEC) && defined(IPSEC_POLICY_IPSEC) if (setpolicy(sndsock, "in bypass") < 0) errx(1, "%s", ipsec_strerror()); @@ -1252,8 +1326,7 @@ send_probe(int seq, int ttl) } #endif - cc = sendto(sndsock, (char *)outip, - packlen, 0, &whereto, sizeof(whereto)); + cc = send(sndsock, (char *)outip, packlen, 0); if (cc < 0 || cc != packlen) { if (cc < 0) Fprintf(stderr, "%s: sendto: %s\n", @@ -1826,7 +1899,12 @@ inetname(struct in_addr in) else { cp = strchr(domain, '.'); if (cp == NULL) { - hp = gethostbyname(domain); +#ifdef HAVE_LIBCASPER + if (capdns != NULL) + hp = cap_gethostbyname(capdns, domain); + else +#endif + hp = gethostbyname(domain); if (hp != NULL) cp = strchr(hp->h_name, '.'); } @@ -1840,7 +1918,13 @@ inetname(struct in_addr in) } } if (!nflag && in.s_addr != INADDR_ANY) { - hp = gethostbyaddr((char *)&in, sizeof(in), AF_INET); +#ifdef HAVE_LIBCASPER + if (capdns != NULL) + hp = cap_gethostbyaddr(capdns, (char *)&in, sizeof(in), + AF_INET); + else +#endif + hp = gethostbyaddr((char *)&in, sizeof(in), AF_INET); if (hp != NULL) { if ((cp = strchr(hp->h_name, '.')) != NULL && strcmp(cp + 1, domain) == 0) @@ -1886,7 +1970,12 @@ gethostinfo(register char *hostname) return (hi); } - hp = gethostbyname(hostname); +#ifdef HAVE_LIBCASPER + if (capdns != NULL) + hp = cap_gethostbyname(capdns, hostname); + else +#endif + hp = gethostbyname(hostname); if (hp == NULL) { Fprintf(stderr, "%s: unknown host %s\n", prog, hostname); exit(1); Modified: stable/11/usr.sbin/traceroute/Makefile ============================================================================== --- stable/11/usr.sbin/traceroute/Makefile Wed Sep 5 20:02:23 2018 (r338474) +++ stable/11/usr.sbin/traceroute/Makefile Wed Sep 5 20:13:28 2018 (r338475) @@ -1,5 +1,7 @@ # $FreeBSD$ +.include + TRACEROUTE_DISTDIR?= ${SRCTOP}/contrib/traceroute .PATH: ${TRACEROUTE_DISTDIR} @@ -26,6 +28,12 @@ CFLAGS+= -DIPSEC .if !defined(TRACEROUTE_NO_IPSEC) LIBADD+= ipsec +.endif + +.if ${MK_CASPER} != "no" +LIBADD+= casper +LIBADD+= cap_dns +CFLAGS+=-DHAVE_LIBCASPER .endif CFLAGS+= -I${TRACEROUTE_DISTDIR} From owner-svn-src-stable@freebsd.org Wed Sep 5 20:43:47 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9FC0EFFC5D8; Wed, 5 Sep 2018 20:43:47 +0000 (UTC) (envelope-from marius@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 4D34972503; Wed, 5 Sep 2018 20:43:47 +0000 (UTC) (envelope-from marius@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 450072AD26; Wed, 5 Sep 2018 20:43:47 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w85Khlac058886; Wed, 5 Sep 2018 20:43:47 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w85KhlIO058885; Wed, 5 Sep 2018 20:43:47 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201809052043.w85KhlIO058885@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Wed, 5 Sep 2018 20:43:47 +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: r338476 - stable/11/sys/dev/mmc X-SVN-Group: stable-11 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/11/sys/dev/mmc X-SVN-Commit-Revision: 338476 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 20:43:47 -0000 Author: marius Date: Wed Sep 5 20:43:46 2018 New Revision: 338476 URL: https://svnweb.freebsd.org/changeset/base/338476 Log: MFC: r338304 The read accessors generated by __BUS_ACCESSOR() have the problem that they don't check the result of BUS_READ_IVAR(9) and silently return stack garbage on failure in case a bus doesn't implement a particular instance variable for example. With MMC bridges not providing MMCBR_IVAR_RETUNE_REQ, yet, this in turn can cause mmc(4) to get into a state in which re-tuning seems to be necessary but is inappropriate, causing mmc_wait_for_request() to fail. Thus, don't use __BUS_ACCESSOR() for mmcbr_get_retune_req() and instead provide a version of the latter which returns retune_req_none if reading MMCBR_IVAR_RETUNE_REQ fails. Modified: stable/11/sys/dev/mmc/mmcbrvar.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/mmc/mmcbrvar.h ============================================================================== --- stable/11/sys/dev/mmc/mmcbrvar.h Wed Sep 5 20:13:28 2018 (r338475) +++ stable/11/sys/dev/mmc/mmcbrvar.h Wed Sep 5 20:43:46 2018 (r338476) @@ -95,7 +95,6 @@ MMCBR_ACCESSOR(host_ocr, HOST_OCR, int) MMCBR_ACCESSOR(mode, MODE, int) MMCBR_ACCESSOR(ocr, OCR, int) MMCBR_ACCESSOR(power_mode, POWER_MODE, int) -MMCBR_ACCESSOR(retune_req, RETUNE_REQ, int) MMCBR_ACCESSOR(vdd, VDD, int) MMCBR_ACCESSOR(vccq, VCCQ, int) MMCBR_ACCESSOR(caps, CAPS, int) @@ -103,6 +102,20 @@ MMCBR_ACCESSOR(timing, TIMING, int) MMCBR_ACCESSOR(max_data, MAX_DATA, int) MMCBR_ACCESSOR(max_busy_timeout, MAX_BUSY_TIMEOUT, u_int) +static int __inline +mmcbr_get_retune_req(device_t dev) +{ + uintptr_t v; + + if (__predict_false(BUS_READ_IVAR(device_get_parent(dev), dev, + MMCBR_IVAR_RETUNE_REQ, &v) != 0)) + return (retune_req_none); + return ((int)v); +} + +/* + * Convenience wrappers for the mmcbr interface + */ static int __inline mmcbr_update_ios(device_t dev) { From owner-svn-src-stable@freebsd.org Wed Sep 5 20:47:52 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EF0FCFFC748; Wed, 5 Sep 2018 20:47:51 +0000 (UTC) (envelope-from marius@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 9581E72713; Wed, 5 Sep 2018 20:47:51 +0000 (UTC) (envelope-from marius@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 82AC42AD27; Wed, 5 Sep 2018 20:47:51 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w85Klp1k059213; Wed, 5 Sep 2018 20:47:51 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w85KlpEb059212; Wed, 5 Sep 2018 20:47:51 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201809052047.w85KlpEb059212@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Wed, 5 Sep 2018 20:47:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r338477 - stable/10/sys/dev/mmc X-SVN-Group: stable-10 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/10/sys/dev/mmc X-SVN-Commit-Revision: 338477 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 20:47:52 -0000 Author: marius Date: Wed Sep 5 20:47:51 2018 New Revision: 338477 URL: https://svnweb.freebsd.org/changeset/base/338477 Log: MFC: r338304 The read accessors generated by __BUS_ACCESSOR() have the problem that they don't check the result of BUS_READ_IVAR(9) and silently return stack garbage on failure in case a bus doesn't implement a particular instance variable for example. With MMC bridges not providing MMCBR_IVAR_RETUNE_REQ, yet, this in turn can cause mmc(4) to get into a state in which re-tuning seems to be necessary but is inappropriate, causing mmc_wait_for_request() to fail. Thus, don't use __BUS_ACCESSOR() for mmcbr_get_retune_req() and instead provide a version of the latter which returns retune_req_none if reading MMCBR_IVAR_RETUNE_REQ fails. Modified: stable/10/sys/dev/mmc/mmcbrvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/mmc/mmcbrvar.h ============================================================================== --- stable/10/sys/dev/mmc/mmcbrvar.h Wed Sep 5 20:43:46 2018 (r338476) +++ stable/10/sys/dev/mmc/mmcbrvar.h Wed Sep 5 20:47:51 2018 (r338477) @@ -95,7 +95,6 @@ MMCBR_ACCESSOR(host_ocr, HOST_OCR, int) MMCBR_ACCESSOR(mode, MODE, int) MMCBR_ACCESSOR(ocr, OCR, int) MMCBR_ACCESSOR(power_mode, POWER_MODE, int) -MMCBR_ACCESSOR(retune_req, RETUNE_REQ, int) MMCBR_ACCESSOR(vdd, VDD, int) MMCBR_ACCESSOR(vccq, VCCQ, int) MMCBR_ACCESSOR(caps, CAPS, int) @@ -103,6 +102,20 @@ MMCBR_ACCESSOR(timing, TIMING, int) MMCBR_ACCESSOR(max_data, MAX_DATA, int) MMCBR_ACCESSOR(max_busy_timeout, MAX_BUSY_TIMEOUT, u_int) +static int __inline +mmcbr_get_retune_req(device_t dev) +{ + uintptr_t v; + + if (__predict_false(BUS_READ_IVAR(device_get_parent(dev), dev, + MMCBR_IVAR_RETUNE_REQ, &v) != 0)) + return (retune_req_none); + return ((int)v); +} + +/* + * Convenience wrappers for the mmcbr interface + */ static int __inline mmcbr_update_ios(device_t dev) { From owner-svn-src-stable@freebsd.org Wed Sep 5 21:05:17 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A759AFFCEA4; Wed, 5 Sep 2018 21:05:17 +0000 (UTC) (envelope-from marius@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 5D89F7326E; Wed, 5 Sep 2018 21:05:17 +0000 (UTC) (envelope-from marius@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 3A4B32B053; Wed, 5 Sep 2018 21:05:17 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w85L5HKR069449; Wed, 5 Sep 2018 21:05:17 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w85L5HsN069448; Wed, 5 Sep 2018 21:05:17 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201809052105.w85L5HsN069448@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Wed, 5 Sep 2018 21:05:17 +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: r338479 - stable/11/sys/dev/sdhci X-SVN-Group: stable-11 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/11/sys/dev/sdhci X-SVN-Commit-Revision: 338479 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 21:05:17 -0000 Author: marius Date: Wed Sep 5 21:05:16 2018 New Revision: 338479 URL: https://svnweb.freebsd.org/changeset/base/338479 Log: MFC: r338261 - According to section 2.2.5 of the SDHCI specification version 4.20, SDHCI_TRNS_ACMD12 is to be set only for multiple-block read/write commands without data length information, so don't unconditionally set this bit. The result matches what e. g. Linux does. - Section 2.2.19 of the SDHCI specification version 4.20 states that SDHCI_ACMD12_ERR should be only valid if SDHCI_INT_ACMD12ERR is set and hardware may clear SDHCI_ACMD12_ERR when SDHCI_INT_ACMD12ERR is cleared (differing silicon behavior is specifically allowed, though). Thus, read SDHCI_ACMD12_ERR before clearing SDHCI_INT_ACMD12ERR. While at it, use the 16-bit accessor rather than the 32-bit one for reading the 16-bit SDHCI_ACMD12_ERR. - SDHCI_INT_TUNEERR isn't one of the ROC bits in SDHCI_INT_STATUS so clear it explicitly. - Add missing prototypes and sort them. Modified: stable/11/sys/dev/sdhci/sdhci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/sdhci/sdhci.c ============================================================================== --- stable/11/sys/dev/sdhci/sdhci.c Wed Sep 5 20:51:53 2018 (r338478) +++ stable/11/sys/dev/sdhci/sdhci.c Wed Sep 5 21:05:16 2018 (r338479) @@ -80,17 +80,37 @@ SYSCTL_INT(_hw_sdhci, OID_AUTO, quirk_set, CTLFLAG_RWT #define WR_MULTI_4(slot, off, ptr, count) \ SDHCI_WRITE_MULTI_4((slot)->bus, (slot), (off), (ptr), (count)) +static void sdhci_acmd_irq(struct sdhci_slot *slot, uint16_t acmd_err); static void sdhci_card_poll(void *arg); static void sdhci_card_task(void *arg, int pending); +static void sdhci_cmd_irq(struct sdhci_slot *slot, uint32_t intmask); +static void sdhci_data_irq(struct sdhci_slot *slot, uint32_t intmask); static int sdhci_exec_tuning(struct sdhci_slot *slot, bool reset); +static void sdhci_handle_card_present_locked(struct sdhci_slot *slot, + bool is_present); +static void sdhci_finish_command(struct sdhci_slot *slot); +static void sdhci_init(struct sdhci_slot *slot); +static void sdhci_read_block_pio(struct sdhci_slot *slot); +static void sdhci_req_done(struct sdhci_slot *slot); static void sdhci_req_wakeup(struct mmc_request *req); +static void sdhci_reset(struct sdhci_slot *slot, uint8_t mask); static void sdhci_retune(void *arg); static void sdhci_set_clock(struct sdhci_slot *slot, uint32_t clock); +static void sdhci_set_power(struct sdhci_slot *slot, u_char power); +static void sdhci_set_transfer_mode(struct sdhci_slot *slot, + struct mmc_data *data); static void sdhci_start(struct sdhci_slot *slot); +static void sdhci_timeout(void *arg); +static void sdhci_start_command(struct sdhci_slot *slot, + struct mmc_command *cmd); static void sdhci_start_data(struct sdhci_slot *slot, struct mmc_data *data); +static void sdhci_write_block_pio(struct sdhci_slot *slot); +static void sdhci_transfer_pio(struct sdhci_slot *slot); /* helper routines */ static void sdhci_dumpregs(struct sdhci_slot *slot); +static void sdhci_getaddr(void *arg, bus_dma_segment_t *segs, int nsegs, + int error); static int slot_printf(struct sdhci_slot *slot, const char * fmt, ...) __printflike(2, 3); static uint32_t sdhci_tuning_intmask(struct sdhci_slot *slot); @@ -1433,12 +1453,14 @@ sdhci_set_transfer_mode(struct sdhci_slot *slot, struc return; mode = SDHCI_TRNS_BLK_CNT_EN; - if (data->len > 512) + if (data->len > 512) { mode |= SDHCI_TRNS_MULTI; + if (__predict_true(slot->req->stop && + !(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP))) + mode |= SDHCI_TRNS_ACMD12; + } if (data->flags & MMC_DATA_READ) mode |= SDHCI_TRNS_READ; - if (slot->req->stop && !(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP)) - mode |= SDHCI_TRNS_ACMD12; if (slot->flags & SDHCI_USE_DMA) mode |= SDHCI_TRNS_DMA; @@ -1957,18 +1979,16 @@ done: } static void -sdhci_acmd_irq(struct sdhci_slot *slot) +sdhci_acmd_irq(struct sdhci_slot *slot, uint16_t acmd_err) { - uint16_t err; - err = RD4(slot, SDHCI_ACMD12_ERR); if (!slot->curcmd) { slot_printf(slot, "Got AutoCMD12 error 0x%04x, but " - "there is no active command.\n", err); + "there is no active command.\n", acmd_err); sdhci_dumpregs(slot); return; } - slot_printf(slot, "Got AutoCMD12 error 0x%04x\n", err); + slot_printf(slot, "Got AutoCMD12 error 0x%04x\n", acmd_err); sdhci_reset(slot, SDHCI_RESET_CMD); } @@ -1976,6 +1996,7 @@ void sdhci_generic_intr(struct sdhci_slot *slot) { uint32_t intmask, present; + uint16_t val16; SDHCI_LOCK(slot); /* Read slot interrupt status. */ @@ -1989,6 +2010,7 @@ sdhci_generic_intr(struct sdhci_slot *slot) /* Handle tuning error interrupt. */ if (__predict_false(intmask & SDHCI_INT_TUNEERR)) { + WR4(slot, SDHCI_INT_STATUS, SDHCI_INT_TUNEERR); slot_printf(slot, "Tuning error indicated\n"); slot->retune_req |= SDHCI_RETUNE_REQ_RESET; if (slot->curcmd) { @@ -2026,8 +2048,10 @@ sdhci_generic_intr(struct sdhci_slot *slot) } /* Handle AutoCMD12 error interrupt. */ if (intmask & SDHCI_INT_ACMD12ERR) { + /* Clearing SDHCI_INT_ACMD12ERR may clear SDHCI_ACMD12_ERR. */ + val16 = RD2(slot, SDHCI_ACMD12_ERR); WR4(slot, SDHCI_INT_STATUS, SDHCI_INT_ACMD12ERR); - sdhci_acmd_irq(slot); + sdhci_acmd_irq(slot, val16); } /* Handle bus power interrupt. */ if (intmask & SDHCI_INT_BUS_POWER) { From owner-svn-src-stable@freebsd.org Wed Sep 5 21:15:24 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E5100FFD324; Wed, 5 Sep 2018 21:15:23 +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 9A806738F6; Wed, 5 Sep 2018 21:15:23 +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 956E02B200; Wed, 5 Sep 2018 21:15:23 +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 w85LFNtP074665; Wed, 5 Sep 2018 21:15:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w85LFNKe074664; Wed, 5 Sep 2018 21:15:23 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201809052115.w85LFNKe074664@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 5 Sep 2018 21:15:23 +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: r338480 - stable/11/sys/compat/freebsd32 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/compat/freebsd32 X-SVN-Commit-Revision: 338480 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 21:15:24 -0000 Author: kib Date: Wed Sep 5 21:15:23 2018 New Revision: 338480 URL: https://svnweb.freebsd.org/changeset/base/338480 Log: MFC r338357: Fix compat32 ftruncate cap mode. PR: 230120 Modified: stable/11/sys/compat/freebsd32/capabilities.conf Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/freebsd32/capabilities.conf ============================================================================== --- stable/11/sys/compat/freebsd32/capabilities.conf Wed Sep 5 21:05:16 2018 (r338479) +++ stable/11/sys/compat/freebsd32/capabilities.conf Wed Sep 5 21:15:23 2018 (r338480) @@ -103,6 +103,7 @@ freebsd32_fstat fstatfs fsync ftruncate +freebsd32_ftruncate freebsd32_futimens freebsd32_futimes getaudit From owner-svn-src-stable@freebsd.org Wed Sep 5 21:15:49 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D3FA8FFD373; Wed, 5 Sep 2018 21:15:48 +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 86F88739FF; Wed, 5 Sep 2018 21:15:48 +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 81D602B202; Wed, 5 Sep 2018 21:15:48 +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 w85LFmkt074744; Wed, 5 Sep 2018 21:15:48 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w85LFmOW074743; Wed, 5 Sep 2018 21:15:48 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201809052115.w85LFmOW074743@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 5 Sep 2018 21:15:48 +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: r338481 - stable/11/sys/compat/freebsd32 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/compat/freebsd32 X-SVN-Commit-Revision: 338481 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 21:15:49 -0000 Author: kib Date: Wed Sep 5 21:15:48 2018 New Revision: 338481 URL: https://svnweb.freebsd.org/changeset/base/338481 Log: Regen. Modified: stable/11/sys/compat/freebsd32/freebsd32_sysent.c Modified: stable/11/sys/compat/freebsd32/freebsd32_sysent.c ============================================================================== --- stable/11/sys/compat/freebsd32/freebsd32_sysent.c Wed Sep 5 21:15:23 2018 (r338480) +++ stable/11/sys/compat/freebsd32/freebsd32_sysent.c Wed Sep 5 21:15:48 2018 (r338481) @@ -253,7 +253,7 @@ struct sysent freebsd32_sysent[] = { { 0, (sy_call_t *)nosys, AUE_NULL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 198 = __syscall */ { compat6(AS(freebsd6_freebsd32_lseek_args),freebsd32_lseek), AUE_LSEEK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 199 = freebsd6 freebsd32_lseek */ { compat6(AS(freebsd6_freebsd32_truncate_args),freebsd32_truncate), AUE_TRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 200 = freebsd6 freebsd32_truncate */ - { compat6(AS(freebsd6_freebsd32_ftruncate_args),freebsd32_ftruncate), AUE_FTRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 201 = freebsd6 freebsd32_ftruncate */ + { compat6(AS(freebsd6_freebsd32_ftruncate_args),freebsd32_ftruncate), AUE_FTRUNCATE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 201 = freebsd6 freebsd32_ftruncate */ { AS(freebsd32_sysctl_args), (sy_call_t *)freebsd32_sysctl, AUE_SYSCTL, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 202 = freebsd32_sysctl */ { AS(mlock_args), (sy_call_t *)sys_mlock, AUE_MLOCK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 203 = mlock */ { AS(munlock_args), (sy_call_t *)sys_munlock, AUE_MUNLOCK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 204 = munlock */ @@ -533,14 +533,14 @@ struct sysent freebsd32_sysent[] = { { AS(freebsd32_mmap_args), (sy_call_t *)freebsd32_mmap, AUE_MMAP, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 477 = freebsd32_mmap */ { AS(freebsd32_lseek_args), (sy_call_t *)freebsd32_lseek, AUE_LSEEK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 478 = freebsd32_lseek */ { AS(freebsd32_truncate_args), (sy_call_t *)freebsd32_truncate, AUE_TRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 479 = freebsd32_truncate */ - { AS(freebsd32_ftruncate_args), (sy_call_t *)freebsd32_ftruncate, AUE_FTRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 480 = freebsd32_ftruncate */ + { AS(freebsd32_ftruncate_args), (sy_call_t *)freebsd32_ftruncate, AUE_FTRUNCATE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 480 = freebsd32_ftruncate */ #else { AS(freebsd32_pread_args), (sy_call_t *)freebsd32_pread, AUE_PREAD, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 475 = freebsd32_pread */ { AS(freebsd32_pwrite_args), (sy_call_t *)freebsd32_pwrite, AUE_PWRITE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 476 = freebsd32_pwrite */ { AS(freebsd32_mmap_args), (sy_call_t *)freebsd32_mmap, AUE_MMAP, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 477 = freebsd32_mmap */ { AS(freebsd32_lseek_args), (sy_call_t *)freebsd32_lseek, AUE_LSEEK, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 478 = freebsd32_lseek */ { AS(freebsd32_truncate_args), (sy_call_t *)freebsd32_truncate, AUE_TRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 479 = freebsd32_truncate */ - { AS(freebsd32_ftruncate_args), (sy_call_t *)freebsd32_ftruncate, AUE_FTRUNCATE, NULL, 0, 0, 0, SY_THR_STATIC }, /* 480 = freebsd32_ftruncate */ + { AS(freebsd32_ftruncate_args), (sy_call_t *)freebsd32_ftruncate, AUE_FTRUNCATE, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 480 = freebsd32_ftruncate */ #endif { AS(thr_kill2_args), (sy_call_t *)sys_thr_kill2, AUE_KILL, NULL, 0, 0, 0, SY_THR_STATIC }, /* 481 = thr_kill2 */ { AS(shm_open_args), (sy_call_t *)sys_shm_open, AUE_SHMOPEN, NULL, 0, 0, SYF_CAPENABLED, SY_THR_STATIC }, /* 482 = shm_open */ From owner-svn-src-stable@freebsd.org Wed Sep 5 21:23:41 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0ACF4FFD8E2; Wed, 5 Sep 2018 21:23:41 +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 B428A741D3; Wed, 5 Sep 2018 21:23:40 +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 951102B3A3; Wed, 5 Sep 2018 21:23:40 +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 w85LNeRG079590; Wed, 5 Sep 2018 21:23:40 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w85LNeUw079589; Wed, 5 Sep 2018 21:23:40 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201809052123.w85LNeUw079589@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 5 Sep 2018 21:23:40 +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: r338482 - stable/11/libexec/rtld-elf X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/libexec/rtld-elf X-SVN-Commit-Revision: 338482 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 21:23:41 -0000 Author: kib Date: Wed Sep 5 21:23:40 2018 New Revision: 338482 URL: https://svnweb.freebsd.org/changeset/base/338482 Log: MFC r324856: Don't call realpath(3) from libmap rtld code. Modified: stable/11/libexec/rtld-elf/libmap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/libexec/rtld-elf/libmap.c ============================================================================== --- stable/11/libexec/rtld-elf/libmap.c Wed Sep 5 21:15:48 2018 (r338481) +++ stable/11/libexec/rtld-elf/libmap.c Wed Sep 5 21:23:40 2018 (r338482) @@ -36,6 +36,8 @@ struct lmp { static TAILQ_HEAD(lmc_list, lmc) lmc_head = TAILQ_HEAD_INITIALIZER(lmc_head); struct lmc { char *path; + dev_t dev; + ino_t ino; TAILQ_ENTRY(lmc) next; }; @@ -99,45 +101,45 @@ lmc_parse_file(char *path) struct lmc *p; struct stat st; int fd; - char *rpath; char *lm_map; - rpath = realpath(path, NULL); - if (rpath == NULL) - return; - TAILQ_FOREACH(p, &lmc_head, next) { - if (strcmp(p->path, rpath) == 0) { - free(rpath); + if (strcmp(p->path, path) == 0) return; - } } - fd = open(rpath, O_RDONLY | O_CLOEXEC); + fd = open(path, O_RDONLY | O_CLOEXEC); if (fd == -1) { - dbg("lm_parse_file: open(\"%s\") failed, %s", rpath, + dbg("lm_parse_file: open(\"%s\") failed, %s", path, rtld_strerror(errno)); - free(rpath); return; } if (fstat(fd, &st) == -1) { close(fd); - dbg("lm_parse_file: fstat(\"%s\") failed, %s", rpath, + dbg("lm_parse_file: fstat(\"%s\") failed, %s", path, rtld_strerror(errno)); - free(rpath); return; } + + TAILQ_FOREACH(p, &lmc_head, next) { + if (p->dev == st.st_dev && p->ino == st.st_ino) { + close(fd); + return; + } + } + lm_map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); if (lm_map == (const char *)MAP_FAILED) { close(fd); - dbg("lm_parse_file: mmap(\"%s\") failed, %s", rpath, + dbg("lm_parse_file: mmap(\"%s\") failed, %s", path, rtld_strerror(errno)); - free(rpath); return; } close(fd); p = xmalloc(sizeof(struct lmc)); - p->path = rpath; + p->path = xstrdup(path); + p->dev = st.st_dev; + p->ino = st.st_ino; TAILQ_INSERT_HEAD(&lmc_head, p, next); lmc_parse(lm_map, st.st_size); munmap(lm_map, st.st_size); @@ -151,26 +153,19 @@ lmc_parse_dir(char *idir) struct lmc *p; char conffile[MAXPATHLEN]; char *ext; - char *rpath; - rpath = realpath(idir, NULL); - if (rpath == NULL) - return; - TAILQ_FOREACH(p, &lmc_head, next) { - if (strcmp(p->path, rpath) == 0) { - free(rpath); + if (strcmp(p->path, idir) == 0) return; - } } d = opendir(idir); - if (d == NULL) { - free(rpath); + if (d == NULL) return; - } p = xmalloc(sizeof(struct lmc)); - p->path = rpath; + p->path = xstrdup(idir); + p->dev = NODEV; + p->ino = 0; TAILQ_INSERT_HEAD(&lmc_head, p, next); while ((dp = readdir(d)) != NULL) { From owner-svn-src-stable@freebsd.org Wed Sep 5 21:24:27 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E1A22FFD9F7; Wed, 5 Sep 2018 21:24:26 +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 970FB7435D; Wed, 5 Sep 2018 21:24:26 +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 90A9C2B3A6; Wed, 5 Sep 2018 21:24:26 +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 w85LOQkG079679; Wed, 5 Sep 2018 21:24:26 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w85LOQYT079678; Wed, 5 Sep 2018 21:24:26 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201809052124.w85LOQYT079678@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 5 Sep 2018 21:24:26 +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: r338483 - stable/11/libexec/rtld-elf X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/libexec/rtld-elf X-SVN-Commit-Revision: 338483 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 21:24:27 -0000 Author: kib Date: Wed Sep 5 21:24:26 2018 New Revision: 338483 URL: https://svnweb.freebsd.org/changeset/base/338483 Log: MFC r338428: Style cleanup. Modified: stable/11/libexec/rtld-elf/libmap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/libexec/rtld-elf/libmap.c ============================================================================== --- stable/11/libexec/rtld-elf/libmap.c Wed Sep 5 21:23:40 2018 (r338482) +++ stable/11/libexec/rtld-elf/libmap.c Wed Sep 5 21:24:26 2018 (r338483) @@ -99,9 +99,9 @@ static void lmc_parse_file(char *path) { struct lmc *p; + char *lm_map; struct stat st; int fd; - char *lm_map; TAILQ_FOREACH(p, &lmc_head, next) { if (strcmp(p->path, path) == 0) @@ -219,17 +219,20 @@ lmc_parse(char *lm_p, size_t lm_len) t = f = c = NULL; /* Skip over leading space */ - while (rtld_isspace(*cp)) cp++; + while (rtld_isspace(*cp)) + cp++; /* Found a comment or EOL */ - if (iseol(*cp)) continue; + if (iseol(*cp)) + continue; /* Found a constraint selector */ if (*cp == '[') { cp++; /* Skip leading space */ - while (rtld_isspace(*cp)) cp++; + while (rtld_isspace(*cp)) + cp++; /* Found comment, EOL or end of selector */ if (iseol(*cp) || *cp == ']') @@ -241,10 +244,12 @@ lmc_parse(char *lm_p, size_t lm_len) cp++; /* Skip and zero out trailing space */ - while (rtld_isspace(*cp)) *cp++ = '\0'; + while (rtld_isspace(*cp)) + *cp++ = '\0'; /* Check if there is a closing brace */ - if (*cp != ']') continue; + if (*cp != ']') + continue; /* Terminate string if there was no trailing space */ *cp++ = '\0'; @@ -253,8 +258,10 @@ lmc_parse(char *lm_p, size_t lm_len) * There should be nothing except whitespace or comment from this point to the end of the line. */ - while(rtld_isspace(*cp)) cp++; - if (!iseol(*cp)) continue; + while (rtld_isspace(*cp)) + cp++; + if (!iseol(*cp)) + continue; if (strlcpy(prog, c, sizeof prog) >= sizeof prog) continue; @@ -264,23 +271,29 @@ lmc_parse(char *lm_p, size_t lm_len) /* Parse the 'from' candidate. */ f = cp++; - while (!rtld_isspace(*cp) && !iseol(*cp)) cp++; + while (!rtld_isspace(*cp) && !iseol(*cp)) + cp++; /* Skip and zero out the trailing whitespace */ - while (rtld_isspace(*cp)) *cp++ = '\0'; + while (rtld_isspace(*cp)) + *cp++ = '\0'; /* Found a comment or EOL */ - if (iseol(*cp)) continue; + if (iseol(*cp)) + continue; /* Parse 'to' mapping */ t = cp++; - while (!rtld_isspace(*cp) && !iseol(*cp)) cp++; + while (!rtld_isspace(*cp) && !iseol(*cp)) + cp++; /* Skip and zero out the trailing whitespace */ - while (rtld_isspace(*cp)) *cp++ = '\0'; + while (rtld_isspace(*cp)) + *cp++ = '\0'; /* Should be no extra tokens at this point */ - if (!iseol(*cp)) continue; + if (!iseol(*cp)) + continue; *cp = '\0'; if (strcmp(f, "includedir") == 0) @@ -293,7 +306,7 @@ lmc_parse(char *lm_p, size_t lm_len) } static void -lm_free (struct lm_list *lml) +lm_free(struct lm_list *lml) { struct lm *lm; @@ -306,11 +319,10 @@ lm_free (struct lm_list *lml) free(lm->t); free(lm); } - return; } void -lm_fini (void) +lm_fini(void) { struct lmp *lmp; struct lmc *p; @@ -331,11 +343,10 @@ lm_fini (void) lm_free(&lmp->lml); free(lmp); } - return; } static void -lm_add (const char *p, const char *f, const char *t) +lm_add(const char *p, const char *f, const char *t) { struct lm_list *lml; struct lm *lm; @@ -356,7 +367,7 @@ lm_add (const char *p, const char *f, const char *t) } char * -lm_find (const char *p, const char *f) +lm_find(const char *p, const char *f) { struct lm_list *lml; char *t; @@ -377,14 +388,15 @@ lm_find (const char *p, const char *f) lml = lmp_find("$DEFAULT$"); if (lml != NULL) return (lml_find(lml, f)); - else - return (NULL); + return (NULL); } -/* Given a libmap translation list and a library name, return the - replacement library, or NULL */ +/* + * Given a libmap translation list and a library name, return the + * replacement library, or NULL. + */ char * -lm_findn (const char *p, const char *f, const int n) +lm_findn(const char *p, const char *f, const int n) { char pathbuf[64], *s, *t; @@ -401,37 +413,43 @@ lm_findn (const char *p, const char *f, const int n) } static char * -lml_find (struct lm_list *lmh, const char *f) +lml_find(struct lm_list *lmh, const char *f) { struct lm *lm; dbg("%s(%p, \"%s\")", __func__, lmh, f); - TAILQ_FOREACH(lm, lmh, lm_link) + TAILQ_FOREACH(lm, lmh, lm_link) { if (strcmp(f, lm->f) == 0) return (lm->t); + } return (NULL); } -/* Given an executable name, return a pointer to the translation list or - NULL if no matches */ +/* + * Given an executable name, return a pointer to the translation list or + * NULL if no matches. + */ static struct lm_list * -lmp_find (const char *n) +lmp_find(const char *n) { struct lmp *lmp; dbg("%s(\"%s\")", __func__, n); - TAILQ_FOREACH(lmp, &lmp_head, lmp_link) + TAILQ_FOREACH(lmp, &lmp_head, lmp_link) { if ((lmp->type == T_EXACT && strcmp(n, lmp->p) == 0) || - (lmp->type == T_DIRECTORY && strncmp(n, lmp->p, strlen(lmp->p)) == 0) || - (lmp->type == T_BASENAME && strcmp(quickbasename(n), lmp->p) == 0)) + (lmp->type == T_DIRECTORY && strncmp(n, lmp->p, + strlen(lmp->p)) == 0) || + (lmp->type == T_BASENAME && strcmp(quickbasename(n), + lmp->p) == 0)) return (&lmp->lml); + } return (NULL); } static struct lm_list * -lmp_init (char *n) +lmp_init(char *n) { struct lmp *lmp; @@ -439,7 +457,7 @@ lmp_init (char *n) lmp = xmalloc(sizeof(struct lmp)); lmp->p = n; - if (n[strlen(n)-1] == '/') + if (n[strlen(n) - 1] == '/') lmp->type = T_DIRECTORY; else if (strchr(n,'/') == NULL) lmp->type = T_BASENAME; @@ -451,15 +469,18 @@ lmp_init (char *n) return (&lmp->lml); } -/* libc basename is overkill. Return a pointer to the character after the - last /, or the original string if there are no slashes. */ +/* + * libc basename is overkill. Return a pointer to the character after + * the last /, or the original string if there are no slashes. + */ static const char * -quickbasename (const char *path) +quickbasename(const char *path) { - const char *p = path; - for (; *path; path++) { + const char *p; + + for (p = path; *path != '\0'; path++) { if (*path == '/') - p = path+1; + p = path + 1; } return (p); } From owner-svn-src-stable@freebsd.org Wed Sep 5 21:28:36 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 137C9FFDBB7; Wed, 5 Sep 2018 21:28:36 +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 B6FD374603; Wed, 5 Sep 2018 21:28:35 +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 B088D2B3AA; Wed, 5 Sep 2018 21:28:35 +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 w85LSZgr079905; Wed, 5 Sep 2018 21:28:35 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w85LSXcp079894; Wed, 5 Sep 2018 21:28:33 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201809052128.w85LSXcp079894@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 5 Sep 2018 21:28: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: r338484 - in stable/11/sys: amd64/amd64 arm/arm arm64/arm64 cddl/contrib/opensolaris/uts/common/fs/zfs/sys i386/i386 mips/mips riscv/riscv vm X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 arm/arm arm64/arm64 cddl/contrib/opensolaris/uts/common/fs/zfs/sys i386/i386 mips/mips riscv/riscv vm X-SVN-Commit-Revision: 338484 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Sep 2018 21:28:36 -0000 Author: kib Date: Wed Sep 5 21:28:33 2018 New Revision: 338484 URL: https://svnweb.freebsd.org/changeset/base/338484 Log: MFC r338370: Remove {max/min}_offset() macros, use vm_map_{max/min}() inlines. Modified: stable/11/sys/amd64/amd64/pmap.c stable/11/sys/arm/arm/pmap-v6.c stable/11/sys/arm64/arm64/pmap.c stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h stable/11/sys/i386/i386/pmap.c stable/11/sys/mips/mips/pmap.c stable/11/sys/riscv/riscv/pmap.c stable/11/sys/vm/vm_glue.c stable/11/sys/vm/vm_init.c stable/11/sys/vm/vm_map.c stable/11/sys/vm/vm_map.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/pmap.c ============================================================================== --- stable/11/sys/amd64/amd64/pmap.c Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/amd64/amd64/pmap.c Wed Sep 5 21:28:33 2018 (r338484) @@ -3020,8 +3020,8 @@ pmap_growkernel(vm_offset_t addr) return; addr = roundup2(addr, NBPDR); - if (addr - 1 >= kernel_map->max_offset) - addr = kernel_map->max_offset; + if (addr - 1 >= vm_map_max(kernel_map)) + addr = vm_map_max(kernel_map); while (kernel_vm_end < addr) { pdpe = pmap_pdpe(kernel_pmap, kernel_vm_end); if ((*pdpe & X86_PG_V) == 0) { @@ -3041,8 +3041,8 @@ pmap_growkernel(vm_offset_t addr) pde = pmap_pdpe_to_pde(pdpe, kernel_vm_end); if ((*pde & X86_PG_V) != 0) { kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } continue; @@ -3060,8 +3060,8 @@ pmap_growkernel(vm_offset_t addr) pde_store(pde, newpdir); kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } } Modified: stable/11/sys/arm/arm/pmap-v6.c ============================================================================== --- stable/11/sys/arm/arm/pmap-v6.c Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/arm/arm/pmap-v6.c Wed Sep 5 21:28:33 2018 (r338484) @@ -2021,21 +2021,21 @@ pmap_growkernel(vm_offset_t addr) * not called, it could be first unused KVA (which is not * rounded up to PTE1_SIZE), * - * (2) when all KVA space is mapped and kernel_map->max_offset + * (2) when all KVA space is mapped and vm_map_max(kernel_map) * address is not rounded up to PTE1_SIZE. (For example, * it could be 0xFFFFFFFF.) */ kernel_vm_end = pte1_roundup(kernel_vm_end); mtx_assert(&kernel_map->system_mtx, MA_OWNED); addr = roundup2(addr, PTE1_SIZE); - if (addr - 1 >= kernel_map->max_offset) - addr = kernel_map->max_offset; + if (addr - 1 >= vm_map_max(kernel_map)) + addr = vm_map_max(kernel_map); while (kernel_vm_end < addr) { pte1 = pte1_load(kern_pte1(kernel_vm_end)); if (pte1_is_valid(pte1)) { kernel_vm_end += PTE1_SIZE; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } continue; @@ -2077,8 +2077,8 @@ pmap_growkernel(vm_offset_t addr) pmap_kenter_pte1(kernel_vm_end, PTE1_LINK(pt2_pa)); kernel_vm_end = kernel_vm_end_new; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } } Modified: stable/11/sys/arm64/arm64/pmap.c ============================================================================== --- stable/11/sys/arm64/arm64/pmap.c Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/arm64/arm64/pmap.c Wed Sep 5 21:28:33 2018 (r338484) @@ -1734,8 +1734,8 @@ pmap_growkernel(vm_offset_t addr) mtx_assert(&kernel_map->system_mtx, MA_OWNED); addr = roundup2(addr, L2_SIZE); - if (addr - 1 >= kernel_map->max_offset) - addr = kernel_map->max_offset; + if (addr - 1 >= vm_map_max(kernel_map)) + addr = vm_map_max(kernel_map); while (kernel_vm_end < addr) { l0 = pmap_l0(kernel_pmap, kernel_vm_end); KASSERT(pmap_load(l0) != 0, @@ -1759,8 +1759,8 @@ pmap_growkernel(vm_offset_t addr) l2 = pmap_l1_to_l2(l1, kernel_vm_end); if ((pmap_load(l2) & ATTR_AF) != 0) { kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } continue; @@ -1779,8 +1779,8 @@ pmap_growkernel(vm_offset_t addr) pmap_invalidate_page(kernel_pmap, kernel_vm_end); kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } } Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h Wed Sep 5 21:28:33 2018 (r338484) @@ -104,13 +104,6 @@ extern "C" { #include #include #include -/* There is clash. vm_map.h defines the two below and vdev_cache.c use them. */ -#ifdef min_offset -#undef min_offset -#endif -#ifdef max_offset -#undef max_offset -#endif #include #include Modified: stable/11/sys/i386/i386/pmap.c ============================================================================== --- stable/11/sys/i386/i386/pmap.c Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/i386/i386/pmap.c Wed Sep 5 21:28:33 2018 (r338484) @@ -2107,13 +2107,13 @@ pmap_growkernel(vm_offset_t addr) mtx_assert(&kernel_map->system_mtx, MA_OWNED); addr = roundup2(addr, NBPDR); - if (addr - 1 >= kernel_map->max_offset) - addr = kernel_map->max_offset; + if (addr - 1 >= vm_map_max(kernel_map)) + addr = vm_map_max(kernel_map); while (kernel_vm_end < addr) { if (pdir_pde(PTD, kernel_vm_end)) { kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } continue; @@ -2135,8 +2135,8 @@ pmap_growkernel(vm_offset_t addr) pmap_kenter_pde(kernel_vm_end, newpdir); kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } } Modified: stable/11/sys/mips/mips/pmap.c ============================================================================== --- stable/11/sys/mips/mips/pmap.c Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/mips/mips/pmap.c Wed Sep 5 21:28:33 2018 (r338484) @@ -1249,8 +1249,8 @@ pmap_growkernel(vm_offset_t addr) mtx_assert(&kernel_map->system_mtx, MA_OWNED); req_class = VM_ALLOC_INTERRUPT; addr = roundup2(addr, NBSEG); - if (addr - 1 >= kernel_map->max_offset) - addr = kernel_map->max_offset; + if (addr - 1 >= vm_map_max(kernel_map)) + addr = vm_map_max(kernel_map); while (kernel_vm_end < addr) { pdpe = pmap_segmap(kernel_pmap, kernel_vm_end); #ifdef __mips_n64 @@ -1266,8 +1266,8 @@ pmap_growkernel(vm_offset_t addr) pde = pmap_pdpe_to_pde(pdpe, kernel_vm_end); if (*pde != 0) { kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } continue; @@ -1299,8 +1299,8 @@ pmap_growkernel(vm_offset_t addr) pte[i] = PTE_G; kernel_vm_end = (kernel_vm_end + NBPDR) & ~PDRMASK; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } } Modified: stable/11/sys/riscv/riscv/pmap.c ============================================================================== --- stable/11/sys/riscv/riscv/pmap.c Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/riscv/riscv/pmap.c Wed Sep 5 21:28:33 2018 (r338484) @@ -1412,8 +1412,8 @@ pmap_growkernel(vm_offset_t addr) mtx_assert(&kernel_map->system_mtx, MA_OWNED); addr = roundup2(addr, L2_SIZE); - if (addr - 1 >= kernel_map->max_offset) - addr = kernel_map->max_offset; + if (addr - 1 >= vm_map_max(kernel_map)) + addr = vm_map_max(kernel_map); while (kernel_vm_end < addr) { l1 = pmap_l1(kernel_pmap, kernel_vm_end); if (pmap_load(l1) == 0) { @@ -1440,8 +1440,8 @@ pmap_growkernel(vm_offset_t addr) l2 = pmap_l1_to_l2(l1, kernel_vm_end); if ((pmap_load(l2) & PTE_REF) != 0) { kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } continue; @@ -1465,8 +1465,8 @@ pmap_growkernel(vm_offset_t addr) pmap_invalidate_page(kernel_pmap, kernel_vm_end); kernel_vm_end = (kernel_vm_end + L2_SIZE) & ~L2_OFFSET; - if (kernel_vm_end - 1 >= kernel_map->max_offset) { - kernel_vm_end = kernel_map->max_offset; + if (kernel_vm_end - 1 >= vm_map_max(kernel_map)) { + kernel_vm_end = vm_map_max(kernel_map); break; } } Modified: stable/11/sys/vm/vm_glue.c ============================================================================== --- stable/11/sys/vm/vm_glue.c Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/vm/vm_glue.c Wed Sep 5 21:28:33 2018 (r338484) @@ -122,7 +122,7 @@ kernacc(addr, len, rw) KASSERT((rw & ~VM_PROT_ALL) == 0, ("illegal ``rw'' argument to kernacc (%x)\n", rw)); - if ((vm_offset_t)addr + len > kernel_map->max_offset || + if ((vm_offset_t)addr + len > vm_map_max(kernel_map) || (vm_offset_t)addr + len < (vm_offset_t)addr) return (FALSE); Modified: stable/11/sys/vm/vm_init.c ============================================================================== --- stable/11/sys/vm/vm_init.c Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/vm/vm_init.c Wed Sep 5 21:28:33 2018 (r338484) @@ -192,8 +192,8 @@ again: * Discount the physical memory larger than the size of kernel_map * to avoid eating up all of KVA space. */ - physmem_est = lmin(physmem, btoc(kernel_map->max_offset - - kernel_map->min_offset)); + physmem_est = lmin(physmem, btoc(vm_map_max(kernel_map) - + vm_map_min(kernel_map))); v = kern_vfs_bio_buffer_alloc(v, physmem_est); Modified: stable/11/sys/vm/vm_map.c ============================================================================== --- stable/11/sys/vm/vm_map.c Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/vm/vm_map.c Wed Sep 5 21:28:33 2018 (r338484) @@ -334,8 +334,8 @@ vmspace_dofree(struct vmspace *vm) * Delete all of the mappings and pages they hold, then call * the pmap module to reclaim anything left. */ - (void)vm_map_remove(&vm->vm_map, vm->vm_map.min_offset, - vm->vm_map.max_offset); + (void)vm_map_remove(&vm->vm_map, vm_map_min(&vm->vm_map), + vm_map_max(&vm->vm_map)); pmap_release(vmspace_pmap(vm)); vm->vm_map.pmap = NULL; @@ -794,8 +794,8 @@ _vm_map_init(vm_map_t map, pmap_t pmap, vm_offset_t mi map->needs_wakeup = FALSE; map->system_map = 0; map->pmap = pmap; - map->min_offset = min; - map->max_offset = max; + map->header.end = min; + map->header.start = max; map->flags = 0; map->root = NULL; map->timestamp = 0; @@ -1193,7 +1193,8 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_oof /* * Check that the start and end points are not bogus. */ - if (start < map->min_offset || end > map->max_offset || start >= end) + if (start < vm_map_min(map) || end > vm_map_max(map) || + start >= end) return (KERN_INVALID_ADDRESS); /* @@ -1393,9 +1394,8 @@ vm_map_findspace(vm_map_t map, vm_offset_t start, vm_s * Request must fit within min/max VM address and must avoid * address wrap. */ - if (start < map->min_offset) - start = map->min_offset; - if (start + length > map->max_offset || start + length < start) + start = MAX(start, vm_map_min(map)); + if (start + length > vm_map_max(map) || start + length < start) return (1); /* Empty tree means wide open address space. */ @@ -3367,7 +3367,7 @@ vmspace_fork(struct vmspace *vm1, vm_ooffset_t *fork_c old_map = &vm1->vm_map; /* Copy immutable fields of vm1 to vm2. */ - vm2 = vmspace_alloc(old_map->min_offset, old_map->max_offset, NULL); + vm2 = vmspace_alloc(vm_map_min(old_map), vm_map_max(old_map), NULL); if (vm2 == NULL) return (NULL); vm2->vm_taddr = vm1->vm_taddr; @@ -4267,14 +4267,14 @@ vm_offset_t vm_map_max_KBI(const struct vm_map *map) { - return (map->max_offset); + return (vm_map_max(map)); } vm_offset_t vm_map_min_KBI(const struct vm_map *map) { - return (map->min_offset); + return (vm_map_min(map)); } pmap_t Modified: stable/11/sys/vm/vm_map.h ============================================================================== --- stable/11/sys/vm/vm_map.h Wed Sep 5 21:24:26 2018 (r338483) +++ stable/11/sys/vm/vm_map.h Wed Sep 5 21:28:33 2018 (r338484) @@ -172,19 +172,26 @@ vm_map_entry_system_wired_count(vm_map_entry_t entry) * A map is a set of map entries. These map entries are * organized both as a binary search tree and as a doubly-linked * list. Both structures are ordered based upon the start and - * end addresses contained within each map entry. The list - * header has max start value and min end value to act as - * sentinels for sequential search of the doubly-linked list. + * end addresses contained within each map entry. + * + * Counterintuitively, the map's min offset value is stored in + * map->header.end, and its max offset value is stored in + * map->header.start. + * + * The list header has max start value and min end value to act + * as sentinels for sequential search of the doubly-linked list. * Sleator and Tarjan's top-down splay algorithm is employed to * control height imbalance in the binary search tree. * - * List of locks + * List of locks * (c) const until freed */ struct vm_map { struct vm_map_entry header; /* List of entries */ -#define min_offset header.end /* (c) */ -#define max_offset header.start /* (c) */ +/* + map min_offset header.end (c) + map max_offset header.start (c) +*/ struct sx lock; /* Lock for map data */ struct mtx system_mtx; int nentries; /* Number of entries */ @@ -213,13 +220,15 @@ struct vm_map { static __inline vm_offset_t vm_map_max(const struct vm_map *map) { - return (map->max_offset); + + return (map->header.start); } static __inline vm_offset_t vm_map_min(const struct vm_map *map) { - return (map->min_offset); + + return (map->header.end); } static __inline pmap_t From owner-svn-src-stable@freebsd.org Thu Sep 6 22:23:41 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A76DFE7824; Thu, 6 Sep 2018 22:23:41 +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 F23F38F1FF; Thu, 6 Sep 2018 22:23:40 +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 EA0E0134DA; Thu, 6 Sep 2018 22:23:40 +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 w86MNesZ067786; Thu, 6 Sep 2018 22:23:40 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w86MNdcq067782; Thu, 6 Sep 2018 22:23:39 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201809062223.w86MNdcq067782@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 6 Sep 2018 22:23:39 +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: r338514 - in stable/11: sys/arm/include sys/arm64/include sys/mips/include sys/riscv/include tests/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable/11: sys/arm/include sys/arm64/include sys/mips/include sys/riscv/include tests/sys/kern X-SVN-Commit-Revision: 338514 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2018 22:23:41 -0000 Author: jhb Date: Thu Sep 6 22:23:39 2018 New Revision: 338514 URL: https://svnweb.freebsd.org/changeset/base/338514 Log: MFC 332906,332907,332976,333679,336053: Expand testing of breakpoints. 332906: Extend support for ptrace() tests using breakpoints. - Use a single list of platforms to define HAVE_BREAKPOINT for platforms that expose a functional breakpoint() inline to userland. Replace existing lists of platform tests with HAVE_BREAKPOINT instead. - Add support for advancing PC past a breakpoint inserted via breakpoint() to support the existing ptrace__PT_CONTINUE_different_thread test on non-x86 platforms (x86 advances the PC past the breakpoint instruction, but other platforms do not). This is implemented by defining a new SKIP_BREAK macro which accepts a pointer to a 'struct reg' as its sole argument and modifies the contents to advance the PC. The intention is to use it in between PT_GETREGS and PT_SETREGS. 332907: Expose breakpoint() to userland from on MIPS. Enable ptrace() tests using breakpoint on MIPS as well. 332976: Shorten some recently-added lines that are an extra indent over 80 columns. 333679: Export a breakpoint() function to userland for riscv. As a result, enable tests using breakpoint() on riscv. 336053: Export a breakpoint() function to userland for arm and arm64. Enable ptrace() tests using breakpoint() on these architectures. Modified: stable/11/sys/arm/include/cpufunc.h stable/11/sys/arm64/include/cpufunc.h stable/11/sys/mips/include/cpufunc.h stable/11/sys/riscv/include/cpufunc.h stable/11/tests/sys/kern/ptrace_test.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/arm/include/cpufunc.h ============================================================================== --- stable/11/sys/arm/include/cpufunc.h Thu Sep 6 21:24:14 2018 (r338513) +++ stable/11/sys/arm/include/cpufunc.h Thu Sep 6 22:23:39 2018 (r338514) @@ -52,7 +52,7 @@ static __inline void breakpoint(void) { - __asm(".word 0xe7ffffff"); + __asm("udf 0xffff"); } struct cpu_functions { @@ -525,6 +525,19 @@ extern int arm_dcache_align_mask; extern u_int arm_cache_level; extern u_int arm_cache_loc; extern u_int arm_cache_type[14]; + +#else /* !_KERNEL */ + +static __inline void +breakpoint(void) +{ + + /* + * This matches the instruction used by GDB for software + * breakpoints. + */ + __asm("udf 0xfdee"); +} #endif /* _KERNEL */ #endif /* _MACHINE_CPUFUNC_H_ */ Modified: stable/11/sys/arm64/include/cpufunc.h ============================================================================== --- stable/11/sys/arm64/include/cpufunc.h Thu Sep 6 21:24:14 2018 (r338513) +++ stable/11/sys/arm64/include/cpufunc.h Thu Sep 6 22:23:39 2018 (r338514) @@ -29,18 +29,18 @@ #ifndef _MACHINE_CPUFUNC_H_ #define _MACHINE_CPUFUNC_H_ -#ifdef _KERNEL - -#include - -void pan_enable(void); - static __inline void breakpoint(void) { __asm("brk #0"); } + +#ifdef _KERNEL + +#include + +void pan_enable(void); static __inline register_t dbg_disable(void) Modified: stable/11/sys/mips/include/cpufunc.h ============================================================================== --- stable/11/sys/mips/include/cpufunc.h Thu Sep 6 21:24:14 2018 (r338513) +++ stable/11/sys/mips/include/cpufunc.h Thu Sep 6 22:23:39 2018 (r338514) @@ -106,6 +106,12 @@ mips_wbflush(void) #endif } +static __inline void +breakpoint(void) +{ + __asm __volatile ("break"); +} + #ifdef _KERNEL /* * XXX @@ -339,12 +345,6 @@ get_intr_mask(void) { return (mips_rd_status() & MIPS_SR_INT_MASK); -} - -static __inline void -breakpoint(void) -{ - __asm __volatile ("break"); } #if defined(__GNUC__) && !defined(__mips_o32) Modified: stable/11/sys/riscv/include/cpufunc.h ============================================================================== --- stable/11/sys/riscv/include/cpufunc.h Thu Sep 6 21:24:14 2018 (r338513) +++ stable/11/sys/riscv/include/cpufunc.h Thu Sep 6 22:23:39 2018 (r338514) @@ -37,16 +37,16 @@ #ifndef _MACHINE_CPUFUNC_H_ #define _MACHINE_CPUFUNC_H_ -#ifdef _KERNEL - -#include - static __inline void breakpoint(void) { __asm("ebreak"); } + +#ifdef _KERNEL + +#include static __inline register_t intr_disable(void) Modified: stable/11/tests/sys/kern/ptrace_test.c ============================================================================== --- stable/11/tests/sys/kern/ptrace_test.c Thu Sep 6 21:24:14 2018 (r338513) +++ stable/11/tests/sys/kern/ptrace_test.c Thu Sep 6 22:23:39 2018 (r338514) @@ -52,6 +52,37 @@ __FBSDID("$FreeBSD$"); #include /* + * Architectures with a user-visible breakpoint(). + */ +#if defined(__aarch64__) || defined(__amd64__) || defined(__arm__) || \ + defined(__i386__) || defined(__mips__) || defined(__riscv) || \ + defined(__sparc64__) +#define HAVE_BREAKPOINT +#endif + +/* + * Adjust PC to skip over a breakpoint when stopped for a breakpoint trap. + */ +#ifdef HAVE_BREAKPOINT +#if defined(__aarch64__) +#define SKIP_BREAK(reg) ((reg)->elr += 4) +#elif defined(__amd64__) || defined(__i386__) +#define SKIP_BREAK(reg) +#elif defined(__arm__) +#define SKIP_BREAK(reg) ((reg)->r_pc += 4) +#elif defined(__mips__) +#define SKIP_BREAK(reg) ((reg)->r_regs[PC] += 4) +#elif defined(__riscv) +#define SKIP_BREAK(reg) ((reg)->sepc += 4) +#elif defined(__sparc64__) +#define SKIP_BREAK(reg) do { \ + (reg)->r_tpc = (reg)->r_tnpc + 4; \ + (reg)->r_tnpc += 8; \ +} while (0) +#endif +#endif + +/* * A variant of ATF_REQUIRE that is suitable for use in child * processes. This only works if the parent process is tripped up by * the early exit and fails some requirement itself. @@ -1688,12 +1719,8 @@ ATF_TC_BODY(ptrace__ptrace_vfork_follow, tc) ATF_REQUIRE(errno == ECHILD); } +#ifdef HAVE_BREAKPOINT /* - * XXX: There's nothing inherently platform specific about this test, however a - * userspace visible breakpoint() is a prerequisite. - */ - #if defined(__amd64__) || defined(__i386__) || defined(__sparc64__) -/* * Verify that no more events are reported after PT_KILL except for the * process exit when stopped due to a breakpoint trap. */ @@ -1738,7 +1765,7 @@ ATF_TC_BODY(ptrace__PT_KILL_breakpoint, tc) ATF_REQUIRE(wpid == -1); ATF_REQUIRE(errno == ECHILD); } -#endif /* defined(__amd64__) || defined(__i386__) || defined(__sparc64__) */ +#endif /* HAVE_BREAKPOINT */ /* * Verify that no more events are reported after PT_KILL except for the @@ -3468,11 +3495,7 @@ ATF_TC_BODY(ptrace__PT_STEP_with_signal, tc) ATF_REQUIRE(errno == ECHILD); } -#if defined(__amd64__) || defined(__i386__) -/* - * Only x86 both define breakpoint() and have a PC after breakpoint so - * that restarting doesn't retrigger the breakpoint. - */ +#if defined(HAVE_BREAKPOINT) && defined(SKIP_BREAK) static void * continue_thread(void *arg __unused) { @@ -3506,6 +3529,7 @@ ATF_TC_BODY(ptrace__PT_CONTINUE_different_thread, tc) pid_t fpid, wpid; lwpid_t lwps[2]; bool hit_break[2]; + struct reg reg; int i, j, status; ATF_REQUIRE((fpid = fork()) != -1); @@ -3579,6 +3603,9 @@ ATF_TC_BODY(ptrace__PT_CONTINUE_different_thread, tc) else i = 1; hit_break[i] = true; + ATF_REQUIRE(ptrace(PT_GETREGS, pl.pl_lwpid, (caddr_t)®, 0) != -1); + SKIP_BREAK(®); + ATF_REQUIRE(ptrace(PT_SETREGS, pl.pl_lwpid, (caddr_t)®, 0) != -1); /* * Resume both threads but pass the other thread's LWPID to @@ -3616,6 +3643,11 @@ ATF_TC_BODY(ptrace__PT_CONTINUE_different_thread, tc) ATF_REQUIRE_MSG(!hit_break[i], "double breakpoint event"); hit_break[i] = true; + ATF_REQUIRE(ptrace(PT_GETREGS, pl.pl_lwpid, (caddr_t)®, + 0) != -1); + SKIP_BREAK(®); + ATF_REQUIRE(ptrace(PT_SETREGS, pl.pl_lwpid, (caddr_t)®, + 0) != -1); } ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); @@ -3663,7 +3695,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, ptrace__event_mask); ATF_TP_ADD_TC(tp, ptrace__ptrace_vfork); ATF_TP_ADD_TC(tp, ptrace__ptrace_vfork_follow); -#if defined(__amd64__) || defined(__i386__) || defined(__sparc64__) +#ifdef HAVE_BREAKPOINT ATF_TP_ADD_TC(tp, ptrace__PT_KILL_breakpoint); #endif ATF_TP_ADD_TC(tp, ptrace__PT_KILL_system_call); @@ -3688,7 +3720,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, ptrace__event_mask_sigkill_discard); ATF_TP_ADD_TC(tp, ptrace__PT_ATTACH_with_SBDRY_thread); ATF_TP_ADD_TC(tp, ptrace__PT_STEP_with_signal); -#if defined(__amd64__) || defined(__i386__) +#if defined(HAVE_BREAKPOINT) && defined(SKIP_BREAK) ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_different_thread); #endif From owner-svn-src-stable@freebsd.org Thu Sep 6 22:30:35 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 20E2DFE7A13; Thu, 6 Sep 2018 22:30:35 +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 CB47D8F52D; Thu, 6 Sep 2018 22:30:34 +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 C64AF134F7; Thu, 6 Sep 2018 22:30:34 +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 w86MUYQX068357; Thu, 6 Sep 2018 22:30:34 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w86MUYvF068356; Thu, 6 Sep 2018 22:30:34 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201809062230.w86MUYvF068356@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 6 Sep 2018 22:30: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: r338515 - stable/11/sys/mips/mips X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/11/sys/mips/mips X-SVN-Commit-Revision: 338515 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2018 22:30:35 -0000 Author: jhb Date: Thu Sep 6 22:30:34 2018 New Revision: 338515 URL: https://svnweb.freebsd.org/changeset/base/338515 Log: MFC 332909: Report proper signal codes for SIGTRAP traps on MIPS. - Use TRAP_TRACE for traps after stepping via PT_STEP. - Use TRAP_BRKPT for software breakpoint traps and watchpoint traps. This was tested via the recently added siginfo ptrace() tests. PT_STEP on MIPS has several bugs that prevent it from working yet, but this does fix the ptrace__breakpoint_siginfo test on MIPS. Modified: stable/11/sys/mips/mips/trap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/mips/mips/trap.c ============================================================================== --- stable/11/sys/mips/mips/trap.c Thu Sep 6 22:23:39 2018 (r338514) +++ stable/11/sys/mips/mips/trap.c Thu Sep 6 22:30:34 2018 (r338515) @@ -852,6 +852,7 @@ dofault: if (td->td_md.md_ss_addr != va || instr != MIPS_BREAK_SSTEP) { i = SIGTRAP; + ucode = TRAP_BRKPT; addr = trapframe->pc; break; } @@ -863,6 +864,7 @@ dofault: */ addr = trapframe->pc; i = SIGTRAP; + ucode = TRAP_TRACE; break; } @@ -877,6 +879,7 @@ dofault: va += sizeof(int); printf("watch exception @ %p\n", (void *)va); i = SIGTRAP; + ucode = TRAP_BRKPT; addr = va; break; } From owner-svn-src-stable@freebsd.org Thu Sep 6 22:33:00 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5599DFE7CE2; Thu, 6 Sep 2018 22:33:00 +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 F064D8F9AB; Thu, 6 Sep 2018 22:32:59 +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 E592913683; Thu, 6 Sep 2018 22:32:59 +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 w86MWxpj072899; Thu, 6 Sep 2018 22:32:59 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w86MWxDA072898; Thu, 6 Sep 2018 22:32:59 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201809062232.w86MWxDA072898@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 6 Sep 2018 22:32:59 +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: r338516 - stable/11/tests/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/11/tests/sys/kern X-SVN-Commit-Revision: 338516 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2018 22:33:00 -0000 Author: jhb Date: Thu Sep 6 22:32:59 2018 New Revision: 338516 URL: https://svnweb.freebsd.org/changeset/base/338516 Log: MFC 332908: Add two tests for TRAP_* signal codes for SIGTRAP. - ptrace__breakpoint_siginfo tests that a SIGTRAP for a software breakpoint in userland triggers a SIGTRAP with a signal code of TRAP_BRKPT. - ptrace__step_siginfo tests that a SIGTRAP reported for a step after stepping via PT_STEP or PT_SETSTEP has a signal code of TRAP_TRACE. Modified: stable/11/tests/sys/kern/ptrace_test.c Directory Properties: stable/11/ (props changed) Modified: stable/11/tests/sys/kern/ptrace_test.c ============================================================================== --- stable/11/tests/sys/kern/ptrace_test.c Thu Sep 6 22:30:34 2018 (r338515) +++ stable/11/tests/sys/kern/ptrace_test.c Thu Sep 6 22:32:59 2018 (r338516) @@ -3495,6 +3495,110 @@ ATF_TC_BODY(ptrace__PT_STEP_with_signal, tc) ATF_REQUIRE(errno == ECHILD); } +#ifdef HAVE_BREAKPOINT +/* + * Verify that a SIGTRAP event with the TRAP_BRKPT code is reported + * for a breakpoint trap. + */ +ATF_TC_WITHOUT_HEAD(ptrace__breakpoint_siginfo); +ATF_TC_BODY(ptrace__breakpoint_siginfo, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + breakpoint(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Continue the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The second wait() should report hitting the breakpoint. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE((pl.pl_flags & PL_FLAG_SI) != 0); + ATF_REQUIRE(pl.pl_siginfo.si_signo == SIGTRAP); + ATF_REQUIRE(pl.pl_siginfo.si_code == TRAP_BRKPT); + + /* Kill the child process. */ + ATF_REQUIRE(ptrace(PT_KILL, fpid, 0, 0) == 0); + + /* The last wait() should report the SIGKILL. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSIGNALED(status)); + ATF_REQUIRE(WTERMSIG(status) == SIGKILL); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} +#endif /* HAVE_BREAKPOINT */ + +/* + * Verify that a SIGTRAP event with the TRAP_TRACE code is reported + * for a single-step trap from PT_STEP. + */ +ATF_TC_WITHOUT_HEAD(ptrace__step_siginfo); +ATF_TC_BODY(ptrace__step_siginfo, tc) +{ + struct ptrace_lwpinfo pl; + pid_t fpid, wpid; + int status; + + ATF_REQUIRE((fpid = fork()) != -1); + if (fpid == 0) { + trace_me(); + exit(1); + } + + /* The first wait() should report the stop from SIGSTOP. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP); + + /* Step the child ignoring the SIGSTOP. */ + ATF_REQUIRE(ptrace(PT_STEP, fpid, (caddr_t)1, 0) == 0); + + /* The second wait() should report a single-step trap. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(wpid == fpid); + ATF_REQUIRE(WIFSTOPPED(status)); + ATF_REQUIRE(WSTOPSIG(status) == SIGTRAP); + + ATF_REQUIRE(ptrace(PT_LWPINFO, wpid, (caddr_t)&pl, sizeof(pl)) != -1); + ATF_REQUIRE((pl.pl_flags & PL_FLAG_SI) != 0); + ATF_REQUIRE(pl.pl_siginfo.si_signo == SIGTRAP); + ATF_REQUIRE(pl.pl_siginfo.si_code == TRAP_TRACE); + + /* Continue the child process. */ + ATF_REQUIRE(ptrace(PT_CONTINUE, fpid, (caddr_t)1, 0) == 0); + + /* The last event should be for the child process's exit. */ + wpid = waitpid(fpid, &status, 0); + ATF_REQUIRE(WIFEXITED(status)); + ATF_REQUIRE(WEXITSTATUS(status) == 1); + + wpid = wait(&status); + ATF_REQUIRE(wpid == -1); + ATF_REQUIRE(errno == ECHILD); +} + #if defined(HAVE_BREAKPOINT) && defined(SKIP_BREAK) static void * continue_thread(void *arg __unused) @@ -3720,6 +3824,10 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, ptrace__event_mask_sigkill_discard); ATF_TP_ADD_TC(tp, ptrace__PT_ATTACH_with_SBDRY_thread); ATF_TP_ADD_TC(tp, ptrace__PT_STEP_with_signal); +#ifdef HAVE_BREAKPOINT + ATF_TP_ADD_TC(tp, ptrace__breakpoint_siginfo); +#endif + ATF_TP_ADD_TC(tp, ptrace__step_siginfo); #if defined(HAVE_BREAKPOINT) && defined(SKIP_BREAK) ATF_TP_ADD_TC(tp, ptrace__PT_CONTINUE_different_thread); #endif From owner-svn-src-stable@freebsd.org Fri Sep 7 10:34:28 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B5BB3FF7582; Fri, 7 Sep 2018 10:34:28 +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 69BBC83E45; Fri, 7 Sep 2018 10:34:28 +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 5F4221AC26; Fri, 7 Sep 2018 10:34:28 +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 w87AYS8v040351; Fri, 7 Sep 2018 10:34:28 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w87AYSp3040350; Fri, 7 Sep 2018 10:34:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201809071034.w87AYSp3040350@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 7 Sep 2018 10:34:28 +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: r338521 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 338521 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Sep 2018 10:34:28 -0000 Author: kib Date: Fri Sep 7 10:34:27 2018 New Revision: 338521 URL: https://svnweb.freebsd.org/changeset/base/338521 Log: MFC r338459: amd64: For non-PTI mode, do not initialize PCPU kcr3 to KPML4phys. Modified: stable/11/sys/amd64/amd64/pmap.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/pmap.c ============================================================================== --- stable/11/sys/amd64/amd64/pmap.c Fri Sep 7 00:12:46 2018 (r338520) +++ stable/11/sys/amd64/amd64/pmap.c Fri Sep 7 10:34:27 2018 (r338521) @@ -7526,9 +7526,13 @@ pmap_activate_boot(pmap_t pmap) CPU_SET(cpuid, &pmap->pm_active); #endif PCPU_SET(curpmap, pmap); - kcr3 = pmap->pm_cr3; - if (pmap_pcid_enabled) - kcr3 |= pmap->pm_pcids[cpuid].pm_pcid | CR3_PCID_SAVE; + if (pti) { + kcr3 = pmap->pm_cr3; + if (pmap_pcid_enabled) + kcr3 |= pmap->pm_pcids[cpuid].pm_pcid | CR3_PCID_SAVE; + } else { + kcr3 = PMAP_NO_CR3; + } PCPU_SET(kcr3, kcr3); PCPU_SET(ucr3, PMAP_NO_CR3); } From owner-svn-src-stable@freebsd.org Sat Sep 8 04:09:35 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BB928FE6D10; Sat, 8 Sep 2018 04:09:34 +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 648EB84133; Sat, 8 Sep 2018 04:09:34 +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 4FF6A258B7; Sat, 8 Sep 2018 04:09:34 +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 w8849YkR080106; Sat, 8 Sep 2018 04:09:34 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w8849ULG080094; Sat, 8 Sep 2018 04:09:30 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201809080409.w8849ULG080094@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sat, 8 Sep 2018 04:09:30 +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: r338530 - in stable/11: contrib/ntp contrib/ntp/html contrib/ntp/include contrib/ntp/libntp contrib/ntp/ntpd contrib/ntp/ntpdate contrib/ntp/ntpdc contrib/ntp/ntpq contrib/ntp/ntpsnmpd ... X-SVN-Group: stable-11 X-SVN-Commit-Author: delphij X-SVN-Commit-Paths: in stable/11: contrib/ntp contrib/ntp/html contrib/ntp/include contrib/ntp/libntp contrib/ntp/ntpd contrib/ntp/ntpdate contrib/ntp/ntpdc contrib/ntp/ntpq contrib/ntp/ntpsnmpd contrib/ntp/scripts contr... X-SVN-Commit-Revision: 338530 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 08 Sep 2018 04:09:35 -0000 Author: delphij Date: Sat Sep 8 04:09:30 2018 New Revision: 338530 URL: https://svnweb.freebsd.org/changeset/base/338530 Log: MFC r338126: MFV r338092: ntp 4.2.8p12. Relnotes: yes Modified: stable/11/contrib/ntp/ChangeLog stable/11/contrib/ntp/NEWS stable/11/contrib/ntp/config.h.in stable/11/contrib/ntp/configure stable/11/contrib/ntp/configure.ac stable/11/contrib/ntp/html/authentic.html stable/11/contrib/ntp/html/authopt.html stable/11/contrib/ntp/html/confopt.html stable/11/contrib/ntp/html/keygen.html stable/11/contrib/ntp/html/ntpdate.html stable/11/contrib/ntp/include/ntp.h stable/11/contrib/ntp/include/ntp_md5.h stable/11/contrib/ntp/libntp/a_md5encrypt.c stable/11/contrib/ntp/libntp/ntp_calendar.c stable/11/contrib/ntp/libntp/prettydate.c stable/11/contrib/ntp/libntp/ssl_init.c stable/11/contrib/ntp/libntp/syssignal.c stable/11/contrib/ntp/libntp/work_fork.c stable/11/contrib/ntp/libntp/work_thread.c stable/11/contrib/ntp/ntpd/complete.conf.in stable/11/contrib/ntp/ntpd/invoke-ntp.conf.texi stable/11/contrib/ntp/ntpd/invoke-ntp.keys.texi stable/11/contrib/ntp/ntpd/invoke-ntpd.texi stable/11/contrib/ntp/ntpd/ntp.conf.5man stable/11/contrib/ntp/ntpd/ntp.conf.5mdoc stable/11/contrib/ntp/ntpd/ntp.conf.def stable/11/contrib/ntp/ntpd/ntp.conf.html stable/11/contrib/ntp/ntpd/ntp.conf.man.in stable/11/contrib/ntp/ntpd/ntp.conf.mdoc.in stable/11/contrib/ntp/ntpd/ntp.keys.5man stable/11/contrib/ntp/ntpd/ntp.keys.5mdoc stable/11/contrib/ntp/ntpd/ntp.keys.def stable/11/contrib/ntp/ntpd/ntp.keys.html stable/11/contrib/ntp/ntpd/ntp.keys.man.in stable/11/contrib/ntp/ntpd/ntp.keys.mdoc.in stable/11/contrib/ntp/ntpd/ntp_config.c stable/11/contrib/ntp/ntpd/ntp_control.c stable/11/contrib/ntp/ntpd/ntp_io.c stable/11/contrib/ntp/ntpd/ntp_loopfilter.c stable/11/contrib/ntp/ntpd/ntp_parser.c stable/11/contrib/ntp/ntpd/ntp_parser.h stable/11/contrib/ntp/ntpd/ntp_proto.c stable/11/contrib/ntp/ntpd/ntp_refclock.c stable/11/contrib/ntp/ntpd/ntp_request.c stable/11/contrib/ntp/ntpd/ntpd-opts.c stable/11/contrib/ntp/ntpd/ntpd-opts.h stable/11/contrib/ntp/ntpd/ntpd.1ntpdman stable/11/contrib/ntp/ntpd/ntpd.1ntpdmdoc stable/11/contrib/ntp/ntpd/ntpd.c stable/11/contrib/ntp/ntpd/ntpd.html stable/11/contrib/ntp/ntpd/ntpd.man.in stable/11/contrib/ntp/ntpd/ntpd.mdoc.in stable/11/contrib/ntp/ntpd/rc_cmdlength.c stable/11/contrib/ntp/ntpd/refclock_datum.c stable/11/contrib/ntp/ntpd/refclock_gpsdjson.c stable/11/contrib/ntp/ntpd/refclock_jupiter.c stable/11/contrib/ntp/ntpd/refclock_shm.c stable/11/contrib/ntp/ntpd/refclock_true.c stable/11/contrib/ntp/ntpdate/ntpdate.c stable/11/contrib/ntp/ntpdc/invoke-ntpdc.texi stable/11/contrib/ntp/ntpdc/ntpdc-opts.c stable/11/contrib/ntp/ntpdc/ntpdc-opts.h stable/11/contrib/ntp/ntpdc/ntpdc.1ntpdcman stable/11/contrib/ntp/ntpdc/ntpdc.1ntpdcmdoc stable/11/contrib/ntp/ntpdc/ntpdc.c stable/11/contrib/ntp/ntpdc/ntpdc.html stable/11/contrib/ntp/ntpdc/ntpdc.man.in stable/11/contrib/ntp/ntpdc/ntpdc.mdoc.in stable/11/contrib/ntp/ntpq/invoke-ntpq.texi stable/11/contrib/ntp/ntpq/ntpq-opts.c stable/11/contrib/ntp/ntpq/ntpq-opts.h stable/11/contrib/ntp/ntpq/ntpq-subs.c stable/11/contrib/ntp/ntpq/ntpq.1ntpqman stable/11/contrib/ntp/ntpq/ntpq.1ntpqmdoc stable/11/contrib/ntp/ntpq/ntpq.c stable/11/contrib/ntp/ntpq/ntpq.html stable/11/contrib/ntp/ntpq/ntpq.man.in stable/11/contrib/ntp/ntpq/ntpq.mdoc.in stable/11/contrib/ntp/ntpq/ntpq.texi stable/11/contrib/ntp/ntpsnmpd/invoke-ntpsnmpd.texi stable/11/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.c stable/11/contrib/ntp/ntpsnmpd/ntpsnmpd-opts.h stable/11/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdman stable/11/contrib/ntp/ntpsnmpd/ntpsnmpd.1ntpsnmpdmdoc stable/11/contrib/ntp/ntpsnmpd/ntpsnmpd.html stable/11/contrib/ntp/ntpsnmpd/ntpsnmpd.man.in stable/11/contrib/ntp/ntpsnmpd/ntpsnmpd.mdoc.in stable/11/contrib/ntp/packageinfo.sh stable/11/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjman stable/11/contrib/ntp/scripts/calc_tickadj/calc_tickadj.1calc_tickadjmdoc stable/11/contrib/ntp/scripts/calc_tickadj/calc_tickadj.html stable/11/contrib/ntp/scripts/calc_tickadj/calc_tickadj.man.in stable/11/contrib/ntp/scripts/calc_tickadj/calc_tickadj.mdoc.in stable/11/contrib/ntp/scripts/calc_tickadj/invoke-calc_tickadj.texi stable/11/contrib/ntp/scripts/invoke-plot_summary.texi stable/11/contrib/ntp/scripts/invoke-summary.texi stable/11/contrib/ntp/scripts/ntp-wait/invoke-ntp-wait.texi stable/11/contrib/ntp/scripts/ntp-wait/ntp-wait-opts stable/11/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitman stable/11/contrib/ntp/scripts/ntp-wait/ntp-wait.1ntp-waitmdoc stable/11/contrib/ntp/scripts/ntp-wait/ntp-wait.html stable/11/contrib/ntp/scripts/ntp-wait/ntp-wait.man.in stable/11/contrib/ntp/scripts/ntp-wait/ntp-wait.mdoc.in stable/11/contrib/ntp/scripts/ntpsweep/invoke-ntpsweep.texi stable/11/contrib/ntp/scripts/ntpsweep/ntpsweep-opts stable/11/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepman stable/11/contrib/ntp/scripts/ntpsweep/ntpsweep.1ntpsweepmdoc stable/11/contrib/ntp/scripts/ntpsweep/ntpsweep.html stable/11/contrib/ntp/scripts/ntpsweep/ntpsweep.man.in stable/11/contrib/ntp/scripts/ntpsweep/ntpsweep.mdoc.in stable/11/contrib/ntp/scripts/ntptrace/invoke-ntptrace.texi stable/11/contrib/ntp/scripts/ntptrace/ntptrace-opts stable/11/contrib/ntp/scripts/ntptrace/ntptrace.1ntptraceman stable/11/contrib/ntp/scripts/ntptrace/ntptrace.1ntptracemdoc stable/11/contrib/ntp/scripts/ntptrace/ntptrace.html stable/11/contrib/ntp/scripts/ntptrace/ntptrace.man.in stable/11/contrib/ntp/scripts/ntptrace/ntptrace.mdoc.in stable/11/contrib/ntp/scripts/plot_summary-opts stable/11/contrib/ntp/scripts/plot_summary.1plot_summaryman stable/11/contrib/ntp/scripts/plot_summary.1plot_summarymdoc stable/11/contrib/ntp/scripts/plot_summary.html stable/11/contrib/ntp/scripts/plot_summary.man.in stable/11/contrib/ntp/scripts/plot_summary.mdoc.in stable/11/contrib/ntp/scripts/summary-opts stable/11/contrib/ntp/scripts/summary.1summaryman stable/11/contrib/ntp/scripts/summary.1summarymdoc stable/11/contrib/ntp/scripts/summary.html stable/11/contrib/ntp/scripts/summary.man.in stable/11/contrib/ntp/scripts/summary.mdoc.in stable/11/contrib/ntp/scripts/update-leap/invoke-update-leap.texi stable/11/contrib/ntp/scripts/update-leap/update-leap-opts stable/11/contrib/ntp/scripts/update-leap/update-leap.1update-leapman stable/11/contrib/ntp/scripts/update-leap/update-leap.1update-leapmdoc stable/11/contrib/ntp/scripts/update-leap/update-leap.html stable/11/contrib/ntp/scripts/update-leap/update-leap.man.in stable/11/contrib/ntp/scripts/update-leap/update-leap.mdoc.in stable/11/contrib/ntp/sntp/config.h.in stable/11/contrib/ntp/sntp/configure stable/11/contrib/ntp/sntp/crypto.c stable/11/contrib/ntp/sntp/include/version.def stable/11/contrib/ntp/sntp/include/version.texi stable/11/contrib/ntp/sntp/invoke-sntp.texi stable/11/contrib/ntp/sntp/m4/ntp_libntp.m4 stable/11/contrib/ntp/sntp/m4/ntp_openssl.m4 stable/11/contrib/ntp/sntp/m4/version.m4 stable/11/contrib/ntp/sntp/main.c stable/11/contrib/ntp/sntp/sntp-opts.c stable/11/contrib/ntp/sntp/sntp-opts.h stable/11/contrib/ntp/sntp/sntp.1sntpman stable/11/contrib/ntp/sntp/sntp.1sntpmdoc stable/11/contrib/ntp/sntp/sntp.html stable/11/contrib/ntp/sntp/sntp.man.in stable/11/contrib/ntp/sntp/sntp.mdoc.in stable/11/contrib/ntp/sntp/tests/crypto.c stable/11/contrib/ntp/sntp/tests/packetProcessing.c stable/11/contrib/ntp/sntp/version.c stable/11/contrib/ntp/util/invoke-ntp-keygen.texi stable/11/contrib/ntp/util/ntp-keygen-opts.c stable/11/contrib/ntp/util/ntp-keygen-opts.def stable/11/contrib/ntp/util/ntp-keygen-opts.h stable/11/contrib/ntp/util/ntp-keygen.1ntp-keygenman stable/11/contrib/ntp/util/ntp-keygen.1ntp-keygenmdoc stable/11/contrib/ntp/util/ntp-keygen.html stable/11/contrib/ntp/util/ntp-keygen.man.in stable/11/contrib/ntp/util/ntp-keygen.mdoc.in stable/11/contrib/ntp/util/ntp-keygen.texi stable/11/contrib/ntp/util/sht.c stable/11/usr.sbin/ntp/config.h stable/11/usr.sbin/ntp/doc/ntp-keygen.8 stable/11/usr.sbin/ntp/doc/ntp.conf.5 stable/11/usr.sbin/ntp/doc/ntp.keys.5 stable/11/usr.sbin/ntp/doc/ntpd.8 stable/11/usr.sbin/ntp/doc/ntpdc.8 stable/11/usr.sbin/ntp/doc/ntpq.8 stable/11/usr.sbin/ntp/doc/sntp.8 stable/11/usr.sbin/ntp/scripts/mkver Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/ntp/ChangeLog ============================================================================== --- stable/11/contrib/ntp/ChangeLog Fri Sep 7 23:12:17 2018 (r338529) +++ stable/11/contrib/ntp/ChangeLog Sat Sep 8 04:09:30 2018 (r338530) @@ -1,5 +1,69 @@ --- +(4.2.8p12) 2018/08/14 Released by Harlan Stenn +* [Sec 3505] CVE-2018-12327 - Arbitrary Code Execution Vulnerability + - fixed stack buffer overflow in the openhost() command-line call + of NTPQ/NTPDC +* [Sec 3012] noepeer tweaks. +* [Bug 3521] Fix a logic bug in the INVALIDNAK checks. +* [Bug 3509] Add support for running as non-root on FreeBSD, Darwin, + other TrustedBSD platforms + - applied patch by Ian Lepore +* [Bug 3506] Service Control Manager interacts poorly with NTPD + - changed interaction with SCM to signal pending startup +* [Bug 3486] Buffer overflow in ntpq/ntpq.c:tstflags() + - applied patch by Gerry Garvey +* [Bug 3485] Undefined sockaddr used in error messages in ntp_config.c + - applied patch by Gerry Garvey +* [Bug 3484] ntpq response from ntpd is incorrect when REFID is null + - rework of ntpq 'nextvar()' key/value parsing +* [Bug 3482] Fixes for compilation warnings (ntp_io.c & ntpq-subs.c) + - applied patch by Gerry Garvey (with mods) +* [Bug 3480] Refclock sample filter not cleared on clock STEP + - applied patch by Gerry Garvey +* [Bug 3479] ctl_putrefid() allows unsafe characters through to ntpq + - applied patch by Gerry Garvey (with mods) +* [Bug 3476]ctl_putstr() sends empty unquoted string [...] + - applied patch by Gerry Garvey (with mods); not sure if that's bug or feature, though +* [Bug 3475] modify prettydate() to suppress output of zero time + - applied patch by Gerry Garvey +* [Bug 3474] Missing pmode in mode7 peer info response + - applied patch by Gerry Garvey +* [Bug 3471] Check for openssl/[ch]mac.h. HStenn. + - add #define ENABLE_CMAC support in configure. HStenn. +* [Bug 3470] ntpd4.2.8p11 fails to compile without OpenSSL +* [Bug 3469] Incomplete string compare [...] in is_refclk_addr + - patch by Stephen Friedl +* [Bug 3467] Potential memory fault in ntpq [...] + - fixed IO redirection and CTRL-C handling in ntq and ntpdc +* [Bug 3465] Default TTL values cannot be used +* [Bug 3461] refclock_shm.c: clear error status on clock recovery + - initial patch by Hal Murray; also fixed refclock_report() trouble +* [Bug 3460] Fix typo in ntpq.texi, reported by Kenyon Ralph. +* [Bug 3456] Use uintptr_t rather than size_t to store an integer in a pointer + - According to Brooks Davis, there was only one location +* [Bug 3449] ntpq - display "loop" instead of refid [...] + - applied patch by Gerry Garvey +* [Bug 3445] Symmetric peer won't sync on startup + - applied patch by Gerry Garvey +* [Bug 3442] Fixes for ntpdate as suggested by Gerry Garvey, + with modifications + New macro REFID_ISTEXT() which is also used in ntpd/ntp_control.c. +* [Bug 3434] ntpd clears STA_UNSYNC on start + - applied patch by Miroslav Lichvar +* [Bug 3426] ntpdate.html -t default is 2 seconds. Leonid Evdokimov. +* [Bug 3121] Drop root privileges for the forked DNS worker + - integrated patch by Reinhard Max +* [Bug 2821] minor build issues + - applied patches by Christos Zoulas, including real bug fixes +* html/authopt.html: cleanup, from +* ntpd/ntpd.c: DROPROOT cleanup. +* Symmetric key range is 1-65535. Update docs. +* html/authentic.html: cleanup, from + +--- +(4.2.8p11) 2018/02/27 Released by Harlan Stenn + * [Sec 3454] Unauthenticated packet can reset authenticated interleave associations. HStenn. * [Sec 3453] Interleaved symmetric mode cannot recover from bad state. HStenn. @@ -14,16 +78,16 @@ - applied patch by Sean Haugh * [Bug 3452] PARSE driver prints uninitialized memory. * [Bug 3450] Dubious error messages from plausibility checks in get_systime() - - removed error log caused by rounding/slew, ensured postcondition + - removed error log caused by rounding/slew, ensured postcondition * [Bug 3447] AES-128-CMAC (fixes) - refactoring the MAC code, too * [Bug 3441] Validate the assumption that AF_UNSPEC is 0. stenn@ntp.org * [Bug 3439] When running multiple commands / hosts in ntpq... - - applied patch by ggarvey + - applied patch by ggarvey * [Bug 3438] Negative values and values > 999 days in... - - applied patch by ggarvey (with minor mods) + - applied patch by ggarvey (with minor mods) * [Bug 3437] ntpd tries to open socket with AF_UNSPEC domain - - applied patch (with mods) by Miroslav Lichvar + - applied patch (with mods) by Miroslav Lichvar * [Bug 3435] anchor NTP era alignment * [Bug 3433] sntp crashes when run with -a. * [Bug 3430] ntpq dumps core (SIGSEGV) for "keytype md2" Modified: stable/11/contrib/ntp/NEWS ============================================================================== --- stable/11/contrib/ntp/NEWS Fri Sep 7 23:12:17 2018 (r338529) +++ stable/11/contrib/ntp/NEWS Sat Sep 8 04:09:30 2018 (r338530) @@ -1,7 +1,78 @@ -- -NTP 4.2.8p11 (Harlan Stenn , 2018/02/27) +NTP 4.2.8p12 (Harlan Stenn , 2018/14/09) NOTE: this NEWS file will be undergoing more revisions. + +Focus: Security, Bug fixes, enhancements. + +Severity: MEDIUM + +This release fixes a "hole" in the noepeer capability introduced to ntpd +in ntp-4.2.8p11, and a buffer overflow in the openhost() function used by +ntpq and ntpdc. It also provides 26 other bugfixes, and 4 other improvements: + +* [Sec 3505] Buffer overflow in the openhost() call of ntpq and ntpdc. + +* [Sec 3012] Fix a hole in the new "noepeer" processing. + +* Bug Fixes: + [Bug 3521] Fix a logic bug in the INVALIDNAK checks. + [Bug 3509] Add support for running as non-root on FreeBSD, Darwin, + other TrustedBSD platforms + - applied patch by Ian Lepore + [Bug 3506] Service Control Manager interacts poorly with NTPD + - changed interaction with SCM to signal pending startup + [Bug 3486] Buffer overflow in ntpq/ntpq.c:tstflags() + - applied patch by Gerry Garvey + [Bug 3485] Undefined sockaddr used in error messages in ntp_config.c + - applied patch by Gerry Garvey + [Bug 3484] ntpq response from ntpd is incorrect when REFID is null + - rework of ntpq 'nextvar()' key/value parsing + [Bug 3482] Fixes for compilation warnings (ntp_io.c & ntpq-subs.c) + - applied patch by Gerry Garvey (with mods) + [Bug 3480] Refclock sample filter not cleared on clock STEP + - applied patch by Gerry Garvey + [Bug 3479] ctl_putrefid() allows unsafe characters through to ntpq + - applied patch by Gerry Garvey (with mods) + [Bug 3476]ctl_putstr() sends empty unquoted string [...] + - applied patch by Gerry Garvey (with mods); not sure if that's bug or feature, though + [Bug 3475] modify prettydate() to suppress output of zero time + - applied patch by Gerry Garvey + [Bug 3474] Missing pmode in mode7 peer info response + - applied patch by Gerry Garvey + [Bug 3471] Check for openssl/[ch]mac.h. HStenn. + - add #define ENABLE_CMAC support in configure. HStenn. + [Bug 3470] ntpd4.2.8p11 fails to compile without OpenSSL + [Bug 3469] Incomplete string compare [...] in is_refclk_addr + - patch by Stephen Friedl + [Bug 3467] Potential memory fault in ntpq [...] + - fixed IO redirection and CTRL-C handling in ntq and ntpdc + [Bug 3465] Default TTL values cannot be used + [Bug 3461] refclock_shm.c: clear error status on clock recovery + - initial patch by Hal Murray; also fixed refclock_report() trouble + [Bug 3460] Fix typo in ntpq.texi, reported by Kenyon Ralph. + [Bug 3456] Use uintptr_t rather than size_t to store an integer in a pointer + - According to Brooks Davis, there was only one location + [Bug 3449] ntpq - display "loop" instead of refid [...] + - applied patch by Gerry Garvey + [Bug 3445] Symmetric peer won't sync on startup + - applied patch by Gerry Garvey + [Bug 3442] Fixes for ntpdate as suggested by Gerry Garvey, + with modifications + New macro REFID_ISTEXT() which is also used in ntpd/ntp_control.c. + [Bug 3434] ntpd clears STA_UNSYNC on start + - applied patch by Miroslav Lichvar + [Bug 3426] ntpdate.html -t default is 2 seconds. Leonid Evdokimov. + [Bug 3121] Drop root privileges for the forked DNS worker + - integrated patch by Reinhard Max + [Bug 2821] minor build issues + - applied patches by Christos Zoulas, including real bug fixes + html/authopt.html: cleanup, from + ntpd/ntpd.c: DROPROOT cleanup. + Symmetric key range is 1-65535. Update docs. + +-- +NTP 4.2.8p11 (Harlan Stenn , 2018/02/27) Focus: Security, Bug fixes, enhancements. Modified: stable/11/contrib/ntp/config.h.in ============================================================================== --- stable/11/contrib/ntp/config.h.in Fri Sep 7 23:12:17 2018 (r338529) +++ stable/11/contrib/ntp/config.h.in Sat Sep 8 04:09:30 2018 (r338530) @@ -311,6 +311,9 @@ /* Provide the explicit 127.0.0.0/8 martian filter? */ #undef ENABLE_BUG3020_FIX +/* Enable CMAC support? */ +#undef ENABLE_CMAC + /* nls support in libopts */ #undef ENABLE_NLS @@ -372,6 +375,14 @@ /* Define to 1 if you have the `daemon' function. */ #undef HAVE_DAEMON +/* Define to 1 if you have the declaration of `siglongjmp', and to 0 if you + don't. */ +#undef HAVE_DECL_SIGLONGJMP + +/* Define to 1 if you have the declaration of `sigsetjmp', and to 0 if you + don't. */ +#undef HAVE_DECL_SIGSETJMP + /* Define to 1 if you have the declaration of `strerror_r', and to 0 if you don't. */ #undef HAVE_DECL_STRERROR_R @@ -653,6 +664,12 @@ /* if you have NT Threads */ #undef HAVE_NT_THREADS +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENSSL_CMAC_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_OPENSSL_HMAC_H + /* Define to 1 if the system has the type `pid_t'. */ #undef HAVE_PID_T @@ -957,6 +974,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_LOCK_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MAC_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_MMAN_H @@ -1116,6 +1136,9 @@ /* Do we have the TIO serial stuff? */ #undef HAVE_TIO_SERIAL_STUFF + +/* Are TrustedBSD MAC policy privileges available? */ +#undef HAVE_TRUSTEDBSD_MAC /* Define to 1 if the system has the type `uint16_t'. */ #undef HAVE_UINT16_T Modified: stable/11/contrib/ntp/configure ============================================================================== --- stable/11/contrib/ntp/configure Fri Sep 7 23:12:17 2018 (r338529) +++ stable/11/contrib/ntp/configure Sat Sep 8 04:09:30 2018 (r338530) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for ntp 4.2.8p11. +# Generated by GNU Autoconf 2.69 for ntp 4.2.8p12. # # Report bugs to . # @@ -590,8 +590,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='ntp' PACKAGE_TARNAME='ntp' -PACKAGE_VERSION='4.2.8p11' -PACKAGE_STRING='ntp 4.2.8p11' +PACKAGE_VERSION='4.2.8p12' +PACKAGE_STRING='ntp 4.2.8p12' PACKAGE_BUGREPORT='http://bugs.ntp.org./' PACKAGE_URL='http://www.ntp.org./' @@ -968,6 +968,7 @@ enable_c99_snprintf enable_clockctl enable_linuxcaps enable_solarisprivs +enable_trustedbsd_mac with_arlib with_net_snmp_config enable_libseccomp @@ -1614,7 +1615,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ntp 4.2.8p11 to adapt to many kinds of systems. +\`configure' configures ntp 4.2.8p12 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1684,7 +1685,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ntp 4.2.8p11:";; + short | recursive ) echo "Configuration of ntp 4.2.8p12:";; esac cat <<\_ACEOF @@ -1731,6 +1732,8 @@ Optional Features and Packages: --enable-clockctl s Use /dev/clockctl for non-root clock control --enable-linuxcaps + Use Linux capabilities for non-root clock control --enable-solarisprivs + Use Solaris privileges for non-root clock control + --enable-trustedbsd-mac s Use TrustedBSD MAC policy for non-root clock + control --with-arlib - deprecated, arlib not distributed --with-net-snmp-config + =net-snmp-config --enable-libseccomp EXPERIMENTAL: enable support for libseccomp @@ -1923,7 +1926,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -ntp configure 4.2.8p11 +ntp configure 4.2.8p12 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2632,7 +2635,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ntp $as_me 4.2.8p11, which was +It was created by ntp $as_me 4.2.8p12, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3633,7 +3636,7 @@ fi # Define the identity of the package. PACKAGE='ntp' - VERSION='4.2.8p11' + VERSION='4.2.8p12' cat >>confdefs.h <<_ACEOF @@ -24026,7 +24029,40 @@ esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_have_solarisprivs" >&5 $as_echo "$ntp_have_solarisprivs" >&6; } -case "$ntp_use_dev_clockctl$ntp_have_linuxcaps$ntp_have_solarisprivs" in +for ac_header in sys/mac.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/mac.h" "ac_cv_header_sys_mac_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_mac_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_MAC_H 1 +_ACEOF + +fi + +done + + +# Check whether --enable-trustedbsd_mac was given. +if test "${enable_trustedbsd_mac+set}" = set; then : + enableval=$enable_trustedbsd_mac; ntp_use_trustedbsd_mac=$enableval + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should use TrustedBSD MAC privileges" >&5 +$as_echo_n "checking if we should use TrustedBSD MAC privileges... " >&6; } + +case "$ntp_use_trustedbsd_mac$ac_cv_header_sys_mac_h" in + yesyes) + +$as_echo "#define HAVE_TRUSTEDBSD_MAC 1" >>confdefs.h + +esac + +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_use_trustedbsd_mac" >&5 +$as_echo "$ntp_use_trustedbsd_mac" >&6; } + +case "$ntp_use_dev_clockctl$ntp_have_linuxcaps$ntp_have_solarisprivs$ntp_use_trustedbsd_mac" in *yes*) $as_echo "#define HAVE_DROPROOT 1" >>confdefs.h @@ -30311,7 +30347,20 @@ $as_echo "$ntp_openssl" >&6; } case "$ntp_openssl" in yes) + for ac_header in openssl/cmac.h openssl/hmac.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF +fi + +done + + $as_echo "#define OPENSSL /**/" >>confdefs.h case "$VER_SUFFIX" in @@ -30534,9 +30583,24 @@ LIBS="$NTPO_SAVED_LIBS" { ntp_openssl_from_pkg_config=; unset ntp_openssl_from_pkg_config;} +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want to enable CMAC support" >&5 +$as_echo_n "checking if we want to enable CMAC support... " >&6; } +case "$ac_cv_header_openssl_cmac_h" in + yes) +$as_echo "#define ENABLE_CMAC 1" >>confdefs.h + ans="yes" + ;; + *) ans="no" + ;; +esac +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5 +$as_echo "$ans" >&6; } + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want to use OpenSSL's crypto random (if available)" >&5 $as_echo_n "checking if we want to use OpenSSL's crypto random (if available)... " >&6; } # Check whether --enable-openssl-random was given. @@ -33223,7 +33287,33 @@ fi ### +ac_fn_c_check_decl "$LINENO" "sigsetjmp" "ac_cv_have_decl_sigsetjmp" "#include +" +if test "x$ac_cv_have_decl_sigsetjmp" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_SIGSETJMP $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "siglongjmp" "ac_cv_have_decl_siglongjmp" "#include +" +if test "x$ac_cv_have_decl_siglongjmp" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_SIGLONGJMP $ac_have_decl +_ACEOF + + +### + + prefix_NONE= exec_prefix_NONE= test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix @@ -33964,7 +34054,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by ntp $as_me 4.2.8p11, which was +This file was extended by ntp $as_me 4.2.8p12, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -34031,7 +34121,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -ntp config.status 4.2.8p11 +ntp config.status 4.2.8p12 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Modified: stable/11/contrib/ntp/configure.ac ============================================================================== --- stable/11/contrib/ntp/configure.ac Fri Sep 7 23:12:17 2018 (r338529) +++ stable/11/contrib/ntp/configure.ac Sat Sep 8 04:09:30 2018 (r338530) @@ -3014,6 +3014,17 @@ AC_MSG_RESULT([$ans]) NTP_OPENSSL +AC_MSG_CHECKING([if we want to enable CMAC support]) +case "$ac_cv_header_openssl_cmac_h" in + yes) + AC_DEFINE([ENABLE_CMAC], [1], [Enable CMAC support?]) + ans="yes" + ;; + *) ans="no" + ;; +esac +AC_MSG_RESULT([$ans]) + NTP_CRYPTO_RAND # if we are using OpenSSL (--with-crypto), by default Autokey is enabled @@ -4377,6 +4388,10 @@ dnl can't be conditionalized. NTP_GOOGLETEST NTP_PROBLEM_TESTS + +### + +AC_CHECK_DECLS([sigsetjmp,siglongjmp], [], [], [[#include ]]) ### Modified: stable/11/contrib/ntp/html/authentic.html ============================================================================== --- stable/11/contrib/ntp/html/authentic.html Fri Sep 7 23:12:17 2018 (r338529) +++ stable/11/contrib/ntp/html/authentic.html Sat Sep 8 04:09:30 2018 (r338530) @@ -1,91 +1,223 @@ - - - -Authentication Support - - - - -

Authentication Support

-giffrom Alice's Adventures in Wonderland, Lewis Carroll -

Our resident cryptographer; now you see him, now you don't.

-

Last update: - 5-Feb-2016 09:13 - UTC

-
-

Related Links

- - -

Table of Contents

- -
-

Introduction

-

This page describes the various cryptographic authentication provisions in NTPv4. Authentication support allows the NTP client to verify that servers are in fact known and trusted and not intruders intending accidentally or intentionally to masquerade as a legitimate server. A detailed discussion of the NTP multi-layer security model and vulnerability analysis is in the white paper NTP Security Analysis.

-

The NTPv3 specification (RFC-1305) defined an authentication scheme properly described as symmetric key cryptography. It used the Data Encryption Standard (DES) algorithm operating in cipher-block chaining (CBC) mode. Subsequently, this algorithm was replaced by the RSA Message Digest 5 (MD5) algorithm commonly called keyed-MD5. Either algorithm computes a message digest or one-way hash which can be used to verify the client has the same message digest as the server. The MD5 message digest algorithm is included in the distribution, so without further cryptographic support, the distribution can be freely exported.

-

If the OpenSSL cryptographic library is installed prior to building the distribution, all message digest algorithms included in the library may be used, including SHA and SHA1. However, if conformance to FIPS 140-2 is required, only a limited subset of these algorithms can be used. This library is available from http://www.openssl.org and can be installed using the procedures outlined in the Building and Installing the Distribution page. Once installed, the configure and build process automatically detects the library and links the library routines -required.

-

In addition to the symmetric key algorithms, this distribution includes support for the Autokey public key algorithms and protocol specified in RFC-5906 "Network Time Protocol Version 4: Autokey Specification". This support is available only if the OpenSSL library has been installed and the --enable-autokey option is used when the distribution is built.

-

Public key cryptography is generally considered more secure than symmetric key cryptography, since the security is based on private and public values which are generated by each participant and where the private value is never revealed. Autokey uses X.509 public certificates, which can be produced by commercial services, the OpenSSL application program, or the ntp-keygen utility program in the NTP software distribution.

-

Note that according to US law, NTP binaries including OpenSSL library components, including the OpenSSL library itself, cannot be exported outside the US without license from the US Department of Commerce. Builders outside the US are advised to obtain the OpenSSL library directly from OpenSSL, which is outside the US, and build outside the US.

-

Authentication is configured separately for each association using the key or autokey option of the server configuration command, as described in the Server Options page. The ntp-keygen page describes the files required for the various authentication schemes. Further details are in the briefings, papers and reports at the NTP project page linked from www.ntp.org.

-

By default, the client sends non-authenticated packets and the server responds with non-authenticated packets. If the client sends authenticated packets, the server responds with authenticated packets if correct, or a crypto-NAK packet if not. In the case of unsolicited packets which might consume significant resources, such as broadcast or symmetric mode packets, authentication is required, unless overridden by a disable auth command. In the current climate of targeted broadcast or "letterbomb" attacks, defeating this requirement would be decidedly dangerous. In any case, the notrust flag, described on the Access Control Options page, can be used to disable access to all but correctly authenticated clients.

-

Symmetric Key Cryptography

-

The original NTPv3 specification (RFC-1305), as well as the current NTPv4 specification (RFC-5905), allows any one of possibly 65,534 message digest keys (excluding zero), each distinguished by a 32-bit key ID, to authenticate an association. The servers and clients involved must agree on the key ID, key type and key to authenticate NTP packets.

-

The message digest is a cryptographic hash computed by an algorithm such as MD5, SHA, or AES-128 CMAC. When authentication is specified, a message authentication code (MAC) is appended to the NTP packet header. The MAC consists of a 32-bit key identifier (key ID) followed by a 128- or 160-bit message digest. The algorithm computes the digest as the hash of a 128- or 160- bit message digest key concatenated with the NTP packet header fields with the exception of the MAC. On transmit, the message digest is computed and inserted in the MAC. On receive, the message digest is computed and compared with the MAC. The packet is accepted only if the two MACs are identical. If a discrepancy is found by the client, the client ignores the packet, but raises an alarm. If this happens at the server, the server returns a special message called a crypto-NAK. Since the crypto-NAK is protected by the loopback test, an intruder cannot disrupt the protocol by sending a bogus crypto -NAK.

-

Keys and related information are specified in a keys file, which must be distributed and stored using secure means beyond the scope of the NTP protocol itself. Besides the keys used for ordinary NTP associations, additional keys can be used as passwords for the ntpq and ntpdc utility programs. Ordinarily, the ntp.keys file is generated by the ntp-keygen program, but it can be constructed and edited using an ordinary text editor.

-

Each line of the keys file consists of three or four fields: a key ID in the range 1 to 65,534, inclusive, a key type, a message digest key consisting of a printable ASCII string less than 40 characters or a 40-character hex digit string, and an optional comma-separated list of IPs that are allowed to serve time. If the OpenSSL library is installed, the key type can be any message digest algorithm supported by the library. If the OpenSSL library is not installed, the only permitted key type is MD5.

- - -
- Figure 1. Typical Symmetric Key File -
-
-# ntpkey_MD5key_bk.ntp.org.3595864945
-# Thu Dec 12 19:22:25 2013
+  
+    
+    
+    Authentication Support
+    
+    
+    
+  
+  
+    

Authentication Support

+ giffrom Alice's Adventures in Wonderland, Lewis Carroll +

Our resident cryptographer; now you see him, now you don't.

+

Last update: + 24-Jul-2018 09:12 + UTC

+
+

Related Links

+ + +

Table of Contents

+ +
+

Introduction

+

This page describes the various cryptographic authentication + provisions in NTPv4. Authentication support allows the NTP client to + verify that servers are in fact known and trusted and not intruders + intending accidentally or intentionally to masquerade as a legitimate + server. A detailed discussion of the NTP multi-layer security model + and vulnerability analysis is in the white + paper NTP + Security Analysis.

+

The NTPv3 specification (RFC-1305) defined an authentication scheme + properly described as symmetric key cryptography. It used + the Data Encryption Standard (DES) algorithm operating in cipher-block + chaining (CBC) mode. Subsequently, this algorithm was replaced by the + RSA Message Digest 5 (MD5) algorithm commonly called keyed-MD5. + Either algorithm computes a message digest or one-way hash which can + be used to verify the client has the same message digest as the + server. The MD5 message digest algorithm is included in the + distribution, so without further cryptographic support, the + distribution can be freely exported.

+

If the OpenSSL cryptographic library is installed prior to building + the distribution, all message digest algorithms included in the + library may be used, including SHA and SHA1. However, if conformance + to FIPS 140-2 is required, only a limited subset of these algorithms + can be used. This library is available + from http://www.openssl.org and + can be installed using the procedures outlined in + the Building and Installing the Distribution + page. Once installed, the configure and build process automatically + detects the library and links the library routines required.

+

In addition to the symmetric key algorithms, this distribution + includes support for the Autokey public key algorithms and protocol + specified in RFC-5906 "Network Time Protocol Version 4: Autokey + Specification". This support is available only if the OpenSSL + library has been installed and the --enable-autokey option is + used when the distribution is built.

+

Public key cryptography is generally considered more secure than + symmetric key cryptography, since the security is based on private and + public values which are generated by each participant and where the + private value is never revealed. Autokey uses X.509 public + certificates, which can be produced by commercial services, the + OpenSSL application program, or + the ntp-keygen utility program in + the NTP software distribution.

+

Note that according to US law, NTP binaries including OpenSSL library + components, including the OpenSSL library itself, cannot be exported + outside the US without license from the US Department of Commerce. + Builders outside the US are advised to obtain the OpenSSL library + directly from OpenSSL, which is outside the US, and build outside the + US.

+

Authentication is configured separately for each association using + the key or autokey option of the server + configuration command, as described in + the Server Options page. + The ntp-keygen page describes the files + required for the various authentication schemes. Further details are + in the briefings, papers and reports at the NTP project page linked + from www.ntp.org.

+

By default, the client sends non-authenticated packets and the server + responds with non-authenticated packets. If the client sends + authenticated packets, the server responds with authenticated packets + if correct, or a crypto-NAK packet if not. In the case of unsolicited + packets which might consume significant resources, such as broadcast + or symmetric mode packets, authentication is required, unless + overridden by a disable auth command. In the current climate + of targeted broadcast or "letterbomb" attacks, defeating + this requirement would be decidedly dangerous. In any case, + the notrust flag, described on + the Access Control Options page, can be + used to disable access to all but correctly authenticated clients.

+

Symmetric Key Cryptography

+

The original NTPv3 specification (RFC-1305), as well as the current + NTPv4 specification (RFC-5905), allows any one of possibly 65,535 + message digest keys (excluding zero), each distinguished by a 32-bit + key ID, to authenticate an association. The servers and clients + involved must agree on the key ID, key type and key to authenticate + NTP packets.

+

The message digest is a cryptographic hash computed by an algorithm + such as MD5, SHA, or AES-128 CMAC. When authentication is specified, + a message authentication code (MAC) is appended to the NTP packet + header. The MAC consists of a 32-bit key identifier (key ID) followed + by a 128- or 160-bit message digest. The algorithm computes the + digest as the hash of a 128- or 160- bit message digest key + concatenated with the NTP packet header fields with the exception of + the MAC. On transmit, the message digest is computed and inserted in + the MAC. On receive, the message digest is computed and compared with + the MAC. The packet is accepted only if the two MACs are identical. + If a discrepancy is found by the client, the client ignores the + packet, but raises an alarm. If this happens at the server, the + server returns a special message called a crypto-NAK. Since + the crypto-NAK is protected by the loopback test, an intruder cannot + disrupt the protocol by sending a bogus crypto-NAK.

+

Keys and related information are specified in a keys file, which must + be distributed and stored using secure means beyond the scope of the + NTP protocol itself. Besides the keys used for ordinary NTP + associations, additional keys can be used as passwords for + the ntpq + and ntpdc utility programs. + Ordinarily, the ntp.keys file is generated by + the ntp-keygen program, but it can + be constructed and edited using an ordinary text editor.

+

Each line of the keys file consists of three or four fields: a key + ID in the range 1 to 65,535, inclusive, a key type, a message digest + key consisting of a printable ASCII string less than 40 characters or + a 40-character hex digit string, and an optional comma-separated list + of IPs that are allowed to serve time. If the OpenSSL library is + installed, the key type can be any message digest algorithm supported + by the library. If the OpenSSL library is not installed, the only + permitted key type is MD5.

+ + +
+ Figure 1. Typical Symmetric Key File +
+
+	    # ntpkey_MD5key_bk.ntp.org.3595864945
+	    # Thu Dec 12 19:22:25 2013
 
-1  MD5 L";Nw<`.I<f4U0)247"i  # MD5 key
-2  MD5 &>l0%XXK9O'51VwV<xq~  # MD5 key
-3  MD5 lb4zLW~d^!K:]RsD'qb6  # MD5 key
-4  MD5 Yue:tL[+vR)M`n~bY,'?  # MD5 key
-5  MD5 B;fxlKgr/&4ZTbL6=RxA  # MD5 key
-6  MD5 4eYwa`o}3i@@V@..R9!l  # MD5 key
-7  MD5 `A.([h+;wTQ|xfi%Sn_!  # MD5 key
-8  MD5 45:V,r4]l6y^JH6"Sh?F  # MD5 key
-9  MD5 3-5vcn*6l29DS?Xdsg)*  # MD5 key
-10 MD5 2late4Me              # MD5 key
-11 SHA1 a27872d3030a9025b8446c751b4551a7629af65c  # SHA1 key
-12 SHA1 21bc3b4865dbb9e920902abdccb3e04ff97a5e74  # SHA1 key
-13 SHA1 2b7736fe24fef5ba85ae11594132ab5d6f6daba9  # SHA1 key
-14 SHA  a5332809c8878dd3a5b918819108a111509aeceb  # SHA  key
-15 MD2  2fe16c88c760ff2f16d4267e36c1aa6c926e6964  # MD2  key
-16 MD4  b2691811dc19cfc0e2f9bcacd74213f29812183d  # MD4  key
-17 MD5  e4d6735b8bdad58ec5ffcb087300a17f7fef1f7c  # MD5  key
-18 MDC2 a8d5e2315c025bf3a79174c87fbd10477de2eabc  # MDC2 key
-19 RIPEMD160 77ca332cafb30e3cafb174dcd5b80ded7ba9b3d2  # RIPEMD160 key
-20 AES128CMAC f92ff73eee86c1e7dc638d6489a04e4e555af878  # AES128CMAC key
-  
-

Figure 1 shows a typical keys file used by the reference implementation when the OpenSSL library is installed. In this figure, for key IDs in he range 1-10, the key is interpreted as a printable ASCII string. For key IDs in the range 11-20, the key is a 40-character hex digit string. The key is truncated or zero-filled internally to either 128 or 160 bits, depending on the key type. The line can be edited later or new lines can be added to change any field. The key can be changed to a password, such as 2late4Me for key ID 10. Note that two or more keys files can be combined in any order as long as the key IDs are distinct.

-

When ntpd is started, it reads the keys file specified by the keys command and installs the keys in the key cache. However, individual keys must be activated with the trustedkey configuration command before use. This allows, for instance, the installation of possibly several batches of keys and then activating a key remotely using ntpq or ntpdc. The requestkey command selects the key ID used as the password for the ntpdc utility, while the controlkey command selects the key ID used as the password for the ntpq utility.

-

Microsoft Windows Authentication

-

In addition to the above means, ntpd now supports Microsoft Windows MS-SNTP authentication using Active Directory services. This support was contributed by the Samba Team and is still in development. It is enabled using the mssntp flag of the restrict command described on the Access Control Options page. Note: Potential users should be aware that these services involve a TCP connection to another process that could potentially block, denying services to other users. Therefore, this flag should be used only for a dedicated server with no clients other than MS-SNTP.

-

Public Key Cryptography

-

See the Autokey Public-Key Authentication page.

-
- - + 1 MD5 L";Nw<`.I<f4U0)247"i # MD5 key + 2 MD5 &>l0%XXK9O'51VwV<xq~ # MD5 key + 3 MD5 lb4zLW~d^!K:]RsD'qb6 # MD5 key + 4 MD5 Yue:tL[+vR)M`n~bY,'? # MD5 key + 5 MD5 B;fxlKgr/&4ZTbL6=RxA # MD5 key + 6 MD5 4eYwa`o}3i@@V@..R9!l # MD5 key + 7 MD5 `A.([h+;wTQ|xfi%Sn_! # MD5 key + 8 MD5 45:V,r4]l6y^JH6"Sh?F # MD5 key + 9 MD5 3-5vcn*6l29DS?Xdsg)* # MD5 key + 10 MD5 2late4Me # MD5 key + 11 SHA1 a27872d3030a9025b8446c751b4551a7629af65c # SHA1 key + 12 SHA1 21bc3b4865dbb9e920902abdccb3e04ff97a5e74 # SHA1 key + 13 SHA1 2b7736fe24fef5ba85ae11594132ab5d6f6daba9 # SHA1 key + 14 SHA a5332809c8878dd3a5b918819108a111509aeceb # SHA key + 15 MD2 2fe16c88c760ff2f16d4267e36c1aa6c926e6964 # MD2 key + 16 MD4 b2691811dc19cfc0e2f9bcacd74213f29812183d # MD4 key + 17 MD5 e4d6735b8bdad58ec5ffcb087300a17f7fef1f7c # MD5 key + 18 MDC2 a8d5e2315c025bf3a79174c87fbd10477de2eabc # MDC2 key + 19 RIPEMD160 77ca332cafb30e3cafb174dcd5b80ded7ba9b3d2 # RIPEMD160 key + 20 AES128CMAC f92ff73eee86c1e7dc638d6489a04e4e555af878 # AES128CMAC key + 21 MD5 sampo 10.1.2.3/24 +
+

Figure 1 shows a typical symmetric keys file used by the reference + implementation when the OpenSSL library is installed. Each line of + the file contains three or four fields. The first field is an integer + between 1 and 65535, inclusive, representing the key identifier. The + second field is the digest algorithm, which in the absence of the + OpenSSL library must be MD5, which designates the MD5 message + digest algorithm. The third field is the key. The optional fourth + field is one or more comma-separated IPs. An IP may end with an + optional /subnetbits suffix, which limits the acceptance of + the key identifier to packets claiming to be from the described IP + space. In this example, for the key IDs in the range 1-10 the key is + interpreted as a printable ASCII string. For the key IDs in the range + 11-20, the key is a 40-character hex digit string. In either case, + the key is truncated or zero-filled internally to either 128 or 160 + bits, depending on the key type. The line can be edited later or new + lines can be added to change any field. The key can be changed to a + password, such as 2late4Me for key ID 10. Note that two or + more keys files can be combined in any order as long as the key IDs + are distinct.

+

When ntpd is started, it reads the keys file specified by + the keys command and installs the keys in the key cache. + However, individual keys must be activated with + the trustedkey configuration command before use. This + allows, for instance, the installation of possibly several batches of + keys and then activating a key remotely using ntpq + or ntpdc. The requestkey command selects the key ID + used as the password for the ntpdc utility, while + the controlkey command selects the key ID used as the + password for the ntpq utility.

+

Microsoft Windows Authentication

+

In addition to the above means, ntpd now supports Microsoft + Windows MS-SNTP authentication using Active Directory services. This + support was contributed by the Samba Team and is still in development. + It is enabled using the mssntp flag of the restrict + command described on the Access Control + Options page. Note: Potential users should + be aware that these services involve a TCP connection to another + process that could potentially block, denying services to other users. + Therefore, this flag should be used only for a dedicated server with + no clients other than MS-SNTP.

+

Public Key Cryptography

+

See the Autokey Public-Key Authentication + page.

+
+ + Modified: stable/11/contrib/ntp/html/authopt.html ============================================================================== --- stable/11/contrib/ntp/html/authopt.html Fri Sep 7 23:12:17 2018 (r338529) +++ stable/11/contrib/ntp/html/authopt.html Sat Sep 8 04:09:30 2018 (r338530) @@ -4,6 +4,7 @@ Authentication Commands and Options + - - -

Authentication Support

-giffrom Alice's Adventures in Wonderland, Lewis Carroll -

Our resident cryptographer; now you see him, now you don't.

-

Last update: - 5-Feb-2016 09:13 - UTC

-
-

Related Links

- - -

Table of Contents

- -
-

Introduction

-

This page describes the various cryptographic authentication provisions in NTPv4. Authentication support allows the NTP client to verify that servers are in fact known and trusted and not intruders intending accidentally or intentionally to masquerade as a legitimate server. A detailed discussion of the NTP multi-layer security model and vulnerability analysis is in the white paper NTP Security Analysis.

-

The NTPv3 specification (RFC-1305) defined an authentication scheme properly described as symmetric key cryptography. It used the Data Encryption Standard (DES) algorithm operating in cipher-block chaining (CBC) mode. Subsequently, this algorithm was replaced by the RSA Message Digest 5 (MD5) algorithm commonly called keyed-MD5. Either algorithm computes a message digest or one-way hash which can be used to verify the client has the same message digest as the server. The MD5 message digest algorithm is included in the distribution, so without further cryptographic support, the distribution can be freely exported.

-

If the OpenSSL cryptographic library is installed prior to building the distribution, all message digest algorithms included in the library may be used, including SHA and SHA1. However, if conformance to FIPS 140-2 is required, only a limited subset of these algorithms can be used. This library is available from http://www.openssl.org and can be installed using the procedures outlined in the Building and Installing the Distribution page. Once installed, the configure and build process automatically detects the library and links the library routines -required.

-

In addition to the symmetric key algorithms, this distribution includes support for the Autokey public key algorithms and protocol specified in RFC-5906 "Network Time Protocol Version 4: Autokey Specification". This support is available only if the OpenSSL library has been installed and the --enable-autokey option is used when the distribution is built.

-

Public key cryptography is generally considered more secure than symmetric key cryptography, since the security is based on private and public values which are generated by each participant and where the private value is never revealed. Autokey uses X.509 public certificates, which can be produced by commercial services, the OpenSSL application program, or the ntp-keygen utility program in the NTP software distribution.

-

Note that according to US law, NTP binaries including OpenSSL library components, including the OpenSSL library itself, cannot be exported outside the US without license from the US Department of Commerce. Builders outside the US are advised to obtain the OpenSSL library directly from OpenSSL, which is outside the US, and build outside the US.

-

Authentication is configured separately for each association using the key or autokey option of the server configuration command, as described in the Server Options page. The ntp-keygen page describes the files required for the various authentication schemes. Further details are in the briefings, papers and reports at the NTP project page linked from www.ntp.org.

-

By default, the client sends non-authenticated packets and the server responds with non-authenticated packets. If the client sends authenticated packets, the server responds with authenticated packets if correct, or a crypto-NAK packet if not. In the case of unsolicited packets which might consume significant resources, such as broadcast or symmetric mode packets, authentication is required, unless overridden by a disable auth command. In the current climate of targeted broadcast or "letterbomb" attacks, defeating this requirement would be decidedly dangerous. In any case, the notrust flag, described on the Access Control Options page, can be used to disable access to all but correctly authenticated clients.

-

Symmetric Key Cryptography

-

The original NTPv3 specification (RFC-1305), as well as the current NTPv4 specification (RFC-5905), allows any one of possibly 65,534 message digest keys (excluding zero), each distinguished by a 32-bit key ID, to authenticate an association. The servers and clients involved must agree on the key ID, key type and key to authenticate NTP packets.

-

The message digest is a cryptographic hash computed by an algorithm such as MD5, SHA, or AES-128 CMAC. When authentication is specified, a message authentication code (MAC) is appended to the NTP packet header. The MAC consists of a 32-bit key identifier (key ID) followed by a 128- or 160-bit message digest. The algorithm computes the digest as the hash of a 128- or 160- bit message digest key concatenated with the NTP packet header fields with the exception of the MAC. On transmit, the message digest is computed and inserted in the MAC. On receive, the message digest is computed and compared with the MAC. The packet is accepted only if the two MACs are identical. If a discrepancy is found by the client, the client ignores the packet, but raises an alarm. If this happens at the server, the server returns a special message called a crypto-NAK. Since the crypto-NAK is protected by the loopback test, an intruder cannot disrupt the protocol by sending a bogus crypto -NAK.

-

Keys and related information are specified in a keys file, which must be distributed and stored using secure means beyond the scope of the NTP protocol itself. Besides the keys used for ordinary NTP associations, additional keys can be used as passwords for the ntpq and ntpdc utility programs. Ordinarily, the ntp.keys file is generated by the ntp-keygen program, but it can be constructed and edited using an ordinary text editor.

-

Each line of the keys file consists of three or four fields: a key ID in the range 1 to 65,534, inclusive, a key type, a message digest key consisting of a printable ASCII string less than 40 characters or a 40-character hex digit string, and an optional comma-separated list of IPs that are allowed to serve time. If the OpenSSL library is installed, the key type can be any message digest algorithm supported by the library. If the OpenSSL library is not installed, the only permitted key type is MD5.

- - -
- Figure 1. Typical Symmetric Key File -
-
-# ntpkey_MD5key_bk.ntp.org.3595864945
-# Thu Dec 12 19:22:25 2013
+  
+    
+    
+    Authentication Support
+    
+    
+    
+  
+  
+    

Authentication Support

+ giffrom Alice's Adventures in Wonderland, Lewis Carroll +

Our resident cryptographer; now you see him, now you don't.

+

Last update: + 24-Jul-2018 09:12 + UTC

+
+

Related Links

+ + +

Table of Contents

+ +
+

Introduction

+

This page describes the various cryptographic authentication + provisions in NTPv4. Authentication support allows the NTP client to + verify that servers are in fact known and trusted and not intruders + intending accidentally or intentionally to masquerade as a legitimate + server. A detailed discussion of the NTP multi-layer security model + and vulnerability analysis is in the white + paper NTP + Security Analysis.

+

The NTPv3 specification (RFC-1305) defined an authentication scheme + properly described as symmetric key cryptography. It used + the Data Encryption Standard (DES) algorithm operating in cipher-block + chaining (CBC) mode. Subsequently, this algorithm was replaced by the + RSA Message Digest 5 (MD5) algorithm commonly called keyed-MD5. + Either algorithm computes a message digest or one-way hash which can + be used to verify the client has the same message digest as the + server. The MD5 message digest algorithm is included in the + distribution, so without further cryptographic support, the + distribution can be freely exported.

+

If the OpenSSL cryptographic library is installed prior to building + the distribution, all message digest algorithms included in the + library may be used, including SHA and SHA1. However, if conformance + to FIPS 140-2 is required, only a limited subset of these algorithms + can be used. This library is available + from http://www.openssl.org and + can be installed using the procedures outlined in + the Building and Installing the Distribution + page. Once installed, the configure and build process automatically + detects the library and links the library routines required.

+

In addition to the symmetric key algorithms, this distribution + includes support for the Autokey public key algorithms and protocol + specified in RFC-5906 "Network Time Protocol Version 4: Autokey + Specification". This support is available only if the OpenSSL + library has been installed and the --enable-autokey option is + used when the distribution is built.

+

Public key cryptography is generally considered more secure than + symmetric key cryptography, since the security is based on private and + public values which are generated by each participant and where the + private value is never revealed. Autokey uses X.509 public + certificates, which can be produced by commercial services, the + OpenSSL application program, or + the ntp-keygen utility program in + the NTP software distribution.

+

Note that according to US law, NTP binaries including OpenSSL library + components, including the OpenSSL library itself, cannot be exported + outside the US without license from the US Department of Commerce. + Builders outside the US are advised to obtain the OpenSSL library + directly from OpenSSL, which is outside the US, and build outside the + US.

+

Authentication is configured separately for each association using + the key or autokey option of the server + configuration command, as described in + the Server Options page. + The ntp-keygen page describes the files + required for the various authentication schemes. Further details are + in the briefings, papers and reports at the NTP project page linked + from www.ntp.org.

+

By default, the client sends non-authenticated packets and the server + responds with non-authenticated packets. If the client sends + authenticated packets, the server responds with authenticated packets + if correct, or a crypto-NAK packet if not. In the case of unsolicited + packets which might consume significant resources, such as broadcast + or symmetric mode packets, authentication is required, unless + overridden by a disable auth command. In the current climate + of targeted broadcast or "letterbomb" attacks, defeating + this requirement would be decidedly dangerous. In any case, + the notrust flag, described on + the Access Control Options page, can be + used to disable access to all but correctly authenticated clients.

+

Symmetric Key Cryptography

+

The original NTPv3 specification (RFC-1305), as well as the current + NTPv4 specification (RFC-5905), allows any one of possibly 65,535 + message digest keys (excluding zero), each distinguished by a 32-bit + key ID, to authenticate an association. The servers and clients + involved must agree on the key ID, key type and key to authenticate + NTP packets.

+

The message digest is a cryptographic hash computed by an algorithm + such as MD5, SHA, or AES-128 CMAC. When authentication is specified, + a message authentication code (MAC) is appended to the NTP packet + header. The MAC consists of a 32-bit key identifier (key ID) followed + by a 128- or 160-bit message digest. The algorithm computes the + digest as the hash of a 128- or 160- bit message digest key + concatenated with the NTP packet header fields with the exception of + the MAC. On transmit, the message digest is computed and inserted in + the MAC. On receive, the message digest is computed and compared with + the MAC. The packet is accepted only if the two MACs are identical. + If a discrepancy is found by the client, the client ignores the + packet, but raises an alarm. If this happens at the server, the + server returns a special message called a crypto-NAK. Since + the crypto-NAK is protected by the loopback test, an intruder cannot + disrupt the protocol by sending a bogus crypto-NAK.

+

Keys and related information are specified in a keys file, which must + be distributed and stored using secure means beyond the scope of the + NTP protocol itself. Besides the keys used for ordinary NTP + associations, additional keys can be used as passwords for + the ntpq + and ntpdc utility programs. + Ordinarily, the ntp.keys file is generated by + the ntp-keygen program, but it can + be constructed and edited using an ordinary text editor.

+

Each line of the keys file consists of three or four fields: a key + ID in the range 1 to 65,535, inclusive, a key type, a message digest + key consisting of a printable ASCII string less than 40 characters or + a 40-character hex digit string, and an optional comma-separated list + of IPs that are allowed to serve time. If the OpenSSL library is + installed, the key type can be any message digest algorithm supported + by the library. If the OpenSSL library is not installed, the only + permitted key type is MD5.

+ + +
+ Figure 1. Typical Symmetric Key File +
+
+	    # ntpkey_MD5key_bk.ntp.org.3595864945
+	    # Thu Dec 12 19:22:25 2013
 
-1  MD5 L";Nw<`.I<f4U0)247"i  # MD5 key
-2  MD5 &>l0%XXK9O'51VwV<xq~  # MD5 key
-3  MD5 lb4zLW~d^!K:]RsD'qb6  # MD5 key
-4  MD5 Yue:tL[+vR)M`n~bY,'?  # MD5 key
-5  MD5 B;fxlKgr/&4ZTbL6=RxA  # MD5 key
-6  MD5 4eYwa`o}3i@@V@..R9!l  # MD5 key
-7  MD5 `A.([h+;wTQ|xfi%Sn_!  # MD5 key
-8  MD5 45:V,r4]l6y^JH6"Sh?F  # MD5 key
-9  MD5 3-5vcn*6l29DS?Xdsg)*  # MD5 key
-10 MD5 2late4Me              # MD5 key
-11 SHA1 a27872d3030a9025b8446c751b4551a7629af65c  # SHA1 key
-12 SHA1 21bc3b4865dbb9e920902abdccb3e04ff97a5e74  # SHA1 key
-13 SHA1 2b7736fe24fef5ba85ae11594132ab5d6f6daba9  # SHA1 key
-14 SHA  a5332809c8878dd3a5b918819108a111509aeceb  # SHA  key
-15 MD2  2fe16c88c760ff2f16d4267e36c1aa6c926e6964  # MD2  key
-16 MD4  b2691811dc19cfc0e2f9bcacd74213f29812183d  # MD4  key
-17 MD5  e4d6735b8bdad58ec5ffcb087300a17f7fef1f7c  # MD5  key
-18 MDC2 a8d5e2315c025bf3a79174c87fbd10477de2eabc  # MDC2 key
-19 RIPEMD160 77ca332cafb30e3cafb174dcd5b80ded7ba9b3d2  # RIPEMD160 key
-20 AES128CMAC f92ff73eee86c1e7dc638d6489a04e4e555af878  # AES128CMAC key
-  
-

Figure 1 shows a typical keys file used by the reference implementation when the OpenSSL library is installed. In this figure, for key IDs in he range 1-10, the key is interpreted as a printable ASCII string. For key IDs in the range 11-20, the key is a 40-character hex digit string. The key is truncated or zero-filled internally to either 128 or 160 bits, depending on the key type. The line can be edited later or new lines can be added to change any field. The key can be changed to a password, such as 2late4Me for key ID 10. Note that two or more keys files can be combined in any order as long as the key IDs are distinct.

-

When ntpd is started, it reads the keys file specified by the keys command and installs the keys in the key cache. However, individual keys must be activated with the trustedkey configuration command before use. This allows, for instance, the installation of possibly several batches of keys and then activating a key remotely using ntpq or ntpdc. The requestkey command selects the key ID used as the password for the ntpdc utility, while the controlkey command selects the key ID used as the password for the ntpq utility.

-

Microsoft Windows Authentication

-

In addition to the above means, ntpd now supports Microsoft Windows MS-SNTP authentication using Active Directory services. This support was contributed by the Samba Team and is still in development. It is enabled using the mssntp flag of the restrict command described on the Access Control Options page. Note: Potential users should be aware that these services involve a TCP connection to another process that could potentially block, denying services to other users. Therefore, this flag should be used only for a dedicated server with no clients other than MS-SNTP.

-

Public Key Cryptography

-

See the Autokey Public-Key Authentication page.

-
- - + 1 MD5 L";Nw<`.I<f4U0)247"i # MD5 key + 2 MD5 &>l0%XXK9O'51VwV<xq~ # MD5 key + 3 MD5 lb4zLW~d^!K:]RsD'qb6 # MD5 key + 4 MD5 Yue:tL[+vR)M`n~bY,'? # MD5 key + 5 MD5 B;fxlKgr/&4ZTbL6=RxA # MD5 key + 6 MD5 4eYwa`o}3i@@V@..R9!l # MD5 key + 7 MD5 `A.([h+;wTQ|xfi%Sn_! # MD5 key + 8 MD5 45:V,r4]l6y^JH6"Sh?F # MD5 key + 9 MD5 3-5vcn*6l29DS?Xdsg)* # MD5 key + 10 MD5 2late4Me # MD5 key + 11 SHA1 a27872d3030a9025b8446c751b4551a7629af65c # SHA1 key + 12 SHA1 21bc3b4865dbb9e920902abdccb3e04ff97a5e74 # SHA1 key + 13 SHA1 2b7736fe24fef5ba85ae11594132ab5d6f6daba9 # SHA1 key + 14 SHA a5332809c8878dd3a5b918819108a111509aeceb # SHA key + 15 MD2 2fe16c88c760ff2f16d4267e36c1aa6c926e6964 # MD2 key + 16 MD4 b2691811dc19cfc0e2f9bcacd74213f29812183d # MD4 key + 17 MD5 e4d6735b8bdad58ec5ffcb087300a17f7fef1f7c # MD5 key + 18 MDC2 a8d5e2315c025bf3a79174c87fbd10477de2eabc # MDC2 key + 19 RIPEMD160 77ca332cafb30e3cafb174dcd5b80ded7ba9b3d2 # RIPEMD160 key + 20 AES128CMAC f92ff73eee86c1e7dc638d6489a04e4e555af878 # AES128CMAC key + 21 MD5 sampo 10.1.2.3/24 +
+

Figure 1 shows a typical symmetric keys file used by the reference + implementation when the OpenSSL library is installed. Each line of + the file contains three or four fields. The first field is an integer + between 1 and 65535, inclusive, representing the key identifier. The + second field is the digest algorithm, which in the absence of the + OpenSSL library must be MD5, which designates the MD5 message + digest algorithm. The third field is the key. The optional fourth + field is one or more comma-separated IPs. An IP may end with an + optional /subnetbits suffix, which limits the acceptance of + the key identifier to packets claiming to be from the described IP + space. In this example, for the key IDs in the range 1-10 the key is + interpreted as a printable ASCII string. For the key IDs in the range + 11-20, the key is a 40-character hex digit string. In either case, + the key is truncated or zero-filled internally to either 128 or 160 + bits, depending on the key type. The line can be edited later or new + lines can be added to change any field. The key can be changed to a + password, such as 2late4Me for key ID 10. Note that two or + more keys files can be combined in any order as long as the key IDs + are distinct.

+

When ntpd is started, it reads the keys file specified by + the keys command and installs the keys in the key cache. + However, individual keys must be activated with + the trustedkey configuration command before use. This + allows, for instance, the installation of possibly several batches of + keys and then activating a key remotely using ntpq + or ntpdc. The requestkey command selects the key ID + used as the password for the ntpdc utility, while + the controlkey command selects the key ID used as the + password for the ntpq utility.

+

Microsoft Windows Authentication

+

In addition to the above means, ntpd now supports Microsoft + Windows MS-SNTP authentication using Active Directory services. This + support was contributed by the Samba Team and is still in development. + It is enabled using the mssntp flag of the restrict + command described on the Access Control + Options page. Note: Potential users should + be aware that these services involve a TCP connection to another + process that could potentially block, denying services to other users. + Therefore, this flag should be used only for a dedicated server with + no clients other than MS-SNTP.

+

Public Key Cryptography

+

See the Autokey Public-Key Authentication + page.

+
+ + Modified: stable/10/contrib/ntp/html/authopt.html ============================================================================== --- stable/10/contrib/ntp/html/authopt.html Sat Sep 8 04:09:30 2018 (r338530) +++ stable/10/contrib/ntp/html/authopt.html Sat Sep 8 04:10:26 2018 (r338531) @@ -4,6 +4,7 @@ Authentication Commands and Options +