IBM created a global variable 'afsconf_SawCell' in the kauth package
and manipulated its value from within bos.c as part of the calling
of ka_Init(). Patchset d52398940d58ccdba4114a9975762f48cc24ad15
exported afsconf_SawCell from afsauthent.dll since bos.exe is built
pthreaded. It was previously mixing pthread and not-pthread libraries
to access the variable.
Unfortunately, the export was declared as a function pointer instead
of DATA. Importing a DATA element from a library also requires that
the variable be __declspec(dllimport). The use of afsconf_SawCell
needs to be replaced but in the meantime fix the import so that bos.exe
can start without crashing.
Build the 3961 library in userspace, with support for the common
kerberos enctypes des3-hmac-sha1, arcfour-hmac-md5, and aesXXX-cts-hmac-sha1-96.
Export new symbols as well, and suppress deprecated warnings.
Rename all symbols, both exported and not, with an oafs_h_ prefix
so as to reduce the chance of conflicts.
Rename heim_octet_string to avoid confusion about where things are coming
from.
Ben Kaduk [Tue, 2 Jul 2013 15:13:25 +0000 (11:13 -0400)]
Disable some heimdal bits
For the rfc3961 library, we don't want linker exposure to an
entropy-gathering daemon, and we don't want to be leaving entropy
seed files around in user homedirs.
Ben Kaduk (1):
Be friendly to krb5_generate_random_block consumers
Jeffrey Altman (6):
roken: include limits.h unconditionally
Avoid unused variable warning on Windows
roken: include direct.h if HAVE_DIRECT_H
roken: Define S_IRWXU and friends on Windows
roken: Add rk_mkdir()
libkrb5: Add missing KRB5_LIB_FUNCTION/KRB5_LIB_CALL
Marc Dionne [Fri, 5 Jul 2013 16:50:36 +0000 (12:50 -0400)]
bos: Do encryption if requested
Commit d008089a79 didn't replace the processing of the aencrypt
flag passed to the GetConn() function, causing all bos connections
to be un-encrypted. This causes "addkey" to fail with an error
from the server, and "listkeys" to silently ignore the -showkey
option to display keys.
Set the AFSCONF_SECOPTS_ALWAYSENCRYPT flag, and don't set
AFSCONF_SECOPTS_FALLBACK_NULL since fallback is not acceptable if
the caller requested enrcyption.
Jeffrey Altman [Wed, 26 Jun 2013 15:00:00 +0000 (11:00 -0400)]
Windows: Protect all Mm and Cc calls with try..except
Wrap all Memory Manager and Cache Manager operations in a try..except
block to protect against leaking the SectionObjectResource if an exception
is thrown. Failure to release the SectionObjectResource will result in
subsequent deadlocks.
Don't assume that converting a UUID to a string will always succeed.
Instead, opr_uuid_toString should return a status result to indicate
whether the operation was successful or not.
Jeffrey Altman [Wed, 19 Jun 2013 17:53:51 +0000 (13:53 -0400)]
Windows: Wake waiters on failed cm_SyncOp exit
If cm_SyncOp exits due to failure and there are threads waiting
to use the cm_scache object, wake them before exiting because there
will be no cm_SyncOpDone() operation to wake them later.
Andrew Deason [Thu, 30 May 2013 22:53:56 +0000 (17:53 -0500)]
namei: Create the IH_CREATE_INIT function
Create a new function that combines calls to IH_CREATE and IH_INIT
into one operation; the new function is called IH_CREATE_INIT. This
allows a caller to create a file and then use it, without needing to
open() the file twice.
This is currently only implemented for the Unix namei backend; other
backends result in effectively the same functionality (but can use the
same API).
Andrew Deason [Thu, 30 May 2013 22:52:32 +0000 (17:52 -0500)]
ihandle: Refactor ih_open to split out ih_attachfd
Refactor the function ih_open, so part of its logic gets split out
into the new ih_attachfd_r (and ih_attachfd) function. This allows
other code to splice in an existing fd, without going through the
normal "open" path.
This patch should incur no functional change; it is just code
reorganization.
Andrew Deason [Thu, 30 May 2013 22:40:58 +0000 (17:40 -0500)]
ihandle: Fix fdInUseCount leak on EMFILE
Here, we close closeFd, but currently we don't decrement fdInUseCount.
Since we retry the open immediately afterwards, this means we can leak
fdInUseCount references. For example, if we retry this 5 times and get
EMFILE on each attempt, we will close 5 FDs, but not decrement
fdInUseCount at all.
To fix this, decrement fdInUseCounter when we close a file for EMFILE.
Several functions in src/auth/userok.c construct pathnames in fixed
size buffers on their stacks. Those buffers are simultaneously too
small for the purpose for which they are used and too large to be
placed on the stack. This change replaces these fixed-size buffers
with dynamically-allocated buffers which are either exactly the right
size (due to asprintf) or have size AFSDIR_PATH_MAX.
When writing a callback state dump, test the return values from
write(2), but don't do anything based on the test. This avoids
compiler warnings when building on Ubuntu 12.10, with gcc 4.7.2 and
eglibc 2.15-0ubuntu20.1. This adds a new macro, WriteBytes(), which
handles writing a requested number of bytes to a file and ignoring
errors.
Fix potential buffer overflows caused by misuse of the scanf function
in the fileserver and ptserver.
Also fix similar issues in the client side fs command and libadmin
library.
Change-Id: Ia6a46981c50537da1673507c2bc777f96e43f95a
(This change was applied to the 1.6 branch as a security fix for 1.6.2 as
commit d1855f8e04; this commit brings the fix into master.)
Reviewed-on: http://gerrit.openafs.org/9962 Reviewed-by: Derrick Brashear <shadow@your-file-system.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Jeffrey Altman [Sat, 25 May 2013 21:05:10 +0000 (17:05 -0400)]
rx: test for active calls in rxi_ChallengeEvent
The challenge event fires when an outstanding challenge request
has not been responded to. If there are no calls in the ACTIVE or PRECALL
state on the connection when the challenge event fires do not re-issue the
challenge. Clients do not respond to challenges when there are no active
calls.
Make the version string used in AFSVersion and cml_version_number
include the names of the user doing the build and the host on which
it is done. Also, remove extraneous whitespace and the content-free
word 'built' from cml_version_string, since Rx debug packages provide
space for only 64 characters of version string.
Change-Id: I128f6c175bb93b1fb5a4d531f64aa81bd2841ce7
Reviewed-on: http://gerrit.openafs.org/2279 Reviewed-by: Mark Vitale <mvitale@sinenomine.net> Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Jeffrey Altman [Sat, 1 Jun 2013 04:48:51 +0000 (00:48 -0400)]
Windows: Protect against cm_GetVolServerList failures
In cm_Analyze, if cm_GetVolServerList() fails volServerpp will be
NULL which will trigger an exception if passed to either
cm_SetServerBusyStatus or cm_ResetServerBusyStatus.
Marc Dionne [Wed, 3 Apr 2013 20:09:53 +0000 (16:09 -0400)]
tests: Improve afstest_UnlinkTestConfig cleanup
Make afstest_UnlinkTestConfig clean up and remove the specified
directory regardless of which files are present. This means
the function no longer has to track the current state of which
files may be present as tests are added and modified.
A sanity check is added to prevent damage in case the function is
called for an inappropriate directory.
As before, no cleaning is done if the test is run outside of a
"make check".
Marc Dionne [Wed, 22 May 2013 13:26:57 +0000 (09:26 -0400)]
Linux: Fix tmpfs cache support
As of kernel 3.1, tmpfs no longer has a readpage() operation in its
address space operations. Some of the cache manager code relies on
this, causing an oops if tmpfs is used as backing store for the
cache.
As a minimal fix, detect that there is no readpage() and disable
the optimizations that depend on it.
Jeffrey Altman [Mon, 13 May 2013 10:45:34 +0000 (06:45 -0400)]
vol: return VNOVNODE if vnode is not allocated
If a request for a vnode fails because the vnode is not allocated
within the volume, the error returned to the client should be VNOVNODE to
indicate that the requested FID does not exist and not VIO indicating a
transient disk i/o error or other transient internal inconsistency.
Simon Wilkinson [Sat, 11 May 2013 19:20:38 +0000 (20:20 +0100)]
Sort all libtool symbol lists
The original plan for the libtool symbol lists was that they be in
alphabetical order. This should make them easier to maintain, as it
becomes harder to accidentaly introduce duplicates, and makes merge
conflicts when adding new symbols less likely.
However, not all of them are properly sorted. Update the ones that
aren't. This was done with
for A in `find . -name *.la.sym`; do sort $A -o $A; done
Marc Dionne [Wed, 6 Mar 2013 00:38:34 +0000 (19:38 -0500)]
libafs: fix Afs_syscall definition for UKERNEL
For the UKERNEL case, Afs_syscall is prototyped and used as (void).
Make the function definition use the void keyword to avoid a warning
about an old style definition.
Remove the uafs_klog() apis from afs_usrops. Nothing uses it except
the obsolete afsweb stuff that isn't built anymore.
Stop linking in all kauth and pts components. Also remove some other
objects from libauth, rxkad, and com_err, that were only present as
dependencies of kauth and pts components
Marc Dionne [Sat, 25 May 2013 14:43:45 +0000 (10:43 -0400)]
volser: Adjust TLV tag range
Tag values up to D_MAX cannot be used as TLV tags, as the parsing
logic assumes anything up to D_MAX is a control tag. Adjust
MIN_TLV_TAG to 21 so that the TLV range sits just above D_MAX.
Dan van der Ster [Fri, 24 May 2013 08:12:14 +0000 (10:12 +0200)]
linux: remove linux osi_alloc hash stats
The bucket stat vector is maintained but never read. And it is
occasionally annoying since it can flood messages with
"afs_get_hash_stats: Warning! exceeded max bucket len ..."
Remove it.
Jeffrey Altman [Thu, 23 May 2013 20:57:21 +0000 (16:57 -0400)]
Windows: Return bytes_read count from cm_GetData
The existing interface for cm_GetData takes an input buffer and
a buffer size and no method by which the number of bytes read into
the buffer can be returned. Add an output parameter to permit it.
Andrew Deason [Mon, 13 May 2013 20:33:42 +0000 (15:33 -0500)]
DAFS: Avoid useless attach2 error message
Since commit 53230846a202a50f6c3a61b38d62ccba8876f89d, attach2 logs an
error when we force a volume to an error state due to attachment
errors. This is to ensure that we never end up with a volume in an
error state without logging a message about it.
However, while this is useful for the fileserver, for non-fileserver
programs this situation is very common for VNOVOL errors and does not
represent an actual problem. For the fileserver, nonexistent volumes
should be caught before we hit attach2 (in e.g. GetVolume when we
can't find a volume structure), so errors here can be significant and
should be rare. But for e.g. the volserver, when we try to use a given
volume id, we just try to attach it directly, so if the volume doesn't
exist, we will hit this code path.
This can happen pretty often for the volserver, since many volume
operations try to determine if a volume already exists by trying to
attach it. In those cases, this error message is pretty much useless
noise. So, get rid of it if we are non-fileserver, and the error we
got is VNOVOL. It is not as important for non-fileserver that we put a
volume in an error state, since volume states are much more transient
for non-fileserver programs, since the volume structs don't stay
around very long.
Michael Meffie [Mon, 13 May 2013 17:59:50 +0000 (13:59 -0400)]
vldb_check: print vlentry file offsets
To aid in debugging, consistently print the vlentry database "address"
and the file offset when displaying errors for vlentries. Print the
vlentry file offsets when printing all the entries with the -entries
option.
Marc Dionne [Wed, 24 Apr 2013 13:11:09 +0000 (09:11 -0400)]
linux: Fix leaked dentry reference in the revalidate op
In one error case, we exit the function without release the
reference on the parent dentry. This dangling reference can cause
an oops when the client is shut down.
Jeffrey Altman [Mon, 13 May 2013 14:09:11 +0000 (10:09 -0400)]
Windows: NotifyHardLink avoid null ptr reference
In AFSNotifyHardLink, if the TargetDirectoryCB out parameter is non-NULL
but pDirNode is NULL, do not attempt to increment the
DirOpenReferenceCount because doing so will trigger an exception.
Anders Kaseorg [Tue, 7 May 2013 04:27:33 +0000 (00:27 -0400)]
Linux: osi_TryEvictVCache: Don’t skip the first dentry if D_ALIAS_IS_HLIST
An hlist doesn’t begin with a sentinel like a list does, so the old
code would skip the first dentry or crash with a NULL dereference if
there wasn’t one. Use the kernel’s list_for_each_entry or
hlist_for_each_entry macros instead of trying to do it manually.
Should fix a crash observed by Alex Chernyakhovsky on kernel 3.6 and
newer.
Change-Id: I6d7bd190013a0250ca896af8d5182df55a3376b0 Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-on: http://gerrit.openafs.org/9857 Reviewed-by: Alex Chernyakhovsky <achernya@mit.edu> Tested-by: Alex Chernyakhovsky <achernya@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Marc Dionne <marc.c.dionne@gmail.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
it's claimed these are not initialized before use.
squelch compiler errors. has to be in parent as otherwise
we will zero them in our loop where we potentially want the
parent group id, which is not on "this" line as we add members.
A crash dump was examined which showed a deadlock due to the leak
of a SectionObjectResource in a code path in which the holding thread
could not have obtained it. The FileObject->FsContext2 (Ccb) pointer
referred to invalid memory which may have been due to pool corruption.
The only code path in which the SectionObjectResource is held exclusive
and then the Ccb pointer is used outside of a try-except block is in
AFSCleanup(). Move this reference inside the try-except block just in
case. If the Ccb is invalid, at least this way AFSRedirLib will catch
the exception and free the SectionObjectResource before continuing.
Change-Id: I08c9baacfc8897ae8d8b551a74976daf7effbcef
Reviewed-on: http://gerrit.openafs.org/9892 Reviewed-by: Peter Scott <pscott@kerneldrivers.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Jeffrey Altman [Thu, 9 May 2013 22:28:09 +0000 (18:28 -0400)]
Windows: AFSCommonWrite do not leak SectionObjectResource
If the write request is neither an extending write nor a non-cached
write and (liStartingByte.QuadPart + ulByteCount) >=
pFcb->Header.FileSize.QuadPart, then the SectionObjectResource pointer
will be leaked. Instead release it before retrying.
Change-Id: Id1ea7a3829a6e2be19280f366e665a11e14fba62
Reviewed-on: http://gerrit.openafs.org/9888 Reviewed-by: Peter Scott <pscott@kerneldrivers.com> Tested-by: BuildBot <buildbot@rampaginggeek.com> Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com> Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Marc Dionne [Thu, 9 May 2013 16:30:39 +0000 (12:30 -0400)]
ubik: Avoid use of freed string
If cellName was just set to dir->cellName, afsconf_Close() will
free the string before fprintf uses it. Just change the order
so we don't access freed memory and print garbage.
Jeffrey Altman [Wed, 8 May 2013 17:08:30 +0000 (13:08 -0400)]
Windows: only retry ALLBUSY for five minutes
Add a volbusyCount field to cm_req_t. Increment the count each time
CM_ERROR_ALLBUSY is processed by cm_Analyze for a given request.
Wait 15 seconds between retries and retry up to 20 times and then
fail. This prevents requests from blocking for a volume that isn't
going to come back online for hours.
Ben Kaduk [Thu, 28 Mar 2013 21:10:29 +0000 (17:10 -0400)]
FreeBSD: VOP_MMAP has been dead since 1996
Clang complains that our (K&R!) declaration of struct vop_mmap_args
will only be visible within the (empty) function.
With the kernel's CFLAGS, though, this is fatal.
Remove the dead code.
Jeffrey Altman [Mon, 6 May 2013 19:12:54 +0000 (15:12 -0400)]
Windows: AFSLibExFreePool*() macros
Introduce the AFSLibExFreePool() and AFSLibExFreePoolWithTag() macros
which simply call ExFreePool() and ExFreePoolWithTag().
The prefix AFSLib indicates that memory allocated by
AFSLibExAllocatePoolWithTag() must be freed before unloading.
AFSExFreePool*() cannot be used because that is a pointer to a
function provided by AFSRedir.sys which may not be assigned when
memory must be freed.
The only time that ExFreePool() should be used is if the memory was
allocated by a system function.
Jeffrey Altman [Mon, 6 May 2013 19:05:10 +0000 (15:05 -0400)]
Windows: Use AFSLibExAllocatePool for library local
If the memory allocation is for an object that must be freed before
the afsredirlib.sys driver unloads, use the AFSLibExAllocatePoolWithTag
interface. AFSExAllocatePoolWithTag allocates the memory from
afsredir.sys which prevents Verifier from being used to detect leaks.
Jeffrey Altman [Tue, 7 May 2013 22:36:16 +0000 (18:36 -0400)]
Windows: RDR_Initialize must cleanup threads on failure
If RDR_Initialize() fails after instantiating the worker thread
pool it must call RDR_ShutdownFinal() to destroy the pool before
exiting. Otherwise, the threads will spin endlessly as each
DeviceIoControl call to the redirector fails.
Jeffrey Altman [Mon, 4 Mar 2013 04:10:51 +0000 (23:10 -0500)]
Windows: CreateFile Reparse Point to File as File
Apply the Reparse Point to File as File Policy to CreateFile. If the
FILE_OPEN_REPARSE_POINT flag is specified to the CreateFile operation
and AFSIgnoreReparsePointToFile() returns TRUE, evaluate the target
object (if possible) and if the object is a FILE, then ignore the
FILE_OPEN_REPARSE_POINT flag. Otherwise, re-evaluate the request to
attempt to open a reparse point if it exists.
AFSIgnoreReparsePointToFile() is a helper routine that uses the
global reparse point policy to decide whether or not a reparse point
whose target is a file should be reported to applications as a file.
When per-AuthGroup or per-Process policy is supported, this function
should be modified.
pete scott [Wed, 27 Feb 2013 15:51:44 +0000 (08:51 -0700)]
Windows: IOCTL_AFS_SET_REPARSE_POLICY
IOCTL_AFS_SET_REPARSE_POLICY is a new ioctl that can be executed
by anyone to alter the behavior of AFS Symlink-to-File reparse point
processing. Policy can be set for a global default or for the active
authentication group. If the AFS_REPARSE_POINT_TO_FILE_AS_FILE policy is
active, afs symlinks will not be reported as reparse points if the symlink
target is known to be a file.
This patchset implements the ioctl but not the "reparse point to file as
file" functionality. Per authgroup policy setting is not permitted by the
ioctl but is not supported at this time.
Jeffrey Altman [Sat, 4 May 2013 15:56:30 +0000 (11:56 -0400)]
Windows: Report Case Sensitive Search
Return the FILE_CASE_SENSITIVE_SEARCH volume flag as part of afs
volume properties. NTFS does and our search algorithm is case
sensitive first, then case insensitive.
Jeffrey Altman [Fri, 3 May 2013 15:23:31 +0000 (11:23 -0400)]
Windows: Introduce CM_CONN_FLAG_NEW
The new CM_CONN_FLAG_NEW flag is set on the cm_conn object whenever
a new rx_connection has been created. The flag is cleared in cm_Analyze
if the call succeeded or if the error is one that is generated as a
result of communicating with the peer. If no communication with the
peer has taken place the connection is considered "new".
For errors that would result in forcing a new connection, check whether
the existing connection is already "new". This avoids an extra
RX_CALL_DEAD timeout period in the case where a "new" connection was
already in use.