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

net: bpf: handle return value of BPF_CGROUP_RUN_PROG_INET4_POST_BIND() #2339

Closed
wants to merge 2 commits into from

Conversation

kernel-patches-bot
Copy link

Pull request for series with
subject: net: bpf: handle return value of BPF_CGROUP_RUN_PROG_INET4_POST_BIND()
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=601424

@kernel-patches-bot
Copy link
Author

Master branch: ecf45e6
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=601424
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: f60edf5
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=601424
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 5b3d729
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=601424
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: b645941
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=601424
version: 1

@kernel-patches-bot
Copy link
Author

Master branch: 3ccdcee
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=601424
version: 1

The return value of BPF_CGROUP_RUN_PROG_INET4_POST_BIND() in
__inet_bind() is not handled properly. While the return value
is non-zero, it will set inet_saddr and inet_rcv_saddr to 0 and
exit:

	err = BPF_CGROUP_RUN_PROG_INET4_POST_BIND(sk);
	if (err) {
		inet->inet_saddr = inet->inet_rcv_saddr = 0;
		goto out_release_sock;
	}

Let's take UDP for example and see what will happen. For UDP
socket, it will be added to 'udp_prot.h.udp_table->hash' and
'udp_prot.h.udp_table->hash2' after the sk->sk_prot->get_port()
called success. If 'inet->inet_rcv_saddr' is specified here,
then 'sk' will be in the 'hslot2' of 'hash2' that it don't belong
to (because inet_saddr is changed to 0), and UDP packet received
will not be passed to this sock. If 'inet->inet_rcv_saddr' is not
specified here, the sock will work fine, as it can receive packet
properly, which is wired, as the 'bind()' is already failed.

I'm not sure what should do here, maybe we should unhash the sock
for UDP? Therefor, user can try to bind another port?

Signed-off-by: Menglong Dong <imagedong@tencent.com>
@kernel-patches-bot
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=601424 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.

2 participants