Commit Graph

12654 Commits

Author SHA1 Message Date
Michael Meffie
f99c1ec32b doc: fs examine no longer requires read rights on the volume root vnode
Update the man page to reflect the current access rights required for fs
examine.  Historically, fs examine required read access on the root
vnode of the volume housing the directory or file being examined.  This
access check was relaxed in commit d2d591caf2,
since the information returned by the file server is already available
anonymously by other means.

Change-Id: If62b625bce8a260b98fb56a6feec49c674f2de53
Reviewed-on: https://gerrit.openafs.org/12223
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
2016-03-19 15:53:03 -04:00
Benjamin Kaduk
02a393de6b Add param files for FreeBSD 10.2, 10.3
FreeBSD 10.3 is in the beta stage now; better get ready for it.

Change-Id: I2a6b6144916f13768bfad27af5eb5340e039939b
Reviewed-on: https://gerrit.openafs.org/12222
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-03-19 15:50:41 -04:00
Benjamin Kaduk
e63c2570f9 OPENAFS-SA-2016-002 ListAddrByAttributes information leak
The ListAddrByAttributes structure is used as an input to the GetAddrsU
RPC; it contains a Mask field that controls which of the other fields
will actually be read by the server during the RPC processing.
Unfortunately, the client only wrote to the fields indicated by the
mask, leaving the other fields uninitialized for transmission on the
wire, leaking some contents of client memory.

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

FIXES 132847

Change-Id: I9ccf814ceff206ddb3a74da97dc50b7e1e3c2014
2016-03-16 00:04:00 -04:00
Benjamin Kaduk
c12b3fee2f OPENAFS-SA-2016-002 VldbListByAttributes information leak
The VldbListByAttributes structure is used as an input to several
RPCs; it contains a Mask field that controls
which of the other fields will actually be read by the server
during the RPC processing.  Unfortunately, the client only
wrote to the fields indicated by the mask, leaving the other
fields uninitialized for transmission on the wire, leaking
some contents of client memory.

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

FIXES 132847

Change-Id: I14964e98a57ba6ef060c6e392497f1ebd3afe042
2016-03-16 00:04:00 -04:00
Benjamin Kaduk
67646c7c90 OPENAFS-SA-2016-002 AFSStoreVolumeStatus information leak
The AFSStoreVolumeStatus structure is used as an input to the
RXAFS_SetVolumeStatus RPC; it contains a Mask field that controls
which of the other fields will actually be read by the server
during the RPC processing.  Unfortunately, the client only
wrote to the fields indicated by the mask, leaving the other
fields uninitialized for transmission on the wire, leaking
some contents of kernel memory.

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

FIXES 132847

Change-Id: Ib309e6b00b95bc4178740352899d7f940f2eb1ea
2016-03-16 00:04:00 -04:00
Benjamin Kaduk
b85c5f9339 OPENAFS-SA-2016-002 AFSStoreStatus information leak
Marc Dionne reported that portions of the AFSStoreStatus structure
were not written to before being sent over the network for
operations such as create, symlink, etc., leaking the contents
of the kernel stack to observers.  Which fields in the request
are used are controlled by a flags field, and so if a field was
not going to be used by the server, it was sometimes left
uninitialized.

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

FIXES 132847

Change-Id: I84a5a10442732ebbcb5d5067ca22030fb795168b
2016-03-16 00:04:00 -04:00
Jeffrey Altman
d853866c56 OPENAFS-SA-2016-001 group creation by foreign users
CVE-2016-2860:

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

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

FIXES 132822

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

Change-Id: I54ddca3e4e1339f76ed320f0d6c53d8820aed89c
2016-03-16 00:04:00 -04:00
Jeffrey Altman
e3bb92c2a0 ptserver: fix pt_util creation of groups
In commit 53ac98931a the adjustment of
owner id was moved from CreateEntry() into CreateGroupName().  This was
done for two reasons:

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

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

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

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

Change-Id: I0d37f5a43ea5919d1bbc3ba6d82b2924ab38befc
2016-03-16 00:04:00 -04:00
Michael Meffie
b702ab5da2 LINUX: ifconfig is deprecated
ifconfig is deprecated and is no longer installed by default on RHEL 7 and
Centos 7. Use the replacement ip command in the init script for linux.
Fallback to ifconfig in the event the ip command is not available.

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

Change-Id: I7ffe272eb712cd83a70a7d880d239f72b40cb5df
Reviewed-on: http://gerrit.openafs.org/12192
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-02-28 15:36:56 -05:00
Mark Vitale
d833ba7680 DAFS: large volume support - fileserver crash after "addled bitmap"
Any DAFS fileserver operation that allocates a new vnode but fails
to update the vnode index will crash:

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

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

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

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

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

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

