Re: [PATCH v2 2/2] ksmbd: add KUnit tests for the DACL declared-size boundary

ChenXiaoSong <[email protected]>
Newsgroups org.kernel.vger.linux-kernel,org.kernel.vger.linux-cifs
Message-ID <[email protected]>
On 8/12/26 18:39, Hang Nan wrote:
> diff --git a/fs/smb/server/Kconfig b/fs/smb/server/Kconfig
> index 08d8b7a965a6..05d16052b9a7 100644
> --- a/fs/smb/server/Kconfig
> +++ b/fs/smb/server/Kconfig
> @@ -72,3 +72,16 @@ config SMB_SERVER_KERBEROS5
>   	bool "Support for Kerberos 5"
>   	depends on SMB_SERVER
>   	default y
> +
> +config SMB_SERVER_KUNIT_TEST
> +	tristate "KUnit tests for SMB3 server helpers" if !KUNIT_ALL_TESTS
> +	depends on SMB_SERVER && KUNIT && SHMEM


depends on SMB_SERVER && SMB_KUNIT_TESTS && TMPFS_XATTR

depends on TMPFS_XATTR because it calls ksmbd_vfs_set_sd_xattr().


> --- 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
> +ksmbd-$(CONFIG_SMB_SERVER_KUNIT_TEST) += smbacl_kunit_test.o


obj-$(CONFIG_SMB_SERVER_KUNIT_TEST) += smbacl_kunit_test.o

The kunit tests should be built as a separate .ko instead of being 
linked into ksmbd.ko.


> +static struct kunit_case ksmbd_smbacl_test_cases[] = {
> +	KUNIT_CASE(ksmbd_dacl_walk_must_stop_at_declared_size),
> +	KUNIT_CASE(ksmbd_smb_check_perm_dacl_boundary_test),


We can also add a maximal-access variant of the smb_check_perm_dacl() 
boundary test.

-- 
ChenXiaoSong <[email protected]>
Chinese Homepage: https://chenxiaosong.com
English Homepage: https://chenxiaosong.com/en
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.