From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754221Ab1A0MPY (ORCPT ); Thu, 27 Jan 2011 07:15:24 -0500 Received: from a.mx.secunet.com ([195.81.216.161]:41324 "EHLO a.mx.secunet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753846Ab1A0MPX (ORCPT ); Thu, 27 Jan 2011 07:15:23 -0500 Date: Thu, 27 Jan 2011 13:15:18 +0100 From: Steffen Klassert To: Dave Hansen Cc: Eric Paris , Andrew Morton , linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: flex_array related problems on selinux policy loading Message-ID: <20110127121518.GE3070@secunet.com> References: <20110120122659.GD4639@secunet.com> <1295537330.9039.583.camel@nimitz> <20110121072022.GA3070@secunet.com> <1295625455.9039.3326.camel@nimitz> <20110126102328.GC3070@secunet.com> <1296058216.7567.21.camel@nimitz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1296058216.7567.21.camel@nimitz> User-Agent: Mutt/1.5.20 (2009-06-14) X-OriginalArrivalTime: 27 Jan 2011 12:15:19.0861 (UTC) FILETIME=[DD6EC650:01CBBE1B] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 26, 2011 at 08:10:16AM -0800, Dave Hansen wrote: > > > > Btw. why the struct flex_array needs to have page size? > > It was designed as an alternative to _large_ allocations and we didn't > expect people to want to use it for small things. But, it doesn't > _need_ to stay that way, we just did it like that for simplicity. > Ok, I thought that. In case of selinux, the informations on how big the array will be comes from the userspace. In the most cases, people use big selinux policies like the selinux reference policy, these arrays are quite big. But if somebody uses just a dummy policy, the arrays are small or empty in some cases. > > If we would make > > flex_array of dynamic size, say metadata plus the maximum size of the array > > in the case that the metadata and the array fit into a single page, and > > metadata plus space for all the base pointers we need to dereference the > > parts, if the metadata and array is beyond page size. With this, the struct > > flex_array would have a reasonable size in any case, even if the array to > > store is small or of zero size. > > Sounds like a good idea to me. Done right, it should only really affect > the allocation path since we use kmalloc() already, and we can still > plain kfree() it. > So lets do it like that. I'll propose another patch, may take some days. Steffen