linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Ingo Molnar <mingo@kernel.org>, Al Viro <viro@zeniv.linux.org.uk>,
	Adam Borowski <kilobyte@angband.pl>,
	Michal Marek <mmarek@suse.com>, Philip Muller <philm@manjaro.org>,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	linux-arch <linux-arch@vger.kernel.org>,
	linux-kbuild <linux-kbuild@vger.kernel.org>
Subject: Re: [PATCH] x86/kbuild: enable modversions for symbols exported from asm
Date: Fri, 25 Nov 2016 11:40:18 +1100	[thread overview]
Message-ID: <20161125114018.12421474@roar.ozlabs.ibm.com> (raw)
In-Reply-To: <20161124152410.GC30905@kroah.com>

On Thu, 24 Nov 2016 16:24:10 +0100
Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:

> On Thu, Nov 24, 2016 at 09:31:52PM +1100, Nicholas Piggin wrote:
> > On Thu, 24 Nov 2016 10:56:22 +0100
> > Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> >   
> > > On Thu, Nov 24, 2016 at 06:53:22PM +1100, Nicholas Piggin wrote:  
> > > > On Thu, 24 Nov 2016 08:36:39 +0100
> > > > Greg Kroah-Hartman <gregkh@linuxfoundation.org> wrote:
> > > >     
> > > > > On Thu, Nov 24, 2016 at 06:20:26PM +1100, Nicholas Piggin wrote:    
> > > > > > But still, modversions is pretty complicated for what it gives us. It sends
> > > > > > preprocessed C into a C parser that makes CRCs using type definitions of
> > > > > > exported symbols, then turns those CRCs into a linker script which which is
> > > > > > used to link the .o file with. What we get in return is a quite limited and
> > > > > > symbol "versioning" system.
> > > > > > 
> > > > > > What if we ripped all that out and just attached an explicit version to
> > > > > > each export, and incompatible changes require an increment?      
> > > > > 
> > > > > How would that work for structures?  Would that be required for every
> > > > > EXPORT_SYMBOL* somehow?    
> > > > 
> > > > Yeah just have EXPORT_SYMBOL take another parameter which attaches a version
> > > > number and use that as the value for the __crc_ symbol versions rather than
> > > > a calculated CRC.
> > > > 
> > > > Yes it would require some level of care from developers and may be a small
> > > > annoyance when changing exports. But making people think a tiny bit more
> > > > before chnaging exported ABI shouldn't be the end of the world.    
> > > 
> > > That wouldn't work at all for structures that change, as we never
> > > explicitly "mark" them for export anywhere.  
> > 
> > Well, the module arrives at the objects one way or another via an exported
> > symbol. Although it can be by following a lot of pointers so yes it's
> > probably near impossible to do well.  
> 
> Yes, manual "marking" is never going to be a viable solution.

I guess it really depends on how exactly you want to use it. For distros
that do stable ABI but rarely may have to break something for security
reasons, it should work and give exact control.

What else do people *actually* use it for? Preventing mismatched modules
when .git version is not attached and release version of the kernel has
not been bumped. Is that it?

> > >  You need a tool that looks
> > > at either the source code (what we have today), or looks at the  
> > 
> > What we have today only looks at the type of the exported function or
> > variable I think (or does it? I didn't look that far into the parser).  
> 
> It should catch things if you change a structure layout of something
> that is an argument in a function (like a pointer to a structure),
> otherwise it wouldn't really be that good of a check, and kind of
> useless.
>
> > Does not follow down all possible derivable pointer types.  
> 
> It should be pretty good, as I think the code is based on the old SuSE
> scripts that used to do this really well.  But it's been a long time
> since I looked at it, so I could be wrong.

Yeah... turns out modversions is in the "kind of useless" camp.

The crc is based on the name of the type and that's it (that's what I
thought, I just now verify it).

> > > > > > Google tells me
> > > > > > Linus is not a neutral bystander on the topic of symbol versioning, so I'm
> > > > > > bracing for a robust response :) (actually I don't much care either way, I'm
> > > > > > happy to put a couple of bandaids on it and keep it going)      
> > > > > 
> > > > > There are tools that people are working on to make it more obvious where
> > > > > API breaks happen by looking at the .o debug data instead of our crazy
> > > > > current system (which is really better than nothing), perhaps we should
> > > > > start using them instead?
> > > > > 
> > > > > See here for more details about this:
> > > > > 	https://kernel-recipes.org/en/2016/talks/would-an-abi-changes-visualization-tool-be-useful-to-linux-kernel-maintenance/    
> > > > 
> > > > Hmm. I guess it's basically similar to modversions, so has downsides of not
> > > > detecting a semantic change unless it changes the type. But still, if we could
> > > > replace our custom code with a tool like this for modversions functionality,
> > > > that alone would be a massive improvement. But requiring debug info might be
> > > > a bit of a show stopper. I also don't know if that would handle asm functions.    
> > > 
> > > I think we can live without asm functions changing their arguments as
> > > that is usually very rare.  And maybe debugging info being a requirement
> > > for those that want modversions (i.e. the distros), is ok as they
> > > already generate that as part of their build.  
> > 
> > Maybe. I'd like to know how people really care about it. Linus post from
> > 
> > http://yarchive.net/comp/linux/modversions.html
> > 
> > Seem to be that he just likes it to prevent module loading if the git version
> > is not available. Fair usage, but could we do better with less effort? Maybe
> > ship with a source version that can do the same job. If you take care of that
> > case, then what is left?  
> 
> The goal is to be able to tell when a symbol changed somehow (structure
> or function signature) and if it has, then to hopefully prevent loading
> a module that doesn't have the same signature.  The distros really want
> this as they want "external" modules to load properly, even when they
> bump their main kernel package version.  And it's a good goal to have,
> no need to rebuild external packages (that usually come from external
> places) if you don't have to, as sometimes you need those modules to
> have your machine to work properly (like the fibre channel mess of
> out-of-tree drivers...)
> 
> So however that type of checking is done, is fine with me, I have no
> real desire to mess with this as personally, I never use it for my own
> machines (I just use module signing and then throw away the key after
> building the kernel).

