SUNRPC: fix sign error causing rpcsec_gss drops
Subsystems (3)
PATCH 1/1 SUNRPC: fix sign error causing rpcsec_gss drops
From: "J. Bruce Fields" <[email protected]>
If sd_max is unsigned, then sd_max - GSS_SEQ_WIN is a very large number whenever sd_max is less than GSS_SEQ_WIN, and the comparison:
seq_num <= sd->sd_max - GSS_SEQ_WIN
in gss_check_seq_num is pretty much always true, even when that's clearly not what was intended.
This was causing pynfs to hang when using krb5, because pynfs uses zero as the initial gss sequence number. That's perfectly legal, but this logic error causes knfsd to drop the rpc in that case. Out-of-order sequence IDs in the first GSS_SEQ_WIN (128) calls will also cause this.
--- net/sunrpc/auth_gss/svcauth_gss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sunrpc/auth_gss/svcauth_gss.c +1 -1
@@ -645,7 +645,7 @@ static bool gss_check_seq_num(const struct svc_rqst *rqstp, struct rsc *rsci, }__set_bit (seq_num %GSS_SEQ_WIN , sd->sd_win); goto ok; - }else if (seq_num <= sd->sd_max -GSS_SEQ_WIN ) { + }else if (seq_num +GSS_SEQ_WIN <= sd->sd_max) { goto toolow; }if (__test_and_set_bit (seq_num %GSS_SEQ_WIN , sd->sd_win))
Signature · 1 line
2.31.1
Quoted 14 lines · J. Bruce Fields
From: "J. Bruce Fields" <[email protected]>
If
sd_maxis unsigned, thensd_max-GSS_SEQ_WINis a very large number wheneversd_maxis less thanGSS_SEQ_WIN, and the comparison:seq_num <= sd->sd_max - GSS_SEQ_WINin
gss_check_seq_numis pretty much always true, even when that's clearly not what was intended.
Quoted 8 lines
This was causing pynfs to hang when using krb5, because pynfs uses zero as the initial gss sequence number. That's perfectly legal, but this logic error causes knfsd to drop the rpc in that case. Out-of-order sequence IDs in the first
GSS_SEQ_WIN(128) calls will also cause this.Fixes 10b9d99a3dbb ("SUNRPC: Augment server-side rpcgss tracepoints")Signed-off-by J. Bruce Fields <[email protected]>
This will be included in the next NFSD 5.15-rc. Thanks! See the for-next branch at
git://git.kernel.org/pub/scm/linux/kernel/git/cel/linux.git
Quoted 20 lines
---
net/sunrpc/auth_gss/svcauth_gss.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)net/sunrpc/auth_gss/svcauth_gss.c +1
-1@@ -645,7 +645,7 @@ static bool gss_check_seq_num(const struct svc_rqst *rqstp, struct rsc *rsci, }__set_bit (seq_num %GSS_SEQ_WIN , sd->sd_win); goto ok; - }else if (seq_num <= sd->sd_max -GSS_SEQ_WIN ) { + }else if (seq_num +GSS_SEQ_WIN <= sd->sd_max) { goto toolow; }if (__test_and_set_bit (seq_num %GSS_SEQ_WIN , sd->sd_win))Signature · 1 line
2.31.1
--
Chuck Lever
Hi Bruce!
Am 01.10.21 um 15:59 schrieb J. Bruce Fields:
Quoted 10 lines
From: "J. Bruce Fields" <[email protected]>
If
sd_maxis unsigned, thensd_max-GSS_SEQ_WINis a very large number wheneversd_maxis less thanGSS_SEQ_WIN, and the comparison:seq_num <= sd->sd_max - GSS_SEQ_WINin
gss_check_seq_numis pretty much always true, even when that's clearly not what was intended.
Quoted 6 lines
This was causing pynfs to hang when using krb5, because pynfs uses zero as the initial gss sequence number. That's perfectly legal, but this logic error causes knfsd to drop the rpc in that case. Out-of-order sequence IDs in the first
GSS_SEQ_WIN(128) calls will also cause this.Fixes 10b9d99a3dbb ("SUNRPC: Augment server-side rpcgss tracepoints")
I wonder about the Fixes tag: That changeset added tracepoints to the exit path, but the buggy logic seems to have been present since the pre-git ages. Or am I missing something about 10b9d99a3dbb? (This might explain some reports of--as you stated elsewhere--"once in a blue moon my krb5 mounts hang" we've investigated, albeit on kernels that predate 10b9d99a3dbb.)
Kind regards,
Daniel
Quoted 20 lines
Signed-off-by J. Bruce Fields <[email protected]>--- net/sunrpc/auth_gss/svcauth_gss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)net/sunrpc/auth_gss/svcauth_gss.c +1
-1@@ -645,7 +645,7 @@ static bool gss_check_seq_num(const struct svc_rqst *rqstp, struct rsc *rsci, }__set_bit (seq_num %GSS_SEQ_WIN , sd->sd_win); goto ok; - }else if (seq_num <= sd->sd_max -GSS_SEQ_WIN ) { + }else if (seq_num +GSS_SEQ_WIN <= sd->sd_max) { goto toolow; }if (__test_and_set_bit (seq_num %GSS_SEQ_WIN , sd->sd_win))
Signature · 14 lines
Daniel Kobras Principal Architect Puzzle ITC Deutschland +49 7071 14316 0 www.puzzle-itc.de -- Puzzle ITC Deutschland GmbH Sitz der Gesellschaft: Eisenbahnstraße 1, 72072 Tübingen Eingetragen am Amtsgericht Stuttgart HRB 765802 Geschäftsführer: Lukas Kallies, Daniel Kobras, Mark Pröhl
Quoted 18 lines · Daniel Kobras
Hi Bruce!
Am 01.10.21 um 15:59 schrieb J. Bruce Fields:
Quoted 15 lines
From: "J. Bruce Fields" <[email protected]>
If
sd_maxis unsigned, thensd_max-GSS_SEQ_WINis a very large number wheneversd_maxis less thanGSS_SEQ_WIN, and the comparison:seq_num <= sd->sd_max - GSS_SEQ_WINin
gss_check_seq_numis pretty much always true, even when that's clearly not what was intended.This was causing pynfs to hang when using krb5, because pynfs uses zero as the initial gss sequence number. That's perfectly legal, but this logic error causes knfsd to drop the rpc in that case. Out-of-order sequence IDs in the first
GSS_SEQ_WIN(128) calls will also cause this.
Quoted 5 lines
Quoted 1 line
Fixes 10b9d99a3dbb ("SUNRPC: Augment server-side rpcgss tracepoints")I wonder about the Fixes tag: That changeset added tracepoints to the exit path, but the buggy logic seems to have been present since the pre-git ages. Or am I missing something about
10b9d99a3dbb?
The relevant parts of 10b9d99a3dbb were:
struct gss_svc_seq_data {
/* highest seq number seen so far: */
- int sd_max;
+ u32 sd_max;and
-gss_check_seq_num(struct rsc *rsci, int seq_num)
+static bool gss_check_seq_num(const struct svc_rqst *rqstp, struct rsc *rsci,
+ u32 seq_num)
Together, they mean the comparison
seq_num <= sd->sd_max - GSS_SEQ_WIN
in the case sd_max is zero, effectively ends up being
seq_num <= 4294967168
instead of what was intended,
seq_num <= -128
.
Quoted 3 lines
(This might explain some reports of--as you stated elsewhere--"once in a blue moon my krb5 mounts hang" we've investigated, albeit on kernels that predate
10b9d99a3dbb.)
Sounds like it was something else, I'm afraid!
--b.
Hi Bruce!
Am 01.10.21 um 19:44 schrieb J. Bruce Fields:
Quoted 42 lines · Daniel Kobras
Quoted 16 lines
Am 01.10.21 um 15:59 schrieb J. Bruce Fields:
Quoted 15 lines
From: "J. Bruce Fields" <[email protected]>
If
sd_maxis unsigned, thensd_max-GSS_SEQ_WINis a very large number wheneversd_maxis less thanGSS_SEQ_WIN, and the comparison:seq_num <= sd->sd_max - GSS_SEQ_WINin
gss_check_seq_numis pretty much always true, even when that's clearly not what was intended.This was causing pynfs to hang when using krb5, because pynfs uses zero as the initial gss sequence number. That's perfectly legal, but this logic error causes knfsd to drop the rpc in that case. Out-of-order sequence IDs in the first
GSS_SEQ_WIN(128) calls will also cause this.Quoted 5 lines
Quoted 1 line
Fixes 10b9d99a3dbb ("SUNRPC: Augment server-side rpcgss tracepoints")I wonder about the Fixes tag: That changeset added tracepoints to the exit path, but the buggy logic seems to have been present since the pre-git ages. Or am I missing something about
10b9d99a3dbb?The relevant parts of
10b9d99a3dbbwere:struct gss_svc_seq_data { /* highest seq number seen so far: */(quoted diff) +1
-1- int sd_max; + u32 sd_max;and
(quoted diff) +2
-1-gss_check_seq_num(struct rsc *rsci, int seq_num) +static bool gss_check_seq_num(const struct svc_rqst *rqstp, struct rsc *rsci, + u32 seq_num)Together, they mean the comparison
seq_num <= sd->sd_max - GSS_SEQ_WINin the case
sd_maxis zero, effectively ends up being
Quoted 7 lines
seq_num <= 4294967168instead of what was intended,
seq_num <= -128.
Sorry, indeed I had missed the change in signedness. Thanks for elaborating!
Quoted 5 lines
Quoted 3 lines
(This might explain some reports of--as you stated elsewhere--"once in a blue moon my krb5 mounts hang" we've investigated, albeit on kernels that predate
10b9d99a3dbb.)Sounds like it was something else, I'm afraid!
Darn! ;-)
Kind regards,
Daniel
Signature · 14 lines
Daniel Kobras Principal Architect Puzzle ITC Deutschland +49 7071 14316 0 www.puzzle-itc.de -- Puzzle ITC Deutschland GmbH Sitz der Gesellschaft: Eisenbahnstraße 1, 72072 Tübingen Eingetragen am Amtsgericht Stuttgart HRB 765802 Geschäftsführer: Lukas Kallies, Daniel Kobras, Mark Pröhl