Re: [PATCH v3 1/3] ksmbd: add KUnit test for the DACL walk boundary

Namjae Jeon <[email protected]>
Newsgroups org.kernel.vger.linux-cifs
Message-ID <CAKYAXd_6NEWvKAT-j5=3MFh=eT9AuL6vL-Q6HUf2ZMjEjk11OQ@mail.gmail.com>
> diff --git a/fs/smb/server/Kconfig b/fs/smb/server/Kconfig
> index 08d8b7a965a6..463fa19819b2 100644
> --- a/fs/smb/server/Kconfig
> +++ b/fs/smb/server/Kconfig
> @@ -72,3 +72,18 @@ config SMB_SERVER_KERBEROS5
>         bool "Support for Kerberos 5"
>         depends on SMB_SERVER
>         default y
> +
> +config SMB_SERVER_KUNIT_TESTS
> +       tristate "KUnit tests for SMB3 server helpers" if !KUNIT_ALL_TESTS
> +       depends on SMB_SERVER && SMB_KUNIT_TESTS && TMPFS_XATTR
> +       default SMB_KUNIT_TESTS
> +
> +       help
> +         KUnit tests for ksmbd server helpers such as the DACL access
> +         check in smb_check_perm_dacl().  The tests use crafted security
> +         descriptors stored in tmpfs NTACL xattrs to exercise the real
> +         permission-checking path.  This option is only useful for kernel
> +         developers; enable it together with CONFIG_SMB_KUNIT_TESTS.
The help text is currently tied to this particular test and its tmpfs
NTACL implementation. Since SMB_SERVER_KUNIT_TESTS may cover more
server tests in the future, please keep the description more generic.
Also, SMB_KUNIT_TESTS is already listed in the dependency, so it does
not need to be mentioned separately in the help text.
> +
> +         For more information on KUnit and unit tests in the kernel,
> +         please read Documentation/dev-tools/kunit/index.rst.
> diff --git a/fs/smb/server/Makefile b/fs/smb/server/Makefile
> index a3e9306055e8..62228679fc9a 100644
> --- a/fs/smb/server/Makefile
> +++ b/fs/smb/server/Makefile
> @@ -19,3 +19,4 @@ $(obj)/ksmbd_spnego_negtokentarg.asn1.o: $(obj)/ksmbd_spnego_negtokentarg.asn1.c
>
>  ksmbd-$(CONFIG_SMB_SERVER_SMBDIRECT) += transport_rdma.o
>  ksmbd-$(CONFIG_PROC_FS) += proc.o
> +obj-$(CONFIG_SMB_SERVER_KUNIT_TESTS) += smbacl_test.o
> diff --git a/fs/smb/server/smbacl_test.c b/fs/smb/server/smbacl_test.c
Also, could the test be moved under fs/smb/server/tests/, for example:

        fs/smb/server/tests/smbacl_kunit.c

with a tests/Kconfig and tests/Makefile. This follows the usual KUnit
layout and will make it easier to add more server-side tests later.
These are not functional issues, but it seems worthwhile to get the
layout right while adding the first test.
Thanks!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.