From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 DB3961B142D for ; Wed, 26 Aug 2026 01:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787706600; cv=none; b=dGKQ2WajNA63kuqLdmH3c71wn5SO/3WBqjjpoCPsG1M/aiQdDIYydrPCBRaVU5LKeveIjPP8WHDb8RmHzyCOQFomCPlnasnFm05vcTnyjKF87NgJ3it2VmZD9QfJNsbSG37NacWT66pA2NMpLZrOTk4mQm3/z/rJFgfcTlVzQcs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787706600; c=relaxed/simple; bh=N0TbZOwb9fM2Lbpw8Sv0+KdfymJihar5UhaRJJ2fwoM=; h=Mime-Version:Content-Type:Date:Message-Id:From:To:Cc:Subject: References:In-Reply-To; b=kAj2r2ssxxqDk8fK0n7vNIRfSzxoX7dz8N/f5absFttMZSmlcFnaYeKSfIk85SKvFYvBUXhNWTRU/qLpUl5eNtvlVCKndCgQUaqS5ldNV3+07Jq8Mv5C6cqkN02wH27LhjIzmQ5otsvHyyy13rbcSD3IIOBvhnIS2L8n/sx6ZOI= 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=EHuEkJ2l; arc=none smtp.client-ip=209.85.210.44 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="EHuEkJ2l" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-7f3faf2b081so434390a34.3 for ; Tue, 25 Aug 2026 18:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787706598; x=1788311398; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=N0TbZOwb9fM2Lbpw8Sv0+KdfymJihar5UhaRJJ2fwoM=; b=EHuEkJ2ld12UMqWLMnDZJ98cy3umRQlNK9Udd4UUDGmgf7Xc40gHrb9DGZbJo82qrv 6e7WiQjASSCuvuE9KR8ODcgPajvGzvrM7oY4rjP8/sNud4ZoSK+Bt2xG3fS9sfyRU/Fw LRMQfmvn5uW75mIG2Z3hJ1uz0Q836WPUvKWeCR2sEDe/SxUtRcgimCtBi4U4Qguoc+bL twhq6kCVcbB3kKnUaehYwuTr0BRxo6UffqATPmZO+xfeHTOyFRm6P2pG13gkX2xBJPBg hrAQCRs8G9YAw4zMJ9IpUlhhcJgdcWJ/5KbrfJpabbWm8pb+aqWgKXMB7Y6qMXLUwz6a GeHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787706598; x=1788311398; h=in-reply-to:references:subject:cc:to:from:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=N0TbZOwb9fM2Lbpw8Sv0+KdfymJihar5UhaRJJ2fwoM=; b=iT5/G5fFKm56cq/n5WxwtCg4f2TZlzOlQOr4GhaX1jaf3B7boihmYBe/axRDHsZRiA 4/rYAzG5pvSgaPiHJEsxQGPHDPzCbLjOXhAbDcyNIUEukn5A6B/PclszsT+FwFyuRSUL lPwKzWbn3tQQgl6eG/Ytg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P id 006d021491bc7-6b1a03ae5abmr2976110eaf.1.1787706597499; Tue, 25 Aug 2026 18:09:57 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:5c::]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-465ade707ecsm899942fac.5.2026.08.25.18.09.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Aug 2026 18:09:56 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 25 Aug 2026 18:09:56 -0700 Message-Id: From: "Alexei Starovoitov" To: =?utf-8?q?J=C3=A9r=C3=A9my_Jean?= , Cc: "Alexei Starovoitov" , "Daniel Borkmann" , Subject: Re: [BUG] bpf: x86 timed may_goto corrupts private-stack JIT state X-Mailer: aerc References: <20260824213158.3755932-2-Jeremy.Jean@oss.cyber.gouv.fr> In-Reply-To: <20260824213158.3755932-2-Jeremy.Jean@oss.cyber.gouv.fr> On Mon Aug 24, 2026 at 2:31 PM PDT, J=C3=A9r=C3=A9my Jean wrote: > Hello, > > With the help of AI models, I found a bug in the x86 timed may_goto path = that > leads to a verifier/JIT state mismatch on private-stack programs. > > The root cause is that timed may_goto fixups pass a stack offset in BPF_R= EG_AX > and the x86 trampoline reconstructs the counter pointer from native %rbp.= That > is incorrect once private-stack JIT mode is enabled: ordinary BPF frame p= ointer > accesses are remapped from %rbp to %r9, but arch_bpf_timed_may_goto() sti= ll > uses %rbp and ends up reading and writing the native JIT frame instead of= the > private BPF stack. > > The bug was introduced by 2fb761823ead ("bpf, x86: Add x86 JIT support fo= r timed > may_goto"). I reproduced it on a KASAN-enabled x86_64 kernel based on v7.= 2, > however KASAN does not trigger because the bad write stays inside the nat= ive > JIT frame. Yet, the saved-register corruption is observable. > > I have not included a patch here because the fix seems subtle to me and w= ould > likely touch many files for different arch. > > I can share the minimal reproducer and other details privately with maint= ainers > if useful. Just send a fix and a selftest to the list.