From nobody Sat Feb 7 05:49:15 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 86378316196; Mon, 3 Nov 2025 14:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762181258; cv=none; b=EwV3792iEv2K5uabKzncTYb6scwXWtZFjX7EAxU7gTiJFbt/sZlWa72WkdstqXsjdbggcxJrfkdis9g9/wJZen7vHvpj3GR9sm78tcMrcFlPY9cVIinCfxGOG6oHVaRsABHKsqRG1GtOOhL4M4VxTvVlXYtXxuymR54fZlskVao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762181258; c=relaxed/simple; bh=wg86WBD1K1dX8X005aMnsThOwNwV8rRIPIQbKIxx4nY=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=bKhZNaF71alJXVpddrfsR70uj8txnkgXvr0bXy627mGCUen9m6/fPh5Y9n0+yKEg/XOjo0k6T98uPWmTCFtiq4xB895ZgjUQRQZVXR04ny5nmkOj3lEO53Tc9v5amoipUBcyiSzJdx73ewSeqogo5YWlRNmnwKcIfH6HmYSC5UU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=x/P7uZJv; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=bsWELXvV; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="x/P7uZJv"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="bsWELXvV" Date: Mon, 03 Nov 2025 14:47:33 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1762181254; h=from:from:sender:sender:reply-to: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=xdMFm6lNDce/jrl75fp0eLG6/2h18qL8bPOJBWInoEo=; b=x/P7uZJvFU8TlEgfJe512UasApFR/Fpd11FkV6ACiwl8aLZedid4riVnkneoqMn00NPqU/ GYjWfv1YkGVQDyfhQBMlFfTesr3QIQxS5Jm43AvCPxSHJcQcHVcDGrzpYzqoZK+K4EFHS1 ooZfSttnA9RX31hlr+zAHcyiiM8HB7TNNAILdOHuSMAUTsl4SbtctysZDOdn9Bw18kX94y lAoRlQL7QPca3WszPLjxviTz6sZfFU+U7SLBaG598qcpSOd56/aoS4AybMYVXV4oU2Cvtf Yb+Yxxooc8RaS9PS9YJRctMoaXpD0B0CrG/qC8iYBiTFp9/c8D+zUsaLKhvA7w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1762181254; h=from:from:sender:sender:reply-to: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=xdMFm6lNDce/jrl75fp0eLG6/2h18qL8bPOJBWInoEo=; b=bsWELXvV2qDzXDUllZGkYSkt11pPI9sTrqfhSoY9iv6g/I7vsRylp9F7wpS+763Y6dALnO a04zgDJnLAAAAkCg== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: core/rseq] rseq: Replace the original debug implementation Cc: Thomas Gleixner , "Peter Zijlstra (Intel)" , Mathieu Desnoyers , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20251027084307.212510692@linutronix.de> References: <20251027084307.212510692@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <176218125354.2601451.3559440362834085389.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the core/rseq branch of tip: Commit-ID: 502c6554c7c32040cd02ab1779a1eb1ffb371a2f Gitweb: https://git.kernel.org/tip/502c6554c7c32040cd02ab1779a1eb1ff= b371a2f Author: Thomas Gleixner AuthorDate: Mon, 27 Oct 2025 09:45:00 +01:00 Committer: Peter Zijlstra CommitterDate: Mon, 03 Nov 2025 15:26:18 +01:00 rseq: Replace the original debug implementation Just utilize the new infrastructure and put the original one to rest. Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Mathieu Desnoyers Link: https://patch.msgid.link/20251027084307.212510692@linutronix.de --- kernel/rseq.c | 81 +++++++------------------------------------------- 1 file changed, 12 insertions(+), 69 deletions(-) diff --git a/kernel/rseq.c b/kernel/rseq.c index 12a9b6a..abd6bfa 100644 --- a/kernel/rseq.c +++ b/kernel/rseq.c @@ -475,84 +475,27 @@ error: =20 #ifdef CONFIG_DEBUG_RSEQ /* - * Unsigned comparison will be true when ip >=3D start_ip, and when - * ip < start_ip + post_commit_offset. - */ -static bool in_rseq_cs(unsigned long ip, struct rseq_cs *rseq_cs) -{ - return ip - rseq_cs->start_ip < rseq_cs->post_commit_offset; -} - -/* - * If the rseq_cs field of 'struct rseq' contains a valid pointer to - * user-space, copy 'struct rseq_cs' from user-space and validate its fiel= ds. - */ -static int rseq_get_rseq_cs(struct task_struct *t, struct rseq_cs *rseq_cs) -{ - struct rseq __user *urseq =3D t->rseq.usrptr; - struct rseq_cs __user *urseq_cs; - u32 __user *usig; - u64 ptr; - u32 sig; - int ret; - - if (get_user(ptr, &rseq->rseq_cs)) - return -EFAULT; - - /* If the rseq_cs pointer is NULL, return a cleared struct rseq_cs. */ - if (!ptr) { - memset(rseq_cs, 0, sizeof(*rseq_cs)); - return 0; - } - /* Check that the pointer value fits in the user-space process space. */ - if (ptr >=3D TASK_SIZE) - return -EINVAL; - urseq_cs =3D (struct rseq_cs __user *)(unsigned long)ptr; - if (copy_from_user(rseq_cs, urseq_cs, sizeof(*rseq_cs))) - return -EFAULT; - - if (rseq_cs->start_ip >=3D TASK_SIZE || - rseq_cs->start_ip + rseq_cs->post_commit_offset >=3D TASK_SIZE || - rseq_cs->abort_ip >=3D TASK_SIZE || - rseq_cs->version > 0) - return -EINVAL; - /* Check for overflow. */ - if (rseq_cs->start_ip + rseq_cs->post_commit_offset < rseq_cs->start_ip) - return -EINVAL; - /* Ensure that abort_ip is not in the critical section. */ - if (rseq_cs->abort_ip - rseq_cs->start_ip < rseq_cs->post_commit_offset) - return -EINVAL; - - usig =3D (u32 __user *)(unsigned long)(rseq_cs->abort_ip - sizeof(u32)); - ret =3D get_user(sig, usig); - if (ret) - return ret; - - if (current->rseq.sig !=3D sig) { - printk_ratelimited(KERN_WARNING - "Possible attack attempt. Unexpected rseq signature 0x%x, expecting 0x%= x (pid=3D%d, addr=3D%p).\n", - sig, current->rseq.sig, current->pid, usig); - return -EINVAL; - } - return 0; -} - -/* * Terminate the process if a syscall is issued within a restartable * sequence. */ void rseq_syscall(struct pt_regs *regs) { - unsigned long ip =3D instruction_pointer(regs); struct task_struct *t =3D current; - struct rseq_cs rseq_cs; + u64 csaddr; =20 - if (!t->rseq.usrptr) + if (!t->rseq.event.has_rseq) return; - if (rseq_get_rseq_cs(t, &rseq_cs) || in_rseq_cs(ip, &rseq_cs)) - force_sig(SIGSEGV); + if (get_user(csaddr, &t->rseq.usrptr->rseq_cs)) + goto fail; + if (likely(!csaddr)) + return; + if (unlikely(csaddr >=3D TASK_SIZE)) + goto fail; + if (rseq_debug_update_user_cs(t, regs, csaddr)) + return; +fail: + force_sig(SIGSEGV); } - #endif =20 /*