Page MenuHomeFreeBSD

PR 291273 - p9fs module missing symbol exports -- dependent modules fail to load with module loader local symbol resolution disabled
AcceptedPublic

Authored by rupeshpilania_gmail.com on Tue, Dec 2, 6:14 PM.

Details

Summary

PR 291273 reported that the virtio_p9fs.ko module fails to load when
debug.link_elf_obj_leak_locals=0 because p9fs does not export the
required symbols.

This patch adds EXPORT_SYMS to sys/modules/p9fs/Makefile so that the
following symbols are intentionally exported:

p9_init_zones
p9_destroy_zones
p9_register_trans
p9_debug_level

With these exports, virtio_p9fs.ko loads successfully.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 69002
Build 65885: arc lint + arc unit

Event Timeline

if you confirm Rupesh Pilania <rupeshpilania@gmail.com> as the git commit author I'll push this, thanks!

I'll take care of reformatting the commit message for our standard style, such as using the standard PR: 291273 trailer metadata.

This revision is now accepted and ready to land.Tue, Dec 2, 9:55 PM

Why can't we make virtio_p9fs.ko depend on p9fs.ko? That would also cover this case, no? And would confine their visibility to that one module, no? It's how we do pci, etc.

In D54037#1234622, @imp wrote:

Why can't we make virtio_p9fs.ko depend on p9fs.ko? That would also cover this case, no? And would confine their visibility to that one module, no? It's how we do pci, etc.

It's independent of module dependencies. If p9fs doesn't export symbols then those symbols will not be available to the kernel module linker, once we disable leaking local & debug symbols.

if you confirm Rupesh Pilania <rupeshpilania@gmail.com> as the git commit author I'll push this, thanks!

I'll take care of reformatting the commit message for our standard style, such as using the standard PR: 291273 trailer metadata.

Yes, please push this

In D54037#1234622, @imp wrote:

Why can't we make virtio_p9fs.ko depend on p9fs.ko?

Indeed virtio_p9fs.ko depends on p9fs.ko. See https://github.com/freebsd/freebsd-src/blob/ef8a0ef2aa97650f37052719496bfbe4ab97a019/sys/dev/virtio/p9fs/virtio_p9fs.c#L494 .

MODULE_DEPEND(virtio_p9fs, p9fs, 1, 1, 1);
In D54037#1234622, @imp wrote:

That would also cover this case, no? And would confine their visibility to that one module, no? It's how we do pci, etc.

No. For the build of standalone kernel modules, the EXPORT_SYMS variable controls whether the public symbols will be hidden or not. See commit 0b3178a45cd08a2387bff09a2844deacc97ae1e7 .