10467 Commits

Author SHA1 Message Date
Marc Dionne
9cfd7f768c Linux 3.9: hlist iterator change
hlist iterators have been reworked to not require a temporary
node parameter.

Change-Id: Ibea1295163bd39ff2901a2194aa46c3d342f5128
Reviewed-on: http://gerrit.openafs.org/9403
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2013-03-20 08:12:51 -07:00
Jeffrey Altman
b5675b57f8 Windows: Avoid cm_Analyze race on cm_serverRef lists
cm_Analyze() accepted as a parameter a pointer to the first element
on a cm_serverRef list which is only ever used for VL operations.

cm_Analyze() would separately call cm_GetVolServerList() to obtain
the cm_serverRef list for RXAFS operations.  Then the variable 'serversp'
would be set to the first element of the list.

'serversp' was then used to refer to the list and would be passed to
cm_SetServerBusyStatus() and cm_ResetServerBusyStatus() which would
in turn obtain the cm_serverLock while it manipulated the cm_serverRef
status flags for the elements in the list.

The problem is that passing a pointer to the first element of the
cm_serverRef list without holding cm_serverLock can permit the list
contents to be altered including removal of the first element.  If the
race is lost and the memory associated with the first element is freed
before access, the afsd_service.exe will crash.

This patchset makes a number of changes.  First, the cm_serverRef_t
parameter is changed from a pointer to the first element of the list
to be a pointer to the HEAD pointer of the list.  Since it is ever only
used for cm_cell.vlServerp lists, the parameter is renamed to
'vlServerspp'.   Second, a separate "cm_serverRef_t ** volServerspp"
variable is allocated for the return value from the cm_GetVolServerList()
operations.

cm_SetServerBusyStatus() and cm_ResetServerBusyStatus() are altered to
accept a pointer to the HEAD of the list instead of a pointer to the first
element.  The cm_serverLock is now held read instead of write because the
list itself is not being altered.  All of the state changes being applied
to the cm_serverRef objects are atomic.

Finally, cm_serverLock is held across all list traversals within
cm_Analyze().  A read lock is obtained if the elements of the list are not
being removed or inserted and a write lock is obtained if they are.

Change-Id: I48464e90a828706dad442c019c75a717b06d690b
Reviewed-on: http://gerrit.openafs.org/9625
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-18 14:26:24 -07:00
pete scott
19dc2fac40 Windows: Replace AFSDbgMsgLog func with macro
In order to reduce computation overhead when trace logging is not
active replace the AFSDbgMsgLog function call with a macro,
AFSDbgTrace.

Change-Id: I7bccee0ddffcd8488f81fcebbb970aa15c8dc52e
Reviewed-on: http://gerrit.openafs.org/9621
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-18 14:23:43 -07:00
Jeffrey Altman
1437789aba Windows: Test AFS_DBG_FLAG_BREAK_ON_ENTRY earlier
During AFSRedir.sys initialization, check the AFS_DBG_FLAG_BREAK_ON_ENTRY
registry flag before initializing the trace log system.

Change-Id: I928fab78b40dce51d2c0686bce68eb76f941b214
Reviewed-on: http://gerrit.openafs.org/9622
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-18 13:44:09 -07:00
Jeffrey Altman
f493a652b2 Windows: Increase AFS DeviceObject StackSize
Increase the StackSize parameter of the DeviceObjects allocated
by the AFS Redirector framework.  The StackSize parameter is used
to notify callers how many Irp Stack frames will be consumed.  Now
that the redirector is using IoCompletion routines, an additional
stack frame is required to handle calls to the AFS Redirector library
driver.

Thanks to Peter Scott for identifying the solution.

FIXES 131618

Change-Id: Ib66f884911f0d425e6e07f338a36b3ebedeb8871
Reviewed-on: http://gerrit.openafs.org/9609
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-18 04:53:12 -07:00
Jeffrey Altman
830744ff43 Windows: File Attribute Reporting Consistency
Do a better job of consistently reporting file attribute information
via directory queries and file information queries.  Avoid computing file
attribute information for file information queries that do not return them
(e.g., Name Information) because computing it is expensive.

