openafs.git
4 years agorxgk: Add NTMakefile to install headers 14/13814/4
Andrew Deason [Mon, 26 Aug 2019 19:34:45 +0000]
rxgk: Add NTMakefile to install headers

Commit 83eec909 (Implement afsconf_GetRXGKKey) added a reference to
rx/rxgk_types.h inside cellconfig.p.h. Nothing ever added src/rxgk
WINNT makefiles, so that include file is never installed into
place, breaking the WINNT build when code tries to include
cellconfig.h.

To fix this and other code that needs rxgk header files, create an
NTMakefile for src/rxgk, which just exists to install headers into
place. Call it from the top-level NTMakefile right before copying in
the auth headers.

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

4 years agorx: Avoid leaking 'sq' in libafs rx_GetCall 15/13715/4
Andrew Deason [Mon, 22 Jul 2019 02:15:11 +0000]
rx: Avoid leaking 'sq' in libafs rx_GetCall

Currently, in rx_GetCall when building for the kernel, if we notice
that we're shutting down (that is, if afs_termState has reached
AFSOP_STOP_RXCALLBACK), we return immediately. However, 'sq' may have
been allocated much earlier in this function, and if we return here,
we never free 'sq' or set it on any list.

Returning immediately is also unnecessary here; if we just 'break' out
of our wait loop, 'call' will still be NULL, and we'll break out of
the outer loop, and go through the rest of the function like normal.
The only difference is, if we 'break' instead of 'return'ing, we'll
put 'sq' on the free list before returning.

So, just 'break' out of the loop instead of returning, so we put 'sq'
on the free list and avoid leaking its memory.

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

4 years agoWINNT: Build bubasics before audit 13/13813/3
Andrew Deason [Mon, 26 Aug 2019 18:13:28 +0000]
WINNT: Build bubasics before audit

Commit 9ebff4c6 (OPENAFS-SA-2018-001 audit: support butc types) made
src/audit require the butc.h header, and updated Makefile.in to
reflect this. However, this dir is also built on WINNT, and the
NTMakefile was not updated to reflect this dependency. As a result, we
might fail to build src/audit on WINNT, since butc.h may not exist
yet, and we get an error like:

            cl [...] /c audit.c
    audit.c
    cl : Command line warning D9025 : overriding '/W4' with '/W3'
    audit.c(27) : fatal error C1083: Cannot open include file: 'afs/butc.h': No such file or directory
    NMAKE : fatal error U1077: 'C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.EXE' : return code '0x2'

To fix this, move 'bubasics' to be made before 'audit' in NTMakefile,
so butc.h is available when we build 'audit'.

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

4 years agoafs: Introduce afs_FreeFirstToken 07/13807/3
Andrew Deason [Wed, 21 Aug 2019 17:04:45 +0000]
afs: Introduce afs_FreeFirstToken

Change afs_FreeOneToken to unlink the given token from its container,
instead of requiring its caller to do so. Rename the function to
afs_FreeFirstToken, to help indicate the change in behavior.

Also, while we are changing afs_FreeTokens to accommodate this change,
simplify afs_FreeTokens a little, making it resemble
afs_DiscardExpiredTokens a bit more.

[kaduk@mit.edu: add note about dead store elimination]

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

4 years agoFBSD: Use ucontext for FreeBSD 10+ on amd64 91/13691/5
Andrew Deason [Sun, 14 Jul 2019 22:31:30 +0000]
FBSD: Use ucontext for FreeBSD 10+ on amd64

Currently, running any LWP program on recent FreeBSD on amd64 causes
(or can cause) a SIGBUS very quickly. This is possibly because our
stack management code in LWP only ensures our stacks are 4 or 8-byte
aligned in most cases (except DARWIN, which gets 16-byte-aligned
stacks), according to the value of STACK_ALIGN. The amd64 ABI mandates
that stacks be 16-byte-aligned, and some function calls assume that
this is followed, causing a SIGBUS when it is not. FreeBSD on amd64
currently uses process.amd64.s for its savecontext() implementation,
which does not do any checking or fixup of the stack alignment.

This behavior has been observed on amd64 with FreeBSD 11 specifically,
but it probably happens on any FreeBSD release when using clang.
FreeBSD switched to clang as the default compiler with FreeBSD 10, so
this probably occurs with FreeBSD 10 and newer.

We could perhaps try to fix this by changing our stack management
code, but we can also avoid most of this nonsense by just using
ucontext instead of our custom assembly code. So, do that, by setting
USE_UCONTEXT for FreeBSD 10+. Also enable the same 'stackvar'-based
workaround in savecontext() as Linux uses, since otherwise 'topstack'
appears to always be NULL, and triggers our stack overflow checks.

Note that while LWP use is deprecated, as of this commit many small
utilities (like 'fs') are still linked to LWP, and so are unusable
without a fix like this.

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

4 years agoFBSD: Set KERNBUILDDIR for --with-bsd-kernel-build 46/13746/4
Andrew Deason [Sun, 28 Jul 2019 20:03:43 +0000]
FBSD: Set KERNBUILDDIR for --with-bsd-kernel-build

Currently, specifying --with-bsd-kernel-build during configure causes
us to set BSD_KERNEL_BUILD, which sets KBLD in MakefileProto.FBSD.in,
but nothing ever uses KBLD. This means that when we use
--with-bsd-kernel-build, we don't actually build against the
configuration for that kernel, which can result in a libafs.ko that
cannot be loaded or causes other errors. Specifically, if trying to
build for a VIMAGE kernel, the kernel complains when trying to load
libafs:

    [...] kernel: link_elf_obj: symbol in_ifaddrhead undefined
    [...] kernel: linker_load_file: Unsupported file type

The FreeBSD module build system looks for KERNBUILDDIR for an
alternative build, which it uses to pull in opt_global.h and other
required pieces from the build tree. So just specify KERNBUILDDIR if
we have one.

At the same time, avoid setting our default value for BSD_KERNEL_BUILD
for FBSD when the calculated dir doesn't exist. At least for the
default GENERIC kernel on FreeBSD 11.2-RELEASE, there may not be a
build dir on the running machine, and so setting BSD_KERNEL_BUILD to
the calculated value causes the build to fail when it doesn't exist.

Change-Id: Ib3079354f9f6dba13970de5308bbcecaf9b35059
Reviewed-on: https://gerrit.openafs.org/13746
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoFBSD: Call CURVNET_SET/CURVNET_RESTORE for VIMAGE 80/12580/6
Tim Creech [Sun, 5 Mar 2017 23:18:01 +0000]
FBSD: Call CURVNET_SET/CURVNET_RESTORE for VIMAGE

In commit 9703b023 (FBSD: VIMAGE support), we changed a couple of our
variable references to their V_* equivalents, to accommodate kernels
with VIMAGE turned on. This allows us to build, but causes us to crash
whenever we hit that code when VIMAGE is enabled, because the relevant
macros reference 'curvnet', which is NULL outside of networking code.

What we're supposed to do is to set 'curvnet' before entering
networking code by calling 'CURVNET_SET(xxx)', and reset it afterwards
by calling 'CURVNET_RESTORE()'. We must make exactly one _RESTORE call
for each _SET, and they are supposed to be run at the same level of
scope.

So to avoid the crashes, make the relevant CURVNET_* calls whenever we
look at networking info. We currently only do this in a few places:

- In afs_SetServerPrefs, to try to detect if a given server address is
  in the same network as one our local interfaces (V_in_ifaddrhead)

- In rxi_GetIFInfo, for some MTU-related info (V_ifnet)

- In rxi_FindIfnet, for some MTU-related info (ifa_ifwithnet)

As for what vnet we actually set 'curvnet' to, we could set it to the
vnet of the current thread (TD_TO_VNET(curthread)), or we could set it
to the vnet of an associated network object (a socket, an interface,
etc). Since all of our network-related code goes through Rx, in this
commit we set curvnet to the vnet of the Rx socket
(rx_socket->so_vnet).

Note that VIMAGE is optional in 11-RELEASE, but is turned on by
default in 12.0-RELEASE. For more information, see:
https://wiki.freebsd.org/VIMAGE/porting-to-vimage

[adeason@dson.org: Reworded commit message; moved some code around.]

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

4 years agoafs: Update style in afs_tokens.c 06/13806/2
Andrew Deason [Wed, 21 Aug 2019 16:48:53 +0000]
afs: Update style in afs_tokens.c

Fix a few style nits and other minor edits in afs_tokens.c. Mark a few
functions 'static' that are not referenced outside of that file.

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

4 years agorx: Update style in rx_opaque.c 05/13805/2
Andrew Deason [Wed, 21 Aug 2019 17:37:06 +0000]
rx: Update style in rx_opaque.c

Fix a few style nits in rx_opaque.c

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

