aboutsummaryrefslogtreecommitdiff
path: root/tools/diag
diff options
context:
space:
mode:
authorJessica Clarke <jrtc27@FreeBSD.org>2022-01-02 20:55:36 +0000
committerJessica Clarke <jrtc27@FreeBSD.org>2022-01-02 20:55:36 +0000
commit5b13fa7987c13aa7b5a67cc6b465475912de2d14 (patch)
tree0b92d95488bae37aa8703134a1b6696ba9e041cf /tools/diag
parent04fd468da0d0baea535da418b92df74101a9659d (diff)
downloadsrc-5b13fa7987c13aa7b5a67cc6b465475912de2d14.tar.gz
src-5b13fa7987c13aa7b5a67cc6b465475912de2d14.zip
ufs: Rework shortlink handling to avoid subobject overflows
Shortlinks occupy the space of both di_db and di_ib when used. However, everywhere that wants to read or write a shortlink takes a pointer do di_db and promptly runs off the end of it into di_ib. This is fine on most architectures, if a little dodgy. However, on CHERI, the compiler can optionally restrict the bounds on pointers to subobjects to just that subobject, in order to mitigate intra-object buffer overflows, and this is enabled in CheriBSD's pure-capability kernels. Instead, clean this up by inserting a union such that a new di_shortlink can be added with the right size and element type, avoiding the need to cast and allowing the use of the DIP macro to access the field. This also mirrors how the ext2fs code implements extents support, with the exact same structure other than having a uint32_t i_data[] instead of a char di_shortlink[]. Reviewed by: mckusick, jhb Differential Revision: https://reviews.freebsd.org/D33650
Diffstat (limited to 'tools/diag')
-rw-r--r--tools/diag/prtblknos/prtblknos.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/diag/prtblknos/prtblknos.c b/tools/diag/prtblknos/prtblknos.c
index 771d79e43ec9..ae53471156a6 100644
--- a/tools/diag/prtblknos/prtblknos.c
+++ b/tools/diag/prtblknos/prtblknos.c
@@ -99,8 +99,8 @@ prtblknos(fs, dp)
if (size < fs->fs_maxsymlinklen) {
printf("symbolic link referencing %s\n",
(fs->fs_magic == FS_UFS1_MAGIC) ?
- (char *)dp->dp1.di_db :
- (char *)dp->dp2.di_db);
+ dp->dp1.di_shortlink :
+ dp->dp2.di_shortlink);
return;
}
printf("symbolic link\n");