From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (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 BABEE18C933 for ; Wed, 25 Mar 2026 13:54:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774446880; cv=none; b=kfKvrm+hWB9EX0bNtWHWFzapATiqBQNGjt48hYyR+oqPYCAifFDEQzN4yIo1mjzu6xVQE6OAwY1FmpbBiVUaDyuAz5Qj8CTSaavJjtYGWbjG0MHnmE+82dfBo31H6IJjJ//2zzqd6daLDpfzOyshTE2GrpYvOyJtNXUacI6RlW8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774446880; c=relaxed/simple; bh=q+pMp5JVqAvlUlZ++vIPWfFNi3wud0iVLrZfD7M2nR0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Wpr7GwKy4Cwlbs1Wz1D95zTVd/zIpZu6tqcvCDwryz6ltVPHPWFiAG2+E20eglznUJS/TSILqHMTv/PDEpYNrP7Uxy2Kr9qLWq1QlvUxe/0cLwCqGS3Z3CDi8YUuIaFdRbA7ysybWCKqwV2Sszbq/0YYLR1Z/9ZUL0Zo0NxH1To= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=m0Hgn8yd; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="m0Hgn8yd" Message-ID: <5e960b3f-bc29-4d92-8af0-ec207e3946f6@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774446875; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FxQsf2q1ci5YPhXSa4LVGW35p81aNPC6dkLRQOM/qOs=; b=m0Hgn8yd2lA+M1l0fBoYvP9D17kDemrGYGXcJYrOFSRmYnjvWysNwrt1vpwkRn0Rg+K9as SzLq4wyTslbyXJ2rssrnv2NtZfsfjF0fH6yZqy5kY/Orv8GtIK42qRtJoKCv75rpBT1j04 4KLOYm5gie+PIWtLQYp8sSuoupKQaYI= Date: Wed, 25 Mar 2026 21:54:15 +0800 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next 2/3] bpf: Disallow freplace on kprobe with mismatched kprobe_write_ctx values To: Jiri Olsa , Kumar Kartikeya Dwivedi Cc: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Shuah Khan , "David S . Miller" , Jakub Kicinski , Jesper Dangaard Brouer , Toke Hoiland-Jorgensen , Lorenzo Bianconi , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, kernel-patches-bot@fb.com References: <20260324150444.68166-1-leon.hwang@linux.dev> <20260324150444.68166-3-leon.hwang@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Leon Hwang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2026/3/25 20:51, Jiri Olsa wrote: > On Tue, Mar 24, 2026 at 11:04:43PM +0800, Leon Hwang wrote: >> uprobe programs are allowed to modify struct pt_regs. >> >> Since the actual program type of uprobe is KPROBE, it can be abused to >> modify struct pt_regs via kprobe+freplace when the kprobe attaches to >> kernel functions. >> >> For example, >> >> SEC("?kprobe") >> int kprobe(struct pt_regs *regs) >> { >> return 0; >> } >> >> SEC("?freplace") >> int freplace_kprobe(struct pt_regs *regs) >> { >> regs->di = 0; >> return 0; >> } >> >> freplace_kprobe prog will attach to kprobe prog. >> kprobe prog will attach to a kernel function. >> >> Without this patch, when the kernel function runs, its first arg will >> always be set as 0 via the freplace_kprobe prog. >> >> To avoid the abuse of kprobe_write_ctx=true via kprobe+freplace, disallow >> freplace on kprobe programs with mismatched kprobe_write_ctx values. >> >> Fixes: 7384893d970e ("bpf: Allow uprobe program to change context registers") >> Signed-off-by: Leon Hwang > > hi, > so it's another issue in addition to that on with tail-calls [1] > do you plan to resend this fix as well? > > thanks, > jirka > > > [1] https://lore.kernel.org/bpf/20260303150639.85007-4-leon.hwang@linux.dev/ > Kumar will re-post it soon. Thanks, Leon