13472 Commits

Author SHA1 Message Date
Mark Vitale
5af53db475 afs: silence bogus warning about dcListCount uninitialized
Commit 3be5880d1d2a0aef6600047ed43d602949cd5f4d 'afs: Avoid panics in
afs_InvalidateAllSegments' is correct, but at least one compiler (gcc
4.3.4 on SLES 11.3) is fooled into issuing a warning:

    [...]/afs_segments.c: In function 'afs_InvalidateAllSegments_once':
    [...]/afs_segments.c:506: error: 'dcListCount' may be used uninitialized in this function

To silence the bogus warning, initialize dcListCount when defined.

Reviewed-on: https://gerrit.openafs.org/14048
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 09ec1073b4c5d2eb70dcf5d8063018bc82e5a35e)

Change-Id: I84b1d4b8b9041242d64b03a84ad4392ff9778950
Reviewed-on: https://gerrit.openafs.org/15266
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 10:02:35 -05:00
Ganesh Chaudhari
05a4adcdff macos: Update postinstall instructions for MacOS 13
System preferences is getting replaced by System settings in MacOS 13.
So, this commit will address the required changes in the dialog box
which gets popped after installing OpenAFS.

Signed-off-by: Ganesh Chaudhari <gangovind@in.ibm.com>
Reviewed-on: https://gerrit.openafs.org/15150
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit c620c91416f726357d556ce043b6cc285cf87a8b)

Change-Id: I6d8da31dc3735cab93c2b2226d436960c77b78ff
Reviewed-on: https://gerrit.openafs.org/15264
Reviewed-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:49:09 -05:00
Ganesh Chaudhari
9c6503e117 macOS: Add support for aarch64-*-darwin* sysname
As of libtool 2.4.7, the supplied config.guess file modifies
the sysname returned on macOS arm64 from arm-*-darwin* to
aarch64-*-darwin*. As a result, trying to build OpenAFS on
macOS arm64 fails with the following message:

  configure: error: An AFS sysname is required

To avoid this problem, added support for aarch64-*-darwin*.

Signed-off-by: Ganesh Chaudhari <gangovind@in.ibm.com>
Reviewed-on: https://gerrit.openafs.org/15149
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit d38b068627f5e84cead88af85f904fea0c8edb6d)

Change-Id: I7685c2b75f62fe28b8723e00fba22f5f7fe795f1
Reviewed-on: https://gerrit.openafs.org/15263
Reviewed-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:47:33 -05:00
Ganesh Chaudhari
41e46e12ac macos: Add support for MacOS 13.0 (Ventura)
This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on OS X 13.0 “Ventura”.

Thank you Kailas Zadbuke (IBM) and Harish Sharma (IBM) for your help.

Reviewed-on: https://gerrit.openafs.org/15139
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit e5a97ef2b46c8821db81363f4917ef214fc34a5e)

Change-Id: I5092fe02a3bc3b7a6cb4ecfd4c8660278da9b0e8
Reviewed-on: https://gerrit.openafs.org/15262
Reviewed-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:45:52 -05:00
Marcio Barbosa
f6b088d2a7 klog.krb5: remove "save and reuse password" logic
In order to avoid repeated requests for the user's password, klog.krb5
caches and reuses it whenever necessary. However, with the introduction
of commit 3a9a5783cd1fd73902655f0876e2069b42688c94, klog.krb5 always
requests a TGT regardless of the state of writeTicketFile, eliminating
the need for possible extra requests for the user's password.

Moreover, krb5_get_init_creds_password() does not accept a custom
prompter on macOS (returns EINVAL). Consequently, if the -password
argument is omitted, klog.krb5 fails with the following error:

klog: Invalid argument Unable to authenticate in realm <REALM>

Given that the user won't be prompted for a password multiple times,
remove the "save and reuse password" logic and use krb5_prompter_posix()
as the prompter function (instead of klog_prompter).

Relevant issue identified by gangovind@in.ibm.com.

Reviewed-on: https://gerrit.openafs.org/14643
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Tested-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit a10f99dbe025c74fb488b501daaf1f9574830cec)

Change-Id: I6587283d93a2dc801c8a41f0663a6de1b5d8a045
Reviewed-on: https://gerrit.openafs.org/15261
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:44:19 -05:00
Marcio Barbosa
69f1ffb898 DARWIN: On macOS 12, mount afs on user's directory
Currently, /afs is mounted/unmounted by a LaunchDaemon. In order to
unmount /afs on restart/shutdown, this daemon runs umount -force /afs.
Unfortunately, SIP (System Integrity Protection) is not allowing the
LaunchDaemon in question to run this command successfully on macOS 12
(exclusively on restart/shutdown):

  umount: Operation not permitted

In this situation, afs can't be turned off correctly, leaving many
unkillable afsd processes lingering around. As a result, the
restart/shutdown process gets stuck indefinitely.

Fortunately, this problem doesn't happen if /afs is mounted on an user's
directory. That said, avoid this issue by mounting /afs on the current
user's directory (/Users/$USER/OpenAFS/afs). Notice that afs is still
accessible (including for other users) through a synthetic link added in
the root directory (/afs -> /Users/$USER/OpenAFS/afs).

Reviewed-on: https://gerrit.openafs.org/14925
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 1c7eda8ea83bee3e674435109efccbc6082e4765)

Change-Id: Idb013d76f00a78cfebd790900eabbcd6968029b7
Reviewed-on: https://gerrit.openafs.org/15260
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:42:37 -05:00
Marcio Barbosa
fd64dcd3fb macos: Packaging support for MacOS X 12.0
This commit introduces the new set of changes / files required to
successfully create the dmg installer on OS X 12.0 "Monterey".

