-
Notifications
You must be signed in to change notification settings - Fork 66
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
NET_NS=n leads to strange program header in liblinux.so #48
Comments
Actually, I was wrong --- CONFIG_NET_NS=y leads to a build error. The other solution still works, though. |
thanks for the issue report (and sorry to be late). it's indeed a problem with the inappropriate elf header and would be great if we can work with valgrind, which is always useful. this is a bit off-topic though but I've been thinking to this arch/lib code to migrate into LKL (linux kernel library), which I'm recently working on. i'm not yet porting all the stuff of net-next-nuse but i see the bright future with a clean design of lkl, which I expect to solve several issues of this repo (including #45). https://github.com/libos-nuse/lkl-linux is my working repository. it would be great if you still see this issue in lkl-linux. |
@thehajime I'll take a look at it. This was an extraordinarily weird problem --- I'd be surprised if it turned up again. Which branch of that repo is the most current one? |
(sorry for the cross-post) I would suggest to use https://github.com/lkl/linux, not my branch (https://github.com/libos-nuse/lkl-linux) as mine is unstable while the upstream is relatively stable. |
After
make defconfig ARCH=lib && make library ARCH=lib
, examiningliblinux.so
's program headers withreadelf -l
shows:The issue is the rwx permissions on section 00. As far as I can tell, the ELF standard allows for executable regions to be writable, but this breaks some standard tools (in particular, Valgrind on amd64) and may cause very subtle bugs down the line. It will also cause issues if nuse is run on architectures with W^X protection. It is caused by a quirk of config options, and isn't necessary for the library to work.
The problem is in section
.init.rodata
, which has rw- permissions. The problem in.init.rodata
comes fromnet/ipv6/{fib6_rules,addrlabel}.o
andnet/ipv4/{fib_rules,ipmr}.o
, which all have.init.rodata
sections with rw- permissions.The problem there comes from the use of the following macros, defined in
include/net/net_namespace.h
:which depend on the macros defined in
include/linux/init.h
:It can be fixed either by changing the
#ifdef CONFIG_NET_NS
line ininclude/net/net_namespace.h
to#if 1
, or by adding:to
arch/lib/Kconfig
. Then As far as I can tell,CONFIG_NET_NS=y
doesn't break anything in nuse, but I haven't yet tested it thoroughly. There may be a better fix that involves changing the problematic functions annotated with__net_initconst
innet/ipv6/{fib6_rules,addrlabel}.c
andnet/ipv4/{fib_rules,ipmr}.c
--- presumably this is not intended behavior.The text was updated successfully, but these errors were encountered: