Unverified Commit 43ce5700 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!11363 kcm: Serialise kcm_sendmsg() for the same socket.

parents 5c8833e9 2761a013
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ struct kcm_sock {
	struct work_struct tx_work;
	struct list_head wait_psock_list;
	struct sk_buff *seq_skb;
	struct mutex tx_mutex;
	u32 tx_stopped : 1;

	/* Don't use bit fields here, these are set under different locks */
+4 −0
Original line number Diff line number Diff line
@@ -754,6 +754,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
		  !(msg->msg_flags & MSG_MORE) : !!(msg->msg_flags & MSG_EOR);
	int err = -EPIPE;

	mutex_lock(&kcm->tx_mutex);
	lock_sock(sk);

	/* Per tcp_sendmsg this should be in poll */
@@ -925,6 +926,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
	KCM_STATS_ADD(kcm->stats.tx_bytes, copied);

	release_sock(sk);
	mutex_unlock(&kcm->tx_mutex);
	return copied;

out_error:
@@ -950,6 +952,7 @@ static int kcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
		sk->sk_write_space(sk);

	release_sock(sk);
	mutex_unlock(&kcm->tx_mutex);
	return err;
}

@@ -1203,6 +1206,7 @@ static void init_kcm_sock(struct kcm_sock *kcm, struct kcm_mux *mux)
	spin_unlock_bh(&mux->lock);

	INIT_WORK(&kcm->tx_work, kcm_tx_work);
	mutex_init(&kcm->tx_mutex);

	spin_lock_bh(&mux->rx_lock);
	kcm_rcv_ready(kcm);