Reviewed-on: https://gerrit.openafs.org/14924
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 873d803a3dc7acffd74c9432872bed4f6575abf9)

Change-Id: I4cbbbeb5eb740b4f7979fa2137cb7faa9027d774
Reviewed-on: https://gerrit.openafs.org/15259
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:40:52 -05:00
Marcio Barbosa
046e787f1f macos: Add support for MacOS 12.0
This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on OS X 12.0 "Monterey".

Reviewed-on: https://gerrit.openafs.org/14923
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 7a862f940b2e2f2169e267fc6deb31db8f3534c0)

Change-Id: I4f1b42002c670e15b3fecfd8d0cfb2f461b8d136
Reviewed-on: https://gerrit.openafs.org/15258
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:39:07 -05:00
Mark Vitale
fc80c74689 DARWIN: disable kextutil check for versions requiring notarization
Our kextutil signing check will fail for releases that require
notarization (Mojave 10.14.5 and up, Catalina 10.15 all versions),
because we aren't notarized yet at the time of the check.

Instead, disable the check for those releases.

Reviewed-on: https://gerrit.openafs.org/14222
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit d2e755e33a266df17169a1fc05db1e540b5e76af)

Change-Id: Ie191503cb3f57c60a2a9c31e638dc7f79c496591
Reviewed-on: https://gerrit.openafs.org/15257
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:37:39 -05:00
Mark Vitale
6652a63279 DARWIN: ensure OpenAFS.pkg is signed
Installation fails because the OpenAFS.pkg was inadvertently omitted
from the codesign logic.

Ensure that the package is signed.

Reviewed-on: https://gerrit.openafs.org/14221
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 336f5d91c6f4e93f77560d456fb29fbd82b237e5)

Change-Id: I58c0ca157653b76562ee7071a567db681d33fc2e
Reviewed-on: https://gerrit.openafs.org/15256
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:35:23 -05:00
Mark Vitale
d20def23d0 DARWIN: ensure PrefPane materials are properly signed
Notarization fails because some prefPane materials were inadvertently
omitted by the codesign logic.

Ensure that these objects are properly signed.

Reviewed-on: https://gerrit.openafs.org/14220
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit d3f8d8122880de9f5b25868b39efd1cc7d385ff6)

Change-Id: Ice6c954e41e375fbe8ac670586d2616c565f0499
Reviewed-on: https://gerrit.openafs.org/15255
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:33:52 -05:00
Marcio Barbosa
35fde5873a DARWIN: Replace afs_osi_cred by allocated ucred
Building the current version of OpenAFS on macOS Monterey arm64 results
in the following error:

 error: globals with authenticated null values are currently unsupported
 afs_ucred_t afs_osi_cred;

To avoid this problem, replace the global in question by a pointer to a
dynamically allocated afs_osi_cred (afs_osi_credp). Ideally we would
create a new credential with kauth_cred_create(), but this function is
not well documented and using it results in crashes. Moreover, if the
kauth_cred_dup() function were still available (private since XNU
1456.1.26 - macOS 10.6), we could also duplicate the current user's
credential during startup (like commit f40f466c7f did for BSD).

Reviewed-on: https://gerrit.openafs.org/14922
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 982d2f9dbe6586d06ffa2a61c02ea726b83b5902)

Change-Id: I720132478d4d1b742f63576e6a98e96c7a935885
Reviewed-on: https://gerrit.openafs.org/15254
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:32:04 -05:00
Andrew Deason
29f7182c3f 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).

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>
(cherry picked from commit 6e5638ac7297701a99ea396dee1df8f56a6a50da)

Change-Id: I17821e2cd0050bb0a468bfadda2c446beafeb537
Reviewed-on: https://gerrit.openafs.org/15253
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:30:22 -05:00
Andrew Deason
3ee628c2dc Remove alpha_dux/alpha_osf references
Several files were still referencing the alpha_dux* and alpha_osf*
sysnames. The code for these platforms has been removed, so get rid of
this cruft.

Reviewed-on: https://gerrit.openafs.org/13339
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 809ee49b80d7bc0e720aaebe78fb9ecfd453065d)

Change-Id: Iae1f642df6cfb4c2e757f0fc381cb98eb5bf448e
Reviewed-on: https://gerrit.openafs.org/15252
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:22:36 -05:00
Marcio Barbosa
8ec429d0a3 DARWIN: Drop afs_event lock before destroying it
On macOS arm64, a lock (lck_mtx_t) must be released (lck_mtx_unlock)
before it can be destroyed/freed (lck_mtx_free -> lck_mtx_destroy). If
this rules isn't respected, the operating system in question will panic
with the following message:

  panic("lck_mtx_assert(): mutex (%p) not owned", lock);

Unfortunately, the current shutdown process of the osi_sleep module
doesn't respect this rule. As a result, macOS arm64 panics when the
OpenAFS client is shut down/restarted. To fix this problem, release
afs_event->lck (EVTLOCK_UNLOCK) before destroying it (EVTLOCK_DESTROY).

Reviewed-on: https://gerrit.openafs.org/14933
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 93b88935999ad25bc22daf64f9ebff30957e0a27)

Change-Id: Ib81c3decc748c06b2f99cfa155095bffd1048f57
Reviewed-on: https://gerrit.openafs.org/15251
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:16:25 -05:00
Marcio Barbosa
b5dd4df6ec macos: Add support for Apple Silicon
This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on Apple M1 (macOS 11+).

Notice that kexts on Apple silicon must support the arm64e architecture,
since they run in kernel space and must support the same architecture
and restrictions as other kernel code. On the other hand, the utilities
that run on user space, like vos, fs, and others, have to be built for
arm64 (currently).

Reviewed-on: https://gerrit.openafs.org/14746
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Andrew Deason <adeason@sinenomine.net>
(cherry picked from commit cdbcb6f947feff528adc324dd6487b21083e23aa)

Change-Id: I854e7553b65956032a3c15aa427189bf8e4e3a0d
Reviewed-on: https://gerrit.openafs.org/15250
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:14:51 -05:00
Marcio Barbosa
33bcff698f macos: Refactor param.x86_darwin_200.h
In preparation for a future commit, try to make param.x86_darwin_200.h
more readable. Also, rename this file to param.darwin_200.h so code from
other architectures can be included in this header.

Reviewed-on: https://gerrit.openafs.org/14934
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 39b74c2c3725cfa39fc5076cd7803ee7d55923e3)

Change-Id: I184591c24fac37b4c5a2b6fab7b42850b3004744
Reviewed-on: https://gerrit.openafs.org/15249
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:12:50 -05:00
Marcio Barbosa
b9c3dbc0a6 build: Select param.h in sysname.m4
Currently, the way the file that will be used as param.h is selected
doesn't allow us to choose headers from other architectures, making
cross-compiling difficult. In an effort to facilitate this process,
select the header that will be used as param.h in sysname.m4. By doing
this, we will have more flexibility to select which header should be
used (in future commits).

Reviewed-on: https://gerrit.openafs.org/14914
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit d456bd9b258445f60745867c34ef7c7a8c7be187)

Change-Id: Iaaa372887ac17f352a6a4bb9c14b896e88e3b28b
Reviewed-on: https://gerrit.openafs.org/15248
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:11:10 -05:00
Marcio Barbosa
84b177ccc8 macos: Build afscell for supported architectures
Given that i386 is no longer supported, trying to build the current
version of afscell on macOS 11 (Big Sur) results in the following error:

error: The i386 architecture is deprecated. You should update your ARCHS
build setting to remove the i386 architecture.

To fix this problem, build afscell for all architectures listed in
ARCHS_STANDARD.

For the macosx11.0 sdk:

$ xcodebuild -showBuildSettings -scheme afscell -sdk macosx | grep ARCHS

    ARCHS = arm64 x86_64
    ARCHS_STANDARD = arm64 x86_64
    ARCHS_STANDARD_32_64_BIT = arm64 x86_64 i386
    ARCHS_STANDARD_32_BIT = i386
    ARCHS_STANDARD_64_BIT = arm64 x86_64
    ARCHS_STANDARD_INCLUDING_64_BIT = arm64 x86_64
    VALID_ARCHS = arm64 arm64e i386 x86_64

While here, add arm64 to the list of valid architectures.

Reviewed-on: https://gerrit.openafs.org/14745
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit dc6ced5e6d63ad89b1ad6f6b236a28b823abb59d)

Change-Id: I483c41a5954caa8ed080134d82f2e08a7c1973a4
Reviewed-on: https://gerrit.openafs.org/15247
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:07:57 -05:00
Cheyenne Wills
a0898c2d90 UKERNEL: avoid double include of roken.h
Commit 'afs: Replace strcpy &co by safer alternatives' (419f0cd7aa75719)
added an include for roken.h into UKERNEL/afsincludes.h.  Neither
UKERNEL/afsincludes.h or roken.h has a guard against a double include,
which can result in a build failure on older kernels (discovered on a
2.6.18 build):

 In file included from ~/openafs/src/afs/UKERNEL/afsincludes.h:30,
          from ~/openafs/src/afs/UKERNEL/afs_usrops.h:15,
          from ~/openafs/src/afs/UKERNEL/afs_usrops.c:24:
 include/roken.h:89: error: redefinition of typedef 'rk_socket_t'
 include/roken.h:89: error: previous declaration of 'rk_socket_t' was here
 In file included from ~/openafs/src/afs/UKERNEL/afsincludes.h:30,
          from ../afs/afsincludes.h:16,
          from ../afs/afs_bypasscache.h:68,
          from ~/openafs/src/afs/UKERNEL/afs_usrops.c:30:

Since roken.h is from an external source, we cannot update it to add
the necessary check.

Update UKERNEL/afsincludes.h to add a check to see if it has already
been included.

auth/ktc.c has a required include for roken.h, but it also can pull in
UKERNEL/afsincludes.h as well.  This can result in a double include for
roken.h.

Update auth/ktc.c to only include roken.h if not building UKERNEL.

Reviewed-on: https://gerrit.openafs.org/15130
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit cc0ffc56e85eec4133bcc5e745efa28f5d3c53a7)

Change-Id: I4508c2d4bb878dadce649f0da2af16c9efa69b91
Reviewed-on: https://gerrit.openafs.org/15265
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 09:04:54 -05:00
Marcio Barbosa
5993965112 DARWIN: Declare/include functions before using them
Every function should be explicitly declared before it can be called.
Since -Wimplicit-function-declaration is usually a warning and not an
error, calling undeclared functions does not prevent us from building
the code.

However, apple-clang 12 makes this an error by default, prohibiting the
build of the current version on macOS 11 (Big Sur).

To fix this problem, declare functions before calling them. Also,
include mach/thread_act.h into afs_call.c so the declaration of
thread_terminate() can be found on macOS. Last, given that the third
argument of PIOCTL() (if UKERNEL is defined) is a pointer, cast it to
'long'. Doing so, we can avoid another inhibited warning. Notice that
this PIOCTL definition is scoped to a single file (src/auth/ktc.c).

Reviewed-on: https://gerrit.openafs.org/14744
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit f9c96d0fd609e14fcb8ff7d9269024e026f742cb)

Change-Id: I70dadc44d40e1fc877f9e0490e28636907432faa
Reviewed-on: https://gerrit.openafs.org/15246
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:59:15 -05:00
Andrew Deason
34d869996d afs: Organize setpag() declarations better
The current declarations for setpag() are a mess (not to be confused
with many other setpag functions, like afs_setpag()), accumulated
across various commits over time. Shuffle the #ifdef logic around, so
this becomes a much more straightforward #ifdef ladder, with one
declaration per conditional. And move the LINUX declaration to be next
to all of the others (even the LINUX setpag() is declared in
osi_groups.c, not osi_misc.c, so it's in the wrong spot anyway).

The resulting #ifdef logic should be identical to the original code,
but is now easier to follow. For the BSDs, it may look like we have
changed the conditional for the case of "XBSD && !DFBSD && !FBSD &&
!NBSD", but that's a very roundabout way of saying OBSD (OpenBSD).

Reviewed-on: https://gerrit.openafs.org/14883
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 738a6487ad088068d19a18c6330e01a40f2fd278)

Change-Id: I9dc933fa96fc6e7839c010c5207e644179343898
Reviewed-on: https://gerrit.openafs.org/15245
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:57:50 -05:00
Marcio Barbosa
b56d5cdfa8 bucoord: Introduce ubik_Call_SingleServer_BUDB_*
In an effort to avoid the usage of undeclared functions, add wrappers
for ubik_Call_SingleServer() (_BUDB_GetVolumes(), _BUDB_DumpDB()) and
adjust its callers accordingly.

Also, make sure that ubik_Call_SingleServer() uses the same signature as
ubik_Call(). This change helps us to get rid of casting errors.

Reviewed-on: https://gerrit.openafs.org/14886
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 981b3d723ec56dad553be570147d1b2aa632f4e1)

Change-Id: I5893a939bc5cd64eec9dbbf1ce8a0dc5032c81f0
Reviewed-on: https://gerrit.openafs.org/15244
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:55:48 -05:00
Marcio Barbosa
1e6fd4ceae afs: Ensure dirEntry->name has room for entry name
Currently, the afs_dynroot_addDirEnt() function assumes that the caller
has allocated the directory to be large enough to hold the necessary
entry. In order to make sure that memory isn't being accidentally
stomped, use strlcpy to truncate instead of stomping on other memory.
That way, if the caller makes a mistake we don't silently corrupt memory.

We specifically do not assert that there is no truncation or panic if
truncation occurs, since the effect of a truncated entry in the
dynamic AFS root volume is limited and does not justify bringing down
the entire client.

Reviewed-on: https://gerrit.openafs.org/14938
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit aa9180652876a3ba9157776b69a6995ac4201d1b)

Change-Id: I21a402bb6e20f2546c61bdabde021817dd3827d8
Reviewed-on: https://gerrit.openafs.org/15243
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:53:43 -05:00
Michael Meffie
79c8c86399 fs: Trim trailing lsmount and flushmount path slashes
Remove trailing slashes from paths given to `fs lsmount` and `fs
flushmount`.  This makes for a more pleasant user experience when shell
tab completion is used to specify the paths.

Thanks to Stephan Wiesand for pointing out this issue.

Reviewed-on: https://gerrit.openafs.org/14779
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit a7a672cae871aa9cf9cc003a37579cb4df51b3fe)

Change-Id: I24a2ae323f64f2d73be8fbc26860fa2864e34bfe
Reviewed-on: https://gerrit.openafs.org/15242
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:52:04 -05:00
Andrew Deason
91f1155171 afs: Detect VIOCPREFETCH special case properly
Currently, afs_syscall_pioctl handles the VIOCPREFETCH pioctl as a
special case, calling into a different code path to handle
backgrounding the prefetch operation. However, we detect that we're
handling a VIOCPREFETCH operation just by looking at the lower 8 bits
of the given opcode. This means that any pioctl that ends in 0x0F will
trigger this codepath, such as if we add a 'C' or 'O' pioctl that uses
code 0x0F.

We only want to catch VIOCPREFETCH requests for this code path, so fix
the check to also check if we're processing a 'V' pioctl.

Reviewed-on: https://gerrit.openafs.org/13301
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 252b3bcc75ea141ff93a7b3147865f4b952fcaca)

Change-Id: I12d0616059dd8115b109b1ffa4cafe6ddc4b1662
Reviewed-on: https://gerrit.openafs.org/15241
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:49:52 -05:00
Marcio Barbosa
581450c74c afs: Replace strcpy &co by safer alternatives
In addition to being unsafe, these functions (strcpy, strncpy, strcat,
and sprintf) are deprecated on macOS. Replace these functions by safer
alternatives (strlcpy, strlcat, snprintf, and afs_strdup).

Notice that, in order to use afs_strdup(), this commit adds the afs_util
library to the AFSPAGOBJS list. Given that afs_strcasecmp() is also
implemented in afs_util.c, src/crypto/hcrypto/kernel/strcasecmp.c can be
removed from the tree.

No functional change should be incurred by this commit.

This commit is a continuation of a patch initially developed by
cwills@sinenomine.net.

Reviewed-on: https://gerrit.openafs.org/14743
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 419f0cd7aa75719dcf4df97e603ad4f0d936ddd9)

[cwills@sinenomine.net]
Part of the (419f0cd7aa) changes to afs_callback.c were pulled in to a
1.8.x specific commit:
    "afs: Avoid unbounded string copy in SRXAFSCB_GetLock()" (79a04c344)
In order to resync the code, the include roken.h in afs_callback.c
introduced in that commit needed to be removed.

Change-Id: Ica0e9bdc82de2b1e89e6d4b513e775b2809fbc34
Reviewed-on: https://gerrit.openafs.org/15240
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:28:30 -05:00
Mark Vitale
c7048f9a5c afs: remove dead code
afs_CheckLocks has been dead code since openafs-ibm-1_0.

