public inbox for linux-integrity@vger.kernel.org
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: Vitaly Chikunov <vt@altlinux.org>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
	linux-integrity@vger.kernel.org
Cc: "Dmitry V. Levin" <ldv@altlinux.org>
Subject: Re: [PATCH ima-evm-utils] Improve memory handling for private keys and passwords
Date: Wed, 18 Aug 2021 17:07:20 -0400	[thread overview]
Message-ID: <0f85d155b154c7358eaf4bb2c65f391587e3809d.camel@linux.ibm.com> (raw)
In-Reply-To: <3e870d0e5c5cbecce5d9fe1c0d613118ddb1bae3.camel@linux.ibm.com>

On Fri, 2021-08-13 at 17:31 -0400, Mimi Zohar wrote:
> Hi Vitaly,
> 
> On Fri, 2021-08-13 at 00:46 +0300, Vitaly Chikunov wrote:
> > Hi,
> > 
> > On Fri, Aug 13, 2021 at 12:21:43AM +0300, Vitaly Chikunov wrote:
> > > After CRYPTO_secure_malloc_init OpenSSL will store private keys in
> > > secure heap. This facility is only available since OpenSSL_1_1_0-pre1
> > > and enabled for 'ima_sign', 'sign', 'sign_hash', and 'hmac'.
> 
> From the manpage:
> CRYPTO_secure_malloc_init() returns 0 on failure, 1 if successful, and
> 2 if successful but the heap could not be protected by memory mapping.
> 
> Not sure what we would do on failure ( 0, 2), but we should at least
> check the return code.
> > 
> > > setvbuf(3) _IONBF is used to hopefully avoid private key and password
> > > being stored inside of stdio buffers.
> > 
> > I should note that usefulness of this method (of avoiding buffering) is
> > not proven. I don't find other implementations doing it. So, I'm open to
> > suggestion of removing it.
> > 
> Probably would be better to split the patch.

According to the man page "OPENSSL_secure_malloc() allocates num bytes
from the heap.  If CRYPTO_secure_malloc_init() is not called, this is
equivalent to calling OPENSSL_malloc()".   OPENSSL_malloc() is
supported in the older openssl versions.

Does it make sense to replace allocating memory for the password via
malloc() with OPENSSL_secure_malloc()?  For older openssl versions,
define OPENSSL_secure_malloc() and OPENSSL_secure_free() as
OPENSSL_malloc() and OPENSSL_free().

This doesn't solve the memory handling for private keys and passwords
for older openssl versions, but it is a path forward.

thanks,

Mimi


  reply	other threads:[~2021-08-18 21:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 21:21 [PATCH ima-evm-utils] Improve memory handling for private keys and passwords Vitaly Chikunov
2021-08-12 21:46 ` Vitaly Chikunov
2021-08-13 21:31   ` Mimi Zohar
2021-08-18 21:07     ` Mimi Zohar [this message]
2021-08-18 21:17       ` Vitaly Chikunov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0f85d155b154c7358eaf4bb2c65f391587e3809d.camel@linux.ibm.com \
    --to=zohar@linux.ibm.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=ldv@altlinux.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=vt@altlinux.org \
    --cc=zohar@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox