From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9A1AB3385BE for ; Mon, 27 Apr 2026 15:59:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777305588; cv=none; b=NIN5tIuPr8XkW4Fk1hHyknigkVSFBLH5b36BeWLodJnPm7YQjX9ej8he4tvoPiekPXG06Z0ja0GSdq2PmwsKGYti9bBwJyE7+uNTEwTshQeye1XgsEkrpRWpMVFUCZjv+gjj9wrQJvYnIHlLKQKVNpACG9IknzJzs4rNfpgoooI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777305588; c=relaxed/simple; bh=UDbQrsy2gzvbWm0VEu65Ew2ISFqJfsCgGlHXVQxG7bU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:content-type; b=H/GqC1VWspuybkUJewXrJTVnRBrNm8HEtrpU2FxPNh23GYFEea723X4FopQkgorEYrejyevNkCy7QmAnptPblDJRsCeBL55tCreIdkV9G47QXmAU3zvJbNCXf73a/WUg+TLdcTaYgZgMIXKSJu9LkxSkVtlciPEGVYQs6ZIdy+A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DU0KXWVq; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DU0KXWVq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1777305586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4uDZloAQMjT5KxS6fE0PysXrnjAlm1DsM3DqS9DQe3Q=; b=DU0KXWVqk3bLttVf0nHXnp+/uQpW43AsFzHXMSc+sZDFt7Bhxt++Hr4IrlfmXg0CIQyD2G uBV/Kpn0oBdF2DFMwa3s/8Z3R3IHCi+OYSyjx7Rlip3pLFd6lc4Utm0TRk5qcb+cmb3fxA yjhPBkA4M1S3qw9ITpPo9i8mdAcybx4= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-540-fpQI05TnNQWP0V1h_Sg6ww-1; Mon, 27 Apr 2026 11:59:44 -0400 X-MC-Unique: fpQI05TnNQWP0V1h_Sg6ww-1 X-Mimecast-MFC-AGG-ID: fpQI05TnNQWP0V1h_Sg6ww_1777305583 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C95011800473 for ; Mon, 27 Apr 2026 15:59:43 +0000 (UTC) Received: from fs-i40c-03.fast.eng.rdu2.dc.redhat.com (fs-i40c-03.mgmt.fast.eng.rdu2.dc.redhat.com [10.6.24.150]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 54138300070A; Mon, 27 Apr 2026 15:59:43 +0000 (UTC) From: Alexander Aring To: teigland@redhat.com Cc: aahringo@redhat.com, gfs2@lists.linux.dev Subject: [PATCH RESEND v7.1-rc1 3/4] dlm: fix add msg handle in send_queue ordered Date: Mon, 27 Apr 2026 11:59:34 -0400 Message-ID: <20260427155935.2415989-4-aahringo@redhat.com> In-Reply-To: <20260427155935.2415989-1-aahringo@redhat.com> References: <20260427155935.2415989-1-aahringo@redhat.com> Precedence: bulk X-Mailing-List: gfs2@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: JmWOB6kTVFFTCNHRojEEnZogGCLhXXO5HWLs5fSjSSg_1777305583 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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: 489d8e559c659 ("fs: dlm: add reliable connection if reconnect") Signed-off-by: Alexander Aring --- fs/dlm/midcomms.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/dlm/midcomms.c b/fs/dlm/midcomms.c index a5b363b4785f3..6b522d4e2b7e3 100644 --- a/fs/dlm/midcomms.c +++ b/fs/dlm/midcomms.c @@ -969,10 +969,10 @@ static void midcomms_new_msg_cb(void *data) atomic_inc(&mh->node->send_queue_cnt); spin_lock_bh(&mh->node->send_queue_lock); + /* need to be locked with list_add_tail_rcu() because list is ordered */ + mh->seq = atomic_fetch_inc(&mh->node->seq_send); list_add_tail_rcu(&mh->list, &mh->node->send_queue); spin_unlock_bh(&mh->node->send_queue_lock); - - mh->seq = atomic_fetch_inc(&mh->node->seq_send); } static struct dlm_msg *dlm_midcomms_get_msg_3_2(struct dlm_mhandle *mh, int nodeid, -- 2.43.0