So we have:

1. The distro users. They don't break ABI, they really just want a way to
   avoid the kernel version check.

2. Linus or other kernel developer who wants to prevent a kernel
   accidentally loading out of date modules when they test some changes
   that don't bump kernel version.

3. Advanced end user who does not want to have to recompile their nvidia
   blob.

Anything else? So, how to handle them?

1. Distros may just want a way to avoid checking some minor part of the
   version string. In rare cases where they do break ABI, they can just
   rename the symbol: external modules have a distro/version compat layer
   anyway.

2. I wonder if this is still important 8 years later now that everyone
   uses git everywhere? :) I also don't think modversions helps this case
   reliably because we don't change export types all that often. Can we
   ship a git version in the source tree somehow that git can handle
   specially?

3. These people today are not well supported with modversions because it
   does not tell them about incompatibility of ABI. Semantics could change.
   Structure args could change. Objects derived through various pointers
   could change. We should not even bother trying IMO. Just let them do
   forced loading at their own risk. We shouldn't offer a false sense of
   security.

Thanks,
Nick

  reply	other threads:[~2016-11-25  0:40 UTC|newest]

Thread overview: 113+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <a73aec83-ddad-2bdf-e612-178c9936a16f@manjaro.org>
     [not found] ` <20161102004639.6870806d@roar.ozlabs.ibm.com>
2016-11-23 20:08   ` BUG: 4.9-rc6 Still "no symbol version" on boot Philip Müller
2016-11-23 20:14     ` Robert LeBlanc
2016-11-23 20:27       ` Philip Müller
2016-11-23 20:53     ` Adam Borowski
2016-11-23 21:01       ` Robert LeBlanc
2016-11-23 21:02       ` [PATCH] x86/kbuild: enable modversions for symbols exported from asm Adam Borowski
2016-11-23 23:10         ` Philip Müller
2016-11-24  4:40         ` Ingo Molnar
2016-11-24  5:20           ` Nicholas Piggin
2016-11-24  6:00             ` Ingo Molnar
2016-11-24  7:20               ` Nicholas Piggin
2016-11-24  7:36                 ` Greg Kroah-Hartman
2016-11-24  7:53                   ` Nicholas Piggin
2016-11-24  9:32                     ` Michal Marek
2016-11-24 10:03                       ` Nicholas Piggin
2016-11-24 10:51                         ` Michal Marek
2016-11-24  9:38                     ` Arnd Bergmann
2016-11-24 10:01                       ` Nicholas Piggin
2016-11-24  9:56                     ` Greg Kroah-Hartman
2016-11-24 10:31                       ` Nicholas Piggin
2016-11-24 15:24                         ` Greg Kroah-Hartman
2016-11-25  0:40                           ` Nicholas Piggin [this message]
2016-11-25 18:00                             ` Linus Torvalds
2016-11-26  0:37                               ` Nicholas Piggin
2016-11-29  1:15                               ` Ben Hutchings
2016-11-29  2:31                                 ` Nicholas Piggin
2016-11-29  9:14                                   ` Michal Marek
2016-11-29  4:08                                 ` Linus Torvalds
2016-11-29 13:19                                   ` Adam Borowski
2016-11-29 13:29                                     ` Ingo Molnar
2016-11-29 14:24                                       ` Adam Borowski
2016-11-29 13:51                                     ` Adam Borowski
     [not found]                                       ` <CA+55aFyZiB4YkwvqzrXO=HD8bcnc2xHkAYrek2QHVnhVvAi3Fw@mail.gmail.com>