Change-Id: Id6cf6b1279b11e6dfc4704bba5739912f663beca
Reviewed-on: http://gerrit.openafs.org/11983
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2016-02-22 23:54:25 -05:00
Mark Vitale
cc79ca882d bozo: allow start of fs and dafs bnodes with options
fs_create() and dafs_create() issue stat() to verify
the existence of each executable specified in the bnode.
However, commit fda2bc8747
inadvertently removed the code that stripped any command
arguments before the stat().  Therefore, any bnode that
specifies arguments (e.g. /usr/afs/bin/dafileserver -d 5),
causes the stat() to fail and the bnode will not start.

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

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

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

Change-Id: I04f7ce2afb8211bd12b9063db1335738bff1cc1e
Reviewed-on: http://gerrit.openafs.org/11934
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-02-22 23:23:38 -05:00
Mark Vitale
44349d0694 viced: incorrect FID audit of BulkStatus and InlineBulkStatus
The audit code for object AUD_FIDS is off by one - we list the
first FID twice and skip the last FID.

Repair so all FIDs are properly audited.

Change-Id: I99f4687e25031eb26ccd7e07b732217b098005de
Reviewed-on: http://gerrit.openafs.org/12191
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-02-17 14:06:42 -05:00
Michael Meffie
c0876aa6b5 test: skip buserror test when SIGBUS is not defined in perl POSIX module
Older versions of the perl POSIX module do not define the SIGBUS symbol, which
causes the opr/softsig-t perl test to fail to compile.  Instead of trying to
defined SIGBUS, which may be platform dependent, skip the buserror unit test on
these older platforms.

Change-Id: Ib8cfd77215ea43566e9d47b501d4989556b83734
Reviewed-on: http://gerrit.openafs.org/12186
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-02-10 23:47:52 -05:00
Michael Meffie
378eae1d53 CellServDB update 01 Jan 2016
Update all remaining copies of CellServDB in the tree, and make the
Red Hat packaging use it by default too.

Change-Id: Idf9d97151b8e9075fefa7aece58fd023bfd857ff
Reviewed-on: http://gerrit.openafs.org/12187
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-02-10 23:46:26 -05:00
Michael Meffie
ed52d65fe9 volser: detect eof in dump stream while reading acl
Detect an EOF condition while reading the ACL in a dump stream
and return a restore error, instead of filling the ACL with
0xFF and then failing the restore due to an invalid tag.

Change-Id: If7a71946c81f47ac68ed2f7afdfca1023bad3baf
Reviewed-on: http://gerrit.openafs.org/11703
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2016-02-03 23:32:05 -05:00
Benjamin Kaduk
97150150e6 cellconfig: check for invalid dotted quads
IP addresses entered into the CellServDB with components larger
than 255 would silently be trucated down to 8-bit unsigned integer
representations.  This could cause confusing behavior with
occasional hangs.

FIXES 131794

Change-Id: I44834cb4662e178fdb4be2eeb03ad58d2fa7c556
Reviewed-on: http://gerrit.openafs.org/12109
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2016-01-26 12:06:30 -05:00
Andrew Deason
11845765c7 afs: Log abnormally large chunk files
Any chunk in our cache for a regular file should be smaller than or
equal to our configured chunksize. If someone sets a chunk to be
larger than that, it is very strange and may cause other confusing
issues. Specifically, afs_DoPartialWrite determines if our cache is
"too full" by counting the number of dirty chunks. If we have a dirty
chunk that is much larger than the chunksize, it can throw off the
afs_DoPartialWrite calculation.

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

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

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

Change-Id: I5cf58e3659dc04255c62fa56b044d5bc1c7ce877
Reviewed-on: http://gerrit.openafs.org/11831
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2016-01-24 22:47:25 -05:00
Chas Williams
775b8873f4 opr: Use opr_Assert() instead of silently failing
These routines should never be passed a NULL.  If this happens it
is a serious issue that needs to be addressed.

Change-Id: I9728dcd67bc9f8e9927bed1674fc0ee83567df1a
Reviewed-on: http://gerrit.openafs.org/11853
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-01-24 22:47:02 -05:00
Chas Williams
04661c4139 opr: Disable some warnings during opr assertions
Detect _Pragma(), a C99 extension for inline #pragma's, and use it to
disable to certain warnings during the use of opr_Verify() and
opr_Assert().

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

