openafs.git
7 years agoAdd akeyconvert, for rxkad.keytab to KeyFileExt conversion 86/11786/12
Benjamin Kaduk [Mon, 2 Mar 2015 22:29:56 +0000]
Add akeyconvert, for rxkad.keytab to KeyFileExt conversion

A simple utility to help with the 1.6-->1.8 upgrade by
bulk-converting keys, with some sanity checking.

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

7 years agoroken: do not include the rk_rename() implementation on unix 91/12091/2
Michael Meffie [Thu, 5 Nov 2015 21:29:05 +0000]
roken: do not include the rk_rename() implementation on unix

libroken provides roken/rename.c for platforms where the native rename()
implementation does not replace the target if it already exists.  As designed,
rk_rename() should be used instead of rename() everywhere and rk_rename()
is #defined to be rename() on platforms where this fix is not necessary.

Do not include the rk_rename() implementation on platforms which do not need
the rk_rename since it is not used on those platforms.

Note: This fix also avoids a recursive rename(). As currently implemented, the
rk_rename() function is redefined to rename() within the roken/rename.c module
when RENAME_DOES_NOT_UNLINK is not defined. This can mask the standard library
rename() and leads to a recursive call to rename().

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

7 years agoexternalize log rotation 31/11731/15
Michael Meffie [Fri, 6 Feb 2015 16:33:48 +0000]
externalize log rotation

Do not create new server log files when servers are restarted by
default.  External log rotation tools may be used to rotate the logs by
renaming log files and then signaling server processes to reopen
log files.

Add the -transarc-logs option to each server to provide backward
compatibility with the traditional Transarc-style logging.  When
-transarc-logs is given, log files are renamed to an ".old" file
(overwriting the existing ".old" file) and the previous the log file is
truncated.

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

7 years agoutil: reopen server logs on SIGUSR1 for external log rotation 27/11727/14
Michael Meffie [Fri, 6 Feb 2015 15:56:43 +0000]
util: reopen server logs on SIGUSR1 for external log rotation

Claim the SIGUSR1 signal for reopening server log files.  A server
process will reopen the log file when the SIGUSR1 signal is received.
If the log file does not exist, the server process will create a new,
empty log file.

This allows external log rotation programs to rotate log files by
renaming an existing log file then sending a SIGUSR1 signal to the
corresponding server process.  Any messages written to the log after the
log file was renamed but before the SIGUSR1 signal is received will
continue to be written to the renamed log file.  The server process will
write messages to the new log file after handling the SIGUSR1 signal.

The SIGUSR1 signal is used to reopen the log file instead of the more
commonly used SIGHUP signal, since SIGHUP is already used for resetting
the logging level.

The retirement of Linux 2.4 support, in particular the desupport of
LinuxThreads, in commit ccf353ede6ef5cce7c562993d1bea0d20844bdb7 allows
for the use of SIGUSR1 in OpenAFS.

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

7 years agoutil: doxygenate server logging functions 21/12221/6
Michael Meffie [Sat, 12 Mar 2016 23:54:43 +0000]
util: doxygenate server logging functions

Provide doxygen style comment blocks for the server logging functions
and module variables.

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

7 years agoRemove server logging globals 68/12168/11
Michael Meffie [Wed, 6 Jan 2016 22:06:54 +0000]
Remove server logging globals

Remove the global variables used to setup server logging and replace
with an argument to OpenLog.

Keep the LogLevel variable as a global for use by the logging macros,
but provide an inline function for applications which check the log
level to dump more information when the log level is increased.

Provide consistency by adding syslog tags to processes that did not
previously set one (salvageserver, salvager, and volserver).

[kaduk@mit.edu: update commit message, use old-style log rotation for
kalog, minor commenting fixes]

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

7 years agoAdd comment about serverlog locking 23/12123/6
Benjamin Kaduk [Thu, 3 Dec 2015 04:56:57 +0000]
Add comment about serverlog locking

The lock protects global state such as the logging FD and the
syslog-related variables.

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

7 years agoReopen the correct filename when -logfile is given 23/11723/16
Michael Meffie [Thu, 5 Feb 2015 21:59:52 +0000]
Reopen the correct filename when -logfile is given

The name of the log file passed to ReOpenLog() may not match the name
given in the initial OpenLog() call. This can happen when the -logfile
option is given to the fileserver or volume server.

Since the name given to ReOpenLog() must match the original name, change
ReOpenLog() to use the name previously given to OpenLog() and update all
callers.

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

7 years agoutil: always reopen the log file 25/11725/16
Michael Meffie [Wed, 4 Feb 2015 17:19:32 +0000]
util: always reopen the log file

Reopen the log file even if the filename exists. This fixes the
situation where an external program moves or deletes the log
file, then creates a new file with the same log file name.

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

7 years agoutil: refactor OpenLog and ReOpenLog 21/11721/18
Michael Meffie [Thu, 5 Feb 2015 15:47:32 +0000]
util: refactor OpenLog and ReOpenLog

Non-functional changes and cleanups in preparation for fixes and
enhancements.

Move the duplicated code to redirect the stdio/stderr streams to a common
static function.  Add a helper function to check for named pipes.  Move the
code to rename files when opening logs to a separate static function.

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

7 years agoutil: Remove undocumented magic of mrafs-style logs 36/12136/5
Benjamin Kaduk [Mon, 21 Dec 2015 04:11:23 +0000]
util: Remove undocumented magic of mrafs-style logs

The MR-AFS-style logs would always include the thread number in
log entries with the timestamp; now that we are trying to rebrand
this feature as "timestampped logs", having this bonus feature
is unexpected.

Thread ids are still used at higher log levels, as enabled by SIGTSTP.

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

7 years agoutil: fix file descriptor leak in mrafs-style logging 22/11722/17
Michael Meffie [Thu, 5 Feb 2015 20:42:16 +0000]
util: fix file descriptor leak in mrafs-style logging

When MR-AFS style logging is in effect, the SIGHUP signal handler will rename
then create a new, empty server log file to support log rotation.

Unfortunately, the old log file descriptor is not closed, so each SIGHUP
signal will leak one file descriptor.

Be sure to close the current log file descriptor before opening the log again.
The OpenLog() routine will move the current log file to a new file, with a
timestamp string appended to the log file, then open the server log file with
truncate flag to start a new log file.

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

7 years agoutil: fix log file renaming of mrafs-style logs 20/12220/4
Michael Meffie [Sun, 13 Mar 2016 21:27:59 +0000]
util: fix log file renaming of mrafs-style logs

Do not make timestamped log files with an invalid number of seconds when
renaming old mrsafs-style log files, i.e., more than 59 seconds in the
seconds field.

Replace the goto used in the mrafs-style make file name retries with a
regular, bounded loop.

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

7 years agoutil: remove unused printLocks variable from mrafs-style logs 19/11719/11
Michael Meffie [Thu, 5 Feb 2015 01:53:52 +0000]
util: remove unused printLocks variable from mrafs-style logs

Remove the unused printLocks variable, which was added in commit,
86f1dc2117e6b6c8abb55ccbc8621743969b8996 "mrafs-server-log-handling-20010212"
but never used.

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

7 years agoutil: allocate log filename buffers 19/12219/4
Michael Meffie [Mon, 14 Mar 2016 20:09:56 +0000]
util: allocate log filename buffers

Allocate the ourName buffer to save the log filename during OpenLog(),
instead of trying to copy the log filename to a fixed size buffer.
Deallocate this buffer when the log is closed with CloseLog().  Save the
log file name even when MR-AFS style logging is not effect to allow
ReOpenLog() to use the saved filename in a later commit.

Dynamically allocate a buffer when formatting a file name for log
rotation instead of using a fixed size buffer on the stack.  Allocate
the buffer for both traditional Transarc-style log file renaming
(appending ".old" to the log filename) and the MR-AFS style logging
(appending a timestamp to the log filename).

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

7 years agoutil: open mrafs-style logs with O_APPEND too 18/12218/4
Michael Meffie [Sun, 13 Mar 2016 20:55:48 +0000]
util: open mrafs-style logs with O_APPEND too

