doc: recommend cleanup steps in "vos convertROtoRW" man page

vos convertROtoRW leaves the older RW copy on the original fileserver,
although it is no longer in the VLDB. Provide the user with some hints
regarding clean up.

Change-Id: I5f6fcf7d5a516b59438d84e60f163a567d3a64fd
Reviewed-on: http://gerrit.openafs.org/9408
Reviewed-by: Ken Dreyer <ktdreyer@ktdreyer.com>
Tested-by: Ken Dreyer <ktdreyer@ktdreyer.com>
Fix buffer length validation in ktc_GetToken and knfs

The signed int tktLen is checked against a maximum size, then passed
as the unsigned size_t argument to memcpy.  So we need to make sure it
isn’t negative.

This doesn’t appear to be exploitable: tktLen comes from the kernel,
which should have previously validated the length within the SETTOK
pioctl.

This bug was found with STACK <http://css.csail.mit.edu/stack/>.

Change-Id: I781bd300cad3d725d3517e7f6ac9e6423c417087
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-on: http://gerrit.openafs.org/11109
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: RDR AFSSubtituteName invalid UNICODE_STRING

The 'ComponentName' parameter to AFSSubstituteName() is a UNICODE_STRING
pointer.  Its address should not be passed to AFSDbgTrace when used
in conjunction with a %wZ format.

Change-Id: I12ead951b1ae376e42da12b21e32f65e736375ab
Reviewed-on: http://gerrit.openafs.org/11090
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: Adjust Last Write time handling for -1

The "what date/time gets changed when and by whom" in Windows is badly
defined, but all filesystems support the semantic that if a date is set
using a specific file object (or the timestamp is set to the magic number
-1)
then other changes provoked by that file object will be ignored.

AFS redirector timestamp handling does not support this behavior.
For the LastWrite timestamp (other timestamps are pretty much advisory and
maintained on a best effort basis) the timestamp would be updated by a
write operation even after -1 is set via the file handle.

This patchset implements the -1 behavior for LastWrite.  It also follows
the standard Windows practice of setting the LastWrite timestamp to be the
time of close of the handle that performed the write, not the time of the
write itself.

Finally, it should be noted that since RX*FS_StoreXXX operations update
the last write time on the server the client must restore the LastWrite
timestamp at handle close if -1 was specified.

Change-Id: Ica0c566fabb6b3046eb51f827402d622190daea8
Reviewed-on: http://gerrit.openafs.org/11110
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
libafs: fix lock leak during shutdown

afs_getattr returns EIO when afs is in the process of shutting
down.  Be sure to unlock the locks taken before returning.
The bozon lock leak has been present since IBM AFS.

Change-Id: Id3e330c458996abf1519de6364060cc0b8828e6a
Reviewed-on: http://gerrit.openafs.org/11096
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: cm_Analyze retries vs CM_REQ_NORETRY (2)

Commit a1b5a1d42280753de13094006dcc130fede978a1 left out a critical
part of the patch.  The check for "retry < 2" when determining whether
retries should be skipped due to CM_REQ_NORETRY.

Change-Id: I9b750e2bab11d28813447b2ee92287b8dcfbbba3
Reviewed-on: http://gerrit.openafs.org/11131
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Linux: Prevent some fakestat data inconsistencies

When fakestat is enabled for a mount point, the parent vcache
entry is not the right place to find the DataVersion of
the target volume root directory.  This can lead to data
inconsistency since the revalidation checks rely on the parent's
DataVersion to determine if a file entry is still valid.  If the
file was replaced or deleted remotely, the only callback we
get is for the parent directory, and in that case the client
will think the file entry is still valid and give back stale
data to the user.

If fakestat is enabled and we have a mountpoint, always use
the parent vcache pointer returned by FakeStat before using it
to either store (in the lookup and create ops) or compare
(in the revalidate op) the DataVersion.

FIXES 131855

Change-Id: I03c05c1dab39e663b74635700e80ba70861b1c2e
Reviewed-on: http://gerrit.openafs.org/11118
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: D Brashear <shadow@your-file-system.com>
Add some configure bits for GSS-API

rxgk will require gss_pseudo_random and might want a couple other
krb5-specific bits.  We'll also need substvars to tell whether or
not we can try building these things.

Change-Id: Id18eb3f554605875696095eb40c25ec54df1f74b
Add rxgk boilerplate

