Date: Sat, 27 Mar 2021 17:45:27 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 71c160a8f614 - main - vfs: Add an assertion around name length limits Message-ID: <202103271745.12RHjRNA033205@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=71c160a8f614fa4812838002ba9d266af3cf988c commit 71c160a8f614fa4812838002ba9d266af3cf988c Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2021-03-27 17:42:48 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2021-03-27 17:45:19 +0000 vfs: Add an assertion around name length limits Some filesystems assume that they can copy a name component, with length bounded by NAME_MAX, into a dirent buffer of size MAXNAMLEN. These constants have the same value; add a compile-time assertion to that effect. Reported by: Alexey Kulaev <alex.qart@gmail.com> Reviewed by: kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29431 --- sys/kern/vfs_lookup.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index e881e8f909a4..07c89e634de4 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> +#include <sys/dirent.h> #include <sys/kernel.h> #include <sys/capsicum.h> #include <sys/fcntl.h> @@ -747,6 +748,14 @@ needs_exclusive_leaf(struct mount *mp, int flags) return (0); } +/* + * Various filesystems expect to be able to copy a name component with length + * bounded by NAME_MAX into a directory entry buffer of size MAXNAMLEN. Make + * sure that these are the same size. + */ +_Static_assert(MAXNAMLEN == NAME_MAX, + "MAXNAMLEN and NAME_MAX have different values"); + /* * Search a pathname. * This is a very central and rather complicated routine.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103271745.12RHjRNA033205>