Commit b71a041364d28d6a56905a770cd20d1497ee26ec added the O_APPEND flag when
opening the log file to allow sites to use logrotate's "copy and truncate"
feature.

Add the O_APPEND to MR-AFS style logs as well so MR-AFS style logs can also be
handled correctly with logrotate, we have consistent open flags, and can remove
a duplicate call to open the log file descriptor.

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

7 years agoutil: remove obsolete SETVBUF_REVERSED 18/11718/11
Michael Meffie [Sun, 1 Feb 2015 21:53:26 +0000]
util: remove obsolete SETVBUF_REVERSED

Commit 8af5762909714367c1cc764b3f491c06c2bcd5d0 "Clean up some
obsolete Autoconf code" removed the obsolete autoconf check
AC_FUNC_SETVBUF_REVERSED and one use of the results, but
overlooked another instance; remove it.

Change-Id: Id62a2a96b911c0d16d51d8cce0966ae3736bde87
Reviewed-on: https://gerrit.openafs.org/11718
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agoutil: always initialize the server log mutex 17/11717/10
Michael Meffie [Wed, 4 Feb 2015 02:07:34 +0000]
util: always initialize the server log mutex

Be sure to always initialize the server log mutex. Use pthread_once to
ensure the mutex is initialized only once.

Before this change the server log mutex was not properly initialized
with pthread_mutex_init when logging to the syslog.

Change-Id: Ief2ee6b373f7309bc05061f7413b6ff623b86e31
Reviewed-on: https://gerrit.openafs.org/11717
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agoutil: fix server log fd validity checks 97/11797/13
Michael Meffie [Thu, 12 Mar 2015 22:12:06 +0000]
util: fix server log fd validity checks

Do not assume the server log file descriptor cannot be zero.

Thanks to Chas Williams for spotting this bug.

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

7 years agoutil: remove util/softsig 98/11998/8
Michael Meffie [Wed, 2 Sep 2015 21:22:16 +0000]
util: remove util/softsig

Remove the old util/softsig implementation, which has been replaced by
opr/softsig.

Change-Id: Ie32f04129dd0b09a8baf9f6739abf53fbf1b98eb
Reviewed-on: https://gerrit.openafs.org/11998
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agoptserver: convert the ptserver to opr softsig 97/11997/8
Michael Meffie [Wed, 2 Sep 2015 20:33:46 +0000]
ptserver: convert the ptserver to opr softsig

Convert the ptserver from regular signal handling to the opr soft
signal handling when built with pthreads. This makes it safe to call
pthread functions within signal handlers.

Change-Id: I43d345517c75e275d6896154a979a908181a1f39
Reviewed-on: https://gerrit.openafs.org/11997
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agovlserver: convert the vlserver to opr softsig 96/11996/8
Michael Meffie [Wed, 2 Sep 2015 20:32:54 +0000]
vlserver: convert the vlserver to opr softsig

Convert the vlserver from regular signal handling to the opr soft
signal handling when built with pthreads. This makes it safe to call
pthread functions within signal handlers.

Change-Id: Ic9bd841c4796bd64b603505541da7e767afda83e
Reviewed-on: https://gerrit.openafs.org/11996
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agovolser: convert the volume server to opr softsig 95/11995/8
Michael Meffie [Wed, 2 Sep 2015 20:28:43 +0000]
volser: convert the volume server to opr softsig

Convert the volume server from regular signal handling to the opr soft
signal handling when built with pthreads. This makes it safe to call
pthread functions within signal handlers.

Change-Id: I25b9a9184c526f4ce9b6e2abb25ae9135cc97ec6
Reviewed-on: https://gerrit.openafs.org/11995
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agoviced: convert the fileserver to opr softsig 94/11994/8
Michael Meffie [Thu, 31 Mar 2016 20:40:40 +0000]
viced: convert the fileserver to opr softsig

Convert the fileserver from the obsolete softsig routines to the modern opr
softsig routines for pthreaded programs.

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

7 years agoviced: remove old signal handler wrappers 21/11921/10
Michael Meffie [Mon, 29 Jun 2015 15:03:16 +0000]
viced: remove old signal handler wrappers

Remove remnants of old lwp thread signal handler wrapper functions from
the fileserver. The lwp softsig handlers required a function which was
passed a void pointer argument and returned a void pointer.  Tidy the
code by removing the unneeded wrappers and use the signal handler
functions directly.

Change-Id: I3d52efe659b03ee9a9484ec7a9d74404f1970278
Reviewed-on: https://gerrit.openafs.org/11921
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

7 years agoutil: softsig version of function to setup logging signal handlers 38/12238/2
Michael Meffie [Thu, 31 Mar 2016 20:39:48 +0000]
util: softsig version of function to setup logging signal handlers

Provide a new routine to setup the server log signals which registers
soft signal handlers for the common log management signals (SIGTSTP and
SIGHUP). Keep the old SetupLogSignals() routine around while lwp still
exists.

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

7 years agoWindows: opr_softsig.h 37/12237/2
Michael Meffie [Thu, 31 Mar 2016 20:38:29 +0000]
Windows: opr_softsig.h

Make the opr softsig header file available in the windows builds
so it can be included unconditionally in the code base.

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

7 years agoprocmgmt: wrappers for softsig handlers 36/12236/2
Michael Meffie [Thu, 31 Mar 2016 20:37:42 +0000]
procmgmt: wrappers for softsig handlers

Provide procmgmt wrappers for Windows environments which match the opr_softsig
functions. This allows builds of the windows servers continue to use the
existing process management signal handling functions, without introducing
additional conditional compilation in the server code.

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

7 years agosalvager: convert salvager and salvagerserver to libutil logging 03/12003/11
Michael Meffie [Thu, 10 Sep 2015 01:26:23 +0000]
salvager: convert salvager and salvagerserver to libutil logging

Use the libutil logging facility in the salvager and DAFS salvageserver
in order to have consistent logging features and time stamp formats with
the other OpenAFS servers.

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

8 years agoFind Tivoli TSM headers in 64 bit location 58/12258/2
Jonathon Weiss [Fri, 15 Apr 2016 23:29:58 +0000]
Find Tivoli TSM headers in 64 bit location

When building with --enable-tivoli-tsm locate the Tivoli TSM headers
if they are installed in the path used by the 64 bit Tivoli TSM
installation.

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

8 years agoafs: shake harder in shake-loose-vcaches 54/11654/12
Michael Meffie [Thu, 27 Aug 2015 17:06:05 +0000]
afs: shake harder in shake-loose-vcaches

Linux based cache managers will allocate vcaches on demand and
deallocate batches of vcaches in the background. This feature is called
dynamic vcaches.

Vcaches to be deallocated are found by traversing the vcache LRU list
(VLRU) from the oldest vcache to the newest. Up to a target number of
vcaches are attempted to be evicted.  The afs_xvcache lock protecting
the VLRU may be dropped and re-acquired while attempting to evict a
vcache. When this happens, it is possible the VLRU may have changed, so
the traversal of the VLRU is restarted.  This restarting of the VLRU
transversal is limited to 100 iterations to avoid looping indefinitely.

Vcaches which are busy cannot be evicted and remain in the VLRU. When a
busy cache was not evicted and the afs_xvache lock was dropped, the VLRU
traversal is restarted from the end of the VLRU. When the busy vcache is
encountered on the retry, it will trigger additional retries until the
loop limit is reached, at which point the target number of vcaches will
not be deallocated.

This can leave a very large number of unbusy vcaches which are never
deallocated.  On a busy machine, tens of millions of unused vcaches can
remain in memory. When the busy vcache at the end of the VLRU is finally
evicted, the log jam is broken, and the background deamon will hold the
afs_xvcache lock for an excessively long time, hanging the system.

Fix this by moving busy vcaches to the head of the VLRU before
restarting the VLRU traversal. These busy vcaches will be skipped when
retrying the VLRU traversal, allowing the cache manager to make progress
deallocating vcaches down to the target level.

