Skip to content

Commit 986a4b6

Browse files
committed
SUNRPC: Fix ("SUNRPC: Add "@len" parameter to gss_unwrap()")
Braino when converting "buf->len -=" to "buf->len = len -". The result is under-estimation of the ralign and rslack values. On krb5p mounts, this has caused READDIR to fail with EIO, and KASAN splats when decoding READLINK replies. As a result of fixing this oversight, the gss_unwrap method now returns a buf->len that can be shorter than priv_len for small RPC messages. The additional adjustment done in unwrap_priv_data() can underflow buf->len. This causes the nfsd_request_too_large check to fail during some NFSv3 operations. Reported-by: Marian Rainer-Harbach Reported-by: Pierre Sauter <[email protected]> BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1886277 Fixes: 31c9590 ("SUNRPC: Add "@len" parameter to gss_unwrap()") Reviewed-by: J. Bruce Fields <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent df60446 commit 986a4b6

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

net/sunrpc/auth_gss/gss_krb5_wrap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ gss_unwrap_kerberos_v2(struct krb5_ctx *kctx, int offset, int len,
584584
buf->head[0].iov_len);
585585
memmove(ptr, ptr + GSS_KRB5_TOK_HDR_LEN + headskip, movelen);
586586
buf->head[0].iov_len -= GSS_KRB5_TOK_HDR_LEN + headskip;
587-
buf->len = len - GSS_KRB5_TOK_HDR_LEN + headskip;
587+
buf->len = len - (GSS_KRB5_TOK_HDR_LEN + headskip);
588588

589589
/* Trim off the trailing "extra count" and checksum blob */
590590
xdr_buf_trim(buf, ec + GSS_KRB5_TOK_HDR_LEN + tailskip);

net/sunrpc/auth_gss/svcauth_gss.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,6 @@ unwrap_priv_data(struct svc_rqst *rqstp, struct xdr_buf *buf, u32 seq, struct gs
990990

991991
maj_stat = gss_unwrap(ctx, 0, priv_len, buf);
992992
pad = priv_len - buf->len;
993-
buf->len -= pad;
994993
/* The upper layers assume the buffer is aligned on 4-byte boundaries.
995994
* In the krb5p case, at least, the data ends up offset, so we need to
996995
* move it around. */

0 commit comments

Comments
 (0)