mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] cifs: fix bad buffer length check in coalesce_t2
@ 2012-01-01 15:34 Jeff Layton
       [not found] ` <CAH2r5msQU=_2X799oGt1MeuejSQX2HLLW4-FgnXqg6DXHwTTZA@mail.gmail.com>
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jeff Layton @ 2012-01-01 15:34 UTC (permalink / raw)
  To: smfrench; +Cc: linux-cifs, linux-kernel, k.skarlatos, shirishpargaonkar

The current check looks to see if the RFC1002 length is larger than
CIFSMaxBufSize, and fails if it is. The buffer is actually larger than
that by MAX_CIFS_HDR_SIZE.

This bug has been around for a long time, but the fact that we used to
cap the clients MaxBufferSize at the same level as the server tended
to paper over it. Commit c974befa changed that however and caused this
bug to bite in more cases.

Reported-and-Tested-by: Konstantinos Skarlatos <k.skarlatos@gmail.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/cifs/connect.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 8cd4b52..27c4f25 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -282,7 +282,7 @@ static int coalesce_t2(struct smb_hdr *psecond, struct smb_hdr *pTargetSMB)
 	byte_count = be32_to_cpu(pTargetSMB->smb_buf_length);
 	byte_count += total_in_buf2;
 	/* don't allow buffer to overflow */
-	if (byte_count > CIFSMaxBufSize)
+	if (byte_count > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4)
 		return -ENOBUFS;
 	pTargetSMB->smb_buf_length = cpu_to_be32(byte_count);
 
-- 
1.7.7.4


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-04 16:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-01 15:34 [PATCH] cifs: fix bad buffer length check in coalesce_t2 Jeff Layton
     [not found] ` <CAH2r5msQU=_2X799oGt1MeuejSQX2HLLW4-FgnXqg6DXHwTTZA@mail.gmail.com>
2012-01-02 11:09   ` Jeff Layton
2012-01-03 16:22 ` Shirish Pargaonkar
2012-01-03 22:46 ` Shirish Pargaonkar
2012-01-04 14:09   ` Jeff Layton
2012-01-04 15:08     ` Shirish Pargaonkar
2012-01-04 16:14     ` Steve French
2012-01-04 16:29       ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®