From 9c1e214f79cb8f8fb38ba2f8fa010f282ec5be79 Mon Sep 17 00:00:00 2001 From: cem Date: Tue, 6 Oct 2015 18:07:00 +0000 Subject: Fix core corruption caused by race in note_procstat_vmmap This fix is spiritually similar to r287442 and was discovered thanks to the KASSERT added in that revision. NT_PROCSTAT_VMMAP output length, when packing kinfo structs, is tied to the length of filenames corresponding to vnodes in the process' vm map via vn_fullpath. As vnodes may move during coredump, this is racy. We do not remove the race, only prevent it from causing coredump corruption. - Add a sysctl, kern.coredump_pack_vmmapinfo, to allow users to disable kinfo packing for PROCSTAT_VMMAP notes. This avoids VMMAP corruption and truncation, even if names change, at the cost of up to PATH_MAX bytes per mapped object. The new sysctl is documented in core.5. - Fix note_procstat_vmmap to self-limit in the second pass. This addresses corruption, at the cost of sometimes producing a truncated result. - Fix PROCSTAT_VMMAP consumers libutil (and libprocstat, via copy-paste) to grok the new zero padding. Reported by: pho (https://people.freebsd.org/~pho/stress/log/datamove4-2.txt) Relnotes: yes Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3824 --- lib/libprocstat/libprocstat.c | 4 ++++ lib/libutil/kinfo_getvmmap.c | 4 ++++ 2 files changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c index 932b5a0..3de64aa 100644 --- a/lib/libprocstat/libprocstat.c +++ b/lib/libprocstat/libprocstat.c @@ -1867,6 +1867,8 @@ kinfo_getvmmap_core(struct procstat_core *core, int *cntp) eb = buf + len; while (bp < eb) { kv = (struct kinfo_vmentry *)(uintptr_t)bp; + if (kv->kve_structsize == 0) + break; bp += kv->kve_structsize; cnt++; } @@ -1882,6 +1884,8 @@ kinfo_getvmmap_core(struct procstat_core *core, int *cntp) /* Pass 2: unpack */ while (bp < eb) { kv = (struct kinfo_vmentry *)(uintptr_t)bp; + if (kv->kve_structsize == 0) + break; /* Copy/expand into pre-zeroed buffer */ memcpy(kp, kv, kv->kve_structsize); /* Advance to next packed record */ diff --git a/lib/libutil/kinfo_getvmmap.c b/lib/libutil/kinfo_getvmmap.c index 129aa03..9d9e427 100644 --- a/lib/libutil/kinfo_getvmmap.c +++ b/lib/libutil/kinfo_getvmmap.c @@ -44,6 +44,8 @@ kinfo_getvmmap(pid_t pid, int *cntp) eb = buf + len; while (bp < eb) { kv = (struct kinfo_vmentry *)(uintptr_t)bp; + if (kv->kve_structsize == 0) + break; bp += kv->kve_structsize; cnt++; } @@ -59,6 +61,8 @@ kinfo_getvmmap(pid_t pid, int *cntp) /* Pass 2: unpack */ while (bp < eb) { kv = (struct kinfo_vmentry *)(uintptr_t)bp; + if (kv->kve_structsize == 0) + break; /* Copy/expand into pre-zeroed buffer */ memcpy(kp, kv, kv->kve_structsize); /* Advance to next packed record */ -- cgit v1.1 From 4b2b2cb1c966e76885839ea06fb86a82bae0ad45 Mon Sep 17 00:00:00 2001 From: dim Date: Tue, 6 Oct 2015 19:49:53 +0000 Subject: For llvm/clang libraries, skip including tablegen-produced .d files when the target is "make depend". This works around errors during incremental make depend of some clang libraries, for example "don't know how to make contrib/llvm/include/llvm/IR/IntrinsicsR600.td". Reported by: emaste --- lib/clang/clang.build.mk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk index 1610a90..acb09f5 100644 --- a/lib/clang/clang.build.mk +++ b/lib/clang/clang.build.mk @@ -247,9 +247,11 @@ Checkers.inc.h: ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td -I ${CLANG_SRCS}/include -d ${.TARGET:C/\.h$/.d/} -o ${.TARGET} \ ${CLANG_SRCS}/lib/StaticAnalyzer/Checkers/Checkers.td -.for dep in ${TGHDRS:C/$/.inc.d/} -. sinclude "${dep}" -.endfor +.if !make(depend) +. for dep in ${TGHDRS:C/$/.inc.d/} +. sinclude "${dep}" +. endfor +.endif SRCS+= ${TGHDRS:C/$/.inc.h/} DPSRCS+= ${TGHDRS:C/$/.inc.h/} -- cgit v1.1 From d71b32ab8189310bd76cf8bb5dfe3fcc093593e9 Mon Sep 17 00:00:00 2001 From: dim Date: Tue, 6 Oct 2015 21:28:54 +0000 Subject: Stop linking libc++.so verbosely, there is no need to. MFC after: 3 days --- lib/libc++/Makefile | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile index f9bbf7e..baa6faf 100644 --- a/lib/libc++/Makefile +++ b/lib/libc++/Makefile @@ -63,7 +63,6 @@ CXXFLAGS+= -std=c++11 .endif LIBADD+= cxxrt -LDFLAGS+= --verbose INCSGROUPS= STD EXP EXT STD_HEADERS= __bit_reference\ -- cgit v1.1 From 7c2a5d79afd81f0e773ba7ddc4fe40c4c3d62627 Mon Sep 17 00:00:00 2001 From: bdrewery Date: Tue, 6 Oct 2015 21:58:38 +0000 Subject: truss: Add support for utrace(2). This uses the kdump(1) utrace support code directly until a common library is created. This allows malloc(3) tracing with MALLOC_CONF=utrace:true and rtld tracing with LD_UTRACE=1. Unknown utrace(2) data is just printed as hex. PR: 43819 [inspired by] Reviewed by: jhb MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D3819 --- lib/libc/sys/utrace.2 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/libc/sys/utrace.2 b/lib/libc/sys/utrace.2 index 9d24f20..345c1fd 100644 --- a/lib/libc/sys/utrace.2 +++ b/lib/libc/sys/utrace.2 @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 1, 2014 +.Dd October 5, 2015 .Dt UTRACE 2 .Os .Sh NAME @@ -70,7 +70,8 @@ support .Sh SEE ALSO .Xr kdump 1 , .Xr ktrace 1 , -.Xr ktrace 2 +.Xr ktrace 2 , +.Xr truss 1 .Sh HISTORY The .Fn utrace -- cgit v1.1 From 9b1033cdad0d2f3ced950ee53780ba9c3b3c2819 Mon Sep 17 00:00:00 2001 From: jhb Date: Wed, 7 Oct 2015 17:52:18 +0000 Subject: Document the recently added pl_syscall_* fields in struct ptrace_lwpinfo. Reviewed by: emaste, kib Differential Revision: https://reviews.freebsd.org/D3833 --- lib/libc/sys/ptrace.2 | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2 index 71b432f..5c93438 100644 --- a/lib/libc/sys/ptrace.2 +++ b/lib/libc/sys/ptrace.2 @@ -2,7 +2,7 @@ .\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $ .\" .\" This file is in the public domain. -.Dd July 3, 2015 +.Dd October 6, 2015 .Dt PTRACE 2 .Os .Sh NAME @@ -307,6 +307,8 @@ struct ptrace_lwpinfo { siginfo_t pl_siginfo; char pl_tdname[MAXCOMLEN + 1]; int pl_child_pid; + u_int pl_syscall_code; + u_int pl_syscall_narg; }; .Ed .Pp @@ -395,6 +397,27 @@ stop when .Dv PL_FLAG_FORKED is set in .Va pl_flags . +.It pl_syscall_code +The ABI-specific identifier of the current system call. +Note that for indirect system calls this field reports the indirected +system call. +Only valid when +.Dv PL_FLAG_SCE +or +.Dv PL_FLAG_SCX +is set in +.Va pl_flags. +.It pl_syscall_narg +The number of arguments passed to the current system call not counting +the system call identifier. +Note that for indirect system calls this field reports the arguments +passed to the indirected system call. +Only valid when +.Dv PL_FLAG_SCE +or +.Dv PL_FLAG_SCX +is set in +.Va pl_flags. .El .It PT_GETNUMLWPS This request returns the number of kernel threads associated with the -- cgit v1.1 From 7d1573f7e98b3fc24bccefb76112063e0562ce07 Mon Sep 17 00:00:00 2001 From: rodrigc Date: Wed, 7 Oct 2015 19:55:58 +0000 Subject: Use proper function prototypes. Eliminates -Wstrict-prototypes warning --- lib/libc/rpc/getpublickey.c | 2 +- lib/libc/rpc/key_call.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/libc/rpc/getpublickey.c b/lib/libc/rpc/getpublickey.c index 74ed983..4c80685 100644 --- a/lib/libc/rpc/getpublickey.c +++ b/lib/libc/rpc/getpublickey.c @@ -56,7 +56,7 @@ __FBSDID("$FreeBSD$"); /* * Hack to let ypserv/rpc.nisd use AUTH_DES. */ -int (*__getpublickey_LOCAL)() = 0; +int (*__getpublickey_LOCAL)(const char *, char *) = 0; /* * Get somebody's public key diff --git a/lib/libc/rpc/key_call.c b/lib/libc/rpc/key_call.c index 664ddfd..b9bc77a 100644 --- a/lib/libc/rpc/key_call.c +++ b/lib/libc/rpc/key_call.c @@ -81,9 +81,9 @@ __FBSDID("$FreeBSD$"); * implementations of these functions, and to call those in key_call(). */ -cryptkeyres *(*__key_encryptsession_pk_LOCAL)() = 0; -cryptkeyres *(*__key_decryptsession_pk_LOCAL)() = 0; -des_block *(*__key_gendes_LOCAL)() = 0; +cryptkeyres *(*__key_encryptsession_pk_LOCAL)(uid_t, void *arg) = 0; +cryptkeyres *(*__key_decryptsession_pk_LOCAL)(uid_t, void *arg) = 0; +des_block *(*__key_gendes_LOCAL)(uid_t, void *) = 0; static int key_call( u_long, xdrproc_t, void *, xdrproc_t, void *); -- cgit v1.1 From 1bb3c00a2bdedce4b3e3d08b9e16499fe82f7278 Mon Sep 17 00:00:00 2001 From: rodrigc Date: Thu, 8 Oct 2015 00:48:29 +0000 Subject: Use -fpermissive if compiling with GCC. Works around GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67888 when compiling Module.cpp --- lib/clang/libclangbasic/Makefile | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/clang/libclangbasic/Makefile b/lib/clang/libclangbasic/Makefile index 68c2a77..028fcdb 100644 --- a/lib/clang/libclangbasic/Makefile +++ b/lib/clang/libclangbasic/Makefile @@ -47,3 +47,6 @@ TGHDRS= AttrHasAttributeImpl \ arm_neon .include "../clang.lib.mk" + +# XX: work around GCC bug 67888 +CFLAGS.gcc += -fpermissive -- cgit v1.1 From 3cab7edfb2189584bee4dcc9949573aaaa5f9861 Mon Sep 17 00:00:00 2001 From: peter Date: Thu, 8 Oct 2015 01:17:45 +0000 Subject: Move SHLIBDIR?=/lib before so that it works again. --- lib/libxo/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/libxo/Makefile b/lib/libxo/Makefile index fd0ba91..d854a4c 100644 --- a/lib/libxo/Makefile +++ b/lib/libxo/Makefile @@ -1,5 +1,7 @@ # $FreeBSD$ +SHLIBDIR?= /lib + .include LIBXOSRC= ${SRCTOP}/contrib/libxo @@ -9,8 +11,6 @@ LIBXOSRC= ${SRCTOP}/contrib/libxo LIB= xo SHLIB_MAJOR=0 -SHLIBDIR?= /lib - SRCS= libxo.c xo_encoder.c xo_syslog.c CFLAGS+=-I${LIBXOSRC}/libxo -- cgit v1.1 From d1d774415709780ebddcecdef527f909484ec184 Mon Sep 17 00:00:00 2001 From: marcel Date: Thu, 8 Oct 2015 17:59:05 +0000 Subject: If we can't open the file, skip devclose() for the exclusive_file_system case. We never called devopen(), so we know there's nothing to close. --- lib/libstand/open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libstand/open.c b/lib/libstand/open.c index 0d90433..214e51b 100644 --- a/lib/libstand/open.c +++ b/lib/libstand/open.c @@ -114,7 +114,7 @@ open(const char *fname, int mode) error = (fs->fo_open)(fname, f); if (error == 0) goto ok; - goto fail; + goto err; } error = devopen(f, fname, &file); -- cgit v1.1