Skip to content

Commit

Permalink
Squash to "bpf: Add mptcp_subflow bpf_iter"
Browse files Browse the repository at this point in the history
Add "sizeof" and "alignof" checks.

Address Martin's comments in v1:

- bpf_iter_mptcp_subflow_new returns -EINVAL when msk socket lock isn't
  held.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed Dec 11, 2024
1 parent 90fbb76 commit 53c7e22
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion net/mptcp/bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,20 @@ bpf_iter_mptcp_subflow_new(struct bpf_iter_mptcp_subflow *it,
struct mptcp_sock *msk)
{
struct bpf_iter_mptcp_subflow_kern *kit = (void *)it;
struct sock *sk = (struct sock *)msk;

BUILD_BUG_ON(sizeof(struct bpf_iter_mptcp_subflow_kern) >
sizeof(struct bpf_iter_mptcp_subflow));
BUILD_BUG_ON(__alignof__(struct bpf_iter_mptcp_subflow_kern) !=
__alignof__(struct bpf_iter_mptcp_subflow));

kit->msk = msk;
if (!msk)
return -EINVAL;

msk_owned_by_me(msk);
if (!sock_owned_by_user_nocheck(sk) &&
!spin_is_locked(&sk->sk_lock.slock))
return -EINVAL;

kit->pos = &msk->conn_list;
return 0;
Expand Down

0 comments on commit 53c7e22

Please sign in to comment.