-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix symbol resolution issues #48
Conversation
devt2devname is under the default license and can be moved to libmultipath. Signed-off-by: Martin Wilck <[email protected]>
in libmpathutil, udev was only used by devt2devname. Remove it. Signed-off-by: Martin Wilck <[email protected]>
This symbol should live in libmpathutil only. Signed-off-by: Martin Wilck <[email protected]>
Using of __attribute__((weak)) here has no effect for dynamic linking. Quoting from ld.so(8): "Standard practice is that the distinction between weak and strong symbols should have effect only at static link time." See also the ELF specification, p. 1-18 "Symbol Table". We would only need this if we supported static linking for multipath-tools, which we haven't done for a long time.
Some symbols like get_multipath_config are exported by both libmpathutil and libmultipath. The symbols exported by `libmpathutil` are dummies, intended to be overridden by `libmultipath` using "breadth-first" symbol lookup search specified by ELF [1]. The dummy symbols are only used by programs not linking to libmultipath, i.e. multipathc. Because we're using ABI versioning, code in libmpathutil actually exports *and references* `get_multipath_config@LIBMULTIPATH_16.0.0`. That worked until 0.9.1, because both libraries were using the same ABI version, and `get_multipath_config@LIBMULTIPATH_16.0.0` from libmultipath overrides the symbol from libmpathutil. But in 0.9.2, we bumped the ABI version of libmultipath to 17.0.0. libmultipath now exports (only) `get_multipath_config@LIBMULTIPATH_17.0.0`, which does *not* override `get_multipath_config@LIBMULTIPATH_16.0.0` from libmpathutil. The effect is that references to these duplicate symbols from libmpathutil are resolved to its own dummy symbols, which is wrong and causes a coredump e.g. with "multipath -t", where the return value of get_multipath_config() is accessed in the call chain snprint_keyword()->snprint_defaults(). This happens only with multipath, because multipathd itself overrides get_multipath_config(). [1]: Executable and Linkable Format (ELF) (https://www.cs.cmu.edu/afs/cs/academic/class/15213-f00/docs/elf.pdf), p. 2-15 ("Shared Object Dependencies") Signed-off-by: Martin Wilck <[email protected]>
Compare to the example in #47 (comment):
|
I can confirm this does no longer crash for me. Thanks a lot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It all looks good to me.
Will we see a new release with this? |
We haven't done that in the past. We usually accumulate some commits before we bump the version. @cvaroqui, would you bump to 0.9.3? |
Ok. Can you prepare the pr ? I will merge and tag asap |
Hi @cvaroqui, hi @bmarzins,
This set fixes #47. The problem analysis can be seen in #47, and in the description of
6e8aec6. In short, if we use duplicate symbols in different shared objects, we need to keep
the versions of these symbols in sync, otherwise symbol lookup won't work as intended.
I've sent this via GitHub and not via
dm-devel
because it's really purely technical stuff thatmatters only little for the ML, and because people who upgrade multipath-tools because of
CVE-2022-41973 and CVE-2022-41974 will be looking here.
The solution for the problem is 3-fold:
udev
andlibmpverbosity
aren't duplicated any more, but defined only in libmultipath and libmpathutil, respectively.get_multipath_config
andput_multipath_config
as duplicate symbols. For these, we use a new ABI "version"LIBMPATHCOMMON_1.0.0
, with comments that make it clear that the version of these symbols must be changed synchronously in the two libraries.Martin Wilck (5):
libmpathutil: move devt2devname() to libmultipath
libmpathutil: remove udev symbol
libmultipath: remove duplicate export of libmp_verbosity
libmpathutil: remove
__attribute__((weak))
libmultipath/libmpathutil: use common ABI version for duplicate symbols
@xosevp for information.