No functional change incurred.

Reviewed-on: https://gerrit.openafs.org/13210
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 0839a3326858f7d7a0042614710dcf7316bb6018)

Change-Id: I1c564255990803dac7abe1789f2941bf4fa30b58
Reviewed-on: https://gerrit.openafs.org/15239
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:26:21 -05:00
Marcio Barbosa
fc5be911a0 UKERNEL: Remove flock -> usr_flock redirection
In order to replace 'struck flock' with 'struct usr_flock' and 'flock()'
with 'usr_flock()', the current version of src/afs/UKERNEL/sysincludes.h
defines flock to usr_flock. This can cause problems when trying to use
libroken in UKERNEL code, because roken.h redefines flock.

To avoid conflicts with libroken (included in a future commit), add a
new UKERNEL specific AFS_FLOCK -> usr_flock redirection. Doing so, the
flock -> usr_flock redirection can be removed. While here, also remove
'usr_flock()' as it shouldn't be called and is not defined in any header
file.

Reviewed-on: https://gerrit.openafs.org/14913
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 51c0387aaa5ec507c6e29063ef56d98e2931402d)

Change-Id: I3c2d9de056bae3f2fed68f1ec183540b63584a43
Reviewed-on: https://gerrit.openafs.org/15238
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:24:20 -05:00
Andrew Deason
276632ea73 UKERNEL: Remove socket -> usr_socket redirection
Currently, src/afs/UKERNEL/sysincludes.h #defines 'socket' to
'usr_socket', in order for 'struct socket' declarations to use struct
usr_socket. Redefining a simple word/function like 'socket' can easily
cause issues, and currently makes it difficult to introduce libroken
callers in UKERNEL code. There are already several instances of
'#undef socket' in the tree for UKERNEL, suggesting that this wasn't a
good idea to start with.

Fortunately, this redefinition of 'socket' in UKERNEL seems
unnecessary, since the only place 'struct usr_socket' is actually
deferenced is inside src/rx/UKERNEL/rx_knet.c. So we can treat 'struct
usr_socket' as a struct definition that's just internal to rx_knet.c,
and no other code even needs to know about the struct, or think that
it's equivalent to 'struct socket'.

Most code in rx_knet.c already explicitly casts between 'struct
socket' and 'struct usr_socket'. The only exception is rxi_Recvmsg
starting in commits near 27c42be1 (ukernel-rx-knet-deref-20060126),
but this is easily fixed by adding an additional explicit cast.

Reviewed-on: https://gerrit.openafs.org/14887
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 17b16cb3989d1f41e314795515daf6c9b41cf1de)

Change-Id: I35c7b7fc61c1c741be928fa7beb889d8848f0b81
Reviewed-on: https://gerrit.openafs.org/15237
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:03:55 -05:00
Marcio Barbosa
f2f0be5e04 afs: Save size of sysname_info->name
In preparation for a future commit, save the size of sysname_info->name
by adding a new field (name_size) into the sysname_info struct. Also,
remove the sysname_info->allocked field, since now we can find out if
memory has been allocated by checking if sysname_info->name_size is
different than zero.

No functional change should be incurred by this commit.

Reviewed-on: https://gerrit.openafs.org/14912
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit c40c0bd00b7e49e67377e13f5b902c13a0e4478c)

Change-Id: I5a7d0d733dfc48d4d4eb5d00ef959ad980722e17
Reviewed-on: https://gerrit.openafs.org/15236
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 08:01:42 -05:00
Marcio Barbosa
6ba75f842f fs: add option to evaluate symlink or mtpt
Currently, several fs subcommands for Windows offer an option (-literal)
to evaluate symlink / mount point rather than the object it refers to.
Provide the same option on Unix for fs_getfid.

Reviewed-on: https://gerrit.openafs.org/14542
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 83d947c150322c3c7c65130ecf08719e466cae04)

Change-Id: Ife60e046c149f3586dbdad0e9b3fd6059967ece1
Reviewed-on: https://gerrit.openafs.org/15235
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 07:55:14 -05:00
Marcio Barbosa
f1fd9c9cae afs: refactor PNewStatMount and PFlushMount
Both functions use the same logic to find a name in a given directory.
To avoid repetition, move this logic to a separate function called
afs_LookupName().

No functional change is incurred by this commit.

Reviewed-on: https://gerrit.openafs.org/14541
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 981bc005f8161ca9ee52ea281c7d73e0e4e2461a)

Change-Id: I11f03146da86c91f83ad682df7ad1943cb4ab68f
Reviewed-on: https://gerrit.openafs.org/15234
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-20 07:49:06 -05:00
Cheyenne Wills
b176259593 cf: Handle autoconf linux checks with -Werror
When the linux kernel has been configured with CONFIG_WERROR=y, several
autoconf configure checks used to detect linux features fail due to the
compiler performing additional coding checks (e.g. unused variables,
uninitialized variables, etc.).  Typically these additional coding
checks produce compiler warnings, but with CONFIG_WERROR=y these
warnings are reported as compiler errors, resulting in a misconfigured
build environment.

When testing for kernel features, turn off -Werror in the autoconf
functions AC_CHECK_LINUX_BUILD and AC_CHECK_LINUX_FUNC by explicitly
setting the compiler '-Wno-error' flag.

In addition, fix the commented description for AC_CHECK_LINUX_BUILD to
match the actual parameters

Reviewed-on: https://gerrit.openafs.org/15191
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit e2ad1ca5f7355062e808f1717e7410b7ae893371)

