From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18C03C8CE for ; Wed, 24 Jun 2026 13:46:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782308775; cv=none; b=AtzY7LjTqfNKb8HNZ3g6lkcXvnUCzG1SMiJK+3ApmiGEzXef5g9JpwuQQqSLNaexTQ6Ntsg3NjDt6RCNt4cGeqtNQawSPSPOL3CcPsiIjlrmddg9TqFocOiX09nfapvLRpNfgVrvXgKsPvKq15hIZaaDWg5ry/mBXg9j0uUJLcc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782308775; c=relaxed/simple; bh=pG17DtnFrwmF7X1dc4UrC8gEnq47GoL1xsU5PnmYQSg=; h=Message-ID:Date:MIME-Version:Subject:To:References:From:Cc: In-Reply-To:Content-Type; b=WksPDGm5B7Zmqt2qKGsB3VO58u7U6SKAHii01pFDsFA3gzWm2t4o/tL4puToEmzy5N24NRi4j809IQMvJm/bjOZ0GUhzAufatxf3R0VKw1TVHK7x3/wIkIuUxYwdxY4oZyarhGZFLp3Dy7hlC7mV07nuhwQdmksr8NylxF76nvA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=RK78GmT2; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="RK78GmT2" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D5CF826A4; Wed, 24 Jun 2026 06:46:08 -0700 (PDT) Received: from [10.2.213.11] (e137867.arm.com [10.2.213.11]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9002F3F905; Wed, 24 Jun 2026 06:46:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1782308773; bh=pG17DtnFrwmF7X1dc4UrC8gEnq47GoL1xsU5PnmYQSg=; h=Date:Subject:To:References:From:Cc:In-Reply-To:From; b=RK78GmT2xEkugTDp7HmM54IrK0gehW5TGtL6dgvFCapOumPrp01DSfWMNs4+vkUSw VPbbcp5bQWWcv4yTDkZ7ivQeFScx8c7UzYC+yAM0wZUyDtVMGmjKgJPyG38W9aPWvH X66GO0RljZBBkJa1iZsLggIJisfko+kMMDGYIsBg= Message-ID: <581b3f1c-2411-4551-9e35-35f18eccb86f@arm.com> Date: Wed, 24 Jun 2026 14:46:07 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v15 06/11] arm64: ptrace: Move rseq_syscall() before audit_syscall_exit() To: Jinjie Ruan References: <20260511092103.1974980-1-ruanjinjie@huawei.com> <20260511092103.1974980-7-ruanjinjie@huawei.com> From: Ada Couprie Diaz Cc: Ada Couprie Diaz , catalin.marinas@arm.com, will@kernel.org, oleg@redhat.com, tglx@kernel.org, peterz@infradead.org, luto@kernel.org, kees@kernel.org, wad@chromium.org, mark.rutland@arm.com, yeoreum.yun@arm.com, linusw@kernel.org, kevin.brodsky@arm.com, ldv@strace.io, thuth@redhat.com, james.morse@arm.com, song@kernel.org, anshuman.khandual@arm.com, broonie@kernel.org, ryan.roberts@arm.com, pengcan@kylinos.cn, liqiang01@kylinos.cn, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Content-Language: en-US, en-GB, fr Organization: Arm Ltd. In-Reply-To: <20260511092103.1974980-7-ruanjinjie@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/05/2026 10:20, Jinjie Ruan wrote: > Move the rseq_syscall() check earlier in the syscall exit path to ensure > it operates on the original instruction pointer (regs->pc) before any > potential modification by a tracer. > > [Background] > When CONFIG_DEBUG_RSEQ is enabled, rseq_syscall() verifies that a system > call was not executed within an rseq critical section by examining > regs->pc. If a violation is detected, it triggers a SIGSEGV. > > [Problem] > Currently, arm64 invokes rseq_syscall() after report_syscall_exit(). > However, during report_syscall_exit(), a ptrace tracer can modify the > task's instruction pointer via PTRACE_SETREGS. This leads to an > inconsistency where rseq may analyze a post-trace PC instead of the > actual PC at the time of syscall exit. > > [Why this matters] > The rseq check is intended to validate the execution context of the > syscall itself. Analyzing a tracer-modified PC can lead to incorrect > detection or missed violations. Moving the check earlier ensures rseq > sees the authentic state of the task. > > [Alignment] > This change aligns arm64 with: > - Generic entry, which calls rseq_syscall() first. > - arm32 implementation, which also performs the check before audit. > > [Impact] > There is no functional change to signal delivery; SIGSEGV will still be > processed in arm64_exit_to_user_mode() at the end of the exit path. > > Cc: Mark Rutland > Cc: Thomas Gleixner > Cc: Will Deacon > Cc: Catalin Marinas > Reviewed-by: Linus Walleij > Reviewed-by: Yeoreum Yun > Reviewed-by: Kevin Brodsky > Signed-off-by: Jinjie Ruan > --- Reviewed-by: Ada Couprie Diaz