Skip to contentSkip to conversation

Use correct NFSv4.0 callback credential

PATCH In review Chuck Lever 3 participants 11 messages Aug 16, 2018 – Aug 17, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover Use correct NFSv4.0 callback credential

Hi Bruce-

This is the same series as I posted in May, merged up to v4.18. I tested it again this morning. Can it be included in v4.19 ?

The previous thread claims Simo Ack'd these patches, but I can't find the actual Acked-by. I've cc'd him on this repost in case he has additional comments.

---

Chuck Lever (4):
sunrpc: Enable the kernel to specify the hostname part of service principals
sunrpc: Extract target name into svc_cred
nfsd: Use correct credential for NFSv4.0 callback with GSS
nfsd: Remove callback_cred

 fs/nfsd/nfs4callback.c               |   29 ++++----------
 fs/nfsd/nfs4state.c                  |   17 +++-----
 fs/nfsd/state.h                      |    2 -
 include/linux/sunrpc/svcauth.h       |    3 +
 net/sunrpc/auth_gss/auth_gss.c       |   20 ++++++++--
 net/sunrpc/auth_gss/gss_rpc_upcall.c |   70 ++++++++++++++++++++++------------
 6 files changed, 80 insertions(+), 61 deletions(-)

--
Chuck Lever

#1 lore raw

PATCH v2 1/4 sunrpc: Enable the kernel to specify the hostname part of service principals

A multi-homed NFS server may have more than one "nfs" key in its keytab. Enable the kernel to pick the key it wants as a machine credential when establishing a GSS context.

This is useful for GSS-protected NFSv4.0 callbacks, which are required by RFC 7530 S3.3.3 to use the same principal as the service principal the client used when establishing its lease.

A complementary modification to rpc.gssd is required to fully enable this feature.

---
 net/sunrpc/auth_gss/auth_gss.c |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
net/sunrpc/auth_gss/auth_gss.c +17 -3
index be8f103..1943e11 100644
@@ -284,7 +284,12 @@ struct gss_auth {
 	return p;
 }
 
