Skip to contentSkip to conversation

rseq: Fix rseq unregistration

PATCH Applied Mathieu Desnoyers 2 participants 3 messages Jan 16, 2025 – Jan 21, 2025 Restartable sequences support

lore
Share & tools
lore

Mathieu Desnoyers

author maintainer
#0 lore raw

PATCH 1/1 rseq: Fix rseq unregistration

A logic inversion in rseq_reset_rseq_cpu_node_id() causes the rseq unregistration to fail when rseq_validate_ro_fields() succeeds rather than the opposite.

This affects both CONFIG_DEBUG_RSEQ=y and CONFIG_DEBUG_RSEQ=n.

Fixes 7d5265ffcd8b ("rseq: Validate read-only fields under DEBUG_RSEQ config")
Cc Peter Zijlstra (Intel) <[email protected]>
---
 kernel/rseq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rseq.c +1 -1
index e04bb30a2eb8..442aba29bc4c 100644
@@ -201,7 +201,7 @@ static int rseq_reset_rseq_cpu_node_id(struct task_struct *t)
 	/*
 	 * Validate read-only rseq fields.
 	 */
-	if (!rseq_validate_ro_fields(t))
+	if (rseq_validate_ro_fields(t))
 		return -EFAULT;
 	/*
 	 * Reset cpu_id_start to its initial state (0).
Signature · 1 line
2.39.5
author maintainer
#1 lore raw
Quoted 9 lines · Mathieu Desnoyers

A logic inversion in rseq_reset_rseq_cpu_node_id() causes the rseq unregistration to fail when rseq_validate_ro_fields() succeeds rather than the opposite.

This affects both CONFIG_DEBUG_RSEQ=y and CONFIG_DEBUG_RSEQ=n.

Fixes 7d5265ffcd8b ("rseq: Validate read-only fields under DEBUG_RSEQ config")
Cc Peter Zijlstra (Intel) <[email protected]>

Ingo, Peter, this fix should have been part of the PR sent to Linus earlier today [1]. Otherwise rseq unregistration is broken.

Thanks,

Mathieu

[1] https://lore.kernel.org/lkml/[email protected]/

Quoted 17 lines
---
  kernel/rseq.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rseq.c +1 -1
index e04bb30a2eb8..442aba29bc4c 100644
@@ -201,7 +201,7 @@ static int rseq_reset_rseq_cpu_node_id(struct task_struct *t)
  	/*
  	 * Validate read-only rseq fields.
  	 */
-	if (!rseq_validate_ro_fields(t))
+	if (rseq_validate_ro_fields(t))
  		return -EFAULT;
  	/*
  	 * Reset cpu_id_start to its initial state (0).
Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
#2 lore raw

[tip: sched/core] rseq: Fix rseq unregistration regression

In reply to Mathieu Desnoyers
The following commit has been merged into the sched/core branch of tip:

The following commit has been merged into the sched/core branch of tip:

Commit-ID:     40724ecafccb1fb62b66264854e8c3ad394c8f3d
Gitweb:        https://git.kernel.org/tip/40724ecafccb1fb62b66264854e8c3ad394c8f3d
Author:        Mathieu Desnoyers <[email protected]>
AuthorDate:    Thu, 16 Jan 2025 15:59:56 -05:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Tue, 21 Jan 2025 08:10:51 +01:00

rseq: Fix rseq unregistration regression

A logic inversion in rseq_reset_rseq_cpu_node_id() causes the rseq unregistration to fail when rseq_validate_ro_fields() succeeds rather than the opposite.

This affects both CONFIG_DEBUG_RSEQ=y and CONFIG_DEBUG_RSEQ=n.

Fixes 7d5265ffcd8b ("rseq: Validate read-only fields under DEBUG_RSEQ config")
---
 kernel/rseq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rseq.c +1 -1
index e04bb30..442aba2 100644
@@ -201,7 +201,7 @@ static int rseq_reset_rseq_cpu_node_id(struct task_struct *t)
 	/*
 	 * Validate read-only rseq fields.
 	 */
-	if (!rseq_validate_ro_fields(t))
+	if (rseq_validate_ro_fields(t))
 		return -EFAULT;
 	/*
 	 * Reset cpu_id_start to its initial state (0).