linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Limiting linker scope
@ 2015-11-19 22:50 Richard Weinberger
  2015-11-19 23:34 ` Richard Weinberger
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Weinberger @ 2015-11-19 22:50 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linux-Arch, octavian.purdila

Hi!

UML recently had an interesting bug[1] where the host side of UML
tried to call sigsuspend() but as the kernel itself offers a function
with the same name it called sigsuspend() on
the UML kernel side and funny things happened.

The root cause of the problem is that the UML links userspace
code like glibc, libpcap, etc. to the kernel image and symbols can
clash. Especially if one side is a shared library it will not noticed
at compile time.

As this is not the first bug of this kind I'm facing on UML I've
started to think how to deal with that.

Is it somehow possible to limit the linker scope?
Such that we can force LD no not blindly link every symbols of
vmlinux into another object? Maybe using a white list?
I have do admit I've never used LD scripts nor GNU export maps,
maybe they can help. Currently I'm reading their docs and hope
to find a way to implement my idea.

The problem is also not specific to UML, the emerging Linux Kernel
Library will suffer from the same issue.
As random programs will link the kernel as library the chance is
high to face similar symbol conflicts.

Maybe we can also find a nice generic solution to limit the linker
scope within the kernel. Such that it does not hurt when a random device
driver exports a symbol like "i".
It would also help to define subsystem interface more strict manner.

Thanks,
//richard

[1] https://lkml.org/lkml/2015/11/16/601

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [RFC] Limiting linker scope
  2015-11-19 22:50 [RFC] Limiting linker scope Richard Weinberger
@ 2015-11-19 23:34 ` Richard Weinberger
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Weinberger @ 2015-11-19 23:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Linux-Arch, octavian.purdila

Am 19.11.2015 um 23:50 schrieb Richard Weinberger:
> Hi!
> 
> UML recently had an interesting bug[1] where the host side of UML
> tried to call sigsuspend() but as the kernel itself offers a function
> with the same name it called sigsuspend() on
> the UML kernel side and funny things happened.
> 
> The root cause of the problem is that the UML links userspace
> code like glibc, libpcap, etc. to the kernel image and symbols can
> clash. Especially if one side is a shared library it will not noticed
> at compile time.
> 
> As this is not the first bug of this kind I'm facing on UML I've
> started to think how to deal with that.
> 
> Is it somehow possible to limit the linker scope?
> Such that we can force LD no not blindly link every symbols of
> vmlinux into another object? Maybe using a white list?
> I have do admit I've never used LD scripts nor GNU export maps,
> maybe they can help. Currently I'm reading their docs and hope
> to find a way to implement my idea.
> 
> The problem is also not specific to UML, the emerging Linux Kernel
> Library will suffer from the same issue.

I take this back. LKL continues to impress me.
It creates a new kernel object using objcopy -G and marks only some
symbols as global. This approach could work for UML too.

Thanks,
//richard

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-19 23:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-19 22:50 [RFC] Limiting linker scope Richard Weinberger
2015-11-19 23:34 ` Richard Weinberger

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).