4 years agoRemove dead code 83/13683/7
Andrew Deason [Wed, 10 Jul 2019 20:14:28 +0000]
Remove dead code

There is a perhaps-surprisingly large amount of code disabled behind
directives like '#if 0', '#ifdef notdef', and '#ifdef notyet'. At
best, this code is clutter, and at worst some of it is
confusing/outdated, and/or confusingly nested inside other
preprocessor conditionals. Sometimes this disabled code shows up when
grepping the tree, and causes a nuisance when refactoring related
areas of code.

Get rid of all of it. If anyone ever wants this code back, it can
always be restored by reverting portions of this commit.

Also delete some comments that clearly refer to the disabled code, and
in some cases, adjust the adjacent comments to make sense accordingly.

This commit doesn't touch any files in src/external/.

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

4 years agoRemove a couple more uses of libafsauthent.a 95/11095/5
Benjamin Kaduk [Sat, 12 Apr 2014 21:24:04 +0000]
Remove a couple more uses of libafsauthent.a

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

4 years agoLINUX: Make sysctl definitions more concise 00/13700/5
Andrew Deason [Fri, 19 Jul 2019 03:56:48 +0000]
LINUX: Make sysctl definitions more concise

Our sysctl definitions are quite verbose, and adding new ones involves
copying a bunch of lines. Make these a little easier to specify, by
defining some new preprocessor macros.

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

4 years agoLINUX: Honor --enable-checking for libafs 82/13682/7
Andrew Deason [Wed, 10 Jul 2019 17:42:54 +0000]
LINUX: Honor --enable-checking for libafs

When we build the kernel module on LINUX, we don't pass in any of our
CFLAGS, since the Linux buildsystem itself figures out what flags are
needed. However, this means that we don't pass in -Werror when
--enable-checking is turned on, so warnings may not cause the build to
fail.

To fix this, create a new autoconf variable, called CFLAGS_WERROR,
that only contains -Werror if --enable-checking is turned on. We then
pass that into the Linux module buildsystem, so -Werror is given to
the compiler when building our module.

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

4 years agoafs: Free afs_thiscell during shutdown 14/13714/3
Andrew Deason [Mon, 22 Jul 2019 00:21:44 +0000]
afs: Free afs_thiscell during shutdown

Currently, afs_thiscell can be allocated (via strdup) during client
startup, but is never freed. Free it in shutdown_cell() to avoid
leaking the memory.

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

4 years agoafs: Introduce shutdown_dynroot() 13/13713/3
Andrew Deason [Sun, 21 Jul 2019 22:58:48 +0000]
afs: Introduce shutdown_dynroot()

Add a shutdown sequence for dynroot, which frees the afs_dynrootDir
and afs_dynrootMountDir blobs, if they exist. Otherwise, we can leak
the memory allocated for those blobs.

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

4 years agoFBSD: Remove unnecessary explicit osi_fbsd_alloc 08/13708/3
Andrew Deason [Mon, 15 Jul 2019 03:53:39 +0000]
FBSD: Remove unnecessary explicit osi_fbsd_alloc

AFS_KALLOC is already defined to be osi_fbsd_alloc on FBSD, so this
extra #ifdef here is completely unnecessary. Remove it.

Do the same for AFS_KFREE/osi_fbsd_free.

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

4 years agoFBSD: Give 0 'rootrefs' to vflush on unmount 09/13709/4
Andrew Deason [Sun, 21 Jul 2019 04:09:27 +0000]
FBSD: Give 0 'rootrefs' to vflush on unmount

Currently, in afs_unmount, we give vflush a 'rootrefs' arg of 1,
indicating that we hold 1 reference on the root vnode. But ever since
commit 6eb1088a (freebsd: properly track vcache references), we drop
the ref for the root vnode at the beginning of this function.

What happens currently in afs_unmount for a normal successful umount
is something like this (at least, on FreeBSD 11.2-RELEASE):

- We afs_PutVCache the afs_globalVp vcache, reducing its v_usecount
  and v_holdcnt to 0, and afs_globalVp is set to NULL.

- vflush calls afs_root() to get the root vnode, which sees that
  afs_globalVp is NULL, and so calls afs_GetVCache for the root fid
  and returns it (and sets afs_globalVp to that vcache), with a
  v_usecount of 1.

- vflush tries to vgonel() all of our vnodes, which calls our
  afs_vop_reclaim, which calls afs_FlushVCache(). For the root vnode
  specifically, vflush() sees that v_usecount is nonzero, and so skips
  calling vgonel() at first, but later calls vgone() on it
  specifically because we gave a nonzero 'rootrefs'. The resulting
  afs_FlushVCache() for the root vnode fails, because the root vnode's
  v_usecount is still 1. Since a failure from afs_vop_reclaim would
  cause a panic, we just log a warning and try to continue on anyway.

- vflush() calls vrele() on the root vnode, right before returning.

All of this allows the unmount to proceed, but this means that most of
afs_FlushVCache() doesn't actually run for the root vcache, and it
means we always log a warning like this on unmount:

    afs_vop_reclaim: afs_FlushVCache failed code 16 [...]

In addition, this means that setting afs_globalVp at the beginning of
afs_unmount() is largely pointless, since it gets set to a vcache
again near the beginning of vflush().

To avoid all of this, stop lying to vflush about how many references
to the root vnode we hold, and just say that we hold 0 references.

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

4 years agoFBSD: Handle F_UNLCK in VOP_ADVLOCK 79/12579/4
Tim Creech [Sun, 5 Mar 2017 23:17:23 +0000]
FBSD: Handle F_UNLCK in VOP_ADVLOCK

When a_fl->type is F_UNLCK, FreeBSD gives our VOP_ADVLOCK an a_op of
F_UNLCK, instead of F_SETLK like we expect. This causes afs_lockctl to
return EINVAL, since F_UNLCK isn't a normal fcntl lock op, and so
userspace requests to unlock fcntl-style locks always fail. This can
be seen, for example, when trying to use sqlite3 to access a database
that lives in afs.

This F_UNLCK behavior in FreeBSD seems a bit peculiar, but has been
around effectively forever (since 4.4BSD-Lite). So just work around
it.

[adeason@dson.org: minor style adjustments and commit message/comment
rewording.]

Change-Id: I8bfaff9274e40761aa291930430a08b83b524d1b
Reviewed-on: https://gerrit.openafs.org/12579
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoafs: Fix a few ARCH/osi_vcache.c style errors 99/13699/4
Andrew Deason [Mon, 15 Jul 2019 21:24:10 +0000]
afs: Fix a few ARCH/osi_vcache.c style errors

Most of the ARCH/osi_vcache.c implementations were defining functions
like:

void
osi_foo(args) {
    /* impl */
}

But our prevailing style is:

void
osi_foo(args)
{
    /* impl */
}

Fix them to follow our prevailing style, and fix a couple of the more
obvious errors with identation and goto label.

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

4 years agoafs: Check for invalid afs_fakestat_enable values 98/13698/5
Andrew Deason [Mon, 15 Jul 2019 22:51:41 +0000]
afs: Check for invalid afs_fakestat_enable values

The only valid values for afs_fakestat_enable right now are 0, 1, and
2. Check if the given value actually matches one of those, in case we
have mismatched libafs/afsd versions, and future code adds new values.

Return EINVAL and log a message if we're given an unknown value.

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

4 years agoLINUX: Turn on AFS_NEW_BKG 84/13284/7
Andrew Deason [Tue, 14 Aug 2018 20:54:29 +0000]
LINUX: Turn on AFS_NEW_BKG

AFS_NEW_BKG allows libafs to request the afsd background daemon
processes to do certain userspace operations. This is currently only
used on DARWIN for handling EXDEV file moves, but this framework can
be useful on LINUX, as well. So, turn it on for LINUX.

This commit does not introduce any new background operations for LINUX
to actually use; we're just turning on the new framework. Future
commits will introduce new background operations.

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

4 years agoafs: Remove reference to nonexistent function 97/13697/4
Andrew Deason [Wed, 10 Jul 2019 21:24:11 +0000]
afs: Remove reference to nonexistent function

The real lie here is that TellALittleWhiteLie exists in afs_vcache.c.
That has never been true, ever since OpenAFS 1.0.

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

4 years agoafs: Remove useless afs_GetVCache arguments 81/13681/7
Andrew Deason [Wed, 10 Jul 2019 17:42:44 +0000]
afs: Remove useless afs_GetVCache arguments

The 'avc' argument in afs_GetVCache has never been used, all the way
back to OpenAFS 1.0. The 'cached' argument was set correctly, but none
of its callers ever looked at the result of 'cached'. Remove these
useless arguments.

afs_LookupVCache and afs_GetRootVCache also had the same 'cached'
argument, which was also never used by callers. Remove it for those,
as well.

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

