Message ID | 20210629062029.13684-1-xiyou.wangcong@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | [bpf] skmsg: check sk_rcvbuf limit before queuing to ingress_skb | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | fail | Series targets non-next tree, but doesn't contain any Fixes tags |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 8 maintainers not CCed: yhs@fb.com kpsingh@kernel.org andrii@kernel.org kafai@fb.com ast@kernel.org songliubraving@fb.com davem@davemloft.net kuba@kernel.org |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 1 this patch: 1 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: line length of 91 exceeds 80 columns |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 1 this patch: 1 |
netdev/header_inline | success | Link |
On Tue, Jun 29, 2021 at 08:20 AM CEST, Cong Wang wrote: [...] > @@ -854,7 +854,8 @@ static int sk_psock_skb_redirect(struct sk_psock *from, struct sk_buff *skb) > return -EIO; > } > spin_lock_bh(&psock_other->ingress_lock); > - if (!sk_psock_test_state(psock_other, SK_PSOCK_TX_ENABLED)) { > + if (!sk_psock_test_state(psock_other, SK_PSOCK_TX_ENABLED) || > + atomic_read(&sk_other->sk_rmem_alloc) > sk_other->sk_rcvbuf) { > spin_unlock_bh(&psock_other->ingress_lock); > skb_bpf_redirect_clear(skb); > sock_drop(from->sk, skb); > @@ -930,7 +931,8 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb, > } > if (err < 0) { > spin_lock_bh(&psock->ingress_lock); > - if (sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)) { > + if (sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED) && > + atomic_read(&sk_other->sk_rmem_alloc) <= sk_other->sk_rcvbuf) { > skb_queue_tail(&psock->ingress_skb, skb); > schedule_work(&psock->work); > err = 0; I belive access to sk_rcvbuf should be annotated with READ_ONCE (for KCSAN's sake) as we don't lock the egress socket. See 8265792bf887 [1] ("net: silence KCSAN warnings around sk_add_backlog() calls") for guidance. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8265792bf8871acc2d00fd03883d830e2249d395
diff --git a/net/core/skmsg.c b/net/core/skmsg.c index 9b6160a191f8..83b581d8023d 100644 --- a/net/core/skmsg.c +++ b/net/core/skmsg.c @@ -854,7 +854,8 @@ static int sk_psock_skb_redirect(struct sk_psock *from, struct sk_buff *skb) return -EIO; } spin_lock_bh(&psock_other->ingress_lock); - if (!sk_psock_test_state(psock_other, SK_PSOCK_TX_ENABLED)) { + if (!sk_psock_test_state(psock_other, SK_PSOCK_TX_ENABLED) || + atomic_read(&sk_other->sk_rmem_alloc) > sk_other->sk_rcvbuf) { spin_unlock_bh(&psock_other->ingress_lock); skb_bpf_redirect_clear(skb); sock_drop(from->sk, skb); @@ -930,7 +931,8 @@ static int sk_psock_verdict_apply(struct sk_psock *psock, struct sk_buff *skb, } if (err < 0) { spin_lock_bh(&psock->ingress_lock); - if (sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)) { + if (sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED) && + atomic_read(&sk_other->sk_rmem_alloc) <= sk_other->sk_rcvbuf) { skb_queue_tail(&psock->ingress_skb, skb); schedule_work(&psock->work); err = 0;