Skip to content

Commit e8d70b3

Browse files
chuckleverTrond Myklebust
authored andcommitted
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: 5f1bc39 ("SUNRPC: Fix buffer handling of GSS MIC ... ") Signed-off-by: Chuck Lever <[email protected]> Reviewed-by: Benjamin Coddington <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 21f86d2 commit e8d70b3

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

net/sunrpc/xdr.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,12 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len)
436436
}
437437

438438
/**
439-
* xdr_shrink_pagelen
439+
* xdr_shrink_pagelen - shrinks buf->pages by up to @len bytes
440440
* @buf: xdr_buf
441441
* @len: bytes to remove from buf->pages
442442
*
443-
* Shrinks XDR buffer's page array buf->pages by
444-
* 'len' bytes. The extra data is not lost, but is instead
445-
* moved into the tail.
443+
* The extra data is not lost, but is instead moved into buf->tail.
444+
* Returns the actual number of bytes moved.
446445
*/
447446
static unsigned int
448447
xdr_shrink_pagelen(struct xdr_buf *buf, size_t len)
@@ -455,8 +454,8 @@ xdr_shrink_pagelen(struct xdr_buf *buf, size_t len)
455454

456455
result = 0;
457456
tail = buf->tail;
458-
BUG_ON (len > pglen);
459-
457+
if (len > buf->page_len)
458+
len = buf-> page_len;
460459
tailbuf_len = buf->buflen - buf->head->iov_len - buf->page_len;
461460

462461
/* Shift the tail first */

0 commit comments

Comments
 (0)