4 years agoLINUX 5.3.0: Use send_sig instead of force_sig 53/13753/7
Cheyenne Wills [Fri, 9 Aug 2019 20:25:03 +0000]
LINUX 5.3.0: Use send_sig instead of force_sig

Linux 5.3.0 commit 3cf5d076fb4d48979f382bc9452765bf8b79e740 "signal
Remove task parameter from force_sig" (part of siginfo-linus branch)
changes the parameters for the Linux kernel function force_sig. See LKML
thread starting at https://lkml.org/lkml/2019/5/22/1351

According to the LKML discussion and the above commit message force_sig
is only safe to deliver a synchronous signal to the current task. To
send a signal to another task, we're supposed to use send_sig instead,
which has been available since at least linux 2.6.12-rc12.

Currently, rx_knet calls force_sig to kill the rxk_ListenerTask.  With
the Linux 5.3.0 kernel, this module fails to compile due to the above
noted changes.

Replace the force_sig call with send_sig.  In order to use send_sig, the
rxk_listener thread must allow SIGKILL and during shutdown (umount)
SIGKILL must be unblocked for the rxk_listener thread.

Note that SIGKILL is initially blocked on rxk_listener and is only
unblocked when shutting down the thread.  Having the signal blocked is
sufficient to prevent unwanted signals from reaching the rxk_listener
thread during normal operation.

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

4 years agoLINUX 5.3.0: Check for 'recurse' arg in keyring_search 52/13752/3
Cheyenne Wills [Thu, 8 Aug 2019 22:53:13 +0000]
LINUX 5.3.0: Check for 'recurse' arg in keyring_search

Linux 5.3.0 commit dcf49dbc8077e278ddd1bc7298abc781496e8a08 "keys: Add a
'recurse' flag for keyring searches" adds a new parameter to
Linux kernel keyring_search function.

Update the call to keyring_search to include the recurse parameter if
available. Setting the parameter to true (1) maintains the current
search behavior.

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

4 years agorxkad: ticket5.c fix typo in #if statement 54/13754/2
Cheyenne Wills [Thu, 8 Aug 2019 18:07:51 +0000]
rxkad: ticket5.c fix typo in #if statement

commit 98ca332c4a5ac9e5687fb4fe21b350134bc74d1b (rxkad: v5der.c format
truncation warnings) contains a typo in the test for clang (_clang
instead of __clang__)

Correct the typo in the #if statement to test for __clang__

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

4 years agoLINUX: Disable kernel fortuna large frame errors 84/13684/4
Andrew Deason [Thu, 11 Jul 2019 04:40:55 +0000]
LINUX: Disable kernel fortuna large frame errors

The rand-fortuna.c we get from Heimdal's hcrypto currently sometimes
causes a warning on LINUX when building in the kernel, because
fortuna_reseed() has a (potentially) large stack size:

.../src/libafs/MODLOAD-.../rand-fortuna-kernel.c:549:1: error: the frame size of 1032 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]

Currently this does not cause the build to fail, even with
--enable-checking, since -Werror is not given in the CFLAGS when
building our kernel module. But if -Werror is passed in CFLAGS (in a
future commit), this would cause the build to fail.

Since this is an external source file, we cannot change it directly.
At least for now, just prevent this warning from breaking the build by
passing -Wno-error=frame-larger-than= into the CFLAGS for that file.

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

4 years agorestorevol: replace snprintf with asprintf 94/13494/11
Cheyenne Wills [Fri, 2 Aug 2019 16:31:13 +0000]
restorevol: replace snprintf with asprintf

GCC is generating format-truncations warnings. With newer levels of gcc
(e.g. gcc8) and --checking-enabled these warnings result in errors and
failed builds.  In addition clang8 static analysis tools are reporting
memory leaks.

Replace snprintf with asprintf and eliminate some of the large work
buffers that are being placed on the stack. In order to correct some of
the format-truncation errors the size of the buffers grew significantly
(e.g. gcc is reporting the need to resize some of the buffers from 256
bytes to 4K in order to eliminate the warnings).

Ensure allocated work buffers are freed before function return.

Obtained a clean build with gcc9/clang8 with --enable-checking and a
clean scan-build report with clang8.

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

4 years agoafs: Skip IsDCacheSizeOK for CDirty/VDIR 47/13747/2
Andrew Deason [Mon, 29 Jul 2019 23:17:21 +0000]
afs: Skip IsDCacheSizeOK for CDirty/VDIR

IsDCacheSizeOK currently can incorrectly flag a dcache as corrupted,
since the size of a dcache may not match the size of the underlying
file in a couple of RW conditions:

- If someone is writing to a file beyond EOF, the intermediate
  'sparse' area may be populated by 0-length dcaches until the data is
  written to the fileserver.

- Directories may be modified locally instead of being fetched from
  the fileserver, which can sometimes result in a directory blob of
  differing sizes.

To avoid false positives detecting dcache corruption, just skip the
IsDCacheSizeOK check for directories, and any file with pending writes
(CDirty).

Also add some extra information to the logging messages when this
"corruption" is detected, so false positives may be more easily
detected in the future.

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

4 years agogtx: Avoid incomplete function type in casts 26/13726/2
Cheyenne Wills [Fri, 26 Jul 2019 20:57:02 +0000]
gtx: Avoid incomplete function type in casts

clang complains that these casts contain an incomplete function type
(since the function argument is omitted rather than declared to be
void).  Since we just need the cast to pointer type, let the compiler
do it implicitly and pass stock NULL, rather than trying to force a
cast to function-pointer type.

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

4 years agoLINUX: Avoid re-taking global lock in afs_dentry_iput 25/13725/3
Yadavendra Yadav [Fri, 26 Jul 2019 14:29:25 +0000]
LINUX: Avoid re-taking global lock in afs_dentry_iput

“dput” function internally can call dentry_iput which  results in
calling afs_dentry_iput. So in case before calling “dput” if global lock
was held then when afs_dentry_iput is called it will again try to lock
global lock and will result in deadlock scenario.  So to avoid this
deadlock make sure if global lock is already taken before calling
afs_dentry_iput, don’t try to lock it again.  This issue was partially
fixed in commit 0dac4de8 (Linux: drop GLOCK before calling dput)

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

4 years agobuild: fix --enable-rxgk help format 22/13722/2
Michael Meffie [Wed, 24 Jul 2019 15:39:43 +0000]
build: fix --enable-rxgk help format

Move the dnl macros out of the AC_ARG_ENABLE to fix the
formatting of the --enable-rxgk help string.

Before this commit:

  $ ./configure --help | grep -C2 rxgk

    --enable-kauth          install the deprecated kauth server, pam modules,
                            and utilities (defaults to disabled)
        --enable-rxgk           Include experimental support for the RXGK security
                            class (defaults to disabled)
    --disable-strip-binaries

After this commit:

  $ ./configure --help | grep -C2 rxgk

    --enable-kauth          install the deprecated kauth server, pam modules,
                            and utilities (defaults to disabled)
    --enable-rxgk           Include experimental support for the RXGK security
                            class (defaults to disabled)
    --disable-strip-binaries

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

4 years agoptserver: testpt.c format-overflow warning 63/13663/8
Cheyenne Wills [Tue, 2 Jul 2019 22:58:28 +0000]
ptserver: testpt.c format-overflow warning

GCC 9 introduced new warnings/errors and is flagging a sprintf with a
format-overflow warning.  With --checking-enabled, this error is causing
testpt.c to fail during compile.

Change the buffer size from 16 bytes to PR_MAXNAMELEN+1 and use snprintf
instead of sprintf. Generate an error message and exit if snprintf
truncates the string.

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

4 years agouss: uss_procs.c format-overflow warning 64/13664/8
Cheyenne Wills [Fri, 26 Jul 2019 13:59:33 +0000]
uss: uss_procs.c format-overflow warning

GCC 9 introduced new warnings/errors and is flagging a sprintf with a
format-overflow warning.  With --checking-enabled, this error is causing
uss_procs.c to fail during compile.

A file name with the full path is being composed and the size of the
buffer was triggering a possible format-overflow warning/error.

Use asprintf to allocate the buffer dynamically instead of using a
buffer sitting on the stack (reducing the stack requirements by 2K).

Produces new error message if asprintf returns an error.

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

4 years agoptserver: Incorrect variable used to print error msg 62/13662/8
Cheyenne Wills [Tue, 25 Jun 2019 21:39:40 +0000]
ptserver: Incorrect variable used to print error msg

In testpt.c the variable cdir is used to print the name of the temporary
dir.  However at this point in the code cdir is NULL and the variable
tmp_conf_dir contains the actual name that should be used in the error
message.

Flagged as an error when --enable-checking is on and using GCC 9.

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

4 years agorxkad: v5der.c format truncation warnings 61/13661/13
Cheyenne Wills [Mon, 15 Jul 2019 14:38:24 +0000]
rxkad: v5der.c format truncation warnings

