From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta0.migadu.com (out-173.mta0.migadu.com [91.218.175.173]) (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 7C079282F1E for ; Mon, 30 Mar 2026 05:38:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774849100; cv=none; b=nPNIY5StHK3TLunIblgfQ9MEtH7A4btvjvhbXX9V4SxQwdvyJIlRkqTCFRSXknPWvoG1cnWGxorIUIgtNIZ+CY/aWmdXNauCzkUOZgx0DzTEFErwRUNh5GbBmRuKa0WPPKqnwZm2bHCLKD68AwUI0jDqrvc4LLLMPDA4YtaCXuc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774849100; c=relaxed/simple; bh=4A2AmJQeheBGu1UUWZvKo0KEJ8O2rjA+fqDcDhvkjoc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kaV5nfW0lQcevpzKRJ5ruiXNuhEoavCoUBjTFwb7CmPIH8x5kl4Wq+Jgu6Fn8EZl7Rz/iW6cYlenshPMXqJjdFm+u8klmMKfFrTyW6xrMAAC+BuS9QAeB5u2fzG72h9U7kBfYaAkHVocIwBE9WEH2Kh3SuHfqRVzjr8fWo5ehUU= 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=Xoo7RXtf; arc=none smtp.client-ip=91.218.175.173 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="Xoo7RXtf" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774849096; 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=UC7S6U4jkOT/S8tS6bcCxKzTr/oSR5FCgpqhFk2yhAE=; b=Xoo7RXtfW4czjwrYwYEInXmup/OoUumSjHfDqyung9Hn/WQP8cke2hIqrx69GDI1lwq8QC VctjyY4W9U5BWLQHReR9Uk98vzOdShNHcX0jNQXMG96YmH5pLaJGCf8MflAKKufaLIyKqC MRwEv3UZzn5ZPft396W67SkI0EpKoVY= Date: Mon, 30 Mar 2026 13:38:06 +0800 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v2 1/2] bpf: Fix abuse of kprobe_write_ctx via freplace Content-Language: en-US To: Song Liu Cc: bpf@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Kumar Kartikeya Dwivedi , Yonghong Song , Jiri Olsa , Shuah Khan , Feng Yang , Toke Hoiland-Jorgensen , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-patches-bot@fb.com References: <20260326141718.17731-1-leon.hwang@linux.dev> <20260326141718.17731-2-leon.hwang@linux.dev> 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: 8bit X-Migadu-Flow: FLOW_OUT On 28/3/26 05:39, Song Liu wrote: > On Thu, Mar 26, 2026 at 7:17 AM Leon Hwang wrote: [...] >> @@ -3733,6 +3733,11 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog, >> tr = prog->aux->dst_trampoline; >> tgt_prog = prog->aux->dst_prog; >> } >> + if (prog->type == BPF_PROG_TYPE_EXT && >> + prog->aux->kprobe_write_ctx != tgt_prog->aux->kprobe_write_ctx) { >> + err = -EINVAL; >> + goto out_unlock; >> + } > > This also blocks uprobe+freplace when prog and tgt_prog have different > kprobe_write_ctx, right? Is this the expected behavior? > Intuitively, yes, this also blocks uprobe+freplace. However, how can we distinguish uprobe/kprobe here? At attach time, uprobe/kprobe is recognized by the target perf event flags instead of BPF prog's expected_attach_type. Thus, we cannot infer the use of prog by prog itself. If we can distinguish them here, I'd like to do it. Thanks, Leon