From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750932AbdEIVpb (ORCPT ); Tue, 9 May 2017 17:45:31 -0400 Received: from mail-pg0-f46.google.com ([74.125.83.46]:35946 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750734AbdEIVp3 (ORCPT ); Tue, 9 May 2017 17:45:29 -0400 Date: Tue, 9 May 2017 14:45:26 -0700 From: Eric Biggers To: David Howells Cc: Kees Cook , James Morris , "Serge E. Hallyn" , keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] key: Convert big_key payload.data to struct Message-ID: <20170509214526.GB87747@gmail.com> References: <20170508221943.GA46762@gmail.com> <20170508214324.GA124468@beast> <10235.1494280856@warthog.procyon.org.uk> <13867.1494314658@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13867.1494314658@warthog.procyon.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 09, 2017 at 08:24:18AM +0100, David Howells wrote: > Eric Biggers wrote: > > > It probably would be easier to kmalloc() this struct and store a pointer to > > it in key->payload.data[0] > > Yeah, but it's a waste of resources if you don't have to do it. > > David Yes, but it seems very much like a micro-optimization, which isn't helpful when the code contains undefined behavior and is creating problems. This is the *big* key type, after all; shouldn't the amount of data in the key normally be large enough to make a kmalloc() of 24 bytes insignificant? And besides, I expect that most users don't even use the big_keys feature. If we actually want to avoid wasting resources that aren't used, we shouldn't allocate the crypto_rng and crypto_skcipher until someone tries to create a big_key. (Currently they're allocated unconditionally in big_key_init().) - Eric