From: Jerry Snitselaar <jsnitsel at redhat.com>
To: tpm2@lists.01.org
Subject: Re: [tpm2] tpm2-abrmd / glib question
Date: Wed, 18 Oct 2017 11:33:52 -0700 [thread overview]
Message-ID: <20171018183352.w6fg67vvmwypca2w@rhwork> (raw)
In-Reply-To: b3cb6c3d-f321-d071-9dd5-12b3ae01e366@twobit.us
[-- Attachment #1: Type: text/plain, Size: 3426 bytes --]
On Wed Oct 18 17, flihp wrote:
>Hi Jerry,
>
>On 10/18/2017 09:46 AM, Jerry Snitselaar wrote:
>> Looking at some items that coverity scan came up with for 1.1.0. It is
>> complaining about a null pointer passed as nonnull parameter with the
>> pthread_mutex_lock call in access_broker_lock.
>
>Are you running these scans yourself or are you looking at the output
>from the scan.coverity.com service that we automate through travis-ci? I
>haven't merged into the coverity_scan branch in a while (since the last
>release) so this may be a new thing but last I checked coverity gave us
>a clean bill of health.
>
This is a scan that gets run against our packages here as part of the
release process. As part of getting tpm2-abrmd into RHEL I have to go
through the covscan output it generates, and determine if they are
actual bugs or not. The two I've seen so far that were bugs, you've
already dealt with upstream. The rest have been false positives.
This was the last one I was dealing with, and while I could tell
the program would never get to that point without the broker allocated,
blowing up long before it got there, I wasn't sure about whether or
not it should be checked after allocation.
>> Is it possible for
>> access_broker_new to fail (g_object_new doesn't allocate an object?)?
>
>According to the GObject docs GOjbect construction cannot fail.
>https://developer.gnome.org/gobject/stable/howto-gobject-construction.html
>
Thanks for the link. I've never dealt with glib, and was digging through
stuff, but hadn't got to this page.
>> Should there be some check after access_broker_new is called? Looking> at the glib code, it seemed like there was at least a way through the
>> code to end up at g_malloc which can return null. I haven't finished
>> digging through the slab allocator code to see what can happen there.
>> I've read a comment though by Allison Lortie that said g_object_new
>> will alway return a non-null value, so I'm wondering what is returned
>> on failure, or if the claim is it will never fail.
>
>This object needs some love. I've been going back and correcting common
>GObject mistakes that I've made but there's still a ways to go. I did
>object finalization last week: https://github.com/01org/tpm2-abrmd/pull/211
>
>But the way I've coded the function isn't right since the SAPI context
>creation in this _new function may fail (a situation currently ignored
>by the code). GObject has a mechanism for doing initialization that
>could fail after object creation, I just didn't know about it at the
>time :( Thankfully Allison Lortie has a great blog post describing the
>feature:
>https://blogs.gnome.org/desrt/2012/02/26/a-gentle-introduction-to-gobject-construction/
>
I think it was a comment here where she mentioned that g_object_new would always
return a non-null value.
>Quick summary of the issue in this object:
>1) g_object_new cannot fail, if a memory allocation fails I think GLib
>will abort the program. So I think the situation you're looking into
>isn't an issue.
>2) The AccessBroker _new function needs to be cleaned up a bit to use
>the interface described by Allison in the link above (GInitable).
>
>I'll queue up #2 from this list as an issue in the tabrmd github so I
>don't forget.
>
>Philip
Yeah, I will go ahead and mark this one as not a bug, and finish up
this process. :)
next reply other threads:[~2017-10-18 18:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-18 18:33 Jerry Snitselaar [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-10-18 18:59 [tpm2] tpm2-abrmd / glib question flihp
2017-10-18 17:49 flihp
2017-10-18 16:46 Jerry Snitselaar
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=20171018183352.w6fg67vvmwypca2w@rhwork \
--to=tpm2@lists.01.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