git: efe6a0997383 - stable/14 - fs: Add static asserts for the size of fid structures
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 20 Dec 2024 22:08:33 UTC
The branch stable/14 has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=efe6a0997383d728290cd01c07d9cf59adc2ed05 commit efe6a0997383d728290cd01c07d9cf59adc2ed05 Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2024-12-06 01:56:23 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2024-12-20 22:07:12 +0000 fs: Add static asserts for the size of fid structures File system specific *fid structures are copied into the generic struct fid defined in sys/mount.h. As such, they cannot be larger than struct fid. This patch adds _Static_assert()s to check for this. ZFS and fuse already have _Static_assert()s. (cherry picked from commit 91b5592a1e1af97480d615cf508be05b5674d2f3) --- sys/fs/msdosfs/msdosfs_vnops.c | 2 ++ sys/fs/tmpfs/tmpfs_vnops.c | 2 ++ sys/fs/udf/udf_vnops.c | 2 ++ sys/ufs/ffs/ffs_vnops.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index 078ea5e52312..6417b7dac16b 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -1962,6 +1962,8 @@ msdosfs_vptofh(struct vop_vptofh_args *ap) { struct denode *dep; struct defid *defhp; + _Static_assert(sizeof(struct defid) <= sizeof(struct fid), + "struct defid cannot be larger than struct fid"); dep = VTODE(ap->a_vp); defhp = (struct defid *)ap->a_fhp; diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 206a95350d2e..4571a2855be3 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1687,6 +1687,8 @@ vop_vptofh { struct tmpfs_fid_data tfd; struct tmpfs_node *node; struct fid *fhp; + _Static_assert(sizeof(struct tmpfs_fid_data) <= sizeof(struct fid), + "struct tmpfs_fid_data cannot be larger than struct fid"); node = VP_TO_TMPFS_NODE(ap->a_vp); fhp = ap->a_fhp; diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c index 98a779280690..88bf4917a851 100644 --- a/sys/fs/udf/udf_vnops.c +++ b/sys/fs/udf/udf_vnops.c @@ -1274,6 +1274,8 @@ udf_vptofh(struct vop_vptofh_args *a) { struct udf_node *node; struct ifid *ifhp; + _Static_assert(sizeof(struct ifid) <= sizeof(struct fid), + "struct ifid cannot be larger than struct fid"); node = VTON(a->a_vp); ifhp = (struct ifid *)a->a_fhp; diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index c14cb5e1ee66..0f60f8061043 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -1922,6 +1922,8 @@ ffs_vptofh( { struct inode *ip; struct ufid *ufhp; + _Static_assert(sizeof(struct ufid) <= sizeof(struct fid), + "struct ufid cannot be larger than struct fid"); ip = VTOI(ap->a_vp); ufhp = (struct ufid *)ap->a_fhp;