This was already done on the mac osx platform while attempting to evict
vcaches. Move the code to move busy vcaches to the head of the VLRU up
the the platform agnostic caller.

Thanks to Andrew Deason for the initial version of this patch.

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

8 years agoLINUX: hold vcache while dropping dcache refs 06/12206/3
Michael Meffie [Thu, 25 Feb 2016 23:49:20 +0000]
LINUX: hold vcache while dropping dcache refs

Hold a reference on a vcache while attempting to evict the inode from
the dcache. Since the afs_xvcache lock is dropped, it could be possible
for the vcache to be flushed during this time, making it unsafe to use
the vcache after the eviction attempt.

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

8 years agoLinux: Fix misleading indentation and other whitespace 53/12253/2
Stephan Wiesand [Thu, 7 Apr 2016 08:58:30 +0000]
Linux: Fix misleading indentation and other whitespace

Commit 7edc6694e7632c9736bd1516935604a638165313 introduced a
misleading indentation of a line in afs_linux_prefetch. Correct
it, and once here remove trailing whitespace throughout the file.

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

8 years agoFix typo in cm_dcache.c 41/12241/2
Benjamin Kaduk [Tue, 5 Apr 2016 17:53:48 +0000]
Fix typo in cm_dcache.c

Commit b85c5f9339e20d3de9b1316217dadbea41ad537e introduced a new
memset() but left out a prenthesis.

In the absence of a windows build machine, this error went unnoticed.

Reported by Mark Vitale.

Change-Id: Ie250163029132896cd70dc822c6170913e83dafe
Reviewed-on: https://gerrit.openafs.org/12241
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agodoc: add missing angle bracket 33/12233/2
Marcio Barbosa [Mon, 28 Mar 2016 18:50:16 +0000]
doc: add missing angle bracket

The options -logfile and -config should be enclosed
by angle brackets.

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

8 years agoLinux 4.4: Do not use splice() 17/12217/5
Stephan Wiesand [Tue, 8 Mar 2016 13:15:17 +0000]
Linux 4.4: Do not use splice()

splice() may return -ERESTARTSYS if there are pending signals, and
it's not even clear how this should be dealt with. This potential
problem has been present for a long time, but as of Linux 4.4
(commit c725bfce7968009756ed2836a8cd7ba4dc163011) seems much more
likely to happen.

Until resources are available to fix the code to handle such errors,
avoid the riskier uses of splice().

If there is a default implementation of file_splice_{write,read},
use that; on somewhat older kernels where it is not available,
use the generic version instead.

[kaduk@mit.edu: add test for default_file_splice_write]

Change-Id: Ib4477cdfb2cd0f49f516da75edc3cb9d1a8817dc
Reviewed-on: https://gerrit.openafs.org/12217
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agoLinux 4.4: Use locks_lock_file_wait 70/12170/5
Michael Laß [Mon, 18 Jan 2016 18:58:00 +0000]
Linux 4.4: Use locks_lock_file_wait

The locks API was changed in Linux 4.4, introducing locks_lock_file_wait
(e55c34a66f87e78fb1fc6b623b78c5ad74b475af) and removing
flock_lock_file_wait (616fb38fa7a9599293e05ae1fa9acfaf73922434).

locks_lock_file_wait can be used as a drop-in replacement so define
flock_lock_file_wait as an alias for it.

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

8 years agoLinux 4.4: key_payload has no member 'value' 69/12169/3
Michael Laß [Mon, 18 Jan 2016 17:29:00 +0000]
Linux 4.4: key_payload has no member 'value'

In Linux 4.4 (146aa8b1453bd8f1ff2304ffb71b4ee0eb9acdcc) type-specific and
payload data have been merged. The payload is now accessed directly and has
no 'value' member anymore.

FIXES 132677

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

8 years agoRemove automated casting in rxgen 16/12116/6
Chas Williams [Mon, 23 Nov 2015 19:19:38 +0000]
Remove automated casting in rxgen

We should let the compiler warn us when we attempt to convert types that
should not be converted.

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

8 years agorxgen: Don't use size_t in struct rx_opaque with XDR 15/12115/5
Chas Williams [Mon, 23 Nov 2015 19:15:08 +0000]
rxgen: Don't use size_t in struct rx_opaque with XDR

OpenAFS's XDR doesn't support size_t at this time.  For now, use a
temporary stack variable to avoid 32/64-bit issues and copy back the
returned value upon success.

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

8 years agoRefactor printing arguments to the xdr routines 14/12114/5
Chas Williams [Mon, 23 Nov 2015 17:29:31 +0000]
Refactor printing arguments to the xdr routines

This makes some future changes a bit easier to read and implement.

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

8 years agodoc: fs examine no longer requires read rights on the volume root vnode 23/12223/3
Michael Meffie [Fri, 18 Mar 2016 14:22:33 +0000]
doc: fs examine no longer requires read rights on the volume root vnode

Update the man page to reflect the current access rights required for fs
examine.  Historically, fs examine required read access on the root
vnode of the volume housing the directory or file being examined.  This
access check was relaxed in commit d2d591caf2c9b4cf2ebae708cc9b4c8b78ca5a5a,
since the information returned by the file server is already available
anonymously by other means.

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

8 years agoAdd param files for FreeBSD 10.2, 10.3 22/12222/2
Benjamin Kaduk [Wed, 16 Mar 2016 21:16:49 +0000]
Add param files for FreeBSD 10.2, 10.3

FreeBSD 10.3 is in the beta stage now; better get ready for it.

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

8 years agoOPENAFS-SA-2016-002 ListAddrByAttributes information leak
Benjamin Kaduk [Tue, 15 Mar 2016 04:15:20 +0000]
OPENAFS-SA-2016-002 ListAddrByAttributes information leak

The ListAddrByAttributes structure is used as an input to the GetAddrsU
RPC; it contains a Mask field that controls which of the other fields
will actually be read by the server during the RPC processing.
Unfortunately, the client only wrote to the fields indicated by the
mask, leaving the other fields uninitialized for transmission on the
wire, leaking some contents of client memory.

Plug the information leak by zeroing the entire structure before use.

FIXES 132847

Change-Id: I9ccf814ceff206ddb3a74da97dc50b7e1e3c2014

8 years agoOPENAFS-SA-2016-002 VldbListByAttributes information leak
Benjamin Kaduk [Tue, 15 Mar 2016 04:15:20 +0000]
OPENAFS-SA-2016-002 VldbListByAttributes information leak

The VldbListByAttributes structure is used as an input to several
RPCs; it contains a Mask field that controls
which of the other fields will actually be read by the server
during the RPC processing.  Unfortunately, the client only
wrote to the fields indicated by the mask, leaving the other
fields uninitialized for transmission on the wire, leaking
some contents of client memory.

Plug the information leak by zeroing the entire structure before use.

FIXES 132847

Change-Id: I14964e98a57ba6ef060c6e392497f1ebd3afe042

8 years agoOPENAFS-SA-2016-002 AFSStoreVolumeStatus information leak
Benjamin Kaduk [Tue, 15 Mar 2016 04:15:20 +0000]
OPENAFS-SA-2016-002 AFSStoreVolumeStatus information leak

The AFSStoreVolumeStatus structure is used as an input to the
RXAFS_SetVolumeStatus RPC; it contains a Mask field that controls
which of the other fields will actually be read by the server
during the RPC processing.  Unfortunately, the client only
wrote to the fields indicated by the mask, leaving the other
fields uninitialized for transmission on the wire, leaking
some contents of kernel memory.

Plug the information leak by zeroing the entire structure before use.

FIXES 132847

Change-Id: Ib309e6b00b95bc4178740352899d7f940f2eb1ea

8 years agoOPENAFS-SA-2016-002 AFSStoreStatus information leak
Benjamin Kaduk [Sun, 13 Mar 2016 17:56:24 +0000]
OPENAFS-SA-2016-002 AFSStoreStatus information leak

Marc Dionne reported that portions of the AFSStoreStatus structure
were not written to before being sent over the network for
operations such as create, symlink, etc., leaking the contents
of the kernel stack to observers.  Which fields in the request
are used are controlled by a flags field, and so if a field was
not going to be used by the server, it was sometimes left
uninitialized.

