Unverified Commit 3ef7a727 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!4283 [sync] PR-4270: fix spinlock already unlocked in inet_csk_reqsk_queue_add' bug

Merge Pull Request from: @openeuler-sync-bot 
 

Origin pull request: 
https://gitee.com/openeuler/kernel/pulls/4270 
 
PR sync from: Zhengchao Shao <shaozhengchao@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/UJII37XCVE62ORCYB7K3UQBZL5DJ6ONQ/ 
Fix spinlock already unlocked in inet_csk_reqsk_queue_add' bug.

Zhengchao Shao (2):
  tcp: make sure init the accept_queue's spinlocks once
  ipv6: init the accept_queue's spinlocks in inet6_create


-- 
2.34.1
 
https://gitee.com/openeuler/kernel/issues/I8RJRU 
 
Link:https://gitee.com/openeuler/kernel/pulls/4283

 

Reviewed-by: default avatarYue Haibing <yuehaibing@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents c91aab5d 7267f8fe
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -344,4 +344,12 @@ static inline bool inet_csk_has_ulp(struct sock *sk)
	return inet_sk(sk)->is_icsk && !!inet_csk(sk)->icsk_ulp_ops;
}

static inline void inet_init_csk_locks(struct sock *sk)
{
	struct inet_connection_sock *icsk = inet_csk(sk);

	spin_lock_init(&icsk->icsk_accept_queue.rskq_lock);
	spin_lock_init(&icsk->icsk_accept_queue.fastopenq.lock);
}

#endif /* _INET_CONNECTION_SOCK_H */
+0 −3
Original line number Diff line number Diff line
@@ -33,9 +33,6 @@

void reqsk_queue_alloc(struct request_sock_queue *queue)
{
	spin_lock_init(&queue->rskq_lock);

	spin_lock_init(&queue->fastopenq.lock);
	queue->fastopenq.rskq_rst_head = NULL;
	queue->fastopenq.rskq_rst_tail = NULL;
	queue->fastopenq.qlen = 0;
+3 −0
Original line number Diff line number Diff line
@@ -327,6 +327,9 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
	if (INET_PROTOSW_REUSE & answer_flags)
		sk->sk_reuse = SK_CAN_REUSE;

	if (INET_PROTOSW_ICSK & answer_flags)
		inet_init_csk_locks(sk);

	inet = inet_sk(sk);
	inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0;

+4 −0
Original line number Diff line number Diff line
@@ -536,6 +536,10 @@ struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern)
	}
	if (req)
		reqsk_put(req);

	if (newsk)
		inet_init_csk_locks(newsk);

	return newsk;
out_err:
	newsk = NULL;
+3 −0
Original line number Diff line number Diff line
@@ -199,6 +199,9 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
	if (INET_PROTOSW_REUSE & answer_flags)
		sk->sk_reuse = SK_CAN_REUSE;

	if (INET_PROTOSW_ICSK & answer_flags)
		inet_init_csk_locks(sk);

	inet = inet_sk(sk);
	inet->is_icsk = (INET_PROTOSW_ICSK & answer_flags) != 0;