Change-Id: I5c8120698261f555edfa98e92230705b593aca36
Reviewed-on: http://gerrit.openafs.org/9613
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-16 15:10:09 -07:00
Jeffrey Altman
170bbbdb93 Windows: netbios name comparisons are case insensitive
When parsing the symlink target string to categorize it as AFS Symlink
or DFS Link, the comparison with the netbios name string must be case
insensitive.  Otherwise, symlinks are reported to the redirector as
DFS Links.  For the most part they will work since the AFS redirector
requesting MUP to Reparse the \\AFS path will call back into the AFS
redirector.  However, the attributes on symlinks to files will be wrong
as DFS Links can only be links to directories.

Change-Id: Ia9652991549b0783f7a534b071ff99ceabdd3382
Reviewed-on: http://gerrit.openafs.org/9612
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-16 15:09:54 -07:00
Jeffrey Altman
a8599a1265 Windows: add RDR_ExtAttributes
Add RDR_ExtAttributes to compute the file attributes for redirector
queries.   The attributes reported via the RDR interface need to be
different from the SMB interface because the SMB interface does not
support reparse points nor does it support DFSLinks.

Change-Id: I5d5172f5afc1d50e2622e2068e20447cd1098fbb
Reviewed-on: http://gerrit.openafs.org/9611
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-16 15:09:41 -07:00
Jeffrey Altman
e5966117c4 Windows: drive mapping enumeration infinite loop
If WNetEnumResource returns an error as opposed to success, such as
ERROR_UNEXP_NET_ERR, the enumeration loop would retry forever passing
zero for 'cEntries' which in turn results in a successful response
containing zero entries.

Change the while conditional to test for continued success instead
of ERROR_NO_MORE_ENTRIES.

Change-Id: I93af73b379aa455de7a8b3264b5178d482bb52b0
Reviewed-on: http://gerrit.openafs.org/9610
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-16 15:09:21 -07:00
Jeffrey Altman
086b47404f Windows: remove last bits of BIOD from Direct Store
Direct I/O Store operations are performed directly against a memory
buffer stored in the background direct store rock structure.  There is no
BIOD used in the current implementation.  Remove the BIOD from the call
stack.

Change-Id: I78d7b898a6eec5eb39c943e760a678913b42bf0d
Reviewed-on: http://gerrit.openafs.org/9607
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-16 15:09:03 -07:00
Jeffrey Altman
adb6add99a Windows: VolumeInfoReadOnlyFlag registry option
Windows 7 Explorer Shell has a bug when processing drive letters
mapped to UNC paths whose target volume information specifies the
FILE_READ_ONLY_VOLUME flag.  When set, not only is the .readonly
volume treated as read only but all volumes that can be accessed via the
drive letter.   This bug is fixed in Windows 8.

Add a registry configuration option to permit configuration of the
behavior.  Sites that do not use drive letter mappings will want to
enable it even on Windows 7 because it permits the Explorer Shell
to disable the "Delete" and "Rename" options and others when the current
directory is read only.

The default is disabled on Win7 and below; enabled on Win8 and above.

Change-Id: I73bbaf7d40918650b1a217ed44409c0679920536
Reviewed-on: http://gerrit.openafs.org/9606
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-16 15:08:25 -07:00
Jeffrey Altman
ec5fd2ce07 Windows: Protect against DirEntry with NULL ObjInfo
During cleanup protect AFSExamineObjectInfo() and AFSExamineDirectory()
from DirectoryCB objects that have a NULL ObjectInformation pointer.

Change-Id: Id46f6b53ec4861f5ac2d28b918d073201d2433ce
Reviewed-on: http://gerrit.openafs.org/9603
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-16 15:07:26 -07:00
Mark Vitale
1092cbe34f vos: noise messages when attempting to delete non-existent volume
With vos refactor commit f4e73067cdef990262c69c38ac98761620a63f25,
some formerly conditional volume deletes are now unconditional.
This regresses 'vos move' output with harmless "error" messages
when AFSVolTransCreate() returns VNOVOL:
  "Failed to start transaction on <volume>"
  "Volume not attached, does not exist, or not online"

Modify DoVolDelete() to return early (and silently) with VNOVOL
in this case, allowing the caller to handle this appropriately.

