public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Luis Henriques <lhenriques@suse.de>
To: Peter Oberparleiter <oberpar@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] gcov: add basic gcov_info validation to gcov initialization
Date: Mon, 7 Jun 2021 11:48:06 +0100	[thread overview]
Message-ID: <YL35Zuk1urUn086g@suse.de> (raw)
In-Reply-To: <f0148fb8-1779-a18e-315c-87df31d3154f@linux.ibm.com>

On Mon, Jun 07, 2021 at 11:59:45AM +0200, Peter Oberparleiter wrote:
> On 02.06.2021 12:24, Luis Henriques wrote:
> > Add a basic gcov_info struct validation helper to gcc to ensure we have
> > sane from the compiler.
> > 
> > Signed-off-by: Luis Henriques <lhenriques@suse.de>
> > ---
> > Hi!
> > 
> > I know this won't really validate the gcov_info struct, but it will at
> > least prevent kernel crashes in simple scenarios (such as the one I'm
> > seeing with gcc 9.3.1).
> 
> Thanks for your suggestion of adding validity checking for the gcov_info
> struct. The goal you aim at is definitely something that we want to have
> to reduce the impact of fallout from changes to GCC's gcov_info struct.
> 
> In my opinion though the approach you described - looking at the
> contents of specific fields in gcov_info - isn't the correct way to go
> forward. Since you cannot know how gcov_info changed, accessing any data
> in it is very dangerous. Even if there's no out-of-bounds access (if the
> struct's size was reduced) the field you are checking could have moved
> elsewhere so the meaningfulness of the check is very limited.
> 
> In a previous discussion on the same topic I proposed a different
> approach for a build-time check that would fully check the compatibility
> of kernel code and GCC-emitted gcov-related data structures. See:
> 
> https://lore.kernel.org/patchwork/patch/1393585/#1592411
> 

Thanks, I see the problem is way more complex and I understand that my
patch is just wrong.  Thanks for pointing me at this thread.

> Unfortunately I have not yet found the time to implement this approach
> but it's still on my to-do-list.
> 
> Regarding the cause of the error you're seeing I'll have a look at the
> corresponding GCC source to see if there's anything that could be
> causing the issue.

Great, thanks.  Let me know if you need me to provide more info or
testing.  I'll be glad to help.

Cheers,
--
Luís

  reply	other threads:[~2021-06-07 10:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01 15:56 gcov: NULL pointer dereference with gcc 9.3.1 Luis Henriques
2021-06-02 10:24 ` [RFC PATCH] gcov: add basic gcov_info validation to gcov initialization Luis Henriques
2021-06-07  9:59   ` Peter Oberparleiter
2021-06-07 10:48     ` Luis Henriques [this message]
2021-06-02 12:35 ` gcov: NULL pointer dereference with gcc 9.3.1 Peter Oberparleiter
2021-06-02 14:22   ` Luis Henriques
2021-06-07 14:32     ` Peter Oberparleiter
2021-06-08 12:46       ` Luis Henriques

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=YL35Zuk1urUn086g@suse.de \
    --to=lhenriques@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oberpar@linux.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