From owner-freebsd-jail@FreeBSD.ORG Thu Jul 15 19:13:56 2010 Return-Path: Delivered-To: jail@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A58CA1065675 for ; Thu, 15 Jul 2010 19:13:56 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from gritton.org (gritton.org [208.92.232.93]) by mx1.freebsd.org (Postfix) with ESMTP id 602488FC15 for ; Thu, 15 Jul 2010 19:13:56 +0000 (UTC) Received: from guppy.corp.verio.net (fw.oremut02.us.wh.verio.net [198.65.168.24]) (authenticated bits=0) by gritton.org (8.14.3/8.14.3) with ESMTP id o6FJDs0r044157; Thu, 15 Jul 2010 13:13:55 -0600 (MDT) (envelope-from jamie@FreeBSD.org) Message-ID: <4C3F5D51.6000903@FreeBSD.org> Date: Thu, 15 Jul 2010 13:11:13 -0600 From: Jamie Gritton User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.1.5) Gecko/20100103 Thunderbird/3.0 MIME-Version: 1.0 To: Stanislav Uzunchev References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: jail@FreeBSD.org, hackers@FreeBSD.org Subject: Re: libjail issues. X-BeenThere: freebsd-jail@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion about FreeBSD jail\(8\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2010 19:13:56 -0000 On 07/15/10 04:12, Stanislav Uzunchev wrote: > I have found something very strange to me... It is a problem with static > allocating size of buffer where jail param is going to be coppied, using > jail_getv function from the libjails. Well for example: > > buff[size]; > jail_getv(0, "name", "1", "host.hostname", buff, NULL); > > the result for size = 64; is bsnmp.test, size = 257; is bsnmp.test, size = > 256; is bs1 ? > > #sysctl -a | grep "security.jail.param.host.hostname:" > 256 > > #jls > JID Hostname > 1 bsnmp.test > > #jls -n | grep "bs1" > returns no match. > > This is really confusing me. That's a bug in jail_getv, which I'm committing the fix for now. Unfortunately, it's too late to get it in the 8.1 release, but it will at least be in future releases. The issue is that jail_getv wrongly allocated temporary space based on the length of the parameters passed in, which don't even have values yet. The different array sizes in your sample code would coincidentally locate the "buff" array with different garbage contents, leading to different behavior with the bug. > Also i will take suggestions, what is the best way, to get and set all > value/params using the jailparam struct. > I am trying first to set the name or jid, and after that getting the values > for the rest parameters with jail_getv, but i face some problems setting > jp_value since it is type (void *). You don't value to set jp_value directly, but use the jailparam_import function. That will set jp_value correctly based on the parameter's type. - Jamie