Change-Id: I2c8ba4c421ed751aa6ff2899ea173c1e84053322
Reviewed-on: https://gerrit.openafs.org/15231
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-18 05:22:37 -05:00
Cheyenne Wills
57df4dff49 cf: Detect how to pass CFLAGS to linux kbuild
The autoconf test LINUX_KBUILD_USES_EXTRA_CFLAGS fails on modern kernels
when detecting how to pass CFLAGS to the compiler when building a Linux
kernel module.  The result of this test is used by configure when
testing for Linux kernel features.

In addition the EXTRA_CFLAGS method of passing compiler parameters has
been deprecated since Linux 2.6.24 commit:
    "kbuild: introduce ccflags-y, asflags-y and ldflags-y" (f77bf01425b)

The currently preferred method is to use the make variable 'ccflags-y'
to set compiler flags.

Replace the autoconf function LINUX_KBUILD_USES_EXTRA_CFLAGS with a new
test, LINUX_KBUILD_FIND_CFLAGS_METHOD, that checks the various ways to
pass compiler flags when building the kernel module.

Set the build variable "LINUX_KBUILD_CFLAGS_VAR" with the determined
method for setting kbuild compiler flags.

Update the AC_TRY_KBUILD26 autoconf function and the
make_kbuild_makefile.pl script to use the determined method for setting
the compiler flags for the kbuild process.

Background:

The autoconf test, LINUX_KBUILD_USES_EXTRA_CFLAGS, is used to determine
when to use either CFLAGS for EXTRA_CFLAGS when performing other
autoconf tests for Linux kernel features. The test was added with the
openafs commit:
 "linux-2624-20071123" (af7cf697ef8)

LINUX_KBUILD_USES_EXTRA_CFLAGS relied on the Linux 2.6.24 commit:
 "kbuild: check for wrong use of CFLAGS" (0c53c8e6eb4)
which caused a build failure if CFLAGS where used instead of
EXTRA_CFLAGS.

Later with the Linux 4.20 commit:
 "kbuild: remove old check for CFLAGS use" (0d91bf584fe)
which removed the build failure when CFLAGS were set and this resulted
in LINUX_KBUILD_USES_EXTRA_CFLAGS failing to properly determining how to
set compiler flags in the kbuild process.

As mentioned above, the EXTRA_CFLAGS method itself has been deprecated
in Linux 2.6.24, but support for using it has still present in the
kbuild processes.

Reviewed-on: https://gerrit.openafs.org/15196
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit f81b01de1a51f02798ac764fb2f6948b592639da)

Change-Id: Ib1e07bf6b8734a427a2682ca694fbe2e083f1ecd
Reviewed-on: https://gerrit.openafs.org/15230
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-18 05:17:41 -05:00
Andrew Deason
2cf76b31ce 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.

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>
(cherry picked from commit 1210a8d6d96db2d84595d35ef81ec5d176de05e8)

Change-Id: I5d52b1eed48564956a687fba0419185b01621b13
Reviewed-on: https://gerrit.openafs.org/15229
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2023-01-18 05:12:31 -05:00
Stephan Wiesand
6cb9320825 Make OpenAFS 1.8.9
Update version strings for the 1.8.9 release, and add the
finishing touch to NEWS.

Change-Id: I8185cc177c1150d29d802df522e3b161dac7d75e
Reviewed-on: https://gerrit.openafs.org/15215
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
openafs-stable-1_8_9
2022-12-15 15:10:23 -05:00
Benjamin Kaduk
0ad4c50f91 viced: cope with signed length/position in FetchData
For legacy reasons, the "Pos" (initial position) and "Len" (length)
inputs to the RXAFS_FetchData and RXAFS_FetchData64 RPCs are represented
as signed integers (the corresponding StoreData RPCs use unsigned values).

The use of signed values allows for the possibility of negative inputs,
and of signed integer overflow (undefined behavior in C), though the latter
is unlikely to arise naturally given that the implementation uses a
common backend with 64-bit values.

In particular, if a negative "Pos" value is supplied, we end up in
FetchData_RXStyle() that performs either FDH_PREAD() or FDH_PREADV()
with the negative value as the position from which to read, which is
an error.  The error handling for those calls treats any error as
indicative of a problem with the volume or its underlying storage,
and takes the volume offline for salvage.  Furthermore, after the
maximum number of automatic salvages the volume is left offline for
administrator action.  This presents a simple route for
(unauthenticated) denial of service, as root.cell.readonly must be
available to all users of the cell, and can be brought offline in this
way; rendering root.cell.readonly unavailable would bring essentially
all access to the cell to a halt.  (Other volumes could be targeted as
well, subject to their corresponding ACLs.)

Since there is no valid use for a negative position or length input,
reject them outright from the common_FetchData64() implementation.
Also check for whether the combination requests a read that would
overflow a signed integer and reject that as well.

Thanks to Jeffrey Altman and Chaskiel Grundman for collaborating on
this change.

FIXES 135263

Reviewed-on: https://gerrit.openafs.org/15223
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 1fbbcbee0183aa7855c0e5d9d38aa89af75902db)

Change-Id: I1d634918789dddd5500ab50a0b508c142d83dc84
Reviewed-on: https://gerrit.openafs.org/15224
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2022-12-15 14:28:59 -05:00
Stephan Wiesand
f812d1125f Make OpenAFS 1.8.9pre2
Update version strings for the second 1.8.9 prerelease.

Change-Id: Ic45d60180097f85263b2bd81b0beb039c36ad51f
Reviewed-on: https://gerrit.openafs.org/15192
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
openafs-stable-1_8_9pre2
2022-11-10 12:11:53 -05:00
Stephan Wiesand
e8ead73224 Update NEWS for 1.8.9pre2
Release notes for the second 1.8.9 prerelease.

