Skip to contentSkip to conversation

Buffer overflow in CIFS VFS.

DISCUSSION Przemyslaw Wegrzyn 2 participants 2 messages Nov 8, 2007

lore
Share & tools
lore
#0 lore raw

Hello all,

I was looking at CIFS VFS code recently, trying to solve other issue, just to find something that looks like a buffer overflow bug. The problem is in SendReceive() function in transport.c - it memcpy's message payload into a buffer passed via out_buf param. The function assumes that all buffers are of size (CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) , unfortunately it is also called with smaller (MAX_CIFS_SMALL_BUFFER_SIZE) buffers.

To check this finding I patched Samba server to send oversized logoffX messages. With ~ 16kB messages the client running 2.6.23.1 crashed upon unmounting.

I've done a quick fix, available here:
http://czajnick.sitenet.pl/cifs-buffer-overflow-fix.patch.gz

#1 lore raw

Not everyone has the time to read lkml. Added Steve to Cc:, just in case.

Quoted 9 lines · Przemyslaw Wegrzyn

I was looking at CIFS VFS code recently, trying to solve other issue, just to find something that looks like a buffer overflow bug. The problem is in SendReceive() function in transport.c - it memcpy's message payload into a buffer passed via out_buf param. The function assumes that all buffers are of size (CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) , unfortunately it is also called with smaller (MAX_CIFS_SMALL_BUFFER_SIZE) buffers.

Quoted 6 lines

To check this finding I patched Samba server to send oversized logoffX messages. With ~ 16kB messages the client running 2.6.23.1 crashed upon unmounting.

I've done a quick fix, available here:
http://czajnick.sitenet.pl/cifs-buffer-overflow-fix.patch.gz

Jörn

Signature · 3 lines
When in doubt, punt.  When somebody actually complains, go back and fix it...
The 90% solution is a good thing.
-- Rob Landley