lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20110127124647.GF3070@secunet.com>
Date:	Thu, 27 Jan 2011 13:46:47 +0100
From:	Steffen Klassert <steffen.klassert@...unet.com>
To:	Dave Hansen <dave@...ux.vnet.ibm.com>
Cc:	Eric Paris <eparis@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org, linux-security-module@...r.kernel.org
Subject: Re: flex_array related problems on selinux policy loading

On Wed, Jan 26, 2011 at 08:15:26AM -0800, Dave Hansen wrote:
> On Wed, 2011-01-26 at 14:04 +0100, Steffen Klassert wrote:
> > Another thing came to my mind. An atempt to do a zero size allocation
> > always succeed on kmalloc. If we want to allocate our metadata even in
> > this case, we should be aware that this allocation _can_ fail. So
> > flex_array_alloc would not show the same behaviour as kmalloc on zero
> > size allocations.
> 
> I think that's just fine.
> 
> You have to check for and handle those allocation failures anyway.  

If we just return a pointer to the user that notifies that this was a
zerro size allocation, we would not need to allocate anything (like
kmalloc does), so we can't get allocation failures.

> Can
> you think of places in the kernel where we have known-zero-sized
> allocations that don't check kmalloc() returns?

Usually, if somebody allocates memory he just checks if he got a
NULL pointer. I've never seen somebody checking for ZERO_SIZE_PTR.

> 
> > As most potential flex_array users convert their code
> > from kmalloc, the behaviour of flex_array_alloc should be the same as of
> > kmalloc. Showing a different behaviour here will produce pitfalls for
> > potential new users. Also, to tell a user that we can not allocate memory
> > for him, if the wants to allocate 0 byte (nothing) is quite odd. This
> > user could easily continue processing, even if we can not allocate our
> > metadata in this moment.
> 
> This doesn't have to be a one to one, direct, replacement for kmalloc().
> As long as it's close enough not to confuse people or normally cause
> problems, I think it's fine.

Indeed, it does not have to be one to one. But if we do it different,
we should document the difference somewere at least. I'll do that
once I have an updated patch and I know how the difference will be.

Steffen
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