From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 5DBEA35D798 for ; Tue, 6 May 2025 03:17:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746501463; cv=none; b=Am8k4Wgv/9wuebV6YDM8geekr/wQ1KyCl04Y/V6Hko/WXutQZX7/DVBuTCBp8GPLa3B2XoXX9NfB5JQRzkPrU+m6c0JhZxMRTn7ys6WlIjuyyemAvxbn+38CLGvhHfPDDxNK9Z9PRG4ci8teNKk4s/xZ+o/2zpKvLdFQCm7jnl8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746501463; c=relaxed/simple; bh=ZYfEe9dfbOlh4TB4RxQM+dfsYnGAY1/9qAXesK03RiA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=HcrPoqzzD7+2HgcUr5RR6Qr7md5/IDwhUE6mDXfVgJIuLfWNqqYw+yyN3LuWvbIhO8GAkO4L8VEuRKG1DesnY798vyo0OsmXL4Cub2N8m2L3DDChPg4HIh8OxrtEjf4n92bsOj5jZR3z6jl1I1IyzpMVdRzzSAhyVPMx+jSGACY= 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=MXLeBZVU; arc=none smtp.client-ip=91.218.175.172 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="MXLeBZVU" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1746501456; 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=4hExdwsduTAZkeZ42lU5nwgYu99F31594YfZgZwFWlw=; b=MXLeBZVUmb3QEbq9zmSZ+JbOGD5oonYBsWLaaShIfJPT+nfTTqoy2J6UyXmrz46pVvp9nc 8uOwddQdSDwr//qxV+hVDmRP9CaA2Ii6PU/dbBy/t/bJ12bcY09XcnYtigKWbSAQhSYbRQ eMT2wr2wckXmDb+XXDz1eyVHE0nWO1U= Date: Tue, 6 May 2025 11:17:28 +0800 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [RFC PATCH bpf-next 2/2] bpf: Get fentry func addr from user when BTF info invalid To: Alexei Starovoitov , Alan Maguire Cc: Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Eduard , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf , LKML References: <20250430164608.3790552-1-chen.dylane@linux.dev> <20250430164608.3790552-3-chen.dylane@linux.dev> <4cabeaa5-0a6f-4be0-89c8-b7d0552b0dd0@oracle.com> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Tao Chen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 在 2025/5/1 06:23, Alexei Starovoitov 写道: > On Wed, Apr 30, 2025 at 10:57 AM Alan Maguire wrote: >>> + >>> + if (!addr && (prog->expected_attach_type == BPF_TRACE_FENTRY || >>> + prog->expected_attach_type == BPF_TRACE_FEXIT)) { >>> + fname = kallsyms_lookup((unsigned long)prog->aux->fentry_func, >>> + NULL, NULL, NULL, trace_symbol); >>> + if (fname) >>> + addr = (long)prog->aux->fentry_func; >> >> >> We should do some validation that the fname we get back matches the BTF >> func name prefix (fname "foo.isra.0" matches "foo") I think? > > I don't think that will be enough. > User space should not be able to pass a random kernel address > and convince the kernel that it matches a particular btf_id. > As discussed in the other thread matching based on name is > breaking apart. > pahole does all the safety check to make sure name/addr/btf_id > are consistent. > We shouldn't be adding workarounds like this because > pahole/btf/kernel build is not smart enough. > Got it thanks for your reply, it is hoped that pahole/btf can have a better way to solve such problems. > pw-bot: cr -- Best Regards Tao Chen