Change-Id: Id3d5ee347f320a366a0571572b58414aa7044bf7
Reviewed-on: http://gerrit.openafs.org/11852
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2016-01-24 22:46:56 -05:00
Andrew Deason
5fbf45b562 afs: Log weird 'size' fetchdata errors
There are a couple of situations that should never happen when issuing
a fetchdata, but cause errors when they do:

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

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

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

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

Change-Id: I7561a9ecc225386f9b140e633912b900c591a9bb
Reviewed-on: http://gerrit.openafs.org/11830
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2016-01-24 21:58:53 -05:00
Andrew Deason
c0f52c3a3d afs: Fix fetchInit for negative/large lengths
Currently, the 'length64' variable in rxfs_fetchInit is almost
completely unused (it just goes into an icl logging function). For the
length that we actually use ('*alength'), we just take the lower 32
bits of the length that the fileserver told us. This method is
incorrect in at least the following cases:

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

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

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

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

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

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

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

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

Change-Id: I7e8f2132d52747b7f0ce4a6a5ba81f6641a298a8
Reviewed-on: http://gerrit.openafs.org/11829
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2016-01-24 21:28:07 -05:00
Andrew Deason
3caee75754 afs: Avoid incorrect size when fetching beyond EOF
Currently, afs_GetDCache contains a couple of calculations that look
similar to this:

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

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

This has two potential effects:

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

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

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

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

But there are probably other similar scenarios.

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

Change-Id: Ie36f66ce11fbee905062b3a787871ec077c15354
Reviewed-on: http://gerrit.openafs.org/11828
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
2016-01-24 20:27:07 -05:00
Michael Meffie
4a69d3894c doc: afsd -settime and -nosettime are obsolete
Update the afsd man page -settime and -nosettime options, which are obsolete
and no longer have any effect.  Use the same wording as the other obsolete
options in the afsd man page.  Keep the recommendations to use the time keeping
daemons provided by the operating system to maintain the system time.

Change-Id: I08a1bd5ae0b2d6618b3e212ebcbb98f470e33820
Reviewed-on: http://gerrit.openafs.org/12175
Reviewed-by: Michael Laß <lass@mail.uni-paderborn.de>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-01-24 19:17:47 -05:00
Dave Botsch
f3145b0de0 rxinit_status needs to be global for the kext since
RXK_UPCALL_ENV is defined in src/rx/DARWIN/rx_knet.c

Change-Id: I23b535f0cd6b45c3e186319c4bacf5b6c5a93681
Reviewed-on: http://gerrit.openafs.org/12073
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2016-01-24 18:40:12 -05:00
Dave Botsch
bf3707ccbf Initial set of changes for El Capitan OS X 10.11 .
Mainly new El Capitan specific config files and defitions of
Darwin 15 variables and config tests/etc.

Change-Id: I87b926109561f41ee95a2f3f94fbdbcf2903691a
Reviewed-on: http://gerrit.openafs.org/12072
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-01-24 18:39:50 -05:00
Benjamin Kaduk
767694d9ec Fix optimized IRIX kernel module builds
Commit 9f94892f8d (from 2006)
introduced per-file CFLAGS, using $(CFLAGS-$@); this construct
is not parsed well by IRIX make, which ends up attempting to
expand '$@)' and finding mismatched parentheses.

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

FIXES 131621

Change-Id: Id5298103221b016239723aa08ebe0dc54bdadc5e
Reviewed-on: http://gerrit.openafs.org/12111
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-01-24 18:27:02 -05:00
Chas Williams
baa037a14f LINUX: don't cache negative entries for dynroot
The dynroot volume lacks any callbacks that would invalidate the directory
or change the data version.  Further, the data version for the dynroot
is only updated for when a new cell is found or added (a positive lookup).

Change-Id: If0b022933de7335d3d94aafc77c50b85b99f4116
Reviewed-on: http://gerrit.openafs.org/12140
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2016-01-23 16:46:43 -05:00
Benjamin Kaduk
6db49a8417 Typo fix in comment
afsd -shutdown takes only a single dash, as with all cmd-style
options.

Improve the grammar a bit while we're here.

Change-Id: Ie96c80dba1770e735617e5c93fe3d4c1e3afd3a9
Reviewed-on: http://gerrit.openafs.org/12133
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2016-01-23 15:03:38 -05:00
Marcio Barbosa
70fd9bc6dc afs: do not allow two shutdown sequences in parallel
Often, ‘afsd -shutdown’ is called right after ‘umount’.
Both commands hold the glock before calling ‘afs_shutdown’.
However, one of the functions called by 'afs_shutdown', namely,
‘afs_FlushVCBs’, might drop the glock when the global
'afs_shuttingdown' is still equal to 0. As a result, a scenario
with two shutdown sequences proceeding in parallel is possible.

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

