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
libbpf: Support symbol versioning for uprobe #5632
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Upstream branch: 831c4b3 |
Upstream branch: 831c4b3 |
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
2 times, most recently
from
September 7, 2023 17:34
ad25bf7
to
43bf134
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 8, 2023 16:05
4108f32
to
12fd492
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 8, 2023 16:07
43bf134
to
77cf2b0
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 8, 2023 23:32
12fd492
to
eb86bf3
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 8, 2023 23:33
77cf2b0
to
511d9c0
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 8, 2023 23:37
eb86bf3
to
bd3fa85
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
2 times, most recently
from
September 11, 2023 01:58
b1ed794
to
180ae4c
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 11, 2023 21:04
bd3fa85
to
6f242f7
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 11, 2023 21:07
180ae4c
to
ae3eb55
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 12, 2023 00:29
6f242f7
to
5bf85b8
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 12, 2023 00:31
ae3eb55
to
df288f2
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 12, 2023 06:11
5bf85b8
to
58ad940
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 12, 2023 06:14
df288f2
to
072a2b6
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 12, 2023 18:42
58ad940
to
9fa78e1
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 12, 2023 18:44
072a2b6
to
c199a35
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 12, 2023 20:13
9fa78e1
to
150ddda
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 12, 2023 20:15
c199a35
to
be3da87
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 12, 2023 20:49
150ddda
to
2053442
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 12, 2023 20:52
be3da87
to
8050551
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 12, 2023 21:04
2053442
to
4633cc0
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 12, 2023 21:06
8050551
to
67f9b02
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 12, 2023 21:55
4633cc0
to
30a2f10
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 12, 2023 21:57
67f9b02
to
a17d499
Compare
kernel-patches-daemon-bpf
bot
force-pushed
the
bpf-next_base
branch
from
September 12, 2023 22:25
30a2f10
to
1fd6cd6
Compare
Dynamic symbols in shared library may have the same name, for example: $ nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep rwlock_wrlock 000000000009b1a0 T __pthread_rwlock_wrlock@GLIBC_2.2.5 000000000009b1a0 T pthread_rwlock_wrlock@@GLIBC_2.34 000000000009b1a0 T pthread_rwlock_wrlock@GLIBC_2.2.5 $ readelf -W --dyn-syms /lib/x86_64-linux-gnu/libc.so.6 | grep rwlock_wrlock 706: 000000000009b1a0 878 FUNC GLOBAL DEFAULT 15 __pthread_rwlock_wrlock@GLIBC_2.2.5 2568: 000000000009b1a0 878 FUNC GLOBAL DEFAULT 15 pthread_rwlock_wrlock@@GLIBC_2.34 2571: 000000000009b1a0 878 FUNC GLOBAL DEFAULT 15 pthread_rwlock_wrlock@GLIBC_2.2.5 Currently, users can't attach a uprobe to pthread_rwlock_wrlock because there are two symbols named pthread_rwlock_wrlock and both are global bind. And libbpf considers it as a conflict. Since both of them are at the same offset we could accept one of them harmlessly. Note that we already does this in elf_resolve_syms_offsets. Reviewed-by: Alan Maguire <alan.maguire@oracle.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
In current implementation, we assume that symbol found in .dynsym section would have a version suffix and use it to compare with symbol user supplied. According to the spec ([0]), this assumption is incorrect, the version info of dynamic symbols are stored in .gnu.version and .gnu.version_d sections of ELF objects. For example: $ nm -D /lib/x86_64-linux-gnu/libc.so.6 | grep rwlock_wrlock 000000000009b1a0 T __pthread_rwlock_wrlock@GLIBC_2.2.5 000000000009b1a0 T pthread_rwlock_wrlock@@GLIBC_2.34 000000000009b1a0 T pthread_rwlock_wrlock@GLIBC_2.2.5 $ readelf -W --dyn-syms /lib/x86_64-linux-gnu/libc.so.6 | grep rwlock_wrlock 706: 000000000009b1a0 878 FUNC GLOBAL DEFAULT 15 __pthread_rwlock_wrlock@GLIBC_2.2.5 2568: 000000000009b1a0 878 FUNC GLOBAL DEFAULT 15 pthread_rwlock_wrlock@@GLIBC_2.34 2571: 000000000009b1a0 878 FUNC GLOBAL DEFAULT 15 pthread_rwlock_wrlock@GLIBC_2.2.5 In this case, specify pthread_rwlock_wrlock@@GLIBC_2.34 or pthread_rwlock_wrlock@GLIBC_2.2.5 in bpf_uprobe_opts::func_name won't work. Because the qualified name does NOT match `pthread_rwlock_wrlock` (without version suffix) in .dynsym sections. This commit implements the symbol versioning for dynsym and allows user to specify symbol in the following forms: - func - func@LIB_VERSION - func@@LIB_VERSION In case of symbol conflicts, error out and users should resolve it by specifying a qualified name. [0]: https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html Reviewed-by: Alan Maguire <alan.maguire@oracle.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
This exercises the newly added dynsym symbol versioning logics. Now we accept symbols in form of func, func@LIB_VERSION or func@@LIB_VERSION. The test rely on liburandom_read.so. For liburandom_read.so, we have: $ nm -D liburandom_read.so w __cxa_finalize@GLIBC_2.17 w __gmon_start__ w _ITM_deregisterTMCloneTable w _ITM_registerTMCloneTable 0000000000000000 A LIBURANDOM_READ_1.0.0 0000000000000000 A LIBURANDOM_READ_2.0.0 000000000000081c T urandlib_api@@LIBURANDOM_READ_2.0.0 0000000000000814 T urandlib_api@LIBURANDOM_READ_1.0.0 0000000000000824 T urandlib_api_sameoffset@LIBURANDOM_READ_1.0.0 0000000000000824 T urandlib_api_sameoffset@@LIBURANDOM_READ_2.0.0 000000000000082c T urandlib_read_without_sema@@LIBURANDOM_READ_1.0.0 00000000000007c4 T urandlib_read_with_sema@@LIBURANDOM_READ_1.0.0 0000000000011018 D urandlib_read_with_sema_semaphore@@LIBURANDOM_READ_1.0.0 For `urandlib_api`, specifying `urandlib_api` will cause a conflict because there are two symbols named urandlib_api and both are global bind. For `urandlib_api_sameoffset`, there are also two symbols in the .so, but both are at the same offset and essentially they refer to the same function so no conflict. Reviewed-by: Alan Maguire <alan.maguire@oracle.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com>
kernel-patches-daemon-bpf
bot
force-pushed
the
series/781414=>bpf-next
branch
from
September 12, 2023 22:27
a17d499
to
9464edb
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=782774 expired. Closing PR. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull request for series with
subject: libbpf: Support symbol versioning for uprobe
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=782232