Date: Fri, 6 Dec 2024 02:12:17 GMT From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 4db1b113b151 - main - tarfs: Fix the size of struct tarfs_fid and add a static assert Message-ID: <202412060212.4B62CH9M014628@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=4db1b113b15158c7d134df83e7a7201cf46d459b commit 4db1b113b15158c7d134df83e7a7201cf46d459b Author: Rick Macklem <rmacklem@FreeBSD.org> AuthorDate: 2024-12-06 02:09:27 +0000 Commit: Rick Macklem <rmacklem@FreeBSD.org> CommitDate: 2024-12-06 02:11:36 +0000 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 --- sys/fs/tarfs/tarfs.h | 2 +- sys/fs/tarfs/tarfs_vnops.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202412060212.4B62CH9M014628>