aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2024-12-06 02:09:27 +0000
committerRick Macklem <rmacklem@FreeBSD.org>2024-12-06 02:11:36 +0000
commit4db1b113b15158c7d134df83e7a7201cf46d459b (patch)
tree0be9fc8f3507095cda53e76f12d9d85734d37c53
parentbd6cd409a955b4a0b0b0d0633b4bbf5e3eac6fdb (diff)
tarfs: Fix the size of struct tarfs_fid and add a static assert
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 packs the structure and checks via a __Static_assert(). Reviewed by: markj MFC after: 2 weeks
-rw-r--r--sys/fs/tarfs/tarfs.h2
-rw-r--r--sys/fs/tarfs/tarfs_vnops.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/sys/fs/tarfs/tarfs.h b/sys/fs/tarfs/tarfs.h
index ff1985e488cd..ffb95d2c0ac5 100644
--- a/sys/fs/tarfs/tarfs.h
+++ b/sys/fs/tarfs/tarfs.h
@@ -165,7 +165,7 @@ struct tarfs_fid {
u_short data0; /* force alignment */
ino_t ino;
unsigned long gen;
-};
+} __packed;
#define TARFS_NODE_LOCK(tnp) \
mtx_lock(&(tnp)->lock)
diff --git a/sys/fs/tarfs/tarfs_vnops.c b/sys/fs/tarfs/tarfs_vnops.c
index 8c97fab185fc..afb8e05f5929 100644
--- a/sys/fs/tarfs/tarfs_vnops.c
+++ b/sys/fs/tarfs/tarfs_vnops.c
@@ -668,6 +668,8 @@ tarfs_vptofh(struct vop_vptofh_args *ap)
{
struct tarfs_fid *tfp;
struct tarfs_node *tnp;
+ _Static_assert(sizeof(struct tarfs_fid) <= sizeof(struct fid),
+ "struct tarfs_fid cannot be larger than struct fid");
tfp = (struct tarfs_fid *)ap->a_fhp;
tnp = VP_TO_TARFS_NODE(ap->a_vp);