From owner-dev-commits-src-all@freebsd.org Sat Apr 3 15:14:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0AD565B6C70; Sat, 3 Apr 2021 15:14:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FCL6w73Kdz4ZH9; Sat, 3 Apr 2021 15:14:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ABA8F1528C; Sat, 3 Apr 2021 15:14:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 133FEGev089348; Sat, 3 Apr 2021 15:14:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 133FEGKH089347; Sat, 3 Apr 2021 15:14:16 GMT (envelope-from git) Date: Sat, 3 Apr 2021 15:14:16 GMT Message-Id: <202104031514.133FEGKH089347@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: ca20444e2ad6 - stable/13 - vfs: Add an assertion around name length limits MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ca20444e2ad664c34bb12f1a24f4ca6dc407a5bc Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Apr 2021 15:14:22 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=ca20444e2ad664c34bb12f1a24f4ca6dc407a5bc commit ca20444e2ad664c34bb12f1a24f4ca6dc407a5bc Author: Mark Johnston AuthorDate: 2021-03-27 17:42:48 +0000 Commit: Mark Johnston CommitDate: 2021-04-03 15:12:21 +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 Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D29431 (cherry picked from commit 71c160a8f614fa4812838002ba9d266af3cf988c) --- 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 #include +#include #include #include #include @@ -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.