Skip to content
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

undefined symbol: timer_create #71

Closed
alex opened this issue Feb 9, 2016 · 2 comments
Closed

undefined symbol: timer_create #71

alex opened this issue Feb 9, 2016 · 2 comments

Comments

@alex
Copy link

alex commented Feb 9, 2016

In my attempt to fuzz the kernel X.509 API (#58), I've ran into an interesting bug. I'm using the following patch:

diff --git a/arch/lkl/Makefile b/arch/lkl/Makefile
index cd4ae2a..b3e62dc 100644
--- a/arch/lkl/Makefile
+++ b/arch/lkl/Makefile
@@ -22,7 +22,7 @@ endif

 LDFLAGS_vmlinux += -r
 LKL_ENTRY_POINTS := lkl_start_kernel lkl_sys_halt lkl_syscall lkl_trigger_irq \
-   lkl_get_free_irq lkl_put_irq
+   lkl_get_free_irq lkl_put_irq x509_cert_parse

 core-y += arch/lkl/kernel/

diff --git a/tools/lkl/Makefile b/tools/lkl/Makefile
index e3bd8b2..78148a2 100644
--- a/tools/lkl/Makefile
+++ b/tools/lkl/Makefile
@@ -61,6 +61,14 @@ lib/liblkl-hijack.so: $(hijack_objs) Makefile lib/liblkl.so

 lib/lkl.o:
    $(MAKE) -C ../.. ARCH=lkl defconfig
+   echo "CONFIG_ASN1=y" >> ../../.config
+   echo "CONFIG_ASYMMETRIC_KEY_TYPE=y" >> ../../.config
+   echo "CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y" >> ../../.config
+   echo "CONFIG_PUBLIC_KEY_ALGO_RSA=y" >> ../../.config
+   echo "CONFIG_X509_CERTIFICATE_PARSER=y" >> ../../.config
+   echo "CONFIG_PKCS7_MESSAGE_PARSER=n" >> ../../.config
+   echo "CONFIG_KEYS=y" >> ../../.config
+   $(MAKE) -C ../.. ARCH=lkl silentoldconfig
    $(MAKE) -C ../.. ARCH=lkl $(KOPT) install INSTALL_PATH=$(PWD)

 %: %.o

And it all compiles ok, but when I try to load liblkl.so, no bueno:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/lkl-linux/tools/lkl$ python -c "import ctypes; ctypes.CDLL('./lib/liblkl.so')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: ./lib/liblkl.so: undefined symbol: timer_create

Here's the complete build log:
build.log.txt

@tommie-lie
Copy link

liblkl.so depends on some other libraries for its host-specific stuff, in your case it needs librt.
The way liblkl.so is currently build does not include these dependencies, they are only added for liblkl-hijack.so. If you want to use liblkl.so independently, you have to link with -lrt -lpthread and probably -ldl. Just add those to line 55 of the Makefile and ctypes should pick them up automatically (see line 60).

@alex
Copy link
Author

alex commented Feb 9, 2016

Ahh, I didn't realize that liblkl-hijack.so was the right entrypoint:

vagrant@vagrant-ubuntu-trusty-64:/vagrant/lkl-linux/tools/lkl$ env LD_LIBRARY_PATH=$(pwd)/lib:$LD_LIBRARY_PATH python -c "import ctypes; ctypes.CDLL('./lib/liblkl-hijack.so')"
vagrant@vagrant-ubuntu-trusty-64:/vagrant/lkl-linux/tools/lkl$ echo $?
0

Thanks!

@alex alex closed this as completed Feb 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants