2001-10-09 16:48:25 +01:00
|
|
|
dnl This file contains the common configuration code which would
|
|
|
|
dnl otherwise be duplicated between configure and configure-libafs.
|
|
|
|
dnl
|
|
|
|
dnl NB: Because this code is a macro, references to positional shell
|
|
|
|
dnl parameters must be done like $[]1 instead of $1
|
|
|
|
|
2004-06-03 07:13:27 +01:00
|
|
|
AC_DEFUN([OPENAFS_CONFIGURE_COMMON],[
|
cf: Set CC before calling AC_PROG_CC
On some platforms (HPUX, SOLARIS, AIX), we forcibly set CC or set a
default CC, because we must use a specific compiler to build kernel
modules, and we specify certain compiler-specific flags. But we do
this after AC_PROG_CC has run, which also searches for a compiler to
use, and runs a few tests against it. AC_PROG_CC often chooses a
different compiler (it prefers gcc if it's available).
As a result, some compiler-derived info may be wrong, which can yield
confusing results, even breaking the build depending on what the
user's PATH is, or what compilers are installed on the system.
We can avoid all of this if we move our CC-setting logic to before
AC_PROG_CC is called. This is a little tricky, because our logic to
set AFS_SYSNAME requires the C compiler, so we must do this before
OPENAFS_SYSNAME, and also before AC_USE_SYSTEM_EXTENSIONS, or any
other autoconf macro that uses the C compiler.
Move our CC-setting logic into a new macro, OPENAFS_PATH_CC, which is
separate from OPENAFS_CONFIGURE_COMMON and must be called before
OPENAFS_CONFIGURE_COMMON. Add some safeguards to try to detect if
AC_PROG_CC is already called to try to prevent future changes from
breaking this; this isn't perfect, but it's better than nothing.
Change-Id: I7c327df5acc5d1ff701b70825eecaaaab4aa44a8
Reviewed-on: https://gerrit.openafs.org/15456
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Ben Huntsman <ben@huntsmans.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
2023-05-19 22:53:55 +01:00
|
|
|
|
|
|
|
AC_USE_SYSTEM_EXTENSIONS
|
|
|
|
AC_PROG_CC
|
|
|
|
|
2018-09-19 21:51:00 +01:00
|
|
|
OPENAFS_AUTOHEADER_TOP
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_AUTOHEADER_BOTTOM
|
2001-10-09 16:48:25 +01:00
|
|
|
SRCDIR_PARENT=`pwd`
|
|
|
|
|
2006-08-01 23:49:36 +01:00
|
|
|
#BOZO_SAVE_CORES pam
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_OPTIONS
|
|
|
|
OPENAFS_DOC
|
2011-07-25 00:20:05 +01:00
|
|
|
|
2014-03-30 13:02:17 +01:00
|
|
|
dnl Checks for UNIX variants.
|
2016-02-29 18:28:28 +00:00
|
|
|
AC_SEARCH_LIBS([strerror],[cposix])
|
2001-10-09 16:48:25 +01:00
|
|
|
|
|
|
|
dnl Various compiler setup.
|
|
|
|
AC_TYPE_PID_T
|
|
|
|
AC_TYPE_SIZE_T
|
|
|
|
|
|
|
|
dnl Checks for programs.
|
|
|
|
AC_PROG_INSTALL
|
|
|
|
AC_PROG_LN_S
|
|
|
|
AC_PROG_RANLIB
|
|
|
|
AC_PROG_YACC
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_LEX
|
2001-10-09 16:48:25 +01:00
|
|
|
|
2017-12-29 19:24:28 +00:00
|
|
|
dnl Checks
|
2010-07-22 18:21:14 +01:00
|
|
|
OPENAFS_FORCE_ABS_INSTALL
|
2001-10-09 16:48:25 +01:00
|
|
|
OPENAFS_CHECK_BIGENDIAN
|
2009-10-12 03:55:05 +01:00
|
|
|
OPENAFS_PRINTF_TAKES_Z_LEN
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_OSTYPE
|
|
|
|
OPENAFS_SYSNAME
|
2011-11-02 16:32:56 +00:00
|
|
|
OPENAFS_OSCONF
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_LINUX_CHECKS
|
|
|
|
OPENAFS_C_ATOMIC_CHECKS
|
|
|
|
OPENAFS_SOCKET_CHECKS
|
|
|
|
OPENAFS_LIBRARY_CHECKS
|
2010-02-27 16:52:03 +00:00
|
|
|
AC_CHECK_RESOLV_RETRANS
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_SOCKOPT_CHECK
|
|
|
|
OPENAFS_PTHREAD_CHECKS
|
2006-01-20 16:40:24 +00:00
|
|
|
HOST_CPU="$host_cpu"
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_BSD_CHECKS
|
|
|
|
OPENAFS_OPTION_TESTS
|
|
|
|
OPENAFS_TIVOLI_TESTS
|
|
|
|
OPENAFS_HEADER_CHECKS
|
|
|
|
OPENAFS_MEMBER_CHECKS
|
|
|
|
OPENAFS_LIBINTL_CHECKS
|
|
|
|
OPENAFS_MORE_OPTION_TESTS
|
|
|
|
OPENAFS_FUNCTION_CHECKS
|
|
|
|
OPENAFS_ROKEN
|
|
|
|
OPENAFS_HCRYPTO
|
|
|
|
OPENAFS_CURSES
|
|
|
|
OPENAFS_C_ATTRIBUTE
|
|
|
|
OPENAFS_C_PRAGMA
|
dir: Introduce struct DirEntryFlex
The directory package as implemented in AFS-2 allocates space for each
directory entry as a DirEntry struct followed by 0-8 contiguous
DirXEntry structs, as needed. This is implemented by:
- afs_dir_NameBlobs calculates the number of blocks needed
- FindBlobs allocates and returns index of entry
- afs_dir_GetBlob returns pointer to 1st DirEntry struct
After this, we populate DirEntry (and any contiguous DirXEntry blocks)
with open code. Most existing code writes the entry's name via a string
copy operation to DirEntry->name, which is only 16 bytes long.
Therefore, for dir entry names that are 16 bytes or longer, OpenAFS
routinely does string copies that look like buffer overruns. This has
not previously caused problems because the OpenAFS code has arranged for
a sufficiently large amount of contiguous memory to be available.
However, this remains undefined behavior in the C abstract virtual
machine; thus compilers are not required to produce safe operation.
Recent changes in the OpenAFS build chain have made this approach no
longer viable:
1) Linux 6.5 commit df8fc4e934c12b 'kbuild: Enable
-fstrict-flex-arrays=3' modified the hardening of several kernel
string operations when running with CONFIG_FORTIFY_SOURCE=y.
2) gcc 13 commit 79a89108dd352cd9288f5de35481b1280c7588a5
'__builtin_dynamic_object_size: Recognize builtin' provides some
enhancements to _builtin_object_size. The Linux commit above will now
use these when the kernel is built with gcc 13.
When OpenAFS is built under Linux 6.5 or higher and gcc 13 or higher,
the hardened strlcpy will BUG for directory entry names longer than 16
characters.
Since there are multiple places where OpenAFS writes directory names,
there are several symptoms that may manifest. However, the first one is
usually a kernel BUG at cache manager initialization if running with
afsd -dynroot _and_ there are any cell names 15 characters or longer in
the client CellServDB. (A 15-character cellname reaches the 16
character limit when -dyrnoot adds the RW mountpoint ".<cellname>".)
Address this by using flexible arrays (standardized with C99). A
flexible array is a variable-length array that is declared with no size
at all, e.g., name[].
Create an autoconf test to determine whether the compiler supports
flexible arrays.
Create a new struct DirEntryFlex. If the compiler supports
flexible arrays, define name[]; otherwise retain the name[16]
definition.
Whenever we write a directory name, use DirEntryFlex so that any
hardening will be satisfied that there is sufficient space for the name.
However, the actual guarantee that this is true is still provided by the
OpenAFS directory routines mentioned above - all of these remain
unchanged.
The DirEntry struct remains unchanged for continued use in OpenAFS, as
well as for any out-of-tree users of the directory package.
Change-Id: I6da5c6c295f051be90017084e5b3a3ef24d1271f
Reviewed-on: https://gerrit.openafs.org/15573
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
2023-09-15 20:01:56 +01:00
|
|
|
OPENAFS_C_FLEXIBLE_ARRAY
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_MORE_ROKEN_CHECKS
|
|
|
|
OPENAFS_NETDB_CHECKS
|
|
|
|
OPENAFS_ROKEN_HEADERS
|
|
|
|
OPENAFS_BSWAP_CHECKS
|
2018-04-04 23:13:24 +01:00
|
|
|
OPENAFS_PIO_CHECKS
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_REGEX_CHECKS
|
|
|
|
OPENAFS_MORE_PTHREAD_CHECKS
|
|
|
|
OPENAFS_TYPE_CHECKS
|
2011-04-28 20:56:11 +01:00
|
|
|
RRA_HEADER_PAM_CONST
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_DIRECTORY_PATHS
|
|
|
|
OPENAFS_YET_MORE_OPTION_TESTS
|
|
|
|
OPENAFS_OUTPUT_VARIABLES
|
2010-04-08 20:50:18 +01:00
|
|
|
OPENAFS_FUSE
|
2009-08-14 22:32:54 +01:00
|
|
|
OPENAFS_SWIG
|
2017-12-29 19:24:28 +00:00
|
|
|
OPENAFS_TOPDIRS
|
|
|
|
OPENAFS_CROSSTOOLS
|
|
|
|
OPENAFS_LINT
|
|
|
|
OPENAFS_CRYPT_CHECKS
|
|
|
|
OPENAFS_C_STRUCT_LABEL_CHECK
|
|
|
|
OPENAFS_DIRENT_CHECKS
|
|
|
|
OPENAFS_SYS_RESOURCE_CHECKS
|
|
|
|
OPENAFS_UUID_CHECKS
|
2018-02-05 21:16:17 +00:00
|
|
|
OPENAFS_CTF_TOOLS_CHECKS
|
2001-10-09 16:48:25 +01:00
|
|
|
])
|