landlock: Change landlock_add_rule(2) argument check ordering
authorMickaël Salaün <mic@digikod.net>
Fri, 6 May 2022 16:08:18 +0000 (18:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:23:23 +0000 (10:23 +0200)
commit1707df9edaedf4c5b75d2cc8c123ce6c6bbeab8c
tree086906a5d0bf21b50175e897d4abd9d8c50c1f47
parentbb416965dbb8da026f40557f769c884ff32a18a0
landlock: Change landlock_add_rule(2) argument check ordering

commit 589172e5636c4d16c40b90e87543d43defe2d968 upstream.

This makes more sense to first check the ruleset FD and then the rule
attribute.  It will be useful to factor out code for other rule types.

Add inval_add_rule_arguments tests, extension of empty_path_beneath_attr
tests, to also check error ordering for landlock_add_rule(2).

Link: https://lore.kernel.org/r/20220506160820.524344-9-mic@digikod.net
Cc: stable@vger.kernel.org
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
security/landlock/syscalls.c
tools/testing/selftests/landlock/base_test.c