aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Macklem <rmacklem@FreeBSD.org>2024-12-06 02:09:27 +0000
committerMark Johnston <markj@FreeBSD.org>2025-01-29 17:27:27 +0000
commitfaa47d299a0ed3af49989495bd1debd469dc54e2 (patch)
tree545e02f8bce821dec7a608ebed572162842147dd
parent1f3cea9cc12c881273c5cae89b299a431b498902 (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(). Approved by: so Security: FreeBSD-SA-25:02.fs Reviewed by: markj MFC after: 2 weeks (cherry picked from commit 4db1b113b15158c7d134df83e7a7201cf46d459b) (cherry picked from commit 155987e2019089a5bd2eef77ed7bcc5cc26c362e)
-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 f2828c60f8a7..4bc923ed8f9c 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);