Fix the information leak by zeroing out the structure before use.

FIXES 132847

Change-Id: I84a5a10442732ebbcb5d5067ca22030fb795168b

8 years agoOPENAFS-SA-2016-001 group creation by foreign users
Jeffrey Altman [Thu, 10 Mar 2016 02:38:10 +0000]
OPENAFS-SA-2016-001 group creation by foreign users

CVE-2016-2860:

In AFS 3.3 as part of the addition of the cross-cell support for foreign
user auto-registration a bug was introduced that permits foreign users
to create arbitrary groups as if they were system administrators.  This
permits the groups to be created without any group quota checks, and
using group names that non-administrators would not normally be able to
create, such as groups with the "system:" prefix or groups with no colon
(that is, in the namespace for users).

Additionally, all entries created using the auto-registration service
were marked as being created by system:administrators.  This behavior
should not be changed on the stable release branch, but for the next
release the behavior will change to show these entries as being
self-created, to better reflect reality.

FIXES 132822

[kaduk@mit.edu: reword commit message, minor style adjustments]

Change-Id: I54ddca3e4e1339f76ed320f0d6c53d8820aed89c

8 years agoptserver: fix pt_util creation of groups
Jeffrey Altman [Thu, 10 Mar 2016 04:34:55 +0000]
ptserver: fix pt_util creation of groups

In commit 53ac98931adf9f04c150d9bc084cae31f3913476 the adjustment of
owner id was moved from CreateEntry() into CreateGroupName().  This was
done for two reasons:

 1. to reuse the computation of "is administrator" within
    CreateGroupName() in order to permit the owner id to be set
    to the invalid values 0 and ANONYMOUSID.

 2. to allow the owner id to be altered in ChangeEntry().

Unfortunately, CreateEntry() needs to be able to alter the owner id
when creating users not only groups.

This change moves the computation of "is administrator" and the
owner id assignment to CreateEntry() and ChangeEntry().

Change-Id: I0d37f5a43ea5919d1bbc3ba6d82b2924ab38befc

8 years agoLINUX: ifconfig is deprecated 92/12192/3
Michael Meffie [Wed, 24 Feb 2016 21:57:11 +0000]
LINUX: ifconfig is deprecated

ifconfig is deprecated and is no longer installed by default on RHEL 7 and
Centos 7. Use the replacement ip command in the init script for linux.
Fallback to ifconfig in the event the ip command is not available.

Thanks to Ben Kaduk for pointing out the hash built-in command.

Change-Id: I7ffe272eb712cd83a70a7d880d239f72b40cb5df
Reviewed-on: http://gerrit.openafs.org/12192
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agoDAFS: large volume support - fileserver crash after "addled bitmap" 83/11983/3
Mark Vitale [Thu, 27 Mar 2014 10:36:59 +0000]
DAFS: large volume support - fileserver crash after "addled bitmap"

Any DAFS fileserver operation that allocates a new vnode but fails
to update the vnode index will crash:

"Fatal Rx error: assertion failed: --vp->nWaiters >= 0,
file: ../vol/volume.c, line: nnnn"

Note: This crash was exposed by other bugs (to be addressed in future
commits) in OpenAFS large volume support.  However, there may
be other failure paths (unrelated to large volumes) that expose
this error as well.

When VAllocVnode() must allocate a new vnode but fails while
updating the vnode index file (e.g. an "addled bitmap" due to other
bugs in working with a vnode index larger than 2^31 bytes), it branches
to common recovery logic at label error_encountered:.

Part of this recovery is to call VFreeBitmapEntry_r().  Commit
08ffe3e81d875b58ae5fe4c5733845d5132913a0 added a VOL_FREE_BITMAP_WAIT
flag to VFreeBitmapEntry() in order to prevent races with VAllocBitmapEntry().
If the caller specifies VOL_FREE_BITMAP_WAIT, VFreeBitmapEntry_r will
call VCreateReservation_r() and VWaitExclusiveState_r().  However, the
exit from VFreeBitmapEntry_r() calls VCancelReservation_r() unconditionally.
This works correctly with the majority of callers to VFreeBitmapEntry_r,
which do specify the VOL_FREE_BITMAP_WAIT flag.

However, the VAllocVnode() error_encountered logic must specify 0 for
this flag because the thread is already in an exclusive state
(VOL_STATE_VNODE_ALLOC).  This correctly causes VFreeBitmapEntry_r() to
forgo both the reservation and wait-for-exclusive-state.  However, before
exit it erroneously calls VCancelReservation_r().  We now have unbalanced
reservations (nWaiters); this causes an assert when the VAllocVnode()
error_encountered recovery code later calls VCancelReservation_r()
for what it believes is its own prior reservation.

Modify VFreeBitmapEntry_r() to make its final VCancelReservation_r()
conditional on flag VOL_FREE_BITMAP_WAIT.

Change-Id: Id6cf6b1279b11e6dfc4704bba5739912f663beca
Reviewed-on: http://gerrit.openafs.org/11983
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agobozo: allow start of fs and dafs bnodes with options 34/11934/11
Mark Vitale [Sat, 18 Jul 2015 05:12:51 +0000]
bozo: allow start of fs and dafs bnodes with options

fs_create() and dafs_create() issue stat() to verify
the existence of each executable specified in the bnode.
However, commit fda2bc874751ca479365dc6389c0eebb41a0bda1
inadvertently removed the code that stripped any command
arguments before the stat().  Therefore, any bnode that
specifies arguments (e.g. /usr/afs/bin/dafileserver -d 5),
causes the stat() to fail and the bnode will not start.

Rename function AppendExecutableExtension() to a less
"window-ish" name: PathToExecutable().

Modify the Windows version of PathToExecutable()
to properly strip arguments.

Reimplement the Unix macro as function PathToExecutable()
that properly strips arguments.

Change-Id: I04f7ce2afb8211bd12b9063db1335738bff1cc1e
Reviewed-on: http://gerrit.openafs.org/11934
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agoviced: incorrect FID audit of BulkStatus and InlineBulkStatus 91/12191/2
Mark Vitale [Tue, 16 Feb 2016 19:55:03 +0000]
viced: incorrect FID audit of BulkStatus and InlineBulkStatus

The audit code for object AUD_FIDS is off by one - we list the
first FID twice and skip the last FID.

Repair so all FIDs are properly audited.

Change-Id: I99f4687e25031eb26ccd7e07b732217b098005de
Reviewed-on: http://gerrit.openafs.org/12191
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agotest: skip buserror test when SIGBUS is not defined in perl POSIX module 86/12186/3
Michael Meffie [Mon, 8 Feb 2016 15:10:32 +0000]
test: skip buserror test when SIGBUS is not defined in perl POSIX module

Older versions of the perl POSIX module do not define the SIGBUS symbol, which
causes the opr/softsig-t perl test to fail to compile.  Instead of trying to
defined SIGBUS, which may be platform dependent, skip the buserror unit test on
these older platforms.

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

8 years agoCellServDB update 01 Jan 2016 87/12187/3
Michael Meffie [Mon, 8 Feb 2016 17:12:22 +0000]
CellServDB update 01 Jan 2016

Update all remaining copies of CellServDB in the tree, and make the
Red Hat packaging use it by default too.

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

8 years agovolser: detect eof in dump stream while reading acl 03/11703/7
Michael Meffie [Fri, 30 Jan 2015 17:20:10 +0000]
volser: detect eof in dump stream while reading acl

Detect an EOF condition while reading the ACL in a dump stream
and return a restore error, instead of filling the ACL with
0xFF and then failing the restore due to an invalid tag.

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

8 years agocellconfig: check for invalid dotted quads 09/12109/4
Benjamin Kaduk [Sun, 22 Nov 2015 20:23:49 +0000]
cellconfig: check for invalid dotted quads

IP addresses entered into the CellServDB with components larger
than 255 would silently be trucated down to 8-bit unsigned integer
representations.  This could cause confusing behavior with
occasional hangs.

