syscalls/statx09: Add new test
PATCH 1/1 syscalls/statx09: Add new test
This test is basically the same as statx04 but here we check for the STATX_ATTR_VERITY flag which is currently only implemented on ext4.
Signed-off-by Dai Shili <[email protected]>
--- configure.ac | 1 + include/lapi/fs.h | 4 + include/lapi/fsverity.h | 38 ++++++ include/lapi/stat.h | 4 + m4/ltp-fsverity.m4 | 22 ++++ runtest/syscalls | 1 + testcases/kernel/syscalls/statx/.gitignore | 1 + testcases/kernel/syscalls/statx/statx09.c | 200 +++++++++++++++++++++++++++++ 8 files changed, 271 insertions(+) create mode 100644 include/lapi/fsverity.h create mode 100644 m4/ltp-fsverity.m4 create mode 100644 testcases/kernel/syscalls/statx/statx09.c
configure.ac +1 -0
@@ -367,6 +367,7 @@ LTP_CHECK_SELINUX LTP_CHECK_SYNC_ADD_AND_FETCH LTP_CHECK_SYSCALL_EVENTFD LTP_CHECK_SYSCALL_FCNTL +LTP_CHECK_FSVERITY if test "x$with_numa" = xyes; then LTP_CHECK_SYSCALL_NUMA
include/lapi/fs.h +4 -0
@@ -41,6 +41,10 @@#define FS_NODUMP_FL 0x00000040/* do not dump file */ #endif +#ifndef FS_VERITY_FL +#define FS_VERITY_FL 0x00100000/* Verity protected inode */ +#endif +/* * Helper function to get MAX_LFS_FILESIZE. * Missing PAGE_SHIFT on some libc prevents defining MAX_LFS_FILESIZE.
include/lapi/fsverity.h new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2022 FUJITSU LIMITED. All rights reserved. +* Author: Dai Shili <[email protected]> +*/ +#ifndef LAPI_FSVERITY_H__ +#define LAPI_FSVERITY_H__ + +#include "config.h" +#include <linux/types.h> + +#ifdef HAVE_LINUX_FSVERITY_H +#include <linux/fsverity.h> +#endif + +#ifndef FS_VERITY_HASH_ALG_SHA256 +# define FS_VERITY_HASH_ALG_SHA256 1 +#endif + +#ifndef FS_IOC_ENABLE_VERITY +# define FS_IOC_ENABLE_VERITY _IOW('f', 133, struct fsverity_enable_arg) +#endif + +#ifndef HAVE_STRUCT_FSVERITY_ENABLE_ARG +struct fsverity_enable_arg { +__u32 version; +__u32 hash_algorithm; +__u32 block_size; +__u32 salt_size; +__u64 salt_ptr; +__u32 sig_size; +__u32 __reserved1; +__u64 sig_ptr; +__u64 __reserved2[11 ]; +}; +#endif + +#endif
include/lapi/stat.h +4 -0
@@ -223,6 +223,10 @@ static inline int statx(int dirfd, const char *pathname, unsigned int flags,# define STATX_ATTR_AUTOMOUNT 0x00001000#endif +#ifndef STATX_ATTR_VERITY +# define STATX_ATTR_VERITY 0x00100000 +#endif +#ifndef AT_SYMLINK_NOFOLLOW # define AT_SYMLINK_NOFOLLOW 0x100#endif
m4/ltp-fsverity.m4 new file +22 -0
@@ -0,0 +1,22 @@ +dnl SPDX-License-Identifier: GPL-2.0-or-later +dnl Copyright (c) 2022 Fujitsu Ltd. +dnl Author: Dai Shili <[email protected]> + +AC_DEFUN([LTP_CHECK_FSVERITY],[ + AC_CHECK_HEADERS([linux/fsverity.h], [have_fsverity=yes] ,[AC_MSG_WARN(missing linux/fsverity.h header)]) + if test "x$have_fsverity" = "xyes"; then + AC_COMPILE_IFELSE([AC_LANG_SOURCE([ +#include <linux/fsverity.h> +int main(void) { + struct fsverity_enable_arg tst_fsverity_enable_arg; + return 0; +}])], [has_fsverity_enable_arg="yes"]) + fi + +if test "x$has_fsverity_enable_arg" = "xyes"; then + AC_DEFINE(HAVE_STRUCT_FSVERITY_ENABLE_ARG, 1, [Define to 1 if you have struct fsverity_enable_arg]) + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi +])
runtest/syscalls +1 -0
@@ -1744,6 +1744,7 @@ statx05 statx05 statx06 statx06 statx07 statx07 statx08 statx08 +statx09 statx09 membarrier01 membarrier01
testcases/kernel/syscalls/statx/.gitignore +1 -0
@@ -6,3 +6,4 @@ /statx06 /statx07 /statx08 +/statx09
testcases/kernel/syscalls/statx/statx09.c new file +200 -0
200 lines not on this page · raw message
Signature · 5 lines
1.8.3.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp