From acd1add3c84293309ccc89ecca1c604e4add28ab Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 15 Jan 2024 11:32:48 +0000 Subject: [PATCH] Revert "bpf, sockmap: af_unix stream sockets need to hold ref for pair sock" This reverts commit 90d1f74c3cf68e6a987c370a50d30a66ef39f5c2 which is commit bffdeaa8a5af7200b0e74c9d5a41167f86626a36 upstream. It breaks the Android kernel abi and can be brought back in the future in an abi-safe way if it is really needed. Bug: 161946584 Change-Id: I8f9ee72f8269598b93fe7abb14acd0d190242dcc Signed-off-by: Greg Kroah-Hartman --- include/linux/skmsg.h | 1 - include/net/af_unix.h | 1 - net/core/skmsg.c | 2 -- net/unix/af_unix.c | 2 ++ net/unix/unix_bpf.c | 5 ----- 5 files changed, 2 insertions(+), 9 deletions(-) diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h index c953b8c0d2f4..c1637515a8a4 100644 --- a/include/linux/skmsg.h +++ b/include/linux/skmsg.h @@ -106,7 +106,6 @@ struct sk_psock { struct mutex work_mutex; struct sk_psock_work_state work_state; struct delayed_work work; - struct sock *sk_pair; struct rcu_work rwork; }; diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 55ca217c626b..480fa579787e 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -77,7 +77,6 @@ static inline struct unix_sock *unix_sk(const struct sock *sk) { return (struct unix_sock *)sk; } -#define unix_peer(sk) (unix_sk(sk)->peer) #define peer_wait peer_wq.wait diff --git a/net/core/skmsg.c b/net/core/skmsg.c index 3818035ea002..a5c1f67dc96e 100644 --- a/net/core/skmsg.c +++ b/net/core/skmsg.c @@ -825,8 +825,6 @@ static void sk_psock_destroy(struct work_struct *work) if (psock->sk_redir) sock_put(psock->sk_redir); - if (psock->sk_pair) - sock_put(psock->sk_pair); sock_put(psock->sk); kfree(psock); } diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index be2ed7b0fe21..6dbeb8007333 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -211,6 +211,8 @@ static inline bool unix_secdata_eq(struct scm_cookie *scm, struct sk_buff *skb) } #endif /* CONFIG_SECURITY_NETWORK */ +#define unix_peer(sk) (unix_sk(sk)->peer) + static inline int unix_our_peer(struct sock *sk, struct sock *osk) { return unix_peer(osk) == sk; diff --git a/net/unix/unix_bpf.c b/net/unix/unix_bpf.c index 7ea7c3a0d0d0..2f9d8271c6ec 100644 --- a/net/unix/unix_bpf.c +++ b/net/unix/unix_bpf.c @@ -159,17 +159,12 @@ int unix_dgram_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool re int unix_stream_bpf_update_proto(struct sock *sk, struct sk_psock *psock, bool restore) { - struct sock *sk_pair; - if (restore) { sk->sk_write_space = psock->saved_write_space; sock_replace_proto(sk, psock->sk_proto); return 0; } - sk_pair = unix_peer(sk); - sock_hold(sk_pair); - psock->sk_pair = sk_pair; unix_stream_bpf_check_needs_rebuild(psock->sk_proto); sock_replace_proto(sk, &unix_stream_bpf_prot); return 0;