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.129.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 3DEA83A7D98 for ; Tue, 12 May 2026 14:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594596; cv=none; b=hcyAgMC3DKzU3q7M4fpxrh5MPakuwdSaBs244vR0mzkGFd+AnbX/Tx1LJ9eLebZApivYdnih8C1M1S7YwnKbn1IFP+b1vmROIQNSHRDmSwF28aDtYEaAhvUxGegLfc/ppBDCpoz2Gc2du7NvjncyD4/Sqt2d9qv8o+wEJmrbWO8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778594596; c=relaxed/simple; bh=G2dxhYV8b68zGT1Hgku5dCKmGIEML0IemM2I2YbedU4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fgE381WYIf6HURpWyhTbGkH92awdXjG7mD3wC3eUls3v99zdSz51H6nWEhAWrLwB1wwZMZpMZf0NWDbeCbnwNyO4DqueVn6bypE2zjkCAA7rRqhPu/oQGF9X2NFW8yRq1GcVpxE/sb/7DkkEKKiA0+lYxVYlY+uC7VmRuhifsfU= 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=feNycSn2; arc=none smtp.client-ip=170.10.129.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="feNycSn2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778594594; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EvfKR93hyiPppA7Uwohf3hx+XK0GIX0z8gBzIkmsYw0=; b=feNycSn2AD6s6OxsNh7NDfOUQDFVo2K5lpLjZsxxG3DueYRUIptzyRBmhpoW7+6IbNvEvC EGcSdZDoCn1l4yPeSYisz9Z631ep8MgdDGmEIw8ITtXJorS4GVoZVb2zA6EcNFmEpZ4GdY bGph61ktiDKAJLaLVp70wx0cDqeHgKA= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-687-zXTRIZvPMROC5j3VunenFQ-1; Tue, 12 May 2026 10:03:09 -0400 X-MC-Unique: zXTRIZvPMROC5j3VunenFQ-1 X-Mimecast-MFC-AGG-ID: zXTRIZvPMROC5j3VunenFQ_1778594587 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D885F19560AF; Tue, 12 May 2026 14:03:06 +0000 (UTC) Received: from gmonaco-thinkpadt14gen3.rmtit.csb (unknown [10.44.34.139]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A3D441800465; Tue, 12 May 2026 14:03:04 +0000 (UTC) From: Gabriele Monaco To: linux-kernel@vger.kernel.org, Steven Rostedt , Gabriele Monaco , Nam Cao , linux-trace-kernel@vger.kernel.org Cc: Wen Yang Subject: [PATCH 3/9] rv: Reset per-task DA monitors before releasing the slot Date: Tue, 12 May 2026 16:02:44 +0200 Message-ID: <20260512140250.262190-4-gmonaco@redhat.com> In-Reply-To: <20260512140250.262190-1-gmonaco@redhat.com> References: <20260512140250.262190-1-gmonaco@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Per-task monitors use task_mon_slot to determine which slot in the array to use for the monitor. During destruction, this slot is returned but this is done before resetting the monitor. As a result, the monitor's reset is in fact resetting a slot that is outside of the array (RV_PER_TASK_MONITOR_INIT). Release the slot only after the reset to avoid out-of-bound memory access. Fixes: 30984ccf31b7f ("rv: Refactor da_monitor to minimise macros") Fixes: 792575348ff70 ("rv/include: Add deterministic automata monitor definition via C macros") Signed-off-by: Gabriele Monaco --- include/rv/da_monitor.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/rv/da_monitor.h b/include/rv/da_monitor.h index 250888812125..0b7028df08fb 100644 --- a/include/rv/da_monitor.h +++ b/include/rv/da_monitor.h @@ -309,10 +309,11 @@ static inline void da_monitor_destroy(void) WARN_ONCE(1, "Disabling a disabled monitor: " __stringify(MONITOR_NAME)); return; } - rv_put_task_monitor_slot(task_mon_slot); - task_mon_slot = RV_PER_TASK_MONITOR_INIT; da_monitor_reset_all(); + + rv_put_task_monitor_slot(task_mon_slot); + task_mon_slot = RV_PER_TASK_MONITOR_INIT; } #elif RV_MON_TYPE == RV_MON_PER_OBJ -- 2.54.0