linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mimi Zohar <zohar@linux.ibm.com>
To: Vitaly Chikunov <vt@altlinux.org>
Cc: linux-integrity@vger.kernel.org
Subject: Re: [PATCH v3 2/2] ima-evm-utils: log unknown keyid's as errors
Date: Tue, 23 Jul 2019 18:59:16 -0400	[thread overview]
Message-ID: <1563922756.4294.16.camel@linux.ibm.com> (raw)
In-Reply-To: <20190723221801.ycvdj5eajlrozxf6@altlinux.org>

On Wed, 2019-07-24 at 01:18 +0300, Vitaly Chikunov wrote:
> Mimi,
> 
> On Thu, Jul 18, 2019 at 10:29:54AM -0400, Mimi Zohar wrote:
> > Each tima a new unknown key is encountered, emit a message of the format
> > "key #: <keyid> unknown".  The individual files using unknown keys are
> > then only logged in verbose mode.
> > 
> > Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
> > ---
> >  src/libimaevm.c | 21 +++++++++++++++++----
> >  1 file changed, 17 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/libimaevm.c b/src/libimaevm.c
> > index 43eb4ef2412c..d2194a6ca0f8 100644
> > --- a/src/libimaevm.c
> > +++ b/src/libimaevm.c
> > @@ -402,13 +402,26 @@ static struct public_key_entry *public_keys = NULL;
> >  
> >  static EVP_PKEY *find_keyid(uint32_t keyid)
> >  {
> > -	struct public_key_entry *entry;
> > +	struct public_key_entry *entry, *tail = public_keys;
> 
> If user specified in `-k` filename that does not exist no key is added
> into public_keys and it remains NULL.

Right, just the keyid is added and an error message is emitted.

> 
> > +	int i = 1;
> >  
> >  	for (entry = public_keys; entry != NULL; entry = entry->next) {
> >  		if (entry->keyid == keyid)
> >  			return entry->key;
> > +		i++;
> > +		tail = entry;
> >  	}
> > -	return NULL;
> > +
> > +	/* add unknown keys to list */
> > +	entry = calloc(1, sizeof(struct public_key_entry));
> > +	if (!entry) {
> > +		perror("calloc");
> > +		return 0;
> > +	}
> > +	entry->keyid = keyid;
> > +	tail->next = entry;
> 
> In that case here is SIGSEGV when user try to ima_verify.

find_keyid() returns NULL, which is checked before being used.
 There's only one caller of this function.

Do you have a test case to reproduce this bug?

Mimi

> 
> > +	log_err("key %d: %x unknown\n", i,  __be32_to_cpup(&keyid));
> > +	return 0;
> >  }
> >  
> >  void init_public_keys(const char *keyfiles)
> > @@ -470,8 +483,8 @@ static int verify_hash_v2(const char *file, const unsigned char *hash, int size,
> >  
> >  	pkey = find_keyid(keyid);
> >  	if (!pkey) {
> > -		log_err("%s: unknown keyid: %x\n",
> > -			file, __be32_to_cpup(&keyid));
> > +		log_info("%s: unknown keyid: %x\n",
> > +			 file, __be32_to_cpup(&keyid));
> >  		return -1;
> >  	}
> >  
> 


  reply	other threads:[~2019-07-23 22:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18 14:29 [PATCH v3 1/2] ima_evm_utils: erroneous "verification failed: 0 (invalid padding)" message Mimi Zohar
2019-07-18 14:29 ` [PATCH v3 2/2] ima-evm-utils: log unknown keyid's as errors Mimi Zohar
2019-07-23 22:18   ` Vitaly Chikunov
2019-07-23 22:59     ` Mimi Zohar [this message]
2019-07-23 23:13       ` Vitaly Chikunov
2019-07-24  0:19         ` Mimi Zohar
2019-07-24  0:50           ` 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=1563922756.4294.16.camel@linux.ibm.com \
    --to=zohar@linux.ibm.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=vt@altlinux.org \
    /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;
as well as URLs for NNTP newsgroup(s).