GCC 7 is producing new warnings due to better compile time analysis.
With --enable-checking v5der.c is failing with 2 errors due to possible
format-truncation in some snprintf calls.  The format strings are being
used to format a date and time values from a tm structure.

The actual warnings/errors are being triggered from arithmetic being
performed on the year and month members of the structure. The resulting
values should not exceed the format lengths, but the compilers are still
flagging the statements.

v5der.c is part of the heimdal package that is pulled into the openafs
source tree.  v5der.c is not compiled directly but is #included in
ticket5.c

Update ticket5.c to change the severity of the format-truncation
diagnostic to a warning if using GCC 7 (or higher).

Note: since v5der.c is pulled from an external source (heimdal), any
changes to update v5der.c directly would need to be performed upstream.

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

4 years agoaklog: require opt-in to enable single-DES in libkrb5 89/13689/2
Benjamin Kaduk [Fri, 12 Jul 2019 04:07:35 +0000]
aklog: require opt-in to enable single-DES in libkrb5

Since the introduction of rxkad-k5 in response to OPENAFS-SA-2013-003,
it is not strictly necessary to configure libkrb5 to allow weak crypto
in order to obtain an AFS token.  A sufficient amount of time has passed
since then that it is safe to assume that the default behavior is the
more-secure one, and require opt-in for the insecure behavior.

To indicate that the use of single-DES is quite risky, add the
"-insecure_des" argument to both klog and aklog, to gate the
preexisting calls that enable weak crypto/single-DES.
These calls, and the -insecure_des option, may be removed entirely
in a future commit.

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

4 years agoafs: Avoid non-dir ENOENT errors in afs_lookup 37/13537/6
Andrew Deason [Mon, 25 Mar 2019 21:33:39 +0000]
afs: Avoid non-dir ENOENT errors in afs_lookup

Historically, there have been many subsystems in libafs that can
generate ENOENT errors for a variety of reasons. In addition to the
expected case where we lookup a name that doesn't exist, other
scenarios have caused ENOENT error codes to be generated, such as:
internal inconsistencies, I/O errors, or even abort codes from the
network.

When one of these scenarios cause an ENOENT error code in one of those
situations during afs_lookup() when the target name does actually
exist, it can be confusing to a user, or even result in incorrect
application behavior. On Linux in particular, ENOENT results from a
lookup are cached in negative dcache entries, and so can cause future
lookups for the same name to yield ENOENT errors.

Various commits have tried to avoid this abuse of the ENOENT error
code, such as 2aa4cb04 (afs: Stop abusing ENOENT). But we cannot
prevent receiving ENOENT abort codes from the network, and mistakes in
the future may cause more scenarios incorrectly yielding ENOENTs.

However, in afs_lookup, we do know that legitimate ENOENT errors can
only occur in one situation: when we have a valid directory blob, and the
afs_dir_Lookup() operation itself returns an ENOENT error for the
target name. For all other areas of afs_lookup(), we know that an
ENOENT error is not legitimate, since we may not be sure if the target
name exists or not.

So to proactively avoid incorrect ENOENT results, prevent afs_lookup
from returning ENOENT, except in the specific code path where
afs_dir_Lookup is called.

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

4 years agoLINUX: Minor osi_vfsop.c cleanup 82/13282/6
Andrew Deason [Wed, 25 Jul 2018 04:22:01 +0000]
LINUX: Minor osi_vfsop.c cleanup

- Fix the formatting on afs_mount/afs_get_sb definitions

- Declare a couple of functions static that are not referenced outside
  of this file

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

4 years agoafs: Add AFS_USPC_SHUTDOWN bkg request 81/13281/7
Andrew Deason [Tue, 14 Aug 2018 20:53:20 +0000]
afs: Add AFS_USPC_SHUTDOWN bkg request

When AFS_NEW_BKG was added, the kernel module indicated to the
relevant afsd process that it's time to shutdown by returning -2. This
works on DARWIN, but it's difficult to make this work on all
platforms, because of the different way that platforms handle error
codes from our pioctls and other AFS syscalls.

Specifically, on LINUX, negative error codes are assumed to be
negative errno codes, and so returning -2 from the syscall handler
means we return -1 to userspace, with errno set to 2 (ENOENT).

Getting this to work consistently across platforms is probably more
trouble than its worth, so instead of relying on specific return codes
from the syscall, just add a new background daemon operation called
AFS_USPC_SHUTDOWN, which just tells the background daemon to exit.

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

4 years agolibadmin: overlap warning in strcpy with gcc9 60/13660/8
Cheyenne Wills [Fri, 5 Jul 2019 14:23:10 +0000]
libadmin: overlap warning in strcpy with gcc9

GCC 9 with --enable-checking produces a new warning/error in
afs_utilAdmin.c associated with a strcpy with the potential of an
overlap.  The index used is signed which triggers the new warning. The
source and target of the strcpy are contained within the same higher
level structure.

Change the variable 'index' from signed to unsigned to resolve the
warning/error. Change the variable 'total' in the same structure to
unsigned to be consistent with it's usage with 'index'.

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

4 years agoafs: Check dcache size when checking DVs 36/13436/7
Andrew Deason [Thu, 17 Jan 2019 22:21:25 +0000]
afs: Check dcache size when checking DVs

Currently, if the dcache for a file has nonsensical length (due to
cache corruption or other bugs), we never notice, and we serve
obviously bad data to applications. For example, the vcache metadata
for a file may say the file is 2k bytes long, but the dcache for that
file only has 1k bytes in it (or more commonly, 0 bytes).

This situation is easily detectable, since the dcache and vcache refer
to the same version of the same file (when the DVs match), and so we
can check if the two lengths make sense together. So to avoid giving
bad data to userspace applications, perform a sanity check on the
lengths at the same time we check for DV matches (to see if the dcache
looks "fresh" and not stale). If the lengths do not make sense
together, we just pretend that the dcache is old, and so we'll ignore
it and fetch a new copy from the fileserver.

Also check the size of the data fetched from the fileserver for a
newly-fetched dcache in afs_GetDCache, to avoid returning a bad dcache
if the dcache isn't already present in the cache.

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

4 years agoLINUX: Unlock page on afs_linux_read_cache errors 72/13672/4
Andrew Deason [Wed, 3 Jul 2019 17:55:53 +0000]
LINUX: Unlock page on afs_linux_read_cache errors

When afs_linux_read_cache is called with a non-NULL task, it is
responsible for unlocking 'page' (unless it's unlocked in a background
task), even if we encounter an error. Currently we almost always do
unlock the given page for a non-NULL task, but if we manage to hit one
of the codepaths that 'goto out', we skip over the unlock_page() call
near the end of the function, and the page never gets unlocked.

As a result, the page stays locked forever. That generally means any
future access to the same file will block forever, and when we try to
flush the relevant vcache, we will block waiting for the page lock
while holding GLOCK. (This can happen via the background daemon via
e.g. afs_ShakeLooseVCaches -> osi_TryEvictVCache -> afs_FlushVCache ->
osi_VM_FlushVCache -> vmtruncate -> ... -> truncate_inode_pages_range
-> __lock_page on Linux 2.6.32-754.2.1.el6.) This quickly brings the
whole client to a halt until the machine can be forcibly rebooted.

To solve this, just move the 'out:' label to before the page unlock.
Add a few locking-related comments around the relevant code to help
explain some relevant details.

The relevant code has changed and been refactored over the years, but
this problem has probably existed ever since this code was originally
converted to using the readpage() of the underlying cache fs, in
commit 88a03758 (Use readpage, not read for fastpath access).

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

4 years agoafs: Introduce afs_IsDCacheFresh 35/13435/5
Andrew Deason [Thu, 17 Jan 2019 21:45:36 +0000]
afs: Introduce afs_IsDCacheFresh

Numerous places in libafs check the DV of a dcache against the DV of
the vcache for the same file, in order to check if the dcache is up to
date and can be used. Consolidate all of these checks into a new
function, afs_IsDCacheFresh, to make it easier for future commits to
alter this logic.

This commit should have no visible impact; it is just code
reorganization.

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

4 years agoafscp: Add -l option 57/13657/3
Andrew Deason [Thu, 15 Nov 2018 18:37:16 +0000]
afscp: Add -l option

Add the -l option to afscp, to "loop" the given FetchData/StoreData
request over and over.

When using this mode, we alternate between using a couple of rx calls,
to avoid getting slowed down by rx BUSY packets when we start a new
call on the same channel too quickly.

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

4 years agoauth: make PGetTokens2 work with 3-char cellnames 99/13599/4
Mark Vitale [Thu, 23 May 2019 02:50:00 +0000]
auth: make PGetTokens2 work with 3-char cellnames

PGetTokens2 accepts two different types of input:
- an integer 'iterator' to request the nth token set for a user
- a string cellname to request the user's token set for that cell