-#define UPCALL_BUF_LEN 128
+/* XXX: Need some documentation about why UPCALL_BUF_LEN is so small.
+ *	Is user space expecting no more than UPCALL_BUF_LEN bytes?
+ *	Note that there are now _two_ NI_MAXHOST sized data items
+ *	being passed in this string.
+ */
+#define UPCALL_BUF_LEN	256
 
 struct gss_upcall_msg {
 	refcount_t count;
@@ -462,8 +467,17 @@ static int gss_encode_v1_msg(struct gss_upcall_msg *gss_msg,
 		p += len;
 		gss_msg->msg.len += len;
 	}
-	if (service_name != NULL) {
-		len = scnprintf(p, buflen, "service=%s ", service_name);
+	if (service_name) {
+		char *c = strchr(service_name, '@');
+
+		if (!c)
+			len = scnprintf(p, buflen, "service=%s ",
+					service_name);
+		else
+			len = scnprintf(p, buflen,
+					"service=%.*s srchost=%s ",
+					(int)(c - service_name),
+					service_name, c + 1);
 		buflen -= len;
 		p += len;
 		gss_msg->msg.len += len;
#2 lore raw

Re: [PATCH v2 1/4] sunrpc: Enable the kernel to specify the hostname part of service principals

T24gVGh1LCAyMDE4LTA4LTE2IGF0IDEyOjA1IC0wNDAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g QSBtdWx0aS1ob21lZCBORlMgc2VydmVyIG1heSBoYXZlIG1vcmUgdGhhbiBvbmUgIm5mcyIga2V5 IGluIGl0cw0KPiBrZXl0YWIuIEVuYWJsZSB0aGUga2VybmVsIHRvIHBpY2sgdGhlIGtleSBpdCB3 YW50cyBhcyBhIG1hY2hpbmUNCj4gY3JlZGVudGlhbCB3aGVuIGVzdGFibGlzaGluZyBhIEdTUyBj b250ZXh0Lg0KPiANCj4gVGhpcyBpcyB1c2VmdWwgZm9yIEdTUy1wcm90ZWN0ZWQgTkZTdjQuMCBj YWxsYmFja3MsIHdoaWNoIGFyZQ0KPiByZXF1aXJlZCBieSBSRkMgNzUzMCBTMy4zLjMgdG8gdXNl IHRoZSBzYW1lIHByaW5jaXBhbCBhcyB0aGUgc2VydmljZQ0KPiBwcmluY2lwYWwgdGhlIGNsaWVu dCB1c2VkIHdoZW4gZXN0YWJsaXNoaW5nIGl0cyBsZWFzZS4NCj4gDQo+IEEgY29tcGxlbWVudGFy eSBtb2RpZmljYXRpb24gdG8gcnBjLmdzc2QgaXMgcmVxdWlyZWQgdG8gZnVsbHkgZW5hYmxlDQ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bGl0eSBv ZiB0aGUgJ3RhcmdldCcgYXJndW1lbnQ/DQoNCi0tIA0KVHJvbmQgTXlrbGVidXN0DQpDVE8sIEhh bW1lcnNwYWNlIEluYw0KNDMwMCBFbCBDYW1pbm8gUmVhbCwgU3VpdGUgMTA1DQpMb3MgQWx0b3Ms IENBIDk0MDIyDQp3d3cuaGFtbWVyLnNwYWNlDQoNCg0K

#3 lore raw

Re: [PATCH v2 1/4] sunrpc: Enable the kernel to specify the hostname part of service principals

Quoted 26 lines · Trond Myklebust
Quoted 25 lines · Chuck Lever

A multi-homed NFS server may have more than one "nfs" key in its keytab. Enable the kernel to pick the key it wants as a machine credential when establishing a GSS context.

This is useful for GSS-protected NFSv4.0 callbacks, which are required by RFC 7530 S3.3.3 to use the same principal as the service principal the client used when establishing its lease.

A complementary modification to rpc.gssd is required to fully enable this feature.

---
 net/sunrpc/auth_gss/auth_gss.c |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)
net/sunrpc/auth_gss/auth_gss.c +0 -0
index be8f103..1943e11 100644
@@ -284,7 +284,12 @@ struct gss_auth {
 	return p;
 }
 
Quoted 12 lines
Quoted 9 lines
net/sunrpc/auth_gss/auth_gss.c +1 -1
-#define UPCALL_BUF_LEN 128
+/* XXX: Need some documentation about why UPCALL_BUF_LEN is so

small.
+ * Is user space expecting no more than UPCALL_BUF_LEN bytes?
+ * Note that there are now _two_ NI_MAXHOST sized data items
+ * being passed in this string.
+ */
+#define UPCALL_BUF_LEN 256

Why? The services are currently "nfs" or "nfsd". Hostnames are normally < 64 characters.

For Kerberos hostnames are fully qualified DNS names, so easily longer than 64 bytes.

Quoted 18 lines
Quoted 18 lines

struct gss_upcall_msg {

net/sunrpc/auth_gss/auth_gss.c +8 -2
 	refcount_t count;
@@ -462,8 +467,17 @@ static int gss_encode_v1_msg(struct
 gss_upcall_msg *gss_msg,
 		p += len;
 		gss_msg->msg.len += len;
 	}
-	if (service_name != NULL) {
-		len = scnprintf(p, buflen, "service=%s ",
 service_name);
+	if (service_name) {
+		char *c = strchr(service_name, '@');
+
+		if (!c)
+			len = scnprintf(p, buflen, "service=%s ",
+					service_name);
+		else
+			len = scnprintf(p, buflen,
Quoted 8 lines

net/sunrpc/auth_gss/auth_gss.c

Quoted 6 lines
net/sunrpc/auth_gss/auth_gss.c +3 -0
+					"service=%.*s srchost=%s ",
+					(int)(c - service_name),
+					service_name, c + 1);
 		buflen -= len;
net/sunrpc/auth_gss/auth_gss.c +0 -0
 		p += len;
 		gss_msg->msg.len += len;

Isn't this just duplicating the functionality of the 'target' argument?

No, but I'll let Chuck re-explain.

Chuck, people are often confused about this, perhaps we need a clarifying comment here to avoid some "optimization" to the code to happen later.

HTH,
Simo.

Quoted 9 lines
Signature · 6 lines
-- 
Trond Myklebust
CTO, Hammerspace Inc
4300 El Camino Real, Suite 105
Los Altos, CA 94022
www.hammer.space
#4 lore raw

Re: [PATCH v2 1/4] sunrpc: Enable the kernel to specify the hostname part of service principals

In reply to Trond Myklebust
Quoted 3 lines

On Aug 16, 2018, at 12:27 PM, Trond Myklebust =

Quoted 30 lines · <[email protected]> wrote:

=20

Quoted 28 lines · Chuck Lever

A multi-homed NFS server may have more than one "nfs" key in its keytab. Enable the kernel to pick the key it wants as a machine credential when establishing a GSS context.
=20
This is useful for GSS-protected NFSv4.0 callbacks, which are required by RFC 7530 S3.3.3 to use the same principal as the service principal the client used when establishing its lease. =20
A complementary modification to rpc.gssd is required to fully enable this feature.
=20

---
net/sunrpc/auth_gss/auth_gss.c | 20 +++++++++++++++++---

1 file changed, 17 insertions(+), 3 deletions(-)

=20

net/sunrpc/auth_gss/auth_gss.c +0 -0
index be8f103..1943e11 100644
@@ -284,7 +284,12 @@ struct gss_auth {
 	return p;
 }

=20

net/sunrpc/auth_gss/auth_gss.c +1 -1
-#define UPCALL_BUF_LEN 128
+/* XXX: Need some documentation about why UPCALL_BUF_LEN is so

small.

Quoted 8 lines
Quoted 6 lines

+ * Is user space expecting no more than UPCALL_BUF_LEN bytes?
+ * Note that there are now _two_ NI_MAXHOST sized data items
+ * being passed in this string.
+ */
+#define UPCALL_BUF_LEN 256
=20

=20
Why? The services are currently "nfs" or "nfsd". Hostnames are =

normally

Quoted 1 line

< 64 characters.

True, but that's an average. We actually should be accommodating the largest possible hostname here: /usr/include/netdb.h defines NI_MAXHOST as 1024. Thus even 256 is too small, but as you point out it will work fine in most real world cases.

Quoted 18 lines
Quoted 18 lines
struct gss_upcall_msg {
	refcount_t count;
net/sunrpc/auth_gss/auth_gss.c +8 -2
@@ -462,8 +467,17 @@ static int gss_encode_v1_msg(struct
 gss_upcall_msg *gss_msg,
 		p +=3D len;
 		gss_msg->msg.len +=3D len;
 	}
-	if (service_name !=3D NULL) {
-		len =3D scnprintf(p, buflen, "service=3D%s ",
 service_name);
+	if (service_name) {
+		char *c =3D strchr(service_name, '@');
+
+		if (!c)
+			len =3D scnprintf(p, buflen, "service=3D%s ",
+					service_name);
+		else
+			len =3D scnprintf(p, buflen,
Quoted 8 lines
Quoted 6 lines
net/sunrpc/auth_gss/auth_gss.c +3 -0
+					"service=3D%.*s srchost=3D%s ",
+					(int)(c - service_name),
+					service_name, c + 1);
 		buflen -=3D len;
		p +=3D len;
		gss_msg->msg.len +=3D len;

=20
Isn't this just duplicating the functionality of the 'target' =

argument?

I might not understand your question, but I believe the answer is no.

I have a multi-homed client and server. The primary hostname of the client is "manet.example.net" and the server is "klimt.example.net" Both have IB interfaces, respectively "manet.ib.example.net" and "klimt.ib.example.net".

Now I do this:

manet# mount -o vers=3D4.0,sec=3Dsys klimt.ib.example.net:/export /mnt

The mount is AUTH_SYS, but lease management is done using krb5i because both systems have a keytab. For the callback channel, RFC 7530 requires that the server use the client's lease management auth flavor. Moreover, the server is required to use the same acceptor that the client authenticated to (in this case, "klimt.ib.example.net").

So now the server establishes a GSS context for it's callback channel:

Aug 16 11:00:17 klimt rpc.gssd[1186]: handle_gssd_upcall: 'mech=3Dkrb5 =

uid=3D0 [email protected] service=3Dnfs = srchost=3Dklimt.ib.example.net enctypes=3D18,17,16,23,3,1,2 ' = (nfsd4_cb/clnt4)

The "target" is the principal of the remote service the server is authenticating to. In full, the target is:

host/[email protected]

The "srchost" is the hostname part of the server's service principal. = This
has to match the acceptor string provided by the client, thus the full source principal has to be:

nfs/[email protected]

gssd uses the service=3D and srchost=3D to select the correct key in its keytab when it establishes a GSS context for the callback channel. = Without
srchost it would select the key for klimt.example.net, which is the wrong key in this case. Since this commit:

commit f11b2a1cfbf5dd783eb55cb470509d06e20d1c78

Author:     Jeff Layton <[email protected]>
AuthorDate: Sat Jun 21 20:52:17 2014 -0400
Commit:     Trond Myklebust <[email protected]>
CommitDate: Sat Jul 12 18:41:25 2014 -0400

nfs4: copy acceptor name from context to nfs_client

the client rejects NFSv4.0 callbacks using krb5 with the wrong acceptor string with "NFSv4 callback contains invalid cred". This occurs _after_ the server has established a GSS context and a connection to the client, so it has already granted delegations which it now cannot recall.

--
Chuck Lever

#5 lore raw

Re: [PATCH v2 1/4] sunrpc: Enable the kernel to specify the hostname part of service principals

T24gVGh1LCAyMDE4LTA4LTE2IGF0IDE1OjAzIC0wNDAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g PiBPbiBBdWcgMTYsIDIwMTgsIGF0IDEyOjI3IFBNLCBUcm9uZCBNeWtsZWJ1c3QgPA0KPiA+IHRy b25kbXlAaGFtbWVyc3BhY2UuY29tPiB3cm90ZToNCj4gPiANCj4gPiBPbiBUaHUsIDIwMTgtMDgt MTYgYXQgMTI6MDUgLTA0MDAsIENodWNrIExldmVyIHdyb3RlOg0KPiA+ID4gQSBtdWx0aS1ob21l ZCBORlMgc2VydmVyIG1heSBoYXZlIG1vcmUgdGhhbiBvbmUgIm5mcyIga2V5IGluIGl0cw0KPiA+ ID4ga2V5dGFiLiBFbmFibGUgdGhlIGtlcm5lbCB0byBwaWNrIHRoZSBrZXkgaXQgd2FudHMgYXMg YSBtYWNoaW5lDQo+ID4gPiBjcmVkZW50aWFsIHdoZW4gZ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RoZSBzZXJ2ZXIgaGFzIGVzdGFibGlzaGVkIGEgR1NTIGNvbnRleHQgYW5kIGEgY29ubmVjdGlv biB0byB0aGUNCj4gY2xpZW50LA0KPiBzbyBpdCBoYXMgYWxyZWFkeSBncmFudGVkIGRlbGVnYXRp b25zIHdoaWNoIGl0IG5vdyBjYW5ub3QgcmVjYWxsLg0KPiANCg0KVGhlIGFib3ZlIHN0b3J5IHJl YWxseSBkb2VzIGRlc2VydmUgYW4gZXhwbGFuYXRpb24gaW4gdGhlIGNvZGUgZm9yIHRoZQ0KdXBj YWxsLg0KUmlnaHQgbm93LCB5b3UgaGF2ZSB0byBodW50IHRocm91Z2ggbmVzdGVkIGxheWVycyBv ZiBzdHJ1Y3QgY29waWVzIHRvDQpmaWd1cmUgb3V0IHRoYXQgJ3RhcmdldCcgcmVmZXJzIHRvIHRo ZSBzZXJ2aWNlIG9uIHRoZSBzZXJ2ZXIgc2lkZQ0KY2FsbGJhY2sgY2hhbm5lbCBmb3IgTkZTdjQu MCBvbmx5LiBBIHNlY29uZCBob3N0bmFtZSBmaWVsZCBmb3IgdGhlIHNhbWUNCnVzZSBjYXNlIGp1 c3QgYWRkcyB0byB0aGF0IGNvbmZ1c2lvbi4NCg0KLS0gDQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4 IE5GUyBjbGllbnQgbWFpbnRhaW5lciwgSGFtbWVyc3BhY2UNCnRyb25kLm15a2xlYnVzdEBoYW1t ZXJzcGFjZS5jb20NCg0KDQo=

#6 lore raw

Re: [PATCH v2 1/4] sunrpc: Enable the kernel to specify the hostname part of service principals

Quoted 3 lines

On Aug 17, 2018, at 12:54 AM, Trond Myklebust =

Quoted 95 lines · <[email protected]> wrote:

=20

Quoted 93 lines · Chuck Lever
Quoted 38 lines

On Aug 16, 2018, at 12:27 PM, Trond Myklebust <
[email protected]> wrote:
=20

Quoted 34 lines · Chuck Lever

A multi-homed NFS server may have more than one "nfs" key in its keytab. Enable the kernel to pick the key it wants as a machine credential when establishing a GSS context.
=20
This is useful for GSS-protected NFSv4.0 callbacks, which are required by RFC 7530 S3.3.3 to use the same principal as the service
principal the client used when establishing its lease. =20
A complementary modification to rpc.gssd is required to fully enable
this feature.
=20

---
net/sunrpc/auth_gss/auth_gss.c | 20 +++++++++++++++++---

1 file changed, 17 insertions(+), 3 deletions(-)

=20

net/sunrpc/auth_gss/auth_gss.c +0 -0
index be8f103..1943e11 100644
@@ -284,7 +284,12 @@ struct gss_auth {
 	return p;
 }

=20

net/sunrpc/auth_gss/auth_gss.c +1 -1
-#define UPCALL_BUF_LEN 128
+/* XXX: Need some documentation about why UPCALL_BUF_LEN is so

small.
+ * Is user space expecting no more than UPCALL_BUF_LEN
bytes?
+ * Note that there are now _two_ NI_MAXHOST sized data
items

Quoted 8 lines
Quoted 4 lines

+ * being passed in this string.
+ */
+#define UPCALL_BUF_LEN 256
=20

=20
Why? The services are currently "nfs" or "nfsd". Hostnames are normally
< 64 characters.

=20
True, but that's an average. We actually should be accommodating the largest possible hostname here: /usr/include/netdb.h defines NI_MAXHOST
as 1024. Thus even 256 is too small, but as you point out it will work
fine in most real world cases.
=20
=20

Quoted 19 lines
Quoted 19 lines
struct gss_upcall_msg {
	refcount_t count;
net/sunrpc/auth_gss/auth_gss.c +9 -2
@@ -462,8 +467,17 @@ static int gss_encode_v1_msg(struct
 gss_upcall_msg *gss_msg,
 		p +=3D len;
 		gss_msg->msg.len +=3D len;
 	}
-	if (service_name !=3D NULL) {
-		len =3D scnprintf(p, buflen, "service=3D%s ",
 service_name);
+	if (service_name) {
+		char *c =3D strchr(service_name, '@');
+
+		if (!c)
+			len =3D scnprintf(p, buflen, "service=3D%s ",
+					service_name);
+		else
+			len =3D scnprintf(p, buflen,
+					"service=3D%.*s srchost=3D%s ",
Quoted 8 lines
Quoted 5 lines
net/sunrpc/auth_gss/auth_gss.c +2 -0
+					(int)(c - service_name),
+					service_name, c + 1);
 		buflen -=3D len;
		p +=3D len;
		gss_msg->msg.len +=3D len;

=20
Isn't this just duplicating the functionality of the 'target' argument?

=20
I might not understand your question, but I believe the answer is no. =20
I have a multi-homed client and server. The primary hostname of the client is "manet.example.net" and the server is "klimt.example.net" Both have IB interfaces, respectively "manet.ib.example.net" and "klimt.ib.example.net".
=20
Now I do this:
=20
manet# mount -o vers=3D4.0,sec=3Dsys klimt.ib.example.net:/export =

/mnt

Quoted 24 lines
Quoted 24 lines

=20
The mount is AUTH_SYS, but lease management is done using krb5i because
both systems have a keytab. For the callback channel, RFC 7530 requires
that the server use the client's lease management auth flavor. Moreover,
the server is required to use the same acceptor that the client authenticated to (in this case, "klimt.ib.example.net"). =20
So now the server establishes a GSS context for it's callback channel:
=20

Aug 16 11:00:17 klimt rpc.gssd[1186]: handle_gssd_upcall: 'mech=3Dkrb5

uid=3D0 [email protected] service=3Dnfs srchost=3Dklimt.ib.example.net enctypes=3D18,17,16,23,3,1,2 ' (nfsd4_cb/clnt4)
=20
The "target" is the principal of the remote service the server is authenticating to. In full, the target is:
=20
host/[email protected]
=20
The "srchost" is the hostname part of the server's service principal.

Quoted 8 lines
Quoted 8 lines

This
has to match the acceptor string provided by the client, thus the full
source principal has to be:
=20
nfs/[email protected]
=20
gssd uses the service=3D and srchost=3D to select the correct key in =

its

Quoted 21 lines
Quoted 10 lines

keytab when it establishes a GSS context for the callback channel. Without
srchost it would select the key for klimt.example.net, which is the wrong key in this case. Since this commit:
=20
commit f11b2a1cfbf5dd783eb55cb470509d06e20d1c78

Author:     Jeff Layton <[email protected]>
AuthorDate: Sat Jun 21 20:52:17 2014 -0400
Commit:     Trond Myklebust <[email protected]>
CommitDate: Sat Jul 12 18:41:25 2014 -0400
Quoted 11 lines

=20
nfs4: copy acceptor name from context to nfs_client
=20
the client rejects NFSv4.0 callbacks using krb5 with the wrong acceptor
string with "NFSv4 callback contains invalid cred". This occurs _after_
the server has established a GSS context and a connection to the client,
so it has already granted delegations which it now cannot recall. =20

Quoted 6 lines

=20
The above story really does deserve an explanation in the code for the upcall.
Right now, you have to hunt through nested layers of struct copies to figure out that 'target' refers to the service on the server side callback channel for NFSv4.0 only. A second hostname field for the =

same

Quoted 1 line

use case just adds to that confusion.

I can send an additional patch that adds one or more comments = documenting
the function of target=3D, service=3D, and srchost=3D.

--
Chuck Lever

#7 lore raw

Re: [PATCH v2 1/4] sunrpc: Enable the kernel to specify the hostname part of service principals

T24gRnJpLCAyMDE4LTA4LTE3IGF0IDA5OjQzIC0wNDAwLCBDaHVjayBMZXZlciB3cm90ZToNCj4g SSBjYW4gc2VuZCBhbiBhZGRpdGlvbmFsIHBhdGNoIHRoYXQgYWRkcyBvbmUgb3IgbW9yZSBjb21t ZW50cw0KPiBkb2N1bWVudGluZw0KPiB0aGUgZnVuY3Rpb24gb2YgdGFyZ2V0PSwgc2VydmljZT0s IGFuZCBzcmNob3N0PS4NCg0KUGxlYXNlIGRvLg0KDQotLSANClRyb25kIE15a2xlYnVzdA0KTGlu dXggTkZTIGNsaWVudCBtYWludGFpbmVyLCBIYW1tZXJzcGFjZQ0KdHJvbmQubXlrbGVidXN0QGhh bW1lcnNwYWNlLmNvbQ0KDQoNCg==

#8 lore raw

PATCH v2 2/4 sunrpc: Extract target name into svc_cred

In reply to Chuck Lever

NFSv4.0 callback needs to know the GSS target name the client used when it established its lease. That information is available from the GSS context created by gssproxy. Make it available in each svc_cred.

Note this will also give us access to the real target service principal name (which is typically "nfs", but spec does not require that).

---
 fs/nfsd/nfs4state.c                  |    7 ++-
 include/linux/sunrpc/svcauth.h       |    3 +
 net/sunrpc/auth_gss/gss_rpc_upcall.c |   70 ++++++++++++++++++++++------------
 3 files changed, 53 insertions(+), 27 deletions(-)
fs/nfsd/nfs4state.c +5 -2
index 8571414..9d9bc4c 100644
@@ -1979,8 +1979,10 @@ static int copy_cred(struct svc_cred *target, struct svc_cred *source)
 	target->cr_principal = kstrdup(source->cr_principal, GFP_KERNEL);
 	target->cr_raw_principal = kstrdup(source->cr_raw_principal,
 								GFP_KERNEL);
-	if ((source->cr_principal && ! target->cr_principal) ||
-	    (source->cr_raw_principal && ! target->cr_raw_principal))
+	target->cr_targ_princ = kstrdup(source->cr_targ_princ, GFP_KERNEL);
+	if ((source->cr_principal && !target->cr_principal) ||
+	    (source->cr_raw_principal && !target->cr_raw_principal) ||
+	    (source->cr_targ_princ && !target->cr_targ_princ))
 		return -ENOMEM;
 
 	target->cr_flavor = source->cr_flavor;
@@ -2057,6 +2059,7 @@ static bool is_gss_cred(struct svc_cred *cr)
 		|| (!gid_eq(cr1->cr_gid, cr2->cr_gid))
 		|| !groups_equal(cr1->cr_group_info, cr2->cr_group_info))
 		return false;
+	/* XXX: check that cr_targ_princ fields match ? */
 	if (cr1->cr_principal == cr2->cr_principal)
 		return true;
 	if (!cr1->cr_principal || !cr2->cr_principal)
include/linux/sunrpc/svcauth.h +3 -0
index 7c36565..04e404a 100644
@@ -31,6 +31,7 @@ struct svc_cred {
 	/* name of form servicetype@hostname, passed down by
 	 * rpc.svcgssd, or computed from the above: */
 	char			*cr_principal;
+	char			*cr_targ_princ;
 	struct gss_api_mech	*cr_gss_mech;
 };
 
@@ -39,6 +40,7 @@ static inline void init_svc_cred(struct svc_cred *cred)
 	cred->cr_group_info = NULL;
 	cred->cr_raw_principal = NULL;
 	cred->cr_principal = NULL;
+	cred->cr_targ_princ = NULL;
 	cred->cr_gss_mech = NULL;
 }
 
@@ -48,6 +50,7 @@ static inline void free_svc_cred(struct svc_cred *cred)
 		put_group_info(cred->cr_group_info);
 	kfree(cred->cr_raw_principal);
 	kfree(cred->cr_principal);
+	kfree(cred->cr_targ_princ);
 	gss_mech_put(cred->cr_gss_mech);
 	init_svc_cred(cred);
 }
net/sunrpc/auth_gss/gss_rpc_upcall.c +45 -25

109 lines not on this page · raw message

#9 lore raw

PATCH v2 3/4 nfsd: Use correct credential for NFSv4.0 callback with GSS

In reply to Chuck Lever

I've had trouble when operating a multi-homed Linux NFS server with Kerberos using NFSv4.0. Lately, I've seen my clients reporting this (and then hanging):

May  9 11:43:26 manet kernel: NFS: NFSv4 callback contains invalid cred

The client-side commit f11b2a1cfbf5 ("nfs4: copy acceptor name from context to nfs_client") appears to be related, but I suspect this problem has been going on for some time before that.

RFC 7530 Section 3.3.3 says:

Quoted 4 lines

For Kerberos V5, nfs/hostname would be a server principal in the Kerberos Key Distribution Center database. This is the same principal the client acquired a GSS-API context for when it issued the SETCLIENTID operation ...

In other words, an NFSv4.0 client expects that the server will use the same GSS principal for callback that the client used to establish its lease. For example, if the client used the service principal "[email protected]" to establish its lease, the server is required to use "[email protected]" when performing NFSv4.0 callback operations.

The Linux NFS server currently does not. It uses a common service principal for all callback connections. Sometimes this works as expected, and other times -- for example, when the server is accessible via multiple hostnames -- it won't work at all.

This patch scrapes the target name from the client credential, and uses that for the NFSv4.0 callback credential. That should be correct much more often.

---
 fs/nfsd/nfs4callback.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
fs/nfsd/nfs4callback.c +8 -1
index 1f04d2a..0e9ff86 100644
@@ -769,7 +769,14 @@ void cleanup_callback_cred(void)
 static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses)
 {
 	if (clp->cl_minorversion == 0) {
-		return get_rpccred(callback_cred);
+		char *principal = clp->cl_cred.cr_targ_princ ?
+					clp->cl_cred.cr_targ_princ : "nfs";
+		struct rpc_cred *cred;
+
+		cred = rpc_lookup_machine_cred(principal);
+		if (!IS_ERR(cred))
+			get_rpccred(cred);
+		return cred;
 	} else {
 		struct rpc_auth *auth = client->cl_auth;
 		struct auth_cred acred = {};
#10 lore raw

PATCH v2 4/4 nfsd: Remove callback_cred

In reply to Chuck Lever

Clean up: The global callback_cred is no longer used, so it can be removed.

---
 fs/nfsd/nfs4callback.c |   20 --------------------
 fs/nfsd/nfs4state.c    |   10 ++--------
 fs/nfsd/state.h        |    2 --
 3 files changed, 2 insertions(+), 30 deletions(-)
fs/nfsd/nfs4callback.c +0 -20
index 0e9ff86..c088f97 100644
@@ -746,26 +746,6 @@ static int max_cb_time(struct net *net)
 	return max(nn->nfsd4_lease/10, (time_t)1) * HZ;
 }
 
-static struct rpc_cred *callback_cred;
-
-int set_callback_cred(void)
-{
-	if (callback_cred)
-		return 0;
-	callback_cred = rpc_lookup_machine_cred("nfs");
-	if (!callback_cred)
-		return -ENOMEM;
-	return 0;
-}
-
-void cleanup_callback_cred(void)
-{
-	if (callback_cred) {
-		put_rpccred(callback_cred);
-		callback_cred = NULL;
-	}
-}
-
 static struct rpc_cred *get_backchannel_cred(struct nfs4_client *clp, struct rpc_clnt *client, struct nfsd4_session *ses)
 {
 	if (clp->cl_minorversion == 0) {
fs/nfsd/nfs4state.c +2 -8
index 9d9bc4c..b7e68fd 100644
@@ -7202,14 +7202,10 @@ static int nfs4_state_create_net(struct net *net)
 {
 	int ret;
 
-	ret = set_callback_cred();
-	if (ret)
-		return ret;
-
 	laundry_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, "nfsd4");
 	if (laundry_wq == NULL) {
 		ret = -ENOMEM;
-		goto out_cleanup_cred;
+		goto out;
 	}
 	ret = nfsd4_create_callback_queue();
 	if (ret)
@@ -7220,8 +7216,7 @@ static int nfs4_state_create_net(struct net *net)
 
 out_free_laundry:
 	destroy_workqueue(laundry_wq);
-out_cleanup_cred:
-	cleanup_callback_cred();
+out:
 	return ret;
 }
 
@@ -7258,7 +7253,6 @@ static int nfs4_state_create_net(struct net *net)
 {
 	destroy_workqueue(laundry_wq);
 	nfsd4_destroy_callback_queue();
-	cleanup_callback_cred();
 }
 
 static void
fs/nfsd/state.h +0 -2
index f3772ea..0b15dac 100644
@@ -617,8 +617,6 @@ extern struct nfs4_client_reclaim *nfsd4_find_reclaim_client(const char *recdir,
 							struct nfsd_net *nn);
 extern __be32 nfs4_check_open_reclaim(clientid_t *clid,
 		struct nfsd4_compound_state *cstate, struct nfsd_net *nn);
-extern int set_callback_cred(void);
-extern void cleanup_callback_cred(void);
 extern void nfsd4_probe_callback(struct nfs4_client *clp);
 extern void nfsd4_probe_callback_sync(struct nfs4_client *clp);
 extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *);