From nobody Thu Apr 16 08:25:54 2026 Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.170]) (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 BD8722E228D for ; Sun, 1 Mar 2026 19:48:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.121.94.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772394509; cv=none; b=Np9T23ZTeSRy89C5hQqH9UEIn/70qcM9mJyywI2wAbo+tXloAwZaEVu7T40Qv7w7X+2jNuVnfcbXBkc80MY8Hso98R1NVPH8KthX9+OHqgmYiZDSRLWo3he6zn9neL/iqDDqT5xgL6dAlYClt0Dq0+x6dsKGQbQFTFTz4VlO7ro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772394509; c=relaxed/simple; bh=NdOJw7xVc1NRf4ACwkD4GxGMaDJF26htCqebjSDLoN8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DsV5nfAWRRDDNO/mfFvu/VD+KOek1HuL5lDPAG97LBhoSIPr+ZcVUK7p1BPYuzVBWNf0rR+9BbfvcUqTBAdWL5RlkXm8GrEioWSB9N8qQGGLQ4iMHfa66Lqfv5g6s85Z977JBBFIO11p78ioYi71j/iDgwx1pIL2+GD2r1VzXUs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xs4all.nl; spf=pass smtp.mailfrom=xs4all.nl; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b=XvwFPF7l; arc=none smtp.client-ip=195.121.94.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xs4all.nl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xs4all.nl Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=xs4all.nl header.i=@xs4all.nl header.b="XvwFPF7l" X-KPN-MessageId: 73771223-15a7-11f1-8a98-005056ab378f Received: from smtp.kpnmail.nl (unknown [10.31.155.40]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 73771223-15a7-11f1-8a98-005056ab378f; Sun, 01 Mar 2026 20:47:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=mime-version:message-id:date:subject:to:from; bh=ouwXiUmqe8cILbChp5hY3vgGz7Od+5WCWJ+YM942Fko=; b=XvwFPF7lj5HFIqcb4V3atA2YHLu3wXxRKnXtk1YHgwQ8FQ/FZs6yLUqSeFGhdJNGLigTA8XzO2xuN NjxEwXJRDPnjqSMRyqBrKZZdkChqAhDQG/FkmgbVrfDnpxiIP8enJ23IlhsNcfpywPS20gJ7h5/dWn RybYvFzutV0DtCkSlwk8Ekb0ahpuIoYJ9slE7bA2nKSFl8al0llweV6Q7H3UK7aX0Oc7OGJbVthX6S XHxz1kw1W0MO1FpwPttqPlBXwJTZfL6vaYpP3rOXgwZB4KhZXNzcXYruYTR/TxARm2YKhDpKst5oAl 5MO84GrZGhoAhqBtHnqFJaWp3IkTCRA== X-KPN-MID: 33|xsijljn+anyx7p5HiGlfnAeciiJE88Ivp4Zy+yaUn/Kc4m8JxnSxGk7A04Z2ymV gFvqa/lQHXVOjsZd+XR/JxAUtO3a2bCGR/t+INI4kC+E= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|7dQETT0/0NbCQPr2gHMN3r5DJloHJKjAvqiQVrg7j432nmcZBSu5XuQvtDjY47O ycxvtNC+rNbAKDKryW7UcXQ== Received: from daedalus.home (unknown [178.225.31.147]) by smtp.xs4all.nl (Halon) with ESMTPSA id 6ee3a17c-15a7-11f1-b8e2-005056ab7584; Sun, 01 Mar 2026 20:47:16 +0100 (CET) From: Jori Koolstra To: shuah@kernel.org Cc: akpm@linux-foundation.org, richard.weiyang@gmail.com, reddybalavignesh9979@gmail.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, ricardo@marliere.net, Jori Koolstra Subject: [PATCH] selftests: get rid of helper header in openat2 tests Date: Sun, 1 Mar 2026 20:47:29 +0100 Message-ID: <20260301194729.2988595-1-jkoolstra@xs4all.nl> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The openat2 tests include a helper header file that defines the necessary structs and constants to use openat2(2), such as struct open_how. This may result in conflicting definitions when the system header openat2.h is present as well. This commit adds openat2.h generated by 'make headers' to the uapi header files in ./tools/include and removes the helper file definitions of the openat2 selftests. Signed-off-by: Jori Koolstra --- tools/include/linux/openat2.h | 47 +++++++++++++++++++++++ tools/testing/selftests/openat2/Makefile | 2 +- tools/testing/selftests/openat2/helpers.h | 36 +---------------- 3 files changed, 49 insertions(+), 36 deletions(-) create mode 100644 tools/include/linux/openat2.h diff --git a/tools/include/linux/openat2.h b/tools/include/linux/openat2.h new file mode 100644 index 000000000000..1ba1e712f9fd --- /dev/null +++ b/tools/include/linux/openat2.h @@ -0,0 +1,47 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _LINUX_OPENAT2_H +#define _LINUX_OPENAT2_H + +#include + +/* + * Arguments for how openat2(2) should open the target path. If only @flag= s and + * @mode are non-zero, then openat2(2) operates very similarly to openat(2= ). + * + * However, unlike openat(2), unknown or invalid bits in @flags result in + * -EINVAL rather than being silently ignored. @mode must be zero unless o= ne of + * {O_CREAT, O_TMPFILE} are set. + * + * @flags: O_* flags. + * @mode: O_CREAT/O_TMPFILE file mode. + * @resolve: RESOLVE_* flags. + */ +struct open_how { + __u64 flags; + __u64 mode; + __u64 resolve; +}; + +/* how->resolve flags for openat2(2). */ +#define RESOLVE_NO_XDEV 0x01 /* Block mount-point crossings + (includes bind-mounts). */ +#define RESOLVE_NO_MAGICLINKS 0x02 /* Block traversal through procfs-style + "magic-links". */ +#define RESOLVE_NO_SYMLINKS 0x04 /* Block traversal through all symlinks + (implies OEXT_NO_MAGICLINKS) */ +#define RESOLVE_BENEATH 0x08 /* Block "lexical" trickery like + "..", symlinks, and absolute + paths which escape the dirfd. */ +#define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".." + be scoped inside the dirfd + (similar to chroot(2)). */ +#define RESOLVE_CACHED 0x20 /* Only complete if resolution can be + completed through cached lookup. May + return -EAGAIN if that's not + possible. */ + +/* openat2(2) exclusive flags are defined in the upper 32 bits of + open_how->flags */ +#define OPENAT2_EMPTY_PATH 0x100000000 /* (1ULL << 32) */ + +#endif /* _LINUX_OPENAT2_H */ diff --git a/tools/testing/selftests/openat2/Makefile b/tools/testing/selft= ests/openat2/Makefile index 185dc76ebb5f..6952e9934d3f 100644 --- a/tools/testing/selftests/openat2/Makefile +++ b/tools/testing/selftests/openat2/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later =20 -CFLAGS +=3D -Wall -O2 -g -fsanitize=3Daddress -fsanitize=3Dundefined +CFLAGS +=3D -Wall -O2 -g -fsanitize=3Daddress -fsanitize=3Dundefined $(TOO= LS_INCLUDES) TEST_GEN_PROGS :=3D openat2_test resolve_test rename_attack_test =20 # gcc requires -static-libasan in order to ensure that Address Sanitizer's diff --git a/tools/testing/selftests/openat2/helpers.h b/tools/testing/self= tests/openat2/helpers.h index 510e60602511..0d79e80949c4 100644 --- a/tools/testing/selftests/openat2/helpers.h +++ b/tools/testing/selftests/openat2/helpers.h @@ -12,6 +12,7 @@ #include #include #include +#include #include "kselftest.h" =20 #define ARRAY_LEN(X) (sizeof (X) / sizeof (*(X))) @@ -24,45 +25,10 @@ #define SYS_openat2 __NR_openat2 #endif /* SYS_openat2 */ =20 -/* - * Arguments for how openat2(2) should open the target path. If @resolve is - * zero, then openat2(2) operates very similarly to openat(2). - * - * However, unlike openat(2), unknown bits in @flags result in -EINVAL rat= her - * than being silently ignored. @mode must be zero unless one of {O_CREAT, - * O_TMPFILE} are set. - * - * @flags: O_* flags. - * @mode: O_CREAT/O_TMPFILE file mode. - * @resolve: RESOLVE_* flags. - */ -struct open_how { - __u64 flags; - __u64 mode; - __u64 resolve; -}; - #define OPEN_HOW_SIZE_VER0 24 /* sizeof first published struct */ -#define OPEN_HOW_SIZE_LATEST OPEN_HOW_SIZE_VER0 =20 bool needs_openat2(const struct open_how *how); =20 -#ifndef RESOLVE_IN_ROOT -/* how->resolve flags for openat2(2). */ -#define RESOLVE_NO_XDEV 0x01 /* Block mount-point crossings - (includes bind-mounts). */ -#define RESOLVE_NO_MAGICLINKS 0x02 /* Block traversal through procfs-style - "magic-links". */ -#define RESOLVE_NO_SYMLINKS 0x04 /* Block traversal through all symlinks - (implies OEXT_NO_MAGICLINKS) */ -#define RESOLVE_BENEATH 0x08 /* Block "lexical" trickery like - "..", symlinks, and absolute - paths which escape the dirfd. */ -#define RESOLVE_IN_ROOT 0x10 /* Make all jumps to "/" and ".." - be scoped inside the dirfd - (similar to chroot(2)). */ -#endif /* RESOLVE_IN_ROOT */ - #define E_func(func, ...) \ do { \ errno =3D 0; \ --=20 2.53.0