Unfortunately, it distinguishes between these by assuming if the input
length is sizeof(afs_int32) (4 bytes), it must be an integer.  This
assumption is incorrect if the cellname is three (3) characters long
plus a nul terminator.

The result is that the cellname string is interpreted as a very large
"n"; the subsequent search for the user's "very-large-nth-token" fails,
making it appear that the user has no valid token for this cell.

Improve on this heuristic by double-checking any putative integer input.
If it is actually a 3-character string, then process the input as a
cellname instead.

Introduced by commit 5ec5ad5dcca84e99e5f55987cc4f787cd482fdde 'New
GetToken pioctl'.

While here, add doxygen comments.

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

4 years agoauth: eliminate pointless retries in ktc_ListTokensEx 98/13598/5
Mark Vitale [Thu, 23 May 2019 03:03:11 +0000]
auth: eliminate pointless retries in ktc_ListTokensEx

ktc_ListTokensEx is an iterator to provide the names of each cell for
which a user has a token set.  It does this by looking for the 1 through
nth token set for a given user.  However, as currently implemented,
it always continues searching up to the 100x safety limit even when
there are no more token sets for the user.

Instead, return immediately when VIOC_GETTOK2 returns EDOM (no more
tokens for this user).

Introduced by commit a86ad262d2a8be36f43ab0885a84dde37ddfc464 'auth: Add
the ktc_ListTokensEx function'.

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

4 years agoafscp: Link against opr/roken/hcrypto 56/13656/2
Andrew Deason [Wed, 26 Jun 2019 22:03:03 +0000]
afscp: Link against opr/roken/hcrypto

Link afscp against libopr, libroken, and libafshcrypto, so afscp can
be built again.

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

4 years agoutil: serverLog using memory after free 59/13659/3
Cheyenne Wills [Tue, 25 Jun 2019 16:40:53 +0000]
util: serverLog using memory after free

clang's scan-build detected a "use of memory after it is freed"
condition.

The function OpenLogFile frees the variable ourName before creating a
duplicate of the name passed to it.  However there is a call that uses
ourName as the parameter: OpenLogFile(ourName).  This results in freeing
ourName then doing a strdup of the same memory location.

Test the passed parameter and if it's the same as ourName already skip
the free and strdup.

This bug was introduced in commit
    340ec2f79208ee21c3130c4b1c13995947ce426c
    "util: allocate log filename buffers"

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

4 years agoLINUX: Run the 'sparse' checker if available 65/13665/3
Andrew Deason [Fri, 28 Jun 2019 19:14:48 +0000]
LINUX: Run the 'sparse' checker if available

The Linux kernel module buildsystem supports running an external tool
(by default, the 'sparse' tool) during the build to run additional
static checks on the source code to flag various warnings.

Tell the kernel build to run such a tool, if 'sparse' is installed.
This causes various new warnings in the build, such as:

  CHECK   /.../src/libafs/MODLOAD-4.9.0-8-amd64-MP/afs_tokens.c
/.../src/libafs/MODLOAD-4.9.0-8-amd64-MP/afs_tokens.c:73:1: warning: symbol 'afs_FreeOneToken' was not declared. Should it be static?
/.../src/libafs/MODLOAD-4.9.0-8-amd64-MP/afs_tokens.c:160:1: warning: symbol 'afs_IsTokenExpired' was not declared. Should it be static?
/.../src/libafs/MODLOAD-4.9.0-8-amd64-MP/afs_tokens.c:187:1: warning: symbol 'afs_IsTokenUsable' was not declared. Should it be static?

None cause the build to fail currently, but are just printed for
potential further investigation.

To control detecting 'sparse', add the --with-sparse configure option
and SPARSE configure variable. Default to checking if sparse is
available, and enabling it if so.

Further information on using sparse in the Linux kernel is available
in Documentation/sparse.txt in the Linux tree.

Using 'sparse' during the build was suggested by yadayada@in.ibm.com.

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

4 years agoafs: test condition mismatch resolved 07/13207/4
Pat Riehecky [Tue, 12 Jun 2018 18:55:56 +0000]
afs: test condition mismatch resolved

While it is unexpected, it is possible for the two disconnected flags to
get out of sync resulting in a path to an undefined varible in use.
(via cppcheck)

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

4 years agoadd dkms dependency in Red Hat unit file 54/13654/2
khm [Tue, 25 Jun 2019 19:51:21 +0000]
add dkms dependency in Red Hat unit file

Currently, there is no explicit relationship between OpenAFS and dkms.
If dkms needs to rebuild the kernel module, OpenAFS will fail to mount
because modprobe will not load the module.  This change specifies that
OpenAFS should run after dkms if dkms is present.

Change-Id: I104cb3780bbc1196cf36852f094ca07c80279d01
Reviewed-on: https://gerrit.openafs.org/13654
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Laß <lass@mail.uni-paderborn.de>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoaklog: Avoid misleading AFSCELL message 71/13371/5
Andrew Deason [Tue, 30 Oct 2018 20:41:22 +0000]
aklog: Avoid misleading AFSCELL message

Currently, if the AFSCELL environment variable is set, aklog (and
other libauth-using utilities) print out a message when
afsconf_GetLocalCell is called:

    Note: Operation is performed on cell env.example.com

However, this message is also printed (with the AFSCELL cell) when
aklog is given the -cell command-line argument, even though aklog
actually uses the cell given on the command line. For example:

    $ AFSCELL=env.example.com aklog -cell cli.example.com -d
    Note: Operation is performed on cell env.example.com
    Authenticating to cell cli.example.com (server srv1.example.com).
    [...]

libauth will normally not print the "Operation" message if we're not
using the default cell, but it determines this by checking if someone
called afsconf_GetCellInfo before calling afsconf_GetLocalCell. And
currently, aklog calls afsconf_GetLocalCell before
afsconf_GetCellInfo, so the message gets printed because libauth has
no way of knowing that we're actually using a different cell.

klog gets around this by making an additional ignored call to
afsconf_GetCellInfo before afsconf_GetLocalCell, but we can fix this
in aklog by just changing the order of the calls. So, just call
afsconf_GetCellInfo first; if we're using the local cell, we can just
give a NULL cell parameter, instead of looking up the local cellname
first.

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

4 years agorx: Set listener pthread name 00/13600/3
Andrew Deason [Sat, 8 Dec 2018 21:08:26 +0000]
rx: Set listener pthread name

When running under pthreads, set the name of the rx listener thread to
"rx_Listener". This can be handy when investigating rx performance
issues, since it makes it easier to identify which thread in the rx
listener.

Don't do this for "hot threads", since in that case we could return
and stop being a listener thread. We could restore the original thread
name, but doing so could have an impact on performance and "hot
threads" should always be disabled these days, so don't bother.

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

4 years agoMove afs_pthread_setname_self to opr 55/13655/2
Andrew Deason [Wed, 26 Jun 2019 16:47:21 +0000]
Move afs_pthread_setname_self to opr

Move the functionality in afs_pthread_setname_self from libutil to
opr, in a new function opr_threadname_set. This allows us to more
easily use the routine in more subsystems, since most code already
uses opr.

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

4 years agolibafs: Create $(DESTDIR)$(KMODDIR) on FBSD inst 53/13653/2
Andrew Deason [Sun, 23 Jun 2019 22:48:53 +0000]
libafs: Create $(DESTDIR)$(KMODDIR) on FBSD inst

We rely on bsd.kmod.mk for our actual rules during 'make install', but
that tries to install our kernel module into $(DESTDIR)$(KMODDIR),
without creating it first. If the user tries to 'make install
DESTDIR=/some/path' and that path doesn't exist, we will fail with
something like:

make DESTDIR=/home/adeason/git/destdir single_instdir_libafs
/usr/bin/install -c -T release -o root -g wheel -m 555   libafs.ko /home/adeason/git/destdir/boot/modules/
install: /home/adeason/git/destdir/boot/modules/: No such file or directory
*** Error code 71

To avoid this, add a dependency on the 'install' target which causes
our target dir to be created.

Change-Id: Icacc507867420265383e411572006df47ef22815
Reviewed-on: https://gerrit.openafs.org/13653
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoasetkey: Fix random_key for Heimdal 52/13652/3
Andrew Deason [Sun, 23 Jun 2019 21:25:27 +0000]
asetkey: Fix random_key for Heimdal

Go through our deref_key_length/deref_key_contents abstractions, so we
can compile with Heimdal krb5.

Also fix these macros to properly separate the 'key' macro argument,
so we can use the macros in these new places.

Change-Id: I3ee53bc70494a67ac5463819dc575c8ee37647c9
Reviewed-on: https://gerrit.openafs.org/13652
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoDARWIN: Use tb->code_raw for BOP_MOVE 80/13280/4
Andrew Deason [Wed, 1 Aug 2018 23:38:51 +0000]
DARWIN: Use tb->code_raw for BOP_MOVE

