openafs.git
2 years agoafs.h: fix out of tree build failures 57/14857/5
Cheyenne Wills [Tue, 11 Jan 2022 01:11:58 +0000]
afs.h: fix out of tree build failures

There are several compiler errors and warnings when building an out of
tree program that includes "afs/afs.h".

 - Errors for unknown type names 'afs_ucred_t' and 'wait_queue_head'
    .../afs/afs.h:1542:16: error: unknown type name ‘afs_ucred_t’
      ... | afs_set_cr_uid(afs_ucred_t *cred, uid_t uid) {
    .../afs/afs.h:1605:5: error: unknown type name ‘wait_queue_head_t’
      ... |     wait_queue_head_t cond;

 - Warnings about declaring structures within missing declarations for
   the structs: osi_File, dcache and afs_FetchOutput
   .../afs/afs.h:1486:36: warning: ‘struct osi_file’ declared inside
        parameter list will not be visible outside of this definition or
        declaration
      ... |     int (*read)(void *rock, struct osi_file *tfile,
                     afs_uint32 offset,

 - Unable to find the file for the include opr/jhash.h

The missing type name 'afs_ucred_t' is due to miss-placed declarations
for some kernel only functions.

The type name 'wait_queue_head' is a data type for Linux kernel modules.

The warnings for the missing declarations are due to either references
to the structures before they are declared, or because they are not
available in any of the other public header files.

To fix the unknown type name afs_ucred_t, relocate the function
declarations that reference 'afs_ucred_t' into the KERNEL only section
(since afs_ucred_t is a kernel specific type).

To fix the unknown type name 'wait_queue_head', relocate the afs_event
structure and the afs_evhasht variable to be within the KERNEL only
section.

To resolve the warnings associated with the structures, simply declare
the structure names before they are referenced.  All references that
are resulting in the warnings are declarations for pointers.

Relocate the include for opr/jhash.h and the define for VCSIZE into the
kernel block.

Change-Id: I4135ff25b76d3221c7779c279ed829000ce31f1c
Reviewed-on: https://gerrit.openafs.org/14857
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoAdd sysname, files and header entries for FreeBSD 12.3 60/14860/2
Mans Nilsson [Thu, 16 Dec 2021 20:36:22 +0000]
Add sysname, files and header entries for FreeBSD 12.3

Created a new sysname "amd64_fbsd_123" in src/config/afs_sysnames.h
and added "param" files with minimal changes:

modified:   src/config/afs_sysnames.h
new file:   src/config/param.amd64_fbsd_123.h
new file:   src/config/param.i386_fbsd_123.h

This mod builds on 12.3 with all tests passing.

Change-Id: Iccf9cfe75362511337b1c09267489d258a5913cb
Reviewed-on: https://gerrit.openafs.org/14860
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Add test keys in afstest_BuildTestConfig 35/14835/5
Andrew Deason [Thu, 1 Apr 2021 05:12:43 +0000]
tests: Add test keys in afstest_BuildTestConfig

Change afstest_BuildTestConfig to add the local keys into the
generated config dir, unless the info->skipkeys is set. This just
makes afstest_BuildTestConfig a little easier to use for the common
case of generating a fully-usable config dir with usable keys (only
some callers want to skip generating keys in order to test
key-populating functionality).

Change-Id: I1ce9d062ea30c391a93562fc90bc18997de75383
Reviewed-on: https://gerrit.openafs.org/14835
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: Drop GLOCK for various Rx calls 84/14184/7
Andrew Deason [Sun, 3 May 2020 15:33:28 +0000]
afs: Drop GLOCK for various Rx calls

Most calls into Rx from libafs do so without the AFS_GLOCK, but a few
pieces of code still hold AFS_GLOCK while making some Rx calls. A few
calls into Rx also currently require AFS_GLOCK, but drop AFS_GLOCK
internally, which is somewhat confusing/inconsistent. Calling Rx
functions with AFS_GLOCK held can potentially cause locking/allocation
problems on various platforms, such as FreeBSD where we get WITNESS
warnings about acquiring sleepable Rx locks while holding the
non-sleepable AFS_GLOCK.

Fix a variety of Rx calls from libafs to drop AFS_GLOCK before calling
into Rx. Specifically, this commit handles calls to rxi_GetIFInfo,
rx_InitHost, rx_StartServer, rx_ServerProc, rx_GetConnection,
rx_DestroyConnection/rx_PutConnection, and
rx_SetConnSecondsUntilNatPing.

For calls made via afs_start_thread, adjust afs_start_thread to accept
a new argument that says whether to acquire AFS_GLOCK for the relevant
function or not.

For a call to rx_InitHost inside afs_InitSetup, dropping GLOCK makes
it possible for another thread to also enter afs_InitSetup while we're
running, before afs_InitSetup_done is set. To prevent two threads from
running afs_InitSetup in parallel, introduce afs_InitSetup_running
(which is set while afs_InitSetup is running), and simply wait for it
to be cleared if it is set when we enter afs_InitSetup.

This commit does not handle strictly all calls into Rx from libafs,
since many Rx calls don't do anything interesting besides set some
internal variables, and so AFS_GLOCK doesn't really matter for them,
and dropping/reacquiring it around those calls may have performance
impact.

Change-Id: Ib6344f08593182ad0f812ea42eb8c91d8f082356
Reviewed-on: https://gerrit.openafs.org/14184
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoautoconf: Remove/update obsolete autoconf macros 38/14838/4
Cheyenne Wills [Tue, 2 Nov 2021 15:18:51 +0000]
autoconf: Remove/update obsolete autoconf macros

Autoconf 2.70 (released in 2020-12) produces warning messages about
obsolete constructs by default.

Running regen.sh with autoconf 2.70 installed produces the following
warnings:

..
 configure.ac:7: warning: The macro `AC_CONFIG_HEADER' is obsolete.
 configure.ac:21: warning: AC_PROG_LEX without either yywrap or noyywrap
   is obsolete
 configure.ac:21: warning: The macro `AC_HEADER_STDC' is obsolete.
 configure.ac:21: warning: The macro `AC_HEADER_TIME' is obsolete.
..

Replace AC_CONFIG_HEADER with AC_CONFIG_HEADERS

Add the noyywrap parameter to AC_PROG_LEX.  Use the noyywrap option
since we already provide a yywrap function in the .l sources.

Remove AC_HEADER_STDC.  There are no references to the the autoconf
variable set by this macro.  This macro was marked as obsolete prior to
autoconf 2.64 with the following note:
 "This macro is obsolescent, as current systems have conforming header
 files. New programs need not use this macro."

AC_HEADER_TIME was marked as obsolete prior to autoconf 2.64 with the
following note:
 "This macro is obsolescent, as current systems can include both files
  when they exist. New programs need not use this macro."

The only reference that requires AC_HEADER_TIME is within the external
roken code pulled from heimdal. Compiles that use the external upstream
heimdal packages result in a build error if TIME_WITH_SYS_TIME is not
defined:
  building src/crypto/hcrypto
    src/external/heimdal/hcrypto/camellia.c
      include/roken.h:803:58: error: ‘struct tm’ declared inside

Update autoheader.m4 so a define for TIME_WITH_SYS_TIME is created. This
avoids modifying the external heimdal/roken code.

Change-Id: If4d6c0650aac617f535b35f81994b54a3b8ac021
Reviewed-on: https://gerrit.openafs.org/14838
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoLINUX-5.16: Use linux/stdarg.h if available 44/14844/3
Cheyenne Wills [Tue, 16 Nov 2021 17:55:30 +0000]
LINUX-5.16: Use linux/stdarg.h if available

Global use of the compiler option '-isystem' was removed from the top
level Makefile with Linux commit ('isystem: delete global -isystem
compile option' 04e85bbf7). This results with an error due to not
finding "stdarg.h" when building the openafs kernel module.

 .../src/rx/rx_kcommon.h:143:12: fatal error: stdarg.h: No such file or
                                 directory
   143 | #  include "stdarg.h"
       |            ^~~~~~~~~~

Linux-5.15, introduced a copy of stdarg.h as 'linux/stdarg.h' in commit
('isystem: ship and use stdarg.h' c0891ac15)

Add a test for the linux/stdarg.h include file and if available, use
"linux/stdarg.h" instead of "stdarg.h" within the Linux kernel module.

Change-Id: I5215182c8240034bd739688a88a9410b74f93c8f
Reviewed-on: https://gerrit.openafs.org/14844
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoprdb.txt: correct fixed header length 24/14824/3
Benjamin Kaduk [Sun, 3 Oct 2021 22:44:05 +0000]
prdb.txt: correct fixed header length

It is decimal 64, not hex 64.

Change-Id: Iee51f4536e8e811bd6ba7e2b86bdde5183227928
Reviewed-on: https://gerrit.openafs.org/14824
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Check for vlserver startup 04/14804/5
Andrew Deason [Thu, 17 Sep 2020 04:05:07 +0000]
tests: Check for vlserver startup

Currently, afstest_StartVLServer waits for a fixed amount of time (5
seconds) for the vlserver to startup. This means each test that runs a
vlserver takes at least 5 seconds, which adds up very quickly when new
tests are added for vlserver functionality.

Instead of waiting 5 seconds each time, change afstest_StartVLServer
to check if the vlserver has started up, and to wait a much shorter
time if it hasn't finished starting up yet. Specifically, wait until
the "Starting AFS vlserver" message appears in VLLog, and the
UBIK_RECHAVEDB recovery state bit is set. This allows vlserver-based
tests to run much more quickly.

Change-Id: I74015670a301980e6d89b3149ed9f2a6c1a40523
Reviewed-on: https://gerrit.openafs.org/14804
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Introduce afstest_MyHostAddr 02/14802/3
Andrew Deason [Sat, 24 Apr 2021 21:08:38 +0000]
tests: Introduce afstest_MyHostAddr

Several places resolve the local hostname into an IP address.
Consolidate these into a single function (gethostaddr), and add the
function afstest_MyHostAddr, which caches the IP and bails if we can't
resolve our hostname.

Change-Id: I7f71cd136796e4395c639eed8dd8eb19a7b9beec
Reviewed-on: https://gerrit.openafs.org/14802
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: record afs_CacheTruncateDaemon stats indirectly 99/14199/14
Mark Vitale [Tue, 14 Apr 2020 21:13:02 +0000]
afs: record afs_CacheTruncateDaemon stats indirectly

In preparation for a future commit, record the CTD_stats through a
pointer.

No functional change is incurred by this commit.

Change-Id: Id0cb97daf06535bad2d14be19bc8d957d6816808
Reviewed-on: https://gerrit.openafs.org/14199
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoafs: export internal stats for afs_CacheTruncateDaemon 98/14198/14
Mark Vitale [Wed, 1 Apr 2020 18:48:37 +0000]
afs: export internal stats for afs_CacheTruncateDaemon

In preparation for a future commit, redefine CTD_stats so they can be
reported externally.  While here, move and rename the struct.

While here, also remove an old comment concerning AIX.

No functional change is incurred by this commit.

Change-Id: If68e44f9dfae5a227d3a24f9fe34932ead1972d1
Reviewed-on: https://gerrit.openafs.org/14198
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoafs: consolidate disk block calculations 27/14227/9
Mark Vitale [Fri, 22 May 2020 22:31:56 +0000]
afs: consolidate disk block calculations

Similar code is used in several places to calculate the number of 1KiBi
blocks required for a cache chunk, rounded up to the nearest
afs_fsfragsize.  Coalesce these into a single inline function,
afs_round_to_fsfragsize.

No functional change should be incurred by this commit.

Change-Id: I1f58ad28426b786fc9809df01d409c8137437012
Reviewed-on: https://gerrit.openafs.org/14227
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoAdd static assert for size of osi_timeval32_t 95/14195/14
Mark Vitale [Mon, 4 May 2020 19:55:07 +0000]
Add static assert for size of osi_timeval32_t

OpenAFS code requires osi_timeval32_t to have 32-bit sizes for members
tv_sec and tv_usec - a total of 8 octets.  One symptom of a
misdefinition may be incorrect operation of xstat_cm_test, which relies
on wire representations of time being 8 bytes on both the client and
server side.

In order to prevent incorrect sizes of osi_timeval32_t, add a static
assert.

Change-Id: Iff487da792aec5aae5e32b2d3409d8639a7ea51a
Reviewed-on: https://gerrit.openafs.org/14195
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoFBSD: Drop GLOCK when grabbing vnode locks 82/14182/7
Andrew Deason [Sun, 3 May 2020 02:01:50 +0000]
FBSD: Drop GLOCK when grabbing vnode locks

In a few places, we try to vn_lock() or VOP_LOCK() while holding
AFS_GLOCK (or do something like vrele(), which internally acquires the
vnode lock). This is against the FBSD locking rules, since our
AFS_GLOCK is a non-sleepable 'struct mtx' lock, and vnode locks are
sleepable lockmgr locks.

So, drop AFS_GLOCK while acquiring vnode locks.

Change-Id: I0ca449bb6398aa8ededd5bb67d56a7d3f13688f0
Reviewed-on: https://gerrit.openafs.org/14182
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoRemove kdump 23/14623/10
Cheyenne Wills [Wed, 7 Jul 2021 17:08:10 +0000]
Remove kdump

Remove the obsolete kdump debugging tool from the tree.  Remove and
clean up the preprocessor tests associated with KDUMP, KDUMP_RX_LOCK and
KDUMP_KERNEL.  Clean up the autoconf and Makefiles to remove kdump and
the associated autoconf and Makefile vars XLIBELFA and XLIBKVM.

The kdump utility has not been well maintained; for some platforms it
fails to build (e.g. Solaris 11).  For Linux, the makefile does not
even try to compile the kdump source but instead creates the kdump file
via touch.

The intended functionality of kdump has been replaced by various kernel
debugging tools, such as dtrace or systemtap.

Change-Id: I23fd82f2b96ba58d1b431af76fdf0afe7d7274b9
Reviewed-on: https://gerrit.openafs.org/14623
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoFBSD: use sx(9) locks for rx afs_kmutex_t 83/14183/6
Andrew Deason [Sun, 3 May 2020 01:56:46 +0000]
FBSD: use sx(9) locks for rx afs_kmutex_t

On FBSD, afs_kmutex_t is defined as a struct mtx, which is a
non-sleepable lock. If we hold one of these locks and then try to
acquire a sleepable lock, there is the potential for deadlock, and
WITNESS complains.

One way this is a problem is that we acquire IFNET_RLOCK in
rxi_GetIFInfo(), which is a sleepable lock. We enter this function
via rxi_FindPeer -> rxi_InitPeerParams, which is encountered while
holding a variety of different Rx locks in different situations, such
as rx_peerHashTable_lock and rx_connHashTable_lock.

Another way this is a problem is that we allocate memory in a variety
of situations whole holding various Rx locks. Currently many of these
are sleepable allocations (which could cause deadlocks); we could
avoid that if they were converted to non-sleepable allocations, but
then the allocations may fail and we'd need to adjust all of the
relevant code paths to accommodate.

To avoid these issues, define Rx's afs_kmutex_t locks to sx(9) locks,
which are sleepable. Drop the use of MTX_DUPOK/SX_DUPOK during lock
init, since we shouldn't be acquiring duplicate locks.

This does not appear to introduce any new issues, except where we
acquire Rx locks while holding the libafs AFS_GLOCK, which we probably
shouldn't be doing and is fixed in subsequent commits. Note that other
platforms also tend to use sleepable locks for afs_kmutex_t: for
example, on LINUX, we use struct mutex (which is sleepable).

Change-Id: I78ede8eb6ba8935d0082925c5475c42260eb7d59
Reviewed-on: https://gerrit.openafs.org/14183
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoubik: Skip sleep on first pass in urecovery loop 03/14803/2
Andrew Deason [Fri, 18 Sep 2020 01:54:54 +0000]
ubik: Skip sleep on first pass in urecovery loop

When running a dbserver without any remote sites, we become the sync
site immediately, since there aren't any other sites so we don't need
to do any processing of votes. The ubik database can thus be accessed
immediately, except we cannot start ubik write transactions right
away, since UBIK_RECHAVEDB will not be set, causing
urecovery_AllBetter() to fail.

UBIK_RECHAVEDB is not set immediately, because urecovery_Interact
sleeps 4 seconds at the beginning of its loop, so no recovery flags
will be set for the first 4 seconds during startup. This makes it
impossible to start any ubik write transactions for the first 4
seconds, even if we're the only site. That may not be a significant
amount of time for a user (since a dbserver daemon doesn't startup too
frequently), but this can cause huge delays for automated testing of
dbservers.

To get rid of this unnecessary delay, just skip this delay the first
time we go through the urecovery_Interact loop.

Change-Id: Ie6653b7b742dcf37798a6bf340b29c283ac3bc4c
Reviewed-on: https://gerrit.openafs.org/14803
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoprdb_check: fix -pheader output 27/14827/2
Benjamin Kaduk [Fri, 8 Oct 2021 04:11:12 +0000]
prdb_check: fix -pheader output

This is prdb_check, so we will print the PRDB header, not the
KADB header.

Change-Id: Id956400794ce866875c1772791301122cc4e1413
Reviewed-on: https://gerrit.openafs.org/14827
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoLINUX 5.14: explicitly set set_page_dirty to default 26/14826/2
Cheyenne Wills [Thu, 7 Oct 2021 17:15:58 +0000]
LINUX 5.14: explicitly set set_page_dirty to default

Linux 5.14 commit: 'mm: require ->set_page_dirty to be explicitly wired
up' (0af573780b0b13) removed calling __set_page_dirty_buffers when the
address_space_operations structure member set_page_dirty was NULL.

A kernel RIP error can occur when the set_page_dirty operation is
requested. (Reproducible by running 'iozone -B -a')

Update the definition for afs_file_aops to explicitly set the
'set_page_dirty' member to '__set_page_dirty_buffers'.

There are no functional changes, since this commit is using the same
function that the Linux kernel was using if set_page_dirty had been
NULL.

Problem originally reported by "Andrej Filipcic"
<andrej.filipcic@ijs.si> in the openafs-info mailing list.  The Linux
5.14 commit causing the openafs failure was identified by "Michael Laß"
<lass@mail.upb.de> also on in the openafs-info mailing list.

Note: The declaration for the function '__set_page_dirty_buffers' was
moved from linux/mm.h into linux/buffer_head.h in Linux 2.6.19.  Since
this is close to the minimum supported Linux version 2.6.18, we are not
introducing an additional autoconf test to determine which header file
the declaration for __set_page_dirty_buffers resides in.

Change-Id: I8f2a00e374635ab1aa69d6eaef8cf97bb449d089
Reviewed-on: https://gerrit.openafs.org/14826
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: Michael Laß <lass@mail.uni-paderborn.de>
Reviewed-by: Michael Laß <lass@mail.uni-paderborn.de>
Tested-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Ralf Brunckhorst <rbrunckhorst@sinenomine.net>
Tested-by: Ralf Brunckhorst <rbrunckhorst@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoCVE-2018-7168 RXAFS_StoreACL deprecate 134 introduce 164 42/12942/5
Jeffrey Altman [Sat, 24 Feb 2018 01:10:27 +0000]
CVE-2018-7168 RXAFS_StoreACL deprecate 134 introduce 164

There exist in the wild AFS3 clients that improperly construct access
control lists which are then stored to directories via RXAFS_StoreACL
(opcode 134).  These clients add negative access control entries (if any)
to the normal rights list.

As there is no method by which a fileserver can determine that the
ACL is improperly constructed, the only method to defend the storage of
broken ACLs is to identify clients that are known to properly construct
ACLs by introducing a new RXAFS_StoreACL opcode (164).

This change:

 * Renames RXAFS opcode 134 to RXAFS_OldStoreACL

 * Introduces RXAFS opcode 164 as RXAFS_StoreACL

 * Implements SRXAFS_OldStoreACL and SRXAFS_StoreACL in the fileserver
   via a common_StoreACL() function that accepts the executed opcode
   as input.

 * To avoid breaking changes in stable release branches,
   SRXAFS_OldStoreACL will still be allowed by default, with an option
   to cause it to be failed by default with error EPERM/UAEPERM.
   A follow-up commit will cause SRXAFS_OldStoreACL to fail by default
   on the master branch.

 * When opcode 134 is called, the a FileLog entry will be generated
   at log level 0 instead of 1 and the entry will contain the string
   "CVE-2018-7168".

 * Modifies the format of the ACL logged to the FileLog and the audit
   stream.  Previously the AFSOpaque format was used directly.  The
   problem with this format is that it uses newlines as the ACE
   separator.  Since the FileLog and file audit log is intended to
   be one line per log entry, the newlines break the file formats.
   This change replaces the newlines with spaces for display purposes
   unless the process is unable to allocate the additional memory.

 * Introduces a new fileserver command line switch -cve-2018-7168-enforce
   which when specified causes SRXAFS_OldStoreACL RPCs to be failed.

[kaduk@mit.edu: switch en/disable-by-default behavior and fix argument parsing]

Change-Id: Ic92ef45314d75fbc2b8ff574223fab2d398a1d60
FIXES: 134485
Reviewed-on: https://gerrit.openafs.org/12942
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Add existing-database test for pt_util 01/14801/2
Andrew Deason [Mon, 28 Dec 2020 20:14:54 +0000]
tests: Add existing-database test for pt_util

Our current tests for pt_util use pt_util to generate a prdb, and then
check the output of pt_util against that created database. Add a new
test that runs pt_util against an existing database (with the same
test data), to make sure that pt_util is still using the same db
format.

Change-Id: I4dbe7f3b5080ee6ff1f9509992b5686fc8381da0
Reviewed-on: https://gerrit.openafs.org/14801
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorx: Cleanup rx.h 29/14629/6
Cheyenne Wills [Mon, 14 Jun 2021 22:13:57 +0000]
rx: Cleanup rx.h

Fix up indentation and white space within preprocessor statements.

Remove multiple blank lines

Fix #endif comments so they match the #if

Split long #define lines
  RX_PACKET_TYPES
  rx_MaxUserDatasize,
  RXS_OP
  RXS_SetConfiguration

Note, this commit does not refactor any preprocessor statements.

Change-Id: I327e9588e96bba9d768ccf345650aced7e824328
Reviewed-on: https://gerrit.openafs.org/14629
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Introduce afstest.pm 00/14800/3
Andrew Deason [Mon, 28 Dec 2020 19:12:59 +0000]
tests: Introduce afstest.pm

Create a perl module for some generic common code for our tests
written in perl: afstest.pm. With this commit, the module just
contains a couple of functions to calculate paths in our src and obj
trees (src_path(), obj_path()), analogous to afstest_src_path and
afstest_obj_path in our C helper library, libafstest_common.la.

Convert all existing perl test code that uses C_TAP_SOURCE/C_TAP_BUILD
to use these new functions.

Change-Id: I5e4d45e3d2d59449bbfc426476cb29b710c73bc1
Reviewed-on: https://gerrit.openafs.org/14800
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agofs: add option to evaluate symlink or mtpt 42/14542/7
Marcio Barbosa [Thu, 1 Jul 2021 13:47:50 +0000]
fs: add option to evaluate symlink or mtpt

Currently, several fs subcommands for Windows offer an option (-literal)
to evaluate symlink / mount point rather than the object it refers to.
Provide the same option on Unix for fs_getfid.

Change-Id: I55ab5f96d5b9e63efbe7e938647edba05a1787ed
Reviewed-on: https://gerrit.openafs.org/14542
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoFBSD: Use GENERIC kernel headers by default 01/14001/8
Andrew Deason [Sun, 22 Dec 2019 06:43:07 +0000]
FBSD: Use GENERIC kernel headers by default

Currently, if --with-bsd-kernel-build is not specified during
configure, we do not set KERNBUILDDIR during the libafs build at all.
This means that we do not use an opt_global.h during the build.

For the GENERIC kernel, in the past this has worked well enough to
produce a working kernel module, but with FreeBSD 12, the GENERIC
kernel turns on the VIMAGE option by default. If our kernel module is
built without VIMAGE defined, our kernel module cannot be loaded into
GENERIC, since VIMAGE changes the definitions of some symbols that we
use (for example, trying to load such a libafs fails with the message
"link_elf_obj: symbol in_ifaddrhead undefined").

To allow the build to work by default for GENERIC kernels, without
needing any additional configure flags, change the libafs Makefile to
use the headers for the GENERIC kernel if no kernel build dir is
given. To do this, we create a directory in our build tree and
generate the opt_*.h headers in there (using config(8)), and specify
that directory as the kernel build dir.

This approach only works for GENERIC kernels, of course, but that is
the most common scenario. Users that want to build for a custom kernel
configuration still need to specify the actual kernel build dir with
--with-bsd-kernel-build.

Change-Id: If716d3f8ded9596d8e5e98bf2e58888921fc5f7f
Reviewed-on: https://gerrit.openafs.org/14001
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: Call afs_FindVCache with DO_STATS, not 1 23/14823/2
Andrew Deason [Sat, 2 Oct 2021 02:02:42 +0000]
afs: Call afs_FindVCache with DO_STATS, not 1

Several callers pass the bare literal 1 to afs_FindVCache, instead of
the named constant DO_STATS. Use the constant, for clarity.

Change-Id: I0c70ee17f48c773dcb3f4d42ec106f440c5bed2c
Reviewed-on: https://gerrit.openafs.org/14823
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoIRIX: Remove pre-65 code 30/14230/4
Andrew Deason [Mon, 25 May 2020 21:48:34 +0000]
IRIX: Remove pre-65 code

Commit d1923139 (irix kill efs and start pruning pre-65) removed all
files that defined AFS_SGI64_ENV and earlier, but didn't remove that
code that depended on those defines. In addition, there has been code
in the tree that checks for AFS_SGI53_ENV since OpenAFS 1.0, but
nothing has ever defined Irix 5.3 support in OpenAFS.

Remove all of this obsolete code. Change all references to
AFS_SGIXX_ENV to AFS_SGI_ENV, and assume AFS_SGI_ENV is defined in all
IRIX dirs. Consolidate some of the resulting ifdef logic
appropriately.

Change-Id: I9dd426296e04801980b805a5e195063762b23189
Reviewed-on: https://gerrit.openafs.org/14230
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: Remove 'retry' arg from afs_FindVCache 31/14231/4
Andrew Deason [Mon, 25 May 2020 21:48:37 +0000]
afs: Remove 'retry' arg from afs_FindVCache

Since OpenAFS 1.0, afs_FindVCache has had an optional 'retry' output
arg. The relevant functionality appears to have been specific to Irix
versions before 5.3, but even OpenAFS 1.0 only had param.h files and
general build logic for Irix 6.2 and later.

With commit 13e44b2b (afs: Refactor osi_vnhold/AFS_FAST_HOLD), the
unused 'retry' argument has now been removed from the lower-level
osi_vnhold function, so now remove it from afs_FindVCache and related
comments, and remove the associated logic to handle a non-zero
'retry'.

Change-Id: I4464347bf6e0a57f8babbcdcdf5283e52532f687
Reviewed-on: https://gerrit.openafs.org/14231
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agobos: Improve string safety 65/14765/7
Michael Meffie [Wed, 23 Jun 2021 01:13:44 +0000]
bos: Improve string safety

To avoid potential string overflows and allow for larger strings in the
future, convert to safe string functions and remove fixed length stack
allocated strings in the bos client.

Add string truncation checks to the date format helper function.

Change-Id: Icf73b970d2c5d22fc6d3c8201498eff74e104812
Reviewed-on: https://gerrit.openafs.org/14765
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: remove dead code afs_SetCheckServerNATmode 12/14812/3
Mark Vitale [Thu, 16 Sep 2021 20:46:59 +0000]
afs: remove dead code afs_SetCheckServerNATmode

afs_SetCheckServerNATmode was introduced by f86af4af2600
'nat-mode-20060330', an early implementation of cache manager
disconnected mode.

It was first used in d335c636e25d 'discon-20060714'.

The last caller was removed by 99c1e0beb1b
'disconnected-merge-conflict-20080630'.

Remove the dead code.  While here, also remove an incorrect comment on
the default probe interval value.

No functional change is incurred by this commit.

Change-Id: I8b6a9d052d011ad0e7d0d5bd0a816d44a497b697
Reviewed-on: https://gerrit.openafs.org/14812
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoafs: eliminate INSTRUMENT_LOCKS 16/14716/2
Mark Vitale [Mon, 26 Jul 2021 03:01:51 +0000]
afs: eliminate INSTRUMENT_LOCKS

Since the original IBM code import, there have been two versions of the
lock macros: one with INSTRUMENT_LOCKS (the default) and one without.
Only the former is ever enabled.  Therefore, remove the unused latter
versions, and all INSTRUMENT_LOCKS conditional logic.

No functional change is incurred by this commit.

Change-Id: I154cd07e81ce7e9a2cc1bb4f0f93615de921e199
Reviewed-on: https://gerrit.openafs.org/14716
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoafs: remove lock dead code 07/14407/4
Mark Vitale [Thu, 22 Oct 2020 22:35:49 +0000]
afs: remove lock dead code

Since OpenAFS 1.0, LockWait has been commented out, and the following
routines have been unreferenced:
- ObtainLock
- ReleaseLock
- afs_osi_SleepR
- afs_osi_SleepW
- afs_osi_SleepS

Remove them from the code and comments.

No functional change is incurred by this commit.

Change-Id: I480d023282878243f9a92f432d7bbec7028af70c
Reviewed-on: https://gerrit.openafs.org/14407
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Use real tempfile in pt_util-t 99/14799/2
Andrew Deason [Mon, 28 Dec 2020 18:22:22 +0000]
tests: Use real tempfile in pt_util-t

Use a real call to File::Temp::tempfile to generate our temporary
filename, instead of creating a somewhat predictable filename based on
our pid.

Change-Id: Icb585c04e088b1fa37dffb6d92fc41cdb14874c7
Reviewed-on: https://gerrit.openafs.org/14799
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoFBSD: Invalidate pages after non-VM write 66/14166/6
Andrew Deason [Mon, 27 Apr 2020 19:47:08 +0000]
FBSD: Invalidate pages after non-VM write

Our VOP_WRITE implementation causes the given data to be written to
the libafs cache, and potentially to the fileserver, but does not
update pages mapped to our vnode. This can cause file data to appear
out-of-date if otherwise valid pages exist for that range.

As a practical example of this, when running 'make buildworld' in
/afs, we run:

cc -nostdlib -Wl,-dc -r -o ipf.lo ipf_stub.o [...]
    crunchide -k _crunched_ipf_stub ipf.lo

The first 'cc' command generates ipf.lo by writing to an mmap'd
region, and the second 'crunchide' command rewrites that file using
write() syscalls.

Afterwards, anything that reads from ipf.lo using mmap'd memory will
see the ipf.lo that 'cc' generated; anything that reads using read()
syscalls will see the updated version from 'crunchide'. And of course
if the pages are evicted for any other reason (such as memory
pressure), everything will see the updated version from 'crunchide'.

The eventual error seen during 'make buildworld' involves duplicate
symbols during linking, since 'crunchide' modifies most symbols to be
hidden. For example:

cc [...] -static -o rescue rescue.o cat.lo [...] ipf.lo [...]
    ld: error: duplicate symbol: main
    >>> defined at rescue.c
    >>>            rescue.o:(main)
    >>> defined at count4bits.c
    >>>            ipf.lo:(.text+0x10)

    ld: error: duplicate symbol: main
    >>> defined at rescue.c
    >>>            rescue.o:(main)
    >>> defined at trace.c
    >>>            routed.lo:(.text+0x3DE0)
    [...]

To fix this, call vn_pages_remove() to invalidate the pages in the
given range after the write has gone through (successfully or not, in
case of partial writes or other edge cases). We don't do this lower in
afs_write(), since that is also called from our VOP_PUTPAGES()
implementation, and we'd be invalidating pages that we were just given
to write out.

Change-Id: I67708ae994da4a4c26edf32e545606a5238da4d0
Reviewed-on: https://gerrit.openafs.org/14166
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agovlserver: Use bounded string copy in FindByName() 63/14763/3
Michael Meffie [Thu, 19 Aug 2021 16:52:30 +0000]
vlserver: Use bounded string copy in FindByName()

Although the volname string passed to FindByName() is currently always
limited 65 characters (including the terminating nul), to be on the safe
side, use the bounded strlcpy() function when coping the volname to the
temporary tname local variable to avoid the possibility of overwriting
the stack with an unbounded strcpy().

Change-Id: I12a8ca2901147c7dd88e63339d0d11c3c89bf94a
Reviewed-on: https://gerrit.openafs.org/14763
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorxgen: Generate default switch arm for void 98/14798/2
Andrew Deason [Wed, 10 Feb 2021 22:42:16 +0000]
rxgen: Generate default switch arm for void

When defining an xdr union with a 'default' arm, rxgen generates xdr
routines like this:

    bool_t
    xdr_myunion(...)
    {
        switch (objp->op) {
        case FOO:
            xdr_foo(...);
            break;

        default:
            xdr_default(...);
            break;
        }
    }

However, if the default arm of the union is just 'void;', we just
don't generate a 'default:' arm in the switch statment in the
generated routines. If there are enum values that are not explicitly
specified, and are handled by the default arm, this generates a
compiler warning (which breaks the build for --enable-checking):

    foo_int.xdr.c:80:2 error: enumeration value 'BAR' not handled in switch [-Werror=switch]
    switch (objp->op) {

To avoid this, change rxgen to always generate a 'default' arm in the
generated switch if there's one specified in the RPC-L. For a void
default, just generate an empty default arm, which avoids the compiler
warning.

Change-Id: I6ac457a4669439ef896b9cad6eb7de2f03068b69
Reviewed-on: https://gerrit.openafs.org/14798
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoRemove reference to afsinstall from src/README.md 05/14805/3
Cheyenne Wills [Thu, 16 Sep 2021 15:14:51 +0000]
Remove reference to afsinstall from src/README.md

Commit "deorbit afsinstall" (ed15b0d5b3) removed afsinstall from the
source tree, but not did remove where it was referenced in
src/README.md.

Remove the reference to 'afsinstall' from the 'Not Maintained' section
in src/README.md.

Change-Id: Ie5226bf97003c21044759bd5dc2b8efe5d9138c2
Reviewed-on: https://gerrit.openafs.org/14805
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agofs: Trim trailing lsmount and flushmount path slashes 79/14779/2
Michael Meffie [Wed, 1 Sep 2021 16:38:14 +0000]
fs: Trim trailing lsmount and flushmount path slashes

Remove trailing slashes from paths given to `fs lsmount` and `fs
flushmount`.  This makes for a more pleasant user experience when shell
tab completion is used to specify the paths.

Thanks to Stephan Wiesand for pointing out this issue.

Change-Id: I756c4d7d9b3fe5cd41e02165caf1d6866a0210e6
Reviewed-on: https://gerrit.openafs.org/14779
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoLinux 5.15: Convert osi_Msg macro to a function 91/14791/7
Cheyenne Wills [Tue, 14 Sep 2021 12:36:49 +0000]
Linux 5.15: Convert osi_Msg macro to a function

With Linux 5.15-prerc1 printk is defined as a macro instead of a
function ("printk: Userspace format indexing support" 33701557)

This change is causing a build failure:

 .../src/rx/rx_kernel.h:62:18: error: ‘printk’ undeclared (first use in
   this function); did you mean ‘_printk’?
   62 | # define osi_Msg printk)(
      |                  ^~~~~~

The definition and use of the osi_Msg and osi_VMsg macros are
unconventional and the C preprocessor is not handling the macro
expansion when printk is itself a macro.

   #define osi_Msg printk)(
   ...
   (osi_Msg "%s", x);

Change osi_Msg to a function, and simply replace osi_VMsg with vprintf
since osi_VMsg is only used at one location within user space code.

osi_Msg is implemented in 2 locations, in rx_kcommon for kernel space
and in rx_user for userspace.

Note: The unconventional definitions of osi_Msg/osi_VMsg was historical
and due to older compilers not supporting variadic macros.  All of
the currently support platforms should now support variadic functions.

Change-Id: I9f015e4929f2c5120e200d2b0378871e8d1375b3
Reviewed-on: https://gerrit.openafs.org/14791
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoFBSD: Disable background stores 85/14185/6
Andrew Deason [Sun, 3 May 2020 15:26:27 +0000]
FBSD: Disable background stores

Currently, when closing a vcache (via afs_close), we write any dirty
data to the net, and we do so via a background daemon if one is
available (for the rarely-used 'fs storebehind' functionality).

However, on FBSD, this breaks the locking rules, since flushing dirty
pages for a vnode requires the vnode to be locked. In the situation
where we are writing via a background daemon, the afs_close() thread
is what holds the vnode lock, but the background thread is the one
that's actually flushing the dirty pages. So the vnode is effectively
locked in this situation, but to the FreeBSD kernel it looks like we
are flushing pages without the vnode lock, and so it complains:

    kernel: KDB: stack backtrace:
    kernel: #0 0xffffffff80bf6557 at kdb_backtrace+0x67
    kernel: #1 0xffffffff80c7a337 at assert_vop_locked+0x77
    kernel: #2 0xffffffff811fc0bb at VOP_PUTPAGES_APV+0x7b
    kernel: #3 0xffffffff80f016bd at vnode_pager_putpages+0x7d
    kernel: #4 0xffffffff80ef424f at vm_pageout_flush+0xff
    kernel: #5 0xffffffff80ee9b39 at vm_object_page_collect_flush+0x239
    kernel: #6 0xffffffff80ee9819 at vm_object_page_clean+0x179
    kernel: #7 0xffffffff828d7181 at osi_VM_StoreAllSegments+0x111
    kernel: #8 0xffffffff82850a3d at afs_StoreAllSegments+0x9d
    kernel: #9 0xffffffff8287b1ce at afs_StoreOnLastReference+0x17e
    kernel: #10 0xffffffff8282dc70 at BStore+0xd0
    kernel: #11 0xffffffff8282d6ec at afs_BackgroundDaemon+0x2cc
    kernel: #12 0xffffffff828c2f2f at afs_syscall_call+0x35f
    kernel: #13 0xffffffff82855963 at afs3_syscall+0x83
    kernel: #14 0xffffffff81074581 at amd64_syscall+0x291
    kernel: #15 0xffffffff8104cde0 at fast_syscall_common+0x101
    kernel: vnode 0xfffff8006974fc58: tag afs, type VREG
    kernel:     usecount 2, writecount 0, refcount 3
    kernel:     flags (VI_ACTIVE)
    kernel:     v_object 0xfffff80023917900 ref 0 pages 171 cleanbuf 0 dirtybuf 0
    kernel:     lock type afs: EXCL by thread 0xfffff800852775e0 (pid 31828, ld.lld, tid 100787)
    kernel: #0 0xffffffff80b81fc2 at lockmgr_lock_fast_path+0x1e2
    kernel: #1 0xffffffff811fa9f6 at VOP_LOCK1_APV+0x96
    kernel: #2 0xffffffff80c8c705 at _vn_lock+0x65
    kernel: #3 0xffffffff80c8c8a3 at vn_close1+0x73
    kernel: #4 0xffffffff80c8b76c at vn_closefile+0x4c
    kernel: #5 0xffffffff80b571ba at _fdrop+0x1a
    kernel: #6 0xffffffff80b5a3cc at closef+0x1ec
    kernel: #7 0xffffffff80b577be at closefp+0x9e
    kernel: #8 0xffffffff81074581 at amd64_syscall+0x291
    kernel: #9 0xffffffff8104cde0 at fast_syscall_common+0x101
    kernel: vc 0xfffffe002b8d4d30 vp 0xfffff8006974fc58 tag afs, fid: 1.536870912.13317022.33596982, opens 1, writers 1
    kernel:   states statd dirty
    kernel: VOP_PUTPAGES: 0xfffff8006974fc58 is not locked but should be

To avoid this, force afs_close() to write dirty data in the same
thread, instead of passing it off to a background daemon.

Change-Id: Id952c7928c301fcc35d226e117dc19010b42776a
Reviewed-on: https://gerrit.openafs.org/14185
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agopts: Fix stringop-overflow warnings 69/14769/4
Michael Meffie [Mon, 23 Aug 2021 23:43:45 +0000]
pts: Fix stringop-overflow warnings

The ptutil functions are defined to accept bounded character arrays for
user and group names. As of GCC 11, callers which provide the names as
string literals now trigger the stringop-overflow warning, since the
regions provided by the string literals are smaller than the bounded
areas.

    error: ‘pr_ChangeEntry’ accessing 64 bytes in a region of size 1
           [-Werror=stringop-overflow=]
    note: referencing argument 4 of type ‘char *’

    error: ‘pr_IsAMemberOf’ accessing 64 bytes in a region of size 22
           [-Werror=stringop-overflow=]
    note: referencing argument 2 of type ‘char *’

    error: ‘pr_CreateUser’ accessing 64 bytes in a region of size 16
           [-Werror=stringop-overflow=]
    note: referencing argument 1 of type ‘char *’

    error: ‘pr_Delete’ accessing 64 bytes in a region of size 16
           [-Werror=stringop-overflow=]
    note: referencing argument 1 of type ‘char *’

Update the callers in pts and testpt which pass literal strings. Instead
of passing char pointers to literal strings, assign the strings to
prname buffers and pass the prname buffers to the pr utility functions.

Change-Id: I7d8c67aa28d21bb6889ef92a2193a77b54c83cb1
Reviewed-on: https://gerrit.openafs.org/14769
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoptserver: Fix CreateEntry() stringop-overflow warnings 89/14789/4
Michael Meffie [Fri, 3 Sep 2021 11:05:36 +0000]
ptserver: Fix CreateEntry() stringop-overflow warnings

The CreateEntry() prototype has been fixed to match the function
definition, so callers are expected to provide bounded arrays for the
user or group name. Fix the InitialGroup() macro which is used to set
the built-in names using string literal to avoid stringop-overflow
warnings.

    error: ‘CreateEntry’ accessing 64 bytes in a region of size 22 [-Werror=stringop-overflow=]
            code = CreateEntry(tt, (name), &temp, /*idflag*/1, flag, SYSADMINID, SYSADMINID); \

    note: in expansion of macro ‘InitialGroup’
           InitialGroup(SYSADMINID, "system:administrators");
    note: referencing argument 2 of type ‘char *’
    note: in a call to function ‘CreateEntry’
            CreateEntry(struct ubik_trans *at, char aname[PR_MAXNAMELEN], ...

    (Repeated for "system:backup", "system:anyuser", "system:authuser",
    "system:ptsviewers", and "anonymous".)

Change-Id: I7a37d4c8e191ffff52c2fdc1ed3783f4c3592b11
Reviewed-on: https://gerrit.openafs.org/14789
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: Avoid touching CBRs after free 65/14165/6
Andrew Deason [Mon, 27 Apr 2020 18:28:33 +0000]
afs: Avoid touching CBRs after free

Currently, we free our CBR structures in shutdown_vcache, but later on
in shutdown_server, we call afs_FreeCBR on each one that's attached to
a struct server. afs_FreeCBR doesn't actually free the memory; it just
modifies some pointers to put the CBR on the free list. Since we do
this after the underlying memory has been freed, it can cause a panic
during shutdown since the structures are no longer valid.

To avoid this, make the afs_FreeCBR calls inside shutdown_vcache,
right before the memory is freed.

Change-Id: I142126d6aa811762b6c234d05abdac3764dad887
Reviewed-on: https://gerrit.openafs.org/14165
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoFBSD: Use user creds for afs_vop_putpages() 64/14164/6
Andrew Deason [Sun, 26 Apr 2020 05:25:10 +0000]
FBSD: Use user creds for afs_vop_putpages()

Currently, the FBSD afs_vop_putpages uses the credentials of the
current process for writing data back to the fileserver. Usually this
works, but sometimes we're being called from syncer(4), which runs as
root instead of as the user accessing the relevant file.

This means that instead of using the tokens from the user that wrote
to the relevant file, we use whatever tokens belong to uid 0. This
usually causes an EACCES error when trying to write the data back to
the fileserver, causing us to store EACCES (13) in avc->vc_error, and
possibly causing a message in the kernel log like so:

    afs: failed to store file (0/13)

Since we set vc_error during these errors, this can also cause access
to the file to fail for the normal user process until vc_error is
cleared (such as when the file is closed).

To avoid this, store the credentials of the current user that
successfully opens the file for writing (in avc->cred), and use those
creds for writing back data to the fileserver. This is the same
approach that LINUX uses as of commit 70c8deab (Use user credentials
for Linux writepage()), and the NFS client code in FreeBSD itself (see
the usage of n_writecred in struct nfsnode as of 12.1-RELEASE).

Change-Id: I592d709b68d746bbdb326dfd7d012d6de829b905
Reviewed-on: https://gerrit.openafs.org/14164
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoptserver: Fix CreateEntry() mismatched array parameter warning 68/14768/3
Michael Meffie [Tue, 24 Aug 2021 20:40:22 +0000]
ptserver: Fix CreateEntry() mismatched array parameter warning

The CreateEntry() prototype does not match the function definition. The
aname parameter is declared as an unbounded array in the prototype but
is defined as a bounded array. As of GCC 12, a warning is issued for the
mismatch.

    error: argument 2 of type ‘char[64]’ with mismatched bound
           [-Werror=array-parameter=]
           CreateEntry(struct ubik_trans *at, char aname[PR_MAXNAMELEN], ...

    note: previously declared as ‘char[]’
          extern afs_int32 CreateEntry(struct ubik_trans *at, char aname[], ...

Fix the prototype to declare the 'aname' parameter as a bounded array as
expected for this function.

Change-Id: I6d4dadcdd3f80c2b6f1b17670bbbc1e9e6076559
Reviewed-on: https://gerrit.openafs.org/14768
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoubik: Fix ubeacon_updateUbikNetworkAddress() mismatched array parameter warning 67/14767/3
Michael Meffie [Mon, 23 Aug 2021 18:23:01 +0000]
ubik: Fix ubeacon_updateUbikNetworkAddress() mismatched array parameter warning

The ubeacon_updateUbikNetworkAddress() prototype does not match the
function definition. The ubik_host parameter is declared as an unbounded
array in the prototype but is defined as a bounded array. As of GCC 12,
a warning is issued for the mismatch:

    error: argument 1 of type ‘afs_uint32[256]’ {aka ‘unsigned int[256]’}
           with mismatched bound [-Werror=array-parameter=]
           ubeacon_updateUbikNetworkAddress(
             afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR])

    note: previously declared as ‘afs_uint32[]’ {aka ‘unsigned int[]’}
          extern int ubeacon_updateUbikNetworkAddress(afs_uint32 ubik_host[]);

Restore the ubik_host array length in the function prototype, which was
dropped in commit 9020e6e2f0357b1082705dcaa6626573433969ec (ubik: Defer
updateUbikNetworkAddress until after RX startup).

Change-Id: I8189effc5b68ef8c1b45b4107f5e22e44ecf59fd
Reviewed-on: https://gerrit.openafs.org/14767
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agolibadmin: Fix isAlias may be uninitialized warning 72/14772/6
Michael Meffie [Mon, 23 Aug 2021 19:42:52 +0000]
libadmin: Fix isAlias may be uninitialized warning

The cfgutil_HostNameIsAlias() function has an output parameter called
isAlias, which is used when cfgutil_HostIsAlias() returns non-zero.
However, it possible for isAlias to not be set before returning. GCC 12
issues a warning about the possible use of the uninitialized isAlias
variable:

    cfginternal.c:366:32: error: ‘isAlias’ may be used uninitialized
       [-Werror=maybe-uninitialized]

Initialize the cfgutil_HostNameIsAlias() isAlias output flag to false.
Also, fix the misleading code indentation around the
cfgutil_HostNameIsAlias() call.

Change-Id: I68e66ae5f9019a613187321bb792d0505959ed30
Reviewed-on: https://gerrit.openafs.org/14772
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agovol: Remove unused ihandle macros 61/14761/2
Andrew Deason [Wed, 18 Aug 2021 23:29:09 +0000]
vol: Remove unused ihandle macros

All of these macros are not used anywhere in the tree; get rid of
them. Mostly this is just removing cruft, but removing
FDH_READ/FDH_WRITE/FDH_SEEK also helps make sure we don't accidentally
reintroduce code paths that use non-positional i/o.

No functional change should be incurred by this commit.

Change-Id: I9f6e885845e814cdb22d7c963e4ee6826cad8cea
Reviewed-on: https://gerrit.openafs.org/14761
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoFBSD: Skip page flush in afs_DoPartialWrite 63/14163/6
Andrew Deason [Thu, 2 Jan 2020 02:11:35 +0000]
FBSD: Skip page flush in afs_DoPartialWrite

Currently, the FBSD afs_vop_putpages() will call afs_write(), which
can then go through afs_DoPartialWrite -> afs_StoreAllSegments ->
osi_VM_StoreAllSegments -> vm_object_page_clean, which will then try
to go through afs_vop_putpages() again.

In this call stack, we're only calling afs_StoreAllSegments to reduce
our dirty cache chunks (afs_StoreAllSegments does nothing if we don't
have that many dirty cache chunks); we don't need to reduce dirty
pages, so calling osi_VM_StoreAllSegments is not needed.

To avoid calling osi_VM_StoreAllSegments in this situation, add a new
flag AFS_NOVMSYNC, which skips the osi_VM_StoreAllSegments call and
just flushes the dirty cache chunks. Use this flag in
afs_DoPartialWrite on FBSD, and slightly refactor the ifdefs to reduce
some code duplication.

Change-Id: Id6bf9a7f4ac6d5f09b0249ca6ed11674d556e909
Reviewed-on: https://gerrit.openafs.org/14163
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoclang-13: remove unused variables flagged by clang 75/14775/4
Cheyenne Wills [Fri, 27 Aug 2021 14:20:42 +0000]
clang-13: remove unused variables flagged by clang

Clang-13 changed the default for the unused-but-set-variable resulting
in build warnings/errors with the following type of messages

vsprocs.c:3493:25: error: variable 'tentries' set but not used
    [-Werror,-Wunused-but-set-variable]
       afs_int32 nentries, tentries = 0;

The locations where these local variables are being flagged show that
while the variables are being updated, they are actually never used for
anything (e.g. used as part of an assignment to another variable, passed
as a parameter, used for as returned value, etc.)

Remove the variables being flagged by the clang-13 compiler.

Removal of these variables will not alter the overall functionality of
the code.

Change-Id: I521ea1323837e0d293e6f45eb8c15d5e05765f19
Reviewed-on: https://gerrit.openafs.org/14775
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agobozo: Log a warning if the bosserver is not started in restricted mode 62/14762/4
Michael Meffie [Thu, 19 Aug 2021 15:47:04 +0000]
bozo: Log a warning if the bosserver is not started in restricted mode

Log a warning to the BosLog when the bosserver is not started in
restricted mode to encourage admins to enable restricted mode.

Also, log a notice when restricted mode is enabled to reassure admins
restricted mode is enabled on start up.

Change-Id: I2cbe0b95f44476d21215204f5ef186b07bba9b69
Reviewed-on: https://gerrit.openafs.org/14762
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agobozo: Fix problems found by static analysis 76/14676/7
Cheyenne Wills [Tue, 31 Aug 2021 14:48:33 +0000]
bozo: Fix problems found by static analysis

Several static analysis tools have identified various problems:
 - files left open from early exits/returns       (infer)
 - missing checks to ensure *alloc was successful (infer)
 - possible memory leaks                          (scan-build, cppcheck)

To resolve the above problems:
 - close files before exiting/returning
 - add checks to ensure *alloc was successful before using the memory
 - fix possible memory leaks by freeing memory

This commit is a reorganization of commits developed by Pat Riehecky,
who ran the static analysis tools and developed the fixes.

Change-Id: Iabebf46d2d1d8bb3bd2378cf2d1e7e4b94706bfd
Reviewed-on: https://gerrit.openafs.org/14676
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorxdebug: Remove rxdumptrace.c 48/14748/2
Andrew Deason [Sun, 8 Aug 2021 20:13:14 +0000]
rxdebug: Remove rxdumptrace.c

Ever since it was introduced in commit 8bc58a3d
(macos-10-6-support-20090216), rxdumptrace.c appears to have been
unused. While we do build a binary called rxdumptrace, we build it
from src/rx/rx_trace.c, not from rxdumptrace.c (which appears to be a
copy of the relevant portions of rx_trace.c).

Also remove rxdumptrace from src/rx/.gitignore, since the binary is
built in src/rxdebug/, not in src/rx/. While we're here, remove the
other entries in src/rx/.gitignore (rxperf and rxdebug), since those
are also built in different directories.

Change-Id: Ide816979168dcf70358f39db035ce16ef6c1dd17
Reviewed-on: https://gerrit.openafs.org/14748
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Remove check/test/tests subdir targets 36/14636/3
Andrew Deason [Mon, 7 Jun 2021 21:44:38 +0000]
tests: Remove check/test/tests subdir targets

Since commit a62de618 (Build util tests properly with make check),
running 'make check' in tests/ also runs 'make check' in each of the
tests subdirectories, which builds the tests in that dir. (And the
same goes for 'make test' and 'make tests'.)

This does ensure that the tests are built before we run them, but it's
a bit strange to build the tests under 'make check', a target that
usually runs tests.

We do this in the top-level tests dir to make sure that the tests are
built, but this purpose is served by the existing 'make all' target.
So to reduce some duplication of logic, and reduce the number of
targets the subdirs need to implement, just have 'make check' depend
on 'make all', so we know the tests are built when we go to run them.

Change-Id: I2fcbe88daeeae94cd7ef7a4a8326c4b56fadee5a
Reviewed-on: https://gerrit.openafs.org/14636
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: refactor PNewStatMount and PFlushMount 41/14541/8
Marcio Barbosa [Tue, 17 Aug 2021 19:52:11 +0000]
afs: refactor PNewStatMount and PFlushMount

Both functions use the same logic to find a name in a given directory.
To avoid repetition, move this logic to a separate function called
afs_LookupName().

No functional change is incurred by this commit.

Change-Id: Ic5da09091e7050dd5f91adc7a413328edfb8292d
Reviewed-on: https://gerrit.openafs.org/14541
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Generalize temp dir management 32/14632/4
Andrew Deason [Thu, 2 Jul 2020 02:18:04 +0000]
tests: Generalize temp dir management

Currently, afstest_BuildTestConfig calls afstest_mkdtemp (our thin
wrapper around mkdtemp) to create its temporary config dir. We may
want to make new tests, though, that create a temp dir for other
purposes. To make that easier, move a little more code into
afstest_mkdtemp, so the caller doesn't need to construct the template.

To allow callers to clean up such temporary dirs, change
afstest_UnlinkTestConfig into a more general function,
afstest_rmdtemp. Allow this new function to remove all files in a dir,
not just files one-level-deep. To avoid needing to write our own
traversal and removal logic, just run 'rm -rf' via a new function,
afstest_systemlp().

Move these temp dir-related functions from config.c into files.c,
since they are no longer specific to config dirs.

Change-Id: I16750a2f30e98c9ca2e14dfb7d3fc9bc5d456e8d
Reviewed-on: https://gerrit.openafs.org/14632
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Introduce is_command() 40/14040/12
Andrew Deason [Tue, 21 Jan 2020 21:40:12 +0000]
tests: Introduce is_command()

Add a new function (is_command), to help implementing tests that
involve running a command. This works like is_string(), except the
string value we compare against is the output of the provided command,
and we also check the exit code of the command.

Convert the existing execl() call in volser/vos-t to use this new
function.

Change-Id: I4a75b1a0333e608da6a6cd69838350116a2503a9
Reviewed-on: https://gerrit.openafs.org/14040
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Introduce afstest_*_path() 19/14319/9
Andrew Deason [Fri, 3 Jul 2020 00:16:40 +0000]
tests: Introduce afstest_*_path()

Currently, several of our tests contain logic to locate files (via
srcdir or objdir), based on the C_TAP_SOURCE/BUILD environment
variables. This logic is duplicated in several places, so consolidate
the code into a couple of new functions: afstest_src_path and
afstest_obj_path. Update all callers to use these new functions.

Change-Id: I67a5e5d7f8fd7a1edb55a45e52d877ac41f9a2ea
Reviewed-on: https://gerrit.openafs.org/14319
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Introduce afstest_asprintf 20/14620/4
Andrew Deason [Wed, 14 Apr 2021 21:09:37 +0000]
tests: Introduce afstest_asprintf

Add a thin wrapper around asprintf, called afstest_asprintf (and
afstest_vasprintf), which does its own error checking. This just helps
makes tests a little less cluttered when needing to construct strings.

Adapt all asprintf callers in 'tests' to use the wrapper.

Change-Id: I6c4ae5b72af827e2c4c66ecfc57f152855b1d401
Reviewed-on: https://gerrit.openafs.org/14620
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Introduce libafstest_common 18/14318/6
Andrew Deason [Thu, 2 Jul 2020 03:42:37 +0000]
tests: Introduce libafstest_common

Currently, a few tests use the code in tests/common/ by linking
individual object files in there in addition to the test code (e.g.
linking ../common/config.o along with superuser-t.o).

This convention makes it very obnoxious to move code around in
tests/common/, since any users need to update their link lines. It
also makes it difficult for code in tests/common/ to make use of
functions in other tests/common/ files.

To fix this, just build all of the objects in tests/common/ into a
convenience library, called libafstest_common, and link the relevant
tests against that. Link a few requisite libraries (roken, rfc3961) in
libafstest_common, so each individual test doesn't need to link
against them.

Also link the TAP library itself in libafstest_common, so tests don't
have to explicitly link against it separately. To do this, convert it
into a libtool library, libafstest_tap.la.

Change-Id: I9c031c164efee20201336edcbfaff429e1d231b7
Reviewed-on: https://gerrit.openafs.org/14318
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoviced: Fix minor log message mistakes 24/14724/3
Mark Vitale [Mon, 22 Jun 2020 01:44:17 +0000]
viced: Fix minor log message mistakes

Fix a few minor mistakes/typos that have crept up in viced over time:

- In PrintCallBackStats, struct FEs and struct CBs are 64 bytes, not
  16 bytes. Show the actual size of the structs.

- A log message in cb_stateDiskEntryToFE is missing the trailing
  newline.

- In cb_stateVerifyHCBList, a log message mentions the non-existent
  cb_stateVerifyFCBList (instead of cb_stateVerifyHCBList)

Change-Id: I1146acae84d11980b6005cede9bb8bb53c54c70f
Reviewed-on: https://gerrit.openafs.org/14724
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorx: compare RX_ACK_TYPE_ACK as a bit-field 65/14465/5
Jeffrey Altman [Fri, 2 Oct 2020 23:51:06 +0000]
rx: compare RX_ACK_TYPE_ACK as a bit-field

The rx_ackPacket.acks array (the SACK table) consists of up to 255
octets.  Each octet stores either the value zero (RX_ACK_TYPE_NACK)
or one (RX_ACK_TYPE_ACK).  Effectively only bit-zero of each octet
is used.

The rx_ackPacket.acks array cannot be enlarged but one possible
method of encoding the ACK/NACK state for packets when the
window size is greater than 255 is to use bits 1-7 of each
octet.

This change alters the test for ACK vs NACK to be a bit comparison
instead of a equality comparison.  This change permits RX to be
compatible with any future use of bits 1-7.

No peer that treats the SACK table as bytes can ever send more
than 255 packets regardless of the advertised receive window.
Therefore, existing peers will never receive a SACK table with
more than 255 packets worth of bits.

Change-Id: I4dfcdc9ea18e060eeb257832297f557b7109e93a
Reviewed-on: https://gerrit.openafs.org/14465
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoLINUX: defer afs_remunlink when current->fs==NULL 91/14691/6
Yadavendra Yadav [Wed, 7 Jul 2021 16:32:36 +0000]
LINUX: defer afs_remunlink when current->fs==NULL

afs_remunlink is called to delete a file on the fileserver after it
has been silly-renamed (due to being unlinked while the file is open).
Sometimes current->fs is NULL when this happens, typically when the
process is shutting down, after current->fs has been freed and file
handles are getting released. During afs_remunlink, we need to
interact with our cache files, and so we call dentry_open, which calls
security_file_open, which calls into the configured LSM for security
checks. Certain LSMs (e.g. Crowdstrike Falcon) will panic the kernel
in this situation if current->fs is NULL.

There's no way to skip the LSM hooks, or to flag to the LSM that we're
making an in-kernel VFS call, so the only way to avoid these panics is
to do our I/O in another thread. Fortunately, we already have a way to
defer afs_remunlink calls to a background daemon (CUnlinkedDel), since
we already do this in some cases (when someone else is holding
afs_xvcache or afs_xdcache).

So, to avoid the panic in the above scenario, defer calls to
afs_remunlink to a background daemon using CUnlinkedDel when
current->fs is NULL, and we're using a disk cache.

More details on this issue is discussed at following thread:
https://lists.openafs.org/pipermail/openafs-info/2021-March/043073.html

Change-Id: I1ee83d088a9b661d2974ce24b36bfd9f6ea4e7e9
Reviewed-on: https://gerrit.openafs.org/14691
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Jonathan Billings <jsbillings@jsbillings.org>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

2 years agoAIX: Fix undefined symbols 07/14707/3
Andrew Deason [Fri, 16 Jul 2021 00:59:47 +0000]
AIX: Fix undefined symbols

Various pieces of our code try to use symbols in our internal
libraries that are not exported in the respective .sym file. On AIX,
this causes the following build failures:

ld: 0711-317 ERROR: Undefined symbol: .ubik_CallRock
ld: 0711-317 ERROR: Undefined symbol: DISK_function_names
ld: 0711-317 ERROR: Undefined symbol: VOTE_function_names
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[4]: *** [Makefile:45: afscp] Error 8
make[4]: Leaving directory '/.../src/libadmin/test'

ld: 0711-317 ERROR: Undefined symbol: PR_function_names
ld: 0711-317 ERROR: Undefined symbol: KAA_function_names
ld: 0711-317 ERROR: Undefined symbol: KAT_function_names
ld: 0711-317 ERROR: Undefined symbol: KAM_function_names
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[4]: *** [Makefile:117: rxstat_get_peer] Error 8
make[4]: Leaving directory '/.../src/libadmin/samples'

ld: 0711-317 ERROR: Undefined symbol: .osi_audit_cmd_Options
ld: 0711-317 ERROR: Undefined symbol: .osi_audit_open
ld: 0711-317 ERROR: Undefined symbol: .afsconf_SuperIdentity
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:71: butc] Error 8
make[3]: Leaving directory '/.../src/tbutc'

ld: 0711-317 ERROR: Undefined symbol: .pr_Initialize2
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:111: pts] Error 8
make[3]: Leaving directory '/.../src/tptserver'

ld: 0711-317 ERROR: Undefined symbol: .AFSVolListPartitions
ld: 0711-317 ERROR: Undefined symbol: .AFSVolXListPartitions
ld: 0711-317 ERROR: Undefined symbol: .RXAFS_GetStatistics64
ld: 0711-317 ERROR: Undefined symbol: .AFSVolPartitionInfo64
ld: 0711-317 ERROR: Undefined symbol: .AFSVolPartitionInfo
ld: 0711-317 ERROR: Undefined symbol: .RXAFS_GetStatistics
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:65: fsprobe_test] Error 8
make[3]: Leaving directory '/.../src/fsprobe'

ld: 0711-317 ERROR: Undefined symbol: fsprobe_Results
ld: 0711-317 ERROR: Undefined symbol: gtxframe_exitValue
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:45: scout] Error 8
make[3]: Leaving directory '/.../src/scout'

ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_toString
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_freeString
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:50: check_sysid] Error 8
make[3]: Leaving directory '/.../src/viced'

ld: 0711-317 ERROR: Undefined symbol: .GetLogLevel
make[3]: *** [Makefile:130: fileserver] Error 8
make[3]: Leaving directory '/.../src/viced'

ld: 0711-317 ERROR: Undefined symbol: .GetLogDest
ld: 0711-317 ERROR: Undefined symbol: .GetLogFilename
ld: 0711-317 ERROR: Undefined symbol: .CloseLog
make[3]: *** [Makefile:166: salvageserver] Error 8
make[3]: Leaving directory '/.../src/tsalvaged'

ld: 0711-317 ERROR: Undefined symbol: .rxkad_StringToLevel
ld: 0711-317 ERROR: Undefined symbol: .FilepathNormalize
ld: 0711-317 ERROR: Undefined symbol: .ConstructLocalPath
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:32: upserver] Error 8
make[3]: Leaving directory '/.../src/update'

ld: 0711-317 ERROR: Undefined symbol: xstat_fs_Results
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:77: xstat_fs_test] Error 8
make[3]: Leaving directory '/.../src/xstat'

ld: 0711-317 ERROR: Undefined symbol: .afsconf_DeleteKeyBySubType
ld: 0711-317 ERROR: Undefined symbol: .afsconf_DeleteKeyByType
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:35: asetkey] Error 8
make[3]: Leaving directory '/.../src/aklog'

ld: 0711-317 ERROR: Undefined symbol: .afsconf_FindService
ld: 0711-317 ERROR: Undefined symbol: .afsconf_AddKey
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetLatestKeyByTypes
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[4]: *** [Makefile:19: authcon-t] Error 8
make[4]: Leaving directory '/.../tests/auth'

ld: 0711-317 ERROR: Undefined symbol: .afsconf_AddUser
ld: 0711-317 ERROR: Undefined symbol: .afsconf_IsSuperIdentity
ld: 0711-317 ERROR: Undefined symbol: .afsconf_AddIdentity
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetNthUser
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetNthIdentity
ld: 0711-317 ERROR: Undefined symbol: .afsconf_DeleteUser
ld: 0711-317 ERROR: Undefined symbol: .afsconf_DeleteIdentity
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[4]: *** [Makefile:25: superuser-t] Error 8
make[4]: Leaving directory '/.../tests/auth'

ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetKeys
ld: 0711-317 ERROR: Undefined symbol: .rx_opaque_new
ld: 0711-317 ERROR: Undefined symbol: .rx_opaque_free
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetKeyByTypes
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetKeysByType
ld: 0711-317 ERROR: Undefined symbol: .afsconf_PutTypedKeyList
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetLatestKeysByType
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[4]: *** [Makefile:31: keys-t] Error 8
make[4]: Leaving directory '/.../tests/auth'

ld: 0711-317 ERROR: Undefined symbol: ._afsconf_Touch
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[1]: *** [Makefile:34: realms-t] Error 8
make[1]: Leaving directory '/.../tests/auth'

ld: 0711-317 ERROR: Undefined symbol: .opr_cache_get
ld: 0711-317 ERROR: Undefined symbol: .opr_cache_put
ld: 0711-317 ERROR: Undefined symbol: .opr_cache_init
ld: 0711-317 ERROR: Undefined symbol: .opr_cache_free
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[1]: *** [Makefile:16: cache-t] Error 8
make[1]: Leaving directory '/.../tests/opr'

ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_isNil
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_equal
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_hash
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_fromString
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_create
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_unpack
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_pack
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[1]: *** [Makefile:37: uuid-t] Error 8
make[1]: Leaving directory '/.../tests/opr'

ld: 0711-317 ERROR: Undefined symbol: .rxevent_Init
ld: 0711-317 ERROR: Undefined symbol: .rxevent_Post
ld: 0711-317 ERROR: Undefined symbol: .rxevent_Cancel
ld: 0711-317 ERROR: Undefined symbol: .rxevent_RaiseEvents
ld: 0711-317 ERROR: Undefined symbol: .rxevent_Put
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[1]: *** [Makefile:18: event-t] Error 8
make[1]: Leaving directory '/.../tests/rx'

To fix these, export the relevant symbols from the library's .sym
file.

Change-Id: I969e7c99610d5c29c81f6d73c52dd5499a1152fd
Reviewed-on: https://gerrit.openafs.org/14707
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorxgen: rename list -> rxgen_list 02/14702/3
Andrew Deason [Thu, 15 Jul 2021 23:27:34 +0000]
rxgen: rename list -> rxgen_list

Our 'struct list' collides with a 'struct list' defined in
/usr/include/grp.h on AIX (at least on AIX 7.2). This is a very
generic structure name, so rename it to rxgen_list to avoid issues
like this.

Change-Id: Ic6d3a1fcde5e7f8a1ae57b974f711fb844f29f3f
Reviewed-on: https://gerrit.openafs.org/14702
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agovol: Introduce and use FDH_BLOCKSIZE 62/14662/4
Andrew Deason [Wed, 3 Jun 2020 20:53:48 +0000]
vol: Introduce and use FDH_BLOCKSIZE

A couple of places in src/volser currently have some logic to get the
size and blocksize of a file. The existing logic is nontrivial due to
platform-specific quirks, and ignores afs_fstat errors.

To fix these issue and consolidate the code into one place, introduce
a new function, FDH_BLOCKSIZE, which gets the file size and blksize.
Update the places in src/volser to use the new function.

Change-Id: I4daeec84c8fdb5756a8d6a7f477d0045a19a8fe9
Reviewed-on: https://gerrit.openafs.org/14662
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotsm41: Fix libs for AIX 7.2 03/14703/3
Andrew Deason [Fri, 16 Jul 2021 19:02:07 +0000]
tsm41: Fix libs for AIX 7.2

AIX 7.2 doesn't seem to have libcsys, netinet.exp, sockets.exp, or
statcmd.exp available. To allow for our IMPORTS and LDFLAGS to change
depending on the AIX version, introduce the autoconf vars TSM_IMPORTS
and TSM_LIBS, which do not contain the missing libs on AIX 7.2, so we
can build on AIX 7.2.

Change-Id: I95feb22f8e2b35948d2024d5c29b917d064f30f3
Reviewed-on: https://gerrit.openafs.org/14703
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoAIX: Add buildsystem support for AIX 7.2 01/14701/2
Andrew Deason [Thu, 15 Jul 2021 22:53:43 +0000]
AIX: Add buildsystem support for AIX 7.2

Change-Id: Iae2523c333e5180c029ca205cf3f0b83a6839dd5
Reviewed-on: https://gerrit.openafs.org/14701
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Avoid WTERMSIG($?) in rx/perf-t 06/14706/2
Andrew Deason [Mon, 19 Jul 2021 18:48:01 +0000]
tests: Avoid WTERMSIG($?) in rx/perf-t

Currently, tests/rx/perf-t calls functions like WIFSIGNALED and
WTERMSIG on $?. However, functions like WTERMSIG expect the native
exit status code (that is, ${^CHILD_ERROR_NATIVE}). The $? var (aka
$CHILD_ERROR), is a synthetic value calculated by perl that stores the
term sig in the lowest 7 bits, and the exit code in the second-lowest
8 bits.

For most modern platforms, these two values tend to be the same. But
on modern AIX (and some other weird platforms, like VMS and BeOS), the
exit status integer is encoded differently. On AIX specifically, the
term sig is in the third-lowest 8 bits, so a process exiting on signal
15 would result in an exit status (${^CHILD_ERROR_NATIVE}) of 0xf000f,
but $? would be just 0xf. Calling WTERMSIG on 0xf000f returns 0xf, but
calling WTERMSIG on 0xf returns 0x0.

All of this means that running rx/perf-t causes the final test to fail
with "Server died with signal 0" (even when the process was killed by
signal 15), which is rather confusing.

To fix this, call WTERMSIG et al with ${^CHILD_ERROR_NATIVE} instead
of $?. Create a local var so we don't need to spell out
${^CHILD_ERROR_NATIVE} so many times.

Change-Id: I3c27642fcaf17c320a94caf57d3665d4b6a4a76e
Reviewed-on: https://gerrit.openafs.org/14706
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoopr: Avoid sigwait on SIGWAITING 05/14705/2
Andrew Deason [Mon, 19 Jul 2021 04:05:38 +0000]
opr: Avoid sigwait on SIGWAITING

On AIX, calling sigwait() on a sigset containing SIGWAITING (or
SIGKILL or SIGSTOP), causes sigwait to return with an EINVAL error.
Currently, signalHandler() calls sigwait() with SIGWAITING, because
SIGWAITING is in the sigset returned by softsigSignalSet(). And so,
sigwait() returns EINVAL, and our opr_Verify in signalHandler() fails,
causing a crash.

To avoid this, remove SIGWAITING from the sigset in
softsigSignalSet(). This is AIX-specific, since the SIGWAITING signal
is AIX-specific.

Change-Id: I42539d859212605e6b1aaeb6a5eecb0ad034cea5
Reviewed-on: https://gerrit.openafs.org/14705
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Add missing va_end in cmd/command-t 04/14704/2
Andrew Deason [Mon, 19 Jul 2021 01:55:57 +0000]
tests: Add missing va_end in cmd/command-t

Every va_start call is supposed to be paired with a matching va_end
call, but 'checkList' is missing any call to va_end. This doesn't
currently seem to cause any visible problems, but add the matching
va_end to avoid potential future issues.

Change-Id: I569618823f39f4da5b1787cc49c5509d8ea37528
Reviewed-on: https://gerrit.openafs.org/14704
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoCleanup usage of LINUX_VERSION_CODE for older kernels 89/14389/14
Cheyenne Wills [Thu, 17 Dec 2020 02:48:46 +0000]
Cleanup usage of LINUX_VERSION_CODE for older kernels

2.6.18 is the minimum supported linux kernel level. There are
preprocessor checks for specific kernel versions that predate 2.6.18.

Refactor the use of the LINUX_VERSION_CODE that checks for kernel
versions older than 2.6.18.

In addition, there are a couple of locations where the kernel version
is checked with an additional test to see if module_param or
module_param_array are defined.  These checks are used to determine
whether to use the macros module_param/module_param_array or to use
the macro MODULE_PARM. The macros module_param and module_param_array
were present in Linux prior to 2.6.12.  The macro MODULE_PARM was marked
as deprecated prior to 2.6.12 and removed in Linux 2.6.17 (8d3b33f67fd
'[PATCH] Remove MODULE_PARM').

Remove the preprocessor checks for module_param/module_param_array and
remove the use of MODULE_PARM.

The updates should have no functional changes.

Change-Id: I1dc5dca1252abfc865917757989df235c75059a6
Reviewed-on: https://gerrit.openafs.org/14389
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoCleanup AFS_*LINUX_ENV usage 88/14388/14
Cheyenne Wills [Fri, 19 Feb 2021 01:38:30 +0000]
Cleanup AFS_*LINUX_ENV usage

Commit 6329a523f6305541871bc3d1694065e7b17abe77 changed all
occurrences of AFS_*LINUXnn_ENV to AFS_*LINUX_ENV, but did not perform
any refactoring of the use of these variables.

This commit completes the task by refactoring the preprocessor
conditionals that involved removing dead code or collapsing statements.

The updates should have no functional changes.

Change-Id: I10fbefb7c862de2ec35ab77cafa2391e6e59f388
Reviewed-on: https://gerrit.openafs.org/14388
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoChange AFS*_LINUXnn_ENV to AFS*_LINUX_ENV 87/14387/12
Cheyenne Wills [Thu, 17 Jun 2021 18:01:34 +0000]
Change AFS*_LINUXnn_ENV to AFS*_LINUX_ENV

The minimum Linux kernel that is now supported is linux-2.6.18.  The
Linux versioned preprocessor macros AFS_*LINUXnn_ENV are no longer
needed to distinguish the different levels of Linux and can be merged
into just a single set of macros.

Perform a global change of _LINUX\d+_ENV to _LINUX_ENV. e.g.
   AFS_LINUX24_ENV       -> AFS_LINUX_ENV
   AFS_USR_LINUX24_ENV   -> AFS_USR_LINUX_ENV
   AFS_AMD64_LINUX20_ENV -> AFS_AMD64_LINUX_ENV

Replace the multiple definitions for the versioned 'AFS*_LINUXnn_ENV'
with just single non-version definitions 'AFS*_LINUX_ENV'.

Apart from replacing the now-redundant #define directives and tidying up
a few comments at the close of a preprocessor block to match their
current form, this commit was done using a mechanical change of the
variable names and did not reduce preprocessor statements that could now
be combined or eliminated.  Nor does this commit remove dead code.  A
follow-up commit (Cleanup AFS_*LINUX_ENV usage) will handle these
changes.

The updates should have no functional changes.

Change-Id: I71e32ca9818d28f82b4f23679868d1b9a62c44bd
Reviewed-on: https://gerrit.openafs.org/14387
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agofs: Avoid unnecessary cell DNS lookups 40/13540/7
Andrew Deason [Thu, 4 Apr 2019 20:18:57 +0000]
fs: Avoid unnecessary cell DNS lookups

Currently, many routines in 'fs' cause afsconf_GetCellInfo to be
called for the given cell, which causes an AFSDB/SRV lookup for the
given cell if the cell has no dbservers specified in the local
CellServDB. Sites often define such CellServDB records to indicate
that the given cell exists, but the dbserver IPs should only be looked
up via DNS.

However, 'fs' is only calling afsconf_GetCellInfo in order to
canonicalize the cell name (we're allowed to give an abbreviated name
for a cell on the command line if the abbreviation is unambiguous, but
we want to give the full name to the kernel). We don't care about the
other cell info at all, so triggering a DNS lookup is completely
unnecessary.

If our DNS server is not responding, e.g. because we've lost network
access entirely, this causes the relevant 'fs' commands to fail,
possibly after a long delay. Some fs commands such as 'fs setcell' are
often run during client startup, and can still otherwise run fine
without network access, and so such failures are unnecessary.

To fix this, we introduce a new function, called afsconf_GetCellName,
which only returns the full name for a cell, and does not require a
DNS lookup for such "empty" cells in the local CellServDB. For all
code paths in 'fs' that just need the cell name (which is all of them
besides 'fs mkmount'), use this new function.

Change-Id: I45eb1bdc6ba3e3b4653be2306dcbf79c1015724c
Reviewed-on: https://gerrit.openafs.org/13540
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agolibadmin: Be sure to free the server list in ListCellsRPC 90/14690/2
Michael Meffie [Fri, 2 Jul 2021 00:14:12 +0000]
libadmin: Be sure to free the server list in ListCellsRPC

Commit 0d6b9defb36cb94f3d34b058f00055e9e99d85fc added a check to avoid
overrunning a buffer when the cell name returned by RXAFSCB_GetCellServDB
is too large for the libadmin buffer, but in that case missed freeing
the server list returned in the same rpc.

Move the xdr_free() of the server list under the cleanup label so the
server list returned by the RPC will always be freed.

Thanks to Mark Vitale for finding this bug.

Change-Id: I4c7228f8c8d48e267f6fbb01cb89fdf5232de97e
Reviewed-on: https://gerrit.openafs.org/14690
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoDARWIN: correct size of fstrace ICL_TYPE_LONG and ICL_TYPE_POINTER 58/14558/4
Mark Vitale [Wed, 10 Mar 2021 04:12:50 +0000]
DARWIN: correct size of fstrace ICL_TYPE_LONG and ICL_TYPE_POINTER

Commit 248da50aa56f19bdc8b2b322f5e17b3d2a363dce 'icl 64 bit platform
rationalization' introduced support for 64-bit ICL_TYPE_POINTER and
ICL_TYPE_LONG for fstrace running on DARWIN kernels.  However, it
neglected to make the matching change in the fstrace utility itself,
which reads and reports these trace entries.  The result is that all
fstrace records which contain 64-bit pointers or longs are misreported
as 32-bit values.  Furthermore, any subsequent values in the same
fstrace record are also misreported because the offsets are now
incorrect.

Move the definition of ICL_LONG from afs_icl.c to icl.h so fstrace.c may
share the ICL_LONG logic and value.

Modify fstrace to use logic similar to the recording logic in afs_icl.c
so that the correct size and offsets are maintained while decoding the
contents of each fstrace record.

We can use the build-time value of ICL_LONG (rather than the runtime
value of afs_sizeofLong) because the difference only matters for SGI62
32-bit kernels.  It is unknown whether the existing code works correctly
for SGI62 32-bit mode, but this commit should not affect that support
either way.

Change-Id: I240f76fed4618822b774451c5184b1160f17221d
Reviewed-on: https://gerrit.openafs.org/14558
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoopr: Allow softsig handlers for SIGFPE 80/14080/6
Andrew Deason [Fri, 21 Feb 2020 20:49:56 +0000]
opr: Allow softsig handlers for SIGFPE

SIGFPE is normally a synchronous signal, which would not be handled by
opr softsig. However, bosserver uses SIGFPE as an asynchronous signal
to modify the local restricted mode. So allow SIGFPE in softsig
handlers, so bosserver can use softsig.

Change-Id: I413edbed967babb3e60c6fa97f89b40b8d7b3ad7
Reviewed-on: https://gerrit.openafs.org/14080
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>

2 years agoopr: Assert opr_cv_timedwait return codes 79/14079/6
Andrew Deason [Fri, 21 Feb 2020 15:49:09 +0000]
opr: Assert opr_cv_timedwait return codes

Almost all of our opr locking primitives assert that they did not
receive an error from pthreads. opr_cv_timedwait is the exception to
this, since it needs to return two possible codes that aren't
internal failures: 0 and ETIMEDOUT. As a result, most callers assert
that our returned code is one of these two values.

To make opr_cv_timedwait act more like our other locking primitives,
removing the need to add opr_Assert()s everywhere, change
opr_cv_timedwait to check that the returned code is 0 or ETIMEDOUT,
and remove the relevant asserts from its callers.

Change-Id: Ie9a62f2edb23969d66e4ed821af37077bc6400c4
Reviewed-on: https://gerrit.openafs.org/14079
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>

2 years agovol: Use FDH_SIZE more consistently 57/14657/2
Andrew Deason [Sun, 31 May 2020 23:20:04 +0000]
vol: Use FDH_SIZE more consistently

Several callers use OS_SIZE(fdP->fd_fd) instead of just calling
FDH_SIZE(fdP). Right now these calls are equivalent, but change all of
these callers to use FDH_SIZE, to make it easier to possibly change
the behavior of FDH_SIZE in the future.

Change-Id: If846c160c71f11935de8c0e4634afa2c7f7ee53f
Reviewed-on: https://gerrit.openafs.org/14657
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agovol: Blank fake linkHandles 56/14656/2
Andrew Deason [Sat, 17 Feb 2018 22:57:12 +0000]
vol: Blank fake linkHandles

A couple of places in namei_ops.c use "fake" linkHandle FdHandle_t's.
Make sure these are initialized, so we don't accidentally use
uninitialized fields in the FdHandle_t.

Currently, the code never uses any fields that are not explicitly set
in this same code path, but this seems rather fragile, and future
commits may change the fields in an FdHandle_t.

Change-Id: I9372f03a4d3b68afd3ab24a27ae669cba92e0abe
Reviewed-on: https://gerrit.openafs.org/14656
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agofstrace: add dump -debug option 57/14557/3
Mark Vitale [Tue, 9 Mar 2021 22:20:22 +0000]
fstrace: add dump -debug option

As a debugging aid, add a -debug option to the dump subcommand to
display each trace record in raw hex format as well as the normal
decoded format.

Change-Id: I80dd675a07e048e25749a9afb584515effcbc08a
Reviewed-on: https://gerrit.openafs.org/14557
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: Free pioctlToken in extractPioctlToken 51/14651/4
Andrew Deason [Thu, 17 Jun 2021 22:15:13 +0000]
afs: Free pioctlToken in extractPioctlToken

Ever since it was introduced in commit 5ec5ad5 (New GetToken pioctl),
extractPioctlToken has incorrectly freed pioctlToken by passing
'&pioctlToken' to xdr_free (instead of 'pioctlToken').

This causes xdr_ktc_tokenUnion to interpret &pioctlToken (which is a
struct ktc_tokenUnion **) as a struct ktc_tokenUnion *. This doesn't
cause any corruption or panics, since ktc_tokenUnion doesn't contain
any freeable fields unless its at_type is 2 (AFSTOKEN_UNION_KAD). So
as long as the bogus 'at_type' from the misinterpreted pointer is not 2,
the xdr_free call will just not free anything (and return an error,
which we ignore).

If the bogus at_type is 2, this would probably cause some memory
corruption or other nastiness. For this to happen on 32-bit systems,
the value of the 'pioctlToken' pointer itself would need to be 0x2.
On 64-bit systems, the top or bottom 32-bits of the pointer would need
to be 0x2 (depending on endianness). Those situations seem impossible
or very unlikely on most systems, and have never been seen in the
wild.

FIXES 135238

Change-Id: Id14571d090570cfacfa920048f41c3b1e434f31c
Reviewed-on: https://gerrit.openafs.org/14651
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

2 years agocmd: version command should not call before or after procs 45/14645/3
Mark Vitale [Tue, 22 Jun 2021 03:29:09 +0000]
cmd: version command should not call before or after procs

Since the original IBM code import, the cmd_Dispatch processor has
avoided calling beforeProc and afterProc for the built-in 'help' and
'apropos' commands.  This is important, because these procs may rely on
application-defined common arguments (e.g., -cell <cell> or -noauth) for
proper operation.  However, application common arguments are not defined
for built-in commands 'help' and 'apropos'.

Unfortunately, when a new built-in 'version' command was added
(350c140d89198cb7 libcmd-support-version-switch-20060630), it was not
exempted from the before and after procs.

In order to avoid a segmentation fault in 'libadmin/test/afscp
version', modify cmd to also avoid calling beforeProc and afterProc for
the 'version' command.

Change-Id: Ic899397de808fd6c4a5f66a0f5add102340064e6
Reviewed-on: https://gerrit.openafs.org/14645
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agobos: Let xdr allocate rpc output strings 50/14650/5
Michael Meffie [Wed, 23 Jun 2021 00:02:18 +0000]
bos: Let xdr allocate rpc output strings

The bos client provides fixed sized buffers on the stack for RPC output
strings instead of letting xdr allocate output strings.  Unfortunately,
the fixed sized buffers do not account for the terminating nul char when
the output string is the maximum size defined for the bozo RPCs.

To avoid potential buffer overflows, and to allow for larger xdr string
sizes in the future, convert these to xdr allocated strings. Be sure to
always free the xdr allocated strings.

The following bozo RPCs have xdr output strings, and are addressed in
this commit:

BOZO_EnumerateInstance
BOZO_GetCellHost
BOZO_GetCellName
BOZO_GetInstanceInfo
BOZO_GetInstanceParm
BOZO_GetInstanceStrings
BOZO_GetStatus
BOZO_ListSUsers

Thanks to Cheyenne Wills for pointing out this issue.

Change-Id: I7fb48ff6766420a2d84723e1663ff24e86313ccf
Reviewed-on: https://gerrit.openafs.org/14650
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoihandle: Remove FDH_READV/WRITEV references 55/14655/2
Andrew Deason [Wed, 27 May 2020 23:06:24 +0000]
ihandle: Remove FDH_READV/WRITEV references

FDH_READV and FDH_WRITEV have been unused since commit
335ccb40 (ihandle positional read and write). Remove a couple of
lingering references to them.

Change-Id: I640d411782440958a823ef0e2aa810bddd8ceee2
Reviewed-on: https://gerrit.openafs.org/14655
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agonamei: Calculate offset before use in GetFreeTag 54/14654/2
Andrew Deason [Fri, 29 May 2020 19:22:34 +0000]
namei: Calculate offset before use in GetFreeTag

We pass 'offset' to FDH_LOCKFILE here, but 'offset' is calculated a
few lines below. The compiler doesn't catch this, since FDH_LOCKFILE
is a macro that ignores the second argument (except on WINNT).

Just move the calculation a few lines above, to ensure 'offset' is set
before it's actually used, to avoid issues if and when FDH_LOCKFILE is
changed to use the second argument.

Change-Id: If858005cb83370ca905f93f9d3d7eed2941ddf99
Reviewed-on: https://gerrit.openafs.org/14654
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoviced: remove dead code from h_Alloc_r 35/14335/2
Mark Vitale [Fri, 28 Aug 2020 19:16:01 +0000]
viced: remove dead code from h_Alloc_r

These two lines have been ifdef'd out since commit 8f2df21ffe59
pull-prototypes-to-head-20020821.  Remove them.

No functional change is incurred by this commit.

Change-Id: I5d1d97d285ad50777bc5a26a53d6e0357140941d
Reviewed-on: https://gerrit.openafs.org/14335
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agolibadmin: Let xdr allocate rpc output strings 26/14626/4
Michael Meffie [Fri, 21 May 2021 16:38:01 +0000]
libadmin: Let xdr allocate rpc output strings

In most functions, the libadmin library provides fixed sized buffers for
RPC output strings instead of letting xdr allocate the output string.
Unfortunately the fixed sized buffers do not account for the terminating
nul char when the output string is the maximum length possible for the
xdr output strings.

To avoid potential buffer overflows, and to allow for larger xdr string
sizes in the future, convert these to xdr allocated strings and use safe
string functions to copy the results to the application buffers. Fail
with an error if the application buffer is too small, instead of
overflowing the buffer or truncating results.

Thanks to Cheyenne Wills for pointing out this issue.

Change-Id: I963e1b790417863c036e897811c86a634d1d4e7f
Reviewed-on: https://gerrit.openafs.org/14626
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoutil: remove dead code KTimeCmp 34/14334/4
Mark Vitale [Fri, 28 Aug 2020 19:12:33 +0000]
util: remove dead code KTimeCmp

This routine has been dead code since the original IBM code import.  It
was ifdef'd out in commit 45376df63f7f util-warning-cleanup-20011005.

Remove the dead code from the tree.

No functional change is incurred by this commit.

Change-Id: I33689db8e016e1dd5abb88910af8da6208a75ce6
Reviewed-on: https://gerrit.openafs.org/14334
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agorxgen: remove dead code deverbatim 33/14333/2
Mark Vitale [Fri, 28 Aug 2020 19:09:17 +0000]
rxgen: remove dead code deverbatim

This routine has been dead code since the original IBM import.  It was
ifdef'd out in commit 8f2df21ffe59 pull-prototypes-to-head-20020821.

Remove it from the tree.

No functional change is incurred by this commit.

Change-Id: Ie81bd8ed1764026e872dcf07e0b12e3c8a31c64d
Reviewed-on: https://gerrit.openafs.org/14333
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorx: remove dead code xdrrx_getpos, xdrrx_setpos 32/14332/2
Mark Vitale [Fri, 28 Aug 2020 19:01:50 +0000]
rx: remove dead code xdrrx_getpos, xdrrx_setpos

These routines have been dead code since the original IBM code import.
They were ifdef'd out in commit 1d93f2da22eb
'rx-warnings-and-prototyping-20010623'

Remove them from the tree.

No functional change is incurred by this commit.

Change-Id: I958c07487e2453690535acd01b92c59fcecd1189
Reviewed-on: https://gerrit.openafs.org/14332
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agolibafsauthent: export pr_IsAMemberOf 77/14377/2
Benjamin Kaduk [Wed, 30 Sep 2020 04:47:55 +0000]
libafsauthent: export pr_IsAMemberOf

Reported by Alexander Chernyakhovsky <achernya@mit.edu>

Change-Id: I0e0282d89a62ab577ceba3d10aa2ee2819c3f882
Reviewed-on: https://gerrit.openafs.org/14377
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoklog.krb5: remove "save and reuse password" logic 43/14643/2
Marcio Barbosa [Sun, 20 Jun 2021 03:52:36 +0000]
klog.krb5: remove "save and reuse password" logic

In order to avoid repeated requests for the user's password, klog.krb5
caches and reuses it whenever necessary. However, with the introduction
of commit 3a9a5783cd1fd73902655f0876e2069b42688c94, klog.krb5 always
requests a TGT regardless of the state of writeTicketFile, eliminating
the need for possible extra requests for the user's password.

Moreover, krb5_get_init_creds_password() does not accept a custom
prompter on macOS (returns EINVAL). Consequently, if the -password
argument is omitted, klog.krb5 fails with the following error:

klog: Invalid argument Unable to authenticate in realm <REALM>

Given that the user won't be prompted for a password multiple times,
remove the "save and reuse password" logic and use krb5_prompter_posix()
as the prompter function (instead of klog_prompter).

Relevant issue identified by gangovind@in.ibm.com.

Change-Id: Ia994a18d1d166893f12ee78d3e6f25192ff327ee
Reviewed-on: https://gerrit.openafs.org/14643
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Tested-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Avoid verbose output for 'make check V=0' 19/14619/3
Andrew Deason [Mon, 28 Dec 2020 18:22:38 +0000]
tests: Avoid verbose output for 'make check V=0'

For "pretty" V=0 builds, change 'make check' to run 'runtests' in
non-verbose mode, so we just get a summary of test results, instead of
the raw test output. Without V=0, the default is unchanged, so we
still print out all test output by default.

Change-Id: I554f9d32ed5a9cd27e83fef6245af589d91e801f
Reviewed-on: https://gerrit.openafs.org/14619
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Introduce 'make check TESTS=test/name' 17/14317/5
Andrew Deason [Wed, 1 Jul 2020 19:21:35 +0000]
tests: Introduce 'make check TESTS=test/name'

Currently 'make check' always runs all tests. We can run individual
tests manually, but doing so is a bit cumbersome to do under the same
environment as 'make check', since doing so means running something
like this:

    $ MAKECHECK=1 $(abs_top_srcdir)/tests/libwrap @TOP_OBJDIR@/lib \
        ./runtests opr/fmt util/ktime

To make it easier to run single tests introduce a way of calling 'make
check' like this:

    $ make check TESTS='opr/fmt util/ktime'

Which will run the same commands as 'make check', but will run
runtests with only the specified tests, instead of running the default
list.

Some makefiles currently use a "TESTS" or "tests" variable to list
their test binaries; rename them all to "BINS" to avoid conflicting
with this new use for "TESTS" and to make our makefiles a little more
consistent.

Change-Id: I427f83be0d4571794644a97123bcd1f32427bd05
Reviewed-on: https://gerrit.openafs.org/14317
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoRemove NoAuth procedures from Admin Guide 38/14638/2
Benjamin Kaduk [Thu, 10 Jun 2021 15:27:58 +0000]
Remove NoAuth procedures from Admin Guide

Retain the factual description of what the file/flag does, but remove
the suggestion that it is useful in favor of a disclaimer that it is
not needed, and replace the emergency-recovery procedure with a short
description using -localauth.

Change-Id: I18b0dad9740f01515717d572a0374cd2f77fc02d
Reviewed-on: https://gerrit.openafs.org/14638
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoRemove recommendation to use NoAuth from NoAuth.5 42/12142/5
Benjamin Kaduk [Fri, 25 Dec 2015 01:46:29 +0000]
Remove recommendation to use NoAuth from NoAuth.5

Do not document that there are cases when this file should exist;
there are not.

Installation no longer needs this file, and key emergencies can
be handled using asetkey or, on 1.8.x, the kerberos tooling to modify
rxkad.keytab.

Change-Id: I0c3ba15f3ffca8660be2d8b092f10053258742e6
Reviewed-on: https://gerrit.openafs.org/12142
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoRemove rpctestlib 17/14617/3
Andrew Deason [Fri, 7 May 2021 20:02:06 +0000]
Remove rpctestlib

There is some code in tests/rpctestlib that appears to be for testing
fileserver RPCs and callback processing, added in commit 262a678d (An
RPC test dispatch library for vice). However, it has never been used,
it seems unlikely that it will be used anytime soon, and it's not
clear if it even works (it contains many hard-coded references to
interfaces and IP addresses).

Just remove the unused code, and some references to rpctestlib. It can
always be added back if needed (or more likely, reimplemented to be
more in line with our current test framework in tests/ ).

Change-Id: Ied3be7474581d8ee75ae000815bb7364d143fd31
Reviewed-on: https://gerrit.openafs.org/14617
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoRemove a few unused opr/util components 47/14547/5
Andrew Deason [Wed, 3 Mar 2021 18:24:27 +0000]
Remove a few unused opr/util components

A few pieces of opr and util have no callers, have never been used
since they were added, and are not expected to be used in the near
future. Remove the unused code; if we ever want to use any of this
again, it can be re-added when we actually need it.

Specifically, this removes:

- 'stoupper' in src/opr/casestrcpy.c, added in e117599f
  (fileserver-hates-pruclient-20060626)

- 'opr_ffsll' and 'opr_flsll' in src/opr/ffs.h, added in d4369917
  (opr: implement the BSD ffs() functions)

- src/util/thread_pool.c and related headers, added in 4ca57f3f
  (Provide an abstract thread pool object)

Change-Id: Id098cb86318ac9e2412937f4b63b5d99e35be568
Reviewed-on: https://gerrit.openafs.org/14547
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>