SUNRPC: Fix another issue with MIC buffer space
Subsystems (3)
PATCH 1/1 SUNRPC: Fix another issue with MIC buffer space
xdr_shrink_pagelen() BUG's when @len is larger than buf->page_len. This can happen when xdr_buf_read_mic() is given an xdr_buf with a small page array (like, only a few bytes).
Instead, just cap the number of bytes that xdr_shrink_pagelen() will move.
Fixes 5f1bc39979d ("SUNRPC: Fix buffer handling of GSS MIC ... ")
Signed-off-by Chuck Lever <[email protected]>
Reviewed-by Benjamin Coddington <[email protected]>
--- net/sunrpc/xdr.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
Hi Anna-
Just wanted to make sure you have this patch for the upcoming merge window for v5.5.
net/sunrpc/xdr.c +5 -6
@@ -436,13 +436,12 @@ __be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int nbytes) }/** -* xdr_shrink_pagelen +* xdr_shrink_pagelen - shrinks buf->pages by up to @len bytes * @buf: xdr_buf * @len: bytes to remove from buf->pages * -* Shrinks XDR buffer's page array buf->pages by -* 'len' bytes. The extra data is not lost, but is instead -* moved into the tail. +* The extra data is not lost, but is instead moved into buf->tail. +* Returns the actual number of bytes moved. */ static unsigned int xdr_shrink_pagelen (struct xdr_buf *buf,size_t len)
@@ -455,8 +454,8 @@ __be32 *xdr_encode_opaque(__be32 *p, const void *ptr, unsigned int nbytes) result =0 ; tail = buf->tail; -BUG_ON (len > pglen); - +if (len > buf->page_len) + len = buf-> page_len; tailbuf_len = buf->buflen - buf->head->iov_len - buf->page_len;/* Shift the tail first */