FIXES 131794

Change-Id: I44834cb4662e178fdb4be2eeb03ad58d2fa7c556
Reviewed-on: http://gerrit.openafs.org/12109
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agoafs: Log abnormally large chunk files 31/11831/5
Andrew Deason [Sun, 12 Apr 2015 01:51:09 +0000]
afs: Log abnormally large chunk files

Any chunk in our cache for a regular file should be smaller than or
equal to our configured chunksize. If someone sets a chunk to be
larger than that, it is very strange and may cause other confusing
issues. Specifically, afs_DoPartialWrite determines if our cache is
"too full" by counting the number of dirty chunks. If we have a dirty
chunk that is much larger than the chunksize, it can throw off the
afs_DoPartialWrite calculation.

This is only true for dcaches backing regular files, though. For
directories, we fetch the entire directory into a single chunk file,
and the size of a directory blob can easily exceed the chunksize
without issues. The aforementioned issue with afs_DoPartialWrite does
not apply, since directory chunks cannot be dirty (we only locally
modify the chunk if we modify the dir on the server, and the DVs
match).

Anyway, it should not be possible to get a chunk for a regular file
larger than the chunksize. Log a message if it does occur, to help
assist anyone in tracking down issues when this does occur.

[mmeffie@sinenomine.net remove unnecessary casts in afs_warn args.]

Change-Id: I5cf58e3659dc04255c62fa56b044d5bc1c7ce877
Reviewed-on: http://gerrit.openafs.org/11831
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agoopr: Use opr_Assert() instead of silently failing 53/11853/4
Chas Williams [Sat, 25 Apr 2015 20:53:43 +0000]
opr: Use opr_Assert() instead of silently failing

These routines should never be passed a NULL.  If this happens it
is a serious issue that needs to be addressed.

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

8 years agoopr: Disable some warnings during opr assertions 52/11852/5
Chas Williams [Sat, 25 Apr 2015 20:38:12 +0000]
opr: Disable some warnings during opr assertions

Detect _Pragma(), a C99 extension for inline #pragma's, and use it to
disable to certain warnings during the use of opr_Verify() and
opr_Assert().

Because some versions of clang support _Pragma, do not have support
for -Wtautological-pointer-compare, and do set -Werror and -Wunknown-pragmas,
we must explicitly check for pragma support for -Wtautological-pointer-compare
as well.

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

8 years agoafs: Log weird 'size' fetchdata errors 30/11830/5
Andrew Deason [Fri, 10 Apr 2015 02:26:25 +0000]
afs: Log weird 'size' fetchdata errors

There are a couple of situations that should never happen when issuing
a fetchdata, but cause errors when they do:

 - The fileserver responds with more than 2^32 bytes of data
 - The fileserver responds with more data than requested (but still
   smaller than 2^32)

While these should normally never be encountered, it can be very
confusing when they do, since they cause file fetches to fail. To give
the user or investigating developer some hope of figuring out what is
going on, at least log a warning in these situations, to at least
indicate this is the area in which something is breaking.

Only log these once, in case something causes these conditions to be
hit, e.g., every fetch. Once is at least enough to say this is
happening.

[mmeffie@sinenomine.net remove unneeded casts in afs_warn args and
explicit static initializers.]

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

8 years agoafs: Fix fetchInit for negative/large lengths 29/11829/4
Andrew Deason [Wed, 8 Apr 2015 03:10:53 +0000]
afs: Fix fetchInit for negative/large lengths

Currently, the 'length64' variable in rxfs_fetchInit is almost
completely unused (it just goes into an icl logging function). For the
length that we actually use ('*alength'), we just take the lower 32
bits of the length that the fileserver told us. This method is
incorrect in at least the following cases:

 - If the fileserver returns a length that is larger than 2^32-1,
   we'll just take the lower 32 bits of the 64-bit length the
   fileserver told us about. The client currently never requests a
   fetch larger than 2^32-1, so this would be an error, but if this
   occurred, we would not detect it until much later in the fetch.

 - If the fileserver returns a length that is larger than 2^31-1, but
   smaller than 2^32, we'll interpret the length as negative (which we
   assume is just 0, due to bugs in older fileservers). This is also
   incorrect.

 - If the fileserver returns a negative length smaller than -2^31+1,
   we may interpret the give length as a positive value instead of a
   negative one. Older fileservers can do this if we fetch data beyond
   the file's EOF (this was fixed in the fileserver in commit
   529d487d65d8561f5d0a43a4dc71f72b86efd975). This positive length
   will cause an error (usually), instead of proceeding without error
   (which is what would happen if we correctly interpreted the length
   as negative).

On Solaris, this can manifest as a failed write, when writing to a
location far beyond the file's EOF from the fileserver's point of
view, because Solaris writes can trigger a fetch for the same area.
Seeking to a location far beyond the file's EOF and writing can
trigger this, as can a normal copy into AFS, if the file is large
enough and the cache is large enough. To explain in more detail:

When copying a file into AFS, the cache manager will buffer the dirty
data in the disk cache until the file is synced/closed, or we run out
of cache space. While this data is buffering, the application will
write into an offset, say, 3GiB into the file. On Solaris, this can
trigger a read for the same region, which will trigger a fetch from
the fileserver at the offset 3GiB into the file. If the fileserver
does not contain the fix in commit
529d487d65d8561f5d0a43a4dc71f72b86efd975, it will respond with a large
negative number, which we interpret as a large positive number; much
larger than the requested length. This will cause the fetch to fail,
which then causes the whole write() call to fail. Specifically this
will fail with EINVAL on Solaris, since that is the error code we
return from afs_GetOnePage when we fail to acquire a dcache. If the
cache is small enough, this will not happen, since we will flush data
to the fileserver before we have a large amount of dirty data,
e.g., 3GiB. (The actual error occurs closer to 2GiB, but this is just
for illustrative purposes.)

To fix this, detect the various ranges of values mentioned above, and
handle them specially. Lengths that are too large will yield an error,
since we cannot handle values over 2^31-1 in the rxfs_* framework
currently.

For lengths that are negative, just act as if we received a length of
0. Do this for both the 64-bit codepath and the non-64-bit codepath,
just so they remain identical.

[mmeffie@sinenomine.net: directly use 64 bit comparisons, don't mask
end call error code, commit nits.]

Change-Id: I7e8f2132d52747b7f0ce4a6a5ba81f6641a298a8
Reviewed-on: http://gerrit.openafs.org/11829
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agoafs: Avoid incorrect size when fetching beyond EOF 28/11828/3
Andrew Deason [Fri, 10 Apr 2015 00:58:51 +0000]
afs: Avoid incorrect size when fetching beyond EOF

Currently, afs_GetDCache contains a couple of calculations that look
similar to this:

    if (position + size > file_length) {
        size = file_length - position;
    }
    if (size < 0) {
        size = 0;
    }

Most of the time, this is fine. However, if 'position' is more than
2GiB greater than file_length, 'size' will calculated to be smaller
than -2GiB. Since 'size' in this code is a signed 32-bit integer, this
can cause 'size' to underflow, and result in a value closer to
(positive) 2GiB.

This has two potential effects:

The afs_AdjustSize call in afs_GetDCache will cause the underlying
cache file for this dcache to be very large (if our offset is around
2GiB larger than the file size). This can confuse other parts of the
client, since our cache usage reporting will be incorrect (and can be
even way larger than the max configured cache size).

This will also cause a read request to the fileserver that is larger
than necessary. Although 'size' will be capped at our chunksize, it
should be 0 in this situation, since we know there is no data to
fetch. At worst, this currently can just result in worse performance
in rare situations, but it can also just be very confusing.

Note that an afs_GetDCache request beyond EOF can currently happen in
non-race conditions on at least Solaris when performing a file write.
For example, with a chunksize of 256KiB, something like this will
trigger the overflow in 'size' in most cases:

    $ printf '' > smallfile && printf b | dd of=smallfile bs=1 oseek=2147745793

But there are probably other similar scenarios.

To fix this, just check if our offset is beyond the relevant file
size, and do not depend on 'size' having sane values in edge cases
such as this.

