From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 23 00:56:11 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3342D9BB for ; Mon, 23 Mar 2015 00:56:11 +0000 (UTC) Received: from mail-wg0-x230.google.com (mail-wg0-x230.google.com [IPv6:2a00:1450:400c:c00::230]) (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 B2193F95 for ; Mon, 23 Mar 2015 00:56:10 +0000 (UTC) Received: by wgra20 with SMTP id a20so133750175wgr.3 for ; Sun, 22 Mar 2015 17:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=LCopYcU5wEh48i6qo7X8JJv1tf63yY61h2CncGHnRd4=; b=dbgK6Y0unICaMd8C4zpIChoe+rYS5/yONWtDs3aCn2HUiNckqE7cix+8+f6ox0yo4P e5tkx5vhkVkXgJ3g7OByigKIY42Yn+aClE/A03tHKQ3NzrD8GSj35fcupgfrEln7RFAp qFWiw+oWstsJAhXQyY7Tex/94tsWb/U9X+sZI4/I0mQ9pfPRCr4pkOJwvwjuw8wPHGH9 ZV7m6XvmqtULYyGnTA0E8IsVpdwHP/Ehq2ZaTDdvzKCXPcwSwLRk4PYf2r/QxgHjOMLh +yOBMgqCJiOe/qbNLZUNmoNPVa94XrmOAPAOqh0AknIaXuROQraXjIoe9OaUTYArinXE OhMw== X-Received: by 10.180.198.110 with SMTP id jb14mr14946013wic.57.1427072169169; Sun, 22 Mar 2015 17:56:09 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by mx.google.com with ESMTPSA id dm6sm8733281wib.22.2015.03.22.17.56.07 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 22 Mar 2015 17:56:07 -0700 (PDT) Date: Mon, 23 Mar 2015 01:56:05 +0100 From: Mateusz Guzik To: Konstantin Belousov Subject: Re: [PATCH] Finish the task 'Validate coredump format string' Message-ID: <20150323005605.GA6798@dft-labs.eu> Mail-Followup-To: Mateusz Guzik , Konstantin Belousov , Tiwei Bie , freebsd-hackers@freebsd.org References: <1426946345-67889-1-git-send-email-btw@mail.ustc.edu.cn> <20150321200500.GC14650@dft-labs.eu> <20150322091853.GA89976@freebsd> <20150322101401.GH14650@dft-labs.eu> <20150322102428.GZ2379@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150322102428.GZ2379@kib.kiev.ua> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-hackers@freebsd.org, Tiwei Bie X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Mar 2015 00:56:11 -0000 On Sun, Mar 22, 2015 at 12:24:28PM +0200, Konstantin Belousov wrote: > On Sun, Mar 22, 2015 at 11:14:01AM +0100, Mateusz Guzik wrote: > > On Sun, Mar 22, 2015 at 05:19:40PM +0800, Tiwei Bie wrote: > > > Sorry, I introduced a bug... allproc_lock could not be used to protect > > > the access to corefilename[]. > > > > > > > First off I committed the code, so the fault is on me. > > > > > Because, sysctl_kern_corefile() could be called very early: > > > > > [..] > > > That is to say, when the tunable `kern.corefile' is set in loader.conf, > > > sysctl_kern_corefile() will be called as the priority of (SI_SUB_KMEM, > > > SI_ORDER_FIRST). > > > > > > At this time, allproc_lock is not initialized. > > > > > > I couldn't find a proper existing lock for this task. Maybe a dedicated > > > lock needs to be created. And initialize it together with sysctlmemlock: > > > > > [..] > > > Or maybe sysctlmemlock could be used, which is only acuqired when > > > req.oldlen > PAGE_SIZE. > > > > > > > > > > I was somehow convinced that tunables are dealt with other code. > > > > If such sysctl handler is also called for tunables, the kernel should > > pass a flag or some other indicator so that the function knows it is > > dealing with a tunable and that would avoid locking and thus solve the > > problem. > > > > I'm wondering if we should go a little bit further and get rid of > > static char corefilename[MAXPATHLEN] > > > > and have a static char *corefilename instead. > Accessing the array through the pointer dereference is micro-pessimization, > as well as having to maintain metadata for the malloced memory, isn't it ? > Having this dynamically allocated opens up a way to set such path per-jail, which may be a desirable feature. Also gets rid of a 1024 bytes table. > > > > A dedicated sysinit func could fetch and validate the tunable, if any. > > If no tunable was provided it would alloc memory for the default. > > Or you could move initialization of the sx in question earlier. -- Mateusz Guzik