Skip to content

Commit 89a3c9f

Browse files
chuckleveramschuma-ntap
authored andcommitted
SUNRPC: Properly set the @Subbuf parameter of xdr_buf_subsegment()
@Subbuf is an output parameter of xdr_buf_subsegment(). A survey of call sites shows that @Subbuf is always uninitialized before xdr_buf_segment() is invoked by callers. There are some execution paths through xdr_buf_subsegment() that do not set all of the fields in @Subbuf, leaving some pointer fields containing garbage addresses. Subsequent processing of that buffer then results in a page fault. Signed-off-by: Chuck Lever <[email protected]> Cc: <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent d03727b commit 89a3c9f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/sunrpc/xdr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,7 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
11181118
base = 0;
11191119
} else {
11201120
base -= buf->head[0].iov_len;
1121+
subbuf->head[0].iov_base = buf->head[0].iov_base;
11211122
subbuf->head[0].iov_len = 0;
11221123
}
11231124

@@ -1130,6 +1131,8 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
11301131
base = 0;
11311132
} else {
11321133
base -= buf->page_len;
1134+
subbuf->pages = buf->pages;
1135+
subbuf->page_base = 0;
11331136
subbuf->page_len = 0;
11341137
}
11351138

@@ -1141,6 +1144,7 @@ xdr_buf_subsegment(struct xdr_buf *buf, struct xdr_buf *subbuf,
11411144
base = 0;
11421145
} else {
11431146
base -= buf->tail[0].iov_len;
1147+
subbuf->tail[0].iov_base = buf->tail[0].iov_base;
11441148
subbuf->tail[0].iov_len = 0;
11451149
}
11461150

0 commit comments

Comments
 (0)