Change-Id: Ie36f66ce11fbee905062b3a787871ec077c15354
Reviewed-on: http://gerrit.openafs.org/11828
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>

8 years agodoc: afsd -settime and -nosettime are obsolete 75/12175/3
Michael Meffie [Thu, 21 Jan 2016 22:55:37 +0000]
doc: afsd -settime and -nosettime are obsolete

Update the afsd man page -settime and -nosettime options, which are obsolete
and no longer have any effect.  Use the same wording as the other obsolete
options in the afsd man page.  Keep the recommendations to use the time keeping
daemons provided by the operating system to maintain the system time.

Change-Id: I08a1bd5ae0b2d6618b3e212ebcbb98f470e33820
Reviewed-on: http://gerrit.openafs.org/12175
Reviewed-by: Michael Laß <lass@mail.uni-paderborn.de>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agorxinit_status needs to be global for the kext since 73/12073/3
Dave Botsch [Wed, 28 Oct 2015 15:53:26 +0000]
rxinit_status needs to be global for the kext since
RXK_UPCALL_ENV is defined in src/rx/DARWIN/rx_knet.c

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

8 years agoInitial set of changes for El Capitan OS X 10.11 . 72/12072/3
Dave Botsch [Wed, 28 Oct 2015 15:28:01 +0000]
Initial set of changes for El Capitan OS X 10.11 .

Mainly new El Capitan specific config files and defitions of
Darwin 15 variables and config tests/etc.

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

8 years agoFix optimized IRIX kernel module builds 11/12111/2
Benjamin Kaduk [Mon, 23 Nov 2015 00:22:58 +0000]
Fix optimized IRIX kernel module builds

Commit 9f94892f8d996a522e7801ef6088a13769bee7c2 (from 2006)
introduced per-file CFLAGS, using $(CFLAGS-$@); this construct
is not parsed well by IRIX make, which ends up attempting to
expand '$@)' and finding mismatched parentheses.

Commit 5987e2923a2670a27a801461dc9668ec88ed7d2a (from 2007) followed,
fixing the IRIX build but only for the NOOPT case.  This left the
problematic expression in CFLAGS_OPT until 2013, when another RT
ticket was filed reporting the continued breakage.  That ticket
was then ignored until 2015 (now) with no particular cries of
outrage on the mailing lists.  Perhaps this gives some indication
of the size and/or mindset of the IRIX userbase.  (There have
been successful IRIX installations during this time period, so
presumably it was discovered that disabling optimizations helped
the build along.)

FIXES 131621

Change-Id: Id5298103221b016239723aa08ebe0dc54bdadc5e
Reviewed-on: http://gerrit.openafs.org/12111
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agoLINUX: don't cache negative entries for dynroot 40/12140/4
Chas Williams [Thu, 24 Dec 2015 22:58:32 +0000]
LINUX: don't cache negative entries for dynroot

The dynroot volume lacks any callbacks that would invalidate the directory
or change the data version.  Further, the data version for the dynroot
is only updated for when a new cell is found or added (a positive lookup).

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

8 years agoTypo fix in comment 33/12133/3
Benjamin Kaduk [Sat, 19 Dec 2015 07:08:06 +0000]
Typo fix in comment

afsd -shutdown takes only a single dash, as with all cmd-style
options.

Improve the grammar a bit while we're here.

Change-Id: Ie96c80dba1770e735617e5c93fe3d4c1e3afd3a9
Reviewed-on: http://gerrit.openafs.org/12133
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agoafs: do not allow two shutdown sequences in parallel 16/12016/8
Marcio Barbosa [Tue, 29 Dec 2015 13:31:43 +0000]
afs: do not allow two shutdown sequences in parallel

Often, ‘afsd -shutdown’ is called right after ‘umount’.
Both commands hold the glock before calling ‘afs_shutdown’.
However, one of the functions called by 'afs_shutdown', namely,
‘afs_FlushVCBs’, might drop the glock when the global
'afs_shuttingdown' is still equal to 0. As a result, a scenario
with two shutdown sequences proceeding in parallel is possible.

To fix the problem, the global ‘afs_shuttingdown’ is used as an
enumerated type to make sure that the second thread will not run
‘afs_shutdown’ while the first one is stuck inside ‘afs_FlushVCBs’.

Change-Id: Iffa89d82278b0df5fb90fc35608af66d8e8db29e
Reviewed-on: http://gerrit.openafs.org/12016
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agoredhat: Correct permissions on systemd unit files 74/12174/3
Brian Torbich [Thu, 21 Jan 2016 15:08:27 +0000]
redhat: Correct permissions on systemd unit files

Change the systemd unit file permissions created via
openafs.spec to be 0644 instead of 0755.  Having the
systemd unit files be executable will trigger a systemd
warning.

FIXES 132662

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

8 years agoredhat: Avoid bogus dependencies when building the srpm 03/11903/2
Stephan Wiesand [Mon, 22 Jun 2015 08:44:11 +0000]
redhat: Avoid bogus dependencies when building the srpm

By default the spec defines that both userland and kernel module
packages should be built. This results in a dependency of the form
"kernel-devel-`uname -m` = `uname -r`" being added to the source
package created by makesrpm.pl, which is bogus because the uname
values are from the system on which the srpm is built and needn't
apply to the system where it is used. While rpm and rpmbuild ignore
such dependencies of source packages, other tools don't and may fail.

Some versions of rpmbuild will also enforce those requirements when
building the srpm itself, which is pointless too.

Avoid both problems by pretending not to attempt building modules
and ignoring any dependencies when makesrpm.pl invokes rpmbuild -bs.

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

8 years agoTweak grammar in README 56/12156/2
Benjamin Kaduk [Tue, 29 Dec 2015 00:30:30 +0000]
Tweak grammar in README

So as to get a trivial change as confirmation that an updated
gerrit is functioning correctly.

Change-Id: I04eb12cab982a3f1b5ecc92d60c455e7a0d2242c
Reviewed-on: http://gerrit.openafs.org/12156
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agoRemove blank line from README 53/12153/5
Benjamin Kaduk [Mon, 28 Dec 2015 22:11:17 +0000]
Remove blank line from README

There's no reason for this file to start with a blank line.

Change-Id: I175390d3c9796fc10ef8086a5b179f4fc27362b5
Reviewed-on: http://gerrit.openafs.org/12153
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agoUpdate extra-iput configure argument description
Benjamin Kaduk [Wed, 4 Feb 2015 15:11:29 +0000]
Update extra-iput configure argument description

Commit 15260c7fdc5ac8fe9fb1797c8e383c665e9e0ccd did not function
as advertised, since the conditional which attempted to make
the configure option --(en|dis)able-linux-d_splice_alias-extra-iput
mandatory on linux checked a variable for the system type which
was not set at the time the check ran.

Subsequent discussion of this behavior produced a consensus that
there is not a need to make the configure option mandatory,
due to the narrow range of kernels affected by the bug in question,
so this follow-up commit just fixes the documentation and removes
the ineffective code.

Change-Id: I36d1f8801d355f33c3132fcab166ea76faab8e87
Reviewed-on: http://gerrit.openafs.org/11710
Reviewed-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agocompile_et: Don't overflow input file buffer
Simon Wilkinson [Mon, 4 Mar 2013 16:15:37 +0000]
compile_et: Don't overflow input file buffer

Don't overlow the buffer that's used for the input filename by
copying in to much with sprintf. Use asprintf to dynamically
allocate a buffer instead.

Link roken for rk_asprintf where needed.

Build compile_et with libtool, to ensure that it is linked statically,
as is needed for build tools such as compile_et.  (This requires
a preceding change to set a buildtool_roken make variable.)

