From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 59D7F344025 for ; Wed, 3 Jun 2026 09:07:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780477664; cv=none; b=AZhIG047PMoJTvVpIAQBAm21FcKebsItWc95kB8QmxBiFLYS+vTNe0tmx2ScE5/p8GiLDi+zK2GtUDyRGEAtRrPNfE/6LtkJAkfhLWfxeqPO0bCIj0EQAnvgnlIgOYvttVWUP+EcypQJGUlLrirvmIhjOFU0GpUGvN1gBJuaYGY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780477664; c=relaxed/simple; bh=cXwNVUS5atUUGX1T/vF2tEdvXfTq7HWs7JAuq58zfkg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=O/H19Q3CRjhesG4YlrONZ/qKT4Qzsms6j9Sd1pm9kl30X5jwhPA96ZMJv/8v0OJc2cPwXs7gJPwthY4H+nvliTHHyLk5OnWhtn4A4JLX4xE33qvLIofgqsNlQQ7op8SV9MabY8r5g8TG7507G6zfLbXPLjXpV/DlV2UQRp/NMJw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=pM30jMd2; arc=none smtp.client-ip=209.85.216.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pM30jMd2" Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-36bcd5f40b1so773225a91.3 for ; Wed, 03 Jun 2026 02:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780477662; x=1781082462; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Y2WtKlX5Be+t9WCfynzOY98X+OoJJT2Buiwxou/xw8c=; b=pM30jMd2fcEjemuKBies141MlAI43rfFEw+NXA+nACD+GqUfJTFQigE4B/28T3Id/9 HFQ2f11YU3px8K18sPW7kmE6YSn4y+2rNpbkGDPWvUpRW+uZC/L8F+pfXWscq94B6tL0 UN8KtxVAsQFI5k/tbLiWTUSbwTlp0bDsGIRdi53OouXs2LTRcCtsBLpyWK7F8dZPMUG6 /tog5Us1tYWlzhiUfK/WDKNxn7uXJ1F/I6Ey9pCiKmAeVpjRNyyiRdEExzq54IZS2cYJ 0Twe2vEyz/Ajs5fvsBK9GlY3wHoZMbhNGRkIlXcMKdkYsb9lNOUUz921dRjBUEjACZxj GBhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780477662; x=1781082462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Y2WtKlX5Be+t9WCfynzOY98X+OoJJT2Buiwxou/xw8c=; b=aTnCvcRDtI9P1G/OmG2ZIZFzDqx2KRJpCJwIIyK1gON5C53vnibOgFOplM3vDHYZ+R fIC8/KHfZZaekpzJwa0xgeGzkEfjoBJVaJhiXduKOy5AYGFbV5CPQosRn3JQJAPWnmHt jFuIQnR2nB4OIiNBfi48NIYIrpFj7cZ/kxS+79fJcIRi+5+NfrKcm0ZyueL2AUrP9oVB j5i3L+Nkbj1bC9xBRtEm0yxMzf1dq3rRo2PzMaCt/AOaNBf5bSrZ9xmOLktT4yVSk1sG J5bcqQrZ1ftbH2TnHY/n40MKp+KpasCRS93IxBDY/QsNyTyujwBvsaGpt3KFiMmATXP0 4BXg== X-Forwarded-Encrypted: i=1; AFNElJ8NsqthjCK6uWUjYEB6ToYHwER/SHY8JdDexN07ewsuuCxr0T69GzgJwhbOH1d89fmNFKFN7/EPX3O6+5U=@vger.kernel.org X-Gm-Message-State: AOJu0YxGdUGZlpUxrc2gw0aFZr7gsIDS3cOy5SUF9x1VcK+5TyRlRU6Z PxWYqAnB5Msrg6jYnwkhIJgalWE68LYbFl8Ser8TVrob9tzFT1v+uyCE X-Gm-Gg: Acq92OEpD4dABcVAZeWVFRUMSDAppqXTE3J+pJ1VlDhOp5U+cM2okCuZGEKHlepNw8G hF59U8UbnQUlu0Jq82SgXvdj5BGF4FwtWxJOizQX04tbW/4pL87ofVqGaqt92I6f5qjpWnkJ3bo 5ernTorfGgs5pGJCB1DB7Y9Obp4bRBX3b+lKnIO+7P7prT8BM/axZY6W4Ay4XenknyBMkShpIND i/D7bFdVWmFtZF1dPeymOjvisbFvUpGrO6QGOWq00UgbmFNvzVdlQXCvaSbOeepIQuCFNz3H4vF 5YaEXzZKyQOeIx9W06YmYKgAtyxM8EHrFtIRHGB8xZdt02uoP+SEVwrMQL4JR2VzwAOUTBwlKwX hQchHhjWKqaUwTx0Lake8mPw4QiCUJ85xGm9Kiu80fdafNai6j5F/bB0cOxP7NcrD252/JoG2Ey AGAM5CXtk8RFigM7RnM/a3oIM5+g/VENsXEyMDOjZVGTw= X-Received: by 2002:a17:90b:5690:b0:369:a719:6747 with SMTP id 98e67ed59e1d1-36e318c3497mr1428504a91.3.1780477662315; Wed, 03 Jun 2026 02:07:42 -0700 (PDT) Received: from localhost.localdomain ([189.1.242.96]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36e0a14485esm2417617a91.3.2026.06.03.02.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jun 2026 02:07:41 -0700 (PDT) From: Yiqi Sun To: will@kernel.org Cc: catalin.marinas@arm.com, kees@kernel.org, keno@juliacomputing.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, luis.machado@linaro.org, mark.rutland@arm.com, rmk+kernel@armlinux.org.uk, ruanjinjie@huawei.com, sunyiqixm@gmail.com Subject: Re: Re: [PATCH] fix: arm64: syscall: use live x0 for syscall_get_arguments() arg0 Date: Wed, 3 Jun 2026 17:07:30 +0800 Message-Id: <20260603090730.16960-1-sunyiqixm@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Mon, 1 Jun 2026 13:43:42 +0100, Well wrote: > On Fri, May 29, 2026 at 02:54:44PM +0800, Yiqi Sun wrote: > > On arm64, seccomp obtains syscall arguments via syscall_get_arguments(), > > where arg0 is currently read from regs->orig_x0. However, the syscall > > wrapper consumes live arguments from regs->regs[0..5]. > > > > A ptracer can modify x0 on syscall-enter stop before seccomp runs, > > but cannot update orig_x0 through that interface. This can > > leave seccomp checking stale arg0 while the syscall executes with updated > > live x0, allowing seccomp bypass when filters depend on arg0. > > > > Make syscall_get_arguments() read arg0 from regs->regs[0], matching the > > actual dispatch arguments and removing this desynchronization. > > > > Fixes: f27bb139c387 ("arm64: Miscellaneous library functions") > > Signed-off-by: Yiqi Sun > > --- > > arch/arm64/include/asm/syscall.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h > > index 5e4c7fc44f73..4bdb4d3ce2b4 100644 > > --- a/arch/arm64/include/asm/syscall.h > > +++ b/arch/arm64/include/asm/syscall.h > > @@ -81,7 +81,7 @@ static inline void syscall_get_arguments(struct task_struct *task, > > struct pt_regs *regs, > > unsigned long *args) > > { > > - args[0] = regs->orig_x0; > > + args[0] = regs->regs[0]; > > args[1] = regs->regs[1]; > > args[2] = regs->regs[2]; > > args[3] = regs->regs[3]; > > -- > > 2.34.1 > > Hrm, this looks like a long-standing issue and I'm pretty nervous about > changing it :/ > > How did you spot it? I share your concern here, and I’m trying to be very careful with any behavior change. I spotted this while comparing seccomp+ptrace ordering across arches. I had previously looked at x86/x86_64 (including the seccomp/ptrace ordering fix from more than 10 years ago), and then checked whether other arches like arm64 had the same issue. > A quick look at the code suggests we have a similar issue with > audit_syscall_entry(), so if we take your patch here then it will silently > introduce a behavioural change to this guy: > > https://lore.kernel.org/all/20260320102620.1336796-5-ruanjinjie@huawei.com/ > > I also notice that the compat ptrace interface allows 'orig_x0' to be > set -- could that cause issues with things like syscall_rollback()? > Will You are right that on arm64, audit_syscall_entry() still takes arg0 from orig_x0, so taking only this seccomp fix would diverge seccomp and audit semantics. I also checked syscall_rollback(): on arm64 it restores regs[0] from orig_x0, and orig_x0 is captured at syscall entry before the ptrace syscall-stop hook. So rollback normally returns to the syscall-entry state (i.e. pre-ptrace argument value), which does not look like a new security issue by itself. compat ptrace can explicitly write orig_x0, but that is existing tracer-controlled behavior and does not, by itself, cross a new security boundary introduced by this patch. If you agree, I can send a follow-up later so seccomp/audit stay consistent. Yiqi Sun