For a while now any NFSv2 mount where sec= is specified uses
AUTH_NULL. If sec= is not specified, the mount uses AUTH_UNIX.
Commit e68fd7c8071d ("mount: use sec= that was specified on the
command line") attempted to address a very similar problem with
NFSv3, and should have fixed this too, but it has a bug.
The MNTv1 MNT procedure does not return a list of security flavors,
so our client makes up a list containing just AUTH_NULL. This should
enable nfs_verify_authflavors() to assign the sec= specified flavor,
but instead, it incorrectly sets it to AUTH_NULL.
I expect this would also be a problem for any NFSv3 server whose
MNTv3 MNT procedure returned a security flavor list containing only
AUTH_NULL.
Fixes: e68fd7c8071d ("mount: use sec= that was specified on ... ")
BugLink: https://bugzilla.linux-nfs.org/show_bug.cgi?id=310
Signed-off-by: Chuck Lever <[email protected]>
---
fs/nfs/super.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
Changes since v1:
- Description edited for accuracy
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index d828ef8..6b179af 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -1691,8 +1691,8 @@ static int nfs_verify_authflavors(struct nfs_parsed_mount_data *args,
rpc_authflavor_t *server_authlist, unsigned int count)
{
rpc_authflavor_t flavor = RPC_AUTH_MAXFLAVOR;
+ bool found_auth_null = false;
unsigned int i;
- int use_auth_null = false;
/*
* If the sec= mount option is used, the specified flavor or AUTH_NULL
@@ -1701,6 +1701,10 @@ static int nfs_verify_authflavors(struct nfs_parsed_mount_data *args,
* AUTH_NULL has a special meaning when it's in the server list - it
* means that the server will ignore the rpc creds, so any flavor
* can be used but still use the sec= that was specified.
+ *
+ * Note also that the MNT procedure in MNTv1 does not return a list
+ * of supported security flavors. In this case, nfs_mount() fabricates
+ * a security flavor list containing just AUTH_NULL.
*/
for (i = 0; i < count; i++) {
flavor = server_authlist[i];
@@ -1709,11 +1713,11 @@ static int nfs_verify_authflavors(struct nfs_parsed_mount_data *args,
goto out;
if (flavor == RPC_AUTH_NULL)
- use_auth_null = true;
+ found_auth_null = true;
}
- if (use_auth_null) {
- flavor = RPC_AUTH_NULL;
+ if (found_auth_null) {
+ flavor = args->auth_info.flavors[0];
goto out;
}
Ping...
> On Aug 10, 2017, at 4:41 PM, Chuck Lever <[email protected]> wrote:
>
> For a while now any NFSv2 mount where sec= is specified uses
> AUTH_NULL. If sec= is not specified, the mount uses AUTH_UNIX.
> Commit e68fd7c8071d ("mount: use sec= that was specified on the
> command line") attempted to address a very similar problem with
> NFSv3, and should have fixed this too, but it has a bug.
>
> The MNTv1 MNT procedure does not return a list of security flavors,
> so our client makes up a list containing just AUTH_NULL. This should
> enable nfs_verify_authflavors() to assign the sec= specified flavor,
> but instead, it incorrectly sets it to AUTH_NULL.
>
> I expect this would also be a problem for any NFSv3 server whose
> MNTv3 MNT procedure returned a security flavor list containing only
> AUTH_NULL.
>
> Fixes: e68fd7c8071d ("mount: use sec= that was specified on ... ")
> BugLink: https://bugzilla.linux-nfs.org/show_bug.cgi?id=310
> Signed-off-by: Chuck Lever <[email protected]>
> ---
> fs/nfs/super.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> Changes since v1:
> - Description edited for accuracy
>
> diff --git a/fs/nfs/super.c b/fs/nfs/super.c
> index d828ef8..6b179af 100644
> --- a/fs/nfs/super.c
> +++ b/fs/nfs/super.c
> @@ -1691,8 +1691,8 @@ static int nfs_verify_authflavors(struct nfs_parsed_mount_data *args,
> rpc_authflavor_t *server_authlist, unsigned int count)
> {
> rpc_authflavor_t flavor = RPC_AUTH_MAXFLAVOR;
> + bool found_auth_null = false;
> unsigned int i;
> - int use_auth_null = false;
>
> /*
> * If the sec= mount option is used, the specified flavor or AUTH_NULL
> @@ -1701,6 +1701,10 @@ static int nfs_verify_authflavors(struct nfs_parsed_mount_data *args,
> * AUTH_NULL has a special meaning when it's in the server list - it
> * means that the server will ignore the rpc creds, so any flavor
> * can be used but still use the sec= that was specified.
> + *
> + * Note also that the MNT procedure in MNTv1 does not return a list
> + * of supported security flavors. In this case, nfs_mount() fabricates
> + * a security flavor list containing just AUTH_NULL.
> */
> for (i = 0; i < count; i++) {
> flavor = server_authlist[i];
> @@ -1709,11 +1713,11 @@ static int nfs_verify_authflavors(struct nfs_parsed_mount_data *args,
> goto out;
>
> if (flavor == RPC_AUTH_NULL)
> - use_auth_null = true;
> + found_auth_null = true;
> }
>
> - if (use_auth_null) {
> - flavor = RPC_AUTH_NULL;
> + if (found_auth_null) {
> + flavor = args->auth_info.flavors[0];
> goto out;
> }
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Chuck Lever
T24gV2VkLCAyMDE3LTA4LTIzIGF0IDE1OjMxIC0wNDAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g
UGluZy4uLg0KDQpBcHBsaWVkIHRvIHRoZSAndGVzdGluZycgYW5kICdsaW51eC1uZXh0JyBicmFu
Y2hlcyBmb3IgdGhlIDQuMTQgbWVyZ2UNCndpbmRvdzoNCiAgaHR0cDovL2dpdC5saW51eC1uZnMu
b3JnLz9wPXRyb25kbXkvbGludXgtbmZzLmdpdDthPXNob3J0bG9nO2g9cmVmcy9oDQplYWRzL2xp
bnV4LW5leHQNCg0KPiANCj4gDQo+ID4gT24gQXVnIDEwLCAyMDE3LCBhdCA0OjQxIFBNLCBDaHVj
ayBMZXZlciA8Y2h1Y2subGV2ZXJAb3JhY2xlLmNvbT4NCj4gPiB3cm90ZToNCj4gPiANCj4gPiBG
b3IgYSB3aGlsZSBub3cgYW55IE5GU3YyIG1vdW50IHdoZXJlIHNlYz0gaXMgc3BlY2lmaWVkIHVz
ZXMNCj4gPiBBVVRIX05VTEwuIElmIHNlYz0gaXMgbm90IHNwZWNpZmllZCwgdGhlIG1vdW50IHVz
ZXMgQVVUSF9VTklYLg0KPiA+IENvbW1pdCBlNjhmZDdjODA3MWQgKCJtb3VudDogdXNlIHNlYz0g
dGhhdCB3YXMgc3BlY2lmaWVkIG9uIHRoZQ0KPiA+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