Caught by coverity (#985907)

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

8 years agoProvide a buildtool_roken make variable
Benjamin Kaduk [Wed, 25 Feb 2015 23:46:28 +0000]
Provide a buildtool_roken make variable

When using roken in build tools, i.e., binaries which must be
executed during the build stage, the roken library must be usable
prior to the 'install' stage.  In particular, if the internal
rokenafs is used, the shared library will not be installed and
the runtime linker will not be able to find it, causing execution
of the build tool to fail.  To avoid this failure, librokenafs
must be linked statically into these build tools.

Unfortunately, the way we currently use libtool is not very
well aligned to libtools model of how it should be used.  As a result,
it does not seem feasible to cause libtool to link librokenafs
statically without breaking other parts of the build.

Libtool peeks at the compiler command-line arguments to affect its
behavior when invoked as a linker.  The flags -static, -all-static,
and -static-libtool-libs can affect whether dynamic or static linkage
is used for various libraries being linked into the executable.
Passing -all-static tells libtool to not do any dynamic linking at
all, but is silently a no-op if static linking is not possible (the
default situation on most modern Linuxen, OS X, and Solaris).
Passing -static causes libtool to not do any dynamic linking of
libtool libraries which have not been installed, and passing
-static-libtool-libs causes libtool to not do any dynamic linking
of libtool libraries at all.

In order to get libtool to actually link statically in all cases,
we should pass -all-static, not just -static.  However, because
too many platforms disallow static linking by default, this is
not a viable option.

If we retain the libtool archive librokenafs.la in the linker search
path, libtool then records the library dependency of libafshcrypto on
librokenafs in its metadata and refuses to install libafshcrypto.la to
any path other than the configured prefix.  This restriction of
libtool is incompatible with our use in 'make dest', and it is not
feasible to desupport 'make dest' before the 1.8 release.

The most appropriate workaround seems to be to just pass the
path to librokenafs.a on the linker command line when linking
build tools.  As such, provide a new make variable buildtool_roken
which is appropriate for linking roken into build tools -- this
variable will be set to the path to librokenafs.a when the internal
roken is used, and the normal -lrokenafs when an external roken
is used.

Change-Id: I079fc6de5d0aa6403eb1071f3d58a248b1777853
Reviewed-on: http://gerrit.openafs.org/11763
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agorxkad: Resolve warnings in ticket5.c
Anders Kaseorg [Fri, 31 Jul 2015 05:42:55 +0000]
rxkad: Resolve warnings in ticket5.c

Resolves these warnings:

ticket5.c: In function ‘tkt_MakeTicket5’:
ticket5.c:574:33: warning: pointer targets in passing argument 1 of ‘_rxkad_v5_encode_EncTicketPart’ differ in signedness [-Wpointer-sign]
     code = encode_EncTicketPart(encodebuf, allocsiz, &data, &encodelen);
                                 ^
In file included from ticket5.c:80:0:
v5gen-rewrite.h:43:30: note: expected ‘unsigned char *’ but argument is of type ‘char *’
 #define encode_EncTicketPart _rxkad_v5_encode_EncTicketPart
                              ^
v5gen.c:1889:1: note: in expansion of macro ‘encode_EncTicketPart’
 encode_EncTicketPart(unsigned char *p, size_t len, const EncTicketPart * data, size_t * size)
 ^
ticket5.c:602:33: warning: pointer targets in passing argument 1 of ‘_rxkad_v5_encode_EncryptedData’ differ in signedness [-Wpointer-sign]
     code = encode_EncryptedData(ticket + *ticketLen - 1, *ticketLen, &encdata, &tl);
                                 ^
In file included from ticket5.c:80:0:
v5gen-rewrite.h:16:30: note: expected ‘unsigned char *’ but argument is of type ‘char *’
 #define encode_EncryptedData _rxkad_v5_encode_EncryptedData
                              ^
v5gen.c:690:1: note: in expansion of macro ‘encode_EncryptedData’
 encode_EncryptedData(unsigned char *p, size_t len, const EncryptedData * data, size_t * size)
 ^
ticket5.c: In function ‘tkt_DecodeTicket5’:
ticket5.c:320:10: warning: ‘plainsiz’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     code = decode_EncTicketPart((unsigned char *)plain, plainsiz, &decr_part, &siz);
          ^

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

8 years agoAdd filepath entries for rxkad.keytab
Benjamin Kaduk [Tue, 3 Mar 2015 01:19:07 +0000]
Add filepath entries for rxkad.keytab

Even though master is not using it, we still want to be able to
find it.

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

8 years agoMake typedKey helpers more friendly to use
Benjamin Kaduk [Mon, 2 Mar 2015 21:05:51 +0000]
Make typedKey helpers more friendly to use

Make freeing a NULL key pointer a no-op.

Allow passing NULL to afsconf_typedKey_values() when not all
values are needed.

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

8 years agoviced: do not overwrite possible failure
Marcio Barbosa [Thu, 24 Dec 2015 20:23:23 +0000]
viced: do not overwrite possible failure

The function ‘hpr_Initialize’ overwrites the code
returned by ‘ubik_ClientInit’. As a result, ‘hpr_Initialize’
will not report any failure triggered by ‘ubik_ClientInit’.

To fix this problem, store the code returned by ‘rxs_Release’
in a new variable. Only return this code if the function
‘ubik_ClientInit’ worked properly. Otherwise, return the code
provided by ‘ubik_ClientInit’.

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

8 years agoafs: incorrect types for AFSDB IPv4 addresses
Mark Vitale [Tue, 24 Nov 2015 02:03:57 +0000]
afs: incorrect types for AFSDB IPv4 addresses

DNS lookup results were being handled with int types.

Fortunately, this seems to be harmless, due to use of
memcpy when the types don't match, and assignment only
when both sides were int.

However, to avoid any future unpleasantness, change
them to afs_uint32.

No functional change should be incurred.

Change-Id: I31aeabb4ae3194a00b29a1fa767d05af167b4e4f
Reviewed-on: http://gerrit.openafs.org/12117
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agoafs: pioctl kernel memory overrun
Mark Vitale [Fri, 7 Aug 2015 15:56:16 +0000]
afs: pioctl kernel memory overrun

CVE-2015-8312:
Any pioctl with an input buffer size (ViceIoctl->in_size)
exactly equal to AFS_LRALLOCSIZE (4096 bytes) will cause
a one-byte overwrite of its kernel memory working buffer.
This may crash the operating system or cause other
undefined behavior.

The attacking pioctl must be a valid AFS pioctl code.
However, it need not specify valid arguments (in the ViceIoctl),
since only rudimentary checking is done in afs_HandlePioctl.
Most argument validation occurs later in the individual
pioctl handlers.

Nor does the issuer need to be authenticated or authorized
in any way, since authorization checks also occur much later,
in the individual pioctl handlers.  An unauthorized user
may therefore trigger the overrun by either crafting his
own malicious pioctl, or by issuing a privileged
command, e.g. 'fs newalias', with appropriately sized but
otherwise arbitrary arguments.  In the latter case, the
attacker will see the expected error message:
 "fs: You do not have the required rights to do this operation"
but in either case the damage has been done.

Pioctls are not logged or audited in any way (except those
that cause loggable or auditable events as side effects).

root cause:
afs_HandlePioctli() calls afs_pd_alloc() to allocate two
two afs_pdata structs, one for input and one for output.
The memory for these buffers is based on the requested
size, plus at least one extra byte for the null terminator
to be set later:
  requested size allocated
  ================= =================================
  > AFS_LRALLOCSIZ osi_Alloc(size+1)
  <= AFS_LRALLOCSIZ afs_AllocLargeSize(AFS_LRALLOCSIZ)

afs_HandlePioctl then adds a null terminator to each buffer,
one byte past the requested size.  This is safe in all cases
except one: if the requested in_size was _exactly_
AFS_LRALLOCSIZ (4096 bytes), this null is one byte beyond
the allocated storage, zeroing a byte of kernel memory.

Commit 6260cbecd0795c4795341bdcf98671de6b9a43fb introduced
the null terminators and they were correct at that time.
But the commit message warns:
 "note that this works because PIGGYSIZE is always less than
  AFS_LRALLOCSIZ"

Commit f8ed1111d76bbf36a466036ff74b44e1425be8bd introduced
the bug by increasing the maximum size of the buffers but
failing to account correctly for the null terminator in
the case of input buffer size == AFS_LRALLOCSIZ.

Commit 592a99d6e693bc640e2bdfc2e7e5243fcedc8f93 (master
version of one of the fixes in the recent 1.6.13 security
release) is the fix that drew my attention to this new
bug.  Ironically, 592a99 (combined with this commit), will
make it possible to eliminate the "offending" null termination
line altogether since it will now be performed automatically by
afs_pd_alloc().

[kaduk@mit.edu: adjust commit message for CVE number assignment,
reduce unneeded churn in the diff.]

Change-Id: I1a536b3a53ec4b6721fbd39a915207da4358720c

8 years agoviced: add missing new lines to log messages
Michael Meffie [Fri, 17 Apr 2015 00:03:21 +0000]
viced: add missing new lines to log messages

The server logger requires an explicit new line.

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

8 years agovolser: range check acl header fields during dumps and restores
Michael Meffie [Fri, 30 Jan 2015 17:12:03 +0000]
volser: range check acl header fields during dumps and restores

Perform range checks on the acl header fields when reading an
acl from a dump stream and when writing an acl to a dump
stream.

Before this change, a bogus value in the total, positive, or
negative acl fields from a dump stream could cause an out of
bounds access of the acl entries table, crashing the volume
server.

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

8 years agovolser: set error, not code, before rfail
Benjamin Kaduk [Sun, 22 Nov 2015 19:24:43 +0000]
volser: set error, not code, before rfail

The rfail cleanup handler overwrites 'code' ~unconditionally, but
does use an existing 'error' value if present.  Since the intent
is to return failure to the caller, preserve the code in the error
variable and do so.

FIXES 131897

Change-Id: I25db2f9ad75a5b856626d39d35f97a09f26bd7a9
Reviewed-on: http://gerrit.openafs.org/12108
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agoutil: add CloseLog routine to close the server log
Michael Meffie [Thu, 10 Sep 2015 01:24:04 +0000]
util: add CloseLog routine to close the server log

Add the missing complement to OpenLog().

Change-Id: I45e7e5d2da3241c163d2d4baa6b386167e90e582
Reviewed-on: http://gerrit.openafs.org/12002
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agosalvager: redd up showlog global flag
Michael Meffie [Wed, 9 Sep 2015 17:22:26 +0000]
salvager: redd up showlog global flag

Clean up the show log flag so it is only set by the salvager and
is reset when spawning a child process.

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

8 years agodafs: log to stderr when running salvageserver in client mode
Michael Meffie [Mon, 9 Feb 2015 15:14:41 +0000]
dafs: log to stderr when running salvageserver in client mode

When the -client option is given to the salvageserver, print
Log() messages to stderr instead of losing them.

Change-Id: I065e8136db9a8cc241639fbe34607db884751b95
Reviewed-on: http://gerrit.openafs.org/11729
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agodafs: remove the salvageserver -showlog option
Michael Meffie [Mon, 30 Mar 2015 17:20:42 +0000]
dafs: remove the salvageserver -showlog option

Remove the salvagerserver option to print log messages to stdout.  This
was a carry over from the stand-alone salvager and is not appropriate for
a daemon.

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

8 years agogtx: use getmaxyx() with sensible fallbacks
Brandon S Allbery [Tue, 24 Nov 2015 21:39:02 +0000]
gtx: use getmaxyx() with sensible fallbacks

configure now checks for the standard getmaxyx() macro; failing that,
it looks for the older but pre-standardization getmaxx() and getmaxy(),
then falls back to the 4.2BSD curses _maxx and _maxy fields; if all
else fails, gtx building is disabled.

gtx now defines getmaxyx() itself if necessary, based on the above.

This also fixes a bug in gtx with all ncurses versions > 1.8.0 on
platforms other than NetBSD and OS X: gtx was using the _maxx and
_maxy fields, which starting with ncurses 1.8.1 were off by 1 from
the expected values. As such, behavior of scout and/or afsmonitor
may change on most ncurses-using platforms.

Change-Id: I49778e87adacef2598f0965e09538dfc3d840dcc
Reviewed-on: http://gerrit.openafs.org/12107
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agoOpen syscall emulation file O_RDONLY
Chas Williams [Wed, 2 Dec 2015 15:38:42 +0000]
Open syscall emulation file O_RDONLY

As reported on the -info mailing list, docker is now exporting the
/proc filesystem as read only.  ioctl() doesn't need write permissions
to do its work, so change O_RDWR to O_RDONLY.

Change-Id: I2068888b13b6b5e31b1a2205bbcbe43f5f9fc55a
Reviewed-on: http://gerrit.openafs.org/12122
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agodafs: remove the salvageserver -datelogs option
Michael Meffie [Mon, 30 Mar 2015 17:17:25 +0000]
dafs: remove the salvageserver -datelogs option

Remove the undocumented -datelogs option from the salavageserver, which
was a carry over from the standalone salvager program, but is not
appropriate for a daemon.

Change-Id: Ia382d6550e0641edcba55a414e00323755487e18
Reviewed-on: http://gerrit.openafs.org/11814
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

8 years agodoc: remove unimplemented -showsuid and -showmounts from the salvageserver man page
Michael Meffie [Tue, 31 Mar 2015 15:08:34 +0000]
doc: remove unimplemented -showsuid and -showmounts from the salvageserver man page

These options were copied from the salvager man page and are not implemented by
the salvageserver.

Change-Id: Ib6c5b3fd494f1662b958442863e5fbfc0755a0c2
Reviewed-on: http://gerrit.openafs.org/11817
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

8 years agoFix ptserver -default_access parsing
Benjamin Kaduk [Sun, 22 Nov 2015 22:34:16 +0000]
Fix ptserver -default_access parsing

Commit 0b9986c8758c13a1de66b8bdae51b11abaea6cf3 converted ptserver
to use libcmd for parsing, but erroneously listed the
-default_access argument as CMD_SINGLE instead of CMD_LIST, since
two arguments are needed.  This made it impossible to use
-default_access at all, since libcmd would reject an extra argument
and the later argument processing would notice that the second
argument was missing.

FIXES 131731

Change-Id: Ib8241308d4f40f980d635513e2255aafa06c3d8a
Reviewed-on: http://gerrit.openafs.org/12110
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

8 years agodoc: add syslog options to salvageserver man page
Michael Meffie [Tue, 31 Mar 2015 15:04:26 +0000]
doc: add syslog options to salvageserver man page

Add the missing -syslog and -syslogfacility options to
the salvageserver man page.

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

8 years agotabular_output: allocate footer-line when set for the first time
Christof Hanke [Wed, 18 Nov 2015 13:02:50 +0000]
tabular_output: allocate footer-line when set for the first time

If the footer line is not allocated, programs segfault at runtime.
The printFooter functions should check if the footer
is allocated before printing them.

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

8 years agovlserver: VL_GetEntryByName* requests undercounted
Mark Vitale [Wed, 18 Nov 2015 20:09:37 +0000]
vlserver: VL_GetEntryByName* requests undercounted

Commit a14e791541bf19c6c377e68bc2f978fba34f94b1
refactored and corrected the counting of requests and aborts.
However, it inadvertently introduced a new undercount for
VL_GetEntryByName* requests, counting them only if
NameIsId(volname), e.g. volname="536870911".

Ensure that the normal case of a non-"numeric" volname is
also counted.

Discovered during review of pullup to 1.6.x.

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

8 years agowriteconfig: emit error messages again in VerifyEntries
Stephan Wiesand [Tue, 17 Nov 2015 14:03:03 +0000]
writeconfig: emit error messages again in VerifyEntries

Before commit e4a8a7a38dbf29e89bc1a7b6b017447a6aa0c764 an error message
was printed if looking up a server hostname failed. Restore this, and
also print a message in the now detected case that the lookup returns
loopback addresses only.

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

8 years agoCODING: permit --enable-checking with clang
Benjamin Kaduk [Fri, 28 Aug 2015 01:20:58 +0000]
CODING: permit --enable-checking with clang

Starting at 3.2, a mostly arbitrarily selected version.

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