Change-Id: I564ee4f4348ca3574a52c75fea30c55dac5e33a4
Reviewed-on: https://gerrit.openafs.org/15193
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Tested-by: Stephan Wiesand <stephan.wiesand@desy.de>
2022-11-10 12:11:13 -05:00
Cheyenne Wills
fdf38483c7 Linux-6.0: Replace add_to_page_cache
Linux 6.0 removed the add_to_page_cache function in the Linux commit:
    'filemap: Remove add_to_page_cache() and add_to_page_cache_locked()'
    (2bb876b58d593d7f2522ec0f41f20a74fde76822)

The replacement function, filemap_add_folio function is exported as GPL,
but a non-GPL wrapper was provided in the Linux 5.15 commit:
    'mm/filemap: Add filemap_add_folio()'
    (9dd3d069406cea073fc633e77bc59abbfde8c6c4)
which changed the GPL exported function add_to_page_cache_lru to a
non-GPL exported function.

The function add_to_page_cache_lru functionally combines the
add_to_page_cache with lru_cache_add.  Within afs, all the calls to
add_to_page_cache follow the pattern of calling the lru_cache_add
via the wrapper afs_lru_cache_add immediately after (except in one case
noted below).

Add an autoconf check to see if add_to_page_cache_lru is available.

Introduce a new wrapper function afs_add_to_page_cache_lru that handles
calling either add_to_page_cache/afs_lru_cache_add or
add_to_page_cache_lru.

As noted above there is one function, afs_linux_bypass_readpages, that
calls add_to_page_cache but does not immediately call afs_lru_cache_add.
This function is only used in Linux kernels prior to 5.18, see the
commit:
    'Linux-5.18: replace readpages with readahead' (7a181415db)
Since this code path is only built for a Linux kernel level where
add_to_page_cache should also exists, we do not replace this call.

NOTE:
The add_to_page_cache_lru was moved into mm/folio-compat.c which has a
comment indicating that callers of these functions should migrate to
folio calls.  However the replacement folio call that is needed by afs,
filemap_add_folio, is exported as GPL.

Reviewed-on: https://gerrit.openafs.org/15132
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>
(cherry picked from commit 0ce315f0cee1cff7e19e6ebcc0e0e82e03719c20)

Change-Id: Ic0496c2fba00e7be467dbbcf52d9854495e1ad9f
Reviewed-on: https://gerrit.openafs.org/15148
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2022-11-03 10:54:36 -04:00
Michael Meffie
79a04c3448 afs: Avoid unbounded string copy in SRXAFSCB_GetLock()
Use strlcpy() instead of strcpy() when filling in the lock name to avoid
string buffer overflows of the AFSDBLock name arrays.

This is a 1.8.x specific commit, derived from 419f0cd7aa (afs: Replace
strcpy &co by safer alternatives)

Change-Id: Ia59f6dccdeab1c0b6f267254bd264842568b7582
Reviewed-on: https://gerrit.openafs.org/15151
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Harish Sharma <Harish.Sharma1@ibm.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2022-11-03 10:54:18 -04:00
Cheyenne Wills
119cea2f49 Remove gssapi in autoconf and configuration
The 1.8.x specific commit in gerrit 12681, "Remove src/rxgk" (7c2ce4040)
removed rxgk from the build, however the probe for GSSAPI is still
place.

If there is no gssapi library available, configure fails:
    checking for gss_import_name in -lgssapi_krb5... no
    checking for gss_import_name in -lgss... no
    configure: error: cannot find usable GSS-API library

There are no references to gssapi other than the probe in autoconf and
2 defines in src/config/Makefile.config.in

Remove the autoconf check for GSSAPI via the RAA_LIB_GSSAPI call.
Remove the 2 GSSAPI related defines from Makefile.config.in
Update the INSTALL document to remove references to gssapi.

Change-Id: I873e46bfccfbf538740e8bf5e28a3ca8c3cd3744
Reviewed-on: https://gerrit.openafs.org/15137
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2022-11-03 10:53:54 -04:00
Stephan Wiesand
a2c1f9dc21 Make OpenAFS 1.8.9pre1
Update version strings for the first 1.8.9 prerelease.

Change-Id: I6fc6dff8143445ee82188a2614588068f1feeb25
Reviewed-on: https://gerrit.openafs.org/14810
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
openafs-stable-1_8_9pre1
2022-09-09 05:02:07 -04:00
Stephan Wiesand
7a44c381f1 Update NEWS for 1.8.9pre1
Release notes for the first 1.8.9 prerelease.

Change-Id: I26e4334f9f1e34b36299b097525a61a89f422aaf
Reviewed-on: https://gerrit.openafs.org/15126
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2022-09-09 05:00:37 -04:00
Cheyenne Wills
beb1a8a16c afs: Clean up compiler warning casting ptr to int
In osi_probe.c, the macro 'check_result' casts a pointer to an int which
on older Linux kernels (e.g. 2.6.18) produces several lines with the C
warning:

... warning: cast from pointer to integer of different size

Change the cast from int to long int.

Linux 2.6.18 doesn't provide intptr_t or uintptr_t, and stdint.h is not
available to kernel modules.  But the size of a pointer is the size of a
long (see uintptr_t in linux/types.h - Linux 2.6.24+), so
change the cast from int to long.

Note that the this code by default only gets pulled in for older Linux
kernels (e.g. 2.6.18).  For newer kernels, ENABLE_LINUX_SYSCALL_PROBING
is not defined, and so most of osi_probe.c is not built.

Reviewed-on: https://gerrit.openafs.org/14092
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
(cherry picked from commit 38d78e2496c3d242e44bad401ecffe15e3883388)

