From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796071884; b=JBLnIpXDJJokjSXbC9EW620RMgDXL/033qYtifzCfK+OdTjAU24GFa8eS1HcP/8Zuh1A 0tpuchEoAviUaYXOGTBnPWeCtX+mDvhcFvEJkXVlkBh5udzpLBxZOT4xc+UVFzSaVRZg6 XCJpNo214jpjMwvVZzWIW/xBKr9P9Qjwkqi3H5LFY2mrM3MwWobzaLIRUnWcvcr+8dOXN LkJJJC6iSz/qwxeJSl5N+T2mKx/emn5NanZeuoQXXWrtaCev+SF+t09EsRbEw8fBg7ME0 Q2EbGgrb1pDU67hqcGo50vepUZJym7wdjGnNLJpSzWhU54kRaULmFqVs5XSBGQ4nH6Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796071884; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To:X-Scanned-By; bh=SX/zQAK1kWCaGeiNsXUP5//PrX2PxDOvmifwS0/cLws=; b=fYE83gYqZrTxti+VrOgoxZGMT7cYu7ThU8NdgC5GmDxbTNHYoCFbSj+R13uZuk1nHrGz DefT/GgAcBDv5UNoU19lDxN/3OYDxaituaM6u553A0lVY0lkDaAbSfAUpCQXJCpIZ9s11 K7eeBnAzwEShGvcFQem3z3OzLHo+N2Tg37gJ4jDLpa15YJMdHsPfuS7c8TMmN/dFNWpl/ +EvgDrz5OFzvrLYRDof3zBJ22bNNDX8Ixx/O0bcIYp+ywr5x09gAxAudZpRoG2izfX6Bh ST1oNoSUEsVheMBQjAMYAnL3lDtTpGY3wXyyEUHPPRMA76PJYdF765gWTM4/iJTDOWw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MDgm5yMU; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A67F6606A32E for ; Mon, 30 Nov 2026 20:51:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A67F6606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MDgm5yMU DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796071882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=SX/zQAK1kWCaGeiNsXUP5//PrX2PxDOvmifwS0/cLws=; b=MDgm5yMUdByhZpHuwRH5hmaUUNXrriNFq2fLFkBHvjkblMHuSmjpgsfhxc8XhULUOVDFHs HEJgOX07QegIu41JCGNP92mfV189Ym/X78zD9grk/MOmIrmxRfHW/REM96jh6emZ+E9yjO RTJvJ984izOI8+46PI3UiBN545xiyKg= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-588-Kl4a1CQgPICZOToGwigL5g-1; Mon, 30 Nov 2026 20:51:19 +0000 X-MC-Unique: Kl4a1CQgPICZOToGwigL5g-1 X-Mimecast-MFC-AGG-ID: Kl4a1CQgPICZOToGwigL5g_1796071878 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D68F51955F08; Mon, 30 Nov 2026 20:51:17 +0000 (UTC) Received: from redhat.com (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7A5CE18004F5; Mon, 30 Nov 2026 20:51:16 +0000 (UTC) Date: Mon, 30 Nov 2026 15:51:14 -0500 From: Joe Lawrence To: Seke Kazuru Cc: live-patching@vger.kernel.org, jpoimboe@kernel.org, mbenes@suse.cz, "pmladek@suse.com" , "song@kernel.org" , peterz@infradead.org, bpf@vger.kernel.org Subject: Re: objtool/klp: ___bpf_prog_run jumptable is correlated to the original, fix never runs Message-ID: References: X-Mailing-List: live-patching@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 On Sat, Nov 28, 2026 at 08:51:14AM +0200, Seke Kazuru wrote: > Hello, > > A livepatch module built by klp-build for a fix to ___bpf_prog_run() > loads, reports "patching complete", and lists ___bpf_prog_run as > patched, but the fixed instruction handlers never run. The replaced > function dispatches through vmlinux's copy of its static jumptable, > whose entries point into the original function body. > > Setup: Linux 6.19, x86_64, gcc 13, a config without BPF JIT (so every > program runs in the interpreter), klp-build from the same tree: > > ./scripts/livepatch/klp-build -T --no-replace -o lp.ko fix.patch > > The fix is c77b30bd1dcb ("bpf: Fix undefined behavior in interpreter > sdiv/smod for INT_MIN"), which changes the signed DIV and MOD handlers > inside ___bpf_prog_run(). Those handlers are reached only through the > computed-goto table: > > static const void * const jumptable[256] = { ... &&label ... }; > > klp diff refers every static local of a changed function to the > original kernel's copy unless is_uncorrelated_static_local() exempts its > name. "jumptable" is not on that list (6.19, and still not in > 7.4-rc4). The module's ___bpf_prog_run therefore carries a relocation > to .klp.sym.vmlinux.jumptable.12 (R_X86_64_32S at +0x40), and every > dispatch lands in the original handlers. > > Test, under KVM: a small helper module runs a three-instruction > program through the interpreter (r0 = S32_MIN; r0 s/= 2 as ALU32 DIV K > with off 1; exit) and prints r0. Unfixed code returns 0x40000000, > fixed code 0xc0000000. > > boot 1, klp-build module as built: > before load: 0x40000000 (6 of 6 runs) > after load, enabled=1, transition=0, "patching complete", > /sys/kernel/livepatch//vmlinux/___bpf_prog_run,1 present: > 0x40000000 (6 of 6 runs) > > boot 2, same command and same fix, with "jumptable." added to the > list in is_uncorrelated_static_local(): > before load: 0x40000000 (6 of 6) > after load: 0xc0000000 (6 of 6) > > The build prints no warning, and every kernel signal reports success. > Any klp-build fix to ___bpf_prog_run has this effect on kernels that run > the interpreter, that is without CONFIG_BPF_JIT_ALWAYS_ON when the JIT > is off or unavailable. > > Two possible fixes: > > 1. Add "jumptable" to is_uncorrelated_static_local(). This is the change > tested in boot 2. It covers this function only. > > 2. More generally, do not correlate a static local whose relocations > point into the changed function's own text (label addresses). Such a > table describes the code, not shared state, so it has to follow the > new function. This would also cover any other computed-goto table. > > I can send the helper module, the program, the kernel config and the > two klp-build logs. I am glad to test a patch on the same setup. > > This came up in a study of live-patch module fidelity. Of 70 klp-build > modules built from real stable fixes on 6.19, this is the only one in > which a changed function's new code does not run. > > Thank you for your time. Hi Seke, Thanks for the detailed report. On the fixes: option 2 seems preferable. Option 1 (adding "jumptable" to the list) may work but sounds fragile, it only catches tables spelled "jumptable", right? On the other hand, keying on "a static local whose relocations point into the changed function's own text" would be compiler/name-agnostic I believe. Before settling on a fix, could you turn this repro into a regression test for the objtool klp suite? It'd be fix-independent (any correct fix makes it pass) and would guard this going forward. See tools/objtool/Documentation/{klp-write-tests.txt,klp-test-design.txt} and tools/objtool/tests/generic/test-switch-rodata.sh, which covers a similar Clang switch-table test. A computed-goto test, run under both gcc and clang, should reproduce it. In my experience, AI agents can usually create a reasonable test from the docs and a report like your own. Thanks, -- Joe