Skip to content

Commit ae9e534

Browse files
Alexander Aringgregkh
authored andcommitted
dlm: fix add msg handle in send_queue ordered
[ Upstream commit d2248cb ] In a benchmark scenario triggering a lot of requests that triggers a lot of DLM messages on the network it can be that the mh->seq is not ordered according the oldest seq number. This ordering is required by dlm_receive_ack as "before(mh->seq, seq)" will stop to check for older sequence numbers that are ordered in the tail of "node->send_queue". The side effects of not having it correct ordered regarding "before(mh->seq, seq)" are refcounting issues and use-after free. I only was able to reproduce this issue in a experimental DLM branch and a user space DLM benchmark that uses io_uring. After changing this I don't experienced any refcounting with the sending buffer issues anymore. Fixes: 489d8e5 ("fs: dlm: add reliable connection if reconnect") Signed-off-by: Alexander Aring <aahringo@redhat.com> Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 6279383 commit ae9e534

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/dlm/midcomms.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,10 +970,10 @@ static void midcomms_new_msg_cb(void *data)
970970
atomic_inc(&mh->node->send_queue_cnt);
971971

972972
spin_lock_bh(&mh->node->send_queue_lock);
973+
/* need to be locked with list_add_tail_rcu() because list is ordered */
974+
mh->seq = atomic_fetch_inc(&mh->node->seq_send);
973975
list_add_tail_rcu(&mh->list, &mh->node->send_queue);
974976
spin_unlock_bh(&mh->node->send_queue_lock);
975-
976-
mh->seq = atomic_fetch_inc(&mh->node->seq_send);
977977
}
978978

979979
static struct dlm_msg *dlm_midcomms_get_msg_3_2(struct dlm_mhandle *mh, int nodeid,

0 commit comments

Comments
 (0)