Change-Id: I474ad10c8cda8c414154e20f739a2aba5ba890cf
Reviewed-on: https://gerrit.openafs.org/15134
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2022-09-08 08:41:53 -04:00
Andrew Deason
7a8c044c09 dir: Set srcdir correctly in src/dir/test
srcdir is a magic variable that needs to be set to @srcdir@, not some
relative path like ../../.. (which will usually be somewhere in the
objdir, not srcdir). Set it correctly in here.

Without this, objdir builds can fail with:

    make[4]: Entering directory '...obj/src/dir/test'
    make[4]: *** No rule to make target 'dtest.o', needed by 'dtest'.  Stop.

Which happens because the automatic rule for dtest.o can't be
constructed, since we cannot find dtest.c automatically because srcdir
isn't set properly.

This has been broken since commit 37b4195d (dtest-20021111), but was
not noticeable until commit 192a2ff4 (dir: make dtest buildable
again), since that caused dtest to actually get built.

Also set LIBS correctly in here, using the conventional ${TOP_LIBDIR},
since ${srcdir} no longer points to "../../..".

Reviewed-on: https://gerrit.openafs.org/14384
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit bc6f50ca0ce6c17a5a9b1042fa90235613f80c95)

Change-Id: I8aff31557b6b92bb10c68abb0ba5a61a68b8f750
Reviewed-on: https://gerrit.openafs.org/15133
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2022-09-08 08:38:09 -04:00
Cheyenne Wills
e3edd8c43e LINUX: Use bitwise & for f_flags test
This code is clearly supposed to be masking f_flags with O_ACCMODE, and
so should be using a bitwise &, not the boolean &&.  Clang complains
about this, causing a warning (which breaks the build with
--enable-checking):

error: use of logical '&&' with constant operand [-Werror,
        -Wconstant-logical-operand]
        } else if ((file->f_flags && O_ACCMODE) != O_WRONLY) {
                                  ^  ~~~~~~~~~
.../osi_vnodeops.c:3192:28: note: use '&' for a
        bitwise operation

For the current code without this commit the behavior of this
check is as follows:

   When f_flags is:         The check is:
   ====================     =============
   O_RDONLY                 True  (as expected)
   O_WRONLY                 False (as expected)
   O_RDWR                   False (incorrect)
   has some non-O_ACCMODE   False (incorrect)
    bit is set

The incorrect check doesn't cause any problems for overall correctness,
but it does mean that in those cases afs_linux_fillpage will not be
called and that partially-written pages will be left out of date and any
reader will need to fill the page again.

Fix this by using the bitwise &.

There is also an out of date link to the Linux documentation.  Update
the comment to point to the current documentation that is in the Linux
source tree.

Reviewed-on: https://gerrit.openafs.org/14903
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>
(cherry picked from commit 8d9545008240d7f285b140503e432f53f41e0724)

Change-Id: Iae459ffe87df9a21a90587c02a1ee2c20b360d33
Reviewed-on: https://gerrit.openafs.org/15129
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2022-09-08 08:37:17 -04:00
Jan Iven
c3f31cc9c3 systemd: do not load the 'openafs' module on boot
remove /etc/sysconfig/modules/openafs-client.modules, i.e no longer have
systemd run "modprobe openafs" at boot, on RPM-based systems.

This had been introduced with a reference to the Fedora packaging guide
at the time. However, this mechanism was meant just for persistent
driver modules (i.e expected to stay loaded over the runtime) - the
"openafs" module is loaded (and unloaded) by the actual systemd unit.

The systemd unit that processes the above file comes from "initscripts",
this is optional in later Fedoras/RHELs and so the file may not even be
processed (/usr/lib/modules-load.d/ would be an alternative mechanism to
load modules at boot.. if needed).

This change is mostly cosmetic, although RT#135204 showed that having
the "openafs" module loaded without a client running can actually be
harmful.

Reviewed-on: https://gerrit.openafs.org/15092
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 40b2c6036737a416f3b33624b5abeefa407c1b01)

Change-Id: Iea1475217b8ae56accfb4436248011f0b84e0c09
Reviewed-on: https://gerrit.openafs.org/15128
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2022-09-08 08:33:47 -04:00
Cheyenne Wills
99f04b1398 linux: Call put_page if errors in aops->readpages
Within the address_space_operations readpages function, when we remove a
page from the page->lru list, we must ensure that the page reference
count is decremented via put_page.

There are two cases within the flow of the afs_linux_readpages where
we remove a page from the page->lru list, but fail to put_page() it.

 - If we go through afs_linux_bypass_readpages we fail to call
   put_page() if the page index is larger than the index calculated from
   i_size_read for the cache file.
 - If get_dcache_readahead returns an error in afs_linux_readpages, we
   fail to put_page().  This can happen if there was a problem opening
   the cache file, or if the cache file has no a_ops->readpage.

Add a call to put_page in afs_linux_bypass_readpages when the page index
is greater than the index calculated from the i_size_read for the cache
file.

Add a call to put_page in afs_linux_readpages if get_dcache_readahead
returns an error.

Note: The condition of not calling put_page if there was an error
opening the cache file was introduced by commit 'LINUX: Don't panic on
some file open errors' (af73b9a3b1f), which replaced an assert with
code that handled the error.  The other conditions have existed since
the relevant code was introduced.

In addition, the problems addressed by this commit are not present in
Linux kernels 5.8 and greater when the commit 'Linux-5.18: replace
readpages with readahead' (7a181415db1) is present, because we call
afs_linux_readahead instead of afs_linux_readpages.

Reviewed-on: https://gerrit.openafs.org/15068
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 903dd5bf5e9328431e356abc42e20c248c5df6fd)

Change-Id: I3679969f985e83a7291a5fb735c80f7d57429c29
Reviewed-on: https://gerrit.openafs.org/15096
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
2022-08-25 08:50:36 -04:00