Change-Id: Iffa89d82278b0df5fb90fc35608af66d8e8db29e
Reviewed-on: http://gerrit.openafs.org/12016
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-01-23 14:27:30 -05:00
Brian Torbich
a4c4b78605 redhat: Correct permissions on systemd unit files
Change the systemd unit file permissions created via
openafs.spec to be 0644 instead of 0755.  Having the
systemd unit files be executable will trigger a systemd
warning.

FIXES 132662

Change-Id: I9f5111c855941528193aaabeb42bf1b732246a7e
Reviewed-on: http://gerrit.openafs.org/12174
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-01-22 11:13:54 -05:00
Stephan Wiesand
9ee5fa152b redhat: Avoid bogus dependencies when building the srpm
By default the spec defines that both userland and kernel module
packages should be built. This results in a dependency of the form
"kernel-devel-`uname -m` = `uname -r`" being added to the source
package created by makesrpm.pl, which is bogus because the uname
values are from the system on which the srpm is built and needn't
apply to the system where it is used. While rpm and rpmbuild ignore
such dependencies of source packages, other tools don't and may fail.

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

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

Change-Id: I0134e1936638c7d9c3fd9ff0ccf1cba36710d0d3
Reviewed-on: http://gerrit.openafs.org/11903
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2016-01-06 10:55:33 -05:00
Benjamin Kaduk
db4343b870 Tweak grammar in README
So as to get a trivial change as confirmation that an updated
gerrit is functioning correctly.

Change-Id: I04eb12cab982a3f1b5ecc92d60c455e7a0d2242c
Reviewed-on: http://gerrit.openafs.org/12156
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
2015-12-28 19:32:17 -05:00
Benjamin Kaduk
318692134d Remove blank line from README
There's no reason for this file to start with a blank line.

Change-Id: I175390d3c9796fc10ef8086a5b179f4fc27362b5
Reviewed-on: http://gerrit.openafs.org/12153
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
2015-12-28 19:09:16 -05:00
Benjamin Kaduk
f7c6915358 Update extra-iput configure argument description
Commit 15260c7fdc did not function
as advertised, since the conditional which attempted to make
the configure option --(en|dis)able-linux-d_splice_alias-extra-iput
mandatory on linux checked a variable for the system type which
was not set at the time the check ran.

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

Change-Id: I36d1f8801d355f33c3132fcab166ea76faab8e87
Reviewed-on: http://gerrit.openafs.org/11710
Reviewed-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2015-12-25 14:03:44 -05:00
Simon Wilkinson
5fd9aed2ba compile_et: Don't overflow input file buffer
Don't overlow the buffer that's used for the input filename by
copying in to much with sprintf. Use asprintf to dynamically
allocate a buffer instead.

Link roken for rk_asprintf where needed.

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

