From owner-svn-src-head@freebsd.org Sat Sep 5 14:56:17 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 17F7D9CA59E; Sat, 5 Sep 2015 14:56:17 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-yk0-f180.google.com (mail-yk0-f180.google.com [209.85.160.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D0E1D323; Sat, 5 Sep 2015 14:56:16 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by ykek143 with SMTP id k143so46127068yke.2; Sat, 05 Sep 2015 07:56:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=3Ct1UuKnNaAVhQKJEJ+F9afP225AANyqSpwAI7G8T1Y=; b=HKfI+y1rOzLySNppQVseIgOQUdDKcXmz4ekuMeWU5B4uO7Cnk5qnBZDutMfs0VoA+K 6eyRehanEPHgzX2Hk6GVxEcMfGuYssog20cvubcrIwVR55IuQniYuUlzYm9N0o7GR8O1 9btEQW4+3Fr+CxHUq5qKf6ynfd7mhIgVDQIq93xw+8gkq4SJIpjWgX0kk/kgkF4+EBeu 5ZDV9CZltlwHuFdZLe2qFVfcow6Vv/XJZX+igV1ZFwu0LT7F/Ka11QuJ7Q2F4caRtTI1 8Dwvq3BaEiPqxtGiTgi7Jfjk3FkXA/uLv6vXD4kW2xELNNZzB40l0mhVtl0k35OUqI4A RTCw== X-Received: by 10.170.169.66 with SMTP id l63mr10382670ykd.60.1441464614091; Sat, 05 Sep 2015 07:50:14 -0700 (PDT) Received: from mail-yk0-f177.google.com (mail-yk0-f177.google.com. [209.85.160.177]) by smtp.gmail.com with ESMTPSA id g197sm5613986ywe.4.2015.09.05.07.50.13 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Sep 2015 07:50:13 -0700 (PDT) Received: by ykek143 with SMTP id k143so46051418yke.2; Sat, 05 Sep 2015 07:50:13 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.170.56.2 with SMTP id 2mr10580419yky.106.1441464613658; Sat, 05 Sep 2015 07:50:13 -0700 (PDT) Reply-To: cem@FreeBSD.org Received: by 10.37.48.134 with HTTP; Sat, 5 Sep 2015 07:50:13 -0700 (PDT) In-Reply-To: <20150905160425.2b7c4088@kalimero.tijl.coosemans.org> References: <201509032032.t83KWAtl043698@repo.freebsd.org> <20150905160425.2b7c4088@kalimero.tijl.coosemans.org> Date: Sat, 5 Sep 2015 07:50:13 -0700 Message-ID: Subject: Re: svn commit: r287442 - in head: lib/libprocstat lib/libutil share/man/man5 sys/kern sys/sys From: Conrad Meyer To: Tijl Coosemans Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Sep 2015 14:56:17 -0000 I'll be offline for the next ~48 hours. It sounds like it's annoying but not critical to fix. If it isn't fixed when I get back, I'll figure something out. Thanks, Conrad P.S., What systems have both imgact_elf64 and 32? On Sat, Sep 5, 2015 at 7:04 AM, Tijl Coosemans wrote: > On Thu, 3 Sep 2015 20:32:10 +0000 (UTC) "Conrad E. Meyer" wrote: >> Author: cem >> Date: Thu Sep 3 20:32:10 2015 >> New Revision: 287442 >> URL: https://svnweb.freebsd.org/changeset/base/287442 >> >> Log: >> Detect badly behaved coredump note helpers >> >> Coredump notes depend on being able to invoke dump routines twice; once >> in a dry-run mode to get the size of the note, and another to actually >> emit the note to the corefile. >> >> When a note helper emits a different length section the second time >> around than the length it requested the first time, the kernel produces >> a corrupt coredump. >> >> NT_PROCSTAT_FILES output length, when packing kinfo structs, is tied to >> the length of filenames corresponding to vnodes in the process' fd table >> via vn_fullpath. As vnodes may move around during dump, this is racy. >> >> So: >> >> - Detect badly behaved notes in putnote() and pad underfilled notes. >> >> - Add a fail point, debug.fail_point.fill_kinfo_vnode__random_path to >> exercise the NT_PROCSTAT_FILES corruption. It simply picks random >> lengths to expand or truncate paths to in fo_fill_kinfo_vnode(). >> >> - Add a sysctl, kern.coredump_pack_fileinfo, to allow users to >> disable kinfo packing for PROCSTAT_FILES notes. This should avoid >> both FILES note corruption and truncation, even if filenames change, >> at the cost of about 1 kiB in padding bloat per open fd. Document >> the new sysctl in core.5. >> >> - Fix note_procstat_files to self-limit in the 2nd pass. Since >> sometimes this will result in a short write, pad up to our advertised >> size. This addresses note corruption, at the risk of sometimes >> truncating the last several fd info entries. >> >> - Fix NT_PROCSTAT_FILES consumers libutil and libprocstat to grok the >> zero padding. >> >> With suggestions from: bjk, jhb, kib, wblock >> Approved by: markj (mentor) >> Relnotes: yes >> Sponsored by: EMC / Isilon Storage Division >> Differential Revision: https://reviews.freebsd.org/D3548 >> >> Modified: >> head/lib/libprocstat/libprocstat.c >> head/lib/libutil/kinfo_getfile.c >> head/share/man/man5/core.5 >> head/sys/kern/imgact_elf.c >> head/sys/kern/kern_descrip.c >> head/sys/kern/vfs_vnops.c >> head/sys/sys/user.h >> >> Modified: head/sys/kern/imgact_elf.c >> ============================================================================== >> --- head/sys/kern/imgact_elf.c Thu Sep 3 19:42:56 2015 (r287441) >> +++ head/sys/kern/imgact_elf.c Thu Sep 3 20:32:10 2015 (r287442) >> @@ -1875,29 +1902,56 @@ __elfN(note_procstat_proc)(void *arg, st >> CTASSERT(sizeof(struct kinfo_file) == KINFO_FILE_SIZE); >> #endif >> >> +static int pack_fileinfo = 1; >> +SYSCTL_INT(_kern, OID_AUTO, coredump_pack_fileinfo, CTLFLAG_RWTUN, >> + &pack_fileinfo, 0, >> + "Enable file path packing in 'procstat -f' coredump notes"); > > This file can be compiled twice (included by both imgact_elf32.c and > imgact_elf64.c) so this sysctl can be added twice and the second time > results in an error message in dmesg: "can't re-use a leaf".