Commit 3ae4c527 authored by Alan Maguire's avatar Alan Maguire Committed by Daniel Borkmann
Browse files

selftests/bpf: More open-coded gettid syscall cleanup



Commit 0e2fb011 ("selftests/bpf: Clean up open-coded gettid syscall
invocations") addressed the issue that older libc may not have a gettid()
function call wrapper for the associated syscall.

A few more instances have crept into tests, use sys_gettid() instead, and
poison raw gettid() usage to avoid future issues.

Signed-off-by: default avatarAlan Maguire <alan.maguire@oracle.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20250911163056.543071-1-alan.maguire@oracle.com
parent 61ee2cce
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -67,6 +67,9 @@ static inline void bpf_strlcpy(char *dst, const char *src, size_t sz)
#define sys_gettid() syscall(SYS_gettid)
#endif

/* and poison usage to ensure it does not creep back in. */
#pragma GCC poison gettid

#ifndef ENOTSUPP
#define ENOTSUPP 524
#endif
+1 −1
Original line number Diff line number Diff line
@@ -457,7 +457,7 @@ int append_tid(char *str, size_t sz)
	if (end + 8 > sz)
		return -1;

	sprintf(&str[end], "%07d", gettid());
	sprintf(&str[end], "%07ld", sys_gettid());
	str[end + 7] = '\0';

	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ static void test_read_cgroup_xattr(void)
	if (!ASSERT_OK_PTR(skel, "read_cgroupfs_xattr__open_and_load"))
		goto out;

	skel->bss->target_pid = gettid();
	skel->bss->target_pid = sys_gettid();

	if (!ASSERT_OK(read_cgroupfs_xattr__attach(skel), "read_cgroupfs_xattr__attach"))
		goto out;
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ void test_kernel_flag(void)
	if (!ASSERT_OK_PTR(lsm_skel, "lsm_skel"))
		return;

	lsm_skel->bss->monitored_tid = gettid();
	lsm_skel->bss->monitored_tid = sys_gettid();

	ret = test_kernel_flag__attach(lsm_skel);
	if (!ASSERT_OK(ret, "test_kernel_flag__attach"))
+1 −1
Original line number Diff line number Diff line
@@ -158,7 +158,7 @@ static int __tld_init_data_p(int map_fd)
	void *data_alloc = NULL;
	int err, tid_fd = -1;

	tid_fd = syscall(SYS_pidfd_open, gettid(), O_EXCL);
	tid_fd = syscall(SYS_pidfd_open, sys_gettid(), O_EXCL);
	if (tid_fd < 0) {
		err = -errno;
		goto out;
Loading