Change-Id: I21a72e38f330335adf97ac50a7ac7d0fb97c1a9c
Reviewed-on: http://gerrit.openafs.org/9596
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2013-03-13 09:49:25 -07:00
Antoine Verheijen
bb42c02ce5 OpenBSD: Replace "vnodeop_desc" with "vops" in kernel module.
In OpenBSD 4.9, the vnode operations vector in the "vnode" struct
was changed from using a "vnodeop_desc" struct to a new "vops"
struct. This patch makes the appropriate changes to the OpenBSD
kernel module support to accommodate the change.

Change-Id: Ib47259e1213e29658a691ce3a53d7ac88e8d746b
Reviewed-on: http://gerrit.openafs.org/8928
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2013-03-13 07:31:34 -07:00
Jeffrey Altman
4811f432ba Windows: avoid null cellp dereference during dump
When performing a memory dump if cm_ucell_t.cellp is NULL, do
not attempt to print the cell name.

Change-Id: I146b90b5424b93d0c52a758b33fcff1bcf441e77
Reviewed-on: http://gerrit.openafs.org/9582
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-12 06:53:07 -07:00
Jeffrey Altman
3e4daf06a6 Revert "Windows: Treat all cached writes as write-through"
This reverts commit 5130681fa2d4a35d3f0b578d92c5db1892fdfb18.

Change-Id: If33a6e1f6969628eaa74d5a56f2eec5560d827f4
Reviewed-on: http://gerrit.openafs.org/9572
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-12 06:52:55 -07:00
Jeffrey Altman
eecf7a1372 Windows: Enforce free space checks every 1MB
Instead of performing a free space (or quota) check on every extending
write, perform the check only when the file length is increased beyond
the next 1MB boundary.   The file server permits 1MB quota over runs
and issuing the volume status rpc to the file server is extremely
expensive.  Especially for append only applications that write just a few
bytes at a time.

