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

selftests/bpf:Enhance bpf ability to detect ksym read error by libcap #7727

Closed

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: selftests/bpf:Enhance bpf ability to detect ksym read error by libcap
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=890358

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 5277d13
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=890358
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 8826498
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=890358
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: de5cb0d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=890358
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: de5cb0d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=890358
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: de5cb0d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=890358
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 494c3a7
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=890358
version: 1

Ksym addr access is restricted
by ``kptr_restrict``(/proc/sys/kernel/kptr_restrict).

On some OS systems(like Android),
ksym addr access is not accessed because ``kptr_restrict=2`.
And it took me a long time to find the root case.

-When ``kptr_restrict==0``, addr is accessed.
	# echo 0 > /proc/sys/kernel/kptr_restrict
	# cat /proc/kallsyms | grep bpf_link_fops
	ffffffd6bfd3fb60 d bpf_link_fops
-When ``kptr_restrict==2``, addr is replaced by ZERO.
	# echo 2 > /proc/sys/kernel/kptr_restrict
	# cat /proc/kallsyms | grep bpf_link_fops
	0000000000000000 d bpf_link_fops
-When ``kptr_restrict==1``, addr is accessed for user having CAP_SYSLOG.

So we should perform a check to remind users for these conditions
before reading /proc/kallsyms.

[before]:
	# echo 2 > /proc/sys/kernel/kptr_restrict
	# ./test_progs -t ksyms
	#133     ksyms:FAIL

[after]:
	# echo 2 > /proc/sys/kernel/kptr_restrict
	# ./test_progs -t ksym
	ksyms restricted, please check /proc/sys/kernel/kptr_restrict
	#133     ksyms:FAIL

Signed-off-by: Lin Yikai <yikai.lin@vivo.com>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: a9f8c1b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=890358
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=890358 expired. Closing PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants