diff options
author | Jeff Layton <jlayton@redhat.com> | 2008-02-06 04:36:43 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-06 13:41:02 -0500 |
commit | ce88cc5ed80de746f5bd2d8242291c87e7b87f63 (patch) | |
tree | ac0c1890d0f741a33c6e2cd41712ae3200bf38ea /fs/smbfs | |
parent | 941e492bdb1239d2ca8f5736cdfd3ff83d00cb90 (diff) |
smbfs: fix calculation of kernel_recvmsg size parameter in smb_receive()
smb_receive calls kernel_recvmsg with a size that's the minimum of the
amount of buffer space in the kvec passed in or req->rq_rlen (which
represents the length of the response). This does not take into account
any data that was read in a request earlier pass through smb_receive.
If the first pass through smb_receive receives some but not all of the
response, then the next pass can call kernel_recvmsg with a size field
that's too big. kernel_recvmsg can overrun into the next response,
throwing off the alignment and making it unrecognizable.
This causes messages like this to pop up in the ring buffer:
smb_get_length: Invalid NBT packet, code=69
as well as other errors indicating that the response is unrecognizable.
Typically this is seen on a smbfs mount under heavy I/O.
This patch changes the code to use (req->rq_rlen - req->rq_bytes_recvd)
instead instead of just req->rq_rlen, since that should represent the
amount of unread data in the response.
I think this is correct, but an ACK or NACK from someone more familiar
with this code would be appreciated...
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/smbfs')
-rw-r--r-- | fs/smbfs/sock.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/smbfs/sock.c b/fs/smbfs/sock.c index e48bd8235a8e..e37fe4deebd0 100644 --- a/fs/smbfs/sock.c +++ b/fs/smbfs/sock.c | |||
@@ -329,9 +329,8 @@ smb_receive(struct smb_sb_info *server, struct smb_request *req) | |||
329 | msg.msg_control = NULL; | 329 | msg.msg_control = NULL; |
330 | 330 | ||
331 | /* Dont repeat bytes and count available bufferspace */ | 331 | /* Dont repeat bytes and count available bufferspace */ |
332 | rlen = smb_move_iov(&p, &num, iov, req->rq_bytes_recvd); | 332 | rlen = min_t(int, smb_move_iov(&p, &num, iov, req->rq_bytes_recvd), |
333 | if (req->rq_rlen < rlen) | 333 | (req->rq_rlen - req->rq_bytes_recvd)); |
334 | rlen = req->rq_rlen; | ||
335 | 334 | ||
336 | result = kernel_recvmsg(sock, &msg, p, num, rlen, flags); | 335 | result = kernel_recvmsg(sock, &msg, p, num, rlen, flags); |
337 | 336 | ||