Change-Id: I74ff17ba5a95adb41350add24bc09a74c950a4fb
Reviewed-on: http://gerrit.openafs.org/9555
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-12 06:52:43 -07:00
Simon Wilkinson
8b76110e23 bos: Remove theoretical overflow in DateOf
DateOf copies the results of ctime into a static buffer. Typically
ctime will return a 26 byte string, but if you pass it a year larger
than 9999 (which we shouldn't), you can get a 32 (or more) byte string.

Get rid of this unlikely event by using strlcpy for the copy. We already
truncate at 24 bytes when we remove the \n, so this shouldn't cause any
further problems.

Really, this whole thing should be rewritten to use strftime.

Caught by coverity (#985776)

Change-Id: I18f6828d6ec3d79ecaf1dad8e27d3e8691ce87d5
Reviewed-on: http://gerrit.openafs.org/9551
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2013-03-12 06:51:49 -07:00
Simon Wilkinson
4e9c6eb9d5 bos: Don't overflow buffer with key data
When parsing key data from the command line, don't overflow the
buffer used to hold it - instead just give an error if the data
is too long.

Caught by coverity (#985775)

Change-Id: I44fb62d30c5022e650475b3ca51a28bcb7cf1e06
Reviewed-on: http://gerrit.openafs.org/9550
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2013-03-12 06:51:42 -07:00
Simon Wilkinson
45993e3ad5 bos: Don't overflow cellname buffer
Don't overflow the fixed sized cellname buffer when copying the
information in from the command line - instead, just use a
dynamically allocated buffer.

Caught by coverity (#985775)

Change-Id: If87b1ba9bcb990d3145a89627e212144cd78f5a0
Reviewed-on: http://gerrit.openafs.org/9549
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2013-03-12 06:51:37 -07:00
Simon Wilkinson
21166744bf butc: Init volheader before using it for hton
When converting a volume header from host to network order, make
sure that any unused fields in the structure are zero'd, so we don't
end up filling them with stack garbage in the network version of
the structure.

Caught by coverity (#985956)

Change-Id: I3e039ffcb102a97afeb0e2223de12523f53b0a67
Reviewed-on: http://gerrit.openafs.org/9548
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2013-03-12 06:51:32 -07:00
Simon Wilkinson
cfeda375fd bucoord: restore requires server and partition
The VolRestoreCmd sub command requires that the user specifies
the server and partition - calls which don't do so won't get past
libcmd. Don't check again in the handler that they have been supplied,
as it confuses things.

Caught by coverity (#985953)

Change-Id: Id4548c117b677bd2048744ade8fd91bb15e0e35e
Reviewed-on: http://gerrit.openafs.org/9547
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2013-03-12 06:51:26 -07:00
Simon Wilkinson
d672d5ee78 upserver: Don't overflow file and hostname buffers
If the user specifies a ridiculously long command line, don't
overflow the filename or hostname buffers with what they supply.

Caught by coverity (#985911)

Change-Id: Ia73f9fb94491f5691358eec1d13dbdd2651a604c
Reviewed-on: http://gerrit.openafs.org/9546
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2013-03-12 06:51:20 -07:00
Derrick Brashear
ceac74a6ba afscp: null-terminate root.cell dir if needed in dynroot mode
instead of doing a check for something which will never be true,
and then terminating, just terminate if it's not already
null-terminated.

Change-Id: I8ad18800de22c8d10eb27fbcb2fffb2b3a5a9127
Reviewed-on: http://gerrit.openafs.org/9439
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chaskiel Grundman <cg2v@andrew.cmu.edu>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2013-03-12 06:34:49 -07:00
Jeffrey Altman
2998ab4535 Windows: Use Microsoft IO_REPARSE_TAG_SYMLINK tag
For symlinks and DFS Links use Microsoft's NTFS Symlink tag,
IO_REPARSE_TAG_SYMLINK, instead of the OpenAFS assigned tag.

The DeleteFile() and RemoveDirectory() Win32 APIs do not delete
non-Microsoft reparse points and instead delete the target object.
While it is possible for Take Command and potentially Cygwin to
alter their behavior with AFS specific knowlege, it is not possible
to alter the Explorer Shell, cmd.exe and powershell.

Using the Microsoft tag is a violation of Microsoft policy.

Change-Id: I90a419fe21637bb871d08528463d1178078a9947
Reviewed-on: http://gerrit.openafs.org/9497
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 17:47:10 -07:00
Jeffrey Altman
241382e3bf Windows: GetReparseData UNC path format
When specifying UNC paths for Symlink and UNCLink targets output
the paths using true UNC notation "\\server\..." instead of "\server\...".

Change-Id: I51ecc6578fb0a984a5ad44b1bf1e40556e737465
Reviewed-on: http://gerrit.openafs.org/9426
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 17:46:37 -07:00
Jeffrey Altman
470b57cc4a Windows: cm_BPlusDirEnumBulkStatNext index error
In cm_BPlusDirEnumBulkStatNext the 'next' variable was being set
even if the FileId was not added to the list of objects added to
the cm_bulkStat array.  Delay the assignment to ensure that 'next'
refers to the first element in the array.

In the CM_ERROR_BULKSTAT_FAILURE processing, 'next' is used to
obtain a reference to the cm_scache object that is supposed to
correlate to the [1] entry in the array.  If 'next' == -1, there
is no such entry.  Add a conditional to ensure that 'next' is not
used when its value is -1.

Change-Id: I4ebc49de4bf67eee5a28790cd49f0128891cc202
Reviewed-on: http://gerrit.openafs.org/9450
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 17:45:52 -07:00
Jeffrey Altman
ee79fb61f5 Windows: PopulateCurrentEntry Symlink Targets
Handle a broader range of symlink target formats and be more
precise regarding what is an afs symlink or a dfs link.

Change-Id: Ia37c1adf5d64ba44fffca976885a455e6900a047
Reviewed-on: http://gerrit.openafs.org/9428
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 17:40:27 -07:00
Jeffrey Altman
abbee864c4 Windows: Claim success for Delete Reparse Tag
The typical pattern for deleting a reparse point is

 1. open reparse point object
 2. delete reparse tag
 3. set delete on close
 4. close handle

Claim success when we receive delete reparse tag fsctl so that
the delete on close disposition can be set.

Change-Id: I8f4212dd6ba04be95455eaa210e632ca59cfa7c8
Reviewed-on: http://gerrit.openafs.org/9427
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 17:40:05 -07:00
Jeffrey Altman
d64cd65a23 Windows: Report actual volume creation time
The cm_scache.volumeCreationDate is populated by any non-bulkstat
callback issuing operation.  If it is not set at the time the
redirector requests volume information, force an RXAFS_FetchStatus
and then use the resulting timestamp in the response.

Change-Id: I8ab471767dd6525efc71deff073d54ae38f1f462
Reviewed-on: http://gerrit.openafs.org/9554
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 17:39:46 -07:00
Jeffrey Altman
002d97363f Windows: RDR_UpdateFile dscp != scp
Do not set bScpLocked when obtaining scp->rw as scp != dscp.

Change-Id: I878166cd510a188a0e56cc92660e74b9625c3ab6
Reviewed-on: http://gerrit.openafs.org/9553
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 17:39:27 -07:00
Jeffrey Altman
75ee4fb1af Windows: Service processing for Symlink creation
Initial support for symlink creation via the Win32 CreateSymbolicLink api.
Add support for AFS_REQUEST_TYPE_CREATE_SYMLINK redirector requests via
the new RDR_CreateSymlinkEntry() function.

Since CreateSymbolicLink api creates a new directory or file object and
then assigns the Microsoft reparse tag data to that object,
RDR_CreateSymlinkEntry must first delete the empty directory or file and
then create the new symlink object in its place.  If the empty object can
be removed but the symlink cannot be created, STATUS_FILE_DELETED is
returned to indicate to the redirector that a failure occurred that
changed the state of the directory without creating a new object.

If the empty object cannot be removed, a STATUS_ACCESS_DENIED error will
be returned and the empty object will unfortunately remain in the AFS
directory.

Target path translation is performed.  Absolute AFS paths are stored in
UNIX notation.  Absolute non-AFS UNC and device paths are prefaced with
"msdfs:".

Change-Id: If8b4729dd5fffddc71221750852b8be731c83cab
Reviewed-on: http://gerrit.openafs.org/9425
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 17:39:11 -07:00
Simon Wilkinson
1c582768df auth: Don't overflow lower case cell string
When building tcell_l in kerberosSuperUser, make sure that we
don't overflow the string that we're constructing.

Use the opr_lcstring function to do the lower case conversion,
rather than rolling our own.

Caught by coverity (#985772)

Change-Id: I6e28cfc54883aac7e3a3eb2f4e2b2bf7ebc0bc63
Reviewed-on: http://gerrit.openafs.org/9544
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2013-03-11 07:27:39 -07:00
Simon Wilkinson
cc95fca8e1 auth: Don't overflow buffer in CompFindUser
The fullname buffer in CompFindUser is theoretically big enough
to take the data usually supplied to it. However, play it safe by
using strlcat and strlcpy to catch buffer overflows.

Caught by coverity (#985771)

Change-Id: Icc80d012b61ae90e1a62a814f7a6d552bb264294
Reviewed-on: http://gerrit.openafs.org/9543
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2013-03-11 07:27:17 -07:00
Simon Wilkinson
8c664a8c0f auth: Catch long cells in backwards compat code
ktc_SetTokenEx can fall back to calling the SetToken pioctl when
the kernel module doesn't support the newer call. When we do this,
we have to transform the token structure into the older format.

Catch tokens whose cells are too long to be represented in the
older format, and bail with KTC_INVAL, rather than overflowing the
array.

Caught by coverity (#985770)

Change-Id: Ibaa1cc92c494cc6f4e56ebe7b16109d4558db131
Reviewed-on: http://gerrit.openafs.org/9449
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2013-03-11 07:26:56 -07:00
Simon Wilkinson
b0b3def56c audit: Fix overflow in file backend
If the filename passed to open_file was larger than MAXPATHLEN-5,
then we'd overflow the oldName buffer when creating the backup
filename. Fix the overflow by using a malloc'd buffer instead.

Caught by coverity (#985767)

Change-Id: Ie364aae0749b3658ab11a354844878d10c6970ab
Reviewed-on: http://gerrit.openafs.org/9448
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
2013-03-11 07:26:41 -07:00
Jeffrey Altman
249a593460 Windows: IsSpaceAvail lock order violation
cm_IsSpaceAvailable() obtains the cm_scache.rw lock of the volume
root directory.  Therefore it is a lock order violation to call the
function while any other cm_scache.rw lock is held belonging to an
object in the same volume.   vnode 1 is always less than any other
vnode value.

Change-Id: Id34591b6ccec8d7e8e0fe48e3357c991cd99acfb
Reviewed-on: http://gerrit.openafs.org/9552
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 07:05:23 -07:00
Jeffrey Altman
f6180b9da6 Windows: Fix directory to service null mask lookups
The direct to service for non-wildcard lookups, commit
b7ba97ad537bd0e9a241f052ddd1c3a50c74745b, introduced a bug when the search
mask is left unspecified.   Do not set bNonWildcardMatch to TRUE
when the mask is NULL.

Change-Id: I6c4846b443acc7e5e42d4e83e75ef383fc400db9
Reviewed-on: http://gerrit.openafs.org/9542
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 07:04:48 -07:00
Jeffrey Altman
816834cc03 Windows: Permit deletion of reparse points
AFSSetDispositionInfo did not set the AFS_DIR_ENTRY_PENDING_DELETE
flag if the DirectoryCB type was mountpoint, symlink, dfslink or invalid.
This patchset permits the flag to be set so reparse point objects can be
deleted without using the AFS "symlink.exe remove" command.

Change-Id: I03e1cb7b08989950a4307e59073e5fb712d1a901
Reviewed-on: http://gerrit.openafs.org/9475
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 07:04:06 -07:00
Jeffrey Altman
540a73dc18 Windows: AFSLocateNameEntry Backup Volume Change
When AFSLocateNameEntry() calls AFSBackupEntry() in the name array it is
possible that the DirectoryCB returned belongs to a different VolumeCB.
If so, pCurrentVolume must be updated and reference counts must be
adjusted.

Change-Id: I9fcd30374b20f2e1c214a019feeab55c30ce9666
Reviewed-on: http://gerrit.openafs.org/9465
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 07:03:40 -07:00
Jeffrey Altman
c9846c9e80 Windows: AFSLocateNameEntry OutVolumeCB can be NULL
It is possible for the AFSLocateNameEntry OutVolumeCB parameter
to be assigned a NULL value upon return.   Handle it in the callers.

Change-Id: I15e4581d4655dbaca7c4ca4b9e9af758e97c5c95
Reviewed-on: http://gerrit.openafs.org/9464
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 07:03:18 -07:00
pete scott
0cc602a065 Windows: RDR SymbolicLink create support
Permit the redirector to handle Microsoft's IO_REPARSE_TAG_MOUNT_POINT
and IO_REPARSE_TAG_SYMLINK requests.   The IO_REPARSE_TAG_SYMLINK request
is issued as a result of a CreateSymbolicLink Win32 API.

Creating a symlink in Windows is not equivalent to the way a symlink is
created in AFS or UNIX.  Instead of creating a symlink object whose data
string represents the target and mode bits indicate that the stream should
be treated as a link, on Windows it is a two step process.

To create a symlink to a directory, create an empty directory and then
assign the reparse tag data to the directory object.  To create a symlink
to anything else, create an empty file and assign the reparse tag data to
the file.  Deleting a reparse point simply removes the reparse tag data
and not the underlying directory or file.

The way this will work for AFS is that assigning reparse data to an
existing directory or file will require that the object be deleted from
the directory and a new symlink object be created in its place.  This is
why upon successful completion of the upcall to the service the directory
object information has the AFS_OBJECT_FLAGS_DIRECTORY_ENUMERATED flag
cleared.

This patchset permits symlink creation but does not do anything to support
symlink removal.

Symlink target data is not validated.

Change-Id: Ie7019445a7c307dcb2cd47beee47d02e1a82145f
Reviewed-on: http://gerrit.openafs.org/9424
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 06:52:27 -07:00
Jeffrey Altman
1b048f1f57 Windows: Avoid race during cm_FreeServerList
cm_FreeServerList obtains cm_serverLock exclusively and in some
circumstances will call cm_FreeServer().   cm_FreeServer() will
drop the cm_serverLock if the cm_server_t.refCount is zero in order to
avoid a lock order violation when calling cm_GCConnections() since
cm_connLock is higher in the lock hierarchy.

The call to cm_FreeServer is performed after the cm_serverRef_t
to be deleted is identified but before it is removed from the list.
There is the potential for two threads calling cm_FreeServerList()
to race and for more than one thread to attempt to delete the same
cm_serverRef_t twice.

Fix this by:

1. maintain a private copy of the cm_server_t pointer, delete the
cm_serverRef_t and update the list pointers before calling cm_FreeServer().

2. obtain and release a refcnt on the next cm_serverRef_t to ensure
that it is not deleted out from underneath the thread in case the
cm_serverLock is dropped.

Change-Id: Ia7b6eed66e9ba306c07d47027262e1a8ad1e52ac
Reviewed-on: http://gerrit.openafs.org/9391
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-11 06:50:45 -07:00
Simon Wilkinson
f4373e7867 aklog: Fix buffer overflows in next_path
Use strlcpy and strlcat

Caught by coverity (#985765)

Change-Id: I2fc3d04a762f6872c31fe728e1ab0247ac16e6de
Reviewed-on: http://gerrit.openafs.org/9447
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-09 19:16:39 -08:00
Simon Wilkinson
2902ef9397 aklog: Protect against overflows from cmdline
The cell, realm and path arrays are populated based on the user's
command line, and xlog_path is populated from their passwd map
entry. Protect against all of these overflowing, by making suitable
use of strlcpy and strlcat.

Caught by coverity (#985764, #985904)

Change-Id: Ia8f1816b010eb2b85b537e156de2b7983e4626ba
Reviewed-on: http://gerrit.openafs.org/9446
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-09 19:16:25 -08:00
Simon Wilkinson
19d2683d71 aklog: Avoid overflows in get_afs_mountpoint
When working with the fixed length cellname buffer, use
strlcat and strlcpy rather than strcat and strcpy.

Caught by coverity (#985763)

Change-Id: Idfb3a0562d4028f5d1aa134b7ab0b5fa2dd60edb
Reviewed-on: http://gerrit.openafs.org/9445
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-09 19:16:14 -08:00
Simon Wilkinson
788a6b67a0 aklog: Fix overflows in auth_to_path
In the auth_to_path routine, don't use strcpy and strcat when
working with the fixed length pathtocheck buffer. Instead, use
strlcpy and strlcat to ensure that all string operations fit within
the buffer limits.

Caught by coverity (#985762)

Change-Id: I66ae11e1f49c66574d457fd79e97dd647ac98a73
Reviewed-on: http://gerrit.openafs.org/9444
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-09 19:16:01 -08:00
Simon Wilkinson
95cd5b1d95 afsmonitor: Fix theoretical overflow of handler string
Don't do an unbounded copy into the thresh structure's handler
string, in case the caller has passed us a string which is too
long.

Instead, switch to strlcpy for all string copies.

Caught by coverity (#985761)

Change-Id: I80e3d35d7a9a4b57e8efc0cb0c7b2dc12f021063
Reviewed-on: http://gerrit.openafs.org/9443
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-09 19:15:45 -08:00
Simon Wilkinson
98191d7761 afsmonitor: Use roken
Include the roken.h header, and remove the redundant system
includes from afsmonitor.c

Change-Id: Ia3eb8a7a0bb1e77d928d26cdfc87f818e6791e16
Reviewed-on: http://gerrit.openafs.org/9463
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-09 19:15:15 -08:00
Simon Wilkinson
fcb7974b83 util: Avoid overflow in GetNameByINet
We copy the results of gethostbyaddr into a fixed length buffer
without checking whether they fit. Add a length check, and use
strlcpy to do the copy to make sure we can't overflow.

Caught by coverity (#985912, #985872)

Change-Id: I1e8f0fbb2577199c25201940f54646a4acdbbd37
Reviewed-on: http://gerrit.openafs.org/9393
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
2013-03-09 19:14:31 -08:00