Just the skeleton of what needs to be there.  The actual import is split
over multiple commits, to make the reviewer's burden more manageable.

Error table, protocol description, and stubs for the security object
routines, with header to declare them.

The public header rxgk.h currently only contains a few typedefs and the
NewSecurityObject prototypes, and includes the RPC interface and com_err
code headers.

Change-Id: I7893f78119bb4aef12112cc1e51e1ec69de326c2
Dummy Makefile for rxgk

Include a libtool export symbol list for the shared library, which
only has the client RPC calls and the NewFooSecurityObject primitives
for now, since that's all that's stubbed out.

Also connect the rxgk directory up to be buildable from the root, but
nothing depends on it yet so it will not be built.

Looking ahead, build a libafsrpc_rxgk.la object.

Change-Id: I12ddefbdaa1ad4845649e3a32efdeaaa21b5e9b7
Configure glue for rxgk

Add an --enable-rxgk switch to control whether the feature is used.
For now, just build the code as a dependency of finale, but we will
phase it in to other parts of the tree as appropriate.

We want to always build as much code as we can to benefit from the
automated build testing, so build rxgk if there is an appropriate
GSSAPI library available, but do not install anything unless the
configure argument was given.

Provide a symbol in afsconfig.h so that code using rxgk can be
conditionally compiled.

Change-Id: Iab661d47aac77c1a238e809362015b869752df18
Export a few krb5 routines for rxgk

We need oafs_h_krb5_generate_random_block when generating random
keys and oafs_h_krb5_crypto_fx_cf2 for CombineTokens.
Having oafs_h_krb5_crypto_prf_length proves very convenient for
key derivation of transport keys, so move it to the public header
and export it.
oafs_h_krb5_enctype_keysize is needed so that we can tell whether or not we
need to pass through random_to_key() when making rxgk_keys.
oafs_h_krb5_random_to_key is needed for that random_to_key() operation.

Change-Id: Ia34c8028b07df203b3885157e2d46c6bb512f608
Add rxgk_crypto_rfc3961.c

rxgk wrappers around an external crypto library, in this case, our
in-tree rfc3961 library.  Primitives for encryption/decryption and
MIC/VerifyMIC, ways to generate and free rxgk_key objects, etc..

Change-Id: I7525086043baf54f5c3019b3f5ab3495760c4236
Add RXGK_NOW()

A quick routine to get the current timestamp.

Change-Id: I0051b5c8e5ad61e35431d97454bf2741daba90cb
Export {Get,Set}ServiceSpecific from liboafs_rx.la

rxgk will use service-specific data.

Change-Id: Id9e2d4b9920e771e1583b9362e61de6216c246b4
Add rxgk_util.c

A few helper routines for the security class implementation, and
routines to set and retrieve a getkey function from rx service-specific
data.

Change-Id: I395802b6c3b2436df4b00906544fc797f3e12e9b
Add rxgk_token.c

Routines for constructing tokens (both regular and printed), extracting
and decrypting tokens, and helpers therein.

Provide the ability to print a token using a given session key and
using a random session key; the former is useful for certain variants
of localauth wherein a dummy GSS negotiation is performed with the
same identity acting as initiator and acceptor.

Change-Id: I0cde7fd0cdf9a27777523cd502b21bdccef41dcc
Add rxgk_gss.c

All the routines which deal with GSSAPI types.
This is, in practice, how the client gets a token, and the server
backend for GSSNegotiate().

These routines are split out into a separate file, and their prototypes
hidden behind ifndef KERNEL, because we need to allow rxgk to be usable
in the absence of a gssapi library, which is the case in the kernel.

Provide a compatibility definition of GSS_C_PRF_KEY_FULL, as there
are known implementations in the wild that provide the function but
do not provide the keyusage constants.

Change-Id: Id2966de07853dd6a74cb40225851728d2422421c
Implement SRXGK_GSSNegotiate()

In-kernel we must fail; the userspace implementation is already
in the tree in rxgk_gss.c.

Change-Id: Id715e3287df5921a20aebe4e65259fd2097dc2b4
Add rxgk_packet.c

Routines to apply and verify encryption and MICs to the data in
rx packets.  Backend to the rxgk_crypto framework for the actual
crypto operations.

Change-Id: I724efacf7df1d688c0d61a327fa9ee9c8168d715