OpenAFS Master Repository branch, master, updated. openafs-devel-1_9_2-235-g98b0415
Gerrit Code Review
gerrit@openafs.org
Tue, 1 Jul 2025 17:04:18 -0400
The following commit has been merged in the master branch:
commit 98b0415b75ae5306fa5e3a9d656a1084afe474a2
Author: Cheyenne Wills <cwills@sinenomine.net>
Date: Mon Jun 23 17:42:21 2025 -0600
afs: Don't build afs_fid() for UKERNEL
Currently, the libafs vnop afs_fid() is built for UKERNEL, even though
no UKERNEL code calls this function. UKERNEL defines its own fake
'struct usr_fid' and a few related preprocessor #define's, which can
cause problems during the build.
Specifically, some code in afs_fid() allocates a 'struct fid' using a
hard-coded size SIZEOF_SMALLFID+2 (10+2) instead of the actual size of a
fid structure. For UKERNEL, this results in an overflow when a small fid
is copied into the fid_data member, since the struct on UKERNEL has a
size of at least 4 bytes plus the fid_data we copy into it:
struct usr_fid {
unsigned short fid_len;
unsigned short fid_reserved;
char fid_data[MAXFIDSZ];
}
This causes a build failure when building rpms under RHEL10, since lto
(link time optimization) is enabled by default. The following warnings
are produced when building the src/libuafs/testlink target:
In function ‘memcpy’,
inlined from ‘afs_fid’ at /build/openafs/packages/rpmbuild/BUILD/openafs-1.9.2-230-gc8f3bf/src/afs/VNOPS/afs_vnop_fid.c:142:6:
/usr/include/bits/string_fortified.h:29:10: warning: ‘__builtin_memcpy’ writing 10 bytes into a region of size 8 overflows the destination [-Wstringop-overflow=]
29 | return __builtin___memcpy_chk (__dest, __src, __len,
| ^
In function ‘afs_osi_Alloc’,
inlined from ‘afs_fid’ at /build/openafs/packages/rpmbuild/BUILD/openafs-1.9.2-230-gc8f3bf/src/afs/VNOPS/afs_vnop_fid.c:138:28:
/build/openafs/packages/rpmbuild/BUILD/openafs-1.9.2-230-gc8f3bf/src/afs/UKERNEL/afs_usrops.c:833:12: note: at offset 4 into destination object of size 12 allocated by ‘malloc’
833 | return malloc(size);
| ^
In function ‘memcpy’,
inlined from ‘afs_fid’ at /build/openafs/packages/rpmbuild/BUILD/openafs-1.9.2-230-gc8f3bf/src/afs/VNOPS/afs_vnop_fid.c:147:2:
/usr/include/bits/string_fortified.h:29:10: warning: ‘__builtin_memcpy’ writing 10 bytes into a region of size 8 overflows the destination [-Wstringop-overflow=]
29 | return __builtin___memcpy_chk (__dest, __src, __len,
| ^
In function ‘afs_osi_Alloc’,
inlined from ‘afs_fid’ at /build/openafs/packages/rpmbuild/BUILD/openafs-1.9.2-230-gc8f3bf/src/afs/VNOPS/afs_vnop_fid.c:138:28:
/build/openafs/packages/rpmbuild/BUILD/openafs-1.9.2-230-gc8f3bf/src/afs/UKERNEL/afs_usrops.c:833:12: note: at offset 4 into destination object of size 12 allocated by ‘malloc’
833 | return malloc(size);
| ^
To avoid this, don't build this function for UKERNEL at all, since it is
never used, and remove some of the related structures and preprocessor
defines. To do this, refactor the logic in afs_vnop_fid.c to only
include it for certain platforms, instead of excluding for certain
platforms. We now only build afs_fid() for Solaris, AIX, Irix, and
HP-UX. Use a #define just for this file, called AFS_VNOP_FID_ENV, to
help make the logic easier to follow.
The questionable hard-coded allocation size is still unchanged, but is
now only used for some esoteric platforms where it maybe makes sense and
are difficult to check (Irix and HP-UX).
Written in collaboration with adeason@sinenomine.net.
Change-Id: I24904d4023066efda95a9f4e38fc0c9372b5913e
Reviewed-on: https://gerrit.openafs.org/16411
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
src/afs/UKERNEL/osi_vnodeops.c | 1 -
src/afs/UKERNEL/sysincludes.h | 21 ---------------------
src/afs/VNOPS/afs_vnop_fid.c | 11 ++++++++---
src/afs/afs_prototypes.h | 2 +-
4 files changed, 9 insertions(+), 26 deletions(-)
--
OpenAFS Master Repository