Currently, BOP_MOVE communicates its error code to the requestor via
the 'retval' field in struct afs_uspc_param, and we assume ptr_parm[0]
of the given brequest is for a struct afs_uspc_param. But this is
unnecessary, since struct brequest already has fields for error codes;
namely, code_raw and code_checkcode.

To avoid afs_BackgroundDaemon needing to interpret ptr_parm[0] in this
way (and assuming the type of the pointer's target), change BOP_MOVE
to just use the code_raw field for error codes, instead of
interpreting ptr_parm[0]. This makes it easier to add more AFS_NEW_BKG
background operations that do not pass a struct afs_uspc_param in the
brequest parameters.

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

4 years agorxkad: Update ticket5 from heimdal 87/13287/6
Andrew Deason [Mon, 20 Aug 2018 20:47:13 +0000]
rxkad: Update ticket5 from heimdal

This updates the rxkad code that we pull from heimdal to heimdal 7.7.0
(heimdal.git commit e1959605bd). This also updates the instructions in
README.v5 to accommodate changes in the heimdal tree, and converts
ticket5.c to use KRB5_ENCTYPE_* constants instead of ETYPE_*
constants (since heimdal has also similarly converted in krb5_asn1.h).

This removes a few -Werror=format-truncation warnings that were
present in the heimdal code before this commit.

README.v5 tweaked in collaboration with kaduk@mit.edu.

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

4 years agoafs: remove bogus comment from afs_IsTokenExpired 40/13640/2
Mark Vitale [Thu, 13 Jun 2019 03:44:32 +0000]
afs: remove bogus comment from afs_IsTokenExpired

Remove an incorrect comment, introduced with commit
adf2e6e827c6caf55247c5e63b88775393156ae5 'Unix CM: Generalise token
storage'.

No functional change is incurred by this commit.

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

4 years agoafs: add a file-level comment to afs_osidnlc.c 57/13557/2
Benjamin Kaduk [Fri, 19 Apr 2019 15:38:24 +0000]
afs: add a file-level comment to afs_osidnlc.c

This file doesn't currently do a great job of telling the reader what
it's used for.  Let's give them a hint, especially for the expansion
of "DNLC".

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

4 years agoptserver: Check for superuser in WhoIsThisWithName 08/13508/3
Andrew Deason [Wed, 27 Feb 2019 02:47:00 +0000]
ptserver: Check for superuser in WhoIsThisWithName

In WhoIsThisWithName, if we don't understand the rx security class
being used (such as rxgk), we'll set the calling id to the anonymous
user and return an error. But for SYSADMINID specifically, we don't
really need to know any security-class-specific details; we just need
to know that the caller is the superuser.

So add a fallback case to check for that; if we don't understand the
calling rx security class, just check if the calling user is
RX_ID_SUPERUSER, and use SYSADMINID if so.

This allows the ptserver to handle rxgk localauth requests (and
theoretically, localauth requests for any future security classes),
and theoretically any localauth requests for future security classes.

Based on a commit from mvitale@sinenomine.net.

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

4 years agoptclient: rxgk support 01/13501/5
Mark Vitale [Mon, 11 Feb 2019 06:21:08 +0000]
ptclient: rxgk support

Allow ptclient to use rxgk, with the new -rxgk option. While we're
here, also allow the user to specify a security level of 3, to turn on
rxkad encryption for non-localauth conns.

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

4 years agoAdd rxgk client options to vl and pt utilities 05/11105/17
Benjamin Kaduk [Mon, 14 Apr 2014 02:01:59 +0000]
Add rxgk client options to vl and pt utilities

Add options to use rxgk for outgoing connections to vlserver, vos,
ptserver, and pts.

For vlserver and ptserver, name the new option -s2scrypt, similar to
the existing volserver option -s2scrypt. For vlserver and ptserver,
specify 'rxgk-crypt' to turn on rxgk crypt connections for our
server-to-server ubik communication.

For vos and pts, just name the new option '-rxgk', and allow the user
to specify the rxgk level to use ('clear', 'auth', or 'crypt'). The
pts code is currently somewhat ill-suited to changing what rx security
class and security level we use, but do the best we can without
refactoring the whole thing.

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

4 years agopioctl: limit fruitless token searches 97/13597/2
Mark Vitale [Thu, 23 May 2019 02:52:10 +0000]
pioctl: limit fruitless token searches

getNthCell searches the afs_users table for the nth token set belonging to a
given user.  However, it is impossible for a user to have more than one
token set per cell.  If the caller specifies a number greater than the
total number of cells this cache manager knows about, we know the search
will be fruitless.

Instead, return early in this case, avoiding both the lock and the
search.

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

4 years agoAdd --quiet option to lwptool 94/13594/2
Andrew Deason [Wed, 15 May 2019 19:35:41 +0000]
Add --quiet option to lwptool

Add an option to lwptool, called --quiet, to suppress printing the
literal commands run. On error, we still print the exact failed
command to stderr.

For "pretty" V=0 builds, use this new option, to make our
lwptool-using compile rules look more like our other compile rules.

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

4 years agoUse the ppc64le_linuxXX sysname for ppc64le builds 93/13593/2
Andrew Deason [Fri, 17 May 2019 01:01:17 +0000]
Use the ppc64le_linuxXX sysname for ppc64le builds

Commit 191e18eb (Open ppc64le_linux sysname space) added the
ppc64le_linux26 sysname, but it still must be manually specified when
running on ppc64le. Use the ppc64le_linux26 by default on ppc64le, so
we can compile without needing to specify an explicit sysname.

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

4 years agoDo not define AFS_SYSCALL for ppc64le_linux26 92/13592/2
Andrew Deason [Thu, 16 May 2019 21:12:47 +0000]
Do not define AFS_SYSCALL for ppc64le_linux26

AFS_SYSCALL is defined to the syscall number we can use for a certain
platform (for pioctls and other AFS-specific kernel calls). On many
modern platforms, such as Linux, we don't use direct syscalls anymore,
instead routing our AFS-specific syscalls through an ioctl, and
AFS_SYSCALL is just used as a fallback for compatibility for older
OpenAFS releases that might still be using the syscall.

For new platforms, we have no need for this compatibility code path,
since there is no existing code we might need to be compatible with.
We should avoid defining AFS_SYSCALL for those, so we can avoid
manually-issuing syscalls in more cases. The ppc64le_linux26 platform
is a very new platform (introduced in 191e18eb "Open ppc64le_linux
sysname space"), and so should not have AFS_SYSCALL defined.

So, remove AFS_SYSCALL from ppc64le_linux26's param.h.

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

4 years agoOpen ppc64le_linux sysname space 62/13562/2
Nathaniel Filardo [Wed, 1 May 2019 22:01:51 +0000]
Open ppc64le_linux sysname space

While here, add config/param.ppc64le_linux26.h; it's just like
ppc64_linux26.h, except not AFSBIG_ENDIAN.

Change-Id: I6671405f829f2bf50b6e8d3355ab9e8aed384c02
Reviewed-on: https://gerrit.openafs.org/13562
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

4 years agoFix static expressions in conditionals 58/13158/6
Pat Riehecky [Fri, 1 Jun 2018 21:33:37 +0000]
Fix static expressions in conditionals

The conditions in these if statements are always true (or always false).
Remove the check in cmdebug.c, as it is unnecessary, and fix the check
in vlclient.c to actually check for a valid voltype. (via cppcheck)

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

4 years agoredhat: RHEL8 add elfutils-devel as build dependency for kernel module 60/13560/3
Cheyenne Wills [Thu, 18 Apr 2019 15:55:09 +0000]
redhat: RHEL8 add elfutils-devel as build dependency for kernel module

Building the kernel modules under RHEL8 produces the following error
message:
    Makefile:952: *** "Cannot generate ORC metadata for
     CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or
     elfutils-libelf-devel".  Stop.

Add elfutils-devel to the BuildRequires in the rpm spec when building
rhel >= 8

Add elfutils-devel to the BuildRequires in the rpm spec that
openafs-kmodtool produces

FIXES 134900

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

4 years agoasetkey: add 'add-random' command 68/12768/9
Andrew Deason [Thu, 9 Nov 2017 18:50:53 +0000]
asetkey: add 'add-random' command

Add a new command, 'add-random', to allow the creation of a new key
with random data. This is helpful for certain rxgk keys, which only
need to exist in KeyFileExt and not in any other database (like a krb5
KDC), and so aren't derived from a krb5 keytab.

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

4 years agoasetkey: Add new 'delete' command variants 67/12767/10
Andrew Deason [Thu, 9 Nov 2017 18:47:57 +0000]
asetkey: Add new 'delete' command variants

The current 'delete' command from asetkey only lets the user delete
old-style rxkad keys. Add a couple of new variants to allow specifying
the key type and subtype, so the user can delete specific key types
and enctypes if they want.

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

4 years agoafs: Raise osidnlc NCSIZE 31/13531/2
Andrew Deason [Fri, 28 Sep 2018 19:55:56 +0000]
afs: Raise osidnlc NCSIZE

The currrent size of the osi DNLC is very small; only 300 entries.
Raise it to 4096 entries, to give it some chance of actually helping.

In the future, of course, this should be runtime configurable, and we
should also raise the hash table size. For now, just raise the number
of entries without changing anything else, to try to make sure nothing
breaks.

With the hash size of 256, this means our hash chains will be at least
16 items long. However, traversing even hundreds of hash items should
still be better than frequently hitting the disk cache to find
entries, and acquiring more locks, etc.

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

4 years agodoc: Remove one lingering reference to src/mcas 39/13539/2
Andrew Deason [Mon, 1 Apr 2019 16:57:42 +0000]
doc: Remove one lingering reference to src/mcas

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

4 years agoRemove src/mcas 38/13538/2
Benjamin Kaduk [Wed, 2 Aug 2017 01:57:52 +0000]
Remove src/mcas

This lock-free library toolkit is intriguing and may be the subject
of future work, but currently nothing uses this code, and these files
are just clutter.

Remove src/mcas and stop mentioning it in SOURCE-MAP; don't reference
it in the rpctests, either.

Reviewed-on: https://gerrit.openafs.org/12682
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit bfc5d1ada2f5ce12bfafe65d352982adbefe9911)

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

4 years agoafsmonitor: avoid double free on exit 61/13161/7
Pat Riehecky [Wed, 6 Jun 2018 15:01:02 +0000]
afsmonitor: avoid double free on exit

The afsmonitor may leak memory and do a double free on shutdown when it
was started with a non-zero -buffers parameter value. The deallocation
of the cm results circular buffer incorrectly frees the base of the
array of results instead of each result.  The fs buffer clean up got
this right.

This fixes the clang scan-build warning:

    afsmonitor.c:461:7: warning: Attempt to free released memory
                        free(tmp_cmlist);
                        ^~~~~~~~~~~~~~~~

[mmeffie: update code and commit message]

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

5 years agoasetkey: Allow rxgk keys 66/12766/9
Andrew Deason [Thu, 9 Nov 2017 06:03:04 +0000]
asetkey: Allow rxgk keys

Add rxgk support to asetkey. This just allows asetkey to display rxgk
keys more prettily, and allows the user to add literal rxgk key data
on the command line, or add keytab-derived keys.

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

5 years agoauth: Add afsconf_ClientAuthRXGK variants 04/11104/17
Benjamin Kaduk [Mon, 14 Apr 2014 01:38:02 +0000]
auth: Add afsconf_ClientAuthRXGK variants

Add various afsconf_ClientAuthRXGK* variants, to use local printed
rxgk tokens with clear, auth, or crypt levels.

Also add the flag AFSCONF_SECOPTS_RXGK for afsconf_PickClientSecObj,
to let callers of afsconf_PickClientSecObj use rxgk connections. To
allow selecting of the "clear" level, add the flag
AFSCONF_SECOPTS_ALWAYSCLEAR. And to allow selecting the "auth" level
but letting "crypt" be the default for rxgk, add the new flag
AFSCONF_SECOPTS_NEVERENCRYPT.

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

5 years agodir: Honor non-ENOENT lookup errors 31/13431/4
Andrew Deason [Thu, 17 Jan 2019 06:04:36 +0000]
dir: Honor non-ENOENT lookup errors

Currently, several places in src/dir/dir.c assume that any error from
a lower-level function (e.g. FindItem) means that the item we're
looking for does not exist in that directory. But if we encountered
some other error, that may not be the case; the directory blob may be
corrupt, we may have encountered some I/O error, etc.

To detect cases like this, return the actual error code from FindItem
&c, instead of always reporting ENOENT. For the code paths that are
actually specifically looking for if the target exists (in
afs_dir_Create), change our checks to specifically check for ENOENT,
and return any other error.

Do the same thing for a few similar callers in viced/afsfileprocs.c,
as well.

FIXES 134904

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

5 years agoLINUX: Avoid lookup ENOENT on fatal signals 30/13530/2
Andrew Deason [Thu, 21 Mar 2019 20:24:06 +0000]
LINUX: Avoid lookup ENOENT on fatal signals

Various Linux kernel operations on various Linux kernel versions can
fail if the current process has a pending fatal signal (i.e. SIGKILL),
including reads and writes to our local disk cache. Depending on what
and when something fails because of this, some parts of libafs throw
an ENOENT error, which may propagate up to callers, and be returned
from afs_lookup(). Notably this can happen via some functions in
src/dir/dir.c, and previously was possible with some code paths before
they were fixed by commit 2aa4cb04 (afs: Stop abusing ENOENT).

For the most part, the exact error given to the userspace caller
doesn't matter, since the process will die as soon as we return to
userspace. However, for ENOENT errors specifically for lookups, we
interpret this to mean that the target filename is known to not exist,
and so we create a negative dentry for that name, which is cached.
Future lookups for that filename will then result in ENOENT before any
AFS functions are called.

The lingering abuses of the ENOENT error code should be removed from
libafs entirely, but as an extra layer of safety, we can just avoid
returning ENOENT from lookups if the current process has a pending
fatal signal. So to do that, change all afs_lookup() callers in
src/afs/LINUX to translate ENOENT to EINTR if we have a pending fatal
signal. If fatal_signal_pending() is not available, then we don't do
this translation.

FIXES 134904

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

5 years agoUse rxgk in afsconf_BuildServerSecurityObjects 41/12941/7
Andrew Deason [Sun, 4 Mar 2018 23:33:47 +0000]
Use rxgk in afsconf_BuildServerSecurityObjects

In afsconf_BuildServerSecurityObjects, create a server security object
for rxgk. Currently, this will only accept printed rxgk tokens, not
tokens negotiated via GSSNegotiate. Future commits will add
functionality to handle user-negotiated tokens, fileserver-specific
creds, etc.

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

5 years agoImplement afsconf_GetRXGKKey 99/11099/17
Benjamin Kaduk [Wed, 26 Mar 2014 10:24:02 +0000]
Implement afsconf_GetRXGKKey

Also afsconf_GetLatestRXGKKey, as a side effect, since we want to have
a single getkey function both for getting encrypting and decrypting keys;
a kvno/enctype pair of 0/0 indicates that the "get latest" behavior is
desired.

Implement both functions in terms of an internal helper that takes
as an argument the type of key to look for in the KeyFileExt.  We
can reuse these helpers wholesale for per-fileserver keys, later.

This also requires implementing an ordering on the quality of the
different RFC 3961 enctypes (which are stored as the subtype of keys
of type afsconf_rxgk). This is subject to debate on the actual
ordering, but since the IANA enctype registry changes rarely, just
assign a full ordering on the standardized (symmetric!) enctypes.
Implement this via a new function, rxgk_enctype_better, in
rxgk_crypto_rfc3961.c.

Introduce a new header file, rxgk_types.h, so we can avoid including
the entire rxgk.h header in cellconfig.p.h.

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

5 years agoAdd rxgk support to userok 76/10576/23
Ben Kaduk [Wed, 4 Dec 2013 18:03:46 +0000]
Add rxgk support to userok

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

5 years agoBuild rxgk support into libafsrpc 91/10591/22
Ben Kaduk [Fri, 13 Dec 2013 23:46:11 +0000]
Build rxgk support into libafsrpc

Add a dependency on the appropriate $(GSSAPI_LIBS) and link in the
librxgk_pic.la helper. Careful control of what functions are exposed
allows static linking to continue to work when rxgk is disabled,
though a stub is needed for the case of rxgk_GetServerInfo, so that
there is a symbol present to satisfy the export symbol list.

Consumers of libafsrpc.a need not be modified in accordance
with this change.

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

5 years agoAdd rxgk_GetServerInfo stub 21/12721/10
Benjamin Kaduk [Fri, 1 Sep 2017 22:45:10 +0000]
Add rxgk_GetServerInfo stub

Provide a stub function that libafsrpc can export when rxgk support
is disabled.  (It always returns failure, of course.)

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

5 years agorxdebug: Add rxgk support 40/12940/7
Andrew Deason [Fri, 2 Mar 2018 06:24:54 +0000]
rxdebug: Add rxgk support

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

5 years agoImplement rxgk client security object routines 73/10573/24
Ben Kaduk [Tue, 10 Dec 2013 05:09:35 +0000]
Implement rxgk client security object routines

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

5 years agoImplement the rxgk server security object routines 72/10572/28
Ben Kaduk [Tue, 10 Dec 2013 03:13:16 +0000]
Implement the rxgk server security object routines

Provide non-trivial implementations of the security class routines
used by the server, along with helpers as necessary.

The identity supplied in a client's token is given as a list of
PrAuthNames; we assume that at most one name is supplied at present,
as the meaning of compound identities (and the use of compound
identities for keyed cache managers) is not fully specified yet.
Convert the PrAuthName to an rx_identity for caching in the server
connection state, as the rx_identity type is more compatible with
superuser checks on the connection.

Also provide an rxgk_GetServerInfo routine which extracts the cached
identity, for use in libauth when making superuser checks.
This moves our dependency on rx_identity from the private data structures
into the public header, so move the nested include accordingly.

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

5 years agorxgk: Avoid calling xdr_destroy on blank xdrs 21/13521/4
Andrew Deason [Tue, 12 Mar 2019 22:03:09 +0000]
rxgk: Avoid calling xdr_destroy on blank xdrs

A couple of callers in rxgk_token.c call xdr_destroy(&xdrs) in a
cleanup code path; at present the code is fine because we are careful to
only jump to the cleanup path from a state where the xdrs are initialized,
but this is needlessly fragile (and is an undocumented requirement of the
code).  Since xdr_destroy() unconditionally looks at xdrs.x_ops->x_destroy,
this could cause a NULL dereference if an error is encountered in a future
version where the 'xdrs' may be zeroed when the cleanup path runs.

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

5 years agorxgk: Do not require gss_pseudo_random 20/13520/4
Andrew Deason [Tue, 12 Mar 2019 23:42:42 +0000]
rxgk: Do not require gss_pseudo_random

We actually do not yet call gss_pseudo_random anywhere in the rxgk
codebase. We will need this later, so print a warning when we don't
have it, but let rxgk build so we can build on platforms without
gss_pseudo_random for now (Solaris/SEAM).

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

5 years agoauth: Make afsconf_PutTypedKeyList idempotent 07/13507/4
Andrew Deason [Sat, 2 Feb 2019 05:25:02 +0000]
auth: Make afsconf_PutTypedKeyList idempotent

Currently, if we call afsconf_PutTypedKeyList on a key list, we set
the key list to NULL. But then if we call afsconf_PutTypedKeyList on a
NULL key list, we segfault because we try to dereference the list.

Change afsconf_PutTypedKeyList to be a noop if we give it a NULL list,
avoiding a segfault in such a situation.

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

5 years agorx: Do not ignore RXS_* op errors 22/13522/4
Andrew Deason [Wed, 13 Mar 2019 23:30:43 +0000]
rx: Do not ignore RXS_* op errors

Several places in rx call an RXS_* security layer operation, but
ignore the error code. Though errors for these operations are rare or
impossible currently, if they ever do return an error there could be
noticeable consequences, like a connection getting an uninitialized
challenge nonce, or sending a challenge packet with uninitialized
payload.

Change these call sites to record and handle the error. Errors from
the security class normally mean aborting the entire conn, but for
many operations we need to behave differently:

- For RXS_DestroyConnection, errors don't make sense, since we're just
  freeing an object. Change the op to return void, and update our
  implementations of DestroyConnection to match.

- For RXS_GetStats, just clear the relevant stats structure on error
  instead. This change also results in us clearing the stats structure
  when there is no security class associated with the connection;
  previously we just reused the same struct data as the previous conn.

- For RXS_CreateChallenge, aborting the entire conn is difficult,
  because some code paths have callers that potentially lock multiple
  calls on the same conn (rxi_UpdatePeerReach -> TryAttach ->
  rxi_ChallengeOn -> RXS_CreateChallenge), and aborting our conn
  requires locking every call on the conn. So instead we just
  propagate an error up to our callers, and we abort just the call we
  have.

- For RXS_GetChallenge, we cannot abort the conn when
  rxi_ChallengeEvent is called directly, because the caller will have
  the call locked. But when rxi_ChallengeEvent is called as an event
  (when we retry sending the challenge), we can.

- For RXS_SetConfiguration, propagate the error up to our caller.
  Update all rx_SetSecurityConfiguration callers to record and handle
  the error; all of these are during initialization of daemons, so
  have them log an error and exit.

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

5 years agoAdd param.h files and sysnames for FreeBSD 11.2 34/13534/3
Stephan Wiesand [Fri, 22 Mar 2019 11:46:17 +0000]
Add param.h files and sysnames for FreeBSD 11.2

Thanks to Måns Nilsson for filing the bug. Note that this change
differs from the proposed patch in the report, in that it
doesn't define the 10.4 symbols in the 11.2 param.h files.

FIXES 134850

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

5 years agoman-pages: create the man3 subdirectory in prep-noistall 33/13533/2
Karl Behler [Fri, 22 Mar 2019 11:22:05 +0000]
man-pages: create the man3 subdirectory in prep-noistall

This should fix a build failure reported on the openafs-devel list
today.

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

5 years agoafs: Cleanup state on rxfs_*Init errors 10/13510/2
Andrew Deason [Sat, 2 Mar 2019 21:58:00 +0000]
afs: Cleanup state on rxfs_*Init errors

Currently, rxfs_storeInit and rxfs_fetchInit return early if they
encounter an error while starting the relevant fetch/store RPC (e.g.
StartRXAFS_FetchData64). In this scenario, they osi_FreeSmallSpace
their rock before returning, but they never go through their
destructor to free the contents of the rock
(rxfs_storeDestroy/rxfs_fetchDestroy), leaking any resources inside
that have already been initialized.

The only thing that could have been initialized by this point is
v->call, so hitting this condition means we leak an Rx call, and means
we can report the wrong error code (since we never go through
rx_EndCall, we never look at the call's abort code). For
rxfs_fetchInit, most code paths call rx_EndCall explicitly, except for
the code path where StartRXAFS_FetchData64 itself fails.

For both fetches and stores, it's difficult to hit this condition,
because this requires that the StartRXAFS_* call fails, before we have
sent or received any data from the wire. However, this can be hit if
the call is already aborted before we use it, which can happen if the
underlying connection has already been aborted by a connection abort.

Before commit 0835d7c2 ("afs: make sure to call afs_Analyze after
afs_Conn"), this was most easily hit by trying to fetch data with a
bad security object (for example, with expired credentials). After the
first fetch failed due to a connection abort (e.g. RXKADEXPIRED),
afs_GetDCache would retry the fetch with the same connection, and
StartRXAFS_FetchData64 would fail because the connection and call were
already aborted. In this case, we'd leak the Rx call, and we would
throw an RXGEN_CC_MARSHAL error (-450), instead of the correct
RXKADEXPIRED error. This causes libafs to report that the target
server as unreachable, due to the negative error code.

With commit 0835d7c2, this doesn't happen because we call afs_Analyze
before retrying the fetch, which detects the invalid credentials and
forces creating a new connetion object. However, this situation should
still be possible if a different call on the same connection triggered
a connection-level abort before we called StartRXAFS_FetchData64.

To fix this and ensure that we don't leak Rx calls, explicitly call
rxfs_storeDestroy/rxfs_fetchDestroy in this error case, before
returning from rxfs_storeInit/rxfs_fetchInit.

Thanks to yadayada@in.ibm.com for reporting a related issue and
providing analysis.

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

5 years agoRemove references to SunOS 4 06/13506/2
Andrew Deason [Mon, 25 Feb 2019 17:35:24 +0000]
Remove references to SunOS 4

We already removed support for Solaris versions before Solaris 8, in
commit e4c2810f ("Remove support for Solaris pre-8"), but there are
still some references to SunOS (meaning SunOS 4) in the tree. This is
even older than Solaris (aka SunOS 5), so get rid of these.

This commit removes most references to SunOS 4 regarding platform
support, and a few comments. This also removes a few comments that
were just wrong or nonsensical (e.g. CMAPPED in afs.h is used by
other platforms; some comments in platform-specific osi_file.c files
referenced SunOS for some reason).

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

5 years agorx: Make rxi_Free(NULL, size) a no-op 14/13514/2
Andrew Deason [Thu, 7 Mar 2019 05:06:16 +0000]
rx: Make rxi_Free(NULL, size) a no-op

Commit 75233973 (afs: Make afs_osi_Free(NULL) a no-op) intended to
make some of our free abstractions behave like the userspace free, so
freeing NULL is a no-op. However, that commit still left rxi_Free such
that rxi_Free(NULL, size) would decrement the relevant allocation
counters.

So to make our free abstractions more consistent, just skip all of
rxi_Free when the given pointer is NULL.

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

5 years agoAdd rxgk_util.c 37/10937/18
Ben Kaduk [Tue, 10 Dec 2013 22:47:42 +0000]
Add rxgk_util.c

A few helper routines for the security class implementation.

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

5 years agoAdd rxgk_packet.c 71/10571/20
Ben Kaduk [Tue, 10 Dec 2013 04:07:17 +0000]
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
Reviewed-on: https://gerrit.openafs.org/10571
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>