Revert "bpf, sockmap: af_unix stream sockets need to hold ref for pair sock"

This reverts commit 90d1f74c3c 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 <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman 2024-01-15 11:32:48 +00:00
parent 190985b1db
commit acd1add3c8
5 changed files with 2 additions and 9 deletions

View File

@ -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;
};

View File

@ -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

View File

@ -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);
}

View File

@ -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;

View File

@ -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;