Caught by coverity (#985907)

Change-Id: I207dd2c49bcae3f04fa41c826b08a0a615d5f422
Reviewed-on: http://gerrit.openafs.org/9545
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2015-12-25 14:03:22 -05:00
Benjamin Kaduk
87ce2a6f05 Provide a buildtool_roken make variable
When using roken in build tools, i.e., binaries which must be
executed during the build stage, the roken library must be usable
prior to the 'install' stage.  In particular, if the internal
rokenafs is used, the shared library will not be installed and
the runtime linker will not be able to find it, causing execution
of the build tool to fail.  To avoid this failure, librokenafs
must be linked statically into these build tools.

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

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

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

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

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

Change-Id: I079fc6de5d0aa6403eb1071f3d58a248b1777853
Reviewed-on: http://gerrit.openafs.org/11763
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-12-25 02:18:08 -05:00
Anders Kaseorg
93f7041a08 rxkad: Resolve warnings in ticket5.c
Resolves these warnings:

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

Change-Id: Ic1b878f01cf82222dc258847747ce192ee5948fc
Reviewed-on: http://gerrit.openafs.org/11955
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2015-12-25 01:57:06 -05:00
Benjamin Kaduk
c0d771672f Add filepath entries for rxkad.keytab
Even though master is not using it, we still want to be able to
find it.

Change-Id: I31fa39fe4d4bed5144c5169236b1106bd9f18501
Reviewed-on: http://gerrit.openafs.org/11784
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-12-25 00:51:32 -05:00
Benjamin Kaduk
a14dec2bff Make typedKey helpers more friendly to use
Make freeing a NULL key pointer a no-op.

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

Change-Id: I3a4088747913e9e88be094da891cd2cca0cbb114
Reviewed-on: http://gerrit.openafs.org/11783
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-12-25 00:46:04 -05:00
Marcio Barbosa
6e4f8e5528 viced: do not overwrite possible failure
The function ‘hpr_Initialize’ overwrites the code
returned by ‘ubik_ClientInit’. As a result, ‘hpr_Initialize’
will not report any failure triggered by ‘ubik_ClientInit’.

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

Change-Id: I1820e3cbc2131daace01cec0464e56fd2982a783
Reviewed-on: http://gerrit.openafs.org/12137
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-12-24 18:22:23 -05:00
Mark Vitale
b8757341fb afs: incorrect types for AFSDB IPv4 addresses
DNS lookup results were being handled with int types.

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

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

No functional change should be incurred.

Change-Id: I31aeabb4ae3194a00b29a1fa767d05af167b4e4f
Reviewed-on: http://gerrit.openafs.org/12117
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams <3chas3@gmail.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-12-21 18:14:35 -05:00
Mark Vitale
17ca935bbd afs: pioctl kernel memory overrun
CVE-2015-8312:
Any pioctl with an input buffer size (ViceIoctl->in_size)
exactly equal to AFS_LRALLOCSIZE (4096 bytes) will cause
a one-byte overwrite of its kernel memory working buffer.
This may crash the operating system or cause other
undefined behavior.

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

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

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

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

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

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

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

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

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

Change-Id: I1a536b3a53ec4b6721fbd39a915207da4358720c
2015-12-15 21:39:01 -05:00
Michael Meffie
634ca4fdc2 viced: add missing new lines to log messages
The server logger requires an explicit new line.

Change-Id: Iffbfcfee7499bfa745a63d1b5ccb8038ee06acd0
Reviewed-on: http://gerrit.openafs.org/11841
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-12-08 16:42:23 -05:00
Michael Meffie
0bf9fba458 volser: range check acl header fields during dumps and restores
Perform range checks on the acl header fields when reading an
acl from a dump stream and when writing an acl to a dump
stream.

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

Change-Id: Ic7d7f615a37491835af8d92f3c5f1b6a667d9d01
Reviewed-on: http://gerrit.openafs.org/11702
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2015-12-03 00:20:54 -05:00
Benjamin Kaduk
888fc16db5 volser: set error, not code, before rfail
The rfail cleanup handler overwrites 'code' ~unconditionally, but
does use an existing 'error' value if present.  Since the intent
is to return failure to the caller, preserve the code in the error
variable and do so.

FIXES 131897

Change-Id: I25db2f9ad75a5b856626d39d35f97a09f26bd7a9
Reviewed-on: http://gerrit.openafs.org/12108
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2015-12-02 23:59:51 -05:00
Michael Meffie
2f3b27ac47 util: add CloseLog routine to close the server log
Add the missing complement to OpenLog().

Change-Id: I45e7e5d2da3241c163d2d4baa6b386167e90e582
Reviewed-on: http://gerrit.openafs.org/12002
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2015-12-02 23:58:01 -05:00
Michael Meffie
d646387c8e salvager: redd up showlog global flag
Clean up the show log flag so it is only set by the salvager and
is reset when spawning a child process.

Change-Id: I1702cf98faca583409594d1199a8215ffe08a75e
Reviewed-on: http://gerrit.openafs.org/12001
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2015-12-02 23:53:58 -05:00
Michael Meffie
4ed8f850b4 dafs: log to stderr when running salvageserver in client mode
When the -client option is given to the salvageserver, print
Log() messages to stderr instead of losing them.

Change-Id: I065e8136db9a8cc241639fbe34607db884751b95
Reviewed-on: http://gerrit.openafs.org/11729
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2015-12-02 23:52:31 -05:00
Michael Meffie
dc134f3eff dafs: remove the salvageserver -showlog option
Remove the salvagerserver option to print log messages to stdout.  This
was a carry over from the stand-alone salvager and is not appropriate for
a daemon.

Change-Id: I55b99112278cdabb3e9911948dbda6a628030951
Reviewed-on: http://gerrit.openafs.org/11815
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2015-12-02 23:52:07 -05:00
Brandon S Allbery
b800f7d9bd gtx: use getmaxyx() with sensible fallbacks
configure now checks for the standard getmaxyx() macro; failing that,
it looks for the older but pre-standardization getmaxx() and getmaxy(),
then falls back to the 4.2BSD curses _maxx and _maxy fields; if all
else fails, gtx building is disabled.

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

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

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