lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240422144538.351722-1-liuxin350@huawei.com>
Date: Mon, 22 Apr 2024 22:45:38 +0800
From: Xin Liu <liuxin350@...wei.com>
To: <ast@...nel.org>, <daniel@...earbox.net>, <andrii@...nel.org>,
	<martin.lau@...ux.dev>, <song@...nel.org>, <yhs@...com>,
	<john.fastabend@...il.com>, <kpsingh@...nel.org>, <sdf@...gle.com>,
	<haoluo@...gle.com>, <jolsa@...nel.org>
CC: <bpf@...r.kernel.org>, <linux-kernel@...r.kernel.org>, <yanan@...wei.com>,
	<wuchangye@...wei.com>, <xiesongyang@...wei.com>, <kongweibin2@...wei.com>,
	<zhangmingyi5@...wei.com>, <liwei883@...wei.com>, <liuxin350@...wei.com>
Subject: [PATCH] libbpf: extending BTF_KIND_INIT to accommodate some unusual types

In btf__add_int, the size of the new btf_kind_int type is limited.
When the size is greater than 16, btf__add_int fails to be added
and -EINVAL is returned. This is usually effective.

However, when the built-in type __builtin_aarch64_simd_xi in the
NEON instruction is used in the code in the arm64 system, the value
of DW_AT_byte_size is 64. This causes btf__add_int to fail to
properly add btf information to it.

like this:
  ...
   <1><cf>: Abbrev Number: 2 (DW_TAG_base_type)
    <d0>   DW_AT_byte_size   : 64              // over max size 16
    <d1>   DW_AT_encoding    : 5        (signed)
    <d2>   DW_AT_name        : (indirect string, offset: 0x53): __builtin_aarch64_simd_xi
   <1><d6>: Abbrev Number: 0
  ...

An easier way to solve this problem is to treat it as a base type
and set byte_size to 64. This patch is modified along these lines.

Fixes: 4a3b33f8579a ("libbpf: Add BTF writing APIs")
Signed-off-by: Xin Liu <liuxin350@...wei.com>
---
 tools/lib/bpf/btf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 2d0840ef599a..0af121293b65 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -1934,7 +1934,7 @@ int btf__add_int(struct btf *btf, const char *name, size_t byte_sz, int encoding
 	if (!name || !name[0])
 		return libbpf_err(-EINVAL);
 	/* byte_sz must be power of 2 */
-	if (!byte_sz || (byte_sz & (byte_sz - 1)) || byte_sz > 16)
+	if (!byte_sz || (byte_sz & (byte_sz - 1)) || byte_sz > 64)
 		return libbpf_err(-EINVAL);
 	if (encoding & ~(BTF_INT_SIGNED | BTF_INT_CHAR | BTF_INT_BOOL))
 		return libbpf_err(-EINVAL);
-- 
2.33.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