[LTP] [PATCH v3 05/11] Add landlock01 test

Li Wang liwang@redhat.com
Fri Jul 12 05:03:44 CEST 2024


On Fri, Jul 12, 2024 at 10:11 AM Li Wang <liwang@redhat.com> wrote:

> Hi Petr,
>
> On Fri, Jul 12, 2024 at 4:40 AM Petr Vorel <pvorel@suse.cz> wrote:
>
>> Hi Andrea,
>>
>> again, LGTM, 2 things:
>>
>> 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):
>>
>> landlock01.c:49: TFAIL: Size is too small expected EINVAL: ENOMSG (42)
>>
>> Is it a kernel bug or a test bug?
>>
>
> 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'.
>
> 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;
#endif

So 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.

I guess we might have to resolve this on the test side.




>
>
>
>>
>> I'm not sure if Li's concern [1] was fully addressed:
>>
>>         We still have to adjust the case if someone introduces one more
>> new field
>>         similar to 'handled_access_net' to the structure in the future.
>>
>> Kind regards,
>> Petr
>>
>> [1]
>> https://lore.kernel.org/ltp/CAEemH2dkKvthbx+za-rwfsmanraZuud-sq1O4FZK2zta5MBMSg@mail.gmail.com/
>>
>>
>
> --
> Regards,
> Li Wang
>


-- 
Regards,
Li Wang


More information about the ltp mailing list