]> git.baikalelectronics.ru Git - kernel.git/commitdiff
SUNRPC: fix sign error causing rpcsec_gss drops
authorJ. Bruce Fields <bfields@redhat.com>
Fri, 1 Oct 2021 13:59:21 +0000 (09:59 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Fri, 1 Oct 2021 15:17:42 +0000 (11:17 -0400)
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.

Fixes: 20c1fddd8e36 ("SUNRPC: Augment server-side rpcgss tracepoints")
Cc: stable@vger.kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/auth_gss/svcauth_gss.c

index 475a965b7b439fc90e10bcf8027ea8d5451364de..1ea82a2e63af01687edf8a314fa4d01b9f978d6d 100644 (file)
@@ -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))