Re: [LTP] [PATCH v3 05/11] Add landlock01 test
From: Petr Vorel <pvorel@suse.cz>
Date: 2024-07-12 07:58:22
Hi Andrea, Li, ...
quoted
quoted
First, this fails at least on various kernel versions (tested: Tumbleweed 6.10.0-rc7-3.g92abc10-default, and SLE15-SP4 5.14.21 with lsm=landlock and Debian 6.6.15-amd64):
quoted
quoted
landlock01.c:49: TFAIL: Size is too small expected EINVAL: ENOMSG (42)
quoted
quoted
Is it a kernel bug or a test bug?
quoted
You probably need to check the `/usr/include/linux/landlock.h` header file exist, and to see if 'struct landlock_ruleset_attr' contains the new field 'handled_access_net'.
quoted
If not exist or does not contain that, the test defines 'struct landlock_ruleset_attr' in lapi/landlock.h which contains handled_access_net directly, this is likely the root cause lead test failed on your box.
And, if the header file does not exist, the macro condition will choose to use 'rule_size - 1', and that caused the ENOMSG error during test on the newer kernel.
#ifdef HAVE_STRUCT_LANDLOCK_RULESET_ATTR_HANDLED_ACCESS_NET
rule_small_size = rule_size - sizeof(uint64_t) - 1;
#else
rule_small_size = rule_size - 1;
#endifSo to keep the kernel-headers and running kernel version consistent should be required for the landlock01 test. Otherwise the #ifdef possibly won't work correctly.
FYI Having inconsistent kernel headers and running kernel would be a problem for more LTP tests than just landlock01 (basically many tests which have autotools check). But this can be problematic for some development (e.g. linux-next). Therefore we at least assume UAPI headers shouldn't be newer than running kernel, see https://lore.kernel.org/ltp/ZJP_qPeJ37H4qhEN@yuki/ (local).
I guess we might have to resolve this on the test side.
Trying to compare versions <linux/version.h> could be used: #define LINUX_VERSION_CODE 395008 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c))) #define LINUX_VERSION_MAJOR 6 #define LINUX_VERSION_PATCHLEVEL 7 #define LINUX_VERSION_SUBLEVEL 0 We already use KERNEL_VERSION() in kdump and device-drivers tests. Kind regards, Petr -- Mailing list info: https://lists.linux.it/listinfo/ltp