2016-11-29 16:03                                         ` Michal Marek
2016-11-29 16:17                                           ` Linus Torvalds
2016-11-29 19:57                                             ` Ben Hutchings
2016-11-29 20:35                                               ` Linus Torvalds
2016-11-30 18:18                                                 ` Nicholas Piggin
2016-11-30 18:40                                                   ` Linus Torvalds
2016-11-30 21:33                                                     ` Ben Hutchings
2016-12-01  1:55                                                       ` Nicholas Piggin
2016-12-01  2:35                                                         ` Ben Hutchings
2016-12-01  3:39                                                           ` Nicholas Piggin
2016-12-01 16:12                                                             ` Michal Marek
2016-12-02 14:36                                                               ` Hannes Frederic Sowa
2016-12-09  3:33                                                               ` Nicholas Piggin
2016-12-09 15:21                                                                 ` Ian Campbell
2016-12-09 16:15                                                                   ` Nicholas Piggin
2016-12-09 22:46                                                                     ` Dodji Seketeli
2016-12-10 12:41                                                                       ` Greg Kroah-Hartman
2016-12-12  3:50                                                                         ` Nicholas Piggin
2016-12-12  9:08                                                                         ` Ian Campbell
2016-12-14 17:59                                                                         ` Don Zickus
2016-12-13  1:07                                                                       ` Stanislav Kozina
2016-12-13 22:51                                                                       ` Michal Marek
2016-12-14  8:58                                                                         ` Dodji Seketeli
2016-12-14  9:15                                                                           ` Michal Marek
2016-12-14  9:36                                                                             ` Dodji Seketeli
2016-12-14  9:44                                                                               ` Michal Marek
2016-12-14 10:02                                                                                 ` Dodji Seketeli
2016-12-14 10:15                                                                                   ` Michal Marek
2016-12-14  9:56                                                                               ` Dodji Seketeli
2016-12-14  9:37                                                                             ` Michal Marek
2016-12-01  4:13                                                     ` Don Zickus
2016-12-01  4:32                                                       ` Nicholas Piggin
2016-12-01 15:20                                                         ` Don Zickus
2016-12-01 15:26                                                           ` Christoph Hellwig
2016-12-01 15:40                                                             ` Don Zickus
2016-12-01 16:06                                                               ` Greg Kroah-Hartman
2016-12-01 18:42                                                                 ` Don Zickus
2016-12-09  3:50                                                           ` Nicholas Piggin
2016-12-09  7:55                                                             ` Stanislav Kozina
2016-12-09  8:14                                                               ` Nicholas Piggin
2016-12-09 14:36                                                                 ` Stanislav Kozina
2016-12-09 15:56                                                                   ` Nicholas Piggin
2016-12-09 16:03                                                                     ` Greg Kroah-Hartman
2016-12-12  9:48                                                                       ` Stanislav Kozina
2016-12-13  7:25                                                                         ` Nicholas Piggin
2016-12-14 14:04                                                                       ` Hannes Frederic Sowa
2016-12-15  2:06                                                                         ` Nicholas Piggin
2016-12-15 11:19                                                                           ` Hannes Frederic Sowa
2016-12-15 12:03                                                                             ` Nicholas Piggin
2016-12-15 13:15                                                                               ` Hannes Frederic Sowa
2016-12-15 14:15                                                                                 ` Nicholas Piggin
2016-12-15 15:17                                                                                   ` Hannes Frederic Sowa
2016-12-15 13:35                                                                               ` Stanislav Kozina
2016-12-09 16:16                                                             ` Don Zickus
2016-12-01 10:48                                                       ` Stanislav Kozina
2016-12-01 11:09                                                         ` Nicholas Piggin
2016-12-01 11:33                                                           ` Stanislav Kozina
2016-12-01 12:39                                                             ` Nicholas Piggin
2016-12-01 15:19                                                           ` Dodji Seketeli
2016-12-01 16:14                                                       ` Michal Marek
2016-11-29 17:05                                         ` Adam Borowski
2016-11-29 17:10                                           ` Linus Torvalds
2016-11-29 17:14                                             ` Linus Torvalds
2016-12-01 13:58                                               ` Arnd Bergmann
2016-12-01 16:21                                                 ` Michal Marek
2016-12-01 18:26                                                 ` Linus Torvalds
2016-12-02 10:55                                                   ` Arnd Bergmann
2016-12-02 12:40                                                     ` [RFC, PATCH, v3.9] default exported asm symbols to zero Arnd Bergmann
2016-12-02 12:59                                                       ` Geert Uytterhoeven
2016-12-02 14:51                                                         ` Arnd Bergmann
2016-12-02 15:35                                                       ` Adam Borowski
2016-12-03  4:36                                                       ` Ben Hutchings
2016-12-03 10:43                                                         ` Arnd Bergmann
2016-12-02 17:04                                                     ` [PATCH] x86/kbuild: enable modversions for symbols exported from asm Linus Torvalds
2016-12-04  7:44                                                     ` Alan Modra
2016-12-04 20:44                                                       ` Linus Torvalds
2016-11-29 21:23                                             ` Michal Marek
2016-11-24  9:25           ` Michal Marek
2016-11-24 11:42         ` Regression: " Kalle Valo
2016-11-23 23:07       ` BUG: 4.9-rc6 Still "no symbol version" on boot Philip Müller
2016-11-28 17:10         ` Robert LeBlanc

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=20161125114018.12421474@roar.ozlabs.ibm.com \
    --to=npiggin@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=kilobyte@angband.pl \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=mmarek@suse.com \
    --cc=philm@manjaro.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).