From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796170559; b=OOAalT3v7AQpFqBD4sTaBjH9uT/HHPZ67IGRJ1aTH46LNGquqNxonov2Nol3v5K4lbVW oMOeJXV2EzDm5NJPyf+v+dQeN6qcejqb/B8Xbweq7IfnSIViQ6jwDGhKf5F6WgRqe1kKd LnnnC5Kls2EULzdfNTvRPJUEXYhPfnGYMvusRoL7zuhPB6GTZlc2FCxI7qnepp+cLUwG/ g06QQyxbKb/l1sirrVs13pzxfQcZxuw0UdPbS6SXw2FIy9MfCPeHCf9lpjWJA5tru2uze HWLXJSfE1b2bicOksTIWZoyKx5qMuzNa46KWIHGDTHK6rWsepM3iheOJomx6iRj24TQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796170559; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=htDCqT5lFJPQyG/9gK/5DwA0jchioCdhBA97W/vC7C4=; b=wg4WBuIzE/A1vCI5AnxPhpRuS1q2R9hgLmSDZADXF9ey6Ys3OVcjMV4HWG303pmNboiz q3b3M63kVfZ4fDS/BhmJHUawIfpJ4UrWShwKnSKulyHMXB7d/54w5m1RSrYidJwOGmcm/ mnyntK8T9Q51nW0yeHMMNrikVY/PQMl+wgk9RL8LRVdoWgPuxuXxcmw3q2W2ulRfYUYMW NLJAd2RgGTPDOs7MSeMUKoar/d69rIXvit9kZF2POgn4vBkxoq3r7bDQDySE7MXy2iMv4 sdHsSnnLgQ4wZL2icUwVZPgFY5KPc14dEqBSNxubyoE+d7LJ/bu7N4bobwWIYOVt8rw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--wusamuel.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=pkh8w2c9; arc=none smtp.remote-ip=209.85.167.198 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3D96606A323 for ; Wed, 2 Dec 2026 00:15:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E3D96606A323 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--wusamuel.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=pkh8w2c9 Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-4c467e19391so17370575b6e.3 for ; Tue, 01 Dec 2026 16:15:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796170558; x=1796775358; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=htDCqT5lFJPQyG/9gK/5DwA0jchioCdhBA97W/vC7C4=; b=pkh8w2c9VfSTd9Wwr516OeDaZMFVxRbTLADA6KiB71EPZtxnAGqEgWG2VgmTOCuT8N WUGRuyo+BB7fXEx5JeGpsBmPVAR5Nh2qtK4n6lSALrVRUZlFtuVMcVCY/VioLiwxk7+H BtLBKHhcwXoYaUNBxC7iyRAkgOL5jja4meWj9a4VIZLXtdS7RinhdBkWNZZ0WemB6HCr e7pik4JrLwsCiEIdengXRGFpEZQXb8oS9dfRqRdd+d+lEqAqqRhnmcqNHOgV79Fm5MuC 0a1j6NBf3EOEU+RiuQinBcqcMfxTBaRe6Kw2UxDpnNUmDQwplD11+m6021npPT6RkkvQ BPUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796170558; x=1796775358; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=htDCqT5lFJPQyG/9gK/5DwA0jchioCdhBA97W/vC7C4=; b=oQNMFDfvIBkSJjZ1W9K6GMvMSXDjJUW2rECndM2kp1UX5UI6HO8cBz+m3o6kbTs3O0 HkjnmZ5EDKgSitZBpWbRHWN8teYCTR7U/lWV0IrxgaBtK3Ew9CYTACram0jxaX4RrpPA M0nm54wybTwbc29dpbkqtqzntnG6s3MJbdMke4HmT8XIRrWCGW2RLaELOBXQNNOJeUTU DworhkIEmKNoA87WvINyyWAQCqDYDWn3CksUJ5a7/pbBqzdERMCc/5GC6GAMEQS3FqVe H5wviVoCr180h+T05SpOojJPplCUW1TTsHC+Juivh7bx1DquZMwCuRccihK1ytpTU2l/ Xdjw== X-Forwarded-Encrypted: i=1; AL+hErHFqegQWD4UqT5a0gplAHvfcRijpFBvQDef/wwLk/ZB5FMT22uVXOjunifNu+OOXONK6a0cVCCOA+S1UUxC@vger.kernel.org X-Gm-Message-State: APuU4Z8pzgRVMGNW543fpNGwwARS9vqu0MrBTmQCrOCLBvTBB3r8uVzm mx+xPH7ZE6Ap3yfq3/3bT6BNUQ87Om6mG7zQbYOC23augK2jSDTke+xAVcvUzQDiSRYZqkP51ep RKD6MqmwJtcBuFQ== X-Received: from oiya23-n1.prod.google.com ([2002:a05:6809:2017:10b0:564:6be:d013]) (user=wusamuel job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:6412:b0:574:17be:1add with SMTP id 5614622812f47-57a09c0fbe9mr39225258b6e.14.1796170557651; Tue, 01 Dec 2026 16:15:57 -0800 (PST) Date: Tue, 1 Dec 2026 16:13:48 -0800 In-Reply-To: <20261202001344.2721429-12-wusamuel@google.com> X-Mailing-List: linux-modules@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: <20261202001344.2721429-12-wusamuel@google.com> X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202001344.2721429-19-wusamuel@google.com> Subject: [PATCH bpf-next v4 07/10] tools: Copy KALLSYMS_QUERY_* definitions to linux/fs.h From: Samuel Wu To: Jonathan Corbet , Shuah Khan , Randy Dunlap , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , John Fastabend , Luis Chamberlain , Petr Pavlu , Daniel Gomez , Sami Tolvanen , Aaron Tomlin , Alexander Viro , Christian Brauner , Jan Kara , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: david.laight.linux@gmail.com, akpm@linux-foundation.org, pmladek@suse.com, Samuel Wu , kernel-team@android.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org, bpf@vger.kernel.org, linux-modules@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Copy the KALLSYMS_QUERY_* definitions from include/uapi/linux/fs.h for the proc selftests. Signed-off-by: Samuel Wu --- tools/include/uapi/linux/fs.h | 58 +++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/tools/include/uapi/linux/fs.h b/tools/include/uapi/linux/fs.h index f0a26309b6d5..302e74ed4c39 100644 --- a/tools/include/uapi/linux/fs.h +++ b/tools/include/uapi/linux/fs.h @@ -567,4 +567,62 @@ struct procmap_query { __u64 build_id_addr; /* in */ }; +/* /proc/kallsyms ioctls. -EPERM if the opener cannot see kernel addresses. */ +#define KALLSYMS_QUERY_BY_NAME _IOC(_IOC_READ | _IOC_WRITE, PROCFS_IOCTL_MAGIC, 48, 0) +#define KALLSYMS_QUERY_BY_ADDR _IOC(_IOC_READ | _IOC_WRITE, PROCFS_IOCTL_MAGIC, 49, 0) + +enum kallsyms_query_flags { + /* Match query_name as a prefix. */ + KALLSYMS_QUERY_NAME_PREFIX = 0x01, +}; + +/* + * Symbol returned by a query. Each buffer pointer and its *_len must both be + * set or both be 0. When set, the kernel sets *_len to the string size + * including the NUL, even if the buffer is too small and the ioctl fails with + * -ENAMETOOLONG. The module name of a vmlinux symbol is "". + */ +struct kallsyms_query_sym { + __u64 sym_addr; /* out - start address */ + __u64 sym_size; /* out - bytes to next symbol, 0 if unknown */ + __u64 sym_name; /* in - user ptr to name buffer, or 0 */ + __u64 sym_name_len; /* in/out - buffer size / string size */ + __u64 sym_module; /* in - user ptr to module name buffer, or 0 */ + __u64 sym_module_len; /* in/out - buffer size / string size */ +}; + +/* + * Find a symbol by exact name, or by prefix with KALLSYMS_QUERY_NAME_PREFIX, + * in the entries of /proc/kallsyms, except undefined module symbols. vmlinux + * matches come first. A query_module of "vmlinux" selects the core kernel; + * any other name selects that module's symbol table, excluding freed init + * functions and pseudo-modules ("bpf", "__builtin__*"). + * + * Each call returns one match and sets pos to its position, even on + * -ENAMETOOLONG. Start with pos 0 and use pos + 1 for the next match, until + * -ENOENT. Use pos only with the same query. Matches can be skipped or + * repeated if symbols change between calls. + */ +struct kallsyms_query_by_name { + __u64 size; /* in - sizeof(struct kallsyms_query_by_name) */ + __u64 query_flags; /* in - enum kallsyms_query_flags */ + __u64 query_name; /* in - user ptr to name or prefix */ + __u64 query_module; /* in - user ptr to "vmlinux", module name, or 0 */ + __u64 pos; /* in/out - start position / match position */ + __u64 sym; /* in - user ptr to struct kallsyms_query_sym */ + __u64 sym_len; /* in - sizeof(struct kallsyms_query_sym) */ +}; + +/* + * Find the /proc/kallsyms entry that covers query_addr, or return -ENOENT. + * ftrace trampolines and kprobe pages are not resolved yet. + */ +struct kallsyms_query_by_addr { + __u64 size; /* in - sizeof(struct kallsyms_query_by_addr) */ + __u64 query_flags; /* in - must be 0 */ + __u64 query_addr; /* in - kernel address */ + __u64 sym; /* in - user ptr to struct kallsyms_query_sym */ + __u64 sym_len; /* in - sizeof(struct kallsyms_query_sym) */ +}; + #endif /* _UAPI_LINUX_FS_H */ -- 2.56.1.911.g883d8bcb20-goog