public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: "Matthias Maennich via libabigail" <libabigail@sourceware.org>
To: Mark Wielaard <mark@klomp.org>
Cc: libabigail@sourceware.org, dodji@seketeli.org,
	kernel-team@android.com,	Alessio Balsini <balsini@android.com>
Subject: Re: [PATCH v1] abg-dwarf-reader: detect kernel modules without exports as such
Date: Tue, 01 Jan 2019 00:00:00 -0000	[thread overview]
Message-ID: <20190725134911.GA197987@google.com> (raw)
In-Reply-To: <20190724215710.GD15558@wildebeest.org>

Hi Mark!

On Wed, Jul 24, 2019 at 11:57:10PM +0200, Mark Wielaard wrote:
> Hi,
> 
> On Wed, Jul 24, 2019 at 10:32:55PM +0100, Matthias Maennich via libabigail wrote:
> > Kernel modules without exported symbols (no use of EXPORT_SYMBOL*()),
> > will not have a __ksymtab_strings section. Libabigail will therefore
> > assume they are usual ELF binaries. That leads to wrong results as
> > now all ELF symbols are considered part of the ABI. That is obviously
> > wrong. Instead consider binaries having a .modinfo section to be kernel
> > binaries. We keep the __ksymtab_strings condition as vmlinux has no
> > .modinfo section but a __ksymtab_strings if symbols are exported.
> > [...] 
> > 	* src/abg-dwarf-reader.cc(is_linux_kernel_binary): consider
> > 	  binaries only having a .modinfo section to be kernel binaries
> > [...]
> >    bool
> >    is_linux_kernel_binary() const
> > -  {return find_section(elf_handle(), "__ksymtab_strings", SHT_PROGBITS);}
> > +  {
> > +    return find_section(elf_handle(), "__ksymtab_strings", SHT_PROGBITS)
> > +	   || find_section(elf_handle(), ".modinfo", SHT_PROGBITS);
> > +  }
> 
> I think the change itself is correct and better than what is there
> now.
> 
> But this is interesting to me because we are discussing an
> eu-elfclassify program addition for elfutils. That utility at the
> moment classifies a --linux-kernel-module as:
> 
> /* Returns true if the file is a linux kernel module (is ET_REL and
>    has the two magic sections .modinfo and .gnu.linkonce.this_module).  */
> static bool
> is_linux_kernel_module (void)
> {
>   return (elf_kind (elf) == ELF_K_ELF
>           && elf_type == ET_REL
>           && has_modinfo
>           && has_gnu_linkonce_this_module);
> }
> 
> Just wondering if you believe that check is too strict?
> 
> The reason to check for both "magic" section names was mainly because
> ".modinfo" seemed a little too generic.
> 
> One difference is that eu-elfclassify doesn't check the section type.
> Maybe it should do that like here, to make sure that it is
> SHT_PROGBITS.
> 
To be honest, I am not entirely sure myself. I was told in IRC that the check
above is sufficient and should be good for kernels of at least 3.18+ (possibly
older kernels as well). I will add a patch on top to restrict abigail a bit
more on this.

> Sorry for hijacking this patch review for something slightly
> different. But I was happy to see something very similar to what I was
> working on in a different, but somewhat related project, and was
> wondering whether it was the correct way to classify something as a
> kernel module.
> 
> Cheers,
> 
> Mark

-- 
Cheers,
Matthias

  reply	other threads:[~2019-07-25 13:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-01  0:00 Matthias Maennich via libabigail
2019-01-01  0:00 ` Dodji Seketeli
2019-01-01  0:00 ` Mark Wielaard
2019-01-01  0:00   ` Matthias Maennich via libabigail [this message]
2019-01-01  0:00   ` Dodji Seketeli

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=20190725134911.GA197987@google.com \
    --to=libabigail@sourceware.org \
    --cc=balsini@android.com \
    --cc=dodji@seketeli.org \
    --cc=kernel-team@android.com \
    --cc=maennich@google.com \
    --cc=mark@klomp.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 read-only IMAP folder(s) and NNTP newsgroup(s).